12 Jun, 2020

1 commit


05 Jun, 2020

2 commits

  • Move the channel (TCP_Server_Info*) selection from the tranport
    layer to higher in the call stack so that:

    - credit handling is done with the server that will actually be used
    to send.
    * ->wait_mtu_credit
    * ->set_credits / set_credits
    * ->add_credits / add_credits
    * add_credits_and_wake_if

    - potential reconnection (smb2_reconnect) done when initializing a
    request is checked and done with the server that will actually be
    used to send.

    To do this:

    - remove the cifs_pick_channel() call out of compound_send_recv()

    - select channel and pass it down by adding a cifs_pick_channel(ses)
    call in:
    - smb311_posix_mkdir
    - SMB2_open
    - SMB2_ioctl
    - __SMB2_close
    - query_info
    - SMB2_change_notify
    - SMB2_flush
    - smb2_async_readv (if none provided in context param)
    - SMB2_read (if none provided in context param)
    - smb2_async_writev (if none provided in context param)
    - SMB2_write (if none provided in context param)
    - SMB2_query_directory
    - send_set_info
    - SMB2_oplock_break
    - SMB311_posix_qfs_info
    - SMB2_QFS_info
    - SMB2_QFS_attr
    - smb2_lockv
    - SMB2_lease_break
    - smb2_compound_op
    - smb2_set_ea
    - smb2_ioctl_query_info
    - smb2_query_dir_first
    - smb2_query_info_comound
    - smb2_query_symlink
    - cifs_writepages
    - cifs_write_from_iter
    - cifs_send_async_read
    - cifs_read
    - cifs_readpages

    - add TCP_Server_Info *server param argument to:
    - cifs_send_recv
    - compound_send_recv
    - SMB2_open_init
    - SMB2_query_info_init
    - SMB2_set_info_init
    - SMB2_close_init
    - SMB2_ioctl_init
    - smb2_iotcl_req_init
    - SMB2_query_directory_init
    - SMB2_notify_init
    - SMB2_flush_init
    - build_qfs_info_req
    - smb2_hdr_assemble
    - smb2_reconnect
    - fill_small_buf
    - smb2_plain_req_init
    - __smb2_plain_req_init

    The read/write codepath is different than the rest as it is using
    pages, io iterators and async calls. To deal with those we add a
    server pointer in the cifs_writedata/cifs_readdata/cifs_io_parms
    context struct and set it in:

    - cifs_writepages (wdata)
    - cifs_write_from_iter (wdata)
    - cifs_readpages (rdata)
    - cifs_send_async_read (rdata)

    The [rw]data->server pointer is eventually copied to
    cifs_io_parms->server to pass it down to SMB2_read/SMB2_write.
    If SMB2_read/SMB2_write is called from a different place that doesn't
    set the server field it will pick a channel.

    Some places do not pick a channel and just use ses->server or
    cifs_ses_server(ses). All cifs_ses_server(ses) calls are in codepaths
    involving negprot/sess.setup.

    - SMB2_negotiate (binding channel)
    - SMB2_sess_alloc_buffer (binding channel)
    - SMB2_echo (uses provided one)
    - SMB2_logoff (uses master)
    - SMB2_tdis (uses master)

    (list not exhaustive)

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

    Aurelien Aptel
     
  • SMB2_read/SMB2_write check and use cifs_io_parms->server, which might
    be uninitialized memory.

    This change makes all callers zero-initialize the struct.

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

    Aurelien Aptel
     

23 Mar, 2020

1 commit


04 Feb, 2020

1 commit

  • When "backup intent" is requested on the mount (e.g. backupuid or
    backupgid mount options), the corresponding flag was missing from
    some of the operations.

    Change all operations to use the macro cifs_create_options() to
    set the backup intent flag if needed.

    Signed-off-by: Amir Goldstein
    Signed-off-by: Steve French

    Amir Goldstein
     

08 May, 2019

1 commit

  • Two of the common symlink formats use reparse points
    (unlike mfsymlinks and also unlike the SMB1 posix
    extensions). This is the first part of the fixes
    to allow these reparse points (NFS style and Windows
    symlinks) to be resolved properly as symlinks by the
    client.

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

    Ronnie Sahlberg
     

05 Mar, 2019

1 commit

  • a trivial patch that replaces all use of snprintf with scnprintf.
    scnprintf() is generally seen as a safer function to use than
    snprintf for many use cases.

    In our case, there is no actual difference between the two since we never
    look at the return value. Thus we did not have any of the bugs that
    scnprintf protects against and the patch does nothing.

    However, for people reading our code it will be a receipt that we
    have done our due dilligence and checked our code for this type of bugs.

    See the presentation "Making C Less Dangerous In The Linux Kernel"
    at this years LCA

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

    Ronnie Sahlberg
     

