Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] NFSD: prevent integer overflow on 32 bit systems
@ 2022-03-14 14:09 Dan Carpenter
  2022-03-14 14:45 ` Chuck Lever III
  2022-03-14 19:57 ` kernel test robot
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2022-03-14 14:09 UTC (permalink / raw)
  To: Chuck Lever, Trond Myklebust
  Cc: Anna Schumaker, linux-nfs, kernel-janitors, Harshit Mogalapalli

On a 32 bit system, the "len * sizeof(*p)" operation can have an
integer overflow.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
It's hard to pick a Fixes tag for this...  The temptation is to say:
Fixes: 37c88763def8 ("NFSv4; Clean up XDR encoding of type bitmap4")
But there were integer overflows in the code before that as well.

 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..61b92e6b9813 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 > ULONG_MAX / sizeof(*p))
+		return -EBADMSG;
 	p = xdr_inline_decode(xdr, len * sizeof(*p));
 	if (unlikely(!p))
 		return -EBADMSG;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-15 15:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-14 14:09 [PATCH] NFSD: prevent integer overflow on 32 bit systems Dan Carpenter
2022-03-14 14:45 ` Chuck Lever III
2022-03-14 17:03   ` Dan Carpenter
2022-03-14 18:05     ` Chuck Lever III
2022-03-14 19:25       ` Trond Myklebust
2022-03-14 19:57 ` kernel test robot
2022-03-15 15:40   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox