1. 19 12月, 2022 2 次提交
  2. 05 10月, 2022 1 次提交
  3. 01 8月, 2022 1 次提交
    • S
      cifs: avoid use of global locks for high contention data · d7d7a66a
      Shyam Prasad N 提交于
      During analysis of multichannel perf, it was seen that
      the global locks cifs_tcp_ses_lock and GlobalMid_Lock, which
      were shared between various data structures were causing a
      lot of contention points.
      
      With this change, we're breaking down the use of these locks
      by introducing new locks at more granular levels. i.e.
      server->srv_lock, ses->ses_lock and tcon->tc_lock to protect
      the unprotected fields of server, session and tcon structs;
      and server->mid_lock to protect mid related lists and entries
      at server level.
      Signed-off-by: NShyam Prasad N <sprasad@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      d7d7a66a
  4. 05 6月, 2022 1 次提交
  5. 04 6月, 2022 1 次提交
    • P
      cifs: skip trailing separators of prefix paths · ef605e86
      Paulo Alcantara 提交于
      During DFS failover, prefix paths may change, so make sure to not
      leave trailing separators when parsing thew in
      dfs_cache_get_tgt_share().  The separators of prefix paths are already
      handled by build_path_from_dentry_optional_prefix().
      
      Consider the following DFS link:
      
        //dom/dfs/link: [\srv1\share\dir1, \srv2\share\dir1]
      
      Before commit:
      
        mount.cifs //dom/dfs/link
        tree connect to \\srv1\share; prefix_path=dir1
        disconnect srv1; failover to srv2
        tree connect to \\srv2\share; prefix_path=dir1\
        mv foo bar
      
        ...
        SMB2 430 Create Request File: dir1\\foo;GetInfo Request FILE_INFO/SMB2_FILE_ALL_INFO;Close Request
        SMB2 582 Create Response File: dir1\\foo;GetInfo Response;Close Response
        SMB2 430 Create Request File: dir1\\bar;GetInfo Request FILE_INFO/SMB2_FILE_ALL_INFO;Close Request
        SMB2 286 Create Response, Error: STATUS_OBJECT_NAME_NOT_FOUND;GetInfo Response, Error: STATUS_OBJECT_NAME_NOT_FOUND;Close Response, Error: STATUS_OBJECT_NAME_NOT_FOUND
        SMB2 462 Create Request File: dir1\\foo;SetInfo Request FILE_INFO/SMB2_FILE_RENAME_INFO NewName:dir1\\bar;Close Request
        SMB2 478 Create Response File: dir1\\foo;SetInfo Response, Error: STATUS_OBJECT_NAME_INVALID;Close Response
      
      After commit:
      
        mount.cifs //dom/dfs/link
        tree connect to \\srv1\share; prefix_path=dir1
        disconnect srv1; failover to srv2
        tree connect to \\srv2\share; prefix_path=dir1
        mv foo bar
      
        ...
        SMB2 430 Create Request File: dir1\foo;GetInfo Request FILE_INFO/SMB2_FILE_ALL_INFO;Close Request
        SMB2 582 Create Response File: dir1\foo;GetInfo Response;Close Response
        SMB2 430 Create Request File: dir1\bar;GetInfo Request FILE_INFO/SMB2_FILE_ALL_INFO;Close Request
        SMB2 286 Create Response, Error: STATUS_OBJECT_NAME_NOT_FOUND;GetInfo Response, Error: STATUS_OBJECT_NAME_NOT_FOUND;Close Response, Error: STATUS_OBJECT_NAME_NOT_FOUND
        SMB2 462 Create Request File: dir1\foo;SetInfo Request FILE_INFO/SMB2_FILE_RENAME_INFO NewName:dir1\bar;Close Request
        SMB2 478 Create Response File: dir1\foo;SetInfo Response;Close Response
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      ef605e86
  6. 01 6月, 2022 1 次提交
    • V
      cifs: fix potential deadlock in direct reclaim · cc391b69
      Vincent Whitchurch 提交于
      The srv_mutex is used during writeback so cifs should ensure that
      allocations done when that mutex is held are done with GFP_NOFS, to
      avoid having direct reclaim ending up waiting for the same mutex and
      causing a deadlock.  This is detected by lockdep with the splat below:
      
       ======================================================
       WARNING: possible circular locking dependency detected
       5.18.0 #70 Not tainted
       ------------------------------------------------------
       kswapd0/49 is trying to acquire lock:
       ffff8880195782e0 (&tcp_ses->srv_mutex){+.+.}-{3:3}, at: compound_send_recv
      
       but task is already holding lock:
       ffffffffa98e66c0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat
      
       which lock already depends on the new lock.
      
       the existing dependency chain (in reverse order) is:
      
       -> #1 (fs_reclaim){+.+.}-{0:0}:
              fs_reclaim_acquire
              kmem_cache_alloc_trace
              __request_module
              crypto_alg_mod_lookup
              crypto_alloc_tfm_node
              crypto_alloc_shash
              cifs_alloc_hash
              smb311_crypto_shash_allocate
              smb311_update_preauth_hash
              compound_send_recv
              cifs_send_recv
              SMB2_negotiate
              smb2_negotiate
              cifs_negotiate_protocol
              cifs_get_smb_ses
              cifs_mount
              cifs_smb3_do_mount
              smb3_get_tree
              vfs_get_tree
              path_mount
              __x64_sys_mount
              do_syscall_64
              entry_SYSCALL_64_after_hwframe
      
       -> #0 (&tcp_ses->srv_mutex){+.+.}-{3:3}:
              __lock_acquire
              lock_acquire
              __mutex_lock
              mutex_lock_nested
              compound_send_recv
              cifs_send_recv
              SMB2_write
              smb2_sync_write
              cifs_write
              cifs_writepage_locked
              cifs_writepage
              shrink_page_list
              shrink_lruvec
              shrink_node
              balance_pgdat
              kswapd
              kthread
              ret_from_fork
      
       other info that might help us debug this:
      
        Possible unsafe locking scenario:
      
              CPU0                    CPU1
              ----                    ----
         lock(fs_reclaim);
                                      lock(&tcp_ses->srv_mutex);
                                      lock(fs_reclaim);
         lock(&tcp_ses->srv_mutex);
      
        *** DEADLOCK ***
      
       1 lock held by kswapd0/49:
        #0: ffffffffa98e66c0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat
      
       stack backtrace:
       CPU: 2 PID: 49 Comm: kswapd0 Not tainted 5.18.0 #70
       Call Trace:
        <TASK>
        dump_stack_lvl
        dump_stack
        print_circular_bug.cold
        check_noncircular
        __lock_acquire
        lock_acquire
        __mutex_lock
        mutex_lock_nested
        compound_send_recv
        cifs_send_recv
        SMB2_write
        smb2_sync_write
        cifs_write
        cifs_writepage_locked
        cifs_writepage
        shrink_page_list
        shrink_lruvec
        shrink_node
        balance_pgdat
        kswapd
        kthread
        ret_from_fork
        </TASK>
      
      Fix this by using the memalloc_nofs_save/restore APIs around the places
      where the srv_mutex is held.  Do this in a wrapper function for the
      lock/unlock of the srv_mutex, and rename the srv_mutex to avoid missing
      call sites in the conversion.
      
      Note that there is another lockdep warning involving internal crypto
      locks, which was masked by this problem and is visible after this fix,
      see the discussion in this thread:
      
       https://lore.kernel.org/all/20220523123755.GA13668@axis.com/
      
      Link: https://lore.kernel.org/r/CANT5p=rqcYfYMVHirqvdnnca4Mo+JQSw5Qu12v=kPfpk5yhhmg@mail.gmail.com/Reported-by: NShyam Prasad N <nspmangalore@gmail.com>
      Suggested-by: NLars Persson <larper@axis.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: NEnzo Matsumiya <ematsumiya@suse.de>
      Signed-off-by: NVincent Whitchurch <vincent.whitchurch@axis.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      cc391b69
  7. 21 5月, 2022 1 次提交
  8. 21 4月, 2022 1 次提交
    • P
      cifs: fix NULL ptr dereference in refresh_mounts() · 41f10081
      Paulo Alcantara 提交于
      Either mount(2) or automount might not have server->origin_fullpath
      set yet while refresh_cache_worker() is attempting to refresh DFS
      referrals.  Add missing NULL check and locking around it.
      
      This fixes bellow crash:
      
      [ 1070.276835] general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN NOPTI
      [ 1070.277676] KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
      [ 1070.278219] CPU: 1 PID: 8506 Comm: kworker/u8:1 Not tainted 5.18.0-rc3 #10
      [ 1070.278701] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014
      [ 1070.279495] Workqueue: cifs-dfscache refresh_cache_worker [cifs]
      [ 1070.280044] RIP: 0010:strcasecmp+0x34/0x150
      [ 1070.280359] Code: 00 00 00 fc ff df 41 54 55 48 89 fd 53 48 83 ec 10 eb 03 4c 89 fe 48 89 ef 48 83 c5 01 48 89 f8 48 89 fa 48 c1 e8 03 83 e2 07 <42> 0f b6 04 28 38 d0 7f 08 84 c0 0f 85 bc 00 00 00 0f b6 45 ff 44
      [ 1070.281729] RSP: 0018:ffffc90008367958 EFLAGS: 00010246
      [ 1070.282114] RAX: 0000000000000000 RBX: dffffc0000000000 RCX: 0000000000000000
      [ 1070.282691] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
      [ 1070.283273] RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffff873eda27
      [ 1070.283857] R10: ffffc900083679a0 R11: 0000000000000001 R12: ffff88812624c000
      [ 1070.284436] R13: dffffc0000000000 R14: ffff88810e6e9a88 R15: ffff888119bb9000
      [ 1070.284990] FS:  0000000000000000(0000) GS:ffff888151200000(0000) knlGS:0000000000000000
      [ 1070.285625] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 1070.286100] CR2: 0000561a4d922418 CR3: 000000010aecc000 CR4: 0000000000350ee0
      [ 1070.286683] Call Trace:
      [ 1070.286890]  <TASK>
      [ 1070.287070]  refresh_cache_worker+0x895/0xd20 [cifs]
      [ 1070.287475]  ? __refresh_tcon.isra.0+0xfb0/0xfb0 [cifs]
      [ 1070.287905]  ? __lock_acquire+0xcd1/0x6960
      [ 1070.288247]  ? is_dynamic_key+0x1a0/0x1a0
      [ 1070.288591]  ? lockdep_hardirqs_on_prepare+0x410/0x410
      [ 1070.289012]  ? lock_downgrade+0x6f0/0x6f0
      [ 1070.289318]  process_one_work+0x7bd/0x12d0
      [ 1070.289637]  ? worker_thread+0x160/0xec0
      [ 1070.289970]  ? pwq_dec_nr_in_flight+0x230/0x230
      [ 1070.290318]  ? _raw_spin_lock_irq+0x5e/0x90
      [ 1070.290619]  worker_thread+0x5ac/0xec0
      [ 1070.290891]  ? process_one_work+0x12d0/0x12d0
      [ 1070.291199]  kthread+0x2a5/0x350
      [ 1070.291430]  ? kthread_complete_and_exit+0x20/0x20
      [ 1070.291770]  ret_from_fork+0x22/0x30
      [ 1070.292050]  </TASK>
      [ 1070.292223] Modules linked in: bpfilter cifs cifs_arc4 cifs_md4
      [ 1070.292765] ---[ end trace 0000000000000000 ]---
      [ 1070.293108] RIP: 0010:strcasecmp+0x34/0x150
      [ 1070.293471] Code: 00 00 00 fc ff df 41 54 55 48 89 fd 53 48 83 ec 10 eb 03 4c 89 fe 48 89 ef 48 83 c5 01 48 89 f8 48 89 fa 48 c1 e8 03 83 e2 07 <42> 0f b6 04 28 38 d0 7f 08 84 c0 0f 85 bc 00 00 00 0f b6 45 ff 44
      [ 1070.297718] RSP: 0018:ffffc90008367958 EFLAGS: 00010246
      [ 1070.298622] RAX: 0000000000000000 RBX: dffffc0000000000 RCX: 0000000000000000
      [ 1070.299428] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
      [ 1070.300296] RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffff873eda27
      [ 1070.301204] R10: ffffc900083679a0 R11: 0000000000000001 R12: ffff88812624c000
      [ 1070.301932] R13: dffffc0000000000 R14: ffff88810e6e9a88 R15: ffff888119bb9000
      [ 1070.302645] FS:  0000000000000000(0000) GS:ffff888151200000(0000) knlGS:0000000000000000
      [ 1070.303462] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 1070.304131] CR2: 0000561a4d922418 CR3: 000000010aecc000 CR4: 0000000000350ee0
      [ 1070.305004] Kernel panic - not syncing: Fatal exception
      [ 1070.305711] Kernel Offset: disabled
      [ 1070.305971] ---[ end Kernel panic - not syncing: Fatal exception ]---
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Cc: stable@vger.kernel.org
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      41f10081
  9. 19 3月, 2022 1 次提交
  10. 09 2月, 2022 1 次提交
  11. 20 1月, 2022 1 次提交
  12. 17 11月, 2021 1 次提交
  13. 11 11月, 2021 1 次提交
    • P
      cifs: support nested dfs links over reconnect · c88f7dcd
      Paulo Alcantara 提交于
      Mounting a dfs link that has nested links was already supported at
      mount(2), so make it work over reconnect as well.
      
      Make the following case work:
      
      * mount //root/dfs/link /mnt -o ...
        - final share: /server/share
      
      * in server settings
        - change target folder of /root/dfs/link3 to /server/share2
        - change target folder of /root/dfs/link2 to /root/dfs/link3
        - change target folder of /root/dfs/link to /root/dfs/link2
      
      * mount -o remount,... /mnt
       - refresh all dfs referrals
       - mark current connection for failover
       - cifs_reconnect() reconnects to root server
       - tree_connect()
         * checks that /root/dfs/link2 is a link, then chase it
         * checks that root/dfs/link3 is a link, then chase it
         * finally tree connect to /server/share2
      
      If the mounted share is no longer accessible and a reconnect had been
      triggered, the client will retry it from both last referral
      path (/root/dfs/link3) and original referral path (/root/dfs/link).
      
      Any new referral paths found while chasing dfs links over reconnect,
      it will be updated to TCP_Server_Info::leaf_fullpath, accordingly.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      c88f7dcd
  14. 10 11月, 2021 1 次提交
  15. 23 7月, 2021 1 次提交
  16. 21 6月, 2021 8 次提交
  17. 26 4月, 2021 2 次提交
  18. 26 2月, 2021 1 次提交
  19. 29 1月, 2021 1 次提交
  20. 14 1月, 2021 1 次提交
    • T
      cifs: check pointer before freeing · 77b6ec01
      Tom Rix 提交于
      clang static analysis reports this problem
      
      dfs_cache.c:591:2: warning: Argument to kfree() is a constant address
        (18446744073709551614), which is not memory allocated by malloc()
              kfree(vi);
              ^~~~~~~~~
      
      In dfs_cache_del_vol() the volume info pointer 'vi' being freed
      is the return of a call to find_vol().  The large constant address
      is find_vol() returning an error.
      
      Add an error check to dfs_cache_del_vol() similar to the one done
      in dfs_cache_update_vol().
      
      Fixes: 54be1f6c ("cifs: Add DFS cache routines")
      Signed-off-by: NTom Rix <trix@redhat.com>
      Reviewed-by: NNathan Chancellor <natechancellor@gmail.com>
      CC: <stable@vger.kernel.org> # v5.0+
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      77b6ec01
  21. 14 12月, 2020 5 次提交
  22. 08 8月, 2020 1 次提交
    • W
      mm, treewide: rename kzfree() to kfree_sensitive() · 453431a5
      Waiman Long 提交于
      As said by Linus:
      
        A symmetric naming is only helpful if it implies symmetries in use.
        Otherwise it's actively misleading.
      
        In "kzalloc()", the z is meaningful and an important part of what the
        caller wants.
      
        In "kzfree()", the z is actively detrimental, because maybe in the
        future we really _might_ want to use that "memfill(0xdeadbeef)" or
        something. The "zero" part of the interface isn't even _relevant_.
      
      The main reason that kzfree() exists is to clear sensitive information
      that should not be leaked to other future users of the same memory
      objects.
      
      Rename kzfree() to kfree_sensitive() to follow the example of the recently
      added kvfree_sensitive() and make the intention of the API more explicit.
      In addition, memzero_explicit() is used to clear the memory to make sure
      that it won't get optimized away by the compiler.
      
      The renaming is done by using the command sequence:
      
        git grep -w --name-only kzfree |\
        xargs sed -i 's/kzfree/kfree_sensitive/'
      
      followed by some editing of the kfree_sensitive() kerneldoc and adding
      a kzfree backward compatibility macro in slab.h.
      
      [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h]
      [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]
      Suggested-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NWaiman Long <longman@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>
      Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      453431a5
  23. 03 8月, 2020 2 次提交
  24. 01 6月, 2020 1 次提交
    • 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
  25. 23 3月, 2020 1 次提交
  26. 04 2月, 2020 1 次提交