2024-02-09 14:57:46

by syzbot

[permalink] [raw]
Subject: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

Hello,

syzbot found the following issue on:

HEAD commit: e7689879d14e ethtool: do not use rtnl in ethnl_default_dum..
git tree: net-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1195b6e0180000
kernel config: https://syzkaller.appspot.com/x/.config?x=ac1116e4986e7570
dashboard link: https://syzkaller.appspot.com/bug?extid=5a630f8ca0120ab43f55
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=121d9b5c180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=165f9cec180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c5b791d72e1e/disk-e7689879.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/472cf2131e7b/vmlinux-e7689879.xz
kernel image: https://storage.googleapis.com/syzbot-assets/c1e5a4b33244/bzImage-e7689879.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

==================================================================
BUG: KASAN: slab-use-after-free in __unix_gc+0xe0f/0xf70
Read of size 8 at addr ffff8880237e3640 by task kworker/u4:4/59

CPU: 0 PID: 59 Comm: kworker/u4:4 Not tainted 6.8.0-rc3-syzkaller-00766-ge7689879d14e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Workqueue: events_unbound __unix_gc
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:377 [inline]
print_report+0x167/0x540 mm/kasan/report.c:488
kasan_report+0x142/0x180 mm/kasan/report.c:601
__unix_gc+0xe0f/0xf70
process_one_work kernel/workqueue.c:2633 [inline]
process_scheduled_works+0x913/0x1420 kernel/workqueue.c:2706
worker_thread+0xa5f/0x1000 kernel/workqueue.c:2787
kthread+0x2ef/0x390 kernel/kthread.c:388
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242
</TASK>

Allocated by task 5076:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
unpoison_slab_object mm/kasan/common.c:314 [inline]
__kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:340
kasan_slab_alloc include/linux/kasan.h:201 [inline]
slab_post_alloc_hook mm/slub.c:3813 [inline]
slab_alloc_node mm/slub.c:3860 [inline]
kmem_cache_alloc+0x16f/0x340 mm/slub.c:3867
sk_prot_alloc+0x58/0x210 net/core/sock.c:2073
sk_alloc+0x38/0x370 net/core/sock.c:2132
unix_create1+0xb4/0x7f0
unix_create+0x14e/0x200 net/unix/af_unix.c:1047
__sock_create+0x48f/0x920 net/socket.c:1571
sock_create net/socket.c:1622 [inline]
__sys_socketpair+0x33d/0x720 net/socket.c:1773
__do_sys_socketpair net/socket.c:1822 [inline]
__se_sys_socketpair net/socket.c:1819 [inline]
__x64_sys_socketpair+0x9b/0xb0 net/socket.c:1819
do_syscall_64+0xf9/0x240
entry_SYSCALL_64_after_hwframe+0x6f/0x77

Freed by task 23:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
kasan_save_free_info+0x4e/0x60 mm/kasan/generic.c:640
poison_slab_object+0xa6/0xe0 mm/kasan/common.c:241
__kasan_slab_free+0x34/0x70 mm/kasan/common.c:257
kasan_slab_free include/linux/kasan.h:184 [inline]
slab_free_hook mm/slub.c:2121 [inline]
slab_free mm/slub.c:4299 [inline]
kmem_cache_free+0x102/0x2a0 mm/slub.c:4363
sk_prot_free net/core/sock.c:2113 [inline]
__sk_destruct+0x470/0x5f0 net/core/sock.c:2207
sock_put include/net/sock.h:1961 [inline]
unix_release_sock+0x903/0xd20 net/unix/af_unix.c:649
unix_release+0x91/0xc0 net/unix/af_unix.c:1062
__sock_release net/socket.c:659 [inline]
sock_close+0xbc/0x240 net/socket.c:1421
__fput+0x429/0x8a0 fs/file_table.c:376
delayed_fput+0x59/0x80 fs/file_table.c:399
process_one_work kernel/workqueue.c:2633 [inline]
process_scheduled_works+0x913/0x1420 kernel/workqueue.c:2706
worker_thread+0xa5f/0x1000 kernel/workqueue.c:2787
kthread+0x2ef/0x390 kernel/kthread.c:388
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242

The buggy address belongs to the object at ffff8880237e3000
which belongs to the cache UNIX-STREAM of size 1920
The buggy address is located 1600 bytes inside of
freed 1920-byte region [ffff8880237e3000, ffff8880237e3780)

