general protection fault in cdev_del (2)

31 views
Skip to first unread message

syzbot

unread,
Sep 24, 2020, 5:26:27 AM9/24/20
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, vi...@zeniv.linux.org.uk
Hello,

syzbot found the following issue on:

HEAD commit: 98477740 Merge branch 'rcu/urgent' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12641dab900000
kernel config: https://syzkaller.appspot.com/x/.config?x=5f4c828c9e3cef97
dashboard link: https://syzkaller.appspot.com/bug?extid=c49fe6089f295a05e6f8
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14eadc8d900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1517d075900000

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

RBP: 00007ffee0265520 R08: 0000000000000002 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: ffffffffffffffff
R13: 0000000000000005 R14: 0000000000000000 R15: 0000000000000000
general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067]
CPU: 0 PID: 7451 Comm: syz-executor249 Not tainted 5.9.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:cdev_del+0x22/0x90 fs/char_dev.c:596
Code: b5 0f 1f 80 00 00 00 00 55 48 89 fd 48 83 ec 08 e8 d3 41 b3 ff 48 8d 7d 64 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 4f 48
RSP: 0018:ffffc90007f07b10 EFLAGS: 00010207
RAX: dffffc0000000000 RBX: ffff8880a16f3500 RCX: ffffffff841165ff
RDX: 000000000000000c RSI: ffffffff81c2fc6d RDI: 0000000000000064
RBP: 0000000000000000 R08: 0000000000000001 R09: ffffffff8d0b7a67
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a16f3508
R13: ffff8880a17cd008 R14: ffff8880a6236420 R15: ffff8880a6236278
FS: 0000000000000000(0000) GS:ffff8880ae400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f0288f8a710 CR3: 0000000094f1e000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
tty_unregister_device drivers/tty/tty_io.c:3193 [inline]
tty_unregister_device+0x112/0x1b0 drivers/tty/tty_io.c:3188
gsmld_detach_gsm drivers/tty/n_gsm.c:2411 [inline]
gsmld_close+0xaa/0x260 drivers/tty/n_gsm.c:2480
tty_ldisc_close+0x110/0x190 drivers/tty/tty_ldisc.c:489
tty_ldisc_kill+0x94/0x150 drivers/tty/tty_ldisc.c:637
tty_ldisc_hangup+0x30b/0x680 drivers/tty/tty_ldisc.c:756
__tty_hangup.part.0+0x403/0x870 drivers/tty/tty_io.c:625
__tty_hangup drivers/tty/tty_io.c:575 [inline]
tty_vhangup+0x1d/0x30 drivers/tty/tty_io.c:698
pty_close+0x3f5/0x550 drivers/tty/pty.c:79
tty_release+0x455/0xf60 drivers/tty/tty_io.c:1679
__fput+0x285/0x920 fs/file_table.c:281
task_work_run+0xdd/0x190 kernel/task_work.c:141
exit_task_work include/linux/task_work.h:25 [inline]
do_exit+0xb7d/0x29f0 kernel/exit.c:806
do_group_exit+0x125/0x310 kernel/exit.c:903
__do_sys_exit_group kernel/exit.c:914 [inline]
__se_sys_exit_group kernel/exit.c:912 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:912
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x440018
Code: Bad RIP value.
RSP: 002b:00007ffee02654c8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000440018
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004bfd90 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d2180 R14: 0000000000000000 R15: 0000000000000000
Modules linked in:
---[ end trace 98d732d1ef99b6c5 ]---
RIP: 0010:cdev_del+0x22/0x90 fs/char_dev.c:596
Code: b5 0f 1f 80 00 00 00 00 55 48 89 fd 48 83 ec 08 e8 d3 41 b3 ff 48 8d 7d 64 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 4f 48
RSP: 0018:ffffc90007f07b10 EFLAGS: 00010207
RAX: dffffc0000000000 RBX: ffff8880a16f3500 RCX: ffffffff841165ff
RDX: 000000000000000c RSI: ffffffff81c2fc6d RDI: 0000000000000064
RBP: 0000000000000000 R08: 0000000000000001 R09: ffffffff8d0b7a67
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a16f3508
R13: ffff8880a17cd008 R14: ffff8880a6236420 R15: ffff8880a6236278
FS: 0000000000000000(0000) GS:ffff8880ae500000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffd722a6000 CR3: 0000000094644000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Hillf Danton

unread,
Sep 24, 2020, 11:10:55 PM9/24/20
to syzbot, linux-...@vger.kernel.org, linux-...@vger.kernel.org, Jiri Slaby, Hillf Danton, syzkall...@googlegroups.com, vi...@zeniv.linux.org.uk

Thu, 24 Sep 2020 02:26:26 -0700
Bail out in case of failure to register tty device to avoid npd.

--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2367,16 +2367,26 @@ static int gsmld_attach_gsm(struct tty_s
gsm->tty = tty_kref_get(tty);
gsm->output = gsmld_output;
ret = gsm_activate_mux(gsm);
- if (ret != 0)
+ if (ret != 0) {
+out:
tty_kref_put(gsm->tty);
- else {
- /* Don't register device 0 - this is the control channel and not
- a usable tty interface */
- base = mux_num_to_base(gsm); /* Base for this MUX */
- for (i = 1; i < NUM_DLCI; i++)
- tty_register_device(gsm_tty_driver, base + i, NULL);
+ return ret;
}
- return ret;
+
+ /* Don't register device 0 - this is the control channel and not
+ * a usable tty interface
+ */
+ base = mux_num_to_base(gsm); /* Base for this MUX */
+ for (i = 1; i < NUM_DLCI; i++) {
+ struct device *dev;
+
+ dev = tty_register_device(gsm_tty_driver, base + i, NULL);
+ if (IS_ERR(dev)) {
+ ret = PTR_ERR(dev);
+ goto out;
+ }
+ }
+ return 0;
}



syzbot

unread,
Oct 2, 2020, 12:53:08 AM10/2/20
to drago...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in cdev_del

general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067]
CPU: 1 PID: 8529 Comm: syz-executor.4 Not tainted 5.9.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:cdev_del+0x22/0x90 fs/char_dev.c:596
Code: b5 0f 1f 80 00 00 00 00 55 48 89 fd 48 83 ec 08 e8 33 33 b3 ff 48 8d 7d 64 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 4f 48
RSP: 0018:ffffc9000a847c48 EFLAGS: 00010207
RAX: dffffc0000000000 RBX: ffff888218605500 RCX: ffffffff841181cf
RDX: 000000000000000c RSI: ffffffff81c30b5d RDI: 0000000000000064
RBP: 0000000000000000 R08: 0000000000000001 R09: ffffffff8d0b7a67
R10: 0000000000000000 R11: 0000000000000000 R12: ffff888218605508
R13: ffff88821860c008 R14: ffff888094c88420 R15: ffff888094c88278
FS: 00000000018fe940(0000) GS:ffff8880ae500000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000556d29fc25a8 CR3: 0000000096a5a000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
tty_unregister_device drivers/tty/tty_io.c:3193 [inline]
tty_unregister_device+0x112/0x1b0 drivers/tty/tty_io.c:3188
gsmld_detach_gsm drivers/tty/n_gsm.c:2411 [inline]
gsmld_close+0xaa/0x260 drivers/tty/n_gsm.c:2480
tty_ldisc_close+0x110/0x190 drivers/tty/tty_ldisc.c:489
tty_ldisc_kill+0x94/0x150 drivers/tty/tty_ldisc.c:637
tty_ldisc_hangup+0x30b/0x680 drivers/tty/tty_ldisc.c:756
__tty_hangup.part.0+0x403/0x870 drivers/tty/tty_io.c:625
__tty_hangup drivers/tty/tty_io.c:575 [inline]
tty_vhangup+0x1d/0x30 drivers/tty/tty_io.c:698
pty_close+0x3f5/0x550 drivers/tty/pty.c:79
tty_release+0x455/0xf60 drivers/tty/tty_io.c:1679
__fput+0x285/0x920 fs/file_table.c:281
task_work_run+0xdd/0x190 kernel/task_work.c:141
tracehook_notify_resume include/linux/tracehook.h:188 [inline]
exit_to_user_mode_loop kernel/entry/common.c:165 [inline]
exit_to_user_mode_prepare+0x1e1/0x200 kernel/entry/common.c:192
syscall_exit_to_user_mode+0x7e/0x2e0 kernel/entry/common.c:267
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x417901
Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 a4 1a 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007ffe5c003970 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000004 RCX: 0000000000417901
RDX: 0000001b30e20000 RSI: 0000000000000001 RDI: 0000000000000003
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
R10: 00007ffe5c003a60 R11: 0000000000000293 R12: 000000000118d9c0
R13: 000000000118d9c0 R14: ffffffffffffffff R15: 000000000118cf4c
Modules linked in:
---[ end trace 690d4da980f750dd ]---
RIP: 0010:cdev_del+0x22/0x90 fs/char_dev.c:596
Code: b5 0f 1f 80 00 00 00 00 55 48 89 fd 48 83 ec 08 e8 33 33 b3 ff 48 8d 7d 64 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 4f 48
RSP: 0018:ffffc9000a847c48 EFLAGS: 00010207
RAX: dffffc0000000000 RBX: ffff888218605500 RCX: ffffffff841181cf
RDX: 000000000000000c RSI: ffffffff81c30b5d RDI: 0000000000000064
RBP: 0000000000000000 R08: 0000000000000001 R09: ffffffff8d0b7a67
R10: 0000000000000000 R11: 0000000000000000 R12: ffff888218605508
R13: ffff88821860c008 R14: ffff888094c88420 R15: ffff888094c88278
FS: 00000000018fe940(0000) GS:ffff8880ae400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000556d29ffdc78 CR3: 0000000096a5a000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit: 472e5b05 pipe: remove pipe_wait() and fix wakeup race with..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10d3a25d900000
kernel config: https://syzkaller.appspot.com/x/.config?x=cf6032d0140fe29e
dashboard link: https://syzkaller.appspot.com/bug?extid=c49fe6089f295a05e6f8
compiler: gcc (GCC) 10.1.0-syz 20200507
patch: https://syzkaller.appspot.com/x/patch.diff?x=1143897b900000

Reply all
Reply to author
Forward
0 new messages