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
     

29 May, 2020

1 commit

  • nfsd4_process_cb_update() invokes svc_xprt_get(), which increases the
    refcount of the "c->cn_xprt".

    The reference counting issue happens in one exception handling path of
    nfsd4_process_cb_update(). When setup callback client failed, the
    function forgets to decrease the refcnt increased by svc_xprt_get(),
    causing a refcnt leak.

    Fix this issue by calling svc_xprt_put() when setup callback client
    failed.

    Signed-off-by: Xiyu Yang
    Signed-off-by: Xin Tan
    Signed-off-by: J. Bruce Fields

    Xiyu Yang
     

21 May, 2020

1 commit


18 Apr, 2020

1 commit

  • Currently, after the forward channel connection goes away,
    backchannel operations are causing soft lockups on the server
    because call_transmit_status's SOFTCONN logic ignores ENOTCONN.
    Such backchannel Calls are aggressively retried until the client
    reconnects.

    Backchannel Calls should use RPC_TASK_NOCONNECT rather than
    RPC_TASK_SOFTCONN. If there is no forward connection, the server is
    not capable of establishing a connection back to the client, thus
    that backchannel request should fail before the server attempts to
    send it. Commit 58255a4e3ce5 ("NFSD: NFSv4 callback client should
    use RPC_TASK_SOFTCONN") was merged several years before
    RPC_TASK_NOCONNECT was available.

    Because setup_callback_client() explicitly sets NOPING, the NFSv4.0
    callback connection depends on the first callback RPC to initiate
    a connection to the client. Thus NFSv4.0 needs to continue to use
    RPC_TASK_SOFTCONN.

    Suggested-by: Trond Myklebust
    Signed-off-by: Chuck Lever
    Cc: # v4.20+

    Chuck Lever
     

20 Dec, 2019

1 commit

  • A couple of time_t variables are only used to track the state of the
    lease time and its expiration. The code correctly uses the 'time_after()'
    macro to make this work on 32-bit architectures even beyond year 2038,
    but the get_seconds() function and the time_t type itself are deprecated
    as they behave inconsistently between 32-bit and 64-bit architectures
    and often lead to code that is not y2038 safe.

    As a minor issue, using get_seconds() leads to problems with concurrent
    settimeofday() or clock_settime() calls, in the worst case timeout never
    triggering after the time has been set backwards.

    Change nfsd to use time64_t and ktime_get_boottime_seconds() here. This
    is clearly excessive, as boottime by itself means we never go beyond 32
    bits, but it does mean we handle this correctly and consistently without
    having to worry about corner cases and should be no more expensive than
    the previous implementation on 64-bit architectures.

    The max_cb_time() function gets changed in order to avoid an expensive
    64-bit division operation, but as the lease time is at most one hour,
    there is no change in behavior.

    Also do the same for server-to-server copy expiration time.

    Signed-off-by: Arnd Bergmann
    [bfields@redhat.com: fix up copy expiration]
    Signed-off-by: J. Bruce Fields

    Arnd Bergmann
     

09 Nov, 2019

4 commits


17 Aug, 2019

1 commit


16 May, 2019

1 commit

  • Pull nfsd updates from Bruce Fields:
    "This consists mostly of nfsd container work:

    Scott Mayhew revived an old api that communicates with a userspace
    daemon to manage some on-disk state that's used to track clients
    across server reboots. We've been using a usermode_helper upcall for
    that, but it's tough to run those with the right namespaces, so a
    daemon is much friendlier to container use cases.

    Trond fixed nfsd's handling of user credentials in user namespaces. He
    also contributed patches that allow containers to support different
    sets of NFS protocol versions.

    The only remaining container bug I'm aware of is that the NFS reply
    cache is shared between all containers. If anyone's aware of other
    gaps in our container support, let me know.

    The rest of this is miscellaneous bugfixes"

    * tag 'nfsd-5.2' of git://linux-nfs.org/~bfields/linux: (23 commits)
    nfsd: update callback done processing
    locks: move checks from locks_free_lock() to locks_release_private()
    nfsd: fh_drop_write in nfsd_unlink
    nfsd: allow fh_want_write to be called twice
    nfsd: knfsd must use the container user namespace
    SUNRPC: rsi_parse() should use the current user namespace
    SUNRPC: Fix the server AUTH_UNIX userspace mappings
    lockd: Pass the user cred from knfsd when starting the lockd server
    SUNRPC: Temporary sockets should inherit the cred from their parent
    SUNRPC: Cache the process user cred in the RPC server listener
    nfsd: Allow containers to set supported nfs versions
    nfsd: Add custom rpcbind callbacks for knfsd
    SUNRPC: Allow further customisation of RPC program registration
    SUNRPC: Clean up generic dispatcher code
    SUNRPC: Add a callback to initialise server requests
    SUNRPC/nfs: Fix return value for nfs4_callback_compound()
    nfsd: handle legacy client tracking records sent by nfsdcld
    nfsd: re-order client tracking method selection
    nfsd: keep a tally of RECLAIM_COMPLETE operations when using nfsdcld
    nfsd: un-deprecate nfsdcld
    ...

    Linus Torvalds
     

10 May, 2019

1 commit

  • Pull NFS client updates from Anna Schumaker:
    "Highlights include:

    Stable bugfixes:
    - Fall back to MDS if no deviceid is found rather than aborting # v4.11+
    - NFS4: Fix v4.0 client state corruption when mount

    Features:
    - Much improved handling of soft mounts with NFS v4.0:
    - Reduce risk of false positive timeouts
    - Faster failover of reads and writes after a timeout
    - Added a "softerr" mount option to return ETIMEDOUT instead of
    EIO to the application after a timeout
    - Increase number of xprtrdma backchannel requests
    - Add additional xprtrdma tracepoints
    - Improved send completion batching for xprtrdma

    Other bugfixes and cleanups:
    - Return -EINVAL when NFS v4.2 is passed an invalid dedup mode
    - Reduce usage of GFP_ATOMIC pages in SUNRPC
    - Various minor NFS over RDMA cleanups and bugfixes
    - Use the correct container namespace for upcalls
    - Don't share superblocks between user namespaces
    - Various other container fixes
    - Make nfs_match_client() killable to prevent soft lockups
    - Don't mark all open state for recovery when handling recallable
    state revoked flag"

    * tag 'nfs-for-5.2-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (69 commits)
    SUNRPC: Rebalance a kref in auth_gss.c
    NFS: Fix a double unlock from nfs_match,get_client
    nfs: pass the correct prototype to read_cache_page
    NFSv4: don't mark all open state for recovery when handling recallable state revoked flag
    SUNRPC: Fix an error code in gss_alloc_msg()
    SUNRPC: task should be exit if encode return EKEYEXPIRED more times
    NFS4: Fix v4.0 client state corruption when mount
    PNFS fallback to MDS if no deviceid found
    NFS: make nfs_match_client killable
    lockd: Store the lockd client credential in struct nlm_host
    NFS: When mounting, don't share filesystems between different user namespaces
    NFS: Convert NFSv2 to use the container user namespace
    NFSv4: Convert the NFS client idmapper to use the container user namespace
    NFS: Convert NFSv3 to use the container user namespace
    SUNRPC: Use namespace of listening daemon in the client AUTH_GSS upcall
    SUNRPC: Use the client user namespace when encoding creds
    NFS: Store the credential of the mount process in the nfs_server
    SUNRPC: Cache cred of process creating the rpc_client
    xprtrdma: Remove stale comment
    xprtrdma: Update comments that reference ib_drain_qp
    ...

    Linus Torvalds
     

03 May, 2019

1 commit

  • Instead of having the convention where individual nfsd4_callback_ops->done
    operations return -1 to indicate the callback path is down, move the check
    to nfsd4_cb_done. Only mark the callback path down on transport-level
    errors, not NFS-level errors.

    The existing logic causes the server to set SEQ4_STATUS_CB_PATH_DOWN
    just because the client returned an error to a CB_RECALL for a
    delegation that the client had already done a FREE_STATEID for. But
    clearly that error doesn't mean that there's anything wrong with the
    backchannel.

    Additionally, handle NFS4ERR_DELAY in nfsd4_cb_recall_done. The client
    returns NFS4ERR_DELAY if it is already in the process of returning the
    delegation.

    Signed-off-by: Scott Mayhew
    Signed-off-by: J. Bruce Fields

    Scott Mayhew
     

27 Apr, 2019

1 commit


26 Apr, 2019

1 commit

  • The RPC_TASK_KILLED flag should really not be set from another context
    because it can clobber data in the struct task when task->tk_flags is
    changed non-atomically.
    Let's therefore swap out RPC_TASK_KILLED with an atomic flag, and add
    a function to set that flag and safely wake up the task.

    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker

    Trond Myklebust
     

09 Apr, 2019

1 commit

  • If there are multiple callbacks queued, waiting for the callback
    slot when the callback gets shut down, then they all currently
    end up acting as if they hold the slot, and call
    nfsd4_cb_sequence_done() resulting in interesting side-effects.

    In addition, the 'retry_nowait' path in nfsd4_cb_sequence_done()
    causes a loop back to nfsd4_cb_prepare() without first freeing the
    slot, which causes a deadlock when nfsd41_cb_get_slot() gets called
    a second time.

    This patch therefore adds a boolean to track whether or not the
    callback did pick up the slot, so that it can do the right thing
    in these 2 cases.

    Cc: stable@vger.kernel.org
    Signed-off-by: Trond Myklebust
    Signed-off-by: J. Bruce Fields

    Trond Myklebust
     

13 Mar, 2019

1 commit

  • Pull NFS server updates from Bruce Fields:
    "Miscellaneous NFS server fixes.

    Probably the most visible bug is one that could artificially limit
    NFSv4.1 performance by limiting the number of oustanding rpcs from a
    single client.

    Neil Brown also gets a special mention for fixing a 14.5-year-old
    memory-corruption bug in the encoding of NFSv3 readdir responses"

    * tag 'nfsd-5.1' of git://linux-nfs.org/~bfields/linux:
    nfsd: allow nfsv3 readdir request to be larger.
    nfsd: fix wrong check in write_v4_end_grace()
    nfsd: fix memory corruption caused by readdir
    nfsd: fix performance-limiting session calculation
    svcrpc: fix UDP on servers with lots of threads
    svcrdma: Remove syslog warnings in work completion handlers
    svcrdma: Squelch compiler warning when SUNRPC_DEBUG is disabled
    svcrdma: Use struct_size() in kmalloc()
    svcrpc: fix unlikely races preventing queueing of sockets
    svcrpc: svc_xprt_has_something_to_do seems a little long
    SUNRPC: Don't allow compiler optimisation of svc_xprt_release_slot()
    nfsd: fix an IS_ERR() vs NULL check

    Linus Torvalds
     

14 Feb, 2019

1 commit


07 Feb, 2019

1 commit

  • The get_backchannel_cred() used to return error pointers on error but
    now it returns NULL pointers.

    Fixes: 97f68c6b02e0 ("SUNRPC: add 'struct cred *' to auth_cred and rpc_cre")
    Signed-off-by: Dan Carpenter
    Signed-off-by: J. Bruce Fields

    Dan Carpenter
     

20 Dec, 2018

4 commits

  • SUNRPC has two sorts of credentials, both of which appear as
    "struct rpc_cred".
    There are "generic credentials" which are supplied by clients
    such as NFS and passed in 'struct rpc_message' to indicate
    which user should be used to authorize the request, and there
    are low-level credentials such as AUTH_NULL, AUTH_UNIX, AUTH_GSS
    which describe the credential to be sent over the wires.

    This patch replaces all the generic credentials by 'struct cred'
    pointers - the credential structure used throughout Linux.

    For machine credentials, there is a special 'struct cred *' pointer
    which is statically allocated and recognized where needed as
    having a special meaning. A look-up of a low-level cred will
    map this to a machine credential.

    Signed-off-by: NeilBrown
    Acked-by: J. Bruce Fields
    Signed-off-by: Anna Schumaker

    NeilBrown
     
  • When NFS creates a machine credential, it is a "generic" credential,
    not tied to any auth protocol, and is really just a container for
    the princpal name.
    This doesn't get linked to a genuine credential until rpcauth_bindcred()
    is called.
    The lookup always succeeds, so various places that test if the machine
    credential is NULL, are pointless.

    As a step towards getting rid of generic credentials, this patch gets
    rid of generic machine credentials. The nfs_client and rpc_client
    just hold a pointer to a constant principal name.
    When a machine credential is wanted, a special static 'struct rpc_cred'
    pointer is used. rpcauth_bindcred() recognizes this, finds the
    principal from the client, and binds the correct credential.

    Signed-off-by: NeilBrown
    Signed-off-by: Anna Schumaker

    NeilBrown
     
  • Use cred->fsuid and cred->fsgid instead.

    Signed-off-by: NeilBrown
    Signed-off-by: Anna Schumaker

    NeilBrown
     
  • The SUNRPC credential framework was put together before
    Linux has 'struct cred'. Now that we have it, it makes sense to
    use it.
    This first step just includes a suitable 'struct cred *' pointer
    in every 'struct auth_cred' and almost every 'struct rpc_cred'.

    The rpc_cred used for auth_null has a NULL 'struct cred *' as nothing
    else really makes sense.

    For rpc_cred, the pointer is reference counted.
    For auth_cred it isn't. struct auth_cred are either allocated on
    the stack, in which case the thread owns a reference to the auth,
    or are part of 'struct generic_cred' in which case gc_base owns the
    reference, and "acred" shares it.

    Signed-off-by: NeilBrown
    Signed-off-by: Anna Schumaker

    NeilBrown
     

26 Sep, 2018

1 commit


23 Aug, 2018

2 commits

  • Clean up: The global callback_cred is no longer used, so it can be
    removed.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • I've had trouble when operating a multi-homed Linux NFS server with
    Kerberos using NFSv4.0. Lately, I've seen my clients reporting
    this (and then hanging):

    May 9 11:43:26 manet kernel: NFS: NFSv4 callback contains invalid cred

    The client-side commit f11b2a1cfbf5 ("nfs4: copy acceptor name from
    context to nfs_client") appears to be related, but I suspect this
    problem has been going on for some time before that.

    RFC 7530 Section 3.3.3 says:
    > For Kerberos V5, nfs/hostname would be a server principal in the
    > Kerberos Key Distribution Center database. This is the same
    > principal the client acquired a GSS-API context for when it issued
    > the SETCLIENTID operation ...

    In other words, an NFSv4.0 client expects that the server will use
    the same GSS principal for callback that the client used to
    establish its lease. For example, if the client used the service
    principal "nfs@server.domain" to establish its lease, the server
    is required to use "nfs@server.domain" when performing NFSv4.0
    callback operations.

    The Linux NFS server currently does not. It uses a common service
    principal for all callback connections. Sometimes this works as
    expected, and other times -- for example, when the server is
    accessible via multiple hostnames -- it won't work at all.

    This patch scrapes the target name from the client credential,
    and uses that for the NFSv4.0 callback credential. That should
    be correct much more often.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     

10 Aug, 2018

1 commit


04 Apr, 2018

1 commit

  • Use enum nfs_cb_opnum4 in decode_cb_op_status. This fixes warnings
    seen with clang:
    fs/nfsd/nfs4callback.c:451:36: warning: implicit conversion from
    enumeration type 'enum nfs_cb_opnum4' to different enumeration
    type 'enum nfs_opnum4' [-Wenum-conversion]
    status = decode_cb_op_status(xdr, OP_CB_SEQUENCE, &cb->cb_seq_status);
    ~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~

    Signed-off-by: Stefan Agner
    Signed-off-by: J. Bruce Fields

    Stefan Agner
     

18 Jul, 2017

1 commit


15 May, 2017

5 commits


18 Feb, 2017

3 commits


15 Nov, 2016

1 commit

  • No real change in functionality, but the old interface seems to be
    deprecated.

    We don't actually care about ordering necessarily, but we do depend on
    running at most one work item at a time: nfsd4_process_cb_update()
    assumes that no other thread is running it, and that no new callbacks
    are starting while it's running.

    Reviewed-by: Jeff Layton
    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     

27 Sep, 2016

1 commit


17 Sep, 2016

1 commit