1. 25 2月, 2020 5 次提交
  2. 15 2月, 2020 2 次提交
  3. 13 2月, 2020 1 次提交
  4. 10 2月, 2020 1 次提交
  5. 07 2月, 2020 5 次提交
  6. 06 2月, 2020 5 次提交
  7. 05 2月, 2020 2 次提交
  8. 04 2月, 2020 2 次提交
  9. 01 2月, 2020 1 次提交
  10. 31 1月, 2020 1 次提交
    • R
      cifs: fix soft mounts hanging in the reconnect code · c54849dd
      Ronnie Sahlberg 提交于
      RHBZ: 1795429
      
      In recent DFS updates we have a new variable controlling how many times we will
      retry to reconnect the share.
      If DFS is not used, then this variable is initialized to 0 in:
      
      static inline int
      dfs_cache_get_nr_tgts(const struct dfs_cache_tgt_list *tl)
      {
              return tl ? tl->tl_numtgts : 0;
      }
      
      This means that in the reconnect loop in smb2_reconnect() we will immediately wrap retries to -1
      and never actually get to pass this conditional:
      
                      if (--retries)
                              continue;
      
      The effect is that we no longer reach the point where we fail the commands with -EHOSTDOWN
      and basically the kernel threads are virtually hung and unkillable.
      
      Fixes: a3a53b76 (cifs: Add support for failover in smb2_reconnect())
      Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      CC: Stable <stable@vger.kernel.org>
      c54849dd
  11. 27 1月, 2020 15 次提交
    • V
      CIFS: Fix task struct use-after-free on reconnect · f1f27ad7
      Vincent Whitchurch 提交于
      The task which created the MID may be gone by the time cifsd attempts to
      call the callbacks on MIDs from cifs_reconnect().
      
      This leads to a use-after-free of the task struct in cifs_wake_up_task:
      
       ==================================================================
       BUG: KASAN: use-after-free in __lock_acquire+0x31a0/0x3270
       Read of size 8 at addr ffff8880103e3a68 by task cifsd/630
      
       CPU: 0 PID: 630 Comm: cifsd Not tainted 5.5.0-rc6+ #119
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
       Call Trace:
        dump_stack+0x8e/0xcb
        print_address_description.constprop.5+0x1d3/0x3c0
        ? __lock_acquire+0x31a0/0x3270
        __kasan_report+0x152/0x1aa
        ? __lock_acquire+0x31a0/0x3270
        ? __lock_acquire+0x31a0/0x3270
        kasan_report+0xe/0x20
        __lock_acquire+0x31a0/0x3270
        ? __wake_up_common+0x1dc/0x630
        ? _raw_spin_unlock_irqrestore+0x4c/0x60
        ? mark_held_locks+0xf0/0xf0
        ? _raw_spin_unlock_irqrestore+0x39/0x60
        ? __wake_up_common_lock+0xd5/0x130
        ? __wake_up_common+0x630/0x630
        lock_acquire+0x13f/0x330
        ? try_to_wake_up+0xa3/0x19e0
        _raw_spin_lock_irqsave+0x38/0x50
        ? try_to_wake_up+0xa3/0x19e0
        try_to_wake_up+0xa3/0x19e0
        ? cifs_compound_callback+0x178/0x210
        ? set_cpus_allowed_ptr+0x10/0x10
        cifs_reconnect+0xa1c/0x15d0
        ? generic_ip_connect+0x1860/0x1860
        ? rwlock_bug.part.0+0x90/0x90
        cifs_readv_from_socket+0x479/0x690
        cifs_read_from_socket+0x9d/0xe0
        ? cifs_readv_from_socket+0x690/0x690
        ? mempool_resize+0x690/0x690
        ? rwlock_bug.part.0+0x90/0x90
        ? memset+0x1f/0x40
        ? allocate_buffers+0xff/0x340
        cifs_demultiplex_thread+0x388/0x2a50
        ? cifs_handle_standard+0x610/0x610
        ? rcu_read_lock_held_common+0x120/0x120
        ? mark_lock+0x11b/0xc00
        ? __lock_acquire+0x14ed/0x3270
        ? __kthread_parkme+0x78/0x100
        ? lockdep_hardirqs_on+0x3e8/0x560
        ? lock_downgrade+0x6a0/0x6a0
        ? lockdep_hardirqs_on+0x3e8/0x560
        ? _raw_spin_unlock_irqrestore+0x39/0x60
        ? cifs_handle_standard+0x610/0x610
        kthread+0x2bb/0x3a0
        ? kthread_create_worker_on_cpu+0xc0/0xc0
        ret_from_fork+0x3a/0x50
      
       Allocated by task 649:
        save_stack+0x19/0x70
        __kasan_kmalloc.constprop.5+0xa6/0xf0
        kmem_cache_alloc+0x107/0x320
        copy_process+0x17bc/0x5370
        _do_fork+0x103/0xbf0
        __x64_sys_clone+0x168/0x1e0
        do_syscall_64+0x9b/0xec0
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
       Freed by task 0:
        save_stack+0x19/0x70
        __kasan_slab_free+0x11d/0x160
        kmem_cache_free+0xb5/0x3d0
        rcu_core+0x52f/0x1230
        __do_softirq+0x24d/0x962
      
       The buggy address belongs to the object at ffff8880103e32c0
        which belongs to the cache task_struct of size 6016
       The buggy address is located 1960 bytes inside of
        6016-byte region [ffff8880103e32c0, ffff8880103e4a40)
       The buggy address belongs to the page:
       page:ffffea000040f800 refcount:1 mapcount:0 mapping:ffff8880108da5c0
       index:0xffff8880103e4c00 compound_mapcount: 0
       raw: 4000000000010200 ffffea00001f2208 ffffea00001e3408 ffff8880108da5c0
       raw: ffff8880103e4c00 0000000000050003 00000001ffffffff 0000000000000000
       page dumped because: kasan: bad access detected
      
       Memory state around the buggy address:
        ffff8880103e3900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        ffff8880103e3980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       >ffff8880103e3a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                 ^
        ffff8880103e3a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        ffff8880103e3b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ==================================================================
      
      This can be reliably reproduced by adding the below delay to
      cifs_reconnect(), running find(1) on the mount, restarting the samba
      server while find is running, and killing find during the delay:
      
        	spin_unlock(&GlobalMid_Lock);
        	mutex_unlock(&server->srv_mutex);
      
       +	msleep(10000);
       +
        	cifs_dbg(FYI, "%s: issuing mid callbacks\n", __func__);
        	list_for_each_safe(tmp, tmp2, &retry_list) {
        		mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
      
      Fix this by holding a reference to the task struct until the MID is
      freed.
      Signed-off-by: NVincent Whitchurch <vincent.whitchurch@axis.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      f1f27ad7
    • C
      cifs: use PTR_ERR_OR_ZERO() to simplify code · 050d2a8b
      Chen Zhou 提交于
      PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR, just use
      PTR_ERR_OR_ZERO directly.
      Signed-off-by: NChen Zhou <chenzhou10@huawei.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      050d2a8b
    • R
      cifs: add support for fallocate mode 0 for non-sparse files · 8bd0d701
      Ronnie Sahlberg 提交于
      RHBZ 1336264
      
      When we extend a file we must also force the size to be updated.
      
      This fixes an issue with holetest in xfs-tests which performs the following
      sequence :
      1, create a new file
      2, use fallocate mode==0 to populate the file
      3, mmap the file
      4, touch each page by reading the mmapped region.
      Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      8bd0d701
    • R
      cifs: fix NULL dereference in match_prepath · fe129268
      Ronnie Sahlberg 提交于
      RHBZ: 1760879
      
      Fix an oops in match_prepath() by making sure that the prepath string is not
      NULL before we pass it into strcmp().
      
      This is similar to other checks we make for example in cifs_root_iget()
      Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      fe129268
    • S
      smb3: fix default permissions on new files when mounting with modefromsid · 643fbcee
      Steve French 提交于
      When mounting with "modefromsid" mount parm most servers will require
      that some default permissions are given to users in the ACL on newly
      created files, files created with the new 'sd context' - when passing in
      an sd context on create, permissions are not inherited from the parent
      directory, so in addition to the ACE with the special SID which contains
      the mode, we also must pass in an ACE allowing users to access the file
      (GENERIC_ALL for authenticated users seemed like a reasonable default,
      although later we could allow a mount option or config switch to make
      it GENERIC_ALL for EVERYONE special sid).
      
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-By: NRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      643fbcee
    • B
      CIFS: Add support for setting owner info, dos attributes, and create time · 438471b6
      Boris Protopopov 提交于
      This is needed for backup/restore scenarios among others.
      
      Add extended attribute "system.cifs_ntsd" (and alias "system.smb3_ntsd")
      to allow for setting owner and DACL in the security descriptor. This is in
      addition to the existing "system.cifs_acl" and "system.smb3_acl" attributes
      that allow for setting DACL only. Add support for setting creation time and
      dos attributes using set_file_info() calls to complement the existing
      support for getting these attributes via query_path_info() calls.
      Signed-off-by: NBoris Protopopov <bprotopopov@hotmail.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      438471b6
    • Y
      cifs: remove set but not used variable 'server' · c4985c3d
      YueHaibing 提交于
      fs/cifs/smb2pdu.c: In function 'SMB2_query_directory':
      fs/cifs/smb2pdu.c:4444:26: warning:
       variable 'server' set but not used [-Wunused-but-set-variable]
        struct TCP_Server_Info *server;
      
      It is not used, so remove it.
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      c4985c3d
    • P
      cifs: Fix memory allocation in __smb2_handle_cancelled_cmd() · 0a5a9886
      Paulo Alcantara (SUSE) 提交于
      __smb2_handle_cancelled_cmd() is called under a spin lock held in
      cifs_mid_q_entry_release(), so make its memory allocation GFP_ATOMIC.
      
      This issue was observed when running xfstests generic/028:
      
      [ 1722.589204] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72064 cmd: 5
      [ 1722.590687] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72065 cmd: 17
      [ 1722.593529] CIFS VFS: \\192.168.30.26 Cancelling wait for mid 72066 cmd: 6
      [ 1723.039014] BUG: sleeping function called from invalid context at mm/slab.h:565
      [ 1723.040710] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 30877, name: cifsd
      [ 1723.045098] CPU: 3 PID: 30877 Comm: cifsd Not tainted 5.5.0-rc4+ #313
      [ 1723.046256] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba527-rebuilt.opensuse.org 04/01/2014
      [ 1723.048221] Call Trace:
      [ 1723.048689]  dump_stack+0x97/0xe0
      [ 1723.049268]  ___might_sleep.cold+0xd1/0xe1
      [ 1723.050069]  kmem_cache_alloc_trace+0x204/0x2b0
      [ 1723.051051]  __smb2_handle_cancelled_cmd+0x40/0x140 [cifs]
      [ 1723.052137]  smb2_handle_cancelled_mid+0xf6/0x120 [cifs]
      [ 1723.053247]  cifs_mid_q_entry_release+0x44d/0x630 [cifs]
      [ 1723.054351]  ? cifs_reconnect+0x26a/0x1620 [cifs]
      [ 1723.055325]  cifs_demultiplex_thread+0xad4/0x14a0 [cifs]
      [ 1723.056458]  ? cifs_handle_standard+0x2c0/0x2c0 [cifs]
      [ 1723.057365]  ? kvm_sched_clock_read+0x14/0x30
      [ 1723.058197]  ? sched_clock+0x5/0x10
      [ 1723.058838]  ? sched_clock_cpu+0x18/0x110
      [ 1723.059629]  ? lockdep_hardirqs_on+0x17d/0x250
      [ 1723.060456]  kthread+0x1ab/0x200
      [ 1723.061149]  ? cifs_handle_standard+0x2c0/0x2c0 [cifs]
      [ 1723.062078]  ? kthread_create_on_node+0xd0/0xd0
      [ 1723.062897]  ret_from_fork+0x3a/0x50
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Fixes: 9150c3ad ("CIFS: Close open handle after interrupted close")
      Cc: Stable <stable@vger.kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      0a5a9886
    • P
      cifs: Fix mount options set in automount · 5739375e
      Paulo Alcantara (SUSE) 提交于
      Starting from 4a367dc0, we must set the mount options based on the
      DFS full path rather than the resolved target, that is, cifs_mount()
      will be responsible for resolving the DFS link (cached) as well as
      performing failover to any other targets in the referral.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Reported-by: NMartijn de Gouw <martijn.de.gouw@prodrive-technologies.com>
      Fixes: 4a367dc0 ("cifs: Add support for failover in cifs_mount()")
      Link: https://lore.kernel.org/linux-cifs/39643d7d-2abb-14d3-ced6-c394fab9a777@prodrive-technologies.comTested-by: NMartijn de Gouw <martijn.de.gouw@prodrive-technologies.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      5739375e
    • S
      cifs: fix unitialized variable poential problem with network I/O cache lock patch · 463a7b45
      Steve French 提交于
      static analysis with Coverity detected an issue with the following
      commit:
      
       Author: Paulo Alcantara (SUSE) <pc@cjr.nz>
       Date:   Wed Dec 4 17:38:03 2019 -0300
      
          cifs: Avoid doing network I/O while holding cache lock
      
      Addresses-Coverity: ("Uninitialized pointer read")
      Reported-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      463a7b45
    • Y
      cifs: Fix return value in __update_cache_entry · eecfc571
      YueHaibing 提交于
      copy_ref_data() may return error, it should be
      returned to upstream caller.
      
      Fixes: 03535b72873b ("cifs: Avoid doing network I/O while holding cache lock")
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      eecfc571
    • P
      cifs: Avoid doing network I/O while holding cache lock · 742d8de0
      Paulo Alcantara (SUSE) 提交于
      When creating or updating a cache entry, we need to get an DFS
      referral (get_dfs_referral), so avoid holding any locks during such
      network operation.
      
      To prevent that, do the following:
      * change cache hashtable sync method from RCU sync to a read/write
        lock.
      * use GFP_ATOMIC in memory allocations.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      742d8de0
    • P
      cifs: Fix potential deadlock when updating vol in cifs_reconnect() · 06d57378
      Paulo Alcantara (SUSE) 提交于
      We can't acquire volume lock while refreshing the DFS cache because
      cifs_reconnect() may call dfs_cache_update_vol() while we are walking
      through the volume list.
      
      To prevent that, make vol_info refcounted, create a temp list with all
      volumes eligible for refreshing, and then use it without any locks
      held.
      
      Besides, replace vol_lock with a spinlock and protect cache_ttl from
      concurrent accesses or changes.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      06d57378
    • P
      cifs: Merge is_path_valid() into get_normalized_path() · ff2f7fc0
      Paulo Alcantara (SUSE) 提交于
      Just do the trivial path validation in get_normalized_path().
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      ff2f7fc0
    • P
      cifs: Introduce helpers for finding TCP connection · 345c1a4a
      Paulo Alcantara (SUSE) 提交于
      Add helpers for finding TCP connections that are good candidates for
      being used by DFS refresh worker.
      Signed-off-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      345c1a4a