24 Dec, 2018

1 commit

  • RHBZ: 1021460

    There is an issue where when multiple threads open/close the same directory
    ntwrk_buf_start might end up being NULL, causing the call to smbCalcSize
    later to oops with a NULL deref.

    The real bug is why this happens and why this can become NULL for an
    open cfile, which should not be allowed.
    This patch tries to avoid a oops until the time when we fix the underlying
    issue.

    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     

12 Sep, 2018

1 commit

  • The "old_entry + le32_to_cpu(pDirInfo->NextEntryOffset)" can wrap
    around so I have added a check for integer overflow.

    Reported-by: Dr Silvio Cesare of InfoSect
    Reviewed-by: Ronnie Sahlberg
    Reviewed-by: Aurelien Aptel
    Signed-off-by: Dan Carpenter
    Signed-off-by: Steve French
    CC: Stable

    Dan Carpenter
     

28 May, 2018

1 commit


15 Jan, 2017

1 commit

  • Reviewed-by: Jeff Layton
    CC: Stable

    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

    Rabin Vincent
     

13 Oct, 2016

1 commit

  • 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
     

18 May, 2016

1 commit

  • CIFS may be used as lower layer of overlayfs and accessing f_path.dentry can
    lead to a crash.

    Fix by replacing direct access of file->f_path.dentry with the
    file_dentry() accessor, which will always return a native object.

    Signed-off-by: Goldwyn Rodrigues
    Acked-by: Shirish Pargaonkar
    Signed-off-by: Steve French

    Goldwyn Rodrigues
     

03 May, 2016

1 commit


11 Apr, 2016

1 commit


15 Jan, 2016

1 commit

  • In some cases tmp_bug can be not filled in cifs_filldir and stay uninitialized,
    therefore its printk with "%s" modifier can leak content of kernelspace memory.
    If old content of this buffer does not contain '\0' access bejond end of
    allocated object can crash the host.

    Signed-off-by: Vasily Averin
    Signed-off-by: Steve French
    CC: Stable

    Vasily Averin
     

29 Sep, 2015

1 commit

  • IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
    is no need to do that again from its callers. Drop it.

    Signed-off-by: Viresh Kumar
    Reviewed-by: Jeff Layton
    Reviewed-by: David Howells
    Reviewed-by: Steve French
    Signed-off-by: Jiri Kosina

    Viresh Kumar
     

11 May, 2015

1 commit

  • Doing a readdir on a dfs root can result in the dentries for directories
    with a dfs share mounted being replaced by new dentries for objects
    returned by the readdir call. These new dentries on shares mounted with
    unix extenstions show up as symlinks pointing to the dfs share.

    # mount -t cifs -o sec=none //vm140-31/dfsroot cifs
    # stat cifs/testlink/testfile; ls -l cifs
    File: ‘cifs/testlink/testfile’
    Size: 0 Blocks: 0 IO Block: 16384 regular
    empty file
    Device: 27h/39d Inode: 130120 Links: 1
    Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
    Access: 2015-03-31 13:55:50.106018200 +0100
    Modify: 2015-03-31 13:55:50.106018200 +0100
    Change: 2015-03-31 13:55:50.106018200 +0100
    Birth: -
    total 0
    drwxr-xr-x 2 root root 0 Mar 31 13:54 testdir
    lrwxrwxrwx 1 root root 19 Mar 24 14:25 testlink -> \vm140-31\test

    In the example above, the stat command mounts the dfs share at
    cifs/testlink. The subsequent ls on the dfsroot directory replaces the
    dentry for testlink with a symlink.

    In the earlier code, the d_invalidate command returned an -EBUSY error
    when attempting to invalidate directories. This stopped the code from
    replacing the directories with symlinks returned by the readdir call.
    Changes were recently made to the d_invalidate() command so
    that it no longer returns an error code. This results in the directory
    with the mounted dfs share being replaced by a symlink which denotes a
    dfs share.

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

    Sachin Prabhu
     