The buggy address belongs to the physical page:
page:ffffea00008df800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x237e0
head:ffffea00008df800 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 ffff8880183aa280 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080100010 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 5069, tgid 5069 (sftp-server), ts 69550911589, free_ts 69532294849
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533
prep_new_page mm/page_alloc.c:1540 [inline]
get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311
__alloc_pages+0x255/0x680 mm/page_alloc.c:4567
__alloc_pages_node include/linux/gfp.h:238 [inline]
alloc_pages_node include/linux/gfp.h:261 [inline]
alloc_slab_page+0x5f/0x160 mm/slub.c:2190
allocate_slab mm/slub.c:2354 [inline]
new_slab+0x84/0x2f0 mm/slub.c:2407
___slab_alloc+0xd17/0x13e0 mm/slub.c:3540
__slab_alloc mm/slub.c:3625 [inline]
__slab_alloc_node mm/slub.c:3678 [inline]
slab_alloc_node mm/slub.c:3850 [inline]
kmem_cache_alloc+0x24d/0x340 mm/slub.c:3867
sk_prot_alloc+0x58/0x210 net/core/sock.c:2073
sk_alloc+0x38/0x370 net/core/sock.c:2132
unix_create1+0xb4/0x7f0
unix_stream_connect+0x348/0x1110 net/unix/af_unix.c:1511
__sys_connect_file net/socket.c:2048 [inline]
__sys_connect+0x2df/0x310 net/socket.c:2065
__do_sys_connect net/socket.c:2075 [inline]
__se_sys_connect net/socket.c:2072 [inline]
__x64_sys_connect+0x7a/0x90 net/socket.c:2072
do_syscall_64+0xf9/0x240
entry_SYSCALL_64_after_hwframe+0x6f/0x77
page last free pid 5069 tgid 5069 stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1140 [inline]
free_unref_page_prepare+0x968/0xa90 mm/page_alloc.c:2346
free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486
discard_slab mm/slub.c:2453 [inline]
__put_partials+0xeb/0x130 mm/slub.c:2922
put_cpu_partial+0x17b/0x250 mm/slub.c:2997
__slab_free+0x302/0x410 mm/slub.c:4166
qlink_free mm/kasan/quarantine.c:160 [inline]
qlist_free_all+0x6d/0xd0 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:324
kasan_slab_alloc include/linux/kasan.h:201 [inline]
slab_post_alloc_hook mm/slub.c:3813 [inline]
slab_alloc_node mm/slub.c:3860 [inline]
kmem_cache_alloc+0x16f/0x340 mm/slub.c:3867
vm_area_alloc+0x24/0x1d0 kernel/fork.c:465
mmap_region+0xbd8/0x1fa0 mm/mmap.c:2806
do_mmap+0x7ae/0xe60 mm/mmap.c:1379
vm_mmap_pgoff+0x1e2/0x420 mm/util.c:556
ksys_mmap_pgoff+0x503/0x6e0 mm/mmap.c:1425
do_syscall_64+0xf9/0x240
entry_SYSCALL_64_after_hwframe+0x6f/0x77

