From: Greg KH <greg@kroah.com>
To: Tien Phan <tienpp@gmail.com>
Cc: security@kernel.org, Chuck Lever <chuck.lever@oracle.com>,
NeilBrown <neilb@suse.de>, Jeff Layton <jlayton@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] nfsd: fix use-after-free of DRC slot in nfsd4_sequence()
Date: Wed, 19 Aug 2026 07:52:05 +0200 [thread overview]
Message-ID: <2026081931-disrupt-flatbed-5de4@gregkh> (raw)
In-Reply-To: <20260819054326.1265334-1-tienpp@gmail.com>
On Wed, Aug 19, 2026 at 02:43:26PM +0900, Tien Phan wrote:
> nfsd4_sequence() loads the slot addressed by the client-supplied
> seq->slotid, bounded only against se_fchannel.maxreqs:
>
> if (seq->slotid >= session->se_fchannel.maxreqs)
> goto out_put_session;
> slot = xa_load(&session->se_slots, seq->slotid);
>
> When the client acknowledges a slot-count reduction, the handler frees
> every slot in [se_target_maxslots, maxreqs):
>
> if (session->se_target_maxslots < session->se_fchannel.maxreqs &&
> slot->sl_generation == session->se_slot_gen &&
> seq->maxslots <= session->se_target_maxslots)
> free_session_slots(session, session->se_target_maxslots);
>
> but never checks that the slot it just loaded lies outside that range.
> A malicious NFSv4.1 client can pick seq->slotid >= se_target_maxslots
> (still < maxreqs, so the bound above passes) and, once the DRC slot
> shrinker has lowered se_target_maxslots below maxreqs, issue two SEQUENCE
> calls on that high slot: the first aligns slot->sl_generation with
> se_slot_gen, the second satisfies the reduce-ack condition and calls
> free_session_slots(), which kfree()s the very slot still referenced by
> the handler. The slot is then written (slot->sl_seqid = seq->seqid,
> slot->sl_flags, cstate->slot = slot) and used for DRC caching -- a
> use-after-free write.
>
> Reject a slotid that falls within the range about to be freed before
> freeing it, so the handler never operates on a freed slot.
>
> Found with an in-tree KASAN harness driving the real free_session_slots()
> on a live slot xarray (KASAN: slab-use-after-free, write of size 4).
>
> Fixes: fc8738c68d0b ("nfsd: add support for freeing unused session-DRC slots")
> Cc: stable@vger.kernel.org # 6.14+
> Signed-off-by: Tien Phan <tienpp@gmail.com>
Did you forget an Assisted-by: tag here?
thanks,
greg k-h
next prev parent reply other threads:[~2026-08-19 5:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 5:43 [PATCH] nfsd: fix use-after-free of DRC slot in nfsd4_sequence() Tien Phan
2026-08-19 5:52 ` Greg KH [this message]
[not found] ` <CALjHmwND53Gdy0xMaPNMtvBP5=9KQ7M9-E2S+W1wweQw30tEmw@mail.gmail.com>
2026-08-19 7:29 ` Greg KH
2026-08-19 11:00 ` Jeff Layton
2026-08-19 7:21 ` [PATCH v2] " Tien Phan
2026-08-19 7:47 ` [PATCH v3] " Tien Phan
2026-08-19 11:23 ` Jeff Layton
2026-08-23 9:26 ` Ingo Molnar
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=2026081931-disrupt-flatbed-5de4@gregkh \
--to=greg@kroah.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=neilb@suse.de \
--cc=security@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tienpp@gmail.com \
/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