08 Aug, 2018

1 commit


08 Jun, 2018

1 commit


02 Apr, 2018

1 commit

  • shash and sdesc and always allocated and freed together.
    * abstract this in new functions cifs_alloc_hash() and cifs_free_hash().
    * make smb2/3 crypto allocation independent from each other.

    Signed-off-by: Aurelien Aptel
    Signed-off-by: Steve French
    Reviewed-by: Ronnie Sahlberg
    CC: Stable

    Aurelien Aptel
     

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
     

15 Dec, 2016

1 commit


28 Sep, 2016

1 commit


31 Dec, 2015

1 commit


09 Dec, 2015

1 commit

  • new method: ->get_link(); replacement of ->follow_link(). The differences
    are:
    * inode and dentry are passed separately
    * might be called both in RCU and non-RCU mode;
    the former is indicated by passing it a NULL dentry.
    * when called that way it isn't allowed to block
    and should return ERR_PTR(-ECHILD) if it needs to be called
    in non-RCU mode.

    It's a flagday change - the old method is gone, all in-tree instances
    converted. Conversion isn't hard; said that, so far very few instances
    do not immediately bail out when called in RCU mode. That'll change
    in the next commits.

    Signed-off-by: Al Viro

    Al Viro
     

23 Jun, 2015

1 commit

  • Pull vfs updates from Al Viro:
    "In this pile: pathname resolution rewrite.

    - recursion in link_path_walk() is gone.

    - nesting limits on symlinks are gone (the only limit remaining is
    that the total amount of symlinks is no more than 40, no matter how
    nested).

    - "fast" (inline) symlinks are handled without leaving rcuwalk mode.

    - stack footprint (independent of the nesting) is below kilobyte now,
    about on par with what it used to be with one level of nested
    symlinks and ~2.8 times lower than it used to be in the worst case.

    - struct nameidata is entirely private to fs/namei.c now (not even
    opaque pointers are being passed around).

    - ->follow_link() and ->put_link() calling conventions had been
    changed; all in-tree filesystems converted, out-of-tree should be
    able to follow reasonably easily.

    For out-of-tree conversions, see Documentation/filesystems/porting
    for details (and in-tree filesystems for examples of conversion).

    That has sat in -next since mid-May, seems to survive all testing
    without regressions and merges clean with v4.1"

    * 'for-linus-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (131 commits)
    turn user_{path_at,path,lpath,path_dir}() into static inlines
    namei: move saved_nd pointer into struct nameidata
    inline user_path_create()
    inline user_path_parent()
    namei: trim do_last() arguments
    namei: stash dfd and name into nameidata
    namei: fold path_cleanup() into terminate_walk()
    namei: saner calling conventions for filename_parentat()
    namei: saner calling conventions for filename_create()
    namei: shift nameidata down into filename_parentat()
    namei: make filename_lookup() reject ERR_PTR() passed as name
    namei: shift nameidata inside filename_lookup()
    namei: move putname() call into filename_lookup()
    namei: pass the struct path to store the result down into path_lookupat()
    namei: uninline set_root{,_rcu}()
    namei: be careful with mountpoint crossings in follow_dotdot_rcu()
    Documentation: remove outdated information from automount-support.txt
    get rid of assorted nameidata-related debris
    lustre: kill unused helper
    lustre: kill unused macro (LOOKUP_CONTINUE)
    ...

    Linus Torvalds
     

11 May, 2015