16 Apr, 2015

1 commit


23 Dec, 2014

1 commit

  • In spite of different file type,
    if file is same name and same inode number, old inode cache is used.
    This causes that you can not cd directory, can not cat SymbolicLink.
    So this patch is that if file type is different, return error.

    Reproducible sample :
    1. create file 'a' at cifs client.
    2. repeat rm and mkdir 'a' 4 times at server, then direcotry 'a' having same inode number is created.
    (Repeat 4 times, then same inode number is recycled.)
    (When server is under RHEL 6.6, 1 time is O.K. Always same inode number is recycled.)
    3. ls -li at client, then you can not cd directory, can not remove directory.

    SymbolicLink has same problem.

    Bug link:
    https://bugzilla.kernel.org/show_bug.cgi?id=90011

    Signed-off-by: Nakajima Akira
    Acked-by: Jeff Layton
    Signed-off-by: Steve French

    Nakajima Akira
     

11 Dec, 2014

1 commit

  • Pull VFS changes from Al Viro:
    "First pile out of several (there _definitely_ will be more). Stuff in
    this one:

    - unification of d_splice_alias()/d_materialize_unique()

    - iov_iter rewrite

    - killing a bunch of ->f_path.dentry users (and f_dentry macro).

    Getting that completed will make life much simpler for
    unionmount/overlayfs, since then we'll be able to limit the places
    sensitive to file _dentry_ to reasonably few. Which allows to have
    file_inode(file) pointing to inode in a covered layer, with dentry
    pointing to (negative) dentry in union one.

    Still not complete, but much closer now.

    - crapectomy in lustre (dead code removal, mostly)

    - "let's make seq_printf return nothing" preparations

    - assorted cleanups and fixes

    There _definitely_ will be more piles"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits)
    copy_from_iter_nocache()
    new helper: iov_iter_kvec()
    csum_and_copy_..._iter()
    iov_iter.c: handle ITER_KVEC directly
    iov_iter.c: convert copy_to_iter() to iterate_and_advance
    iov_iter.c: convert copy_from_iter() to iterate_and_advance
    iov_iter.c: get rid of bvec_copy_page_{to,from}_iter()
    iov_iter.c: convert iov_iter_zero() to iterate_and_advance
    iov_iter.c: convert iov_iter_get_pages_alloc() to iterate_all_kinds
    iov_iter.c: convert iov_iter_get_pages() to iterate_all_kinds
    iov_iter.c: convert iov_iter_npages() to iterate_all_kinds
    iov_iter.c: iterate_and_advance
    iov_iter.c: macros for iterating over iov_iter
    kill f_dentry macro
    dcache: fix kmemcheck warning in switch_names
    new helper: audit_file()
    nfsd_vfs_write(): use file_inode()
    ncpfs: use file_inode()
    kill f_dentry uses
    lockd: get rid of ->f_path.dentry->d_sb
    ...

    Linus Torvalds
     

08 Dec, 2014

1 commit


20 Nov, 2014

3 commits


17 Oct, 2014

