07 Oct, 2020

1 commit

  • [ Upstream commit d33030e2ee3508d65db5644551435310df86010e ]

    nfs_readdir_page_filler() iterates over entries in a directory, reusing
    the same security label buffer, but does not reset the buffer's length.
    This causes decode_attr_security_label() to return -ERANGE if an entry's
    security label is longer than the previous one's. This error, in
    nfs4_decode_dirent(), only gets passed up as -EAGAIN, which causes another
    failed attempt to copy into the buffer. The second error is ignored and
    the remaining entries do not show up in ls, specifically the getdents64()
    syscall.

    Reproduce by creating multiple files in NFS and giving one of the later
    files a longer security label. ls will not see that file nor any that are
    added afterwards, though they will exist on the backend.

    In nfs_readdir_page_filler(), reset security label buffer length before
    every reuse

    Signed-off-by: Jeffrey Mitchell
    Fixes: b4487b935452 ("nfs: Fix getxattr kernel panic and memory overflow")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Jeffrey Mitchell
     

01 Oct, 2020

2 commits


23 Sep, 2020

2 commits

  • [ Upstream commit 644c9f40cf71969f29add32f32349e71d4995c0b ]

    If a write delegation isn't available, the Linux NFS client uses
    a zero-stateid when performing a SETATTR.

    NFSv4.0 provides no mechanism for an NFS server to match such a
    request to a particular client. It recalls all delegations for that
    file, even delegations held by the client issuing the request. If
    that client happens to hold a read delegation, the server will
    recall it immediately, resulting in an NFS4ERR_DELAY/CB_RECALL/
    DELEGRETURN sequence.

    Optimize out this pipeline bubble by having the client return any
    delegations it may hold on a file before it issues a
    SETATTR(zero-stateid) on that file.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Chuck Lever
     
  • [ Upstream commit 3d7a9520f0c3e6a68b6de8c5812fc8b6d7a52626 ]

    A client should be able to handle getting an ERR_DELAY error
    while doing a LOCK call to reclaim state due to delegation being
    recalled. This is a transient error that can happen due to server
    moving its volumes and invalidating its file location cache and
    upon reference to it during the LOCK call needing to do an
    expensive lookup (leading to an ERR_DELAY error on a PUTFH).

    Signed-off-by: Olga Kornievskaia
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Olga Kornievskaia
     

21 Aug, 2020

3 commits

  • [ Upstream commit b4487b93545214a9db8cbf32e86411677b0cca21 ]

    Move the buffer size check to decode_attr_security_label() before memcpy()
    Only call memcpy() if the buffer is large enough

    Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS")
    Signed-off-by: Jeffrey Mitchell
    [Trond: clean up duplicate test of label->len != 0]
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Jeffrey Mitchell
     
  • [ Upstream commit ce368536dd614452407dc31e2449eb84681a06af ]

    The NFS_CONTEXT_ERROR_WRITE flag (as well as the check of said flag) was
    removed by commit 6fbda89b257f. The absence of an error check allows
    writes to be continually queued up for a server that may no longer be
    able to handle them. Fix it by adding an error check using the generic
    error reporting functions.

    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Scott Mayhew
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Scott Mayhew
     
  • [ Upstream commit 67dd23f9e6fbaf163431912ef5599c5e0693476c ]

    nfs_wb_all() calls filemap_write_and_wait(), which uses
    filemap_check_errors() to determine the error to return.
    filemap_check_errors() only looks at the mapping->flags and will
    therefore only return either -ENOSPC or -EIO. To ensure that the
    correct error is returned on close(), nfs{,4}_file_flush() should call
    filemap_check_wb_err() which looks at the errseq value in
    mapping->wb_err without consuming it.

    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with
    generic one")
    Signed-off-by: Scott Mayhew
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Scott Mayhew
     

19 Aug, 2020

2 commits

  • commit d474f96104bd4377573526ebae2ee212205a6839 upstream.

    If the NFS_LAYOUT_RETURN_REQUESTED flag is set, we want to return the
    layout as soon as possible, meaning that the affected layout segments
    should be marked as invalid, and should no longer be in use for I/O.

    Fixes: f0b429819b5f ("pNFS: Ignore non-recalled layouts in pnfs_layout_need_return()")
    Cc: stable@vger.kernel.org # v4.19+
    Signed-off-by: Trond Myklebust
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     
  • commit ff041727e9e029845857cac41aae118ead5e261b upstream.

    If the layout segment is still in use for a read or a write, we should
    not move it to the layout plh_return_segs list. If we do, we can end
    up returning the layout while I/O is still in progress.

    Fixes: e0b7d420f72a ("pNFS: Don't discard layout segments that are marked for return")
    Cc: stable@vger.kernel.org # v4.19+
    Signed-off-by: Trond Myklebust
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     