3 commits

  • its only use is getting passed to nd_jump_link(), which can obtain
    it from current->nameidata

    Signed-off-by: Al Viro

    Al Viro
     
  • a) instead of storing the symlink body (via nd_set_link()) and returning
    an opaque pointer later passed to ->put_link(), ->follow_link() _stores_
    that opaque pointer (into void * passed by address by caller) and returns
    the symlink body. Returning ERR_PTR() on error, NULL on jump (procfs magic
    symlinks) and pointer to symlink body for normal symlinks. Stored pointer
    is ignored in all cases except the last one.

    Storing NULL for opaque pointer (or not storing it at all) means no call
    of ->put_link().

    b) the body used to be passed to ->put_link() implicitly (via nameidata).
    Now only the opaque pointer is. In the cases when we used the symlink body
    to free stuff, ->follow_link() now should store it as opaque pointer in addition
    to returning it.

    Signed-off-by: Al Viro

    Al Viro
     
  • Cifs client has problem with reserved chars filename.

    [BUG1] : several functions handle incorrect value of mapchars
    - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
    + cifs_remap(cifs_sb));

    [BUG2] : forget to convert reserved chars when creating SymbolicLink.
    - CIFSUnixCreateSymLink() calls cifs_strtoUTF16
    + CIFSUnixCreateSymLink() calls cifsConvertToUTF16() with remap

    [BUG3] : forget to convert reserved chars when getting SymbolicLink.
    - CIFSSMBUnixQuerySymLink() calls cifs_strtoUTF16
    + CIFSSMBUnixQuerySymLink() calls cifsConvertToUTF16() with remap

    [BUG4] : /proc/mounts don't show "mapposix" when using mapposix mount option
    + cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR)
    + seq_puts(s, ",mapposix");

    Reported-by: t.wede@kw-reneg.de
    Reported-by: Nakajima Akira
    Signed-off-by: Nakajima Akira
    Signed-off-by: Carl Schaefer
    Signed-off-by: Steve French

    Nakajima Akira
     

16 Apr, 2015

1 commit


18 Oct, 2014

1 commit


17 Oct, 2014

3 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
     
  • Adds support on SMB2.1 and SMB3 mounts for emulation of symlinks
    via the "Minshall/French" symlink format already used for cifs
    mounts when mfsymlinks mount option is used (and also used by Apple).
    http://wiki.samba.org/index.php/UNIX_Extensions#Minshall.2BFrench_symlinks
    This second patch adds support to query them (recognize them as symlinks
    and read them). Third version of patch makes minor corrections
    to error handling.

    Signed-off-by: Steve French
    Reviewed-by: Stefan Metzmacher

    Steve French
     
  • Adds support on SMB2.1 and SMB3 mounts for emulation of symlinks
    via the "Minshall/French" symlink format already used for cifs
    mounts when mfsymlinks mount option is used (and also used by Apple).
    http://wiki.samba.org/index.php/UNIX_Extensions#Minshall.2BFrench_symlinks
    This first patch adds support to create them. The next patch will
    add support for recognizing them and reading them. Although CIFS/SMB3
    have other types of symlinks, in the many use cases they aren't
    practical (e.g. either require cifs only mounts with unix extensions
    to Samba, or require the user to be Administrator to Windows for SMB3).
    This also helps enable running additional xfstests over SMB3 (since some
    xfstests directly or indirectly require symlink support).

    Signed-off-by: Steve French
    CC: Stefan Metzmacher

    Steve French
     

16 Sep, 2014

1 commit


15 Sep, 2014

1 commit


17 Jun, 2014

1 commit


31 Jan, 2014

1 commit

  • MF Symlinks are regular files containing content in a specified format.

    The function couldbe_mf_symlink() checks the mode for a set S_IFREG bit
    as a test to confirm that it is a regular file. This bit is also set for
    other filetypes and simply checking for this bit being set may return
    false positives.

    We ensure that we are actually checking for a regular file by using the
    S_ISREG macro to test instead.

    Signed-off-by: Sachin Prabhu
    Reviewed-by: Jeff Layton
    Reported-by: Neil Brown
    Reported-by: Dan Carpenter
    Signed-off-by: Steve French

    Sachin Prabhu
     

20 Jan, 2014

8 commits


28 Dec, 2013

1 commit

  • When we obtain tcon from cifs_sb, we use cifs_sb_tlink() to first obtain
    tlink which also grabs a reference to it. We do not drop this reference
    to tlink once we are done with the call.

    The patch fixes this issue by instead passing tcon as a parameter and
    avoids having to obtain a reference to the tlink. A lookup for the tcon
    is already made in the calling functions and this way we avoid having to
    re-run the lookup. This is also consistent with the argument list for
    other similar calls for M-F symlinks.

    We should also return an ENOSYS when we do not find a protocol specific
    function to lookup the MF Symlink data.

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

    Sachin Prabhu
     

25 Oct, 2013

1 commit


09 Sep, 2013

1 commit


31 Jul, 2013

1 commit

  • When use of symlinks is enabled (mounting with mfsymlinks option) to
    non-Samba servers, we always tried to use cifs, even when we
    were mounted with SMB2 or SMB3, which causes the server to drop the
    network connection.

    This patch separates out the protocol specific operations for cifs from
    the code which recognizes symlinks, and fixes the problem where
    with SMB2 mounts we attempt cifs operations to open and read
    symlinks. The next patch will add support for SMB2 for opening
    and reading symlinks. Additional followon patches will address
    the similar problem creating symlinks.

    Signed-off-by: Steve French

    Steve French