From: Dan Carpenter <dan.carpenter@oracle.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: Anna Schumaker <anna@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>,
linux-nfs@vger.kernel.org,
Trond Myklebust <trondmy@hammerspace.com>,
kernel-janitors@vger.kernel.org
Subject: [PATCH v2] NFSD: prevent integer overflow on 32 bit systems
Date: Tue, 15 Mar 2022 18:34:06 +0300 [thread overview]
Message-ID: <20220315153406.GA1527@kili> (raw)
On a 32 bit system, the "len * sizeof(*p)" operation can have an
integer overflow.
c: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: add stable to the CC. Use SIZE_MAX.
include/linux/sunrpc/xdr.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index b519609af1d0..4417f667c757 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -731,6 +731,8 @@ xdr_stream_decode_uint32_array(struct xdr_stream *xdr,
if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
return -EBADMSG;
+ if (len > SIZE_MAX / sizeof(*p))
+ return -EBADMSG;
p = xdr_inline_decode(xdr, len * sizeof(*p));
if (unlikely(!p))
return -EBADMSG;
--
2.20.1
next reply other threads:[~2022-03-15 15:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 15:34 Dan Carpenter [this message]
2022-03-15 16:22 ` [PATCH v2] NFSD: prevent integer overflow on 32 bit systems Chuck Lever III
2022-03-15 16:30 ` Trond Myklebust
2022-03-15 16:39 ` Chuck Lever III
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=20220315153406.GA1527@kili \
--to=dan.carpenter@oracle.com \
--cc=anna@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@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