Skip to content

pnfs/blocklayout: harden GETDEVICEINFO volume parser

Werner Kasselman linux-nfs lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2pnfs/blocklayout: validate volume indices and limit recursion depthfs/nfs/blocklayout/blocklayout.h fs/nfs/blocklayout/dev.c+41 -141 reply
2/2pnfs/blocklayout: cap total parse operations in volume topologyfs/nfs/blocklayout/blocklayout.h fs/nfs/blocklayout/dev.c+20 -121 reply

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/2] pnfs/blocklayout: harden GETDEVICEINFO volume parser

The recursive-descent volume parser in fs/nfs/blocklayout/dev.c has three problems reachable from a malicious NFS server:

- Server-supplied volume indices are used without bounds checking, causing an OOB heap read at volumes[idx].type.
- The mutual recursion between bl_parse_deviceid and the type-specific parsers has no depth limit, so a cyclic or deeply chained topology overflows the kernel stack.
- When nr_volumes is 0, the entry point computes nr_volumes - 1 as the starting index, underflowing to -1.

Patch 1 fixes the memory-safety issues: index validation, depth cap, and nr_volumes == 0 rejection.

Patch 2 adds a total parse-operation budget (PNFS_BLOCK_MAX_PARSE_OPS) to prevent resource exhaustion from DAG-shaped topologies where shared child references cause exponential tree materialization.

A standalone test exercising all three bug classes and the fixes is at:
tools/testing/pnfs-blocklayout/test-volume-parser.c

Werner Kasselman (2):
pnfs/blocklayout: validate volume indices and limit recursion depth pnfs/blocklayout: cap total parse operations in volume topology

 fs/nfs/blocklayout/blocklayout.h |  2 ++
 fs/nfs/blocklayout/dev.c         | 61 ++++++++++++++++++++++++--------
 2 files changed, 49 insertions(+), 14 deletions(-)

--
2.43.0