1. 05 6月, 2020 2 次提交
  2. 04 6月, 2020 2 次提交
  3. 02 6月, 2020 3 次提交
  4. 01 6月, 2020 10 次提交
  5. 15 5月, 2020 1 次提交
  6. 14 5月, 2020 1 次提交
  7. 06 5月, 2020 1 次提交
  8. 23 4月, 2020 3 次提交
    • P
      cifs: fix uninitialised lease_key in open_shroot() · 0fe0781f
      Paulo Alcantara 提交于
      SMB2_open_init() expects a pre-initialised lease_key when opening a
      file with a lease, so set pfid->lease_key prior to calling it in
      open_shroot().
      
      This issue was observed when performing some DFS failover tests and
      the lease key was never randomly generated.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      CC: Stable <stable@vger.kernel.org>
      0fe0781f
    • P
      cifs: ensure correct super block for DFS reconnect · 3786f4bd
      Paulo Alcantara 提交于
      This patch is basically fixing the lookup of tcons (DFS specific) during
      reconnect (smb2pdu.c:__smb2_reconnect) to update their prefix paths.
      
      Previously, we relied on the TCP_Server_Info pointer
      (misc.c:tcp_super_cb) to determine which tcon to update the prefix path
      
      We could not rely on TCP server pointer to determine which super block
      to update the prefix path when reconnecting tcons since it might map
      to different tcons that share same TCP connection.
      
      Instead, walk through all cifs super blocks and compare their DFS full
      paths with the tcon being updated to.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      3786f4bd
    • P
      cifs: do not share tcons with DFS · 65303de8
      Paulo Alcantara 提交于
      This disables tcon re-use for DFS shares.
      
      tcon->dfs_path stores the path that the tcon should connect to when
      doing failing over.
      
      If that tcon is used multiple times e.g. 2 mounts using it with
      different prefixpath, each will need a different dfs_path but there is
      only one tcon. The other solution would be to split the tcon in 2
      tcons during failover but that is much harder.
      
      tcons could not be shared with DFS in cifs.ko because in a
      DFS namespace like:
      
                //domain/dfsroot -> /serverA/dfsroot, /serverB/dfsroot
      
                //serverA/dfsroot/link -> /serverA/target1/aa/bb
      
                //serverA/dfsroot/link2 -> /serverA/target1/cc/dd
      
      you can see that link and link2 are two DFS links that both resolve to
      the same target share (/serverA/target1), so cifs.ko will only contain a
      single tcon for both link and link2.
      
      The problem with that is, if we (auto)mount "link" and "link2", cifs.ko
      will only contain a single tcon for both DFS links so we couldn't
      perform failover or refresh the DFS cache for both links because
      tcon->dfs_path was set to either "link" or "link2", but not both --
      which is wrong.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      65303de8
  9. 22 4月, 2020 1 次提交
  10. 21 4月, 2020 1 次提交
  11. 17 4月, 2020 1 次提交
  12. 16 4月, 2020 2 次提交
    • J
      cifs: improve read performance for page size 64KB & cache=strict & vers=2.1+ · 1f641d94
      Jones Syue 提交于
      Found a read performance issue when linux kernel page size is 64KB.
      If linux kernel page size is 64KB and mount options cache=strict &
      vers=2.1+, it does not support cifs_readpages(). Instead, it is using
      cifs_readpage() and cifs_read() with maximum read IO size 16KB, which is
      much slower than read IO size 1MB when negotiated SMB 2.1+. Since modern
      SMB server supported SMB 2.1+ and Max Read Size can reach more than 64KB
      (for example 1MB ~ 8MB), this patch check max_read instead of maxBuf to
      determine whether server support readpages() and improve read performance
      for page size 64KB & cache=strict & vers=2.1+, and for SMB1 it is more
      cleaner to initialize server->max_read to server->maxBuf.
      
      The client is a linux box with linux kernel 4.2.8,
      page size 64KB (CONFIG_ARM64_64K_PAGES=y),
      cpu arm 1.7GHz, and use mount.cifs as smb client.
      The server is another linux box with linux kernel 4.2.8,
      share a file '10G.img' with size 10GB,
      and use samba-4.7.12 as smb server.
      
      The client mount a share from the server with different
      cache options: cache=strict and cache=none,
      mount -tcifs //<server_ip>/Public /cache_strict -overs=3.0,cache=strict,username=<xxx>,password=<yyy>
      mount -tcifs //<server_ip>/Public /cache_none -overs=3.0,cache=none,username=<xxx>,password=<yyy>
      
      The client download a 10GbE file from the server across 1GbE network,
      dd if=/cache_strict/10G.img of=/dev/null bs=1M count=10240
      dd if=/cache_none/10G.img of=/dev/null bs=1M count=10240
      
      Found that cache=strict (without patch) is slower read throughput and
      smaller read IO size than cache=none.
      cache=strict (without patch): read throughput 40MB/s, read IO size is 16KB
      cache=strict (with patch): read throughput 113MB/s, read IO size is 1MB
      cache=none: read throughput 109MB/s, read IO size is 1MB
      
      Looks like if page size is 64KB,
      cifs_set_ops() would use cifs_addr_ops_smallbuf instead of cifs_addr_ops,
      
      	/* check if server can support readpages */
      	if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf <
      			PAGE_SIZE + MAX_CIFS_HDR_SIZE)
      		inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
      	else
      		inode->i_data.a_ops = &cifs_addr_ops;
      
      maxBuf is came from 2 places, SMB2_negotiate() and CIFSSMBNegotiate(),
      (SMB2_MAX_BUFFER_SIZE is 64KB)
      SMB2_negotiate():
      	/* set it to the maximum buffer size value we can send with 1 credit */
      	server->maxBuf = min_t(unsigned int, le32_to_cpu(rsp->MaxTransactSize),
      			       SMB2_MAX_BUFFER_SIZE);
      CIFSSMBNegotiate():
      	server->maxBuf = le32_to_cpu(pSMBr->MaxBufferSize);
      
      Page size 64KB and cache=strict lead to read_pages() use cifs_readpage()
      instead of cifs_readpages(), and then cifs_read() using maximum read IO
      size 16KB, which is much slower than maximum read IO size 1MB.
      (CIFSMaxBufSize is 16KB by default)
      
      	/* FIXME: set up handlers for larger reads and/or convert to async */
      	rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize);
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: NJones Syue <jonessyue@qnap.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      1f641d94
    • R
      cifs: dump the session id and keys also for SMB2 sessions · f560cda9
      Ronnie Sahlberg 提交于
      We already dump these keys for SMB3, lets also dump it for SMB2
      sessions so that we can use the session key in wireshark to check and validate
      that the signatures are correct.
      Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      f560cda9
  13. 11 4月, 2020 1 次提交
    • S
      smb3: enable swap on SMB3 mounts · 4e8aea30
      Steve French 提交于
      Add experimental support for allowing a swap file to be on an SMB3
      mount.  There are use cases where swapping over a secure network
      filesystem is preferable. In some cases there are no local
      block devices large enough, and network block devices can be
      hard to setup and secure.  And in some cases there are no
      local block devices at all (e.g. with the recent addition of
      remote boot over SMB3 mounts).
      
      There are various enhancements that can be added later e.g.:
      - doing a mandatory byte range lock over the swapfile (until
      the Linux VFS is modified to notify the file system that an open
      is for a swapfile, when the file can be opened "DENY_ALL" to prevent
      others from opening it).
      - pinning more buffers in the underlying transport to minimize memory
      allocations in the TCP stack under the fs
      - documenting how to create ACLs (on the server) to secure the
      swapfile (or adding additional tools to cifs-utils to make it easier)
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Acked-by: NPavel Shilovsky <pshilov@microsoft.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      4e8aea30
  14. 10 4月, 2020 1 次提交
  15. 08 4月, 2020 8 次提交
    • S
      smb3: smbdirect support can be configured by default · 2bcb4fd6
      Steve French 提交于
      smbdirect support (SMB3 over RDMA) should be enabled by
      default in many configurations.
      
      It is not experimental and is stable enough and has enough
      performance benefits to recommend that it be configured by
      default.  Change the  "If unsure N" to "If unsure Y" in
      the description of the configuration parameter.
      Acked-by: NAurelien Aptel <aaptel@suse.com>
      Reviewed-by: NLong Li <longli@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      2bcb4fd6
    • L
      cifs: smbd: Do not schedule work to send immediate packet on every receive · 044b541c
      Long Li 提交于
      Immediate packets should only be sent to peer when there are new
      receive credits made available. New credits show up on freeing
      receive buffer, not on receiving data.
      
      Fix this by avoid unnenecessary work schedules.
      Signed-off-by: NLong Li <longli@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      044b541c
    • L
      cifs: smbd: Properly process errors on ib_post_send · f1b7b862
      Long Li 提交于
      When processing errors from ib_post_send(), the transport state needs to be
      rolled back to the condition before the error.
      
      Refactor the old code to make it easy to roll back on IB errors, and fix this.
      Signed-off-by: NLong Li <longli@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      f1b7b862
    • L
      cifs: Allocate crypto structures on the fly for calculating signatures of incoming packets · eda1c54f
      Long Li 提交于
      CIFS uses pre-allocated crypto structures to calculate signatures for both
      incoming and outgoing packets. In this way it doesn't need to allocate crypto
      structures for every packet, but it requires a lock to prevent concurrent
      access to crypto structures.
      
      Remove the lock by allocating crypto structures on the fly for
      incoming packets. At the same time, we can still use pre-allocated crypto
      structures for outgoing packets, as they are already protected by transport
      lock srv_mutex.
      Signed-off-by: NLong Li <longli@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      eda1c54f
    • L
      cifs: smbd: Update receive credits before sending and deal with credits roll... · d4e5160d
      Long Li 提交于
      cifs: smbd: Update receive credits before sending and deal with credits roll back on failure before sending
      
      Recevie credits should be updated before sending the packet, not
      before a work is scheduled. Also, the value needs roll back if
      something fails and cannot send.
      Signed-off-by: NLong Li <longli@microsoft.com>
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      d4e5160d
    • L
      cifs: smbd: Check send queue size before posting a send · 3ffbe78a
      Long Li 提交于
      Sometimes the remote peer may return more send credits than the send queue
      depth. If all the send credits are used to post senasd, we may overflow the
      send queue.
      
      Fix this by checking the send queue size before posting a send.
      Signed-off-by: NLong Li <longli@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      3ffbe78a
    • L
      cifs: smbd: Merge code to track pending packets · 072a14ec
      Long Li 提交于
      As an optimization, SMBD tries to track two types of packets: packets with
      payload and without payload. There is no obvious benefit or performance gain
      to separately track two types of packets.
      
      Just treat them as pending packets and merge the tracking code.
      Signed-off-by: NLong Li <longli@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      072a14ec
    • A
      cifs: ignore cached share root handle closing errors · e79b0332
      Aurelien Aptel 提交于
      Fix tcon use-after-free and NULL ptr deref.
      
      Customer system crashes with the following kernel log:
      
      [462233.169868] CIFS VFS: Cancelling wait for mid 4894753 cmd: 14       => a QUERY DIR
      [462233.228045] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
      [462233.305922] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
      [462233.306205] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
      [462233.347060] CIFS VFS: cifs_put_smb_ses: Session Logoff failure rc=-4
      [462233.347107] CIFS VFS: Close unmatched open
      [462233.347113] BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
      ...
          [exception RIP: cifs_put_tcon+0xa0] (this is doing tcon->ses->server)
       #6 [...] smb2_cancelled_close_fid at ... [cifs]
       #7 [...] process_one_work at ...
       #8 [...] worker_thread at ...
       #9 [...] kthread at ...
      
      The most likely explanation we have is:
      
      * When we put the last reference of a tcon (refcount=0), we close the
        cached share root handle.
      * If closing a handle is interrupted, SMB2_close() will
        queue a SMB2_close() in a work thread.
      * The queued object keeps a tcon ref so we bump the tcon
        refcount, jumping from 0 to 1.
      * We reach the end of cifs_put_tcon(), we free the tcon object despite
        it now having a refcount of 1.
      * The queued work now runs, but the tcon, ses & server was freed in
        the meantime resulting in a crash.
      
      THREAD 1
      ========
      cifs_put_tcon                 => tcon refcount reach 0
        SMB2_tdis
         close_shroot_lease
          close_shroot_lease_locked => if cached root has lease && refcount = 0
           smb2_close_cached_fid    => if cached root valid
            SMB2_close              => retry close in a thread if interrupted
             smb2_handle_cancelled_close
              __smb2_handle_cancelled_close    => !! tcon refcount bump 0 => 1 !!
               INIT_WORK(&cancelled->work, smb2_cancelled_close_fid);
               queue_work(cifsiod_wq, &cancelled->work) => queue work
       tconInfoFree(tcon);    ==> freed!
       cifs_put_smb_ses(ses); ==> freed!
      
      THREAD 2 (workqueue)
      ========
      smb2_cancelled_close_fid
        SMB2_close(0, cancelled->tcon, ...); => use-after-free of tcon
        cifs_put_tcon(cancelled->tcon);      => tcon refcount reach 0 second time
        *CRASH*
      
      Fixes: d9191319 ("CIFS: Close cached root handle only if it has a lease")
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      e79b0332
  16. 30 3月, 2020 2 次提交