2 commits

  • This is a bigger patch, but its size is mostly due to
    a single change for how we check for remapping illegal characters
    in file names - a lot of repeated, small changes to
    the way callers request converting file names.

    The final patch in the series does the following:

    1) changes default behavior for cifs to be more intuitive.
    Currently we do not map by default to seven reserved characters,
    ie those valid in POSIX but not in NTFS/CIFS/SMB3/Windows,
    unless a mount option (mapchars) is specified. Change this
    to by default always map and map using the SFM maping
    (like the Mac uses) unless the server negotiates the CIFS Unix
    Extensions (like Samba does when mounting with the cifs protocol)
    when the remapping of the characters is unnecessary. This should
    help SMB3 mounts in particular since Samba will likely be
    able to implement this mapping with its new "vfs_fruit" module
    as it will be doing for the Mac.
    2) if the user specifies the existing "mapchars" mount option then
    use the "SFU" (Microsoft Services for Unix, SUA) style mapping of
    the seven characters instead.
    3) if the user specifies "nomapposix" then disable SFM/MAC style mapping
    (so no character remapping would be used unless the user specifies
    "mapchars" on mount as well, as above).
    4) change all the places in the code that check for the superblock
    flag on the mount which is set by mapchars and passed in on all
    path based operation and change it to use a small function call
    instead to set the mapping type properly (and check for the
    mapping type in the cifs unicode functions)

    Signed-off-by: Steve French

    Steve French
     
  • This allows directory listings to Mac to display filenames
    correctly which have been created with illegal (to Windows)
    characters in their filename. It does not allow
    converting the other direction yet ie opening files with
    these characters (followon patch).

    There are seven reserved characters that need to be remapped when
    mounting to Windows, Mac (or any server without Unix Extensions) which
    are valid in POSIX but not in the other OS.

    : \ < > ? * |

    We used the normal UCS-2 remap range for this in order to convert this
    to/from UTF8 as did Windows Services for Unix (basically add 0xF000 to
    any of the 7 reserved characters), at least when the "mapchars" mount
    option was specified.

    Mac used a very slightly different "Services for Mac" remap range
    0xF021 through 0xF027. The attached patch allows cifs.ko (the kernel
    client) to read directories on macs containing files with these
    characters and display their names properly. In theory this even
    might be useful on mounts to Samba when the vfs_catia or new
    "vfs_fruit" module is loaded.

    Currently the 7 reserved characters look very strange in directory
    listings from cifs.ko to Mac server. This patch allows these file
    name characters to be read (requires specifying mapchars on mount).

    Two additional changes are needed:
    1) Make it more automatic: a way of detecting enough info so that
    we know to try to always remap these characters or not. Various
    have suggested that the SFM approach be made the default when
    the server does not support POSIX Unix extensions (cifs mounts
    to Samba for example) so need to make SFM remapping the default
    unless mapchars (SFU style mapping) specified on mount or no
    mapping explicitly requested or no mapping needed (cifs mounts to Samba).

    2) Adding a patch to map the characters the other direction
    (ie UTF-8 to UCS-2 on open). This patch does it for translating
    readdir entries (ie UCS-2 to UTF-8)

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

    Steve French
     

09 Oct, 2014

1 commit

  • Now that d_invalidate can no longer fail, stop returning a useless
    return code. For the few callers that checked the return code update
    remove the handling of d_invalidate failure.

    Reviewed-by: Miklos Szeredi
    Signed-off-by: "Eric W. Biederman"
    Signed-off-by: Al Viro

    Eric W. Biederman
     

26 Aug, 2014

1 commit

  • The existing code calls server->ops->close() that is not
    right. This causes XFS test generic/310 to fail. Fix this
    by using server->ops->closedir() function.

    Cc: # v3.7+
    Signed-off-by: Dan Carpenter
    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Pavel Shilovsky
     

17 Aug, 2014

1 commit

  • SMB2 servers indicates the end of a directory search with
    STATUS_NO_MORE_FILE error code that is not processed now.
    This causes generic/257 xfstest to fail. Fix this by triggering
    the end of search by this error code in SMB2_query_directory.

    Also when negotiating CIFS protocol we tell the server to close
    the search automatically at the end and there is no need to do
    it itself. In the case of SMB2 protocol, we need to close it
    explicitly - separate close directory checks for different
    protocols.

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

    Pavel Shilovsky
     

20 Jan, 2014

1 commit


12 Nov, 2013

