[syzbot] BUG: unable to handle kernel NULL pointer dereference in nci_cmd_timer

24 views
Skip to first unread message

syzbot

unread,
Nov 16, 2022, 5:52:39 AM11/16/22
to da...@davemloft.net, 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: 9500fc6e9e60 Merge branch 'for-next/core' into for-kernelci
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=16cbf7a5880000
kernel config: https://syzkaller.appspot.com/x/.config?x=b25c9f218686dd5e
dashboard link: https://syzkaller.appspot.com/bug?extid=10257d01dd285b15170a
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1354dce9880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10880a95880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/1363e60652f7/disk-9500fc6e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/fcc4da811bb6/vmlinux-9500fc6e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0b554298f1fa/Image-9500fc6e.gz.xz

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

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
Data abort info:
ISV = 0, ISS = 0x00000004
CM = 0, WnR = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=000000010c75b000
[0000000000000000] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.1.0-rc5-syzkaller-32269-g9500fc6e9e60 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/30/2022
pstate: 004000c5 (nzcv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : __queue_work+0x3c4/0x8b4
lr : __queue_work+0x3c4/0x8b4 kernel/workqueue.c:1458
sp : ffff800008003d60
x29: ffff800008003d60 x28: 0000000000000000 x27: ffff80000d3a9000
x26: ffff80000d3ad050 x25: ffff80000d2fe008 x24: ffff80000db54000
x23: 0000000000000000 x22: 0000000000000023 x21: ffff0000c7a95400
x20: 0000000000000008 x19: ffff0000cd0d20f8 x18: ffff80000db78158
x17: ffff80000ddda198 x16: ffff80000dc18158 x15: ffff80000d3cbc80
x14: 0000000000000000 x13: 00000000ffffffff x12: ffff80000d3cbc80
x11: ff8080000c07dfe4 x10: 0000000000000000 x9 : ffff80000c07dfe4
x8 : ffff80000d3cbc80 x7 : ffff80000813bae8 x6 : 0000000000000000
x5 : 0000000000000080 x4 : 0000000000000000 x3 : 0000000000000002
x2 : 0000000000000008 x1 : 0000000000000000 x0 : ffff0000c0014c00
Call trace:
__queue_work+0x3c4/0x8b4 kernel/workqueue.c:1458
queue_work_on+0xb0/0x15c kernel/workqueue.c:1545
queue_work include/linux/workqueue.h:503 [inline]
nci_cmd_timer+0x30/0x40 net/nfc/nci/core.c:615
call_timer_fn+0x90/0x144 kernel/time/timer.c:1474
expire_timers kernel/time/timer.c:1519 [inline]
__run_timers+0x280/0x374 kernel/time/timer.c:1790
run_timer_softirq+0x34/0x5c kernel/time/timer.c:1803
_stext+0x168/0x37c
____do_softirq+0x14/0x20 arch/arm64/kernel/irq.c:79
call_on_irq_stack+0x2c/0x54 arch/arm64/kernel/entry.S:892
do_softirq_own_stack+0x20/0x2c arch/arm64/kernel/irq.c:84
invoke_softirq+0x70/0xbc kernel/softirq.c:452
__irq_exit_rcu+0xf0/0x140 kernel/softirq.c:650
irq_exit_rcu+0x10/0x40 kernel/softirq.c:662
__el1_irq arch/arm64/kernel/entry-common.c:472 [inline]
el1_interrupt+0x38/0x68 arch/arm64/kernel/entry-common.c:486
el1h_64_irq_handler+0x18/0x24 arch/arm64/kernel/entry-common.c:491
el1h_64_irq+0x64/0x68 arch/arm64/kernel/entry.S:580
arch_local_irq_enable+0xc/0x18 arch/arm64/include/asm/irqflags.h:35
default_idle_call+0x48/0xb8 kernel/sched/idle.c:109
cpuidle_idle_call kernel/sched/idle.c:191 [inline]
do_idle+0x110/0x2d4 kernel/sched/idle.c:303
cpu_startup_entry+0x24/0x28 kernel/sched/idle.c:400
kernel_init+0x0/0x290 init/main.c:729
start_kernel+0x0/0x620 init/main.c:890
start_kernel+0x450/0x620 init/main.c:1145
__primary_switched+0xb4/0xbc arch/arm64/kernel/head.S:471
Code: 94001384 aa0003f7 aa1303e0 9400144a (f94002f8)
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
0: 94001384 bl 0x4e10
4: aa0003f7 mov x23, x0
8: aa1303e0 mov x0, x19
c: 9400144a bl 0x5134
* 10: f94002f8 ldr x24, [x23] <-- trapping instruction


---
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,
Nov 16, 2022, 7:39:08 AM11/16/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On 16 Nov 2022 02:52:37 -0800
> syzbot found the following issue on:
>
> HEAD commit: 9500fc6e9e60 Merge branch 'for-next/core' into for-kernelci
> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> console output: https://syzkaller.appspot.com/x/log.txt?x=16cbf7a5880000
> kernel config: https://syzkaller.appspot.com/x/.config?x=b25c9f218686dd5e
> dashboard link: https://syzkaller.appspot.com/bug?extid=10257d01dd285b15170a
Check NCI_UNREG in the nci cmd work to not re-arm cmd timer.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git 9500fc6e9e60

--- x/net/nfc/nci/core.c
+++ n/net/nfc/nci/core.c
@@ -559,6 +559,8 @@ static int nci_close_device(struct nci_d
*/
mutex_lock(&ndev->req_lock);

+ set_bit(NCI_UNREG, &ndev->flags);
+
if (!test_and_clear_bit(NCI_UP, &ndev->flags)) {
/* Need to flush the cmd wq in case
* there is a queued/running cmd_work
@@ -595,11 +597,8 @@ static int nci_close_device(struct nci_d

/* Flush cmd wq */
flush_workqueue(ndev->cmd_wq);
-
del_timer_sync(&ndev->cmd_timer);
-
- /* Clear flags except NCI_UNREG */
- ndev->flags &= BIT(NCI_UNREG);
+ flush_workqueue(ndev->cmd_wq);

mutex_unlock(&ndev->req_lock);

@@ -1282,12 +1281,6 @@ void nci_unregister_device(struct nci_de
{
struct nci_conn_info *conn_info, *n;

- /* This set_bit is not protected with specialized barrier,
- * However, it is fine because the mutex_lock(&ndev->req_lock);
- * in nci_close_device() will help to emit one.
- */
- set_bit(NCI_UNREG, &ndev->flags);
-
nci_close_device(ndev);

destroy_workqueue(ndev->cmd_wq);
@@ -1543,6 +1536,8 @@ static void nci_cmd_work(struct work_str
struct nci_dev *ndev = container_of(work, struct nci_dev, cmd_work);
struct sk_buff *skb;

+ if (test_bit(NCI_UNREG, &ndev->flags))
+ return;
pr_debug("cmd_cnt %d\n", atomic_read(&ndev->cmd_cnt));

/* Send queued command */
--

Lin Horse

unread,
Nov 16, 2022, 7:39:55 AM11/16/22
to syzkaller-bugs

syzbot

unread,
Nov 16, 2022, 7:39:59 AM11/16/22
to Lin Horse, kylin.f...@gmail.com, syzkall...@googlegroups.com
> #syz test: https://github.com/f0rm2l1n/linux-forfix.git master

I see the command but can't find the corresponding bug.
Please resend the email to syzbo...@syzkaller.appspotmail.com address
that is the sender of the bug report (also present in the Reported-by tag).

>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bug...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/9369be5f-44b3-496f-9466-d9d6480f54ebn%40googlegroups.com.
Message has been deleted

syzbot

unread,
Nov 16, 2022, 8:08:00 AM11/16/22
to Lin Horse, kylin.f...@gmail.com, syzkall...@googlegroups.com
>> HEAD commit: 9500fc6e9e60 Merge branch 'for-next/core' into for-kernelci
>> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
> for-kernelci
>> console output: https://syzkaller.appspot.com/x/log.txt?x=16cbf7a5880000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=b25c9f218686dd5e
>> dashboard link:
> https://syzkaller.appspot.com/bug?extid=10257d01dd285b15170a
>> compiler: Debian clang version
> 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU
> Binutils for Debian) 2.35.2
> #syz test: https://github.com/f0rm2l1n/linux-forfix.git master

I see the command but can't find the corresponding bug.
Please resend the email to syzbo...@syzkaller.appspotmail.com address
that is the sender of the bug report (also present in the Reported-by tag).

>
> diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
> index 6a193cce2..7e582d79d 100644
> --- a/net/nfc/nci/core.c
> +++ b/net/nfc/nci/core.c
> @@ -542,7 +542,7 @@ static int nci_open_device(struct nci_dev *ndev)
> skb_queue_purge(&ndev->tx_q);
>
> ndev->ops->close(ndev);
> - ndev->flags = 0;
> + ndev->flags &= BIT(NCI_UNREG);;
> }
>
> done:
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bug...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/5b68c088-c338-414c-b2d3-6b530d24a473n%40googlegroups.com.

Lin Ma

unread,
Nov 16, 2022, 8:11:51 AM11/16/22
to syzbot, da...@davemloft.net, edum...@google.com, krzysztof...@linaro.org, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
> From: syzbot <syzbot+10257d...@syzkaller.appspotmail.com>
> Sent Time: 2022-11-16 18:52:37 (Wednesday)
> To: da...@davemloft.net, 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
> Cc:
> Subject: [syzbot] BUG: unable to handle kernel NULL pointer dereference in nci_cmd_timer

#syz test: https://github.com/f0rm2l1n/linux-fix.git master

syzbot

unread,
Nov 16, 2022, 12:20:16 PM11/16/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

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

Reported-and-tested-by: syzbot+10257d...@syzkaller.appspotmail.com

Tested on:

commit: 9500fc6e Merge branch 'for-next/core' into for-kernelci
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=15daabc1880000
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
patch: https://syzkaller.appspot.com/x/patch.diff?x=14919b11880000

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

syzbot

unread,
Nov 16, 2022, 1:17:24 PM11/16/22
to da...@davemloft.net, 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 has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+10257d...@syzkaller.appspotmail.com

Tested on:

commit: 1c96c97c nfc/nci: fix race with opening and closing
git tree: https://github.com/f0rm2l1n/linux-fix.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=16b3ea01880000
kernel config: https://syzkaller.appspot.com/x/.config?x=c42faa14acb6dc7f
dashboard link: https://syzkaller.appspot.com/bug?extid=10257d01dd285b15170a
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Note: no patches were applied.

Dmitry Vyukov

unread,
Nov 30, 2022, 4:28:58 AM11/30/22
to Lin Ma, 马麟, syzbot, krzysztof...@linaro.org, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com
#syz dup: WARNING in nci_send_cmd
Reply all
Reply to author
Forward
0 new messages