Memory state around the buggy address:
ffff8880237e3500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880237e3580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880237e3600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880237e3680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880237e3700: 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 [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

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

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.

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

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

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


2024-02-10 02:25:58

by Hillf Danton

[permalink] [raw]
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

On Fri, 09 Feb 2024 06:57:17 -0800
> HEAD commit: e7689879d14e ethtool: do not use rtnl in ethnl_default_dum..
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=165f9cec180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git e7689879d14e

--- x/net/unix/garbage.c
+++ y/net/unix/garbage.c
@@ -119,6 +119,7 @@ void unix_inflight(struct user_struct *u
if (!u->inflight) {
WARN_ON_ONCE(!list_empty(&u->link));
list_add_tail(&u->link, &gc_inflight_list);
+ sock_hold(&u->sk);
} else {
WARN_ON_ONCE(list_empty(&u->link));
}
@@ -350,6 +351,11 @@ static void __unix_gc(struct work_struct
}
#endif

+ list_for_each_entry_safe(u, next, &gc_candidates, link) {
+ list_del(&u->link);
+ sock_put(&u->sk);
+ }
+
spin_lock(&unix_gc_lock);

/* All candidates should have been detached by now. */
--

2024-02-10 04:08:13

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to checkout kernel repo https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git on commit e7689879d14e: failed to run ["git" "fetch" "--force" "--tags" "ee231638377c5338d84cc90b6c821555f8e3813f" "e7689879d14e"]: exit status 128
fatal: couldn't find remote ref e7689879d14e



Tested on:

commit: [unknown
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git e7689879d14e
kernel config: https://syzkaller.appspot.com/x/.config?x=ac1116e4986e7570
dashboard link: https://syzkaller.appspot.com/bug?extid=5a630f8ca0120ab43f55
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=16f3d320180000


2024-02-10 06:41:18

by Hillf Danton

[permalink] [raw]
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

On Fri, 09 Feb 2024 06:57:17 -0800
> HEAD commit: e7689879d14e ethtool: do not use rtnl in ethnl_default_dum..
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=165f9cec180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main

--- x/net/unix/garbage.c
+++ y/net/unix/garbage.c
@@ -119,6 +119,7 @@ void unix_inflight(struct user_struct *u
if (!u->inflight) {
WARN_ON_ONCE(!list_empty(&u->link));
list_add_tail(&u->link, &gc_inflight_list);
+ sock_hold(&u->sk);
} else {
WARN_ON_ONCE(list_empty(&u->link));
}
@@ -350,6 +351,11 @@ static void __unix_gc(struct work_struct
}
#endif

+ list_for_each_entry_safe(u, next, &gc_candidates, link) {
+ list_del(&u->link);
+ sock_put(&u->sk);
+ }
+
spin_lock(&unix_gc_lock);

/* All candidates should have been detached by now. */
--

2024-02-10 07:03:20

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
INFO: task hung in unix_stream_sendmsg

INFO: task syz-executor.0:7136 blocked for more than 143 seconds.
Not tainted 6.8.0-rc3-syzkaller-00811-gb63cc73341e0-dirty #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor.0 state:D stack:25200 pid:7136 tgid:7135 ppid:5423 flags:0x00004006
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5400 [inline]
__schedule+0x17d1/0x49f0 kernel/sched/core.c:6727
__schedule_loop kernel/sched/core.c:6802 [inline]
schedule+0x149/0x260 kernel/sched/core.c:6817
schedule_timeout+0xb0/0x310 kernel/time/timer.c:2159
do_wait_for_common kernel/sched/completion.c:95 [inline]
__wait_for_common kernel/sched/completion.c:116 [inline]
wait_for_common kernel/sched/completion.c:127 [inline]
wait_for_completion+0x354/0x620 kernel/sched/completion.c:148
__flush_work+0x950/0xad0 kernel/workqueue.c:3410
unix_stream_sendmsg+0x1c3/0xe60 net/unix/af_unix.c:2264
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x221/0x270 net/socket.c:745
____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
___sys_sendmsg net/socket.c:2638 [inline]
__sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
do_syscall_64+0xf9/0x240
entry_SYSCALL_64_after_hwframe+0x6f/0x77
RIP: 0033:0x7f5b08e7dda9
RSP: 002b:00007f5b09cb70c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f5b08fabf80 RCX: 00007f5b08e7dda9
RDX: 0000000020004005 RSI: 0000000020000280 RDI: 0000000000000004
RBP: 00007f5b08eca47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f5b08fabf80 R15: 00007fffbd0155e8
</TASK>

Showing all locks held in the system:
1 lock held by khungtaskd/29:
#0: ffffffff8e130ae0 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:298 [inline]
#0: ffffffff8e130ae0 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:750 [inline]
#0: ffffffff8e130ae0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x55/0x2a0 kernel/locking/lockdep.c:6614
2 locks held by kworker/u4:7/2789:
2 locks held by getty/4819:
#0: ffff88802a9d20a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x25/0x70 drivers/tty/tty_ldisc.c:243
#1: ffffc90002efe2f0 (&ldata->atomic_read_lock){+.+.}-{3:3}, at: n_tty_read+0x6b4/0x1e10 drivers/tty/n_tty.c:2201

=============================================

NMI backtrace for cpu 1
CPU: 1 PID: 29 Comm: khungtaskd Not tainted 6.8.0-rc3-syzkaller-00811-gb63cc73341e0-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106
nmi_cpu_backtrace+0x49c/0x4d0 lib/nmi_backtrace.c:113
nmi_trigger_cpumask_backtrace+0x198/0x320 lib/nmi_backtrace.c:62
trigger_all_cpu_backtrace include/linux/nmi.h:160 [inline]
check_hung_uninterruptible_tasks kernel/hung_task.c:222 [inline]
watchdog+0xfaf/0xff0 kernel/hung_task.c:379
kthread+0x2ef/0x390 kernel/kthread.c:388
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242
</TASK>
Sending NMI from CPU 1 to CPUs 0:
NMI backtrace for cpu 0
CPU: 0 PID: 132 Comm: kworker/u4:5 Not tainted 6.8.0-rc3-syzkaller-00811-gb63cc73341e0-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Workqueue: bat_events batadv_nc_worker
RIP: 0010:lockdep_hardirqs_on+0x71/0x140 kernel/locking/lockdep.c:4409
Code: c0 75 74 65 8b 05 c7 28 9b 74 85 c0 75 69 83 3d 04 35 e1 08 00 75 2e 48 c7 04 24 00 00 00 00 9c 8f 04 24 f7 04 24 00 02 00 00 <75> 67 83 3d e6 34 e1 08 00 75 10 48 8b 83 98 0a 00 00 48 3b 83 b0
RSP: 0018:ffffc90002d57a18 EFLAGS: 00000046
RAX: 0000000000000000 RBX: ffff88801cf7bb80 RCX: ffffffff8171840a
RDX: dffffc0000000000 RSI: ffffffff8baac760 RDI: ffffffff81592108
RBP: ffffc90002d57af0 R08: ffffffff92c914f7 R09: 1ffffffff259229e
R10: dffffc0000000000 R11: fffffbfff259229f R12: dffffc0000000000
R13: 1ffff920005aaf50 R14: ffffffff81592108 R15: 0000000000000201
FS: 0000000000000000(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f210bda80c0 CR3: 000000000df32000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<NMI>
</NMI>
<TASK>
__local_bh_enable_ip+0x168/0x200 kernel/softirq.c:386
spin_unlock_bh include/linux/spinlock.h:396 [inline]
batadv_nc_purge_paths+0x30f/0x3b0 net/batman-adv/network-coding.c:471
batadv_nc_worker+0x328/0x610 net/batman-adv/network-coding.c:720
process_one_work kernel/workqueue.c:2633 [inline]
process_scheduled_works+0x913/0x1420 kernel/workqueue.c:2706
worker_thread+0xa5f/0x1000 kernel/workqueue.c:2787
kthread+0x2ef/0x390 kernel/kthread.c:388
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242
</TASK>


Tested on:

commit: b63cc733 net: phy: realtek: use generic MDIO helpers t..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
console output: https://syzkaller.appspot.com/x/log.txt?x=16d4bd20180000
kernel config: https://syzkaller.appspot.com/x/.config?x=ac1116e4986e7570
dashboard link: https://syzkaller.appspot.com/bug?extid=5a630f8ca0120ab43f55
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=15e9e3a2180000


2024-02-10 08:11:17

by Kuniyuki Iwashima

[permalink] [raw]
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

From: syzbot <[email protected]>
Date: Fri, 09 Feb 2024 06:57:17 -0800
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: e7689879d14e ethtool: do not use rtnl in ethnl_default_dum..
> git tree: net-next
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=1195b6e0180000
> kernel config: https://syzkaller.appspot.com/x/.config?x=ac1116e4986e7570
> dashboard link: https://syzkaller.appspot.com/bug?extid=5a630f8ca0120ab43f55
> 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=121d9b5c180000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=165f9cec180000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/c5b791d72e1e/disk-e7689879.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/472cf2131e7b/vmlinux-e7689879.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/c1e5a4b33244/bzImage-e7689879.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> ==================================================================
> BUG: KASAN: slab-use-after-free in __unix_gc+0xe0f/0xf70

#syz dup: INFO: task hung in unix_dgram_sendmsg

Here's a fix.
https://lore.kernel.org/netdev/[email protected]/

Thanks!

2024-02-10 10:14:57

by Hillf Danton

[permalink] [raw]
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

On Fri, 09 Feb 2024 06:57:17 -0800
> HEAD commit: e7689879d14e ethtool: do not use rtnl in ethnl_default_dum..
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=165f9cec180000

Test KI's fix [1].

[1] https://lore.kernel.org/netdev/[email protected]/

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main

--- x/net/unix/garbage.c
+++ y/net/unix/garbage.c
@@ -340,10 +340,11 @@ static void __unix_gc(struct work_struct
__skb_queue_purge(&hitlist);

#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
- list_for_each_entry_safe(u, next, &gc_candidates, link) {
- struct sk_buff *skb = u->oob_skb;
+ while (!list_empty(&gc_candidates)) {
+ u = list_entry(gc_candidates.next, struct unix_sock, link);
+ if (u->oob_skb) {
+ struct sk_buff *skb = u->oob_skb;

- if (skb) {
u->oob_skb = NULL;
kfree_skb(skb);
}
--

2024-02-10 11:39:13

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc

Hello,

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

Reported-and-tested-by: [email protected]

Tested on:

commit: b63cc733 net: phy: realtek: use generic MDIO helpers t..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
console output: https://syzkaller.appspot.com/x/log.txt?x=119e6c42180000
kernel config: https://syzkaller.appspot.com/x/.config?x=ac1116e4986e7570
dashboard link: https://syzkaller.appspot.com/bug?extid=5a630f8ca0120ab43f55
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12fb6de0180000

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