KMSAN: uninit-value in digitv_rc_query

15 views
Skip to first unread message

syzbot

unread,
Nov 8, 2019, 12:04:11ā€ÆPM11/8/19
to gli...@google.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 1e76a3e5 kmsan: replace __GFP_NO_KMSAN_SHADOW with kmsan_i..
git tree: https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=16860a63600000
kernel config: https://syzkaller.appspot.com/x/.config?x=f03c659d0830ab8d
dashboard link: https://syzkaller.appspot.com/bug?extid=6bf9606ee955b646c0e1
compiler: clang version 9.0.0 (/home/glider/llvm/clang
80fee25776c2fb61e74c1ecb1a523375c2500b69)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12c1101b600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15db3cfd600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+6bf960...@syzkaller.appspotmail.com

dvb-usb: schedule remote query interval to 1000 msecs.
dvb-usb: Nebula Electronics uDigiTV DVB-T USB2.0) successfully initialized
and connected.
dvb-usb: bulk message failed: -22 (7/0)
dvb-usb: bulk message failed: -22 (7/0)
dvb-usb: bulk message failed: -22 (7/-30591)
dvb-usb: bulk message failed: -22 (7/0)
=====================================================
BUG: KMSAN: uninit-value in legacy_dvb_usb_read_remote_control+0x106/0x790
drivers/media/usb/dvb-usb/dvb-usb-remote.c:123
CPU: 1 PID: 3844 Comm: kworker/1:2 Not tainted 5.3.0-rc7+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: events legacy_dvb_usb_read_remote_control
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x191/0x1f0 lib/dump_stack.c:113
kmsan_report+0x13a/0x2b0 mm/kmsan/kmsan_report.c:108
__msan_warning+0x73/0xe0 mm/kmsan/kmsan_instr.c:250
digitv_rc_query+0x76a/0x890 drivers/media/usb/dvb-usb/digitv.c:259
legacy_dvb_usb_read_remote_control+0x106/0x790
drivers/media/usb/dvb-usb/dvb-usb-remote.c:123
process_one_work+0x1572/0x1ef0 kernel/workqueue.c:2269
worker_thread+0x111b/0x2460 kernel/workqueue.c:2415
kthread+0x4b5/0x4f0 kernel/kthread.c:256
ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355

Local variable description: ----key@digitv_rc_query
Variable was created at:
digitv_rc_query+0x78/0x890 drivers/media/usb/dvb-usb/digitv.c:234
legacy_dvb_usb_read_remote_control+0x106/0x790
drivers/media/usb/dvb-usb/dvb-usb-remote.c:123
=====================================================
Kernel panic - not syncing: panic_on_warn set ...
CPU: 1 PID: 3844 Comm: kworker/1:2 Tainted: G B 5.3.0-rc7+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: events legacy_dvb_usb_read_remote_control
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x191/0x1f0 lib/dump_stack.c:113
panic+0x3c9/0xc1e kernel/panic.c:219
kmsan_report+0x2a2/0x2b0 mm/kmsan/kmsan_report.c:131
__msan_warning+0x73/0xe0 mm/kmsan/kmsan_instr.c:250
digitv_rc_query+0x76a/0x890 drivers/media/usb/dvb-usb/digitv.c:259
legacy_dvb_usb_read_remote_control+0x106/0x790
drivers/media/usb/dvb-usb/dvb-usb-remote.c:123
process_one_work+0x1572/0x1ef0 kernel/workqueue.c:2269
worker_thread+0x111b/0x2460 kernel/workqueue.c:2415
kthread+0x4b5/0x4f0 kernel/kthread.c:256
ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355
Kernel Offset: disabled
Rebooting in 86400 seconds..


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Nov 11, 2019, 12:59:01ā€ÆPM11/11/19
to hver...@xs4all.nl, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer still triggered
crash:
KMSAN: uninit-value in number