29 Jul, 2020

1 commit

  • commit 65caafd0d2145d1dd02072c4ced540624daeab40 upstream.

    Reverting commit d03727b248d0 "NFSv4 fix CLOSE not waiting for
    direct IO compeletion". This patch made it so that fput() by calling
    inode_dio_done() in nfs_file_release() would wait uninterruptably
    for any outstanding directIO to the file (but that wait on IO should
    be killable).

    The problem the patch was also trying to address was REMOVE returning
    ERR_ACCESS because the file is still opened, is supposed to be resolved
    by server returning ERR_FILE_OPEN and not ERR_ACCESS.

    Signed-off-by: Olga Kornievskaia
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Olga Kornievskaia
     

22 Jul, 2020

1 commit

  • [ Upstream commit 913fadc5b105c3619d9e8d0fe8899ff1593cc737 ]

    We used to do this before 3453d5708b33, but this was changed to better
    handle the NFS4ERR_SEQ_MISORDERED error code. This commit fixed the slot
    re-use case when the server doesn't receive the interrupted operation,
    but if the server does receive the operation then it could still end up
    replying to the client with mis-matched operations from the reply cache.

    We can fix this by sending a SEQUENCE to the server while recovering from
    a SEQ_MISORDERED error when we detect that we are in an interrupted slot
    situation.

    Fixes: 3453d5708b33 (NFSv4.1: Avoid false retries when RPC calls are interrupted)
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Anna Schumaker
     

01 Jul, 2020

2 commits

  • commit d03727b248d0dae6199569a8d7b629a681154633 upstream.

    Figuring out the root case for the REMOVE/CLOSE race and
    suggesting the solution was done by Neil Brown.

    Currently what happens is that direct IO calls hold a reference
    on the open context which is decremented as an asynchronous task
    in the nfs_direct_complete(). Before reference is decremented,
    control is returned to the application which is free to close the
    file. When close is being processed, it decrements its reference
    on the open_context but since directIO still holds one, it doesn't
    sent a close on the wire. It returns control to the application
    which is free to do other operations. For instance, it can delete a
    file. Direct IO is finally releasing its reference and triggering
    an asynchronous close. Which races with the REMOVE. On the server,
    REMOVE can be processed before the CLOSE, failing the REMOVE with
    EACCES as the file is still opened.

    Signed-off-by: Olga Kornievskaia
    Suggested-by: Neil Brown
    CC: stable@vger.kernel.org
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Olga Kornievskaia
     
  • commit 8b04013737341442ed914b336cde866b902664ae upstream.

    If the mirror count changes in the new layout we pick up inside
    ff_layout_pg_init_write(), then we can end up adding the
    request to the wrong mirror and corrupting the mirror->pg_list.

    Fixes: d600ad1f2bdb ("NFS41: pop some layoutget errors to application")
    Cc: stable@vger.kernel.org
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     

24 Jun, 2020

2 commits

  • [ Upstream commit 3a39e778690500066b31fe982d18e2e394d3bce2 ]

    Use the following command to test nfsv4(size of file1M is 1MB):
    mount -t nfs -o vers=4.0,actimeo=60 127.0.0.1/dir1 /mnt
    cp file1M /mnt
    du -h /mnt/file1M -->0 within 60s, then 1M

    When write is done(cp file1M /mnt), will call this:
    nfs_writeback_done
    nfs4_write_done
    nfs4_write_done_cb
    nfs_writeback_update_inode
    nfs_post_op_update_inode_force_wcc_locked(change, ctime, mtime
    nfs_post_op_update_inode_force_wcc_locked
    nfs_set_cache_invalid
    nfs_refresh_inode_locked
    nfs_update_inode

    nfsd write response contains change, ctime, mtime, the flag will be
    clear after nfs_update_inode. Howerver, write response does not contain
    space_used, previous open response contains space_used whose value is 0,
    so inode->i_blocks is still 0.

    nfs_getattr -->called by "du -h"
    do_update |= force_sync || nfs_attribute_cache_expired -->false in 60s
    cache_validity = READ_ONCE(NFS_I(inode)->cache_validity)
    do_update |= cache_validity & (NFS_INO_INVALID_ATTR -->false
    if (do_update) {
    __nfs_revalidate_inode
    }

    Within 60s, does not send getattr request to nfsd, thus "du -h /mnt/file1M"
    is 0.

    Add a NFS_INO_INVALID_BLOCKS flag, set it when nfsv4 write is done.

    Fixes: 16e143751727 ("NFS: More fine grained attribute tracking")
    Signed-off-by: Zheng Bin
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Zheng Bin
     
  • [ Upstream commit 1c709b766e73e54d64b1dde1b7cfbcf25bcb15b9 ]

    Fixes: 02a95dee8cf0 ("NFS add callback_ops to nfs4_proc_bind_conn_to_session_callback")
    Signed-off-by: Olga Kornievskaia
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Olga Kornievskaia
     

20 May, 2020

5 commits

  • [ Upstream commit 8eed292bc8cbf737e46fb1c119d4c8f6dcb00650 ]

    Prior to commit e3d3ab64dd66 ("SUNRPC: Use au_rslack when
    computing reply buffer size"), there was enough slack in the reply
    buffer to commodate filehandles of size 60bytes. However, the real
    problem was that the reply buffer size for the MOUNT operation was
    not correctly calculated. Received buffer size used the filehandle
    size for NFSv2 (32bytes) which is much smaller than the allowed
    filehandle size for the v3 mounts.

    Fix the reply buffer size (decode arguments size) for the MNT command.

    Fixes: 2c94b8eca1a2 ("SUNRPC: Use au_rslack when computing reply buffer size")
    Signed-off-by: Olga Kornievskaia
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Olga Kornievskaia
     
  • [ Upstream commit 29fe839976266bc7c55b927360a1daae57477723 ]

    We add the new state to the nfsi->open_states list, making it
    potentially visible to other threads, before we've finished initializing
    it.

    That wasn't a problem when all the readers were also taking the i_lock
    (as we do here), but since we switched to RCU, there's now a possibility
    that a reader could see the partially initialized state.

    Symptoms observed were a crash when another thread called
    nfs4_get_valid_delegation() on a NULL inode, resulting in an oops like:

    BUG: unable to handle page fault for address: ffffffffffffffb0 ...
    RIP: 0010:nfs4_get_valid_delegation+0x6/0x30 [nfsv4] ...
    Call Trace:
    nfs4_open_prepare+0x80/0x1c0 [nfsv4]
    __rpc_execute+0x75/0x390 [sunrpc]
    ? finish_task_switch+0x75/0x260
    rpc_async_schedule+0x29/0x40 [sunrpc]
    process_one_work+0x1ad/0x370
    worker_thread+0x30/0x390
    ? create_worker+0x1a0/0x1a0
    kthread+0x10c/0x130
    ? kthread_park+0x80/0x80
    ret_from_fork+0x22/0x30

    Fixes: 9ae075fdd190 "NFSv4: Convert open state lookup to use RCU"
    Reviewed-by: Seiichi Ikarashi
    Tested-by: Daisuke Matsuda
    Tested-by: Masayoshi Mizuma
    Signed-off-by: J. Bruce Fields
    Cc: stable@vger.kernel.org # v4.20+
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    J. Bruce Fields
     
  • [ Upstream commit 50eaa652b54df1e2b48dc398d9e6114c9ed080eb ]

    Commit 402cb8dda949 ("fscache: Attach the index key and aux data to
    the cookie") added the aux_data and aux_data_len to parameters to
    fscache_acquire_cookie(), and updated the callers in the NFS client.
    In the process it modified the aux_data to include the change_attr,
    but missed adding change_attr to a couple places where aux_data was
    used. Specifically, when opening a file and the change_attr is not
    added, the following attempt to lookup an object will fail inside
    cachefiles_check_object_xattr() = -116 due to
    nfs_fscache_inode_check_aux() failing memcmp on auxdata and returning
    FSCACHE_CHECKAUX_OBSOLETE.

    Fix this by adding nfs_fscache_update_auxdata() to set the auxdata
    from all relevant fields in the inode, including the change_attr.

    Fixes: 402cb8dda949 ("fscache: Attach the index key and aux data to the cookie")
    Signed-off-by: Dave Wysochanski
    Signed-off-by: David Howells
    Signed-off-by: Sasha Levin

    Dave Wysochanski
     
  • [ Upstream commit 6e31ded6895adfca97211118cc9b72236e8f6d53 ]

    nfs currently behaves differently on 32-bit and 64-bit kernels regarding
    the on-disk format of nfs_fscache_inode_auxdata.

    That format should really be the same on any kernel, and we should avoid
    the 'timespec' type in order to remove that from the kernel later on.

    Using plain 'timespec64' would not be good here, since that includes
    implied padding and would possibly leak kernel stack data to the on-disk
    format on 32-bit architectures.

    struct __kernel_timespec would work as a replacement, but open-coding
    the two struct members in nfs_fscache_inode_auxdata makes it more
    obvious what's going on here, and keeps the current format for 64-bit
    architectures.

    Cc: David Howells
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Sasha Levin

    Arnd Bergmann
     
  • [ Upstream commit d9bfced1fbcb35b28d8fbed4e785d2807055ed2b ]

    Commit 402cb8dda949 ("fscache: Attach the index key and aux data to
    the cookie") added the index_key and index_key_len parameters to
    fscache_acquire_cookie(), and updated the callers in the NFS client.
    One of the callers was inside nfs_fscache_get_super_cookie()
    and was changed to use the full struct nfs_fscache_key as the
    index_key. However, a couple members of this structure contain
    pointers and thus will change each time the same NFS share is
    remounted. Since index_key is used for fscache_cookie->key_hash
    and this subsequently is used to compare cookies, the effectiveness
    of fscache with NFS is reduced to the point at which a umount
    occurs. Any subsequent remount of the same share will cause a
    unique NFS super_block index_key and key_hash to be generated for
    the same data, rendering any prior fscache data unable to be
    found. A simple reproducer demonstrates the problem.

    1. Mount share with 'fsc', create a file, drop page cache
    systemctl start cachefilesd
    mount -o vers=3,fsc 127.0.0.1:/export /mnt
    dd if=/dev/zero of=/mnt/file1.bin bs=4096 count=1
    echo 3 > /proc/sys/vm/drop_caches

    2. Read file into page cache and fscache, then unmount
    dd if=/mnt/file1.bin of=/dev/null bs=4096 count=1
    umount /mnt

    3. Remount and re-read which should come from fscache
    mount -o vers=3,fsc 127.0.0.1:/export /mnt
    echo 3 > /proc/sys/vm/drop_caches
    dd if=/mnt/file1.bin of=/dev/null bs=4096 count=1

    4. Check for READ ops in mountstats - there should be none
    grep READ: /proc/self/mountstats

    Looking at the history and the removed function, nfs_super_get_key(),
    we should only use nfs_fscache_key.key plus any uniquifier, for
    the fscache index_key.

    Fixes: 402cb8dda949 ("fscache: Attach the index key and aux data to the cookie")
    Signed-off-by: Dave Wysochanski
    Signed-off-by: David Howells
    Signed-off-by: Sasha Levin

    Dave Wysochanski
     

06 May, 2020

2 commits

  • commit 7648f939cb919b9d15c21fff8cd9eba908d595dc upstream.

    nfs3_set_acl keeps track of the acl it allocated locally to determine if an acl
    needs to be released at the end. This results in a memory leak when the
    function allocates an acl as well as a default acl. Fix by releasing acls
    that differ from the acl originally passed into nfs3_set_acl.

    Fixes: b7fa0554cf1b ("[PATCH] NFS: Add support for NFSv3 ACLs")
    Reported-by: Xiyu Yang
    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Trond Myklebust
    Signed-off-by: Greg Kroah-Hartman

    Andreas Gruenbacher
     
  • commit dff58530c4ca8ce7ee5a74db431c6e35362cf682 upstream.

    Currently, if the client sends BIND_CONN_TO_SESSION with
    NFS4_CDFC4_FORE_OR_BOTH but only gets NFS4_CDFS4_FORE back it ignores
    that it wasn't able to enable a backchannel.

    To make sure, the client sends BIND_CONN_TO_SESSION as the first
    operation on the connections (ie., no other session compounds haven't
    been sent before), and if the client's request to bind the backchannel
    is not satisfied, then reset the connection and retry.

    Cc: stable@vger.kernel.org
    Signed-off-by: Olga Kornievskaia
    Signed-off-by: Trond Myklebust
    Signed-off-by: Greg Kroah-Hartman

    Olga Kornievskaia
     

23 Apr, 2020

5 commits

  • [ Upstream commit 862f35c94730c9270833f3ad05bd758a29f204ed ]

    If we just set the mirror count to 1 without first clearing out
    the mirrors, we can leak queued up requests.

    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit 8605cf0e852af3b2c771c18417499dc4ceed03d5 ]

    When dreq is allocated by nfs_direct_req_alloc(), dreq->kref is
    initialized to 2. Therefore we need to call nfs_direct_req_release()
    twice to release the allocated dreq. Usually it is called in
    nfs_file_direct_{read, write}() and nfs_direct_complete().

    However, current code only calls nfs_direct_req_relese() once if
    nfs_get_lock_context() fails in nfs_file_direct_{read, write}().
    So, that case would result in memory leak.

    Fix this by adding the missing call.

    Signed-off-by: Misono Tomohiro
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Misono Tomohiro
     
  • [ Upstream commit f5fdf1243fb750598b46305dd03c553949cfa14f ]

    This fixes xfstests generic/356 failure on NFSv4.2.

    Signed-off-by: Murphy Zhou
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Murphy Zhou
     
  • [ Upstream commit d911c57a19551c6bef116a3b55c6b089901aacb0 ]

    Make sure to test the stateid for validity so that we catch instances
    where the server may have been reusing stateids in
    nfs_layout_find_inode_by_stateid().

    Fixes: 7b410d9ce460 ("pNFS: Delay getting the layout header in CB_LAYOUTRECALL handlers")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit 1d179d6bd67369a52edea8562154b31ee20be1cc ]

    If we're creating a nfs_open_context() for a specific file pointer,
    we must use the cred assigned to that file.

    Fixes: a52458b48af1 ("NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'.")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Trond Myklebust
     

17 Apr, 2020

2 commits

  • commit add42de31721fa29ed77a7ce388674d69f9d31a4 upstream.

    When we detach a subrequest from the list, we must also release the
    reference it holds to the parent.

    Fixes: 5b2b5187fa85 ("NFS: Fix nfs_page_group_destroy() and nfs_lock_and_join_requests() race cases")
    Cc: stable@vger.kernel.org # v4.14+
    Signed-off-by: Trond Myklebust
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     
  • commit dc9dc2febb17f72e9878eb540ad3996f7984239a upstream.

    We need to ensure that we create the mirror requests before calling
    nfs_pageio_add_request_mirror() on the request we are adding.
    Otherwise, we can end up with a use-after-free if the call to
    nfs_pageio_add_request_mirror() triggers I/O.

    Fixes: c917cfaf9bbe ("NFS: Fix up NFS I/O subrequest creation")
    Cc: stable@vger.kernel.org
    Signed-off-by: Trond Myklebust
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     

01 Apr, 2020

1 commit

  • [ Upstream commit 55dee1bc0d72877b99805e42e0205087e98b9edd ]

    An NFS client that mounts multiple exports from the same NFS
    server with higher NFSv4 versions disabled (i.e. 4.2) and without
    forcing a specific NFS version results in fscache index cookie
    collisions and the following messages:
    [ 570.004348] FS-Cache: Duplicate cookie detected

    Each nfs_client structure should have its own fscache index cookie,
    so add the minorversion to nfs_server_key.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=200145
    Signed-off-by: Scott Mayhew
    Signed-off-by: Dave Wysochanski
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Scott Mayhew
     

05 Mar, 2020

1 commit

  • [ Upstream commit cf5b4059ba7197d6cef9c0e024979d178ed8c8ec ]

    We want to make sure that we revalidate the dentry if and only if
    we've done an OPEN by filename.
    In order to avoid races with remote changes to the directory on the
    server, we want to save the verifier before calling OPEN. The exception
    is if the server returned a delegation with our OPEN, as we then
    know that the filename can't have changed on the server.

    Signed-off-by: Trond Myklebust
    Reviewed-by: Benjamin Coddington
    Tested-by: Benjamin Coddington
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     

24 Feb, 2020

1 commit

  • [ Upstream commit 123c23c6a7b7ecd2a3d6060bea1d94019f71fd66 ]

    In _nfs42_proc_copy(), 'res->commit_res.verf' is allocated through
    kzalloc() if 'args->sync' is true. In the following code, if
    'res->synchronous' is false, handle_async_copy() will be invoked. If an
    error occurs during the invocation, the following code will not be executed
    and the error will be returned . However, the allocated
    'res->commit_res.verf' is not deallocated, leading to a memory leak. This
    is also true if the invocation of process_copy_commit() returns an error.

    To fix the above leaks, redirect the execution to the 'out' label if an
    error is encountered.

    Signed-off-by: Wenwen Wang
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Wenwen Wang
     

20 Feb, 2020

1 commit

  • commit cd1b659d8ce7697ee9799b64f887528315b9097b upstream.

    Turning caching off for writes on the server should improve performance.

    Fixes: fba83f34119a ("NFS: Pass "privileged" value to nfs4_init_sequence()")
    Signed-off-by: Olga Kornievskaia
    Reviewed-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Olga Kornievskaia
     

15 Feb, 2020

6 commits

  • commit 7dc2993a9e51dd2eee955944efec65bef90265b7 upstream.

    Currently, each time nfs4_do_fsinfo() is called it will do an implicit
    NFS4 lease renewal, which is not compliant with the NFS4 specification.
    This can result in a lease being expired by an NFS server.

    Commit 83ca7f5ab31f ("NFS: Avoid PUTROOTFH when managing leases")
    introduced implicit client lease renewal in nfs4_do_fsinfo(),
    which can result in the NFSv4.0 lease to expire on a server side,
    and servers returning NFS4ERR_EXPIRED or NFS4ERR_STALE_CLIENTID.

    This can easily be reproduced by frequently unmounting a sub-mount,
    then stat'ing it to get it mounted again, which will delay or even
    completely prevent client from sending RENEW operations if no other
    NFS operations are issued. Eventually nfs server will expire client's
    lease and return an error on file access or next RENEW.

    This can also happen when a sub-mount is automatically unmounted
    due to inactivity (after nfs_mountpoint_expiry_timeout), then it is
    mounted again via stat(). This can result in a short window during
    which client's lease will expire on a server but not on a client.
    This specific case was observed on production systems.

    This patch removes the implicit lease renewal from nfs4_do_fsinfo().

    Fixes: 83ca7f5ab31f ("NFS: Avoid PUTROOTFH when managing leases")
    Signed-off-by: Robert Milkowski
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Robert Milkowski
     
  • commit 924491f2e476f7234d722b24171a4daff61bbe13 upstream.

    Currently, if an nfs server returns NFS4ERR_EXPIRED to open(),
    we return EIO to applications without even trying to recover.

    Fixes: 272289a3df72 ("NFSv4: nfs4_do_handle_exception() handle revoke/expiry of a single stateid")
    Signed-off-by: Robert Milkowski
    Reviewed-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Robert Milkowski
     
  • commit 387122478775be5d9816c34aa29de53d0b926835 upstream.

    When comparing two 'struct cred' for equality w.r.t. behaviour under
    filesystem access, we need to use cred_fscmp().

    Fixes: a52458b48af1 ("NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'.")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     
  • commit 118b6292195cfb86a9f43cb65610fc6d980c65f4 upstream.

    Casting a negative value to an unsigned long is not the same as
    converting it to its absolute value.

    Fixes: 96650e2effa2 ("NFS: Fix show_nfs_errors macros again")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     
  • commit 221203ce6406273cf00e5c6397257d986c003ee6 upstream.

    Instead of making assumptions about the commit verifier contents, change
    the commit code to ensure we always check that the verifier was set
    by the XDR code.

    Fixes: f54bcf2ecee9 ("pnfs: Prepare for flexfiles by pulling out common code")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust
     
  • commit 0df68ced55443243951d02cc497be31fadf28173 upstream.

    If we suffer a fatal error upon writing a file, which causes us to
    need to revalidate the entire mapping, then we should also revalidate
    the file size.

    Fixes: d2ceb7e57086 ("NFS: Don't use page_file_mapping after removing the page")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Greg Kroah-Hartman

    Trond Myklebust