From: Michael Bommarito <michael.bommarito@gmail.com>
To: Trond Myklebust <trondmy@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: Jeff Layton <jlayton@kernel.org>,
Tom Haynes <Thomas.Haynes@primarydata.com>,
Peng Tao <tao.peng@primarydata.com>, Kees Cook <kees@kernel.org>,
Mike Snitzer <snitzer@kernel.org>,
Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH v2 0/2] NFSv4/pNFS: fix client kernel panic from malformed GETDEVICEINFO
Date: Wed, 27 May 2026 12:30:34 -0400 [thread overview]
Message-ID: <20260527163036.1524927-1-michael.bommarito@gmail.com> (raw)
A malicious or compromised NFSv4.1+ pNFS metadata server can panic any
pNFS-flexfile client by returning a GETDEVICEINFO body with a
multipath-DS count of >= 3 and exactly one valid (netid, uaddr) pair.
The unbounded inner loop in nfs4_ff_alloc_deviceid_node() (and the
parallel site in nfs4_fl_alloc_deviceid_node() for the legacy file
layout) keeps iterating after the first netaddr is decoded, consuming
the trailing version_count / version / minor words of the body as
opaque netid + uaddr pairs. Both come out as zero-length strings;
xdr_stream_decode_string_dup() sets *str = NULL and returns 0; the
caller in nfs4_decode_mp_ds_addr() only checks "< 0" and immediately
calls strrchr(NULL, '.').
A QEMU/KASAN reproducer is described in the second patch. The
shortest crashing GETDEVICEINFO body is 56 bytes, the panic is 5/5
deterministic at multipath_count = 10, and it fires before any
user-level read can complete on the first pNFS file the client
touches.
Patch 1 closes the NULL dereference itself by changing the two
xdr_stream_decode_string_dup() return-value checks in
nfs4_decode_mp_ds_addr() from "< 0" to "<= 0". Patch 2 promotes
NFS4_PNFS_MAX_MULTI_CNT to include/linux/nfs4.h so flexfile and the
legacy file layout can share it, bounds the inner mp_count loop in
both drivers against that cap, and breaks the loop on the first NULL
return from nfs4_decode_mp_ds_addr() so a hostile server cannot drive
the decoder past a single malformed entry. Either patch alone closes
the panic; both together close the latent unbounded-decode class.
The unbound on mp_count predates the flexfile driver: the same loop
exists in the legacy file layout since 35124a0994fc ("Cleanup XDR
parsing for LAYOUTGET, GETDEVICEINFO", 2011) and was carried into
flexfile by d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout
Driver", 2014). The NULL-deref site was introduced by 6b7f3cf96364
("nfs41: pull decode_ds_addr from file layout to generic pnfs") when
the netaddr decode was unified. Stable backporting wanted for all
three.
Changes in v2:
- Carry the stripe_index provenance comment from filelayout.h to the
new NFS4_PNFS_MAX_MULTI_CNT location in include/linux/nfs4.h, as
Anna requested.
Cc: stable@vger.kernel.org
Michael Bommarito (2):
NFSv4/pNFS: reject zero-length r_addr in nfs4_decode_mp_ds_addr
NFSv4/flexfile,filelayout: bound multipath DS count in GETDEVICEINFO
fs/nfs/filelayout/filelayout.h | 2 +-
fs/nfs/filelayout/filelayoutdev.c | 7 +++++--
fs/nfs/flexfilelayout/flexfilelayoutdev.c | 10 ++++++++--
fs/nfs/pnfs_nfs.c | 4 ++--
include/linux/nfs4.h | 5 +++++
5 files changed, 21 insertions(+), 7 deletions(-)
base-commit: 0a0e44d91ce037ac5371b0d8dfbbfc5f693b27c7
--
2.53.0
next reply other threads:[~2026-05-27 16:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 16:30 Michael Bommarito [this message]
2026-05-27 16:30 ` [PATCH v2 1/2] NFSv4/pNFS: reject zero-length r_addr in nfs4_decode_mp_ds_addr Michael Bommarito
2026-05-27 16:30 ` [PATCH v2 2/2] NFSv4/flexfile,filelayout: bound multipath DS count in GETDEVICEINFO Michael Bommarito
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=20260527163036.1524927-1-michael.bommarito@gmail.com \
--to=michael.bommarito@gmail.com \
--cc=Thomas.Haynes@primarydata.com \
--cc=anna@kernel.org \
--cc=jlayton@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=snitzer@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tao.peng@primarydata.com \
--cc=tigran.mkrtchyan@desy.de \
--cc=trondmy@kernel.org \
/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
all inboxes | Powered by JetHome®