20 Jan, 2021

2 commits


30 Dec, 2020

1 commit

  • [ Upstream commit 05ad917561fca39a03338cb21fe9622f998b0f9c ]

    Currently, the client will always ask for security_labels if the server
    returns that it supports that feature regardless of any LSM modules
    (such as Selinux) enforcing security policy. This adds performance
    penalty to the READDIR operation.

    Client adjusts superblock's support of the security_label based on
    the server's support but also current client's configuration of the
    LSM modules. Thus, prior to using the default bitmask in READDIR,
    this patch checks the server's capabilities and then instructs
    READDIR to remove FATTR4_WORD2_SECURITY_LABEL from the bitmask.

    v5: fixing silly mistakes of the rushed v4
    v4: simplifying logic
    v3: changing label's initialization per Ondrej's comment
    v2: dropping selinux hook and using the sb cap.

    Suggested-by: Ondrej Mosnacek
    Suggested-by: Scott Mayhew
    Signed-off-by: Olga Kornievskaia
    Fixes: 2b0143b5c986 ("VFS: normal filesystems (and lustre): d_inode() annotations")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Olga Kornievskaia
     

11 Dec, 2020

1 commit

  • We've been seeing failures with xfstests generic/091 and generic/263
    when using READ_PLUS. I've made some progress on these issues, and the
    tests fail later on but still don't pass. Let's disable READ_PLUS by
    default until we can work out what is going on.

    Signed-off-by: Anna Schumaker

    Anna Schumaker
     

16 Oct, 2020

1 commit


09 Oct, 2020

2 commits


08 Oct, 2020

1 commit


02 Oct, 2020

