All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFSD: check for negative "len" values in nfssvc_decode_writeargs()
@ 2022-03-14 14:06 Dan Carpenter
  2022-03-14 14:42 ` Chuck Lever III
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2022-03-14 14:06 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs, kernel-janitors, Harshit Mogalapalli

This code checks the upper bound of "len" but it needs to check for
negative values as well.

Fixes: a51b5b737a0b ("NFSD: Update the NFSv2 WRITE argument decoder to use struct xdr_stream")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
From static analysis and I am not sure of the implications of this bug.

 fs/nfsd/nfsxdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index aba8520b4b8b..a9f80e30320e 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -336,7 +336,7 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 	/* opaque data */
 	if (xdr_stream_decode_u32(xdr, &args->len) < 0)
 		return false;
-	if (args->len > NFSSVC_MAXBLKSIZE_V2)
+	if (args->len < 0 || args->len > NFSSVC_MAXBLKSIZE_V2)
 		return false;
 	if (!xdr_stream_subsegment(xdr, &args->payload, args->len))
 		return false;
-- 
2.20.1


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-14 14:06 [PATCH] NFSD: check for negative "len" values in nfssvc_decode_writeargs() Dan Carpenter
2022-03-14 14:42 ` Chuck Lever III
2022-03-15  9:45   ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.