[syzbot] [net?] KASAN: slab-use-after-free Read in ptp_release

26 views
Skip to first unread message

syzbot

unread,
Oct 23, 2023, 8:34:55 AM10/23/23
to linux-...@vger.kernel.org, net...@vger.kernel.org, richard...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 2dac75696c6d Add linux-next specific files for 20231018
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=10dd834d680000
kernel config: https://syzkaller.appspot.com/x/.config?x=6f8545e1ef7a2b66
dashboard link: https://syzkaller.appspot.com/bug?extid=8a676a50d4eee2f21539
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/2375f16ed327/disk-2dac7569.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c80aee6e2e6c/vmlinux-2dac7569.xz
kernel image: https://storage.googleapis.com/syzbot-assets/664dc23b738d/bzImage-2dac7569.xz

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

==================================================================
BUG: KASAN: slab-use-after-free in __lock_acquire+0x41eb/0x5dc0 kernel/locking/lockdep.c:5004
Read of size 8 at addr ffff888058af5020 by task syz-executor.4/30114

CPU: 0 PID: 30114 Comm: syz-executor.4 Not tainted 6.6.0-rc6-next-20231018-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
__lock_acquire+0x41eb/0x5dc0 kernel/locking/lockdep.c:5004
lock_acquire kernel/locking/lockdep.c:5753 [inline]
lock_acquire+0x1b2/0x530 kernel/locking/lockdep.c:5718
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0x3a/0x50 kernel/locking/spinlock.c:162
ptp_release+0xb2/0x2b0 drivers/ptp/ptp_chardev.c:146
ptp_read+0xf6/0x830 drivers/ptp/ptp_chardev.c:589
posix_clock_read+0x138/0x1b0 kernel/time/posix-clock.c:51
vfs_read+0x1ce/0x8f0 fs/read_write.c:468
ksys_read+0x12f/0x250 fs/read_write.c:613
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f5b40c7cae9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f5b41a770c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f5b40d9c050 RCX: 00007f5b40c7cae9
RDX: 000000000000008a RSI: 0000000020000040 RDI: 0000000000000005
RBP: 00007f5b40cc847a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f5b40d9c050 R15: 00007fffd3982cb8
</TASK>

Allocated by task 30113:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383
kmalloc include/linux/slab.h:600 [inline]
kzalloc include/linux/slab.h:721 [inline]
ptp_open+0xe3/0x4f0 drivers/ptp/ptp_chardev.c:112
posix_clock_open+0x17e/0x240 kernel/time/posix-clock.c:134
chrdev_open+0x26d/0x6e0 fs/char_dev.c:414
do_dentry_open+0x8d4/0x18d0 fs/open.c:948
do_open fs/namei.c:3621 [inline]
path_openat+0x1d3b/0x2ce0 fs/namei.c:3778
do_filp_open+0x1de/0x430 fs/namei.c:3808
do_sys_openat2+0x176/0x1e0 fs/open.c:1440
do_sys_open fs/open.c:1455 [inline]
__do_sys_openat fs/open.c:1471 [inline]
__se_sys_openat fs/open.c:1466 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1466
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Freed by task 30113:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:164 [inline]
slab_free_hook mm/slub.c:1800 [inline]
slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
slab_free mm/slub.c:3809 [inline]
__kmem_cache_free+0xc0/0x180 mm/slub.c:3822
ptp_release+0x204/0x2b0 drivers/ptp/ptp_chardev.c:150
ptp_read+0xf6/0x830 drivers/ptp/ptp_chardev.c:589
posix_clock_read+0x138/0x1b0 kernel/time/posix-clock.c:51
vfs_read+0x1ce/0x8f0 fs/read_write.c:468
ksys_read+0x12f/0x250 fs/read_write.c:613
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82
entry_SYSCALL_64_after_hwframe+0x63/0x6b

The buggy address belongs to the object at ffff888058af4000
which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 4128 bytes inside of
freed 8192-byte region [ffff888058af4000, ffff888058af6000)

