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: 1be5683b03 ("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>
This commit is contained in:
Benjamin Coddington 2026-09-15 08:22:05 -04:00 committed by Anna Schumaker
parent 0cc1191538
commit 32f0967ea2

View File

@ -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);