1 commit

  • Now we treat any reparse point as a symbolic link and map it to a Unix
    one that is not true in a common case due to many reparse point types
    supported by SMB servers.

    Distinguish reparse point types into two groups:
    1) that can be accessed directly through a reparse point
    (junctions, deduplicated files, NFS symlinks);
    2) that need to be processed manually (Windows symbolic links, DFS);

    and map only Windows symbolic links to Unix ones.

    Cc:
    Acked-by: Jeff Layton
    Reported-and-tested-by: Joao Correia
    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Pavel Shilovsky
     

21 Sep, 2013

1 commit

  • Since we don't get info about the number of links from the readdir
    linfo levels, stat() will return 0 for st_nlink, and in particular,
    samba re-exported shares will show directories as files (as samba is
    keying off st_nlink before evaluating how to set the dos modebits)
    when doing a dir or ls.

    Copy nlink to the inode, unless it wasn't provided. Provide
    sane values if we don't have an existing one and none was provided.

    Signed-off-by: Jim McDonough
    Reviewed-by: Jeff Layton
    Reviewed-by: David Disseldorp
    Signed-off-by: Steve French

    Jim McDonough
     

09 Sep, 2013

1 commit


07 Aug, 2013

1 commit

  • David reported that commit c2b93e06 (cifs: only set ops for inodes in
    I_NEW state) caused a regression with mfsymlinks. Prior to that patch,
    if a mfsymlink dentry was instantiated at readdir time, the inode would
    get a new set of ops when it was revalidated. After that patch, this
    did not occur.

    This patch addresses this by simply skipping instantiating dentries in
    the readdir codepath when we know that they will need to be immediately
    revalidated. The next attempt to use that dentry will cause a new lookup
    to occur (which is basically what we want to happen anyway).

    Cc:
    Cc: "Stefan (metze) Metzmacher"
    Cc: Sachin Prabhu
    Reported-and-Tested-by: David McBride
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

04 Jul, 2013

1 commit

  • Pull cifs updates from Steve French:
    "Various CIFS/SMB2/SMB3 updates for 3.11. Includes bug fixes - SMB3
    support should be much more stable with key DFS fix and also signing
    possible now (although is more work to do to get SMB3 signing working
    well with multiuser).

    Mounts using the new SMB 3.02 dialect can now be done (specify
    "vers=3.02" on mount) against the most current Microsoft systems.

    Also includes a big cleanup of the cifs/smb2/smb3 authentication code
    from Jeff which fixes some long standing problems with the way allowed
    authentication flavors and signing are configured.

    Some followon patches later in the cycle will clean up allocation of
    structures for the various security mechanisms depending on what
    dialect is chosen (reduces memory usage a little) and to add support
    for the secure negotiate fsctl (for smb3) which prevents downgrade
    attacks."

    * 'for-next' of git://git.samba.org/sfrench/cifs-2.6: (39 commits)
    cifs: fill TRANS2_QUERY_FILE_INFO ByteCount fields
    cifs: fix SMB2 signing enablement in cifs_enable_signing
    [CIFS] Fix build warning
    [CIFS] SMB3 Signing enablement
    [CIFS] Do not set DFS flag on SMB2 open
    [CIFS] fix static checker warning
    cifs: try to handle the MUST SecurityFlags sanely
    When server doesn't provide SecurityBuffer on SMB2Negotiate pick default
    Handle big endianness in NTLM (ntlmv2) authentication
    revalidate directories instiantiated via FIND_* in order to handle DFS referrals
    SMB2 FSCTL and IOCTL worker function
    Charge at least one credit, if server says that it supports multicredit
    Remove typo
    Some missing share flags
    cifs: using strlcpy instead of strncpy
    Update headers to update various SMB3 ioctl definitions
    Update cifs version number
    Add ability to dipslay SMB3 share flags and capabilities for debugging
    Add some missing SMB3 and SMB3.02 flags
    Add SMB3.02 dialect support
    ...

    Linus Torvalds
     

29 Jun, 2013

1 commit


27 Jun, 2013