=====================================================
BUG: KMSAN: uninit-value in number+0x32e/0x1e40 lib/vsprintf.c:436
CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.4.0-rc5+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: usb_hub_wq hub_event
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x191/0x1f0 lib/dump_stack.c:113
kmsan_report+0x128/0x220 mm/kmsan/kmsan_report.c:108
__msan_warning+0x73/0xe0 mm/kmsan/kmsan_instr.c:245
number+0x32e/0x1e40 lib/vsprintf.c:436
vsnprintf+0x1e99/0x3210 lib/vsprintf.c:2576
vscnprintf+0xc2/0x180 lib/vsprintf.c:2613
vprintk_store+0xf2/0x11f0 kernel/printk/printk.c:1917
vprintk_emit+0x2c6/0x860 kernel/printk/printk.c:1984
vprintk_default+0x90/0xa0 kernel/printk/printk.c:2029
vprintk_func+0x635/0x810 kernel/printk/printk_safe.c:386
printk+0x180/0x1c3 kernel/printk/printk.c:2062
dvb_usb_generic_rw+0x8ec/0xea0 drivers/media/usb/dvb-usb/dvb-usb-urb.c:36
digitv_ctrl_msg drivers/media/usb/dvb-usb/digitv.c:47 [inline]
digitv_i2c_xfer+0x8d0/0xb70 drivers/media/usb/dvb-usb/digitv.c:68
__i2c_transfer+0xcde/0x2c90 drivers/i2c/i2c-core-base.c:1986
i2c_transfer+0x273/0x5c0 drivers/i2c/i2c-core-base.c:2047
mt352_read_register drivers/media/dvb-frontends/mt352.c:80 [inline]
mt352_attach+0x31d/0x600 drivers/media/dvb-frontends/mt352.c:544
digitv_frontend_attach+0x10e/0x630 drivers/media/usb/dvb-usb/digitv.c:144
dvb_usb_adapter_frontend_init+0x105/0xa00
drivers/media/usb/dvb-usb/dvb-usb-dvb.c:290
dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:84 [inline]
dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:173 [inline]
dvb_usb_device_init+0x2350/0x2e10
drivers/media/usb/dvb-usb/dvb-usb-init.c:287
digitv_probe+0xa1/0x480 drivers/media/usb/dvb-usb/digitv.c:271
usb_probe_interface+0xd19/0x1310 drivers/usb/core/driver.c:361
really_probe+0xd91/0x1f90 drivers/base/dd.c:552
driver_probe_device+0x1ba/0x510 drivers/base/dd.c:721
__device_attach_driver+0x5b8/0x790 drivers/base/dd.c:828
bus_for_each_drv+0x28e/0x3b0 drivers/base/bus.c:430
__device_attach+0x489/0x750 drivers/base/dd.c:894
device_initial_probe+0x4a/0x60 drivers/base/dd.c:941
bus_probe_device+0x131/0x390 drivers/base/bus.c:490
device_add+0x25b5/0x2df0 drivers/base/core.c:2202
usb_set_configuration+0x309f/0x3710 drivers/usb/core/message.c:2027
generic_probe+0xe7/0x280 drivers/usb/core/generic.c:210
usb_probe_device+0x146/0x200 drivers/usb/core/driver.c:266
really_probe+0xd91/0x1f90 drivers/base/dd.c:552
driver_probe_device+0x1ba/0x510 drivers/base/dd.c:721
__device_attach_driver+0x5b8/0x790 drivers/base/dd.c:828
bus_for_each_drv+0x28e/0x3b0 drivers/base/bus.c:430
__device_attach+0x489/0x750 drivers/base/dd.c:894
device_initial_probe+0x4a/0x60 drivers/base/dd.c:941
bus_probe_device+0x131/0x390 drivers/base/bus.c:490
device_add+0x25b5/0x2df0 drivers/base/core.c:2202
usb_new_device+0x23e5/0x2fb0 drivers/usb/core/hub.c:2536
hub_port_connect drivers/usb/core/hub.c:5098 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5213 [inline]
port_event drivers/usb/core/hub.c:5359 [inline]
hub_event+0x581d/0x72f0 drivers/usb/core/hub.c:5441
process_one_work+0x1572/0x1ef0 kernel/workqueue.c:2269
worker_thread+0x111b/0x2460 kernel/workqueue.c:2415
kthread+0x4b5/0x4f0 kernel/kthread.c:256
ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355