The buggy address belongs to the physical page:
page:ffffea000162bc00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x58af0
head:ffffea000162bc00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888012c42280 ffffea000066c400 dead000000000006
raw: 0000000000000000 0000000080020002 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5072, tgid 5072 (syz-executor.0), ts 99807679464, free_ts 30263208265
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1537
prep_new_page mm/page_alloc.c:1544 [inline]
get_page_from_freelist+0xa16/0x3680 mm/page_alloc.c:3348
__alloc_pages+0x1d0/0x4c0 mm/page_alloc.c:4604
alloc_pages_mpol+0x258/0x5f0 mm/mempolicy.c:2133
alloc_slab_page mm/slub.c:1870 [inline]
allocate_slab+0x251/0x380 mm/slub.c:2017
new_slab mm/slub.c:2070 [inline]
___slab_alloc+0x8c7/0x1580 mm/slub.c:3223
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
__slab_alloc_node mm/slub.c:3375 [inline]
slab_alloc_node mm/slub.c:3468 [inline]
__kmem_cache_alloc_node+0x131/0x310 mm/slub.c:3517
__do_kmalloc_node mm/slab_common.c:1006 [inline]
__kmalloc_node+0x56/0x130 mm/slab_common.c:1014
kmalloc_node include/linux/slab.h:620 [inline]
kvmalloc_node+0x6f/0x1a0 mm/util.c:607
kvmalloc include/linux/slab.h:738 [inline]
kvmalloc_array include/linux/slab.h:756 [inline]
__ptr_ring_init_queue_alloc include/linux/ptr_ring.h:471 [inline]
ptr_ring_init include/linux/ptr_ring.h:489 [inline]
skb_array_init include/linux/skb_array.h:182 [inline]
pfifo_fast_init+0x125/0x3a0 net/sched/sch_generic.c:858
qdisc_create_dflt+0x101/0x3f0 net/sched/sch_generic.c:1004
attach_one_default_qdisc net/sched/sch_generic.c:1160 [inline]
netdev_for_each_tx_queue include/linux/netdevice.h:2511 [inline]
attach_default_qdiscs net/sched/sch_generic.c:1178 [inline]
dev_activate+0x66c/0x1310 net/sched/sch_generic.c:1237
__dev_open+0x383/0x4d0 net/core/dev.c:1459
__dev_change_flags+0x56a/0x730 net/core/dev.c:8608
dev_change_flags+0x9a/0x170 net/core/dev.c:8680
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1137 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2383
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2523
free_contig_range+0xb6/0x190 mm/page_alloc.c:6569
destroy_args+0x7c9/0xa10 mm/debug_vm_pgtable.c:1028
debug_vm_pgtable+0x1d50/0x40e0 mm/debug_vm_pgtable.c:1408
do_one_initcall+0x128/0x670 init/main.c:1232
do_initcall_level init/main.c:1294 [inline]
do_initcalls init/main.c:1310 [inline]
do_basic_setup init/main.c:1329 [inline]
kernel_init_freeable+0x5c2/0x900 init/main.c:1547
kernel_init+0x1c/0x2a0 init/main.c:1437
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242

Memory state around the buggy address:
ffff888058af4f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888058af4f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888058af5000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888058af5080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888058af5100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Oct 31, 2023, 10:51:29 PM10/31/23
to linux-...@vger.kernel.org, net...@vger.kernel.org, richard...@gmail.com, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 89ed67ef126c Merge tag 'net-next-6.7' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1142a1a5680000
kernel config: https://syzkaller.appspot.com/x/.config?x=6e3b1d98cf5a2cca
dashboard link: https://syzkaller.appspot.com/bug?extid=8a676a50d4eee2f21539
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1751c63d680000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b69c238dd56a/disk-89ed67ef.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f555d654a8ba/vmlinux-89ed67ef.xz
kernel image: https://storage.googleapis.com/syzbot-assets/335bbfb6c442/bzImage-89ed67ef.xz

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

