From: Cheng Yongkang <teel4res@gmail.com>
To: Trond Myklebust <trondmy@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] NFS: keep in-flight slots when shrinking the session slot table
Date: Sun, 29 Nov 2026 21:18:05 -0800 [thread overview]
Message-ID: <20261130051805.3469379-1-teel4res@gmail.com> (raw)
In-Reply-To: <1ea6f3606dc3c3caaed3e013a1a51a4b2c78d909.camel@kernel.org>
On Sat, 2026-11-28 at 19:56 -0500, Trond Myklebust wrote:
> 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.
The case I hit is the create_session workflow run from
nfs4_reset_session(). The drain there does not keep the table empty
until nfs4_proc_create_session() runs. nfs4_drain_slot_tbl() returns
once highest_used_slotid is NFS4_NO_SLOT, but nfs4_setup_sequence() and
nfs41_assign_slot() still give slots to privileged RPCs while
NFS4_SLOT_TBL_DRAINING is set. Since commit dfe1fe75e00e ("NFSv4: Fix
deadlock between nfs4_evict_inode() and nfs4_opendata_get_inode()"), the
DELEGRETURN sent from nfs4_evict_inode() is privileged once
nfs_igrab_and_active() fails, so it can take a slot after the drain:
state manager inode eviction
nfs4_reset_session()
nfs4_begin_drain_session()
table empty, returns
nfs4_proc_destroy_session()
nfs4_evict_inode()
DELEGRETURN (privileged)
nfs4_setup_sequence()
takes slot 1
nfs4_proc_create_session()
server returns max_reqs = 1
nfs4_setup_session_slot_tables()
nfs4_realloc_slot_table()
nfs4_reset_slot_table()
nfs4_shrink_slot_table()
kfree(slot 1)
DELEGRETURN reply
decode_sequence()
reads the freed slot
I reproduced it on 7.3 with a test server that answers a GETATTR
compound with NFS4ERR_BADSESSION, delays the DESTROY_SESSION and
DELEGRETURN replies, and returns max_reqs = 1 instead of 4 in the new
session:
BUG: KASAN: slab-use-after-free in decode_sequence+0xb3/0x690
Read of size 8 at addr ... by task kworker/u8:1/13
Workqueue: rpciod rpc_async_schedule
decode_sequence+0xb3/0x690
nfs4_xdr_dec_delegreturn+0x54/0x380
call_decode+0x522/0x930
__rpc_execute+0x520/0x1270
rpc_async_schedule+0x52/0xa0
Freed by task ...:
kfree
nfs4_realloc_slot_table+0x597
nfs4_setup_session_slot_tables
nfs4_proc_create_session
nfs4_run_state_manager
The delays only widen the window. RFC 8881 lets a server destroy a
session while fore channel requests are outstanding (section 18.37.3
only allows it to refuse for unanswered CB_COMPOUNDs), and lets it
change ca_maxrequests for the fore channel in CREATE_SESSION (section
18.36).
v2 keeps the slots that are still in use when the table is shrunk. If
you would rather keep the privileged DELEGRETURN off the slot table
during a session reset, or wait for it before
nfs4_proc_create_session(), I can rework it that way.
Thanks,
Cheng
prev parent reply other threads:[~2026-11-30 5:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 10:52 Cheng Yongkang
2026-11-29 0:56 ` Trond Myklebust
2026-11-30 5:18 ` Cheng Yongkang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130051805.3469379-1-teel4res@gmail.com \
--to=teel4res@gmail.com \
--cc=anna@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=trondmy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®