Re: [PATCH v2] NFS: keep in-flight slots when shrinking the session slot table
From: Trond Myklebust
Date: Sat Nov 28 2026 - 19:56:47 EST
On Mon, 2026-10-26 at 03:52 -0700, Cheng Yongkang wrote:
> nfs4_reset_slot_table() shrinks the forechannel slot table to the new
> session's max_reqs without checking whether any of the slots being
> freed are still in use. The session drain it follows only snapshots
> highest_used_slotid once, while nfs4_setup_sequence() and
> nfs41_assign_slot() deliberately let privileged RPCs (sa_privileged,
> e.g. the DELEGRETURN sent while an inode is being evicted) allocate a
> slot after that snapshot. If such an RPC owns a slot with
> slot_nr >= max_reqs, nfs4_shrink_slot_table() kfree()s it and the
> reply path (decode_sequence(), nfs41_release_slot(),
> nfs4_free_slot())
> later dereferences the freed slot: a slab-use-after-free.
>
> Clamp the shrink target to highest_used_slotid + 1 when the table is
> not empty, so only slots above the highest used slot are freed, and
> stop resetting highest_used_slotid: the high-water mark is still
> needed
> to release those slots and to complete a later drain. max_slotid is
> still set to the server's new highest slotid, so new RPCs cannot use
> the preserved slots above the new max_reqs. A server advertising
> max_reqs == 0 arrives with server_highest_slotid == NFS4_NO_SLOT;
> make
> that wrap explicit.
>
NACK. nfs4_reset_slot_table() is never called on a session table that
is in use. It is called as part of the create_session workflow, and as
part of the NFSv4.0 client initialisation.
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@xxxxxxxxxx, trond.myklebust@xxxxxxxxxxxxxxx