13 Oct, 2011

2 commits

  • Add mount options backupuid and backugid.

    It allows an authenticated user to access files with the intent to back them
    up including their ACLs, who may not have access permission but has
    "Backup files and directories user right" on them (by virtue of being part
    of the built-in group Backup Operators.

    When mount options backupuid is specified, cifs client restricts the
    use of backup intents to the user whose effective user id is specified
    along with the mount option.

    When mount options backupgid is specified, cifs client restricts the
    use of backup intents to the users whose effective user id belongs to the
    group id specified along with the mount option.

    If an authenticated user is not part of the built-in group Backup Operators
    at the server, access to such files is denied, even if allowed by the client.

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

    Shirish Pargaonkar
     
  • The variable names in this function are so ambiguous that it's very
    difficult to know what it's doing. Rename them to make it a bit more
    clear.

    Also, remove a redundant length check. cifsd checks to make sure that
    the rfclen isn't larger than the maximum frame size when it does the
    receive.

    Finally, change checkSMB to return a real error code (-EIO) when
    it finds an error. That will help simplify some coming changes in the
    callers.

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

    Jeff Layton
     

01 Aug, 2011

1 commit

  • Currently, we take a sb->s_active reference and a cifsFileInfo reference
    when an oplock break workqueue job is queued. This is unnecessary and
    more complicated than it needs to be. Also as Al points out,
    deactivate_super has non-trivial locking implications so it's best to
    avoid that if we can.

    Instead, just cancel any pending oplock breaks for this filehandle
    synchronously in cifsFileInfo_put after taking it off the lists.
    That should ensure that this job doesn't outlive the structures it
    depends on.

    Reported-by: Al Viro
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

27 May, 2011

1 commit


19 May, 2011

2 commits

  • This is the same patch as originally posted, just with some merge
    conflicts fixed up...

    Currently, the ByteCount is usually converted to host-endian on receive.
    This is confusing however, as we need to keep two sets of routines for
    accessing it, and keep track of when to use each routine. Munging
    received packets like this also limits when the signature can be
    calulated.

    Simplify the code by keeping the received ByteCount in little-endian
    format. This allows us to eliminate a set of routines for accessing it
    and we can now drop the *_le suffixes from the accessor functions since
    that's now implied.

    While we're at it, switch all of the places that read the ByteCount
    directly to use the get_bcc inline which should also clean up some
    unaligned accesses.

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

    Jeff Layton
     
  • There is one big endian field in the cifs protocol, the RFC1001
    length, which cifs code (unlike in the smb2 code) had been handling as
    u32 until the last possible moment, when it was converted to be32 (its
    native form) before sending on the wire. To remove the last sparse
    endian warning, and to make this consistent with the smb2
    implementation (which always treats the fields in their
    native size and endianness), convert all uses of smb_buf_length to
    be32.

    This version incorporates Christoph's comment about
    using be32_add_cpu, and fixes a typo in the second
    version of the patch.

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

    Steve French
     

12 Apr, 2011

2 commits


01 Feb, 2011

1 commit

  • The cERROR message in checkSMB when the calculated length doesn't match
    the RFC1001 length is incorrect in many cases. It always says that the
    RFC1001 length is bigger than the SMB, even when it's actually the
    reverse.

    Fix the error message to say the reverse of what it does now when the
    SMB length goes beyond the end of the received data. Also, clarify the
    error message when the RFC length is too big. Finally, clarify the
    comments to show that the 512 byte limit on extra data at the end of
    the packet is arbitrary.

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

    Jeff Layton
     

31 Jan, 2011

2 commits

  • Currently, we allow the pending_mid_q to grow without bound with
    SIGKILL'ed processes. This could eventually be a DoS'able problem. An
    unprivileged user could a process that does a long-running call and then
    SIGKILL it.

    If he can also intercept the NT_CANCEL calls or the replies from the
    server, then the pending_mid_q could grow very large, possibly even to
    2^16 entries which might leave GetNextMid in an infinite loop. Fix this
    by imposing a hard limit of 32k calls per server. If we cross that
    limit, set the tcpStatus to CifsNeedReconnect to force cifsd to
    eventually reconnect the socket and clean out the pending_mid_q.

    While we're at it, clean up the function a bit and eliminate an
    unnecessary NULL pointer check.

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

    Jeff Layton
     
  • ...just cleanup. There should be no behavior change.

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

    Jeff Layton
     

21 Jan, 2011

1 commit

  • Move cifsConvertToUCS to cifs_unicode.c where all of the other unicode
    related functions live. Have it store mapped characters in 'temp' and
    then use put_unaligned_le16 to copy it to the target buffer. Also fix
    the comments to match kernel coding style.

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

    Jeff Layton
     

20 Jan, 2011

1 commit

  • When we get oplock break notification we should set the appropriate
    value of OplockLevel field in oplock break acknowledge according to
    the oplock level held by the client in this time. As we only can have
    level II oplock or no oplock in the case of oplock break, we should be
    aware only about clientCanCacheRead field in cifsInodeInfo structure.

    Also fix bug connected with wrong interpretation of OplockLevel field
    during oplock break notification processing.

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

    Pavel Shilovsky
     

06 Nov, 2010

1 commit


03 Nov, 2010

1 commit


25 Oct, 2010

1 commit


22 Oct, 2010

1 commit

  • Now that it's feasible for a cifsFileInfo to outlive the filp under
    which it was created, move the close processing into cifsFileInfo_put.

    This means that the last user of the filehandle always does the actual
    on the wire close call. This also allows us to get rid of the closePend
    flag from cifsFileInfo. If we have an active reference to the file
    then it's never going to have a close pending.

    cifs_close is converted to simply put the filehandle.

    Signed-off-by: Jeff Layton
    Reviewed-by: Suresh Jayaraman
    Signed-off-by: Steve French

    Steve French
     

21 Oct, 2010

1 commit

  • cifs_tcp_ses_lock is a rwlock with protects the cifs_tcp_ses_list,
    server->smb_ses_list and the ses->tcon_list. It also protects a few
    ref counters in server, ses and tcon. In most cases the critical section
    doesn't seem to be large, in a few cases where it is slightly large, there
    seem to be really no benefit from concurrent access. I briefly considered RCU
    mechanism but it appears to me that there is no real need.

    Replace it with a spinlock and get rid of the last rwlock in the cifs code.

    Signed-off-by: Suresh Jayaraman
    Signed-off-by: Steve French

    Suresh Jayaraman
     

18 Oct, 2010

1 commit

  • Convert this lock to a regular spinlock

    A rwlock_t offers little value here. It's more expensive than a regular
    spinlock unless you have a fairly large section of code that runs under
    the read lock and can benefit from the concurrency.

    Additionally, we need to ensure that the refcounting for files isn't
    racy and to do that we need to lock areas that can increment it for
    write. That means that the areas that can actually use a read_lock are
    very few and relatively infrequently used.

    While we're at it, change the name to something easier to type, and fix
    a bug in find_writable_file. cifsFileInfo_put can sleep and shouldn't be
    called while holding the lock.

    Signed-off-by: Jeff Layton
    Reviewed-by: Suresh Jayaraman
    Signed-off-by: Steve French

    Jeff Layton
     

13 Oct, 2010

1 commit

  • cifsFileInfo is a bit problematic. It contains a reference back to the
    struct file itself. This makes it difficult for a cifsFileInfo to exist
    without a corresponding struct file.

    It would be better instead of the cifsFileInfo just held info pertaining
    to the open file on the server instead without any back refrences to the
    struct file. This would allow it to exist after the filp to which it was
    originally attached was closed.

    Much of the use of the file pointer in this struct is to get at the
    dentry. Begin divorcing the cifsFileInfo from the struct file by
    keeping a reference to the dentry. Since the dentry will have a
    reference to the inode, we can eliminate the "pInode" field too and
    convert the igrab/iput to dget/dput.

    Signed-off-by: Jeff Layton
    Reviewed-by: Suresh Jayaraman
    Acked-by: Dave Kleikamp
    Signed-off-by: Steve French

    Jeff Layton
     

30 Sep, 2010

2 commits

  • At mount time, we'll always need to create a tcon that will serve as a
    template for others that are associated with the mount. This tcon is
    known as the "master" tcon.

    In some cases, we'll need to use that tcon regardless of who's accessing
    the mount. Add an accessor function for the master tcon and go ahead and
    switch the appropriate places to use it.

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

    Jeff Layton
     
  • When we convert cifs to do multiple sessions per mount, we'll need more
    than one tcon per superblock. At that point "cifs_sb->tcon" will make
    no sense. Add a new accessor function that gets a tcon given a cifs_sb.
    For now, it just returns cifs_sb->tcon. Later it'll do more.

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

    Jeff Layton
     

23 Jul, 2010

1 commit

  • Workqueue can now handle high concurrency. Use system_nrt_wq
    instead of slow-work.

    * Updated is_valid_oplock_break() to not call cifs_oplock_break_put()
    as advised by Steve French. It might cause deadlock. Instead,
    reference is increased after queueing succeeded and
    cifs_oplock_break() briefly grabs GlobalSMBSeslock before putting
    the cfile to make sure it doesn't put before the matching get is
    finished.

    * Anton Blanchard reported that cifs conversion was using now gone
    system_single_wq. Use system_nrt_wq which provides non-reentrance
    guarantee which is enough and much better.

    Signed-off-by: Tejun Heo
    Acked-by: Steve French
    Cc: Anton Blanchard

    Tejun Heo
     

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
     

25 Feb, 2010

1 commit


16 Nov, 2009

1 commit

  • Fix the commit ec06aedd44 that intended to turn off querying for server inode
    numbers when server doesn't consistently support inode numbers. Presumably
    the commit didn't actually clear the CIFS_MOUNT_SERVER_INUM flag, perhaps a
    typo.

    Signed-off-by: Suresh Jayaraman
    Acked-by: Jeff Layton
    Cc: Stable
    Signed-off-by: Steve French

    Suresh Jayaraman
     

07 Nov, 2009

1 commit

  • It's possible that a server will return a valid FileID when we query the
    FILE_INTERNAL_INFO for the root inode, but then zeroed out inode numbers
    when we do a FindFile with an infolevel of
    SMB_FIND_FILE_ID_FULL_DIR_INFO.

    In this situation turn off querying for server inode numbers, generate a
    warning for the user and just generate an inode number using iunique.
    Once we generate any inode number with iunique we can no longer use any
    server inode numbers or we risk collisions, so ensure that we don't do
    that in cifs_get_inode_info either.

    Cc: Stable
    Reported-by: Timothy Normand Miller
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

25 Sep, 2009

1 commit

  • This is the fourth respin of the patch to convert oplock breaks to
    use the slow_work facility.

    A customer of ours was testing a backport of one of the earlier
    patchsets, and hit a "Busy inodes after umount..." problem. An oplock
    break job had raced with a umount, and the superblock got torn down and
    its memory reused. When the oplock break job tried to dereference the
    inode->i_sb, the kernel oopsed.

    This patchset has the oplock break job hold an inode and vfsmount
    reference until the oplock break completes. With this, there should be
    no need to take a tcon reference (the vfsmount implicitly holds one
    already).

    Currently, when an oplock break comes in there's a chance that the
    oplock break job won't occur if the allocation of the oplock_q_entry
    fails. There are also some rather nasty races in the allocation and
    handling these structs.

    Rather than allocating oplock queue entries when an oplock break comes
    in, add a few extra fields to the cifsFileInfo struct. Get rid of the
    dedicated cifs_oplock_thread as well and queue the oplock break job to
    the slow_work thread pool.

    This approach also has the advantage that the oplock break jobs can
    potentially run in parallel rather than be serialized like they are
    today.

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

    Jeff Layton
     

16 Sep, 2009

2 commits


30 Apr, 2009

2 commits


29 Dec, 2008

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: (31 commits)
    [CIFS] Remove redundant test
    [CIFS] make sure that DFS pathnames are properly formed
    Remove an already-checked error condition in SendReceiveBlockingLock
    Streamline SendReceiveBlockingLock: Use "goto out:" in an error condition
    Streamline SendReceiveBlockingLock: Use "goto out:" in an error condition
    [CIFS] Streamline SendReceive[2] by using "goto out:" in an error condition
    Slightly streamline SendReceive[2]
    Check the return value of cifs_sign_smb[2]
    [CIFS] Cleanup: Move the check for too large R/W requests
    [CIFS] Slightly simplify wait_for_free_request(), remove an unnecessary "else" branch
    Simplify allocate_mid() slightly: Remove some unnecessary "else" branches
    [CIFS] In SendReceive, move consistency check out of the mutexed region
    cifs: store password in tcon
    cifs: have calc_lanman_hash take more granular args
    cifs: zero out session password before freeing it
    cifs: fix wait_for_response to time out sleeping processes correctly
    [CIFS] Can not mount with prefixpath if root directory of share is inaccessible
    [CIFS] various minor cleanups pointed out by checkpatch script
    [CIFS] fix typo
    [CIFS] remove sparse warning
    ...

    Fix trivial conflict in fs/cifs/cifs_fs_sb.h due to comment changes for
    the CIFS_MOUNT_xyz bit definitions between cifs updates and security
    updates.

    Linus Torvalds
     

26 Dec, 2008

2 commits


04 Dec, 2008

1 commit


21 Nov, 2008

1 commit

  • If a connection with open file handles has gone down
    and come back up and reconnected without reopening
    the file handle yet, do not attempt to send an SMB close
    request for this handle in cifs_close. We were
    checking for the connection being invalid in cifs_close
    but since the connection may have been reconnected
    we also need to check whether the file handle
    was marked invalid (otherwise we could close the
    wrong file handle by accident).

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

    Steve French
     

18 Nov, 2008

1 commit

  • Conflicts:
    fs/cifs/misc.c

    Merge to resolve above, per the patch below.

    Signed-off-by: James Morris

    diff --cc fs/cifs/misc.c
    index ec36410,addd1dc..0000000
    --- a/fs/cifs/misc.c
    +++ b/fs/cifs/misc.c
    @@@ -347,13 -338,13 +338,13 @@@ header_assemble(struct smb_hdr *buffer
    /* BB Add support for establishing new tCon and SMB Session */
    /* with userid/password pairs found on the smb session */
    /* for other target tcp/ip addresses BB */
    - if (current->fsuid != treeCon->ses->linux_uid) {
    + if (current_fsuid() != treeCon->ses->linux_uid) {
    cFYI(1, ("Multiuser mode and UID "
    "did not match tcon uid"));
    - read_lock(&GlobalSMBSeslock);
    - list_for_each(temp_item, &GlobalSMBSessionList) {
    - ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList);
    + read_lock(&cifs_tcp_ses_lock);
    + list_for_each(temp_item, &treeCon->ses->server->smb_ses_list) {
    + ses = list_entry(temp_item, struct cifsSesInfo, smb_ses_list);
    - if (ses->linux_uid == current->fsuid) {
    + if (ses->linux_uid == current_fsuid()) {
    if (ses->server == treeCon->ses->server) {
    cFYI(1, ("found matching uid substitute right smb_uid"));
    buffer->Uid = ses->Suid;

    James Morris
     

17 Nov, 2008

1 commit

  • Use a similar approach to the SMB session sharing. Add a list of tcons
    attached to each SMB session. Move the refcount to non-atomic. Protect
    all of the above with the cifs_tcp_ses_lock. Add functions to
    properly find and put references to the tcons.

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

    Jeff Layton
     

15 Nov, 2008

1 commit

  • We do this by abandoning the global list of SMB sessions and instead
    moving to a per-server list. This entails adding a new list head to the
    TCP_Server_Info struct. The refcounting for the cifsSesInfo is moved to
    a non-atomic variable. We have to protect it by a lock anyway, so there's
    no benefit to making it an atomic. The list and refcount are protected
    by the global cifs_tcp_ses_lock.

    The patch also adds a new routines to find and put SMB sessions and
    that properly take and put references under the lock.

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

    Jeff Layton