Local variable description: ----actlen@dvb_usb_generic_rw
Variable was created at:
dvb_usb_generic_rw+0xd3/0xea0 drivers/media/usb/dvb-usb/dvb-usb-urb.c:14
dvb_usb_generic_rw+0xd3/0xea0 drivers/media/usb/dvb-usb/dvb-usb-urb.c:14
=====================================================


Tested on:

commit: e741088f stackdepot: remove code preventing compiler optim..
console output: https://syzkaller.appspot.com/x/log.txt?x=1677bd52e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=9e324dfe9c7b0360
dashboard link: https://syzkaller.appspot.com/bug?extid=6bf9606ee955b646c0e1
compiler: clang version 9.0.0 (/home/glider/llvm/clang
80fee25776c2fb61e74c1ecb1a523375c2500b69)
patch: https://syzkaller.appspot.com/x/patch.diff?x=116a4a3ce00000

syzbot

unread,
Nov 12, 2019, 3:48:01ā€ÆAM11/12/19
to hver...@xs4all.nl, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger
crash:

Reported-and-tested-by:
syzbot+6bf960...@syzkaller.appspotmail.com

Tested on:

commit: e741088f stackdepot: remove code preventing compiler optim..
git tree: https://github.com/google/kmsan.git master
kernel config: https://syzkaller.appspot.com/x/.config?x=9e324dfe9c7b0360
dashboard link: https://syzkaller.appspot.com/bug?extid=6bf9606ee955b646c0e1
compiler: clang version 9.0.0 (/home/glider/llvm/clang
80fee25776c2fb61e74c1ecb1a523375c2500b69)
patch: https://syzkaller.appspot.com/x/patch.diff?x=12e4472ce00000

Note: testing is done by a robot and is best-effort only.

Phong Tran

unread,
Dec 2, 2019, 7:41:50ā€ÆPM12/2/19
to mch...@kernel.org, gre...@linuxfoundation.org, all...@lohutok.net, tg...@linutronix.de, syzbot+6bf960...@syzkaller.appspotmail.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, gli...@google.com, syzkall...@googlegroups.com, Phong Tran
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+6bf960...@syzkaller.appspotmail.com
Tested-by: syzbot+6bf960...@syzkaller.appspotmail.com

[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 <tranma...@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 };
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

Sean Young

unread,
Jan 15, 2020, 12:32:29ā€ÆPM1/15/20
to Phong Tran, mch...@kernel.org, gre...@linuxfoundation.org, all...@lohutok.net, tg...@linutronix.de, syzbot+6bf960...@syzkaller.appspotmail.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, gli...@google.com, syzkall...@googlegroups.com
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+6bf960...@syzkaller.appspotmail.com
> Tested-by: syzbot+6bf960...@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 <tranma...@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

Dan Carpenter

unread,
Jan 15, 2020, 1:02:53ā€ÆPM1/15/20
to Sean Young, Phong Tran, mch...@kernel.org, gre...@linuxfoundation.org, all...@lohutok.net, tg...@linutronix.de, syzbot+6bf960...@syzkaller.appspotmail.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, gli...@google.com, syzkall...@googlegroups.com
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

Dan Carpenter

unread,
Jan 15, 2020, 1:14:46ā€ÆPM1/15/20
to Sean Young, Phong Tran, mch...@kernel.org, gre...@linuxfoundation.org, all...@lohutok.net, tg...@linutronix.de, syzbot+6bf960...@syzkaller.appspotmail.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, gli...@google.com, syzkall...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages