NFSD: Randomize clientids, session IDs, and COPY_NOTIFY tokens
Get series with b4
b4 am [email protected] change-id 20261029-random-stateids-c66f263d7800Versions newest first
- v2 Latest10 patches 0 repliesNew
- v110 patches 3 repliesSuperseded
Changes in v2 from the cover letter
- Re-organized the KUnit tests per recommendations in Documentation/
- Free the KUnit COPY_NOTIFY entry if idr_alloc_u32() fails (sashiko)
- Link to v1: https://patch.msgid.link/[email protected]
Patches in v2 No applies recorded yet
Reviews trailers per patch
9 of 10 patches have a Reviewed-by or Acked-by.
| Patch | Jeff Layton |
|---|---|
| 1/10 | R-b |
| 2/10 | R-b |
| 3/10 | R-b |
| 4/10 | R-b |
| 5/10 | R-b |
| 6/10 | R-b |
| 7/10 | R-b |
| 8/10 | R-b |
| 9/10 | R-b |
| 10/10 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 00/10] NFSD: Randomize clientids, session IDs, and COPY_NOTIFY tokens
NFSD currently assigns a clientid from a per-netns counter, a session ID's sequence word from a global counter, and a COPY_NOTIFY stateid's so_id from a cyclic allocator with a fixed clientid word. Each of the three is a bearer token. NFSv4.0 resolves a presented stateid against the client named inside it rather than the caller, and the errors the protocol mandates (EXPIRED for an unknown clientid, BAD_STATEID for a known clientid with an unknown index) let the two halves be searched separately. Under SP4_NONE, nfsd4_sequence() does not check a credential, so a session ID alone can reach another client's slot table. Adjacent counter values let a malicious requester find a neighbor's token in a few dozen probes by counting outward from its own.
After this series, the clientid, the session ID, and the COPY_NOTIFY token's clientid word are random. Predicting a live clientid costs about 2^32 / C probes for C clients of the probe's minor version, and a session ID 2^64. An ordinary stateid's so_id stays cyclic, so it stays cheap to search once a clientid is known. RFC 8881 forbids reusing an "other" value for a different purpose, and the cyclic allocator is the non-reuse mechanism clients rely on.
Tested with the new KUnit suite, pynfs 4.0 and 4.1 over loopback, and pynfs-based probes that confirm the three tokens are unpredictable, that a LOCKT denial no longer carries a clientid, and that a COPY_NOTIFY stateid with a wrong clientid word is rejected. A same-second restart loop confirmed STALE_CLIENTID on RENEW and a clean shutdown with live COPY_NOTIFY state.
---
Changes in v2:
- Re-organized the KUnit tests per recommendations in Documentation/
- Free the KUnit COPY_NOTIFY entry if idr_alloc_u32() fails (sashiko)
- Link to v1: https://patch.msgid.link/[email protected]
---
Chuck Lever (10):
NFSD: Serialize forced client expiry with state shutdown
NFSD: Check machine credentials before expiring a client in DESTROY_CLIENTID
NFSD: Make nn->boot_time strictly increase across state starts
NFSD: Give each client a display id independent of cl_id
NFSD: Generate the clientid at random instead of from a counter
NFSD: Stop disclosing the conflicting lock holder in a lock denial
NFSD: Destroy the COPY_NOTIFY stateid IDR at netns teardown
NFSD: Put a random word in each COPY_NOTIFY stateid
NFSD: Fill the session ID's sequence and reserved words at random
NFSD: Add KUnit tests for the random identifier generators
fs/nfsd/Kconfig | 14 + fs/nfsd/Makefile | 2 + fs/nfsd/netns.h | 9 +- fs/nfsd/nfs4layouts.c | 10 +- fs/nfsd/nfs4proc.c | 2 - fs/nfsd/nfs4state.c | 313 ++++++++++++++----- fs/nfsd/nfsctl.c | 2 + fs/nfsd/state.h | 45 ++- fs/nfsd/tests/Makefile | 3 + fs/nfsd/tests/nfsd_state_kunit.c | 634 +++++++++++++++++++++++++++++++++++++++ fs/nfsd/xdr4.h | 2 - 11 files changed, 944 insertions(+), 92 deletions(-)
---
base-commit: 6ab6af61dba3facd7684c303763bb15da8a959fb
change-id: 20261029-random-stateids-c66f263d7800
Best regards,
Signature · 1 line
Chuck Lever <[email protected]>