1. 05 5月, 2021 1 次提交
  2. 04 5月, 2021 1 次提交
  3. 26 4月, 2021 4 次提交
    • A
      cifs: allocate buffer in the caller of build_path_from_dentry() · f6a9bc33
      Al Viro 提交于
      build_path_from_dentry() open-codes dentry_path_raw().  The reason
      we can't use dentry_path_raw() in there (and postprocess the
      result as needed) is that the callers of build_path_from_dentry()
      expect that the object to be freed on cleanup and the string to
      be used are at the same address.  That's painful, since the path
      is naturally built end-to-beginning - we start at the leaf and
      go through the ancestors, accumulating the pathname.
      
      Life would be easier if we left the buffer allocation to callers.
      It wouldn't be exact-sized buffer, but none of the callers keep
      the result for long - it's always freed before the caller returns.
      So there's no need to do exact-sized allocation; better use
      __getname()/__putname(), same as we do for pathname arguments
      of syscalls.  What's more, there's no need to do allocation under
      spinlocks, so GFP_ATOMIC is not needed.
      
      Next patch will replace the open-coded dentry_path_raw() (in
      build_path_from_dentry_optional_prefix()) with calling the real
      thing.  This patch only introduces wrappers for allocating/freeing
      the buffers and switches to new calling conventions:
      	build_path_from_dentry(dentry, buf)
      expects buf to be address of a page-sized object or NULL,
      return value is a pathname built inside that buffer on success,
      ERR_PTR(-ENOMEM) if buf is NULL and ERR_PTR(-ENAMETOOLONG) if
      the pathname won't fit into page.  Note that we don't need to
      check for failure when allocating the buffer in the caller -
      build_path_from_dentry() will do the right thing.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      f6a9bc33
    • A
      cifs: make build_path_from_dentry() return const char * · 8e33cf20
      Al Viro 提交于
      ... and adjust the callers.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      8e33cf20
    • A
      f6f1f179
    • A
      cifs: remove old dead code · ec4e4862
      Aurelien Aptel 提交于
      While reviewing a patch clarifying locks and locking hierarchy I
      realized some locks were unused.
      
      This commit removes old data and code that isn't actually used
      anywhere, or hidden in ifdefs which cannot be enabled from the kernel
      config.
      
      * The uid/gid trees and associated locks are left-overs from when
        uid/sid mapping had an extra caching layer on top of the keyring and
        are now unused.
        See commit faa65f07 ("cifs: simplify id_to_sid and sid_to_id mapping code")
        from 2012.
      
      * cifs_oplock_break_ops is a left-over from when slow_work was remplaced
        by regular workqueue and is now unused.
        See commit 9b646972 ("cifs: use workqueue instead of slow-work")
        from 2010.
      
      * CIFSSMBSetAttrLegacy is SMB1 cruft dealing with some legacy
        NT4/Win9x behaviour.
      
      * Remove CONFIG_CIFS_DNOTIFY_EXPERIMENTAL left-overs. This was already
        partially removed in 392e1c5d ("cifs: rename and clarify CIFS_ASYNC_OP and CIFS_NO_RESP")
        from 2019. Kill it completely.
      
      * Another candidate that was considered but spared is
        CONFIG_CIFS_NFSD_EXPORT which has an empty implementation and cannot
        be enabled by a config option (although it is listed but disabled with
        "BROKEN" as a dep). It's unclear whether this could even function
        today in its current form but it has it's own .c file and Kconfig
        entry which is a bit more involved to remove and might make a come
        back?
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      ec4e4862
  4. 26 2月, 2021 1 次提交
  5. 29 1月, 2021 1 次提交
  6. 19 12月, 2020 1 次提交
  7. 14 12月, 2020 10 次提交
  8. 21 10月, 2020 1 次提交
  9. 03 8月, 2020 4 次提交
  10. 13 6月, 2020 1 次提交
  11. 12 6月, 2020 1 次提交
  12. 05 6月, 2020 2 次提交
    • A
      cifs: multichannel: try to rebind when reconnecting a channel · 2f589679
      Aurelien Aptel 提交于
      first steps in trying to make channels properly reconnect.
      
      * add cifs_ses_find_chan() function to find the enclosing cifs_chan
        struct it belongs to
      * while we have the session lock and are redoing negprot and
        sess.setup in smb2_reconnect() redo the binding of channels.
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      2f589679
    • A
      cifs: multichannel: move channel selection above transport layer · 352d96f3
      Aurelien Aptel 提交于
      Move the channel (TCP_Server_Info*) selection from the tranport
      layer to higher in the call stack so that:
      
      - credit handling is done with the server that will actually be used
        to send.
        * ->wait_mtu_credit
        * ->set_credits / set_credits
        * ->add_credits / add_credits
        * add_credits_and_wake_if
      
      - potential reconnection (smb2_reconnect) done when initializing a
        request is checked and done with the server that will actually be
        used to send.
      
      To do this:
      
      - remove the cifs_pick_channel() call out of compound_send_recv()
      
      - select channel and pass it down by adding a cifs_pick_channel(ses)
        call in:
        - smb311_posix_mkdir
        - SMB2_open
        - SMB2_ioctl
        - __SMB2_close
        - query_info
        - SMB2_change_notify
        - SMB2_flush
        - smb2_async_readv  (if none provided in context param)
        - SMB2_read         (if none provided in context param)
        - smb2_async_writev (if none provided in context param)
        - SMB2_write        (if none provided in context param)
        - SMB2_query_directory
        - send_set_info
        - SMB2_oplock_break
        - SMB311_posix_qfs_info
        - SMB2_QFS_info
        - SMB2_QFS_attr
        - smb2_lockv
        - SMB2_lease_break
          - smb2_compound_op
        - smb2_set_ea
        - smb2_ioctl_query_info
        - smb2_query_dir_first
        - smb2_query_info_comound
        - smb2_query_symlink
        - cifs_writepages
        - cifs_write_from_iter
        - cifs_send_async_read
        - cifs_read
        - cifs_readpages
      
      - add TCP_Server_Info *server param argument to:
        - cifs_send_recv
        - compound_send_recv
        - SMB2_open_init
        - SMB2_query_info_init
        - SMB2_set_info_init
        - SMB2_close_init
        - SMB2_ioctl_init
        - smb2_iotcl_req_init
        - SMB2_query_directory_init
        - SMB2_notify_init
        - SMB2_flush_init
        - build_qfs_info_req
        - smb2_hdr_assemble
        - smb2_reconnect
        - fill_small_buf
        - smb2_plain_req_init
        - __smb2_plain_req_init
      
      The read/write codepath is different than the rest as it is using
      pages, io iterators and async calls. To deal with those we add a
      server pointer in the cifs_writedata/cifs_readdata/cifs_io_parms
      context struct and set it in:
      
      - cifs_writepages      (wdata)
      - cifs_write_from_iter (wdata)
      - cifs_readpages       (rdata)
      - cifs_send_async_read (rdata)
      
      The [rw]data->server pointer is eventually copied to
      cifs_io_parms->server to pass it down to SMB2_read/SMB2_write.
      If SMB2_read/SMB2_write is called from a different place that doesn't
      set the server field it will pick a channel.
      
      Some places do not pick a channel and just use ses->server or
      cifs_ses_server(ses). All cifs_ses_server(ses) calls are in codepaths
      involving negprot/sess.setup.
      
      - SMB2_negotiate         (binding channel)
      - SMB2_sess_alloc_buffer (binding channel)
      - SMB2_echo              (uses provided one)
      - SMB2_logoff            (uses master)
      - SMB2_tdis              (uses master)
      
      (list not exhaustive)
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      352d96f3
  13. 02 6月, 2020 1 次提交
  14. 01 6月, 2020 2 次提交
    • J
      cifs: Standardize logging output · a0a3036b
      Joe Perches 提交于
      Use pr_fmt to standardize all logging for fs/cifs.
      
      Some logging output had no CIFS: specific prefix.
      
      Now all output has one of three prefixes:
      
      o CIFS:
      o CIFS: VFS:
      o Root-CIFS:
      
      Miscellanea:
      
      o Convert printks to pr_<level>
      o Neaten macro definitions
      o Remove embedded CIFS: prefixes from formats
      o Convert "illegal" to "invalid"
      o Coalesce formats
      o Add missing '\n' format terminations
      o Consolidate multiple cifs_dbg continuations into single calls
      o More consistent use of upper case first word output logging
      o Multiline statement argument alignment and wrapping
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      a0a3036b
    • P
      cifs: handle hostnames that resolve to same ip in failover · e4af35fa
      Paulo Alcantara 提交于
      In order to support reconnect to hostnames that resolve to same ip
      address, besides relying on the currently set hostname to match DFS
      targets, attempt to resolve the targets and then match their addresses
      with the reconnected server ip address.
      
      For instance, if we have two hostnames "FOO" and "BAR", and both
      resolve to the same ip address, we would be able to handle failover in
      DFS paths like
      
          \\FOO\dfs\link1 -> [ \BAZ\share2 (*), \BAR\share1 ]
          \\FOO\dfs\link2 -> [ \BAZ\share2 (*), \FOO\share1 ]
      
      so when "BAZ" is no longer accessible, link1 and link2 would get
      reconnected despite having different target hostnames.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      e4af35fa
  15. 23 3月, 2020 1 次提交
  16. 25 2月, 2020 1 次提交
    • A
      cifs: fix rename() by ensuring source handle opened with DELETE bit · 86f740f2
      Aurelien Aptel 提交于
      To rename a file in SMB2 we open it with the DELETE access and do a
      special SetInfo on it. If the handle is missing the DELETE bit the
      server will fail the SetInfo with STATUS_ACCESS_DENIED.
      
      We currently try to reuse any existing opened handle we have with
      cifs_get_writable_path(). That function looks for handles with WRITE
      access but doesn't check for DELETE, making rename() fail if it finds
      a handle to reuse. Simple reproducer below.
      
      To select handles with the DELETE bit, this patch adds a flag argument
      to cifs_get_writable_path() and find_writable_file() and the existing
      'bool fsuid_only' argument is converted to a flag.
      
      The cifsFileInfo struct only stores the UNIX open mode but not the
      original SMB access flags. Since the DELETE bit is not mapped in that
      mode, this patch stores the access mask in cifs_fid on file open,
      which is accessible from cifsFileInfo.
      
      Simple reproducer:
      
      	#include <stdio.h>
      	#include <stdlib.h>
      	#include <sys/types.h>
      	#include <sys/stat.h>
      	#include <fcntl.h>
      	#include <unistd.h>
      	#define E(s) perror(s), exit(1)
      
      	int main(int argc, char *argv[])
      	{
      		int fd, ret;
      		if (argc != 3) {
      			fprintf(stderr, "Usage: %s A B\n"
      			"create&open A in write mode, "
      			"rename A to B, close A\n", argv[0]);
      			return 0;
      		}
      
      		fd = openat(AT_FDCWD, argv[1], O_WRONLY|O_CREAT|O_SYNC, 0666);
      		if (fd == -1) E("openat()");
      
      		ret = rename(argv[1], argv[2]);
      		if (ret) E("rename()");
      
      		ret = close(fd);
      		if (ret) E("close()");
      
      		return ret;
      	}
      
      $ gcc -o bugrename bugrename.c
      $ ./bugrename /mnt/a /mnt/b
      rename(): Permission denied
      
      Fixes: 8de9e86c ("cifs: create a helper to find a writeable handle by path name")
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      86f740f2
  17. 05 2月, 2020 1 次提交
  18. 04 2月, 2020 1 次提交
  19. 27 1月, 2020 2 次提交
  20. 07 12月, 2019 1 次提交
  21. 25 11月, 2019 2 次提交
    • A
      cifs: try opening channels after mounting · d70e9fa5
      Aurelien Aptel 提交于
      After doing mount() successfully we call cifs_try_adding_channels()
      which will open as many channels as it can.
      
      Channels are closed when the master session is closed.
      
      The master connection becomes the first channel.
      
      ,-------------> global cifs_tcp_ses_list <-------------------------.
      |                                                                  |
      '- TCP_Server_Info  <-->  TCP_Server_Info  <-->  TCP_Server_Info <-'
            (master con)           (chan#1 con)         (chan#2 con)
            |      ^                    ^                    ^
            v      '--------------------|--------------------'
         cifs_ses                       |
         - chan_count = 3               |
         - chans[] ---------------------'
         - smb3signingkey[]
            (master signing key)
      
      Note how channel connections don't have sessions. That's because
      cifs_ses can only be part of one linked list (list_head are internal
      to the elements).
      
      For signing keys, each channel has its own signing key which must be
      used only after the channel has been bound. While it's binding it must
      use the master session signing key.
      
      For encryption keys, since channel connections do not have sessions
      attached we must now find matching session by looping over all sessions
      in smb2_get_enc_key().
      
      Each channel is opened like a regular server connection but at the
      session setup request step it must set the
      SMB2_SESSION_REQ_FLAG_BINDING flag and use the session id to bind to.
      
      Finally, while sending in compound_send_recv() for requests that
      aren't negprot, ses-setup or binding related, use a channel by cycling
      through the available ones (round-robin).
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      d70e9fa5
    • A
      cifs: add server param · f780bd3f
      Aurelien Aptel 提交于
      As we get down to the transport layer, plenty of functions are passed
      the session pointer and assume the transport to use is ses->server.
      
      Instead we modify those functions to pass (ses, server) so that we
      can decouple the session from the server.
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      f780bd3f