Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in __unix_gc
From: Hillf Danton
Date: Sat Feb 10 2024 - 05:07:34 EST
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/20240209220453.96053-1-kuniyu@xxxxxxxxxx/
#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);
}
--