summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Coddington <ben.coddington@hammerspace.com>2026-09-15 08:22:05 -0400
committerAnna Schumaker <anna.schumaker@hammerspace.com>2026-10-05 09:46:42 -0400
commit32f0967ea296d447925465c98e7eec71d4e2f755 (patch)
treeb942410d4dd718050625d461aa0daeebab6a87c3
parent0cc1191538b1523dfe944eedc799fdd146c05fbf (diff)
NFSv4/pnfs: bound the CB_NOTIFY_DEVICEID array count before allocating
decode_devicenotify_args() hands the server's notification count straight to kmalloc_objs() as the array length, without checking it against the message that carried it. Bound it the way nfs4xdr.c bounds an attribute length, against xdr_stream_remaining(). Fixes: 1be5683b03a7 ("pnfs: CB_NOTIFY_DEVICEID") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-fable-5 Signed-off-by: Benjamin Coddington <bcodding@hammerspace.com> Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
-rw-r--r--fs/nfs/callback_xdr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 88e1af0fda01..b1bc2c02b5a6 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -271,6 +271,13 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
if (n == 0)
goto out;
+ /* sanity check the count against the remaining stream */
+ if (n > xdr_stream_remaining(xdr) /
+ ((4 * sizeof(uint32_t)) + NFS4_DEVICEID4_SIZE)) {
+ status = htonl(NFS4ERR_BADXDR);
+ goto out;
+ }
+
args->devs = kmalloc_objs(*args->devs, n);
if (!args->devs) {
status = htonl(NFS4ERR_DELAY);