CVE-2026-99366: nfsd: don't modify a session slot when replaying its cached reply
In the Linux kernel, the following vulnerability has been resolved:
nfsd: don't modify a session slot when replaying its cached reply
nfsd4sequence() claims a session slot by setting NFSD4SLOTINUSE under nn->clientlock. A reply served from the slot's reply cache does not claim it, and that distinction lived only in cstate->status, which nfsd4sequence() set to nfserrreplaycache. Commit cc028a10a48c ("NFSD: Hoist status code encoding into XDR encoder functions") moved nfsd4proccompound()'s cstate->status assignment below the out: label, and the replay path's goto out was the one path that relied on skipping it. The test in nfsd4sequencedone() therefore no longer identifies a replay, and every replay now stores its reply and clears NFSD4SLOTINUSE as though it owned the slot.
NFSD4SLOTINUSE is the interlock: checkslotseqid() rejects every sequence id for a slot that is in use, before replaymatchescache() runs. A replay never sets it, so two replays can be in flight on the same slot at once. One can read slot->slcred under nn->clientlock while the other's completion frees and rebuilds it from the XDR encoder without that lock. Two completions can also collide with each other and release the same groupinfo twice. freesvccred() leaves cruid, crgid and crflavor intact, so the reader passes every earlier test in samecreds() and dereferences a NULL crgroupinfo. From a 6.12.91 production server:
BUG: kernel NULL pointer dereference, address: 0000000000000004 CPU: 63 UID: 0 PID: 39015 Comm: nfsd RIP: 0010:samecreds+0x38/0xa0 [nfsd] RDX: 0000000000000000 Call Trace: nfsd4sequence+0x6a8/0x910 [nfsd] nfsd4proccompound+0x345/0x670 [nfsd] nfsddispatch+0x100/0x220 [nfsd] svcprocesscommon+0x311/0x700 [sunrpc] svcprocess+0x131/0x1c0 [sunrpc] svcrecv+0x7ef/0x9c0 [sunrpc] nfsd+0xa3/0x100 [nfsd] Kernel panic - not syncing: Fatal exception
Since v6.14 a live session's slot table can shrink, and the unowned store becomes a use-after-free write. nfsd4sequence() defers the shrink while a slot is in use, but it tests NFSD4SLOTINUSE, which a replay does not set, so freesessionslots() can kfree() the slot the replay still holds in cstate->slot.
Record the claim in cstate->slotowned when nfsd4sequence() accepts a request and test that in nfsd4sequencedone(), so only the request that claimed the slot updates its cached reply and clears NFSD4SLOTINUSE. svcgenericinitrequest() zeroes the compound response before each request, so the flag starts clear.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch cc028a10a48c