Skip to contentSkip to conversation

user pointer bugs

DISCUSSION Suhabe Bugrara 2 participants 2 messages Jan 14, 2007 – Jan 15, 2007

lore
Share & tools
lore
#0 lore raw

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"

#1 lore raw
Quoted 5 lines · Suhabe Bugrara

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.

Quoted 8 lines

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

Quoted 7 lines

========================
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'