Re: KASAN: slab-use-after-free Read in ip_finish_output
From: Eric Dumazet <edumazet@google.com>
Date: 2024-03-06 10:41:52
Also in:
linux-hams, lkml
On Wed, Mar 6, 2024 at 11:36 AM Florian Westphal [off-list ref] wrote:
Eric Dumazet [off-list ref] wrote:quoted
On Wed, Mar 6, 2024 at 11:00 AM xingwei lee [off-list ref] wrote:quoted
Hello, I found a new bug titled "KASAN: slab-use-after-free Read in ip_finish_output” or “KASAN: slab-use-after-free in sk_to_full_sk" and confirmed it in the latest net and net-next branch. After my simple analysis, it may be related to the net/rose or AF_PACKET/PF_PACKET socket.I already had a syzbot report for this issue, thanks. Adding Florian to the discussion. The issue is cause by ip defrag layer, which calls skb_orphan() These were my notes, I had little time to work on it so far.quoted
Calling ip_defrag() in output path is also implying skb_orphan(), which is buggy because output path relies on sk not disappearing.Ugh. Thanks for your annotations and notes, this is very helpful. ipvlan (and two spots in ip_output.c do): err = ip_local_out(net, skb->sk, skb); so skb->sk gets propagated down to __ip_finish_output(), long after connrack defrag has called skb_orphan(). No idea yet how to fix it,
My plan was to refine "inet: frag: Always orphan skbs inside ip_defrag()" and only do the skb_orphan() for skb added to a frag_list. The head skb would keep a reference to the socket.