1 commit

  • We've had a long-standing problem with DFS referral points. CIFS servers
    generally try to make them look like directories in FIND_FIRST/NEXT
    responses. When you go to try to do a FIND_FIRST on them though, the
    server will then (correctly) return STATUS_PATH_NOT_COVERED. Mostly this
    manifests as spurious EREMOTE errors back to userland.

    This patch attempts to fix this by marking directories that are
    discovered via FIND_FIRST/NEXT for revaldiation. When the lookup code
    runs across them again, we'll reissue a QPathInfo against them and that
    will make it chase the referral properly.

    There is some performance penalty involved here and no I haven't
    measured it -- it'll be highly dependent upon the workload and contents
    of the mounted share. To try and mitigate that though, the code only
    marks the inode for revalidation when it's possible to run across a DFS
    referral. i.e.: when the kernel has DFS support built in and the share
    is "in DFS"

    [At the Microsoft plugfest we noted that usually the DFS links had
    the REPARSE attribute tag enabled - DFS junctions are reparse points
    after all - so I just added a check for that flag too so the
    performance impact should be smaller - Steve]

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

    Jeff Layton
     

05 May, 2013

1 commit

  • It's not obvious from reading the macro names that these macros
    are for debugging. Convert the names to a single more typical
    kernel style cifs_dbg macro.

    cERROR(1, ...) -> cifs_dbg(VFS, ...)
    cFYI(1, ...) -> cifs_dbg(FYI, ...)
    cFYI(DBG2, ...) -> cifs_dbg(NOISY, ...)

    Move the terminating format newline from the macro to the call site.

    Add CONFIG_CIFS_DEBUG function cifs_vfs_err to emit the
    "CIFS VFS: " prefix for VFS messages.

    Size is reduced ~ 1% when CONFIG_CIFS_DEBUG is set (default y)

    $ size fs/cifs/cifs.ko*
    text data bss dec hex filename
    265245 2525 132 267902 4167e fs/cifs/cifs.ko.new
    268359 2525 132 271016 422a8 fs/cifs/cifs.ko.old

    Other miscellaneous changes around these conversions:

    o Miscellaneous typo fixes
    o Add terminating \n's to almost all formats and remove them
    from the macros to be more kernel style like. A few formats
    previously had defective \n's
    o Remove unnecessary OOM messages as kmalloc() calls dump_stack
    o Coalesce formats to make grep easier,
    added missing spaces when coalescing formats
    o Use %s, __func__ instead of embedded function name
    o Removed unnecessary "cifs: " prefixes
    o Convert kzalloc with multiply to kcalloc
    o Remove unused cifswarn macro

    Signed-off-by: Joe Perches
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Joe Perches
     

26 Feb, 2013

1 commit


23 Feb, 2013

1 commit


21 Dec, 2012

1 commit

  • Oliver reported that commit cd60042c caused his cifs mounts to
    continually thrash through new inodes on readdir. His servers are not
    sending inode numbers (or he's not using them), and the new test in
    that function doesn't account for that sort of setup correctly.

    If we're not using server inode numbers, then assume that the inode
    attached to the dentry hasn't changed. Go ahead and update the
    attributes in place, but keep the same inode number.

    Cc: # v3.5+
    Reported-and-Tested-by: Oliver Mössinger
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

06 Dec, 2012

2 commits


30 Nov, 2012

1 commit


29 Sep, 2012

1 commit

  • Rebased and resending the patch.

    Path based queries can fail for lack of access, especially during lookup
    during open.
    open itself would actually succeed becasue of back up intent bit
    but queries (either path or file handle based) do not have a means to
    specifiy backup intent bit.
    So query the file info during lookup using
    trans2 / findfirst / file_id_full_dir_info
    to obtain file info as well as file_id/inode value.

    Signed-off-by: Shirish Pargaonkar
    Acked-by: Jeff Layton
    Signed-off-by: Steve French

    Shirish Pargaonkar
     

25 Sep, 2012

1 commit