* [Patch] Off by one in drivers/usb/serial/usb-serial.c
@ 2006-06-21 21:28 Eric Sesterhenn
0 siblings, 0 replies; 6+ messages in thread
From: Eric Sesterhenn @ 2006-06-21 21:28 UTC (permalink / raw)
To: linux-kernel; +Cc: gregkh
hi,
this fixes coverity id #554. since serial table
is defines as serial_table[SERIAL_TTY_MINORS] we
should make sure we dont acess with an index
of SERIAL_TTY_MINORS.
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
--- linux-2.6.17-git2/drivers/usb/serial/usb-serial.c.orig 2006-06-21 23:24:07.000000000 +0200
+++ linux-2.6.17-git2/drivers/usb/serial/usb-serial.c 2006-06-21 23:25:12.000000000 +0200
@@ -83,7 +83,7 @@ static struct usb_serial *get_free_seria
good_spot = 1;
for (j = 1; j <= num_ports-1; ++j)
- if ((i+j >= SERIAL_TTY_MINORS) || (serial_table[i+j])) {
+ if ((i+j >= SERIAL_TTY_MINORS-1)||(serial_table[i+j])) {
good_spot = 0;
i += j;
break;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Off by one in drivers/usb/serial/usb-serial.c
2006-06-26 19:10 ` Greg KH
@ 2006-06-26 19:30 ` Eric Sesterhenn / Snakebyte
0 siblings, 0 replies; 6+ messages in thread
From: Eric Sesterhenn / Snakebyte @ 2006-06-26 19:30 UTC (permalink / raw)
To: Greg KH; +Cc: Eric Sesterhenn / Snakebyte, Mikael Pettersson, linux-kernel
> So, what does this mean? That coverity is broken, yet again?
right, it means that this was a false report.
> I'm getting very tired of these false positives from them, it is getting
> so that I can't trust the output of the tool at all :(
you shouldnt trust it anyways. At the moment ~11% of the
stuff we checked is marked as bug, ~24% as false or ignore,
5% pending, 4% resolved and 54% uninspected. If we count
pending and resolved to the bugs, that would mean a 50/50
split between bugs and false positives. So we should not trust
it blind and i try my best to avoid such mistakes.
But I wouldnt say coverity is that bad, and it already helped
us fixing several bugs.
Greetings, Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Off by one in drivers/usb/serial/usb-serial.c
2006-06-25 22:59 ` Eric Sesterhenn / Snakebyte
@ 2006-06-26 19:10 ` Greg KH
2006-06-26 19:30 ` Eric Sesterhenn / Snakebyte
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2006-06-26 19:10 UTC (permalink / raw)
To: Eric Sesterhenn / Snakebyte; +Cc: Mikael Pettersson, linux-kernel
On Mon, Jun 26, 2006 at 12:59:21AM +0200, Eric Sesterhenn / Snakebyte wrote:
> * Mikael Pettersson (mikpe@it.uu.se) wrote:
> > On Wed, 21 Jun 2006 23:28:17 +0200, Eric Sesterhenn wrote:
> > > this fixes coverity id #554. since serial table
> > > is defines as serial_table[SERIAL_TTY_MINORS] we
> > > should make sure we dont acess with an index
> > > of SERIAL_TTY_MINORS.
> > >
> > > Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> > >
> > > --- linux-2.6.17-git2/drivers/usb/serial/usb-serial.c.orig 2006-06-21 23:24:07.000000000 +0200
> > > +++ linux-2.6.17-git2/drivers/usb/serial/usb-serial.c 2006-06-21 23:25:12.000000000 +0200
> > > @@ -83,7 +83,7 @@ static struct usb_serial *get_free_seria
> > >
> > > good_spot = 1;
> > > for (j = 1; j <= num_ports-1; ++j)
> > > - if ((i+j >= SERIAL_TTY_MINORS) || (serial_table[i+j])) {
> > > + if ((i+j >= SERIAL_TTY_MINORS-1)||(serial_table[i+j])) {
> > > good_spot = 0;
> > > i += j;
> > > break;
> >
> > Where is the access coverity complained about? If it's the serial_table[i+j]
> > quoted above, then the original code is OK since i+j < SERIAL_TTY_MINORS is
> > an invariant in that subexpression.
> >
> > And the other accesses to serial_table[] in get_free_serial() are also only
> > done when the index is < SERIAL_TTY_MINORS.
>
> guess i was too quick on that one, sorry. Here is the coverity
> report for completeness.
>
> Event assignment: Assigning "1" to "j"
> Also see events: [overrun-local]
> At conditional (11): "j <= (num_ports - 1)" taking true path
> At conditional (16): "j <= (num_ports - 1)" taking true path
>
> 85 for (j = 1; j <= num_ports-1; ++j)
>
> Event overrun-local: Overrun of static array "serial_table" of size 255
> at position 255 with index variable "(i + j)"
> Also see events: [assignment]
> At conditional (12): "(i + j) >= 255" taking true path
> At conditional (17): "(i + j) >= 255" taking false path
>
> 86 if ((i+j >= SERIAL_TTY_MINORS) ||
> (serial_table[i+j])) {
> 87 good_spot = 0;
> 88 i += j;
> 89 break;
> 90 }
So, what does this mean? That coverity is broken, yet again?
I'm getting very tired of these false positives from them, it is getting
so that I can't trust the output of the tool at all :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Off by one in drivers/usb/serial/usb-serial.c
2006-06-22 13:31 Mikael Pettersson
2006-06-22 14:28 ` Eric Sesterhenn / Snakebyte
@ 2006-06-25 22:59 ` Eric Sesterhenn / Snakebyte
2006-06-26 19:10 ` Greg KH
1 sibling, 1 reply; 6+ messages in thread
From: Eric Sesterhenn / Snakebyte @ 2006-06-25 22:59 UTC (permalink / raw)
To: Mikael Pettersson; +Cc: linux-kernel, snakebyte, gregkh
* Mikael Pettersson (mikpe@it.uu.se) wrote:
> On Wed, 21 Jun 2006 23:28:17 +0200, Eric Sesterhenn wrote:
> > this fixes coverity id #554. since serial table
> > is defines as serial_table[SERIAL_TTY_MINORS] we
> > should make sure we dont acess with an index
> > of SERIAL_TTY_MINORS.
> >
> > Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> >
> > --- linux-2.6.17-git2/drivers/usb/serial/usb-serial.c.orig 2006-06-21 23:24:07.000000000 +0200
> > +++ linux-2.6.17-git2/drivers/usb/serial/usb-serial.c 2006-06-21 23:25:12.000000000 +0200
> > @@ -83,7 +83,7 @@ static struct usb_serial *get_free_seria
> >
> > good_spot = 1;
> > for (j = 1; j <= num_ports-1; ++j)
> > - if ((i+j >= SERIAL_TTY_MINORS) || (serial_table[i+j])) {
> > + if ((i+j >= SERIAL_TTY_MINORS-1)||(serial_table[i+j])) {
> > good_spot = 0;
> > i += j;
> > break;
>
> Where is the access coverity complained about? If it's the serial_table[i+j]
> quoted above, then the original code is OK since i+j < SERIAL_TTY_MINORS is
> an invariant in that subexpression.
>
> And the other accesses to serial_table[] in get_free_serial() are also only
> done when the index is < SERIAL_TTY_MINORS.
guess i was too quick on that one, sorry. Here is the coverity
report for completeness.
Event assignment: Assigning "1" to "j"
Also see events: [overrun-local]
At conditional (11): "j <= (num_ports - 1)" taking true path
At conditional (16): "j <= (num_ports - 1)" taking true path
85 for (j = 1; j <= num_ports-1; ++j)
Event overrun-local: Overrun of static array "serial_table" of size 255
at position 255 with index variable "(i + j)"
Also see events: [assignment]
At conditional (12): "(i + j) >= 255" taking true path
At conditional (17): "(i + j) >= 255" taking false path
86 if ((i+j >= SERIAL_TTY_MINORS) ||
(serial_table[i+j])) {
87 good_spot = 0;
88 i += j;
89 break;
90 }
greetings, Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Off by one in drivers/usb/serial/usb-serial.c
2006-06-22 13:31 Mikael Pettersson
@ 2006-06-22 14:28 ` Eric Sesterhenn / Snakebyte
2006-06-25 22:59 ` Eric Sesterhenn / Snakebyte
1 sibling, 0 replies; 6+ messages in thread
From: Eric Sesterhenn / Snakebyte @ 2006-06-22 14:28 UTC (permalink / raw)
To: Mikael Pettersson; +Cc: linux-kernel, snakebyte, gregkh
* Mikael Pettersson (mikpe@it.uu.se) wrote:
> On Wed, 21 Jun 2006 23:28:17 +0200, Eric Sesterhenn wrote:
> > this fixes coverity id #554. since serial table
> > is defines as serial_table[SERIAL_TTY_MINORS] we
> > should make sure we dont acess with an index
> > of SERIAL_TTY_MINORS.
> >
> > Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> >
> > --- linux-2.6.17-git2/drivers/usb/serial/usb-serial.c.orig 2006-06-21 23:24:07.000000000 +0200
> > +++ linux-2.6.17-git2/drivers/usb/serial/usb-serial.c 2006-06-21 23:25:12.000000000 +0200
> > @@ -83,7 +83,7 @@ static struct usb_serial *get_free_seria
> >
> > good_spot = 1;
> > for (j = 1; j <= num_ports-1; ++j)
> > - if ((i+j >= SERIAL_TTY_MINORS) || (serial_table[i+j])) {
> > + if ((i+j >= SERIAL_TTY_MINORS-1)||(serial_table[i+j])) {
> > good_spot = 0;
> > i += j;
> > break;
>
> Where is the access coverity complained about? If it's the serial_table[i+j]
> quoted above, then the original code is OK since i+j < SERIAL_TTY_MINORS is
> an invariant in that subexpression.
>
> And the other accesses to serial_table[] in get_free_serial() are also only
> done when the index is < SERIAL_TTY_MINORS.
I'll check that again on sunday, when i am back home.
Greetings, Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Off by one in drivers/usb/serial/usb-serial.c
@ 2006-06-22 13:31 Mikael Pettersson
2006-06-22 14:28 ` Eric Sesterhenn / Snakebyte
2006-06-25 22:59 ` Eric Sesterhenn / Snakebyte
0 siblings, 2 replies; 6+ messages in thread
From: Mikael Pettersson @ 2006-06-22 13:31 UTC (permalink / raw)
To: linux-kernel, snakebyte; +Cc: gregkh
On Wed, 21 Jun 2006 23:28:17 +0200, Eric Sesterhenn wrote:
> this fixes coverity id #554. since serial table
> is defines as serial_table[SERIAL_TTY_MINORS] we
> should make sure we dont acess with an index
> of SERIAL_TTY_MINORS.
>
> Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
>
> --- linux-2.6.17-git2/drivers/usb/serial/usb-serial.c.orig 2006-06-21 23:24:07.000000000 +0200
> +++ linux-2.6.17-git2/drivers/usb/serial/usb-serial.c 2006-06-21 23:25:12.000000000 +0200
> @@ -83,7 +83,7 @@ static struct usb_serial *get_free_seria
>
> good_spot = 1;
> for (j = 1; j <= num_ports-1; ++j)
> - if ((i+j >= SERIAL_TTY_MINORS) || (serial_table[i+j])) {
> + if ((i+j >= SERIAL_TTY_MINORS-1)||(serial_table[i+j])) {
> good_spot = 0;
> i += j;
> break;
Where is the access coverity complained about? If it's the serial_table[i+j]
quoted above, then the original code is OK since i+j < SERIAL_TTY_MINORS is
an invariant in that subexpression.
And the other accesses to serial_table[] in get_free_serial() are also only
done when the index is < SERIAL_TTY_MINORS.
/Mikael
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-06-26 19:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-21 21:28 [Patch] Off by one in drivers/usb/serial/usb-serial.c Eric Sesterhenn
2006-06-22 13:31 Mikael Pettersson
2006-06-22 14:28 ` Eric Sesterhenn / Snakebyte
2006-06-25 22:59 ` Eric Sesterhenn / Snakebyte
2006-06-26 19:10 ` Greg KH
2006-06-26 19:30 ` Eric Sesterhenn / Snakebyte
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).