From: Dan Carpenter <dan.carpenter@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: Camylla Goncalves Cantanheide <c.cantanheide@gmail.com>,
gregkh@linuxfoundation.org, navid.emamdoost@gmail.com,
sylphrenadin@gmail.com, nishkadg.linux@gmail.com,
stephen@brennan.io, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org
Subject: Re: [PATCH 1/2] staging: rtl8192u: Refactoring setKey function
Date: Tue, 14 Apr 2020 21:32:18 +0300 [thread overview]
Message-ID: <20200414181812.GE14511@kadam> (raw)
In-Reply-To: <d3725a08531898adc1bfb1e6d875888c434b42d6.camel@perches.com>
On Tue, Apr 14, 2020 at 09:01:18AM -0700, Joe Perches wrote:
> On Tue, 2020-04-14 at 15:33 +0300, Dan Carpenter wrote:
> > On Mon, Apr 13, 2020 at 03:01:28AM +0000, Camylla Goncalves Cantanheide wrote:
> > > +
> > > + for (i = 2; i < CAM_CONTENT_COUNT; i++) {
> > > + write_nic_dword(dev, WCAMI, *keycontent++);
> >
> > This code was wrong in the original as well, but now that I see the bug
> > let's fix it. CAM_CONTENT_COUNT is 8. 8 - 2 = 6. We are writing 6
> > u32 variables to write_nic_dword(). But the *keycontent buffer only has
> > 4 u32 variables so it is a buffer overflow.
>
> Did you find the overflow with smatch?
No. Smatch isn't smart enough to understand that *(keycontent + i - 2)
is an array overflow. It thinks *(keycontent + i) is an array overflow
but the "- 2" confuses it. Also Smatch isn't smart enough to parse the
*keycontent++. It takes a shortcut when it parses loops.
To be honest, I just didn't like starting the loop from 2 and was trying
to see if there was a better define to use.
I agree that your solution of making the buffer larger is probably the
safest approach given that none of us really know the hardware.
regards,
dan carpenter
next prev parent reply other threads:[~2020-04-14 18:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-13 3:01 [PATCH 1/2] staging: rtl8192u: Refactoring setKey function Camylla Goncalves Cantanheide
2020-04-13 3:01 ` [PATCH 2/2] staging: rtl8192u: Renames variables in " Camylla Goncalves Cantanheide
2020-04-13 12:50 ` Greg KH
2020-04-13 12:50 ` [PATCH 1/2] staging: rtl8192u: Refactoring " Greg KH
2020-04-13 15:39 ` Joe Perches
2020-04-14 12:33 ` Dan Carpenter
2020-04-14 16:01 ` Joe Perches
2020-04-14 18:32 ` Dan Carpenter [this message]
[not found] ` <CAG3pEr+huVACoP7sTMALYfE46dc+D8DdGPF0ky6EShd4eXD9eg@mail.gmail.com>
2020-04-15 3:09 ` Joe Perches
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=20200414181812.GE14511@kadam \
--to=dan.carpenter@oracle.com \
--cc=c.cantanheide@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkcamp@lists.libreplanetbr.org \
--cc=navid.emamdoost@gmail.com \
--cc=nishkadg.linux@gmail.com \
--cc=stephen@brennan.io \
--cc=sylphrenadin@gmail.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