Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* WARNING in kmem_cache_alloc_trace
@ 2019-08-19 16:18 syzbot
  2019-08-19 16:59 ` Andrey Konovalov
  0 siblings, 1 reply; 9+ messages in thread
From: syzbot @ 2019-08-19 16:18 UTC (permalink / raw)
  To: andreyknvl, balbi, chunfeng.yun, gregkh, linux-kernel, linux-usb,
	stern, syzkaller-bugs

Hello,

syzbot found the following crash on:

HEAD commit:    d0847550 usb-fuzzer: main usb gadget fuzzer driver
git tree:       https://github.com/google/kasan.git usb-fuzzer
console output: https://syzkaller.appspot.com/x/log.txt?x=16947fce600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
dashboard link: https://syzkaller.appspot.com/bug?extid=0e7b6b6001ca8ed655f6
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1141c5ba600000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11ed91d2600000

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

------------[ cut here ]------------
do not call blocking ops when !TASK_RUNNING; state=1 set at  
[<000000000453b57c>] prepare_to_wait+0xb1/0x2b0 kernel/sched/wait.c:230
WARNING: CPU: 0 PID: 1720 at kernel/sched/core.c:6551  
__might_sleep+0x135/0x190 kernel/sched/core.c:6551
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 1720 Comm: syz-executor552 Not tainted 5.3.0-rc4+ #26
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0xca/0x13e lib/dump_stack.c:113
  panic+0x2a3/0x6da kernel/panic.c:219
  __warn.cold+0x20/0x4a kernel/panic.c:576
  report_bug+0x262/0x2a0 lib/bug.c:186
  fixup_bug arch/x86/kernel/traps.c:179 [inline]
  fixup_bug arch/x86/kernel/traps.c:174 [inline]
  do_error_trap+0x12b/0x1e0 arch/x86/kernel/traps.c:272
  do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:291
  invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1028
RIP: 0010:__might_sleep+0x135/0x190 kernel/sched/core.c:6551
Code: 65 48 8b 1c 25 00 ef 01 00 48 8d 7b 10 48 89 fe 48 c1 ee 03 80 3c 06  
00 75 2b 48 8b 73 10 48 c7 c7 e0 55 c6 85 e8 30 21 f6 ff <0f> 0b e9 46 ff  
ff ff e8 ef ee 46 00 e9 29 ff ff ff e8 e5 ee 46 00
RSP: 0018:ffff8881c7df7a30 EFLAGS: 00010282
RAX: 0000000000000000 RBX: ffff8881d4a49800 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff81288cfd RDI: ffffed1038fbef38
RBP: ffffffff86a6a5d1 R08: ffff8881d4a49800 R09: fffffbfff11ad3a1
R10: fffffbfff11ad3a0 R11: ffffffff88d69d07 R12: 00000000000001f5
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000cc0
  slab_pre_alloc_hook mm/slab.h:501 [inline]
  slab_alloc_node mm/slub.c:2690 [inline]
  slab_alloc mm/slub.c:2778 [inline]
  kmem_cache_alloc_trace+0x233/0x2f0 mm/slub.c:2795
  kmalloc include/linux/slab.h:552 [inline]
  dummy_urb_enqueue+0x7c/0x890 drivers/usb/gadget/udc/dummy_hcd.c:1249
  usb_hcd_submit_urb+0x2aa/0x1ee0 drivers/usb/core/hcd.c:1555
  usb_submit_urb+0x6e5/0x13b0 drivers/usb/core/urb.c:569
  yurex_write+0x3b2/0x710 drivers/usb/misc/yurex.c:491
  __vfs_write+0x76/0x100 fs/read_write.c:494
  vfs_write+0x262/0x5c0 fs/read_write.c:558
  ksys_write+0x127/0x250 fs/read_write.c:611
  do_syscall_64+0xb7/0x580 arch/x86/entry/common.c:296
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440749
Code: e8 bc af 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffccb32e308 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440749
RDX: 000000000000008d RSI: 0000000020000040 RDI: 0000000000000004
RBP: 00000000006cb018 R08: 000000000000000f R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000401fd0
R13: 0000000000402060 R14: 0000000000000000 R15: 0000000000000000
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 syzkaller@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

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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-19 16:18 WARNING in kmem_cache_alloc_trace syzbot
@ 2019-08-19 16:59 ` Andrey Konovalov
  2019-08-19 20:01   ` Alan Stern
                     ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Andrey Konovalov @ 2019-08-19 16:59 UTC (permalink / raw)
  To: syzbot
  Cc: Felipe Balbi, chunfeng.yun, Greg Kroah-Hartman, LKML, USB list,
	Alan Stern, syzkaller-bugs

On Mon, Aug 19, 2019 at 6:18 PM syzbot
<syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit:    d0847550 usb-fuzzer: main usb gadget fuzzer driver
> git tree:       https://github.com/google/kasan.git usb-fuzzer
> console output: https://syzkaller.appspot.com/x/log.txt?x=16947fce600000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
> dashboard link: https://syzkaller.appspot.com/bug?extid=0e7b6b6001ca8ed655f6
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1141c5ba600000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11ed91d2600000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com
>
> ------------[ cut here ]------------
> do not call blocking ops when !TASK_RUNNING; state=1 set at
> [<000000000453b57c>] prepare_to_wait+0xb1/0x2b0 kernel/sched/wait.c:230
> WARNING: CPU: 0 PID: 1720 at kernel/sched/core.c:6551
> __might_sleep+0x135/0x190 kernel/sched/core.c:6551
> Kernel panic - not syncing: panic_on_warn set ...
> CPU: 0 PID: 1720 Comm: syz-executor552 Not tainted 5.3.0-rc4+ #26
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> Call Trace:
>   __dump_stack lib/dump_stack.c:77 [inline]
>   dump_stack+0xca/0x13e lib/dump_stack.c:113
>   panic+0x2a3/0x6da kernel/panic.c:219
>   __warn.cold+0x20/0x4a kernel/panic.c:576
>   report_bug+0x262/0x2a0 lib/bug.c:186
>   fixup_bug arch/x86/kernel/traps.c:179 [inline]
>   fixup_bug arch/x86/kernel/traps.c:174 [inline]
>   do_error_trap+0x12b/0x1e0 arch/x86/kernel/traps.c:272
>   do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:291
>   invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1028
> RIP: 0010:__might_sleep+0x135/0x190 kernel/sched/core.c:6551
> Code: 65 48 8b 1c 25 00 ef 01 00 48 8d 7b 10 48 89 fe 48 c1 ee 03 80 3c 06
> 00 75 2b 48 8b 73 10 48 c7 c7 e0 55 c6 85 e8 30 21 f6 ff <0f> 0b e9 46 ff
> ff ff e8 ef ee 46 00 e9 29 ff ff ff e8 e5 ee 46 00
> RSP: 0018:ffff8881c7df7a30 EFLAGS: 00010282
> RAX: 0000000000000000 RBX: ffff8881d4a49800 RCX: 0000000000000000
> RDX: 0000000000000000 RSI: ffffffff81288cfd RDI: ffffed1038fbef38
> RBP: ffffffff86a6a5d1 R08: ffff8881d4a49800 R09: fffffbfff11ad3a1
> R10: fffffbfff11ad3a0 R11: ffffffff88d69d07 R12: 00000000000001f5
> R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000cc0
>   slab_pre_alloc_hook mm/slab.h:501 [inline]
>   slab_alloc_node mm/slub.c:2690 [inline]
>   slab_alloc mm/slub.c:2778 [inline]
>   kmem_cache_alloc_trace+0x233/0x2f0 mm/slub.c:2795
>   kmalloc include/linux/slab.h:552 [inline]
>   dummy_urb_enqueue+0x7c/0x890 drivers/usb/gadget/udc/dummy_hcd.c:1249
>   usb_hcd_submit_urb+0x2aa/0x1ee0 drivers/usb/core/hcd.c:1555
>   usb_submit_urb+0x6e5/0x13b0 drivers/usb/core/urb.c:569
>   yurex_write+0x3b2/0x710 drivers/usb/misc/yurex.c:491
>   __vfs_write+0x76/0x100 fs/read_write.c:494
>   vfs_write+0x262/0x5c0 fs/read_write.c:558
>   ksys_write+0x127/0x250 fs/read_write.c:611
>   do_syscall_64+0xb7/0x580 arch/x86/entry/common.c:296
>   entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x440749
> Code: e8 bc af 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7
> 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
> ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007ffccb32e308 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
> RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440749
> RDX: 000000000000008d RSI: 0000000020000040 RDI: 0000000000000004
> RBP: 00000000006cb018 R08: 000000000000000f R09: 00000000004002c8
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000401fd0
> R13: 0000000000402060 R14: 0000000000000000 R15: 0000000000000000
> 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 syzkaller@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

Looks like an issue in the yurex driver, despite a generic report title.

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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-19 16:59 ` Andrey Konovalov
@ 2019-08-19 20:01   ` Alan Stern
  2019-08-19 20:20     ` syzbot
  2019-08-20 13:07   ` Oliver Neukum
  2019-08-20 13:24   ` Oliver Neukum
  2 siblings, 1 reply; 9+ messages in thread