list_del corruption. next->prev should be ffff888020fe5048, but was ffff88807a0f9048. (next=ffff88802533e5e8)
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:67!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 5827 Comm: syz-executor.5 Not tainted 6.6.0-syzkaller-05843-g89ed67ef126c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
RIP: 0010:__list_del_entry_valid_or_report+0x122/0x130 lib/list_debug.c:65
Code: 85 06 0f 0b 48 c7 c7 20 5f 9d 8b 4c 89 fe 48 89 d9 e8 52 db 85 06 0f 0b 48 c7 c7 a0 5f 9d 8b 4c 89 fe 4c 89 f1 e8 3e db 85 06 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa 80 3d 1d 6e
RSP: 0018:ffffc9000aaa7db0 EFLAGS: 00010046
RAX: 000000000000006d RBX: ffff88802533e5f0 RCX: 88e517f49d581b00
RDX: 0000000000000000 RSI: 0000000080000001 RDI: 0000000000000000
RBP: ffff888020fe5008 R08: ffffffff81717aac R09: 1ffff92001554f54
R10: dffffc0000000000 R11: fffff52001554f55 R12: dffffc0000000000
R13: ffff888020fe4000 R14: ffff88802533e5e8 R15: ffff888020fe5048
FS: 0000555557106480(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f1cc2398000 CR3: 000000001cad1000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__list_del_entry_valid include/linux/list.h:124 [inline]
__list_del_entry include/linux/list.h:215 [inline]
list_del include/linux/list.h:229 [inline]
ptp_release+0xa8/0x1e0 drivers/ptp/ptp_chardev.c:147
posix_clock_release+0x8c/0x100 kernel/time/posix-clock.c:157
__fput+0x3cc/0xa10 fs/file_table.c:394
__do_sys_close fs/open.c:1590 [inline]
__se_sys_close+0x15f/0x220 fs/open.c:1575
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f1cc227b9da
Code: 48 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c 24 0c e8 03 7f 02 00 8b 7c 24 0c 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 63 7f 02 00 8b 44 24
RSP: 002b:00007ffe5d85d9f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f1cc227b9da
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000000032 R08: 0000001b30160000 R09: 00007f1cc239bf8c
R10: 00007ffe5d85db40 R11: 0000000000000293 R12: 00007f1cc1e001d8
R13: ffffffffffffffff R14: 00007f1cc1e00000 R15: 0000000000015db0
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__list_del_entry_valid_or_report+0x122/0x130 lib/list_debug.c:65
Code: 85 06 0f 0b 48 c7 c7 20 5f 9d 8b 4c 89 fe 48 89 d9 e8 52 db 85 06 0f 0b 48 c7 c7 a0 5f 9d 8b 4c 89 fe 4c 89 f1 e8 3e db 85 06 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa 80 3d 1d 6e
RSP: 0018:ffffc9000aaa7db0 EFLAGS: 00010046

RAX: 000000000000006d RBX: ffff88802533e5f0 RCX: 88e517f49d581b00
RDX: 0000000000000000 RSI: 0000000080000001 RDI: 0000000000000000
RBP: ffff888020fe5008 R08: ffffffff81717aac R09: 1ffff92001554f54
R10: dffffc0000000000 R11: fffff52001554f55 R12: dffffc0000000000
R13: ffff888020fe4000 R14: ffff88802533e5e8 R15: ffff888020fe5048
FS: 0000555557106480(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f1cc2398000 CR3: 000000001cad1000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

syzbot

unread,
Nov 1, 2023, 12:03:34 PM11/1/23
to linux-...@vger.kernel.org, net...@vger.kernel.org, richard...@gmail.com, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 89ed67ef126c Merge tag 'net-next-6.7' of git://git.kernel...
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=150b105f680000
kernel config: https://syzkaller.appspot.com/x/.config?x=6e3b1d98cf5a2cca
dashboard link: https://syzkaller.appspot.com/bug?extid=8a676a50d4eee2f21539
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13dd173b680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16ce0840e80000

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

list_del corruption. next->prev should be ffff88802a019048, but was ffff88802a401048. (next=ffff88802515e5e8)
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:67!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 6526 Comm: syz-executor155 Not tainted 6.6.0-syzkaller-05843-g89ed67ef126c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
RIP: 0010:__list_del_entry_valid_or_report+0x122/0x130 lib/list_debug.c:65
Code: 85 06 0f 0b 48 c7 c7 20 5f 9d 8b 4c 89 fe 48 89 d9 e8 52 db 85 06 0f 0b 48 c7 c7 a0 5f 9d 8b 4c 89 fe 4c 89 f1 e8 3e db 85 06 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa 80 3d 1d 6e
RSP: 0018:ffffc90009d67b18 EFLAGS: 00010046
RAX: 000000000000006d RBX: ffff88802515e5f0 RCX: 58e87076363f5a00
RDX: 0000000000000000 RSI: 0000000080000001 RDI: 0000000000000000
RBP: ffff88802a019008 R08: ffffffff81717aac R09: 1ffff920013acf04
R10: dffffc0000000000 R11: fffff520013acf05 R12: dffffc0000000000
R13: ffff88802a018000 R14: ffff88802515e5e8 R15: ffff88802a019048
FS: 0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ff08f2c4110 CR3: 0000000074918000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__list_del_entry_valid include/linux/list.h:124 [inline]
__list_del_entry include/linux/list.h:215 [inline]
list_del include/linux/list.h:229 [inline]
ptp_release+0xa8/0x1e0 drivers/ptp/ptp_chardev.c:147
posix_clock_release+0x8c/0x100 kernel/time/posix-clock.c:157
__fput+0x3cc/0xa10 fs/file_table.c:394
task_work_run+0x24a/0x300 kernel/task_work.c:180
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xa2c/0x2650 kernel/exit.c:874
do_group_exit+0x206/0x2c0 kernel/exit.c:1024
__do_sys_exit_group kernel/exit.c:1035 [inline]
__se_sys_exit_group kernel/exit.c:1033 [inline]
__x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1033
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7ff08f248bf9
Code: Unable to access opcode bytes at 0x7ff08f248bcf.
RSP: 002b:00007ffc5a8eb438 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ff08f248bf9
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 00007ff08f2c3290 R08: ffffffffffffffb8 R09: 00000000000000a0
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ff08f2c3290
R13: 0000000000000000 R14: 00007ff08f2c3d00 R15: 00007ff08f219da0
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__list_del_entry_valid_or_report+0x122/0x130 lib/list_debug.c:65
Code: 85 06 0f 0b 48 c7 c7 20 5f 9d 8b 4c 89 fe 48 89 d9 e8 52 db 85 06 0f 0b 48 c7 c7 a0 5f 9d 8b 4c 89 fe 4c 89 f1 e8 3e db 85 06 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa 80 3d 1d 6e
RSP: 0018:ffffc90009d67b18 EFLAGS: 00010046

RAX: 000000000000006d RBX: ffff88802515e5f0 RCX: 58e87076363f5a00
RDX: 0000000000000000 RSI: 0000000080000001 RDI: 0000000000000000
RBP: ffff88802a019008 R08: ffffffff81717aac R09: 1ffff920013acf04
R10: dffffc0000000000 R11: fffff520013acf05 R12: dffffc0000000000
R13: ffff88802a018000 R14: ffff88802515e5e8 R15: ffff88802a019048
FS: 0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ff08f2c4110 CR3: 0000000074918000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


syzbot

unread,
Nov 1, 2023, 6:21:05 PM11/1/23
to da...@davemloft.net, linux-...@vger.kernel.org, net...@vger.kernel.org, rei...@gmail.com, richard...@gmail.com, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 8f5de6fb245326704f37d91780b9a10253a8a100
Author: Xabier Marquiegui <rei...@gmail.com>
Date: Wed Oct 11 22:39:55 2023 +0000

ptp: support multiple timestamp event readers

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1019f36f680000
start commit: 89ed67ef126c Merge tag 'net-next-6.7' of git://git.kernel...
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=1219f36f680000
console output: https://syzkaller.appspot.com/x/log.txt?x=1419f36f680000
Reported-by: syzbot+8a676a...@syzkaller.appspotmail.com
Fixes: 8f5de6fb2453 ("ptp: support multiple timestamp event readers")

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

Hillf Danton

unread,
Nov 3, 2023, 8:01:26 AM11/3/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Wed, 01 Nov 2023 09:03:31 -0700
> HEAD commit: 89ed67ef126c Merge tag 'net-next-6.7' of git://git.kernel...
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16ce0840e80000

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

diff -pur x/drivers/ptp/ptp_chardev.c y/drivers/ptp/ptp_chardev.c
--- x/drivers/ptp/ptp_chardev.c 2023-11-03 19:50:17.982245800 +0800
+++ y/drivers/ptp/ptp_chardev.c 2023-11-03 19:53:45.968210400 +0800
@@ -108,6 +108,7 @@ int ptp_open(struct posix_clock_context
container_of(pccontext->clk, struct ptp_clock, clock);
struct timestamp_event_queue *queue;
char debugfsname[32];
+ unsigned long flags;

queue = kzalloc(sizeof(*queue), GFP_KERNEL);
if (!queue)
@@ -119,7 +120,9 @@ int ptp_open(struct posix_clock_context
}
bitmap_set(queue->mask, 0, PTP_MAX_CHANNELS);
spin_lock_init(&queue->lock);
+ spin_lock_irqsave(&ptp->qlock, flags);
list_add_tail(&queue->qlist, &ptp->tsevqs);
+ spin_unlock_irqrestore(&ptp->qlock, flags);
pccontext->private_clkdata = queue;

/* Debugfs contents */
@@ -139,13 +142,14 @@ int ptp_release(struct posix_clock_conte
{
struct timestamp_event_queue *queue = pccontext->private_clkdata;
unsigned long flags;
+ struct ptp_clock *ptp = container_of(pccontext->clk, struct ptp_clock, clock);

if (queue) {
debugfs_remove(queue->debugfs_instance);
pccontext->private_clkdata = NULL;
- spin_lock_irqsave(&queue->lock, flags);
+ spin_lock_irqsave(&ptp->qlock, flags);
list_del(&queue->qlist);
- spin_unlock_irqrestore(&queue->lock, flags);
+ spin_unlock_irqrestore(&ptp->qlock, flags);
bitmap_free(queue->mask);
kfree(queue);
}
diff -pur x/drivers/ptp/ptp_clock.c y/drivers/ptp/ptp_clock.c
--- x/drivers/ptp/ptp_clock.c 2023-11-03 19:50:48.632832100 +0800
+++ y/drivers/ptp/ptp_clock.c 2023-11-03 19:53:45.981719300 +0800
@@ -179,11 +179,10 @@ static void ptp_clock_release(struct dev
mutex_destroy(&ptp->pincfg_mux);
mutex_destroy(&ptp->n_vclocks_mux);
/* Delete first entry */
- tsevq = list_first_entry(&ptp->tsevqs, struct timestamp_event_queue,
- qlist);
- spin_lock_irqsave(&tsevq->lock, flags);
+ spin_lock_irqsave(&ptp->qlock, flags);
+ tsevq = list_first_entry(&ptp->tsevqs, struct timestamp_event_queue, qlist);
list_del(&tsevq->qlist);
- spin_unlock_irqrestore(&tsevq->lock, flags);
+ spin_unlock_irqrestore(&ptp->qlock, flags);
bitmap_free(tsevq->mask);
kfree(tsevq);
debugfs_remove(ptp->debugfs_root);
@@ -243,6 +242,7 @@ struct ptp_clock *ptp_clock_register(str
ptp->devid = MKDEV(major, index);
ptp->index = index;
INIT_LIST_HEAD(&ptp->tsevqs);
+ spin_lock_init(&ptp->qlock);
queue = kzalloc(sizeof(*queue), GFP_KERNEL);
if (!queue)
goto no_memory_queue;
@@ -407,6 +407,7 @@ void ptp_clock_event(struct ptp_clock *p
{
struct timestamp_event_queue *tsevq;
struct pps_event_time evt;
+ unsigned long flags;

switch (event->type) {

@@ -415,10 +416,12 @@ void ptp_clock_event(struct ptp_clock *p

case PTP_CLOCK_EXTTS:
/* Enqueue timestamp on selected queues */
+ spin_lock_irqsave(&ptp->qlock, flags);
list_for_each_entry(tsevq, &ptp->tsevqs, qlist) {
if (test_bit((unsigned int)event->index, tsevq->mask))
enqueue_external_timestamp(tsevq, event);
}
+ spin_unlock_irqrestore(&ptp->qlock, flags);
wake_up_interruptible(&ptp->tsev_wq);
break;

diff -pur x/drivers/ptp/ptp_private.h y/drivers/ptp/ptp_private.h
--- x/drivers/ptp/ptp_private.h 2023-11-03 19:52:09.501076900 +0800
+++ y/drivers/ptp/ptp_private.h 2023-11-03 19:53:45.997601200 +0800
@@ -41,6 +41,7 @@ struct ptp_clock {
struct ptp_clock_info *info;
dev_t devid;
int index; /* index into clocks.map */
+ spinlock_t qlock;
struct pps_device *pps_source;
long dialed_frequency; /* remembers the frequency adjustment */
struct list_head tsevqs; /* timestamp fifo list */
--

syzbot

unread,
Nov 3, 2023, 8:21:05 AM11/3/23
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+8a676a...@syzkaller.appspotmail.com

Tested on:

commit: 8f6f76a6 Merge tag 'mm-nonmm-stable-2023-11-02-14-08' ..
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=17f42af3680000
kernel config: https://syzkaller.appspot.com/x/.config?x=94632a8e2ffd08bb
dashboard link: https://syzkaller.appspot.com/bug?extid=8a676a50d4eee2f21539
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1700153d680000

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

syzbot

unread,
Dec 11, 2023, 12:37:08 AM12/11/23
to da...@davemloft.net, ead...@qq.com, hda...@sina.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, rei...@gmail.com, richard...@gmail.com, syzkall...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 1bea2c3e6df8caf45d18384abfb707f47e9ff993
Author: Edward Adam Davis <ead...@qq.com>
Date: Tue Nov 7 08:00:41 2023 +0000

ptp: fix corrupted list in ptp_open

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=145ba76ce80000
start commit: 6bc986ab839c Merge tag 'nfs-for-6.7-1' of git://git.linux-..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=1ffa1cec3b40f3ce
dashboard link: https://syzkaller.appspot.com/bug?extid=8a676a50d4eee2f21539
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17cc14a8e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11ade40f680000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: ptp: fix corrupted list in ptp_open

syzbot

unread,
Jan 19, 2024, 5:59:11 AMJan 19
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages