linux-hams.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Eric Dumazet <edumazet@google.com>
Cc: Florian Westphal <fw@strlen.de>,
	xingwei lee <xrivendell7@gmail.com>,
	pabeni@redhat.com, davem@davemloft.net, kuba@kernel.org,
	linux-hams@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, ralf@linux-mips.org,
	syzkaller-bugs@googlegroups.com, samsun1006219@gmail.com
Subject: Re: KASAN: slab-use-after-free Read in ip_finish_output
Date: Tue, 12 Mar 2024 14:21:07 +0100	[thread overview]
Message-ID: <20240312132107.GA1529@breakpoint.cc> (raw)
In-Reply-To: <CANn89iLe0KGjbSim5Qxxr6o0AjJVs7-h79UvMMXKOgGKQUosiA@mail.gmail.com>

Eric Dumazet <edumazet@google.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.

  reply	other threads:[~2024-03-12 13:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 10:00 KASAN: slab-use-after-free Read in ip_finish_output xingwei lee
2024-03-06 10:07 ` Eric Dumazet
2024-03-06 10:36   ` Florian Westphal
2024-03-06 10:41     ` Eric Dumazet
2024-03-12 13:21       ` Florian Westphal [this message]
2024-03-12 13:48         ` Eric Dumazet
2024-03-12 14:30           ` Florian Westphal
2024-03-14 11:26           ` Florian Westphal
2024-03-15  0:07             ` Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240312132107.GA1529@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-hams@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ralf@linux-mips.org \
    --cc=samsun1006219@gmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=xrivendell7@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).