1 commit

  • Since commit 0e0cb35b417f ("NFSv4: Handle NFS4ERR_OLD_STATEID in
    CLOSE/OPEN_DOWNGRADE") the following livelock may occur if a CLOSE races
    with the update of the nfs_state:

    Process 1 Process 2 Server
    ========= ========= ========
    OPEN file
    OPEN file
    Reply OPEN (1)
    Reply OPEN (2)
    Update state (1)
    CLOSE file (1)
    Reply OLD_STATEID (1)
    CLOSE file (2)
    Reply CLOSE (-1)
    Update state (2)
    wait for state change
    OPEN file
    wake
    CLOSE file
    OPEN file
    wake
    CLOSE file
    ...
    ...

    We can avoid this situation by not issuing an immediate retry with a bumped
    seqid when CLOSE/OPEN_DOWNGRADE receives NFS4ERR_OLD_STATEID. Instead,
    take the same approach used by OPEN and wait at least 5 seconds for
    outstanding stateid updates to complete if we can detect that we're out of
    sequence.

    Note that after this change it is still possible (though unlikely) that
    CLOSE waits a full 5 seconds, bumps the seqid, and retries -- and that
    attempt races with another OPEN at the same time. In order to avoid this
    race (which would result in the livelock), update
    nfs_need_update_open_stateid() to handle the case where:
    - the state is NFS_OPEN_STATE, and
    - the stateid doesn't match the current open stateid

    Finally, nfs_need_update_open_stateid() is modified to be idempotent and
    renamed to better suit the purpose of signaling that the stateid passed
    is the next stateid in sequence.

    Fixes: 0e0cb35b417f ("NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE")
    Cc: stable@vger.kernel.org # v5.4+
    Signed-off-by: Benjamin Coddington
    Signed-off-by: Anna Schumaker

    Benjamin Coddington
     

24 Sep, 2020

1 commit

  • Client uses static bitmask for GETATTR on CLOSE/WRITE/DELEGRETURN
    and ignores the fact that it might have some attributes marked
    invalid in its cache. Compared to v3 where all attributes are
    retrieved in postop attributes, v4's cache is frequently out of
    sync and leads to standalone GETATTRs being sent to the server.

    Instead, in addition to the minimum cache consistency attributes
    also check cache_validity and adjust the GETATTR request accordingly.

    Signed-off-by: Olga Kornievskaia
    Signed-off-by: Anna Schumaker

    Olga Kornievskaia
     

21 Sep, 2020

2 commits

  • The variable error is ssize_t, which is signed and will
    cast to unsigned when comapre with variable size, so add
    a check to avoid unexpected result in case of negative
    value of error.

    Signed-off-by: Chengguang Xu
    Signed-off-by: Anna Schumaker

    Chengguang Xu
     
  • The pointer clnt is being initialized with a value that is never
    read and so this is assignment redundant and can be removed. The
    pointer can removed because it is being used as a temporary
    variable and it is clearer to make the direct assignment and remove
    it completely.

    Addresses-Coverity: ("Unused value")
    Signed-off-by: Colin Ian King
    Signed-off-by: Anna Schumaker

    Colin Ian King
     

10 Sep, 2020

1 commit

  • Pull NFS client bugfixes from Trond Myklebust:

    - Fix an NFS/RDMA resource leak

    - Fix the error handling during delegation recall

    - NFSv4.0 needs to return the delegation on a zero-stateid SETATTR

    - Stop printk reading past end of string

    * tag 'nfs-for-5.9-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
    SUNRPC: stop printk reading past end of string
    NFS: Zero-stateid SETATTR should first return delegation
    NFSv4.1 handle ERR_DELAY error reclaiming locking state on delegation recall
    xprtrdma: Release in-flight MRs on disconnect

    Linus Torvalds
     

05 Sep, 2020

1 commit

  • 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

    Chuck Lever
     

27 Aug, 2020

1 commit

  • 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

    Olga Kornievskaia
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

15 Aug, 2020

1 commit

  • Pull NFS client updates from Trond Myklebust:
    "Stable fixes:
    - pNFS: Don't return layout segments that are being used for I/O
    - pNFS: Don't move layout segments off the active list when being used for I/O

    Features:
    - NFS: Add support for user xattrs through the NFSv4.2 protocol
    - NFS: Allow applications to speed up readdir+statx() using AT_STATX_DONT_SYNC
    - NFSv4.0 allow nconnect for v4.0

    Bugfixes and cleanups:
    - nfs: ensure correct writeback errors are returned on close()
    - nfs: nfs_file_write() should check for writeback errors
    - nfs: Fix getxattr kernel panic and memory overflow
    - NFS: Fix the pNFS/flexfiles mirrored read failover code
    - SUNRPC: dont update timeout value on connection reset
    - freezer: Add unsafe versions of freezable_schedule_timeout_interruptible for NFS
    - sunrpc: destroy rpc_inode_cachep after unregister_filesystem"

    * tag 'nfs-for-5.9-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (32 commits)
    NFS: Fix flexfiles read failover
    fs: nfs: delete repeated words in comments
    rpc_pipefs: convert comma to semicolon
    nfs: Fix getxattr kernel panic and memory overflow
    NFS: Don't return layout segments that are in use
    NFS: Don't move layouts to plh_return_segs list while in use
    NFS: Add layout segment info to pnfs read/write/commit tracepoints
    NFS: Add tracepoints for layouterror and layoutstats.
    NFS: Report the stateid + status in trace_nfs4_layoutreturn_on_close()
    SUNRPC dont update timeout value on connection reset
    nfs: nfs_file_write() should check for writeback errors
    nfs: ensure correct writeback errors are returned on close()
    NFSv4.2: xattr cache: get rid of cache discard work queue
    NFS: remove redundant initialization of variable result
    NFSv4.0 allow nconnect for v4.0
    freezer: Add unsafe versions of freezable_schedule_timeout_interruptible for NFS
    sunrpc: destroy rpc_inode_cachep after unregister_filesystem
    NFSv4.2: add client side xattr caching.
    NFSv4.2: hook in the user extended attribute handlers
    NFSv4.2: add the extended attribute proc functions.
    ...

    Linus Torvalds
     

12 Aug, 2020

1 commit

  • 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

    Jeffrey Mitchell
     

03 Aug, 2020

1 commit

  • * pm-sleep:
    PM: sleep: spread "const char *" correctness
    PM: hibernate: fix white space in a few places
    freezer: Add unsafe version of freezable_schedule_timeout_interruptible() for NFS
    PM: sleep: core: Emit changed uevent on wakeup_sysfs_add/remove

    * pm-domains:
    PM: domains: Restore comment indentation for generic_pm_domain.child_links
    PM: domains: Fix up terminology with parent/child

    * powercap:
    powercap: Add Power Limit4 support
    powercap: idle_inject: Replace play_idle() with play_idle_precise() in comments
    powercap: intel_rapl: add support for Sapphire Rapids

    * pm-tools:
    pm-graph v5.7 - important s2idle fixes
    cpupower: Replace HTTP links with HTTPS ones
    cpupower: Fix NULL but dereferenced coccicheck errors
    cpupower: Fix comparing pointer to 0 coccicheck warns

    Rafael J. Wysocki
     

18 Jul, 2020

1 commit

  • commit 0688e64bc600 ("NFS: Allow signal interruption of NFS4ERR_DELAYed operations")
    introduces nfs4_delay_interruptible which also needs an _unsafe version to
    avoid the following call trace for the same reason explained in
    commit 416ad3c9c006 ("freezer: add unsafe versions of freezable helpers for NFS")

    CPU: 4 PID: 3968 Comm: rm Tainted: G W 5.8.0-rc4 #1
    Hardware name: Marvell OcteonTX CN96XX board (DT)
    Call trace:
    dump_backtrace+0x0/0x1dc
    show_stack+0x20/0x30
    dump_stack+0xdc/0x150
    debug_check_no_locks_held+0x98/0xa0
    nfs4_delay_interruptible+0xd8/0x120
    nfs4_handle_exception+0x130/0x170
    nfs4_proc_rmdir+0x8c/0x220
    nfs_rmdir+0xa4/0x360
    vfs_rmdir.part.0+0x6c/0x1b0
    do_rmdir+0x18c/0x210
    __arm64_sys_unlinkat+0x64/0x7c
    el0_svc_common.constprop.0+0x7c/0x110
    do_el0_svc+0x24/0xa0
    el0_sync_handler+0x13c/0x1b8
    el0_sync+0x158/0x180

    Signed-off-by: He Zhe
    Signed-off-by: Trond Myklebust

    He Zhe
     

15 Jul, 2020

1 commit

  • commit 0688e64bc600 ("NFS: Allow signal interruption of
    NFS4ERR_DELAYed operations") introduces nfs4_delay_interruptible
    which also needs an _unsafe version to avoid the following call
    trace for the same reason explained in commit 416ad3c9c006 ("freezer:
    add unsafe versions of freezable helpers for NFS")

    CPU: 4 PID: 3968 Comm: rm Tainted: G W 5.8.0-rc4 #1
    Hardware name: Marvell OcteonTX CN96XX board (DT)
    Call trace:
    dump_backtrace+0x0/0x1dc
    show_stack+0x20/0x30
    dump_stack+0xdc/0x150
    debug_check_no_locks_held+0x98/0xa0
    nfs4_delay_interruptible+0xd8/0x120
    nfs4_handle_exception+0x130/0x170
    nfs4_proc_rmdir+0x8c/0x220
    nfs_rmdir+0xa4/0x360
    vfs_rmdir.part.0+0x6c/0x1b0
    do_rmdir+0x18c/0x210
    __arm64_sys_unlinkat+0x64/0x7c
    el0_svc_common.constprop.0+0x7c/0x110
    do_el0_svc+0x24/0xa0
    el0_sync_handler+0x13c/0x1b8
    el0_sync+0x158/0x180

    Signed-off-by: He Zhe
    Signed-off-by: Rafael J. Wysocki

    He Zhe
     

14 Jul, 2020

7 commits


13 Jul, 2020

1 commit

  • 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

    Anna Schumaker
     

27 May, 2020

1 commit


12 May, 2020

1 commit


29 Apr, 2020

1 commit

  • 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

    Olga Kornievskaia
     

25 Apr, 2020

1 commit


08 Apr, 2020

1 commit

  • Pull NFS client updates from Trond Myklebust:
    "Highlights include:

    Stable fixes:
    - Fix a page leak in nfs_destroy_unlinked_subrequests()

    - Fix use-after-free issues in nfs_pageio_add_request()

    - Fix new mount code constant_table array definitions

    - finish_automount() requires us to hold 2 refs to the mount record

    Features:
    - Improve the accuracy of telldir/seekdir by using 64-bit cookies
    when possible.

    - Allow one RDMA active connection and several zombie connections to
    prevent blocking if the remote server is unresponsive.

    - Limit the size of the NFS access cache by default

    - Reduce the number of references to credentials that are taken by
    NFS

    - pNFS files and flexfiles drivers now support per-layout segment
    COMMIT lists.

    - Enable partial-file layout segments in the pNFS/flexfiles driver.

    - Add support for CB_RECALL_ANY to the pNFS flexfiles layout type

    - pNFS/flexfiles Report NFS4ERR_DELAY and NFS4ERR_GRACE errors from
    the DS using the layouterror mechanism.

    Bugfixes and cleanups:
    - SUNRPC: Fix krb5p regressions

    - Don't specify NFS version in "UDP not supported" error

    - nfsroot: set tcp as the default transport protocol

    - pnfs: Return valid stateids in nfs_layout_find_inode_by_stateid()

    - alloc_nfs_open_context() must use the file cred when available

    - Fix locking when dereferencing the delegation cred

    - Fix memory leaks in O_DIRECT when nfs_get_lock_context() fails

    - Various clean ups of the NFS O_DIRECT commit code

    - Clean up RDMA connect/disconnect

    - Replace zero-length arrays with C99-style flexible arrays"

    * tag 'nfs-for-5.7-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (86 commits)
    NFS: Clean up process of marking inode stale.
    SUNRPC: Don't start a timer on an already queued rpc task
    NFS/pnfs: Reference the layout cred in pnfs_prepare_layoutreturn()
    NFS/pnfs: Fix dereference of layout cred in pnfs_layoutcommit_inode()
    NFS: Beware when dereferencing the delegation cred
    NFS: Add a module parameter to set nfs_mountpoint_expiry_timeout
    NFS: finish_automount() requires us to hold 2 refs to the mount record
    NFS: Fix a few constant_table array definitions
    NFS: Try to join page groups before an O_DIRECT retransmission
    NFS: Refactor nfs_lock_and_join_requests()
    NFS: Reverse the submission order of requests in __nfs_pageio_add_request()
    NFS: Clean up nfs_lock_and_join_requests()
    NFS: Remove the redundant function nfs_pgio_has_mirroring()
    NFS: Fix memory leaks in nfs_pageio_stop_mirroring()
    NFS: Fix a request reference leak in nfs_direct_write_clear_reqs()
    NFS: Fix use-after-free issues in nfs_pageio_add_request()
    NFS: Fix races nfs_page_group_destroy() vs nfs_destroy_unlinked_subrequests()
    NFS: Fix a page leak in nfs_destroy_unlinked_subrequests()
    NFS: Remove unused FLUSH_SYNC support in nfs_initiate_pgio()
    pNFS/flexfiles: Specify the layout segment range in LAYOUTGET
    ...

    Linus Torvalds
     

04 Apr, 2020

2 commits


01 Apr, 2020

1 commit

  • Pull SELinux updates from Paul Moore:
    "We've got twenty SELinux patches for the v5.7 merge window, the
    highlights are below:

    - Deprecate setting /sys/fs/selinux/checkreqprot to 1.

    This flag was originally created to deal with legacy userspace and
    the READ_IMPLIES_EXEC personality flag. We changed the default from
    1 to 0 back in Linux v4.4 and now we are taking the next step of
    deprecating it, at some point in the future we will take the final
    step of rejecting 1.

    - Allow kernfs symlinks to inherit the SELinux label of the parent
    directory. In order to preserve backwards compatibility this is
    protected by the genfs_seclabel_symlinks SELinux policy capability.

    - Optimize how we store filename transitions in the kernel, resulting
    in some significant improvements to policy load times.

    - Do a better job calculating our internal hash table sizes which
    resulted in additional policy load improvements and likely general
    SELinux performance improvements as well.

    - Remove the unused initial SIDs (labels) and improve how we handle
    initial SIDs.

    - Enable per-file labeling for the bpf filesystem.

    - Ensure that we properly label NFS v4.2 filesystems to avoid a
    temporary unlabeled condition.

    - Add some missing XFS quota command types to the SELinux quota
    access controls.

    - Fix a problem where we were not updating the seq_file position
    index correctly in selinuxfs.

    - We consolidate some duplicated code into helper functions.

    - A number of list to array conversions.

    - Update Stephen Smalley's email address in MAINTAINERS"

    * tag 'selinux-pr-20200330' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: clean up indentation issue with assignment statement
    NFS: Ensure security label is set for root inode
    MAINTAINERS: Update my email address
    selinux: avtab_init() and cond_policydb_init() return void
    selinux: clean up error path in policydb_init()
    selinux: remove unused initial SIDs and improve handling
    selinux: reduce the use of hard-coded hash sizes
    selinux: Add xfs quota command types
    selinux: optimize storage of filename transitions
    selinux: factor out loop body from filename_trans_read()
    security: selinux: allow per-file labeling for bpffs
    selinux: generalize evaluate_cond_node()
    selinux: convert cond_expr to array
    selinux: convert cond_av_list to array
    selinux: convert cond_list to array
    selinux: sel_avc_get_stat_idx should increase position index
    selinux: allow kernfs symlinks to inherit parent directory context
    selinux: simplify evaluate_cond_node()
    Documentation,selinux: deprecate setting checkreqprot to 1
    selinux: move status variables out of selinux_ss

    Linus Torvalds
     

31 Mar, 2020

1 commit

  • When using NFSv4.2, the security label for the root inode should be set
    via a call to nfs_setsecurity() during the mount process, otherwise the
    inode will appear as unlabeled for up to acdirmin seconds. Currently
    the label for the root inode is allocated, retrieved, and freed entirely
    witin nfs4_proc_get_root().

    Add a field for the label to the nfs_fattr struct, and allocate & free
    the label in nfs_get_root(), where we also add a call to
    nfs_setsecurity(). Note that for the call to nfs_setsecurity() to
    succeed, it's necessary to also move the logic calling
    security_sb_{set,clone}_security() from nfs_get_tree_common() down into
    nfs_get_root()... otherwise the SBLABEL_MNT flag will not be set in the
    super_block's security flags and nfs_setsecurity() will silently fail.

    Reported-by: Richard Haines
    Signed-off-by: Scott Mayhew
    Acked-by: Stephen Smalley
    Tested-by: Stephen Smalley
    [PM: fixed 80-char line width problems]
    Signed-off-by: Paul Moore

    Scott Mayhew
     

16 Mar, 2020

2 commits

  • The current codebase makes use of the zero-length array language
    extension to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning
    in case the flexible array does not occur last in the structure, which
    will help us prevent some kind of undefined behavior bugs from being
    inadvertently introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by
    this change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    This issue was found with the help of Coccinelle.

    [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    [2] https://github.com/KSPP/linux/issues/21
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Trond Myklebust

    Gustavo A. R. Silva
     
  • Layoutget is just using the credential attached to the open context.

    Signed-off-by: Trond Myklebust

    Trond Myklebust