From: scameron@beardog.cce.hp.com
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: kernel-janitors@vger.kernel.org,
"James E.J. Bottomley" <JBottomley@parallels.com>,
iss_storagedev@hp.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, scameron@beardog.cce.hp.com
Subject: Re: [PATCH 6/10] hpsa: use safer test on the result of find_first_zero_bit
Date: Wed, 4 Jun 2014 10:14:10 -0500 [thread overview]
Message-ID: <20140604151410.GF6970@beardog.cce.hp.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1406041706050.2441@hadrien>
On Wed, Jun 04, 2014 at 05:06:44PM +0200, Julia Lawall wrote:
>
>
> On Wed, 4 Jun 2014, scameron@beardog.cce.hp.com wrote:
>
> > On Wed, Jun 04, 2014 at 11:07:56AM +0200, Julia Lawall wrote:
> > > From: Julia Lawall <Julia.Lawall@lip6.fr>
> > >
> > > Find_first_zero_bit considers BITS_PER_LONG bits at a time, and thus may
> > > return a larger number than the maximum position argument if that position
> > > is not a multiple of BITS_PER_LONG.
> > >
> > > The semantic match that finds this problem is as follows:
> > > (http://coccinelle.lip6.fr/)
> > >
> > > // <smpl>
> > > @@
> > > expression e1,e2,e3;
> > > statement S1,S2;
> > > @@
> > >
> > > e1 = find_first_zero_bit(e2,e3)
> > > ...
> > > if (e1
> > > - ==
> > > + >=
> > > e3)
> > > S1 else S2
> > > // </smpl>
> > >
> > > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> > >
> > > ---
> > > drivers/scsi/hpsa.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff -u -p a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> > > --- a/drivers/scsi/hpsa.c
> > > +++ b/drivers/scsi/hpsa.c
> > > @@ -4703,7 +4703,7 @@ static struct CommandList *cmd_alloc(str
> > > spin_lock_irqsave(&h->lock, flags);
> > > do {
> > > i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
> > > - if (i == h->nr_cmds) {
> > > + if (i >= h->nr_cmds) {
> > > spin_unlock_irqrestore(&h->lock, flags);
> > > return NULL;
> > > }
> >
> > Thanks, Ack.
> >
> > You can add
> >
> > Reviewed-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
> >
> > to this patch if you want.
> >
> > You might also consider adding "Cc: stable@vger.kernel.org" to the sign-off area.
>
> Actually, it seems that the function can never overshoot the specified
> limit. So the change is not needed.
Well, that would explain why nobody has complained about it in all these years.
I figured that must have been the case at least on x86, but I thought maybe
other archictectures might behave differently, and the change seemed harmless
in any case.
-- steve
next prev parent reply other threads:[~2014-06-04 15:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 9:07 [PATCH 0/10] use safer test on the result of find_first_zero_bit Julia Lawall
2014-06-04 9:07 ` [PATCH 6/10] hpsa: " Julia Lawall
2014-06-04 14:54 ` scameron
2014-06-04 15:06 ` Julia Lawall
2014-06-04 15:14 ` scameron [this message]
2014-06-04 9:35 ` [PATCH 0/10] " Geert Uytterhoeven
[not found] ` <CAMuHMdXsoFUXj4jLMWN6NY7Um19KwWO9Rhx=9=gqWu_K5Ev2kQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-06-04 9:38 ` Julia Lawall
2014-06-04 9:46 ` David Laight
2014-06-04 9:52 ` Julia Lawall
2014-06-04 10:55 ` Geert Uytterhoeven
2014-06-04 11:00 ` Julia Lawall
2014-06-04 11:07 ` Geert Uytterhoeven
2014-06-04 13:12 ` Julia Lawall
2014-06-04 13:34 ` David Laight
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=20140604151410.GF6970@beardog.cce.hp.com \
--to=scameron@beardog.cce.hp.com \
--cc=JBottomley@parallels.com \
--cc=iss_storagedev@hp.com \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).