Skip to content

NFS: harden pNFS XDR decoding

Prabhakar Pujeri linux-nfs stable 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest7 patches 0 repliesNew

Changes in v2 from the cover letter

- rebase from the NFS client linux-next integration commit 10f307e525a1

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7NFS: free netid when discarding pNFS DS addressesfs/nfs/filelayout/filelayoutdev.c fs/nfs/flexfilelayout/flexfilelayoutdev.c fs/nfs/pnfs.h +1 more+7 -100 replies
2/7NFS: bound flexfiles GETDEVICEINFO version countfs/nfs/flexfilelayout/flexfilelayoutdev.c+3 -40 replies
3/7NFS: bound flexfiles filehandle version countfs/nfs/flexfilelayout/flexfilelayout.c+2 -10 replies
4/7NFS: validate pNFS data server port octetsfs/nfs/pnfs_nfs.c+28 -180 replies
5/7NFS: bound multipath address count in file-layout GETDEVICEINFOfs/nfs/filelayout/filelayoutdev.c fs/nfs/pnfs.h+13 -00 replies
6/7NFS: bound multipath address count in flexfiles GETDEVICEINFOfs/nfs/flexfilelayout/flexfilelayoutdev.c+5 -00 replies
7/7NFS: add KUnit coverage for pNFS XDR decodingfs/nfs/Kconfig fs/nfs/Makefile fs/nfs/flexfilelayout/Makefile +5 more+561 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/7] NFS: harden pNFS XDR decoding

pNFS device and layout replies contain several counts and strings supplied by the server. The current decoders trust some of those values before the reply has proved that the corresponding XDR objects are present. A broken or malicious server can therefore provoke oversized allocations, very long decode loops, malformed data-server ports, or leaked netid strings on temporary-address cleanup paths.

This series makes those paths proportional to the received XDR length. It also validates both decimal port octets and uses the common data-server address destructor wherever a temporary address is discarded.

The last patch adds focused, page-backed KUnit coverage for the address, GETDEVICEINFO, and LAYOUTGET decoders. It covers 16 universal-address cases and six flexfiles cases, including cache reuse and malformed multipath, version, and filehandle counts.

This version is based on v7.3-rc1.

Validation:

- nfs_pnfs_decode KUnit suite: 16/16 passed
- nfs_flexfile_deviceid KUnit suite: 6/6 passed
- GCC 16 W=1 build of fs/nfs/: passed with no NFS diagnostics
- Clang 22 W=1 build of fs/nfs/: passed with no NFS diagnostics
- GCC 16 W=1 build of fs/nfs/ with KUnit disabled: passed
- Sparse C=2 checks of every touched C source: passed with no diagnostics
- GCC 16 W=1 full kernel and modules build: passed
- git diff --check: clean
- per-patch checkpatch: no errors or code warnings; patch 7 reports only the generic FILE_PATH_CHANGES warning for the new test files

Changes in v2:

- rebase from the NFS client linux-next integration commit 10f307e525a1

    to v7.3-rc1

- free da_netid on file-layout and flexfiles temporary-address paths
- bound flexfiles GETDEVICEINFO version_count before allocation
- bound flexfiles LAYOUTGET fh_count before allocation
- expand flexfiles KUnit coverage from three to six cases, including the cache-hit and malformed-version cleanup paths
- rename the test patch to reflect the broader XDR coverage

v1: https://lore.kernel.org/r/[email protected]

Prabhakar Pujeri (7):
NFS: free netid when discarding pNFS DS addresses
NFS: bound flexfiles GETDEVICEINFO version count
NFS: bound flexfiles filehandle version count
NFS: validate pNFS data server port octets
NFS: bound multipath address count in file-layout GETDEVICEINFO
NFS: bound multipath address count in flexfiles GETDEVICEINFO
NFS: add KUnit coverage for pNFS XDR decoding

 fs/nfs/Kconfig                               |  34 +++
 fs/nfs/Makefile                              |   3 +
 fs/nfs/filelayout/filelayoutdev.c            |  11 +-
 fs/nfs/flexfilelayout/Makefile               |   3 +
 fs/nfs/flexfilelayout/flexfilelayout.c       |   7 +-
 fs/nfs/flexfilelayout/flexfilelayout.h       |   6 +
 fs/nfs/flexfilelayout/flexfilelayoutdev.c    |  22 +-
 fs/nfs/flexfilelayout/tests/deviceid_kunit.c | 286 +++++++++++++++++++
 fs/nfs/pnfs.h                                |   9 +
 fs/nfs/pnfs_nfs.c                            |  50 ++--
 fs/nfs/tests/pnfs_decode_kunit.c             | 222 ++++++++++++++
 11 files changed, 619 insertions(+), 34 deletions(-)
 create mode 100644 fs/nfs/flexfilelayout/tests/deviceid_kunit.c
 create mode 100644 fs/nfs/tests/pnfs_decode_kunit.c

base-commit: cee9395acd8043be0644b25c34bfa86623f2b935

Signature · 1 line
2.54.0