Message ID | 20191203004138.21223-1-tranmanphong@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: dvb: check return value digitv_ctrl_msg | expand |
Hello, On Tue, Dec 03, 2019 at 07:41:38AM +0700, Phong Tran wrote: > For fixing syzbot "KMSAN: uninit-value in digitv_rc_query" > > In scenario testing for syzbot, failure reading from > digitv_ctrl_msg() [1]. > > Eg: > [ 91.846657][ T3844] dvb-usb: bulk message failed: -22 (7/0) > > digitv_rc_query() always return 0. But in this case a wrong thing happens. > > Reported-by: syzbot+6bf9606ee955b646c0e1@syzkaller.appspotmail.com > Tested-by: syzbot+6bf9606ee955b646c0e1@syzkaller.appspotmail.com A fix for this was already merged I'm afraid, see commit eecc70d22ae5 ("media: digitv: don't continue if remote control state can't be read"). > [1]: https://syzkaller.appspot.com/text?tag=CrashLog&x=16860a63600000 > [2]: https://groups.google.com/d/msg/syzkaller-bugs/-TXIJAZ0J9Q/T4PEUQoeAQAJ > > Signed-off-by: Phong Tran <tranmanphong@gmail.com> > --- > drivers/media/usb/dvb-usb/digitv.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/usb/dvb-usb/digitv.c b/drivers/media/usb/dvb-usb/digitv.c > index dd5bb230cec1..61bc8945e6b9 100644 > --- a/drivers/media/usb/dvb-usb/digitv.c > +++ b/drivers/media/usb/dvb-usb/digitv.c > @@ -231,17 +231,21 @@ static struct rc_map_table rc_map_digitv_table[] = { > static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) > { > int i; > - u8 key[5]; > + u8 key[5] = { 0 }; The merged commit does not change this line. Why was this changed? Thanks Sean > u8 b[4] = { 0 }; > + int ret; > > *event = 0; > *state = REMOTE_NO_KEY_PRESSED; > > - digitv_ctrl_msg(d,USB_READ_REMOTE,0,NULL,0,&key[1],4); > - > + ret = digitv_ctrl_msg(d, USB_READ_REMOTE, 0, NULL, 0, &key[1], 4); > + if (ret < 0) > + return ret; > /* Tell the device we've read the remote. Not sure how necessary > this is, but the Nebula SDK does it. */ > - digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); > + ret = digitv_ctrl_msg(d, USB_WRITE_REMOTE, 0, b, 4, NULL, 0); > + if (ret < 0) > + return ret; > > /* if something is inside the buffer, simulate key press */ > if (key[1] != 0) > -- > 2.20.1
On Wed, Jan 15, 2020 at 05:32:26PM +0000, Sean Young wrote: > Hello, > > On Tue, Dec 03, 2019 at 07:41:38AM +0700, Phong Tran wrote: > > For fixing syzbot "KMSAN: uninit-value in digitv_rc_query" > > > > In scenario testing for syzbot, failure reading from > > digitv_ctrl_msg() [1]. > > > > Eg: > > [ 91.846657][ T3844] dvb-usb: bulk message failed: -22 (7/0) > > > > digitv_rc_query() always return 0. But in this case a wrong thing happens. > > > > Reported-by: syzbot+6bf9606ee955b646c0e1@syzkaller.appspotmail.com > > Tested-by: syzbot+6bf9606ee955b646c0e1@syzkaller.appspotmail.com > > A fix for this was already merged I'm afraid, see commit eecc70d22ae5 > ("media: digitv: don't continue if remote control state can't be read"). > > > [1]: https://syzkaller.appspot.com/text?tag=CrashLog&x=16860a63600000 > > [2]: https://groups.google.com/d/msg/syzkaller-bugs/-TXIJAZ0J9Q/T4PEUQoeAQAJ > > > > Signed-off-by: Phong Tran <tranmanphong@gmail.com> > > --- > > drivers/media/usb/dvb-usb/digitv.c | 12 ++++++++---- > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/media/usb/dvb-usb/digitv.c b/drivers/media/usb/dvb-usb/digitv.c > > index dd5bb230cec1..61bc8945e6b9 100644 > > --- a/drivers/media/usb/dvb-usb/digitv.c > > +++ b/drivers/media/usb/dvb-usb/digitv.c > > @@ -231,17 +231,21 @@ static struct rc_map_table rc_map_digitv_table[] = { > > static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) > > { > > int i; > > - u8 key[5]; > > + u8 key[5] = { 0 }; > > The merged commit does not change this line. Why was this changed? > It would fix the problem that key[0] is never initialized... But the correct fix is to make key 4 elements long and delete key[0]. regards, dan carpenter
On Wed, Jan 15, 2020 at 09:01:17PM +0300, Dan Carpenter wrote: > On Wed, Jan 15, 2020 at 05:32:26PM +0000, Sean Young wrote: > > Hello, > > > > On Tue, Dec 03, 2019 at 07:41:38AM +0700, Phong Tran wrote: > > > For fixing syzbot "KMSAN: uninit-value in digitv_rc_query" > > > > > > In scenario testing for syzbot, failure reading from > > > digitv_ctrl_msg() [1]. > > > > > > Eg: > > > [ 91.846657][ T3844] dvb-usb: bulk message failed: -22 (7/0) > > > > > > digitv_rc_query() always return 0. But in this case a wrong thing happens. > > > > > > Reported-by: syzbot+6bf9606ee955b646c0e1@syzkaller.appspotmail.com > > > Tested-by: syzbot+6bf9606ee955b646c0e1@syzkaller.appspotmail.com > > > > A fix for this was already merged I'm afraid, see commit eecc70d22ae5 > > ("media: digitv: don't continue if remote control state can't be read"). > > > > > [1]: https://syzkaller.appspot.com/text?tag=CrashLog&x=16860a63600000 > > > [2]: https://groups.google.com/d/msg/syzkaller-bugs/-TXIJAZ0J9Q/T4PEUQoeAQAJ > > > > > > Signed-off-by: Phong Tran <tranmanphong@gmail.com> > > > --- > > > drivers/media/usb/dvb-usb/digitv.c | 12 ++++++++---- > > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/media/usb/dvb-usb/digitv.c b/drivers/media/usb/dvb-usb/digitv.c > > > index dd5bb230cec1..61bc8945e6b9 100644 > > > --- a/drivers/media/usb/dvb-usb/digitv.c > > > +++ b/drivers/media/usb/dvb-usb/digitv.c > > > @@ -231,17 +231,21 @@ static struct rc_map_table rc_map_digitv_table[] = { > > > static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) > > > { > > > int i; > > > - u8 key[5]; > > > + u8 key[5] = { 0 }; > > > > The merged commit does not change this line. Why was this changed? > > > > It would fix the problem that key[0] is never initialized... But the > correct fix is to make key 4 elements long and delete key[0]. Phong, Presumably you can fix this? You will have to renumber key[1] to key[0] and key[2] to key[1] etc... Add a fixes tag. Fixes: 774c0de4aed4 ("V4L/DVB (4616): [PATCH] Nebula DigiTV USB RC support") Otherwise if you want I can send the patch. regards, dan carpenter
diff --git a/drivers/media/usb/dvb-usb/digitv.c b/drivers/media/usb/dvb-usb/digitv.c index dd5bb230cec1..61bc8945e6b9 100644 --- a/drivers/media/usb/dvb-usb/digitv.c +++ b/drivers/media/usb/dvb-usb/digitv.c @@ -231,17 +231,21 @@ static struct rc_map_table rc_map_digitv_table[] = { static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) { int i; - u8 key[5]; + u8 key[5] = { 0 }; u8 b[4] = { 0 }; + int ret; *event = 0; *state = REMOTE_NO_KEY_PRESSED; - digitv_ctrl_msg(d,USB_READ_REMOTE,0,NULL,0,&key[1],4); - + ret = digitv_ctrl_msg(d, USB_READ_REMOTE, 0, NULL, 0, &key[1], 4); + if (ret < 0) + return ret; /* Tell the device we've read the remote. Not sure how necessary this is, but the Nebula SDK does it. */ - digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); + ret = digitv_ctrl_msg(d, USB_WRITE_REMOTE, 0, b, 4, NULL, 0); + if (ret < 0) + return ret; /* if something is inside the buffer, simulate key press */ if (key[1] != 0)