linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* WARNING in kernfs_get
@ 2018-09-10  7:31 syzbot
  2018-10-31  9:56 ` Tetsuo Handa
  2019-11-20  8:17 ` syzbot
  0 siblings, 2 replies; 6+ messages in thread
From: syzbot @ 2018-09-10  7:31 UTC (permalink / raw)
  To: gregkh, linux-kernel, syzkaller-bugs, tj

Hello,

syzbot found the following crash on:

HEAD commit:    9a5682765a2e Merge branch 'x86-urgent-for-linus' of git://..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1624858e400000
kernel config:  https://syzkaller.appspot.com/x/.config?x=8f59875069d721b6
dashboard link: https://syzkaller.appspot.com/bug?extid=3dcb532381f98c86aeb1
compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12657f0a400000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=117728ae400000

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

WARNING: CPU: 0 PID: 5659 at fs/kernfs/dir.c:494  
kernfs_get.part.8+0x131/0x160 fs/kernfs/dir.c:494
Kernel panic - not syncing: panic_on_warn set ...

CPU: 0 PID: 5659 Comm: syz-executor154 Not tainted 4.19.0-rc2+ #9
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+0x1c4/0x2b4 lib/dump_stack.c:113
  panic+0x238/0x4e7 kernel/panic.c:184
  __warn.cold.8+0x163/0x1ba kernel/panic.c:536
  report_bug+0x254/0x2d0 lib/bug.c:186
  fixup_bug arch/x86/kernel/traps.c:178 [inline]
  do_error_trap+0x1fc/0x4d0 arch/x86/kernel/traps.c:296
  do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:316
  invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:993
RIP: 0010:kernfs_get.part.8+0x131/0x160 fs/kernfs/dir.c:494
Code: 44 05 00 00 00 00 00 48 8b 45 d0 65 48 33 04 25 28 00 00 00 75 2f 48  
83 c4 60 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 df 1c 87 ff <0f> 0b eb b1 4c  
89 e7 e8 d3 83 ca ff eb 81 48 89 df e8 29 83 ca ff
RSP: 0018:ffff8801d892f500 EFLAGS: 00010293
RAX: ffff8801c5f56640 RBX: ffff8801c541b8c0 RCX: ffffffff81f7b391
kobject: 'bluetooth' (00000000076788a3): kobject_add_internal:  
parent: 'virtual', set: '(null)'
RDX: 0000000000000000 RSI: ffffffff81f7b3e1 RDI: 0000000000000005
RBP: ffff8801d892f588 R08: ffff8801c5f56640 R09: ffffed0038a83718
R10: ffffed0038a83718 R11: ffff8801c541b8c3 R12: 1ffff1003b125ea4
R13: 1ffff1003b125ea0 R14: 0000000000000000 R15: ffff8801d892f560
  kernfs_get fs/kernfs/dir.c:493 [inline]
  kernfs_new_node+0xb4/0x120 fs/kernfs/dir.c:698
  kernfs_create_dir_ns+0x4d/0x160 fs/kernfs/dir.c:1021
  sysfs_create_dir_ns+0x19b/0x340 fs/sysfs/dir.c:58
kobject: 'hci1' (000000003c3c3740): kobject_add_internal:  
parent: 'bluetooth', set: 'devices'
  create_dir lib/kobject.c:88 [inline]
  kobject_add_internal+0x440/0xb60 lib/kobject.c:247
kobject: 'hci3' (00000000e8906dbf): kobject_add_internal:  
parent: 'bluetooth', set: 'devices'
kobject: 'hci3' (00000000e8906dbf): kobject_uevent_env
  kobject_add_varg lib/kobject.c:382 [inline]
  kobject_add+0x13f/0x1b0 lib/kobject.c:426
  device_add+0x3e2/0x17f0 drivers/base/core.c:1879
kobject: 'hci2' (000000009e3c3103): kobject_add_internal:  
parent: 'bluetooth', set: 'devices'
  hci_register_dev+0x3e6/0xb80 net/bluetooth/hci_core.c:3196
kobject: 'hci2' (000000009e3c3103): kobject_uevent_env
  __vhci_create_device+0x2c1/0x580 drivers/bluetooth/hci_vhci.c:139
  vhci_create_device drivers/bluetooth/hci_vhci.c:163 [inline]
  vhci_get_user drivers/bluetooth/hci_vhci.c:219 [inline]
  vhci_write+0x2de/0x470 drivers/bluetooth/hci_vhci.c:299
  call_write_iter include/linux/fs.h:1807 [inline]
  new_sync_write fs/read_write.c:474 [inline]
  __vfs_write+0x6b8/0x9f0 fs/read_write.c:487
