media: gspca: zero usb_buf on error
If reg_r() fails, then gspca_dev->usb_buf was left uninitialized, and some drivers used the contents of that buffer in logic. This caused several syzbot errors: https://syzkaller.appspot.com/bug?extid=397fd082ce5143e2f67d https://syzkaller.appspot.com/bug?extid=1a35278dd0ebfb3a038a https://syzkaller.appspot.com/bug?extid=06ddf1788cfd048c5e82 I analyzed the gspca drivers and zeroed the buffer where needed. Reported-and-tested-by: syzbot+1a35278dd0ebfb3a038a@syzkaller.appspotmail.com Reported-and-tested-by: syzbot+397fd082ce5143e2f67d@syzkaller.appspotmail.com Reported-and-tested-by: syzbot+06ddf1788cfd048c5e82@syzkaller.appspotmail.com Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
2509d725e0
commit
4843a543fa
@@ -2073,6 +2073,11 @@ static int reg_r(struct sd *sd, u16 index)
|
||||
} else {
|
||||
gspca_err(gspca_dev, "reg_r %02x failed %d\n", index, ret);
|
||||
sd->gspca_dev.usb_err = ret;
|
||||
/*
|
||||
* Make sure the result is zeroed to avoid uninitialized
|
||||
* values.
|
||||
*/
|
||||
gspca_dev->usb_buf[0] = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -2101,6 +2106,11 @@ static int reg_r8(struct sd *sd,
|
||||
} else {
|
||||
gspca_err(gspca_dev, "reg_r8 %02x failed %d\n", index, ret);
|
||||
sd->gspca_dev.usb_err = ret;
|
||||
/*
|
||||
* Make sure the buffer is zeroed to avoid uninitialized
|
||||
* values.
|
||||
*/
|
||||
memset(gspca_dev->usb_buf, 0, 8);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user