From: Alan Stern @ 2019-08-19 20:01 UTC (permalink / raw)
  To: Andrey Konovalov
  Cc: syzbot, Felipe Balbi, chunfeng.yun, Greg Kroah-Hartman, LKML,
	USB list, syzkaller-bugs

On Mon, 19 Aug 2019, Andrey Konovalov wrote:

> On Mon, Aug 19, 2019 at 6:18 PM syzbot
> <syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com> wrote:
> >
> > Hello,
> >
> > syzbot found the following crash on:
> >
> > HEAD commit:    d0847550 usb-fuzzer: main usb gadget fuzzer driver
> > git tree:       https://github.com/google/kasan.git usb-fuzzer
> > console output: https://syzkaller.appspot.com/x/log.txt?x=16947fce600000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
> > dashboard link: https://syzkaller.appspot.com/bug?extid=0e7b6b6001ca8ed655f6
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1141c5ba600000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11ed91d2600000
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com
> >
> > ------------[ cut here ]------------
> > do not call blocking ops when !TASK_RUNNING; state=1 set at
> > [<000000000453b57c>] prepare_to_wait+0xb1/0x2b0 kernel/sched/wait.c:230
> > WARNING: CPU: 0 PID: 1720 at kernel/sched/core.c:6551
> > __might_sleep+0x135/0x190 kernel/sched/core.c:6551
> > Kernel panic - not syncing: panic_on_warn set ...
> > CPU: 0 PID: 1720 Comm: syz-executor552 Not tainted 5.3.0-rc4+ #26
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > Call Trace:
> >   __dump_stack lib/dump_stack.c:77 [inline]
> >   dump_stack+0xca/0x13e lib/dump_stack.c:113
> >   panic+0x2a3/0x6da kernel/panic.c:219
> >   __warn.cold+0x20/0x4a kernel/panic.c:576
> >   report_bug+0x262/0x2a0 lib/bug.c:186
> >   fixup_bug arch/x86/kernel/traps.c:179 [inline]
> >   fixup_bug arch/x86/kernel/traps.c:174 [inline]
> >   do_error_trap+0x12b/0x1e0 arch/x86/kernel/traps.c:272
> >   do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:291
> >   invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1028
> > RIP: 0010:__might_sleep+0x135/0x190 kernel/sched/core.c:6551
> > Code: 65 48 8b 1c 25 00 ef 01 00 48 8d 7b 10 48 89 fe 48 c1 ee 03 80 3c 06
> > 00 75 2b 48 8b 73 10 48 c7 c7 e0 55 c6 85 e8 30 21 f6 ff <0f> 0b e9 46 ff
> > ff ff e8 ef ee 46 00 e9 29 ff ff ff e8 e5 ee 46 00
> > RSP: 0018:ffff8881c7df7a30 EFLAGS: 00010282
> > RAX: 0000000000000000 RBX: ffff8881d4a49800 RCX: 0000000000000000
> > RDX: 0000000000000000 RSI: ffffffff81288cfd RDI: ffffed1038fbef38
> > RBP: ffffffff86a6a5d1 R08: ffff8881d4a49800 R09: fffffbfff11ad3a1
> > R10: fffffbfff11ad3a0 R11: ffffffff88d69d07 R12: 00000000000001f5
> > R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000cc0
> >   slab_pre_alloc_hook mm/slab.h:501 [inline]
> >   slab_alloc_node mm/slub.c:2690 [inline]
> >   slab_alloc mm/slub.c:2778 [inline]
> >   kmem_cache_alloc_trace+0x233/0x2f0 mm/slub.c:2795
> >   kmalloc include/linux/slab.h:552 [inline]
> >   dummy_urb_enqueue+0x7c/0x890 drivers/usb/gadget/udc/dummy_hcd.c:1249
> >   usb_hcd_submit_urb+0x2aa/0x1ee0 drivers/usb/core/hcd.c:1555
> >   usb_submit_urb+0x6e5/0x13b0 drivers/usb/core/urb.c:569
> >   yurex_write+0x3b2/0x710 drivers/usb/misc/yurex.c:491
> >   __vfs_write+0x76/0x100 fs/read_write.c:494
> >   vfs_write+0x262/0x5c0 fs/read_write.c:558

> Looks like an issue in the yurex driver, despite a generic report title.

Indeed.  The code for waiting on the completion of an URB is very out 
of date.

Alan Stern

#syz test: https://github.com/google/kasan.git d0847550

