[syzbot] BUG: corrupted list in nfc_llcp_register_device

20 views
Skip to first unread message

syzbot

unread,
Dec 21, 2022, 3:14:42 AM12/21/22
to da...@davemloft.net, dvy...@google.com, edum...@google.com, krzysztof...@linaro.org, ku...@kernel.org, li...@zju.edu.cn, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6feb57c2fd7c Merge tag 'kbuild-v6.2' of git://git.kernel.o..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14dd1bbf880000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3fb546de56fbf8d
dashboard link: https://syzkaller.appspot.com/bug?extid=c1d0a03d305972dbbe14
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15fbcbd0480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/81556e491789/disk-6feb57c2.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/065c943ec9de/vmlinux-6feb57c2.xz
kernel image: https://storage.googleapis.com/syzbot-assets/66e98c522c1f/bzImage-6feb57c2.xz

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

list_add corruption. next->prev should be prev (ffffffff8e7c1b40), but was 054e024500005c15. (next=ffff8880286ef000).
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:29!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 23580 Comm: syz-executor.3 Not tainted 6.1.0-syzkaller-13822-g6feb57c2fd7c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
RIP: 0010:__list_add_valid+0xdd/0x100 lib/list_debug.c:27
Code: b9 45 6b 06 0f 0b 48 c7 c7 20 c2 4b 8b 31 c0 e8 a9 45 6b 06 0f 0b 48 c7 c7 80 c2 4b 8b 4c 89 e6 4c 89 f1 31 c0 e8 93 45 6b 06 <0f> 0b 48 c7 c7 00 c3 4b 8b 4c 89 f6 4c 89 e1 31 c0 e8 7d 45 6b 06
RSP: 0018:ffffc9000bb8f560 EFLAGS: 00010246
RAX: 0000000000000075 RBX: ffff8880286ef008 RCX: 7255f226623a9300
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: 1ffff110056b8600 R08: ffffffff816f2c9d R09: fffff52001771e65
R10: fffff52001771e65 R11: 1ffff92001771e64 R12: ffffffff8e7c1b40
R13: dffffc0000000000 R14: ffff8880286ef000 R15: ffff88802b5c3000
FS: 00007fa56cb80700(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f9560bfe718 CR3: 0000000078b31000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__list_add include/linux/list.h:69 [inline]
list_add include/linux/list.h:88 [inline]
nfc_llcp_register_device+0x6c4/0x800 net/nfc/llcp_core.c:1603
nfc_register_device+0x68/0x320 net/nfc/core.c:1124
nci_register_device+0x7b5/0x8f0 net/nfc/nci/core.c:1257
virtual_ncidev_open+0x138/0x1b0 drivers/nfc/virtual_ncidev.c:148
misc_open+0x346/0x3c0 drivers/char/misc.c:165
chrdev_open+0x53b/0x5f0 fs/char_dev.c:414
do_dentry_open+0x85f/0x11b0 fs/open.c:882
do_open fs/namei.c:3557 [inline]
path_openat+0x25ba/0x2dd0 fs/namei.c:3714
do_filp_open+0x264/0x4f0 fs/namei.c:3741
do_sys_openat2+0x124/0x4e0 fs/open.c:1310
do_sys_open fs/open.c:1326 [inline]
__do_sys_openat fs/open.c:1342 [inline]
__se_sys_openat fs/open.c:1337 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1337
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fa56be8c0d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa56cb80168 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007fa56bfabf80 RCX: 00007fa56be8c0d9
RDX: 0000000000000002 RSI: 0000000020000080 RDI: ffffffffffffff9c
RBP: 00007fa56bee7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd25093fef R14: 00007fa56cb80300 R15: 0000000000022000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__list_add_valid+0xdd/0x100 lib/list_debug.c:27
Code: b9 45 6b 06 0f 0b 48 c7 c7 20 c2 4b 8b 31 c0 e8 a9 45 6b 06 0f 0b 48 c7 c7 80 c2 4b 8b 4c 89 e6 4c 89 f1 31 c0 e8 93 45 6b 06 <0f> 0b 48 c7 c7 00 c3 4b 8b 4c 89 f6 4c 89 e1 31 c0 e8 7d 45 6b 06
RSP: 0018:ffffc9000bb8f560 EFLAGS: 00010246
RAX: 0000000000000075 RBX: ffff8880286ef008 RCX: 7255f226623a9300
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: 1ffff110056b8600 R08: ffffffff816f2c9d R09: fffff52001771e65
R10: fffff52001771e65 R11: 1ffff92001771e64 R12: ffffffff8e7c1b40
R13: dffffc0000000000 R14: ffff8880286ef000 R15: ffff88802b5c3000
FS: 00007fa56cb80700(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f9560bfe718 CR3: 0000000078b31000 CR4: 00000000003506e0
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,
Dec 21, 2022, 7:30:13 AM12/21/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Date: Wed, 21 Dec 2022 00:14:41 -0800
> syzbot found the following issue on:
>
> HEAD commit: 6feb57c2fd7c Merge tag 'kbuild-v6.2' of git://git.kernel.o..
> git tree: upstream
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15fbcbd0480000

Add llcp_devices_lock spin lock.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

--- x/net/nfc/llcp_core.c
+++ y/net/nfc/llcp_core.c
@@ -17,6 +17,7 @@
static u8 llcp_magic[3] = {0x46, 0x66, 0x6d};

static LIST_HEAD(llcp_devices);
+static DEFINE_SPINLOCK(llcp_devices_lock);

static void nfc_llcp_rx_skb(struct nfc_llcp_local *local, struct sk_buff *skb);

@@ -281,11 +282,17 @@ static void nfc_llcp_sdreq_timer(struct
struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev)
{
struct nfc_llcp_local *local;
+ unsigned long flags;
+
+ spin_lock_irqsave(&llcp_devices_lock, flags);

list_for_each_entry(local, &llcp_devices, list)
- if (local->dev == dev)
+ if (local->dev == dev) {
+ spin_unlock_irqrestore(&llcp_devices_lock, flags);
return local;
+ }

+ spin_unlock_irqrestore(&llcp_devices_lock, flags);
pr_debug("No device found\n");

return NULL;
@@ -1562,6 +1569,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *
int nfc_llcp_register_device(struct nfc_dev *ndev)
{
struct nfc_llcp_local *local;
+ unsigned long flags;

local = kzalloc(sizeof(struct nfc_llcp_local), GFP_KERNEL);
if (local == NULL)
@@ -1600,7 +1608,9 @@ int nfc_llcp_register_device(struct nfc_
timer_setup(&local->sdreq_timer, nfc_llcp_sdreq_timer, 0);
INIT_WORK(&local->sdreq_timeout_work, nfc_llcp_sdreq_timeout_work);

+ spin_lock_irqsave(&llcp_devices_lock, flags);
list_add(&local->list, &llcp_devices);
+ spin_unlock_irqrestore(&llcp_devices_lock, flags);

return 0;
}
--

syzbot

unread,
Dec 21, 2022, 10:02:28 AM12/21/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
INFO: rcu detected stall in corrupted

rcu: INFO: rcu_preempt detected expedited stalls on CPUs/tasks: { P5555 } 2640 jiffies s: 2765 root: 0x0/T
rcu: blocking rcu_node structures (internal RCU debug):


Tested on:

commit: b6bb9676 Merge tag 'm68knommu-for-v6.2' of git://git.k..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=136b095f880000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3fb546de56fbf8d
dashboard link: https://syzkaller.appspot.com/bug?extid=c1d0a03d305972dbbe14
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=12bab1c8480000

syzbot

unread,
Jan 23, 2023, 2:58:52 AM1/23/23
to da...@davemloft.net, dvy...@google.com, edum...@google.com, hda...@sina.com, krzysztof...@linaro.org, ku...@kernel.org, li...@zju.edu.cn, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 2475bf0250de Merge tag 'sched_urgent_for_v6.2_rc6' of git:..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=116dd0ac480000
kernel config: https://syzkaller.appspot.com/x/.config?x=23330449ad10b66f
dashboard link: https://syzkaller.appspot.com/bug?extid=c1d0a03d305972dbbe14
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: i386
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e4a789480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=100108fa480000

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

list_add corruption. prev->next should be next (ffff88802620c000), but was ffff88801d633000. (prev=ffffffff8e546e60).
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:30!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 12187 Comm: syz-executor209 Not tainted 6.2.0-rc5-syzkaller-00013-g2475bf0250de #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
RIP: 0010:__list_add_valid.cold+0x56/0x58 lib/list_debug.c:30
Code: 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 c0 bc a6 8a e8 df 2c f0 ff 0f 0b 48 89 f1 48 c7 c7 40 bc a6 8a 4c 89 e6 e8 cb 2c f0 ff <0f> 0b 4c 89 e1 48 89 ee 48 c7 c7 a0 be a6 8a e8 b7 2c f0 ff 0f 0b
RSP: 0018:ffffc90026c577f0 EFLAGS: 00010282
RAX: 0000000000000075 RBX: ffff888026209000 RCX: 0000000000000000
RDX: ffff888012c20000 RSI: ffffffff816680ec RDI: fffff52004d8aef0
RBP: ffff888026209000 R08: 0000000000000075 R09: 0000000000000000
R10: 0000000080000000 R11: 0000000000000000 R12: ffff88802620c000
R13: ffff88802620c000 R14: 0000000000000000 R15: ffff88802620a140
FS: 0000000000000000(0000) GS:ffff88802c600000(0063) knlGS:0000000057a07380
CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
CR2: 00000000200003c0 CR3: 000000002433d000 CR4: 0000000000150ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__list_add include/linux/list.h:69 [inline]
list_add include/linux/list.h:88 [inline]
nfc_llcp_register_device+0x7a8/0x9e0 net/nfc/llcp_core.c:1604
nfc_register_device+0x70/0x3b0 net/nfc/core.c:1124
nci_register_device+0x7cb/0xb50 net/nfc/nci/core.c:1257
virtual_ncidev_open+0x14f/0x230 drivers/nfc/virtual_ncidev.c:148
misc_open+0x37a/0x4a0 drivers/char/misc.c:165
chrdev_open+0x26a/0x770 fs/char_dev.c:414
do_dentry_open+0x6cc/0x13f0 fs/open.c:882
do_open fs/namei.c:3557 [inline]
path_openat+0x1bbc/0x2a50 fs/namei.c:3714
do_filp_open+0x1ba/0x410 fs/namei.c:3741
do_sys_openat2+0x16d/0x4c0 fs/open.c:1310
do_sys_open fs/open.c:1326 [inline]
__do_compat_sys_openat fs/open.c:1386 [inline]
__se_compat_sys_openat fs/open.c:1384 [inline]
__ia32_compat_sys_openat+0x143/0x1f0 fs/open.c:1384
do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline]
__do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178
do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203
entry_SYSENTER_compat_after_hwframe+0x70/0x82
RIP: 0023:0xf7e6f549
Code: 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00
RSP: 002b:00000000ff98601c EFLAGS: 00000292 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00000000ffffff9c RCX: 0000000020000080
RDX: 0000000000000002 RSI: 0000000000000000 RDI: 00000000ffffffff
RBP: 0000000000008933 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__list_add_valid.cold+0x56/0x58 lib/list_debug.c:30
Code: 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 c0 bc a6 8a e8 df 2c f0 ff 0f 0b 48 89 f1 48 c7 c7 40 bc a6 8a 4c 89 e6 e8 cb 2c f0 ff <0f> 0b 4c 89 e1 48 89 ee 48 c7 c7 a0 be a6 8a e8 b7 2c f0 ff 0f 0b
RSP: 0018:ffffc90026c577f0 EFLAGS: 00010282
RAX: 0000000000000075 RBX: ffff888026209000 RCX: 0000000000000000
RDX: ffff888012c20000 RSI: ffffffff816680ec RDI: fffff52004d8aef0
RBP: ffff888026209000 R08: 0000000000000075 R09: 0000000000000000
R10: 0000000080000000 R11: 0000000000000000 R12: ffff88802620c000
R13: ffff88802620c000 R14: 0000000000000000 R15: ffff88802620a140
FS: 0000000000000000(0000) GS:ffff88802c600000(0063) knlGS:0000000057a07380
CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
CR2: 00000000200003c0 CR3: 000000002433d000 CR4: 0000000000150ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 03 74 c0 01 add 0x1(%rax,%rax,8),%esi
4: 10 05 03 74 b8 01 adc %al,0x1b87403(%rip) # 0x1b8740d
a: 10 06 adc %al,(%rsi)
c: 03 74 b4 01 add 0x1(%rsp,%rsi,4),%esi
10: 10 07 adc %al,(%rdi)
12: 03 74 b0 01 add 0x1(%rax,%rsi,4),%esi
16: 10 08 adc %cl,(%rax)
18: 03 74 d8 01 add 0x1(%rax,%rbx,8),%esi
1c: 00 00 add %al,(%rax)
1e: 00 00 add %al,(%rax)
20: 00 51 52 add %dl,0x52(%rcx)
23: 55 push %rbp
24: 89 e5 mov %esp,%ebp
26: 0f 34 sysenter
28: cd 80 int $0x80
* 2a: 5d pop %rbp <-- trapping instruction
2b: 5a pop %rdx
2c: 59 pop %rcx
2d: c3 retq
2e: 90 nop
2f: 90 nop
30: 90 nop
31: 90 nop
32: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi
39: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi

Reply all
Reply to author
Forward
0 new messages