From: Trond Myklebust <trondmy@hammerspace.com>
To: "dan.carpenter@oracle.com" <dan.carpenter@oracle.com>,
"chuck.lever@oracle.com" <chuck.lever@oracle.com>
Cc: "anna@kernel.org" <anna@kernel.org>,
"harshit.m.mogalapalli@oracle.com"
<harshit.m.mogalapalli@oracle.com>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] NFSD: prevent integer overflow on 32 bit systems
Date: Mon, 14 Mar 2022 19:25:32 +0000 [thread overview]
Message-ID: <a7ec2df0162554c5cb72a14f038819a695b780a1.camel@hammerspace.com> (raw)
In-Reply-To: <D5859D5C-229F-4377-98FE-314EE2C80721@oracle.com>
On Mon, 2022-03-14 at 18:05 +0000, Chuck Lever III wrote:
>
>
> > On Mar 14, 2022, at 1:03 PM, Dan Carpenter
> > <dan.carpenter@oracle.com> wrote:
> >
> > On Mon, Mar 14, 2022 at 05:45:59PM +0300, Chuck Lever III wrote:
> > > Hi Dan-
> > >
> > > > On Mar 14, 2022, at 10:09 AM, Dan Carpenter
> > > > <dan.carpenter@oracle.com> wrote:
> > > >
> > > > 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;
> > >
> > > IIUC xdr_inline_decode() returns NULL if the value of
> > > "len * sizeof(p)" is larger than the remaining XDR buffer
> > > size. I don't believe this extra check is necessary.
> > >
> >
> > Yes, but because of the integer overflow then "len * sizeof(*p))"
> > will
> > be a very reasonable small number.
>
> Got it.
Shouldn't we technically rather specify SIZE_MAX instead of ULONG_MAX
since xdr_inline_decode() takes a size_t?
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2022-03-14 19:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-03-14 19:57 ` kernel test robot
2022-03-15 15:40 ` Dan Carpenter
2022-03-15 15:40 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2022-03-15 7:35 kernel test robot
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=a7ec2df0162554c5cb72a14f038819a695b780a1.camel@hammerspace.com \
--to=trondmy@hammerspace.com \
--cc=anna@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=dan.carpenter@oracle.com \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
/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 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.