[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240312132107.GA1529@breakpoint.cc>
Date: Tue, 12 Mar 2024 14:21:07 +0100
From: Florian Westphal <fw@...len.de>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Florian Westphal <fw@...len.de>, xingwei lee <xrivendell7@...il.com>,
pabeni@...hat.com, davem@...emloft.net, kuba@...nel.org,
linux-hams@...r.kernel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, ralf@...ux-mips.org,
syzkaller-bugs@...glegroups.com, samsun1006219@...il.com
Subject: Re: KASAN: slab-use-after-free Read in ip_finish_output
Eric Dumazet <edumazet@...gle.com> wrote:
> > 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.
I tried to follow this but its beyond my abilities.
Defrag messes with skb->truesize, and I do not know how to
fix that up safely so later calls to destructor won't underflow sk
accouting.
Furthermore, depending on delivery order, the skb that gets
passed to rest of stack might not be the head skb (the one with
full l4 header and sk reference), its always the last one that arrived.
Existing code skb_morphs() this, see inet_frag_reasm_prepare() and also
the ->truesize munging (which is fine only because all skbs are
orphans...).
So in order to not pass already-released sk to inet output somehow
the skb->sk reference needs to be stolen and moved from one sk
to another.
No idea how to do this, let alone do regression testing for this.
see e.g. 48cac18ecf1de82f76259a54402c3adb7839ad01 which added
unconditional orphaning in ipv6 netfilter defrag.
ATM the only "solution" I see is to completely remove netfilter defrag
support for outgoing packets.
Powered by blists - more mailing lists