kobject: 'hci3' (00000000e8906dbf): fill_kobj_path: path  
= '/devices/virtual/bluetooth/hci3'
kobject: 'hci1' (000000003c3c3740): kobject_uevent_env
  vfs_write+0x1fc/0x560 fs/read_write.c:549
  ksys_write+0x101/0x260 fs/read_write.c:598
kobject: 'hci1' (000000003c3c3740): fill_kobj_path: path  
= '/devices/virtual/bluetooth/hci1'
  __do_sys_write fs/read_write.c:610 [inline]
  __se_sys_write fs/read_write.c:607 [inline]
  __x64_sys_write+0x73/0xb0 fs/read_write.c:607
  do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
kobject: 'hci6': free name
kobject: 'rfkill160' (000000007e905e9b): kobject_add_internal:  
parent: 'hci3', set: 'devices'
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440e49
Code: e8 ac e8 ff ff 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 0b 0a fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffce43766e8 EFLAGS: 00000213 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000440e49
RDX: 0000000000000002 RSI: 00000000200000c0 RDI: 0000000000000003
kobject: 'hci2' (000000009e3c3103): fill_kobj_path: path  
= '/devices/virtual/bluetooth/hci2'
RBP: 0000000000000000 R08: 00000000004002c8 R09: 00000000004002c8
R10: 000000000075f880 R11: 0000000000000213 R12: 000000000000c1e3
R13: 0000000000401d70 R14: 0000000000000000 R15: 0000000000000000
Dumping ftrace buffer:
    (ftrace buffer empty)
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#bug-status-tracking 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] 6+ messages in thread

* Re: WARNING in kernfs_get
  2018-09-10  7:31 WARNING in kernfs_get syzbot
@ 2018-10-31  9:56 ` Tetsuo Handa
  2019-11-20  8:17 ` syzbot
  1 sibling, 0 replies; 6+ messages in thread
From: Tetsuo Handa @ 2018-10-31  9:56 UTC (permalink / raw)
  To: gregkh, tj; +Cc: syzbot, linux-kernel, syzkaller-bugs

On 2018/09/10 16:31, syzbot wrote:
> HEAD commit:    9a5682765a2e Merge branch 'x86-urgent-for-linus' of git://..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1624858e400000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=8f59875069d721b6
> dashboard link: https://syzkaller.appspot.com/bug?extid=3dcb532381f98c86aeb1
> compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12657f0a400000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=117728ae400000

Here is a simplified reproducer.

----------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
	int i;
	for (i = 0; i < 16; i++)
		if (fork() == 0)
			while (1) {
				int fd = open("/dev/vhci", O_WRONLY);
				write(fd, "\xff\x80", 2);
				close(fd);
			}
	while (1)
		pause();
	return 0;
}
----------

According to debug printk() patch,
atomic_read(&kn->active) == KN_DEACTIVATED_BIAS when we hit
WARN_ON(!atomic_read(&kn->count)) at kernfs_get().

Therefore, I guess that the caller is failing to check whether
kn is already deactivated (and hence need to recreate a new
entry by that name) before reusing existing kn.

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

* Re: WARNING in kernfs_get
  2018-09-10  7:31 WARNING in kernfs_get syzbot
  2018-10-31  9:56 ` Tetsuo Handa
@ 2019-11-20  8:17 ` syzbot
  2019-11-20  8:29   ` Greg KH
  1 sibling, 1 reply; 6+ messages in thread
From: syzbot @ 2019-11-20  8:17 UTC (permalink / raw)
  To: benh, gregkh, linux-kernel, penguin-kernel, rafael,
	syzkaller-bugs, tj, torvalds

syzbot has bisected this bug to:

commit 726e41097920a73e4c7c33385dcc0debb1281e18
Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date:   Tue Jul 10 00:29:10 2018 +0000

     drivers: core: Remove glue dirs from sysfs earlier

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=17a101cee00000
start commit:   9a568276 Merge branch 'x86-urgent-for-linus' of git://git...
git tree:       upstream
final crash:    https://syzkaller.appspot.com/x/report.txt?x=146101cee00000
console output: https://syzkaller.appspot.com/x/log.txt?x=106101cee00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=8f59875069d721b6
dashboard link: https://syzkaller.appspot.com/bug?extid=3dcb532381f98c86aeb1
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12657f0a400000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=117728ae400000

Reported-by: syzbot+3dcb532381f98c86aeb1@syzkaller.appspotmail.com
Fixes: 726e41097920 ("drivers: core: Remove glue dirs from sysfs earlier")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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

* Re: WARNING in kernfs_get
  2019-11-20  8:17 ` syzbot
@ 2019-11-20  8:29   ` Greg KH
  2019-11-20  8:53     ` Dmitry Vyukov
  2019-11-20 10:42     ` Tetsuo Handa
  0 siblings, 2 replies; 6+ messages in thread
From: Greg KH @ 2019-11-20  8:29 UTC (permalink / raw)
  To: syzbot
  Cc: Benjamin Herrenschmidt, linux-kernel, penguin-kernel, rafael,
	syzkaller-bugs, tj, torvalds

On Wed, Nov 20, 2019 at 12:17:01AM -0800, syzbot wrote:
> syzbot has bisected this bug to:
> 
> commit 726e41097920a73e4c7c33385dcc0debb1281e18
> Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Date:   Tue Jul 10 00:29:10 2018 +0000
> 
>     drivers: core: Remove glue dirs from sysfs earlier
> 
> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=17a101cee00000
> start commit:   9a568276 Merge branch 'x86-urgent-for-linus' of git://git...
> git tree:       upstream
> final crash:    https://syzkaller.appspot.com/x/report.txt?x=146101cee00000
> console output: https://syzkaller.appspot.com/x/log.txt?x=106101cee00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=8f59875069d721b6
> dashboard link: https://syzkaller.appspot.com/bug?extid=3dcb532381f98c86aeb1
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12657f0a400000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=117728ae400000
> 
> Reported-by: syzbot+3dcb532381f98c86aeb1@syzkaller.appspotmail.com
> Fixes: 726e41097920 ("drivers: core: Remove glue dirs from sysfs earlier")
> 
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Again, I think this should be resolved with ac43432cb1f5 ("driver core:
Fix use-after-free and double free on glue directory")

Is there any way to run the reproducer on a newer tree?

thanks,

greg k-h

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

* Re: WARNING in kernfs_get
  2019-11-20  8:29   ` Greg KH
@ 2019-11-20  8:53     ` Dmitry Vyukov
  2019-11-20 10:42     ` Tetsuo Handa
  1 sibling, 0 replies; 6+ messages in thread
From: Dmitry Vyukov @ 2019-11-20  8:53 UTC (permalink / raw)
  To: Greg KH
  Cc: syzbot, Benjamin Herrenschmidt, LKML, Tetsuo Handa, rafael,
	syzkaller-bugs, Tejun Heo, Linus Torvalds

On Wed, Nov 20, 2019 at 9:30 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Nov 20, 2019 at 12:17:01AM -0800, syzbot wrote:
> > syzbot has bisected this bug to:
> >
> > commit 726e41097920a73e4c7c33385dcc0debb1281e18
> > Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Date:   Tue Jul 10 00:29:10 2018 +0000
> >
> >     drivers: core: Remove glue dirs from sysfs earlier
> >
> > bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=17a101cee00000
> > start commit:   9a568276 Merge branch 'x86-urgent-for-linus' of git://git...
> > git tree:       upstream
> > final crash:    https://syzkaller.appspot.com/x/report.txt?x=146101cee00000
> > console output: https://syzkaller.appspot.com/x/log.txt?x=106101cee00000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=8f59875069d721b6
> > dashboard link: https://syzkaller.appspot.com/bug?extid=3dcb532381f98c86aeb1
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12657f0a400000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=117728ae400000
> >
> > Reported-by: syzbot+3dcb532381f98c86aeb1@syzkaller.appspotmail.com
> > Fixes: 726e41097920 ("drivers: core: Remove glue dirs from sysfs earlier")
> >
> > For information about bisection process see: https://goo.gl/tpsmEJ#bisection
>
> Again, I think this should be resolved with ac43432cb1f5 ("driver core:
> Fix use-after-free and double free on glue directory")
>
> Is there any way to run the reproducer on a newer tree?

The generic fix testing instruction should work:
https://github.com/google/syzkaller/blob/master/docs/syzbot.md#testing-patches
Note: you don't need to attach any patch, just pointing to a
tree/branch works too.

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

* Re: WARNING in kernfs_get
  2019-11-20  8:29   ` Greg KH
  2019-11-20  8:53     ` Dmitry Vyukov
@ 2019-11-20 10:42     ` Tetsuo Handa
  1 sibling, 0 replies; 6+ messages in thread
From: Tetsuo Handa @ 2019-11-20 10:42 UTC (permalink / raw)
  To: Greg KH, syzbot
  Cc: Benjamin Herrenschmidt, linux-kernel, rafael, syzkaller-bugs, tj,
	torvalds

On 2019/11/20 17:29, Greg KH wrote:
> Again, I think this should be resolved with ac43432cb1f5 ("driver core:
> Fix use-after-free and double free on glue directory")

Last occurrence was v5.3-rc3 and that patch went to v5.3-rc4. Should be fixed.

#syz fix: driver core: Fix use-after-free and double free on glue directory

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

end of thread, other threads:[~2019-11-20 10:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10  7:31 WARNING in kernfs_get syzbot
2018-10-31  9:56 ` Tetsuo Handa
2019-11-20  8:17 ` syzbot
2019-11-20  8:29   ` Greg KH
2019-11-20  8:53     ` Dmitry Vyukov
2019-11-20 10:42     ` Tetsuo Handa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).