Subject: Re: KASAN: slab-use-after-free Read in ip_finish_output

From: Florian Westphal <[email-masked]>
Date: Wed, 6 Mar 2024 11:36:32 +0100

Eric Dumazet <[email-masked]> wrote:
> On Wed, Mar 6, 2024 at 11:00 AM xingwei lee <[email-masked]> wrote:
> >
> > 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.

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