Index: usb-devel/drivers/usb/misc/yurex.c
===================================================================
--- usb-devel.orig/drivers/usb/misc/yurex.c
+++ usb-devel/drivers/usb/misc/yurex.c
@@ -62,6 +62,7 @@ struct usb_yurex {
 	struct mutex		io_mutex;
 	struct fasync_struct	*async_queue;
 	wait_queue_head_t	waitq;
+	int			command_finished;
 
 	spinlock_t		lock;
 	__s64			bbu;		/* BBU from device */
@@ -80,6 +81,7 @@ static void yurex_control_callback(struc
 	if (status) {
 		dev_err(&urb->dev->dev, "%s - control failed: %d\n",
 			__func__, status);
+		dev->command_finished = 1;
 		wake_up_interruptible(&dev->waitq);
 		return;
 	}
@@ -173,6 +175,7 @@ static void yurex_interrupt(struct urb *
 	case CMD_ACK:
 		dev_dbg(&dev->interface->dev, "%s ack: %c\n",
 			__func__, buf[1]);
+		dev->command_finished = 1;
 		wake_up_interruptible(&dev->waitq);
 		break;
 	}
@@ -321,6 +324,7 @@ static void yurex_disconnect(struct usb_
 
 	/* wakeup waiters */
 	kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
+	dev->command_finished = 1;
 	wake_up_interruptible(&dev->waitq);
 
 	/* decrement our usage count */
@@ -428,8 +432,7 @@ static ssize_t yurex_write(struct file *
 	char buffer[16 + 1];
 	char *data = buffer;
 	unsigned long long c, c2 = 0;
-	signed long timeout = 0;
-	DEFINE_WAIT(wait);
+	signed long time_remaining = 0;
 
 	count = min(sizeof(buffer) - 1, count);
 	dev = file->private_data;
@@ -485,14 +488,16 @@ static ssize_t yurex_write(struct file *
 	}
 
 	/* send the data as the control msg */
-	prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
 	dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,
 		dev->cntl_buffer[0]);
 	retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
-	if (retval >= 0)
-		timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
-	finish_wait(&dev->waitq, &wait);
-
+	if (retval >= 0) {
+		dev->command_finished = 0;
+		time_remaining = wait_event_interruptible_timeout(dev->waitq,
+				dev->command_finished, YUREX_WRITE_TIMEOUT);
+		if (time_remaining < 0)
+			retval = -EINTR;
+	}
 	mutex_unlock(&dev->io_mutex);
 
 	if (retval < 0) {
@@ -501,9 +506,9 @@ static ssize_t yurex_write(struct file *
 			__func__, retval);
 		goto error;
 	}
-	if (set && timeout)
+	if (set && time_remaining)
 		dev->bbu = c2;
-	return timeout ? count : -EIO;
+	return time_remaining ? count : -EIO;
 
 error:
 	return retval;


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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-19 20:01   ` Alan Stern
@ 2019-08-19 20:20     ` syzbot
  0 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2019-08-19 20:20 UTC (permalink / raw)
  To: andreyknvl, balbi, chunfeng.yun, gregkh, linux-kernel, linux-usb,
	stern, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer still triggered  
crash:
WARNING in yurex_write/usb_submit_urb

------------[ cut here ]------------
URB 00000000c866c77d submitted while active
WARNING: CPU: 1 PID: 2816 at drivers/usb/core/urb.c:362  
usb_submit_urb+0x10c1/0x13b0 drivers/usb/core/urb.c:362
Kernel panic - not syncing: panic_on_warn set ...
CPU: 1 PID: 2816 Comm: syz-executor.4 Not tainted 5.3.0-rc4+ #1
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0xca/0x13e lib/dump_stack.c:113
  panic+0x2a3/0x6da kernel/panic.c:219
  __warn.cold+0x20/0x4a kernel/panic.c:576
  report_bug+0x262/0x2a0 lib/bug.c:186
  fixup_bug arch/x86/kernel/traps.c:179 [inline]
  fixup_bug arch/x86/kernel/traps.c:174 [inline]
  do_error_trap+0x12b/0x1e0 arch/x86/kernel/traps.c:272
  do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:291
  invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1028
RIP: 0010:usb_submit_urb+0x10c1/0x13b0 drivers/usb/core/urb.c:362
Code: 89 de e8 62 b7 ef fd 84 db 0f 85 42 f6 ff ff e8 25 b6 ef fd 4c 89 fe  
48 c7 c7 c0 67 18 86 c6 05 07 29 3a 04 01 e8 14 9b c5 fd <0f> 0b e9 20 f6  
ff ff c7 44 24 14 01 00 00 00 e9 d7 f6 ff ff 41 bd
RSP: 0018:ffff8881c6f3fc48 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff81288cfd RDI: ffffed1038de7f7b
RBP: ffff8881d1210000 R08: ffff8881c726c800 R09: fffffbfff11ad3a4
R10: fffffbfff11ad3a3 R11: ffffffff88d69d1f R12: 1ffff11038de7f9f
R13: 00000000fffffff0 R14: 0000000000000000 R15: ffff8881d63eff00
  yurex_write+0x369/0x8f0 drivers/usb/misc/yurex.c:493
  __vfs_write+0x76/0x100 fs/read_write.c:494
  vfs_write+0x262/0x5c0 fs/read_write.c:558
  ksys_write+0x127/0x250 fs/read_write.c:611
  do_syscall_64+0xb7/0x580 arch/x86/entry/common.c:296
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459829
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f5fe5e65c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459829
RDX: 000000000000008d RSI: 0000000020000040 RDI: 0000000000000004
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5fe5e666d4
R13: 00000000004c99b9 R14: 00000000004e1038 R15: 00000000ffffffff
Kernel Offset: disabled
Rebooting in 86400 seconds..


Tested on:

commit:         d0847550 usb-fuzzer: main usb gadget fuzzer driver
git tree:       https://github.com/google/kasan.git
console output: https://syzkaller.appspot.com/x/log.txt?x=16026986600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=14fe315a600000


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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-19 16:59 ` Andrey Konovalov
  2019-08-19 20:01   ` Alan Stern
@ 2019-08-20 13:07   ` Oliver Neukum
  2019-08-20 13:14     ` syzbot
  2019-08-20 13:24   ` Oliver Neukum
  2 siblings, 1 reply; 9+ messages in thread
From: Oliver Neukum @ 2019-08-20 13:07 UTC (permalink / raw)
  To: Andrey Konovalov, syzbot
  Cc: syzkaller-bugs, Felipe Balbi, Greg Kroah-Hartman, chunfeng.yun,
	Alan Stern, LKML, USB list

Am Montag, den 19.08.2019, 18:59 +0200 schrieb Andrey Konovalov:
> On Mon, Aug 19, 2019 at 6:18 PM syzbot
> <syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com> wrote:
> > 
> > Hello,
> > 
> > syzbot found the following crash on:
> > 
> > HEAD commit:    d0847550 usb-fuzzer: main usb gadget fuzzer driver
> > git tree:       https://github.com/google/kasan.git usb-fuzzer
> > console output: https://syzkaller.appspot.com/x/log.txt?x=16947fce600000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
> > dashboard link: https://syzkaller.appspot.com/bug?extid=0e7b6b6001ca8ed655f6
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1141c5ba600000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11ed91d2600000
> > 
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com
> > 

#syz test: https://github.com/google/kasan.git d0847550

From eeb920819e1d98e631fb78fe849649dc8dd6eb1b Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Tue, 20 Aug 2019 15:04:00 +0200
Subject: [PATCH] USB: yurex: fix failure to wait for control message

Using usb_submit_urb() after prepare_to_wait() won't work, because
it may reset the task state to TASK_RUNNING. Replacing it with
a completion.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/misc/yurex.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 6715a128e6c8..519bb53993aa 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -62,6 +62,7 @@ struct usb_yurex {
 	struct mutex		io_mutex;
 	struct fasync_struct	*async_queue;
 	wait_queue_head_t	waitq;
+	struct completion	cntl_cpl;
 
 	spinlock_t		lock;
 	__s64			bbu;		/* BBU from device */
@@ -80,7 +81,7 @@ static void yurex_control_callback(struct urb *urb)
 	if (status) {
 		dev_err(&urb->dev->dev, "%s - control failed: %d\n",
 			__func__, status);
-		wake_up_interruptible(&dev->waitq);
+		complete(&dev->cntl_cpl);
 		return;
 	}
 	/* on success, sender woken up by CMD_ACK int in, or timeout */
@@ -202,6 +203,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 	mutex_init(&dev->io_mutex);
 	spin_lock_init(&dev->lock);
 	init_waitqueue_head(&dev->waitq);
+	init_completion(&dev->cntl_cpl);
 
 	dev->udev = usb_get_dev(interface_to_usbdev(interface));
 	dev->interface = interface;
@@ -322,6 +324,7 @@ static void yurex_disconnect(struct usb_interface *interface)
 	/* wakeup waiters */
 	kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
 	wake_up_interruptible(&dev->waitq);
+	complete(&dev->cntl_cpl);
 
 	/* decrement our usage count */
 	kref_put(&dev->kref, yurex_delete);
@@ -485,13 +488,10 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 	}
 
 	/* send the data as the control msg */
-	prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
 	dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,
 		dev->cntl_buffer[0]);
 	retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
-	if (retval >= 0)
-		timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
-	finish_wait(&dev->waitq, &wait);
+	timeout = wait_for_completion_interruptible__timeout(&dev->cntl_cpl, YUREX_WRITE_TIMEOUT);
 
 	mutex_unlock(&dev->io_mutex);
 
-- 
2.16.4


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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-20 13:07   ` Oliver Neukum
@ 2019-08-20 13:14     ` syzbot
  0 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2019-08-20 13:14 UTC (permalink / raw)
  To: andreyknvl, balbi, chunfeng.yun, gregkh, linux-kernel, linux-usb,
	oneukum, stern, syzkaller-bugs

Hello,

syzbot tried to test the proposed patch but build/boot failed:

rs/staging/uwb/lc-dev.o
   CC      drivers/staging/uwb/lc-rc.o
   CC      drivers/staging/uwb/neh.o
   CC      drivers/video/fbdev/core/cfbfillrect.o
   AR      drivers/staging/wlan-ng/built-in.a
   CC      drivers/video/fbdev/core/cfbcopyarea.o
   AR      drivers/net/wireless/realtek/rtlwifi/rtl8723be/built-in.a
   CC      drivers/staging/rtl8712/rtl871x_ioctl_set.o
   CC      drivers/net/wireless/realtek/rtlwifi/rtl8821ae/rf.o
   CC      drivers/staging/uwb/pal.o
   CC      drivers/gpu/drm/drm_agpsupport.o
   AR      drivers/usb/core/built-in.a
   CC      drivers/gpu/drm/drm_debugfs.o
   CC      drivers/staging/uwb/rsv.o
   CC      drivers/staging/uwb/scan.o
   CC      drivers/staging/uwb/radio.o
   CC      drivers/staging/uwb/reset.o
   CC      drivers/usb/dwc3/ulpi.o
   CC      drivers/staging/uwb/uwb-debug.o
   CC      drivers/gpu/drm/drm_debugfs_crc.o
   CC      drivers/gpu/drm/drm_mipi_dsi.o
   CC      drivers/staging/rtl8712/rtl8712_led.o
   CC      drivers/usb/dwc3/debugfs.o
   CC      drivers/staging/rtl8712/rtl871x_mlme.o
   AR      drivers/staging/wusbcore/host/whci/built-in.a
   AR      drivers/staging/wusbcore/host/built-in.a
   CC      drivers/staging/wusbcore/rh.o
   CC      drivers/staging/rtl8712/ieee80211.o
   CC      drivers/gpu/drm/i915/display/intel_ddi.o
   CC      drivers/gpu/drm/i915/display/intel_dp.o
   CC      drivers/net/wireless/realtek/rtlwifi/efuse.o
   CC      drivers/staging/rtl8712/rtl871x_mp_ioctl.o
   CC      drivers/net/wireless/realtek/rtlwifi/ps.o
   CC      drivers/staging/wusbcore/reservation.o
   CC      drivers/video/fbdev/core/cfbimgblt.o
   CC      drivers/video/fbdev/core/sysfillrect.o
   CC      drivers/gpu/drm/drm_panel_orientation_quirks.o
   CC      drivers/staging/uwb/uwbd.o
   CC      drivers/usb/dwc3/dwc3-pci.o
   CC      drivers/staging/rtl8712/rtl871x_mp.o
   CC      drivers/usb/early/ehci-dbgp.o
   CC      drivers/gpu/drm/i915/display/intel_dp_aux_backlight.o
   CC      drivers/net/wireless/realtek/rtlwifi/rc.o
   AR      drivers/usb/gadget/function/built-in.a
   CC      drivers/staging/uwb/umc-bus.o
   CC      drivers/net/wireless/realtek/rtlwifi/regd.o
   CC      drivers/usb/gadget/fuzzer/fuzzer.o
   CC      drivers/staging/wusbcore/security.o
   CC      drivers/usb/gadget/legacy/inode.o
   CC      drivers/video/fbdev/core/syscopyarea.o
   CC      drivers/staging/wusbcore/wa-hc.o
   CC      drivers/staging/wusbcore/wusbhc.o
   CC      drivers/staging/uwb/umc-dev.o
   CC      drivers/usb/host/pci-quirks.o
   CC      drivers/usb/gadget/udc/bdc/bdc_core.o
   CC      drivers/net/wireless/realtek/rtlwifi/stats.o
   CC      drivers/video/fbdev/core/sysimgblt.o
   CC      drivers/staging/uwb/umc-drv.o
   CC      drivers/usb/gadget/udc/core.o
   AR      drivers/usb/early/built-in.a
   CC      drivers/usb/gadget/udc/bdc/bdc_cmd.o
   CC      drivers/usb/gadget/udc/trace.o
   CC      drivers/usb/gadget/udc/dummy_hcd.o
   AR      drivers/usb/dwc2/built-in.a
   CC      drivers/usb/image/mdc800.o
   CC      drivers/usb/isp1760/isp1760-core.o
   CC      drivers/usb/isp1760/isp1760-if.o
   CC      drivers/staging/uwb/whci.o
   CC      drivers/usb/image/microtek.o
   CC      drivers/net/wireless/realtek/rtlwifi/pci.o
   CC      drivers/staging/rtl8712/mlme_linux.o
   CC      drivers/video/fbdev/core/fb_sys_fops.o
   CC      drivers/net/wireless/realtek/rtlwifi/usb.o
   CC      drivers/staging/rtl8712/recv_linux.o
   CC      drivers/staging/rtl8712/xmit_linux.o
   CC      drivers/staging/wusbcore/wa-nep.o
   CC      drivers/usb/gadget/udc/bdc/bdc_ep.o
   CC      drivers/gpu/drm/i915/display/intel_dp_link_training.o
   CC      drivers/usb/dwc3/dwc3-haps.o
   CC      drivers/usb/dwc3/dwc3-of-simple.o
   AR      drivers/usb/gadget/fuzzer/built-in.a
   CC      drivers/gpu/drm/i915/display/intel_dp_mst.o
   CC      drivers/usb/host/ehci-hcd.o
   CC      drivers/staging/uwb/whc-rc.o
   CC      drivers/gpu/drm/i915/display/intel_dsi.o
   AR      drivers/usb/gadget/legacy/built-in.a
   CC      drivers/staging/rtl8712/usb_intf.o
   CC      drivers/staging/wusbcore/wa-rpipe.o
   CC      drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.o
   CC      drivers/usb/host/ehci-pci.o
   CC      drivers/usb/gadget/udc/net2272.o
   AR      drivers/usb/image/built-in.a
   CC      drivers/usb/misc/sisusbvga/sisusb.o
   CC      drivers/staging/rtl8712/os_intfs.o
   CC      drivers/usb/misc/adutux.o
   CC      drivers/gpu/drm/i915/display/intel_dsi_vbt.o
   CC      drivers/usb/isp1760/isp1760-hcd.o
   CC      drivers/usb/gadget/udc/net2280.o
   CC      drivers/usb/gadget/udc/snps_udc_core.o
   AR      drivers/video/fbdev/core/built-in.a
   AR      drivers/video/fbdev/built-in.a
   CC      drivers/usb/gadget/udc/amd5536udc_pci.o
   AR      drivers/video/built-in.a
   AR      drivers/usb/dwc3/built-in.a
   CC      drivers/usb/gadget/udc/pxa27x_udc.o
   CC      drivers/staging/rtl8712/rtl871x_pwrctrl.o
   CC      drivers/usb/mon/mon_main.o
   CC      drivers/staging/rtl8712/rtl8712_recv.o
   CC      drivers/staging/uwb/hwa-rc.o
   CC      drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.o
   CC      drivers/gpu/drm/i915/display/intel_dvo.o
   CC      drivers/gpu/drm/i915/display/intel_gmbus.o
   CC      drivers/gpu/drm/i915/display/intel_hdmi.o
   CC      drivers/staging/wusbcore/wa-xfer.o
   CC      drivers/usb/mon/mon_stat.o
   CC      drivers/usb/host/ehci-platform.o
   CC      drivers/gpu/drm/i915/display/intel_lspcon.o
   CC      drivers/gpu/drm/i915/display/intel_lvds.o
   CC      drivers/usb/gadget/udc/goku_udc.o
   CC      drivers/usb/misc/appledisplay.o
   CC      drivers/staging/rtl8712/rtl871x_sta_mgt.o
   CC      drivers/staging/rtl8712/rtl871x_recv.o
   CC      drivers/gpu/drm/i915/display/intel_panel.o
   CC      drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.o
   CC      drivers/staging/rtl8712/rtl871x_xmit.o
   CC      drivers/usb/host/oxu210hp-hcd.o
   CC      drivers/gpu/drm/i915/display/intel_sdvo.o
   CC      drivers/usb/gadget/udc/bdc/bdc_udc.o
   AR      drivers/staging/uwb/built-in.a
   CC      drivers/usb/mon/mon_text.o
   CC      drivers/gpu/drm/i915/display/intel_tv.o
   CC      drivers/net/wireless/realtek/rtlwifi/rtl8821ae/trx.o
   CC      drivers/staging/wusbcore/cbaf.o
   CC      drivers/usb/mon/mon_bin.o
   CC      drivers/gpu/drm/i915/display/intel_vdsc.o
   CC      drivers/usb/host/isp116x-hcd.o
   CC      drivers/usb/gadget/udc/bdc/bdc_pci.o
   AR      drivers/usb/misc/sisusbvga/built-in.a
   CC      drivers/staging/rtl8712/rtl8712_xmit.o
   CC      drivers/usb/misc/cypress_cy7c63.o
   CC      drivers/usb/isp1760/isp1760-udc.o
   CC      drivers/usb/host/ohci-hcd.o
   CC      drivers/gpu/drm/i915/display/vlv_dsi.o
   CC      drivers/gpu/drm/i915/display/vlv_dsi_pll.o
   CC      drivers/usb/host/ohci-pci.o
   CC      drivers/usb/gadget/udc/r8a66597-udc.o
   CC      drivers/usb/misc/cytherm.o
   CC      drivers/usb/gadget/udc/pch_udc.o
   AR      drivers/usb/gadget/udc/bdc/built-in.a
   CC      drivers/usb/musb/musb_core.o
   CC      drivers/usb/gadget/udc/mv_udc_core.o
   CC      drivers/gpu/drm/i915/i915_gpu_error.o
   CC      drivers/usb/host/ohci-platform.o
   CC      drivers/gpu/drm/i915/i915_vgpu.o
   CC      drivers/usb/musb/musb_trace.o
   CC      drivers/usb/host/uhci-hcd.o
   CC      drivers/usb/musb/musb_virthub.o
   CC      drivers/usb/host/xhci.o
   CC      drivers/usb/musb/musb_host.o
   CC      drivers/usb/misc/emi26.o
   CC      drivers/usb/misc/emi62.o
   AR      drivers/usb/mon/built-in.a
   CC      drivers/usb/host/xhci-mem.o
   AR      drivers/staging/rtl8712/built-in.a
   CC      drivers/usb/host/xhci-ext-caps.o
   CC      drivers/usb/host/xhci-ring.o
   CC      drivers/usb/phy/phy.o
   CC      drivers/usb/phy/of.o
   AR      drivers/usb/isp1760/built-in.a
   CC      drivers/usb/misc/ezusb.o
   CC      drivers/usb/phy/phy-generic.o
   CC      drivers/usb/phy/phy-tahvo.o
   CC      drivers/usb/host/xhci-hub.o
   CC      drivers/usb/host/xhci-dbg.o
   CC      drivers/usb/host/xhci-trace.o
   CC      drivers/usb/host/xhci-dbgcap.o
   CC      drivers/usb/phy/phy-gpio-vbus-usb.o
   CC      drivers/usb/phy/phy-isp1301.o
   AR      drivers/net/wireless/realtek/rtlwifi/rtl8821ae/built-in.a
   AR      drivers/net/wireless/realtek/rtlwifi/built-in.a
   CC      drivers/usb/host/xhci-dbgtty.o
   AR      drivers/net/wireless/realtek/built-in.a
   CC      drivers/usb/host/xhci-debugfs.o
   AR      drivers/net/wireless/built-in.a
   AR      drivers/staging/wusbcore/built-in.a
   CC      drivers/usb/gadget/udc/fotg210-udc.o
   CC      drivers/gpu/drm/i915/i915_perf.o
   AR      drivers/staging/built-in.a
   AR      drivers/net/built-in.a
   CC      drivers/usb/gadget/udc/mv_u3d_core.o
   CC      drivers/usb/host/xhci-pci.o
   CC      drivers/usb/misc/ftdi-elan.o
   CC      drivers/usb/gadget/udc/gr_udc.o
   CC      drivers/usb/gadget/udc/snps_udc_plat.o
   CC      drivers/usb/roles/class.o
   CC      drivers/usb/serial/usb-serial.o
   CC      drivers/usb/serial/generic.o
   CC      drivers/usb/misc/idmouse.o
   CC      drivers/usb/misc/iowarrior.o
   CC      drivers/usb/musb/musb_gadget_ep0.o
   AR      drivers/usb/phy/built-in.a
   CC      drivers/usb/storage/uas.o
   AR      drivers/usb/roles/built-in.a
   CC      drivers/gpu/drm/i915/i915_oa_hsw.o
   CC      drivers/usb/storage/scsiglue.o
   CC      drivers/usb/misc/isight_firmware.o
   CC      drivers/usb/misc/usblcd.o
   AR      drivers/usb/typec/altmodes/built-in.a
   CC      drivers/usb/serial/bus.o
   CC      drivers/usb/serial/aircable.o
   AR      drivers/usb/typec/mux/built-in.a
   CC      drivers/usb/musb/musb_gadget.o
   CC      drivers/usb/musb/musb_debugfs.o
   CC      drivers/usb/typec/tcpm/tcpm.o
   CC      drivers/usb/host/xhci-plat.o
   CC      drivers/usb/storage/protocol.o
   CC      drivers/usb/misc/ldusb.o
   CC      drivers/usb/typec/tcpm/fusb302.o
   CC      drivers/gpu/drm/i915/i915_oa_bdw.o
   CC      drivers/gpu/drm/i915/i915_oa_chv.o
   CC      drivers/usb/host/sl811-hcd.o
   CC      drivers/usb/typec/ucsi/ucsi.o
   CC      drivers/usb/host/sl811_cs.o
   CC      drivers/usb/typec/ucsi/trace.o
   CC      drivers/usb/misc/legousbtower.o
   CC      drivers/usb/host/u132-hcd.o
   CC      drivers/usb/misc/rio500.o
   CC      drivers/usb/host/r8a66597-hcd.o
   CC      drivers/gpu/drm/i915/i915_oa_sklgt2.o
   CC      drivers/usb/usbip/usbip_common.o
   CC      drivers/usb/host/bcma-hcd.o
   CC      drivers/usb/serial/ark3116.o
   AR      drivers/usb/gadget/udc/built-in.a
   AR      drivers/usb/gadget/built-in.a
   CC      drivers/usb/typec/class.o
   CC      drivers/gpu/drm/i915/i915_oa_sklgt3.o
   CC      drivers/usb/usbip/usbip_event.o
   CC      drivers/usb/typec/ucsi/ucsi_acpi.o
   CC      drivers/usb/typec/mux.o
   CC      drivers/usb/host/ssb-hcd.o
   CC      drivers/usb/misc/usbtest.o
   CC      drivers/usb/misc/ehset.o
   CC      drivers/usb/serial/belkin_sa.o
   CC      drivers/usb/typec/tcpm/tcpci.o
   CC      drivers/usb/storage/transport.o
   CC      drivers/usb/serial/ch341.o
   CC      drivers/usb/serial/cp210x.o
   CC      drivers/usb/misc/trancevibrator.o
   CC      drivers/usb/typec/bus.o
   CC      drivers/usb/host/fotg210-hcd.o
   CC      drivers/usb/serial/cyberjack.o
   CC      drivers/usb/typec/tps6598x.o
   CC      drivers/usb/misc/uss720.o
   CC      drivers/usb/misc/usbsevseg.o
   CC      drivers/usb/misc/yurex.o
   CC      drivers/usb/storage/usb.o
   CC      drivers/usb/usbip/vhci_sysfs.o
   CC      drivers/usb/usbip/vhci_tx.o
   CC      drivers/usb/misc/usb251xb.o
   CC      drivers/usb/serial/cypress_m8.o
   AR      drivers/usb/musb/built-in.a
   AR      drivers/usb/typec/ucsi/built-in.a
   CC      drivers/gpu/drm/i915/i915_oa_sklgt4.o
   CC      drivers/usb/storage/initializers.o
   CC      drivers/usb/serial/usb_debug.o
   CC      drivers/usb/serial/digi_acceleport.o
   CC      drivers/usb/serial/io_edgeport.o
   CC      drivers/gpu/drm/i915/i915_oa_bxt.o
   CC      drivers/usb/usbip/vhci_rx.o
drivers/usb/misc/yurex.c: In function ‘yurex_write’:
drivers/usb/misc/yurex.c:494:12: error: implicit declaration of function  
‘wait_for_completion_interruptible__timeout’; did you mean  
‘wait_for_completion_interruptible_timeout’?  
[-Werror=implicit-function-declaration]
   494 |  timeout =  
wait_for_completion_interruptible__timeout(&dev->cntl_cpl,  
YUREX_WRITE_TIMEOUT);
       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |            wait_for_completion_interruptible_timeout
   CC      drivers/usb/misc/usb4604.o
   CC      drivers/usb/storage/sierra_ms.o
   CC      drivers/usb/misc/usb3503.o
   CC      drivers/usb/misc/chaoskey.o
   CC      drivers/usb/storage/option_ms.o
   CC      drivers/usb/misc/lvstest.o
   CC      drivers/usb/serial/io_ti.o
   CC      drivers/gpu/drm/i915/i915_oa_kblgt2.o
cc1: some warnings being treated as errors
scripts/Makefile.build:280: recipe for target 'drivers/usb/misc/yurex.o'  
failed
make[3]: *** [drivers/usb/misc/yurex.o] Error 1
make[3]: *** Waiting for unfinished jobs....
   CC      drivers/usb/host/max3421-hcd.o
   CC      drivers/usb/usbip/vhci_hcd.o
   CC      drivers/gpu/drm/i915/i915_oa_kblgt3.o
   CC      drivers/usb/storage/usual-tables.o
   CC      drivers/usb/serial/empeg.o
   CC      drivers/usb/serial/f81232.o
   CC      drivers/usb/usbip/stub_dev.o
   CC      drivers/usb/storage/alauda.o
   CC      drivers/usb/serial/f81534.o
   CC      drivers/usb/serial/ftdi_sio.o
   CC      drivers/usb/usbip/stub_main.o
   CC      drivers/gpu/drm/i915/i915_oa_glk.o
   CC      drivers/usb/storage/cypress_atacb.o
   CC      drivers/usb/storage/datafab.o
   CC      drivers/usb/usbip/stub_rx.o
   CC      drivers/usb/usbip/stub_tx.o
   CC      drivers/usb/serial/garmin_gps.o
   CC      drivers/usb/storage/ene_ub6250.o
   CC      drivers/usb/storage/freecom.o
   CC      drivers/usb/usbip/vudc_dev.o
   CC      drivers/usb/usbip/vudc_sysfs.o
   CC      drivers/gpu/drm/i915/i915_oa_cflgt2.o
   CC      drivers/usb/usbip/vudc_tx.o
   CC      drivers/usb/serial/ipaq.o
   CC      drivers/usb/usbip/vudc_rx.o
   CC      drivers/usb/serial/ipw.o
   CC      drivers/gpu/drm/i915/i915_oa_cflgt3.o
   CC      drivers/gpu/drm/i915/i915_oa_cnl.o
   CC      drivers/gpu/drm/i915/i915_oa_icl.o
   CC      drivers/usb/storage/isd200.o
   CC      drivers/usb/usbip/vudc_transfer.o
   CC      drivers/usb/serial/ir-usb.o
   CC      drivers/usb/serial/iuu_phoenix.o
   CC      drivers/usb/usbip/vudc_main.o
   CC      drivers/usb/storage/jumpshot.o
   CC      drivers/usb/serial/keyspan.o
   CC      drivers/usb/storage/karma.o
   CC      drivers/usb/storage/onetouch.o
scripts/Makefile.build:497: recipe for target 'drivers/usb/misc' failed
make[2]: *** [drivers/usb/misc] Error 2
make[2]: *** Waiting for unfinished jobs....
   CC      drivers/usb/storage/realtek_cr.o
   CC      drivers/usb/storage/sddr09.o
   CC      drivers/usb/serial/keyspan_pda.o
   CC      drivers/usb/serial/kl5kusb105.o
   CC      drivers/usb/storage/sddr55.o
   CC      drivers/usb/storage/shuttle_usbat.o
   CC      drivers/usb/serial/kobil_sct.o
   CC      drivers/usb/serial/mct_u232.o
   CC      drivers/usb/serial/metro-usb.o
   CC      drivers/usb/serial/mos7720.o
   CC      drivers/usb/serial/mos7840.o
   CC      drivers/usb/serial/navman.o
   CC      drivers/usb/serial/mxuport.o
   CC      drivers/usb/serial/omninet.o
   CC      drivers/usb/serial/opticon.o
   CC      drivers/usb/serial/option.o
   CC      drivers/usb/serial/pl2303.o
   CC      drivers/usb/serial/oti6858.o
   CC      drivers/usb/serial/qcaux.o
   CC      drivers/usb/serial/qcserial.o
   CC      drivers/usb/serial/quatech2.o
   AR      drivers/usb/usbip/built-in.a
   CC      drivers/usb/serial/safe_serial.o
   CC      drivers/usb/serial/sierra.o
   CC      drivers/usb/serial/usb-serial-simple.o
   AR      drivers/gpu/drm/i915/built-in.a
   CC      drivers/usb/serial/spcp8x5.o
   CC      drivers/usb/serial/ssu100.o
   AR      drivers/gpu/drm/built-in.a
   CC      drivers/usb/serial/symbolserial.o
   CC      drivers/usb/serial/usb_wwan.o
   AR      drivers/gpu/built-in.a
   CC      drivers/usb/serial/ti_usb_3410_5052.o
   CC      drivers/usb/serial/upd78f0730.o
   CC      drivers/usb/serial/visor.o
   CC      drivers/usb/serial/wishbone-serial.o
   AR      drivers/usb/typec/tcpm/built-in.a
   AR      drivers/usb/typec/built-in.a
   CC      drivers/usb/serial/whiteheat.o
   CC      drivers/usb/serial/xsens_mt.o
   AR      drivers/usb/host/built-in.a
   AR      drivers/usb/storage/built-in.a
   AR      drivers/usb/serial/built-in.a
scripts/Makefile.build:497: recipe for target 'drivers/usb' failed
make[1]: *** [drivers/usb] Error 2
Makefile:1083: recipe for target 'drivers' failed
make: *** [drivers] Error 2


Error text is too large and was truncated, full error text is at:
https://syzkaller.appspot.com/x/error.txt?x=16c198bc600000


Tested on:

commit:         d0847550 usb-fuzzer: main usb gadget fuzzer driver
git tree:       https://github.com/google/kasan.git
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=17e0cb4a600000


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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-19 16:59 ` Andrey Konovalov
  2019-08-19 20:01   ` Alan Stern
  2019-08-20 13:07   ` Oliver Neukum
@ 2019-08-20 13:24   ` Oliver Neukum
  2019-08-20 13:40     ` syzbot
  2 siblings, 1 reply; 9+ messages in thread
From: Oliver Neukum @ 2019-08-20 13:24 UTC (permalink / raw)
  To: Andrey Konovalov, syzbot
  Cc: syzkaller-bugs, Felipe Balbi, Greg Kroah-Hartman, chunfeng.yun,
	Alan Stern, LKML, USB list

Am Montag, den 19.08.2019, 18:59 +0200 schrieb Andrey Konovalov:
> On Mon, Aug 19, 2019 at 6:18 PM syzbot
> <syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com> wrote:
> > 
> > Hello,
> > 
> > syzbot found the following crash on:
> > 
> > HEAD commit:    d0847550 usb-fuzzer: main usb gadget fuzzer driver
> > git tree:       https://github.com/google/kasan.git usb-fuzzer
> > console output: https://syzkaller.appspot.com/x/log.txt?x=16947fce600000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
> > dashboard link: https://syzkaller.appspot.com/bug?extid=0e7b6b6001ca8ed655f6
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1141c5ba600000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11ed91d2600000
> > 
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+0e7b6b6001ca8ed655f6@syzkaller.appspotmail.com
> > 

#syz test: https://github.com/google/kasan.git d0847550

From 8d100dc018a0c1ba9c25dc5a222527ea4748f4c7 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Tue, 20 Aug 2019 15:04:00 +0200
Subject: [PATCH] USB: yurex: fix failure to wait for control message

Using usb_submit_urb() after prepare_to_wait() won't work, because
it may reset the task state to TASK_RUNNING. Replacing it with
a completion.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/misc/yurex.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 6715a128e6c8..64b2bfe7fb83 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -62,6 +62,7 @@ struct usb_yurex {
 	struct mutex		io_mutex;
 	struct fasync_struct	*async_queue;
 	wait_queue_head_t	waitq;
+	struct completion	cntl_cpl;
 
 	spinlock_t		lock;
 	__s64			bbu;		/* BBU from device */
@@ -80,7 +81,7 @@ static void yurex_control_callback(struct urb *urb)
 	if (status) {
 		dev_err(&urb->dev->dev, "%s - control failed: %d\n",
 			__func__, status);
-		wake_up_interruptible(&dev->waitq);
+		complete(&dev->cntl_cpl);
 		return;
 	}
 	/* on success, sender woken up by CMD_ACK int in, or timeout */
@@ -202,6 +203,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_
 	mutex_init(&dev->io_mutex);
 	spin_lock_init(&dev->lock);
 	init_waitqueue_head(&dev->waitq);
+	init_completion(&dev->cntl_cpl);
 
 	dev->udev = usb_get_dev(interface_to_usbdev(interface));
 	dev->interface = interface;
@@ -322,6 +324,7 @@ static void yurex_disconnect(struct usb_interface *interface)
 	/* wakeup waiters */
 	kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
 	wake_up_interruptible(&dev->waitq);
+	complete(&dev->cntl_cpl);
 
 	/* decrement our usage count */
 	kref_put(&dev->kref, yurex_delete);
@@ -485,13 +488,10 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 	}
 
 	/* send the data as the control msg */
-	prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
 	dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,
 		dev->cntl_buffer[0]);
 	retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
-	if (retval >= 0)
-		timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
-	finish_wait(&dev->waitq, &wait);
+	timeout = wait_for_completion_interruptible_timeout(&dev->cntl_cpl, YUREX_WRITE_TIMEOUT);
 
 	mutex_unlock(&dev->io_mutex);
 
-- 
2.16.4


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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-20 13:24   ` Oliver Neukum
@ 2019-08-20 13:40     ` syzbot
  2019-08-20 14:25       ` Oliver Neukum
  0 siblings, 1 reply; 9+ messages in thread
From: syzbot @ 2019-08-20 13:40 UTC (permalink / raw)
  To: andreyknvl, balbi, chunfeng.yun, gregkh, linux-kernel, linux-usb,
	oneukum, stern, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer still triggered  
crash:
WARNING in yurex_write/usb_submit_urb

------------[ cut here ]------------
URB 0000000052a92140 submitted while active
WARNING: CPU: 1 PID: 3052 at drivers/usb/core/urb.c:362  
usb_submit_urb+0x10c1/0x13b0 drivers/usb/core/urb.c:362
Kernel panic - not syncing: panic_on_warn set ...
CPU: 1 PID: 3052 Comm: syz-executor.5 Not tainted 5.3.0-rc4+ #1
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0xca/0x13e lib/dump_stack.c:113
  panic+0x2a3/0x6da kernel/panic.c:219
  __warn.cold+0x20/0x4a kernel/panic.c:576
  report_bug+0x262/0x2a0 lib/bug.c:186
  fixup_bug arch/x86/kernel/traps.c:179 [inline]
  fixup_bug arch/x86/kernel/traps.c:174 [inline]
  do_error_trap+0x12b/0x1e0 arch/x86/kernel/traps.c:272
  do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:291
  invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1028
RIP: 0010:usb_submit_urb+0x10c1/0x13b0 drivers/usb/core/urb.c:362
Code: 89 de e8 62 b7 ef fd 84 db 0f 85 42 f6 ff ff e8 25 b6 ef fd 4c 89 fe  
48 c7 c7 c0 67 18 86 c6 05 87 29 3a 04 01 e8 14 9b c5 fd <0f> 0b e9 20 f6  
ff ff c7 44 24 14 01 00 00 00 e9 d7 f6 ff ff 41 bd
RSP: 0018:ffff8881d4037c68 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff81288cfd RDI: ffffed103a806f7f
RBP: 1ffff1103a806f9f R08: ffff8881cfdc8000 R09: fffffbfff11ad3a4
R10: fffffbfff11ad3a3 R11: ffffffff88d69d1f R12: ffff8881d2352f00
R13: 00000000fffffff0 R14: ffff8881d2352f48 R15: ffff8881d1feef00
  yurex_write+0x395/0x6e0 drivers/usb/misc/yurex.c:493
  __vfs_write+0x76/0x100 fs/read_write.c:494
  vfs_write+0x262/0x5c0 fs/read_write.c:558
  ksys_write+0x127/0x250 fs/read_write.c:611
  do_syscall_64+0xb7/0x580 arch/x86/entry/common.c:296
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459829
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fe53dbeec78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459829
RDX: 000000000000008d RSI: 0000000020000040 RDI: 0000000000000004
RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe53dbef6d4
R13: 00000000004c99b9 R14: 00000000004e1038 R15: 00000000ffffffff
Kernel Offset: disabled
Rebooting in 86400 seconds..


Tested on:

commit:         d0847550 usb-fuzzer: main usb gadget fuzzer driver
git tree:       https://github.com/google/kasan.git
console output: https://syzkaller.appspot.com/x/log.txt?x=154528bc600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=14dedf6a600000


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

* Re: WARNING in kmem_cache_alloc_trace
  2019-08-20 13:40     ` syzbot
@ 2019-08-20 14:25       ` Oliver Neukum
  0 siblings, 0 replies; 9+ messages in thread
From: Oliver Neukum @ 2019-08-20 14:25 UTC (permalink / raw)
  To: syzbot, andreyknvl, syzkaller-bugs, balbi, gregkh, chunfeng.yun,
	stern, linux-kernel, linux-usb

Am Dienstag, den 20.08.2019, 06:40 -0700 schrieb syzbot:
> Hello,
> 
> syzbot has tested the proposed patch but the reproducer still triggered  
> crash:
> WARNING in yurex_write/usb_submit_urb

It looks to me like we have two issues here. The driver is simply not
ready to deal with concurrent writers. Is that one of the test cases?

	Regards
		Oliver


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

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 16:18 WARNING in kmem_cache_alloc_trace syzbot
2019-08-19 16:59 ` Andrey Konovalov
2019-08-19 20:01   ` Alan Stern
2019-08-19 20:20     ` syzbot
2019-08-20 13:07   ` Oliver Neukum
2019-08-20 13:14     ` syzbot
2019-08-20 13:24   ` Oliver Neukum
2019-08-20 13:40     ` syzbot
2019-08-20 14:25       ` Oliver Neukum

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org linux-usb@archiver.kernel.org
	public-inbox-index linux-usb


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/ public-inbox