* [PATCH v2] nfsd: prevent integer overflow in decode_cb_compound4res()
@ 2024-09-19 8:12 Dan Carpenter
2024-09-19 8:44 ` Jeff Layton
2024-09-19 14:02 ` Chuck Lever III
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-09-19 8:12 UTC (permalink / raw)
To: Chuck Lever
Cc: Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
linux-nfs, linux-kernel, kernel-janitors
If "length" is >= U32_MAX - 3 then the "length + 4" addition can result
in an integer overflow. The impact of this bug is not totally clear to
me, but it's safer to not allow the integer overflow.
Check that "length" is valid right away before doing any math.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
v2: Check that "len" is valid instead of just checking for integer
overflows.
fs/nfsd/nfs4callback.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 43b8320c8255..0f5b7b6fba74 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -317,6 +317,8 @@ static int decode_cb_compound4res(struct xdr_stream *xdr,
hdr->status = be32_to_cpup(p++);
/* Ignore the tag */
length = be32_to_cpup(p++);
+ if (unlikely(length > xdr->buf->len))
+ goto out_overflow;
p = xdr_inline_decode(xdr, length + 4);
if (unlikely(p == NULL))
goto out_overflow;
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] nfsd: prevent integer overflow in decode_cb_compound4res()
2024-09-19 8:12 [PATCH v2] nfsd: prevent integer overflow in decode_cb_compound4res() Dan Carpenter
@ 2024-09-19 8:44 ` Jeff Layton
2024-09-19 14:02 ` Chuck Lever III
1 sibling, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2024-09-19 8:44 UTC (permalink / raw)
To: Dan Carpenter, Chuck Lever
Cc: Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey, linux-nfs,
linux-kernel, kernel-janitors
On Thu, 2024-09-19 at 11:12 +0300, Dan Carpenter wrote:
> If "length" is >= U32_MAX - 3 then the "length + 4" addition can result
> in an integer overflow. The impact of this bug is not totally clear to
> me, but it's safer to not allow the integer overflow.
>
> Check that "length" is valid right away before doing any math.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> v2: Check that "len" is valid instead of just checking for integer
> overflows.
>
> fs/nfsd/nfs4callback.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> index 43b8320c8255..0f5b7b6fba74 100644
> --- a/fs/nfsd/nfs4callback.c
> +++ b/fs/nfsd/nfs4callback.c
> @@ -317,6 +317,8 @@ static int decode_cb_compound4res(struct xdr_stream *xdr,
> hdr->status = be32_to_cpup(p++);
> /* Ignore the tag */
> length = be32_to_cpup(p++);
> + if (unlikely(length > xdr->buf->len))
> + goto out_overflow;
> p = xdr_inline_decode(xdr, length + 4);
> if (unlikely(p == NULL))
> goto out_overflow;
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] nfsd: prevent integer overflow in decode_cb_compound4res()
2024-09-19 8:12 [PATCH v2] nfsd: prevent integer overflow in decode_cb_compound4res() Dan Carpenter
2024-09-19 8:44 ` Jeff Layton
@ 2024-09-19 14:02 ` Chuck Lever III
2024-09-20 11:10 ` Dan Carpenter
1 sibling, 1 reply; 4+ messages in thread
From: Chuck Lever III @ 2024-09-19 14:02 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Linux NFS Mailing List, Linux Kernel Mailing List,
kernel-janitors
> On Sep 19, 2024, at 1:12 AM, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> If "length" is >= U32_MAX - 3 then the "length + 4" addition can result
> in an integer overflow. The impact of this bug is not totally clear to
> me, but it's safer to not allow the integer overflow.
>
> Check that "length" is valid right away before doing any math.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> v2: Check that "len" is valid instead of just checking for integer
> overflows.
>
> fs/nfsd/nfs4callback.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> index 43b8320c8255..0f5b7b6fba74 100644
> --- a/fs/nfsd/nfs4callback.c
> +++ b/fs/nfsd/nfs4callback.c
> @@ -317,6 +317,8 @@ static int decode_cb_compound4res(struct xdr_stream *xdr,
> hdr->status = be32_to_cpup(p++);
> /* Ignore the tag */
> length = be32_to_cpup(p++);
> + if (unlikely(length > xdr->buf->len))
> + goto out_overflow;
> p = xdr_inline_decode(xdr, length + 4);
> if (unlikely(p == NULL))
> goto out_overflow;
> --
> 2.34.1
>
Hi Dan, I've already gone with
https://lore.kernel.org/linux-nfs/172658972371.2454.15715383792386404543.stgit@oracle-102.chuck.lever.oracle.com.nfsv4.dev/T/#u
Let me know if that doesn't make sense.
--
Chuck Lever
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] nfsd: prevent integer overflow in decode_cb_compound4res()
2024-09-19 14:02 ` Chuck Lever III
@ 2024-09-20 11:10 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-09-20 11:10 UTC (permalink / raw)
To: Chuck Lever III
Cc: Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Linux NFS Mailing List, Linux Kernel Mailing List,
kernel-janitors
On Thu, Sep 19, 2024 at 02:02:19PM +0000, Chuck Lever III wrote:
>
>
> > On Sep 19, 2024, at 1:12 AM, Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > If "length" is >= U32_MAX - 3 then the "length + 4" addition can result
> > in an integer overflow. The impact of this bug is not totally clear to
> > me, but it's safer to not allow the integer overflow.
> >
> > Check that "length" is valid right away before doing any math.
> >
> > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > v2: Check that "len" is valid instead of just checking for integer
> > overflows.
> >
> > fs/nfsd/nfs4callback.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> > index 43b8320c8255..0f5b7b6fba74 100644
> > --- a/fs/nfsd/nfs4callback.c
> > +++ b/fs/nfsd/nfs4callback.c
> > @@ -317,6 +317,8 @@ static int decode_cb_compound4res(struct xdr_stream *xdr,
> > hdr->status = be32_to_cpup(p++);
> > /* Ignore the tag */
> > length = be32_to_cpup(p++);
> > + if (unlikely(length > xdr->buf->len))
> > + goto out_overflow;
> > p = xdr_inline_decode(xdr, length + 4);
> > if (unlikely(p == NULL))
> > goto out_overflow;
> > --
> > 2.34.1
> >
>
> Hi Dan, I've already gone with
>
> https://lore.kernel.org/linux-nfs/172658972371.2454.15715383792386404543.stgit@oracle-102.chuck.lever.oracle.com.nfsv4.dev/T/#u
>
> Let me know if that doesn't make sense.
Oh, sorry, I got mixed up which things were patched. That looks good.
The truth is I always prefer when people give me a reported by tag so I
don't have to write a v2 patch. It just saves a back and forth.
Thanks!
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-20 11:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-19 8:12 [PATCH v2] nfsd: prevent integer overflow in decode_cb_compound4res() Dan Carpenter
2024-09-19 8:44 ` Jeff Layton
2024-09-19 14:02 ` Chuck Lever III
2024-09-20 11:10 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®