From: Anna Schumaker <anna@kernel.org>
To: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com
Cc: anna@kernel.org
Subject: [PATCH 2/3] NFS: Modernize the callback decode_bitmap() function
Date: Mon, 12 Oct 2026 08:33:45 -0400 [thread overview]
Message-ID: <20261012123346.123126-3-anna@kernel.org> (raw)
In-Reply-To: <20261012123346.123126-1-anna@kernel.org>
From: Anna Schumaker <anna.schumaker@hammerspace.com>
The sunrpc function xdr_stream_decode_uint32_array() is already designed
to decode arrays of integers with all necessary bounds checking. Update
the decode_bitmap() function to call this and map the return value into
something the callback handler expects.
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
---
fs/nfs/callback_xdr.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 5a1f05469268..b6ecfb73d850 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -100,24 +100,14 @@ static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh)
return 0;
}
-static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
+static __be32 decode_bitmap(struct xdr_stream *xdr, __u32 *bitmap,
+ size_t bitmap_size)
{
- __be32 *p;
- unsigned int attrlen;
+ ssize_t status;
- p = xdr_inline_decode(xdr, 4);
- if (unlikely(p == NULL))
+ status = xdr_stream_decode_uint32_array(xdr, bitmap, bitmap_size);
+ if (unlikely(status < 0))
return htonl(NFS4ERR_RESOURCE);
- attrlen = ntohl(*p);
- p = xdr_inline_decode(xdr, attrlen << 2);
- if (unlikely(p == NULL))
- return htonl(NFS4ERR_RESOURCE);
- if (likely(attrlen > 0))
- bitmap[0] = ntohl(*p++);
- if (attrlen > 1)
- bitmap[1] = ntohl(*p++);
- if (attrlen > 2)
- bitmap[2] = ntohl(*p);
return 0;
}
@@ -182,7 +172,7 @@ static __be32 decode_getattr_args(struct svc_rqst *rqstp,
status = decode_fh(xdr, &args->fh);
if (unlikely(status != 0))
return status;
- return decode_bitmap(xdr, args->bitmap);
+ return decode_bitmap(xdr, args->bitmap, ARRAY_SIZE(args->bitmap));
}
static __be32 decode_recall_args(struct svc_rqst *rqstp,
@@ -458,7 +448,7 @@ static __be32 decode_recallany_args(struct svc_rqst *rqstp,
if (unlikely(p == NULL))
return htonl(NFS4ERR_BADXDR);
args->craa_objs_to_keep = ntohl(*p++);
- status = decode_bitmap(xdr, bitmap);
+ status = decode_bitmap(xdr, bitmap, ARRAY_SIZE(bitmap));
if (unlikely(status))
return status;
args->craa_type_mask = bitmap[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 ` Anna Schumaker [this message]
2026-10-12 13:13 ` [PATCH 2/3] NFS: Modernize the callback decode_bitmap() function Benjamin Coddington
2026-10-12 15:06 ` Anna Schumaker
2026-10-12 12:33 ` [PATCH 3/3] NFS: Modernize decode_getdevinfo() bitmap decoding Anna Schumaker
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-3-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