From: Anna Schumaker <anna@kernel.org>
To: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com
Cc: anna@kernel.org
Subject: [PATCH 3/3] NFS: Modernize decode_getdevinfo() bitmap decoding
Date: Mon, 12 Oct 2026 08:33:46 -0400 [thread overview]
Message-ID: <20261012123346.123126-4-anna@kernel.org> (raw)
In-Reply-To: <20261012123346.123126-1-anna@kernel.org>
From: Anna Schumaker <anna.schumaker@hammerspace.com>
Use the decode_bitmap4() function for decoding notification bitmaps.
This function calls xdr_stream_decode_uint32_array() to do proper bounds
and overflow checking.
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
---
fs/nfs/nfs4xdr.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 4d12b97f423e..c0971af20154 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -6064,7 +6064,7 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr,
{
struct pnfs_device *pdev = res->pdev;
__be32 *p;
- uint32_t len, type;
+ uint32_t type;
int status;
status = decode_op_hdr(xdr, OP_GETDEVICEINFO);
@@ -6099,26 +6099,8 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr,
return -EIO;
/* Parse notification bitmap, verifying that it is zero. */
- p = xdr_inline_decode(xdr, 4);
- if (unlikely(!p))
+ if (decode_bitmap4(xdr, &res->notification, 1) < 0)
return -EIO;
- len = be32_to_cpup(p);
- if (len) {
- uint32_t i;
-
- p = xdr_inline_decode(xdr, 4 * len);
- if (unlikely(!p))
- return -EIO;
-
- res->notification = be32_to_cpup(p++);
- for (i = 1; i < len; i++) {
- if (be32_to_cpup(p++)) {
- dprintk("%s: unsupported notification\n",
- __func__);
- return -EIO;
- }
- }
- }
return 0;
}
--
2.56.0
next prev parent reply other threads:[~2026-10-12 12:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 12:33 [PATCH 0/3] NFS: Modernize decoding uint32 arrays Anna Schumaker
2026-10-12 12:33 ` [PATCH 1/3] NFS: Have decode_pnfs_layout_types() use XDR's decode_uint32_array() Anna Schumaker
2026-10-12 12:33 ` [PATCH 2/3] NFS: Modernize the callback decode_bitmap() function Anna Schumaker
2026-10-12 13:13 ` Benjamin Coddington
2026-10-12 15:06 ` Anna Schumaker
2026-10-12 12:33 ` Anna Schumaker [this message]
2026-10-12 13:14 ` [PATCH 0/3] NFS: Modernize decoding uint32 arrays Benjamin Coddington
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=20261012123346.123126-4-anna@kernel.org \
--to=anna@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/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