24 Oct, 2018

3 commits

  • We do not call cifs_open_file() for directories and thus we do not have a
    pSMBFile we can extract the FIDs from.

    Solve this by instead always using a compounded open/query/close for
    the passthrough ioctl.

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

    Ronnie Sahlberg
     
  • This allows userspace tools to query the raw info levels for cifs files
    and process the response in userspace.
    In particular this is useful for many of those data where there is no
    corresponding native data structure in linux.
    For example querying the security descriptor for a file and extract the
    SIDs.

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

    Ronnie Sahlberg
     
  • Fixes gcc '-Wunused-but-set-variable' warning:

    fs/cifs/ioctl.c: In function 'cifs_ioctl':
    fs/cifs/ioctl.c:164:23: warning:
    variable 'cifs_sb' set but not used [-Wunused-but-set-variable]

    Signed-off-by: YueHaibing
    Signed-off-by: Steve French

    YueHaibing
     

09 Jul, 2017

1 commit

  • Remove the CONFIG_CIFS_SMB2 ifdef and Kconfig option since they
    must always be on now.

    For various security reasons, SMB3 and later are STRONGLY preferred
    over CIFS and older dialects, and SMB3 (and later) will now be
    the default dialects so we do not want to allow them to be
    ifdeffed out.

    In the longer term, we may be able to make older CIFS support
    disableable in Kconfig with a new set of #ifdef, but we always
    want SMB3 and later support enabled.

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

    Steve French
     

04 May, 2017

1 commit


03 May, 2017

1 commit

  • As with 618763958b22, an open directory may have a NULL private_data
    pointer prior to readdir. CIFS_ENUMERATE_SNAPSHOTS must check for this
    before dereference.

    Fixes: 834170c85978 ("Enable previous version support")
    Signed-off-by: David Disseldorp
    CC: Stable
    Signed-off-by: Steve French

    David Disseldorp
     

28 Apr, 2017

1 commit

  • commit 620d8745b35d ("Introduce cifs_copy_file_range()") changes the
    behaviour of the cifs ioctl call CIFS_IOC_COPYCHUNK_FILE. In case of
    successful writes, it now returns the number of bytes written. This
    return value is treated as an error by the xfstest cifs/001. Depending
    on the errno set at that time, this may or may not result in the test
    failing.

    The patch fixes this by setting the return value to 0 in case of
    successful writes.

    Fixes: commit 620d8745b35d ("Introduce cifs_copy_file_range()")
    Reported-by: Eryu Guan
    Signed-off-by: Sachin Prabhu
    Acked-by: Pavel Shilovsky
    Cc: stable@vger.kernel.org
    Signed-off-by: Steve French

    Sachin Prabhu
     

07 Apr, 2017

2 commits

  • The earlier changes to copy range for cifs unintentionally disabled the more
    common form of server side copy.

    The patch introduces the file_operations helper cifs_copy_file_range()
    which is used by the syscall copy_file_range. The new file operations
    helper allows us to perform server side copies for SMB2.0 and 2.1
    servers as well as SMB 3.0+ servers which do not support the ioctl
    FSCTL_DUPLICATE_EXTENTS_TO_FILE.

    The new helper uses the ioctl FSCTL_SRV_COPYCHUNK_WRITE to perform
    server side copies. The helper is called by vfs_copy_file_range() only
    once an attempt to clone the file using the ioctl
    FSCTL_DUPLICATE_EXTENTS_TO_FILE has failed.

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

    Sachin Prabhu
     
  • Server side copy is one of the most important mechanisms smb2/smb3
    supports and it was unintentionally disabled for most use cases.

    Renaming calls to reflect the underlying smb2 ioctl called. This is
    similar to the name duplicate_extents used for a similar ioctl which is
    also used to duplicate files by reusing fs blocks. The name change is to
    avoid confusion.

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

    Sachin Prabhu
     

03 Dec, 2016

1 commit


14 Oct, 2016

1 commit


08 Dec, 2015

1 commit

  • The btrfs clone ioctls are now adopted by other file systems, with NFS
    and CIFS already having support for them, and XFS being under active
    development. To avoid growth of various slightly incompatible
    implementations, add one to the VFS. Note that clones are different from
    file copies in several ways:

    - they are atomic vs other writers
    - they support whole file clones
    - they support 64-bit legth clones
    - they do not allow partial success (aka short writes)
    - clones are expected to be a fast metadata operation

    Because of that it would be rather cumbersome to try to piggyback them on
    top of the recent clone_file_range infrastructure. The converse isn't
    true and the clone_file_range system call could try clone file range as
    a first attempt to copy, something that further patches will enable.

    Based on earlier work from Peng Tao.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

09 Nov, 2015

1 commit

  • FSCTL_SRV_COPYCHUNK_WRITE only requires that the source and target
    be on the same server (not the same volume or same share),
    so relax the existing check (which required them to be on
    the same share). Note that this works to Windows (and presumably
    most other NAS) but Samba requires that the source
    and target be on the same share. Moving a file across
    shares is a common use case and can be very heplful (100x faster).

    Signed-off-by: Steve French
    Reviewed-by: David Disseldorp

    Steve French
     

11 Sep, 2015

1 commit

  • This might lead to local privilege escalation (code execution as
    kernel) for systems where the following conditions are met:

    - CONFIG_CIFS_SMB2 and CONFIG_CIFS_POSIX are enabled
    - a cifs filesystem is mounted where:
    - the mount option "vers" was used and set to a value >=2.0
    - the attacker has write access to at least one file on the filesystem

    To attack this, an attacker would have to guess the target_tcon
    pointer (but guessing wrong doesn't cause a crash, it just returns an
    error code) and win a narrow race.

    CC: Stable
    Signed-off-by: Jann Horn
    Signed-off-by: Steve French

    Jann Horn
     

20 Aug, 2015

1 commit

  • The server exports information about the share and underlying
    device under an SMB3 export, including its attributes and
    capabilities, which is stored by cifs.ko when first connecting
    to the share.

    Add ioctl to cifs.ko to allow user space smb3 helper utilities
    (in cifs-utils) to display this (e.g. via smb3util).

    This information is also useful for debugging and for
    resolving configuration errors.

    Signed-off-by: Steve French

    Steve French
     

29 Jun, 2015

2 commits

  • set integrity increases reliability of files stored on SMB3 servers.
    Add ioctl to allow setting this on files on SMB3 and later mounts.

    Signed-off-by: Steve French

    Steve French
     
  • Getting fantastic copy performance with cp --reflink over SMB3.11
    using the new FSCTL_DUPLICATE_EXTENTS.

    This FSCTL was added in the SMB3.11 dialect (testing was
    against REFS file system) so have put it as a 3.11 protocol
    specific operation ("vers=3.1.1" on the mount). Tested at
    the SMB3 plugfest in Redmond.

    It depends on the new FS Attribute (BLOCK_REFCOUNTING) which
    is used to advertise support for the ability to do this ioctl
    (if you can support multiple files pointing to the same block
    than this refcounting ability or equivalent is needed to
    support the new reflink-like duplicate extent SMB3 ioctl.

    Signed-off-by: Steve French

    Steve French
     

19 Jan, 2015

1 commit

  • It really needs to check that src is non-directory *and* use
    {un,}lock_two_nodirectories(). As it is, it's trivial to cause
    double-lock (ioctl(fd, CIFS_IOC_COPYCHUNK_FILE, fd)) and if the
    last argument is an fd of directory, we are asking for trouble
    by violating the locking order - all directories go before all
    non-directories. If the last argument is an fd of parent
    directory, it has 50% odds of locking child before parent,
    which will cause AB-BA deadlock if we race with unlink().

    Cc: stable@vger.kernel.org @ 3.13+
    Signed-off-by: Al Viro

    Al Viro
     

22 May, 2014

1 commit


25 Nov, 2013

1 commit

  • Change cifs.ko to using CIFS_IOCTL_COPYCHUNK instead
    of BTRFS_IOC_CLONE to avoid confusion about whether
    copy-on-write is required or optional for this operation.

    SMB2/SMB3 copyoffload had used the BTRFS_IOC_CLONE ioctl since
    they both speed up copy by offloading the copy rather than
    passing many read and write requests back and forth and both have
    identical syntax (passing file handles), but for SMB2/SMB3
    CopyChunk the server is not required to use copy-on-write
    to make a copy of the file (although some do), and Christoph
    has commented that since CopyChunk does not require
    copy-on-write we should not reuse BTRFS_IOC_CLONE.

    This patch renames the ioctl to use a cifs specific IOCTL
    CIFS_IOCTL_COPYCHUNK. This ioctl is particularly important
    for SMB2/SMB3 since large file copy over the network otherwise
    can be very slow, and with this is often more than 100 times
    faster putting less load on server and client.

    Note that if a copy syscall is ever introduced, depending on
    its requirements/format it could end up using one of the other
    three methods that CIFS/SMB2/SMB3 can do for copy offload,
    but this method is particularly useful for file copy
    and broadly supported (not just by Samba server).

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

    Steve French
     

14 Nov, 2013

1 commit

  • This first patch adds the ability for us to do a server side copy
    (ie fast copy offloaded to the server to perform, aka refcopy)

    "cp --reflink"

    of one file to another located on the same server. This
    is much faster than traditional copy (which requires
    reading and writing over the network and extra
    memcpys).

    This first version is not going to be copy
    files larger than about 1MB (to Samba) until I add
    support for multiple chunks and for autoconfiguring
    the chunksize.

    It includes:
    1) processing of the ioctl
    2) marshalling and sending the SMB2/SMB3 fsctl over the network
    3) simple parsing of the response

    It does not include yet (these will be in followon patches to come soon):
    1) support for multiple chunks
    2) support for autoconfiguring and remembering the chunksize
    3) Support for the older style copychunk which Samba 4.1 server supports
    (because this requires write permission on the target file, which
    cp does not give you, apparently per-posix). This may require
    a distinct tool (other than cp) and other ioctl to implement.

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

    Steve French
     

03 Nov, 2013

1 commit


28 Oct, 2013

1 commit

  • Allow cifs/smb2/smb3 to return whether or not a file is compressed
    via lsattr, and allow SMB2/SMB3 to set the per-file compression
    flag ("chattr +c filename" on an smb3 mount).

    Windows users often set the compressed flag (it can be
    done from the desktop and file manager). David Disseldorp
    has patches to Samba server to support this (at least on btrfs)
    which are complementary to this

    Signed-off-by: Steve French

    Steve French
     

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
     

23 Feb, 2013

1 commit


25 Sep, 2012

2 commits


24 Jul, 2012

1 commit


17 May, 2012

1 commit


27 May, 2011

1 commit


09 Nov, 2010

1 commit

  • Commit 13cfb7334e made cifs_ioctl use the tlink attached to the
    cifsFileInfo for a filp. This ignores the case of an open directory
    however, which in CIFS can have a NULL private_data until a readdir
    is done on it.

    This patch re-adds the NULL pointer checks that were removed in commit
    50ae28f01 and moves the setting of tcon and "caps" variables lower.

    Long term, a better fix would be to establish a f_op->open routine for
    directories that populates that field at open time, but that requires
    some other changes to how readdir calls are handled.

    Reported-by: Kjell Rune Skaaraas
    Reviewed-and-Tested-by: Suresh Jayaraman
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

02 Nov, 2010

1 commit

  • Stanse found that pSMBFile in cifs_ioctl and file->f_path.dentry in
    cifs_user_write are dereferenced prior their test to NULL.

    The alternative is not to dereference them before the tests. The patch is
    to point out the problem, you have to decide.

    While at it we cache the inode in cifs_user_write to a local variable
    and use all over the function.

    Signed-off-by: Jiri Slaby
    Cc: Steve French
    Cc: linux-cifs@vger.kernel.org
    Cc: Jeff Layton
    Cc: Christoph Hellwig
    Signed-off-by: Steve French

    Jiri Slaby
     

07 Oct, 2010

1 commit


30 Sep, 2010

1 commit


02 Aug, 2010

1 commit


21 Apr, 2010

1 commit

  • Neaten cERROR and cFYI macros, reduce text space
    ~2.5K

    Convert '__FILE__ ": " fmt' to '"%s: " fmt', __FILE__' to save text space
    Surround macros with do {} while
    Add parentheses to macros
    Make statement expression macro from macro with assign
    Remove now unnecessary parentheses from cFYI and cERROR uses

    defconfig with CIFS support old
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    156012 1760 148 157920 268e0 fs/cifs/built-in.o

    defconfig with CIFS support old
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    153508 1760 148 155416 25f18 fs/cifs/built-in.o

    allyesconfig old:
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    309138 3864 74824 387826 5eaf2 fs/cifs/built-in.o

    allyesconfig new
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    305655 3864 74824 384343 5dd57 fs/cifs/built-in.o

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

    Joe Perches
     

14 Nov, 2008

1 commit

  • Wrap access to task credentials so that they can be separated more easily from
    the task_struct during the introduction of COW creds.

    Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id().

    Change some task->e?[ug]id to task_e?[ug]id(). In some places it makes more
    sense to use RCU directly rather than a convenient wrapper; these will be
    addressed by later patches.

    Signed-off-by: David Howells
    Reviewed-by: James Morris
    Acked-by: Serge Hallyn
    Cc: Steve French
    Cc: linux-cifs-client@lists.samba.org
    Signed-off-by: James Morris

    David Howells
     

15 May, 2008

1 commit


08 Feb, 2008

1 commit


10 Jul, 2007

1 commit