LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* user pointer bugs
@ 2007-01-14 23:58 Suhabe Bugrara
  2007-01-15 16:56 ` Jan Engelhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Suhabe Bugrara @ 2007-01-14 23:58 UTC (permalink / raw)
  To: linux-kernel

Hello,

In linux-2.6.19.2, do the following lines have bugs in them? It looks
like they dereference a user pointer without first being checked by
the "access_ok" macro to ensure that they point into userspace.

Suhabe

========================
File: sound/isa/sscape.c
Lines: 550, 665
Description: The pointer "bb" is dereferenced in the expression
"bb->code" without being checked first.
Fix: Replace "bb->code" with "&bb->code"

========================
File: block/scsi_ioctl.c
Lines: 406, 427, 430, 482, 486
Description: The pointer "sic" is dereferenced in the expression
"sic->data" without being checked first.
Fix: Replace "sic->code" with "&sic->code"

========================
File: sound/pci/rme9652/hdsp.c
Line: 4589
Description: The pointer "mixer" is dereferenced in the expression
"mixer->data" without being checked first.
Fix: Replace "mixer->matrix" with "&mixer->matrix"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: user pointer bugs
  2007-01-14 23:58 user pointer bugs Suhabe Bugrara
@ 2007-01-15 16:56 ` Jan Engelhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Engelhardt @ 2007-01-15 16:56 UTC (permalink / raw)
  To: Suhabe Bugrara; +Cc: linux-kernel


On Jan 14 2007 15:58, Suhabe Bugrara wrote:
>
> In linux-2.6.19.2, do the following lines have bugs in them? It looks
> like they dereference a user pointer without first being checked by
> the "access_ok" macro to ensure that they point into userspace.
>
> Suhabe
>
> ========================
> File: sound/isa/sscape.c
> Lines: 550, 665
> Description: The pointer "bb" is dereferenced in the expression
> "bb->code" without being checked first.
> Fix: Replace "bb->code" with "&bb->code"

Looking at 2.6.20-rc5 now...

550: ret = upload_dma_data(sscape, bb->code, sizeof(bb->code));
665: if ( !access_ok(VERIFY_READ, bb->code, sizeof(bb->code)) )

Here's a test:

$ cat x.c
/*1*/ struct foo {
/*2*/     char bar[256];
/*3*/ };
/*4*/ int main(void) {
/*5*/     struct foo tmp;
/*6*/     char *x = tmp.bar;
/*7*/     char *y = &tmp.bar;
/*8*/     return 0;
/*9*/ }

$ cc x.c -Wall
x.c:7: warning: initialization from incompatible pointer type

Hence, &bb->code would be wrong. Really. (Talk to ##c or comp.lang.c
perhaps on details.)

>
> ========================
> File: block/scsi_ioctl.c
> Lines: 406, 427, 430, 482, 486
> Description: The pointer "sic" is dereferenced in the expression
> "sic->data" without being checked first.
> Fix: Replace "sic->code" with "&sic->code"

Same. sic->code decays into a char* when used.
This gets boring, I won't look at the others.


	-`J'
-- 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-01-15 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-14 23:58 user pointer bugs Suhabe Bugrara
2007-01-15 16:56 ` Jan Engelhardt

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).