09 Feb, 2017

1 commit

  • commit 81ddd8c0c5e1cb41184d66567140cb48c53eb3d1 upstream.

    Reviewed-by: Jeff Layton

    file_info_lock is not initalized in initiate_cifs_search(), leading to the
    following splat after a simple "mount.cifs ... dir && ls dir/":

    BUG: spinlock bad magic on CPU#0, ls/486
    lock: 0xffff880009301110, .magic: 00000000, .owner: /-1, .owner_cpu: 0
    CPU: 0 PID: 486 Comm: ls Not tainted 4.9.0 #27
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
    ffffc900042f3db0 ffffffff81327533 0000000000000000 ffff880009301110
    ffffc900042f3dd0 ffffffff810baf75 ffff880009301110 ffffffff817ae077
    ffffc900042f3df0 ffffffff810baff6 ffff880009301110 ffff880008d69900
    Call Trace:
    [] dump_stack+0x65/0x92
    [] spin_dump+0x85/0xe0
    [] spin_bug+0x26/0x30
    [] do_raw_spin_lock+0xe9/0x130
    [] _raw_spin_lock+0x1f/0x30
    [] cifs_closedir+0x4d/0x100
    [] __fput+0x5d/0x160
    [] ____fput+0xe/0x10
    [] task_work_run+0x7e/0xa0
    [] exit_to_usermode_loop+0x92/0xa0
    [] syscall_return_slowpath+0x49/0x50
    [] entry_SYSCALL_64_fastpath+0xa7/0xa9

    Fixes: 3afca265b5f53a0 ("Clarify locking of cifs file and tcon structures and make more granular")
    Signed-off-by: Rabin Vincent
    Signed-off-by: Steve French
    Signed-off-by: Greg Kroah-Hartman

    Rabin Vincent
     

06 Jan, 2017

6 commits

  • commit e3d240e9d505fc67f8f8735836df97a794bbd946 upstream.

    If maxBuf is not 0 but less than a size of SMB2 lock structure
    we can end up with a memory corruption.

    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Greg Kroah-Hartman

    Pavel Shilovsky
     
  • commit b0a752b5ce76bd1d8b733a53757c3263511dcb69 upstream.

    Reviewed-by: Aurelien Aptel
    Acked-by: Sachin Prabhu
    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Greg Kroah-Hartman

    Pavel Shilovsky
     
  • commit 96a988ffeb90dba33a71c3826086fe67c897a183 upstream.

    With the current code it is possible to lock a mutex twice when
    a subsequent reconnects are triggered. On the 1st reconnect we
    reconnect sessions and tcons and then persistent file handles.
    If the 2nd reconnect happens during the reconnecting of persistent
    file handles then the following sequence of calls is observed:

    cifs_reopen_file -> SMB2_open -> small_smb2_init -> smb2_reconnect
    -> cifs_reopen_persistent_file_handles -> cifs_reopen_file (again!).

    So, we are trying to acquire the same cfile->fh_mutex twice which
    is wrong. Fix this by moving reconnecting of persistent handles to
    the delayed work (smb2_reconnect_server) and submitting this work
    every time we reconnect tcon in SMB2 commands handling codepath.

    This can also lead to corruption of a temporary file list in
    cifs_reopen_persistent_file_handles() because we can recursively
    call this function twice.

    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Greg Kroah-Hartman

    Pavel Shilovsky
     
  • commit 4772c79599564bd08ee6682715a7d3516f67433f upstream.

    Acked-by: Sachin Prabhu
    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Greg Kroah-Hartman

    Pavel Shilovsky
     
  • commit 53e0e11efe9289535b060a51d4cf37c25e0d0f2b upstream.

    We can not unlock/lock cifs_tcp_ses_lock while walking through ses
    and tcon lists because it can corrupt list iterator pointers and
    a tcon structure can be released if we don't hold an extra reference.
    Fix it by moving a reconnect process to a separate delayed work
    and acquiring a reference to every tcon that needs to be reconnected.
    Also do not send an echo request on newly established connections.

    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Greg Kroah-Hartman

    Pavel Shilovsky
     
  • commit 06deeec77a5a689cc94b21a8a91a76e42176685d upstream.

    smbencrypt() points a scatterlist to the stack, which is breaks if
    CONFIG_VMAP_STACK=y.

    Fix it by switching to crypto_cipher_encrypt_one(). The new code
    should be considerably faster as an added benefit.

    This code is nearly identical to some code that Eric Biggers
    suggested.

    Reported-by: Eric Biggers
    Signed-off-by: Andy Lutomirski
    Acked-by: Jeff Layton
    Signed-off-by: Steve French
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski
     

29 Nov, 2016

3 commits

  • Commit 2211d5ba5c6c ("posix_acl: xattr representation cleanups")
    removes the typedefs and the zero-length a_entries array in struct
    posix_acl_xattr_header, and uses bare struct posix_acl_xattr_header
    and struct posix_acl_xattr_entry directly.

    But it failed to iterate over posix acl slots when converting posix
    acls to CIFS format, which results in several test failures in
    xfstests (generic/053 generic/105) when testing against a samba v1
    server, starting from v4.9-rc1 kernel. e.g.

    [root@localhost xfstests]# diff -u tests/generic/105.out /root/xfstests/results//generic/105.out.bad
    --- tests/generic/105.out 2016-09-19 16:33:28.577962575 +0800
    +++ /root/xfstests/results//generic/105.out.bad 2016-10-22 15:41:15.201931110 +0800
    @@ -1,3 +1,4 @@
    QA output created by 105
    -rw-r--r-- root
    +setfacl: subdir: Invalid argument
    -rw-r--r-- root

    Fix it by introducing a new "ace" var, like what
    cifs_copy_posix_acl() does, and iterating posix acl xattr entries
    over it in the for loop.

    Signed-off-by: Eryu Guan
    Signed-off-by: Steve French

    Eryu Guan
     
  • Commit 4fcd1813e640 ("Fix reconnect to not defer smb3 session reconnect
    long after socket reconnect") changes the behaviour of the SMB2 echo
    service and causes it to renegotiate after a socket reconnect. However
    under default settings, the echo service could take up to 120 seconds to
    be scheduled.

    The patch forces the echo service to be called immediately resulting a
    negotiate call being made immediately on reconnect.

    Signed-off-by: Sachin Prabhu
    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Sachin Prabhu
     
  • Andy Lutromirski's new virtually mapped kernel stack allocations moves
    kernel stacks the vmalloc area. This triggers the bug
    kernel BUG at ./include/linux/scatterlist.h:140!
    at calc_seckey()->sg_init()

    Signed-off-by: Sachin Prabhu
    Signed-off-by: Steve French
    Reviewed-by: Jeff Layton

    Sachin Prabhu
     

15 Oct, 2016

2 commits

  • New mount option "idsfromsid" indicates to cifs.ko that
    it should try to retrieve the uid and gid owner fields
    from special sids. This patch adds the code to parse the owner
    sids in the ACL to see if they match, and if so populate the
    uid and/or gid from them. This is faster than upcalling for
    them and asking winbind, and is a fairly common case, and is
    also helpful when cifs.upcall and idmapping is not configured.

    Signed-off-by: Steve French
    Reviewed-by: Shirish Pargaonkar
    Reviewed-by: Jeff Layton
    Reviewed-by: Pavel Shilovsky

    Steve French
     
  • Add "idsfromsid" mount option to indicate to cifs.ko that it should
    try to retrieve the uid and gid owner fields from special sids in the
    ACL if present. This first patch just adds the parsing for the mount
    option.

    Signed-off-by: Steve French
    Reviewed-by: Shirish Pargaonkar
    Reviewed-by: Pavel Shilovsky

    Steve French
     

14 Oct, 2016

8 commits


13 Oct, 2016

11 commits

  • Add mount option "max_credits" to allow setting maximum SMB3
    credits to any value from 10 to 64000 (default is 32000).
    This can be useful to workaround servers with problems allocating
    credits, or to throttle the client to use smaller amount of
    simultaneous i/o or to workaround server performance issues.

    Also adds a cap, so that even if the server granted us more than
    65000 credits due to a server bug, we would not use that many.

    Signed-off-by: Steve French

    Steve French
     
  • Continuous Availability features like persistent handles
    require that clients reconnect their open files, not
    just the sessions, soon after the network connection comes
    back up, otherwise the server will throw away the state
    (byte range locks, leases, deny modes) on those handles
    after a timeout.

    Add code to reconnect handles when use_persistent set
    (e.g. Continuous Availability shares) after tree reconnect.

    Signed-off-by: Aurelien Aptel
    Reviewed-by: Germano Percossi
    Signed-off-by: Steve French

    Steve French
     
  • Remove the global file_list_lock to simplify cifs/smb3 locking and
    have spinlocks that more closely match the information they are
    protecting.

    Add new tcon->open_file_lock and file->file_info_lock spinlocks.
    Locks continue to follow a heirachy,
    cifs_socket --> cifs_ses --> cifs_tcon --> cifs_file
    where global tcp_ses_lock still protects socket and cifs_ses, while the
    the newer locks protect the lower level structure's information
    (tcon and cifs_file respectively).

    CC: Stable
    Signed-off-by: Steve French
    Signed-off-by: Pavel Shilovsky
    Reviewed-by: Aurelien Aptel
    Reviewed-by: Germano Percossi

    Steve French
     
  • Patch a6b5058 results in -EREMOTE returned by is_path_accessible() in
    cifs_mount() to be ignored which breaks DFS mounting.

    Signed-off-by: Sachin Prabhu
    Reviewed-by: Aurelien Aptel
    CC: Stable
    Signed-off-by: Steve French

    Sachin Prabhu
     
  • When we open a durable handle we give a Globally Unique
    Identifier (GUID) to the server which we must keep for later reference
    e.g. when reopening persistent handles on reconnection.

    Without this the GUID generated for a new persistent handle was lost and
    16 zero bytes were used instead on re-opening.

    Signed-off-by: Aurelien Aptel
    CC: Stable
    Signed-off-by: Steve French

    Aurelien Aptel
     
  • GUIDs although random, and 16 bytes, need to be generated as
    proper uuids.

    Signed-off-by: Steve French
    Reviewed-by: Aurelien Aptel
    Reported-by: David Goebels
    CC: Stable

    Steve French
     
  • Signed-off-by: Steve French
    CC: Stable
    Reported-by: David Goebel

    Steve French
     
  • The kernel client requests 2 credits for many operations even though
    they only use 1 credit (presumably to build up a buffer of credit).
    Some servers seem to give the client as much credit as is requested. In
    this case, the amount of credit the client has continues increasing to
    the point where (server->credits * MAX_BUFFER_SIZE) overflows in
    smb2_wait_mtu_credits().

    Fix this by throttling the credit requests if an set limit is reached.
    For async requests where the credit charge may be > 1, request as much
    credit as what is charged.
    The limit is chosen somewhat arbitrarily. The Windows client
    defaults to 128 credits, the Windows server allows clients up to
    512 credits (or 8192 for Windows 2016), and the NetApp server
    (and at least one other) does not limit clients at all.
    Choose a high enough value such that the client shouldn't limit
    performance.

    This behavior was seen with a NetApp filer (NetApp Release 9.0RC2).

    Signed-off-by: Ross Lagerwall
    CC: Stable
    Signed-off-by: Steve French

    Ross Lagerwall
     
  • In debugging smb3, it is useful to display the number
    of credits available, so we can see when the server has not granted
    sufficient operations for the client to make progress, or alternatively
    the client has requested too many credits (as we saw in a recent bug)
    so we can compare with the number of credits the server thinks
    we have.

    Add a /proc/fs/cifs/DebugData line to display the client view
    on how many credits are available.

    Signed-off-by: Steve French
    Reported-by: Germano Percossi
    CC: Stable

    Steve French
     
  • Add parsing for new pseudo-xattr user.cifs.creationtime file
    attribute to allow backup and test applications to view
    birth time of file on cifs/smb3 mounts.

    Signed-off-by: Steve French

    Steve French
     
  • Add parsing for new pseudo-xattr user.cifs.dosattrib file attribute
    so tools can recognize what kind of file it is, and verify if common
    SMB3 attributes (system, hidden, archive, sparse, indexed etc.) are
    set.

    Signed-off-by: Steve French
    Reviewed-by: Pavel Shilovsky

    Steve French
     

11 Oct, 2016

3 commits

  • Pull more vfs updates from Al Viro:
    ">rename2() work from Miklos + current_time() from Deepa"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: Replace current_fs_time() with current_time()
    fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
    fs: Replace CURRENT_TIME with current_time() for inode timestamps
    fs: proc: Delete inode time initializations in proc_alloc_inode()
    vfs: Add current_time() api
    vfs: add note about i_op->rename changes to porting
    fs: rename "rename2" i_op to "rename"
    vfs: remove unused i_op->rename
    fs: make remaining filesystems use .rename2
    libfs: support RENAME_NOREPLACE in simple_rename()
    fs: support RENAME_NOREPLACE for local filesystems
    ncpfs: fix unused variable warning

    Linus Torvalds
     
  • Al Viro
     
  • Pull vfs xattr updates from Al Viro:
    "xattr stuff from Andreas

    This completes the switch to xattr_handler ->get()/->set() from
    ->getxattr/->setxattr/->removexattr"

    * 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    vfs: Remove {get,set,remove}xattr inode operations
    xattr: Stop calling {get,set,remove}xattr inode operations
    vfs: Check for the IOP_XATTR flag in listxattr
    xattr: Add __vfs_{get,set,remove}xattr helpers
    libfs: Use IOP_XATTR flag for empty directory handling
    vfs: Use IOP_XATTR flag for bad-inode handling
    vfs: Add IOP_XATTR inode operations flag
    vfs: Move xattr_resolve_name to the front of fs/xattr.c
    ecryptfs: Switch to generic xattr handlers
    sockfs: Get rid of getxattr iop
    sockfs: getxattr: Fail with -EOPNOTSUPP for invalid attribute names
    kernfs: Switch to generic xattr handlers
    hfs: Switch to generic xattr handlers
    jffs2: Remove jffs2_{get,set,remove}xattr macros
    xattr: Remove unnecessary NULL attribute name check

    Linus Torvalds
     

08 Oct, 2016

3 commits


28 Sep, 2016

3 commits