mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption
       [not found]   ` <179110850671.434549.2584497019282941556@kernel.org>
@ 2026-10-08  1:49     ` Qihang
  2026-10-12  7:54       ` Steffen Klassert
  0 siblings, 1 reply; 6+ messages in thread
From: Qihang @ 2026-10-08  1:49 UTC (permalink / raw)
  To: netdev
  Cc: David Ahern, Ido Schimmel, Steffen Klassert, Herbert Xu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, linux-kernel

All real, and vti6 has the same problems.

The dev_hold()/dev_put() idea assumed the callback runs exactly once
per skb, which xfrm_input() doesn't guarantee. IPTFS frees the outer
skb on its own without any callback. The early drop when the SA is no
longer valid happens while family is still AF_UNSPEC, so xfrm_rcv_cb()
can't find the afinfo and never calls us. And on the success path I'd
drop the last reference before gro_cells_receive() is done with
skb->dev.

So I'll drop this. Two options I can see for the respin:

Re-lookup the tunnel in the callback like xfrmi does. The only key I
have there is the outer addresses of the state, which won't reproduce
the original lookup for wildcard-source SAs, and during teardown it
can pick up the fallback device instead. The RCU section also ends at
gro_cells_receive(): the skb queued to the gro cell is processed by
NAPI afterwards with skb->dev still pointing at the tunnel device and
nothing holding a reference.

Keep a reference from vti_input() but release it when the skb is freed
instead of in the callback, so the paths where the callback never runs
can't leak. That looks like it needs xfrm core support, so I'd rather
not pick it unilaterally.

Which way do you want this to go?

pw-bot: cr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption
  2026-10-08  1:49     ` [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption Qihang
@ 2026-10-12  7:54       ` Steffen Klassert
  2026-10-12  9:07         ` Qihang
  0 siblings, 1 reply; 6+ messages in thread
From: Steffen Klassert @ 2026-10-12  7:54 UTC (permalink / raw)
  To: Qihang
  Cc: netdev, David Ahern, Ido Schimmel, Herbert Xu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	linux-kernel

On Thu, Oct 08, 2026 at 01:49:16AM +0000, Qihang wrote:
> All real, and vti6 has the same problems.
> 
> The dev_hold()/dev_put() idea assumed the callback runs exactly once
> per skb, which xfrm_input() doesn't guarantee. IPTFS frees the outer
> skb on its own without any callback.

This is a IPTFS bug. If IPTFS frees the skb, it has to make sure
to run the whole destruction path including all the callbacks.

> The early drop when the SA is no
> longer valid happens while family is still AF_UNSPEC, so xfrm_rcv_cb()
> can't find the afinfo and never calls us.

Assigning family before the early drop should fix this.

> And on the success path I'd
> drop the last reference before gro_cells_receive() is done with
> skb->dev.

I think we should unconditionally refcount skb->dev in the
xfrm input path to fix that for now.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption
  2026-10-12  7:54       ` Steffen Klassert
@ 2026-10-12  9:07         ` Qihang
  2026-10-12 10:13           ` Steffen Klassert
  0 siblings, 1 reply; 6+ messages in thread
From: Qihang @ 2026-10-12  9:07 UTC (permalink / raw)
  To: Steffen Klassert
  Cc: netdev, David Ahern, Ido Schimmel, Herbert Xu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	linux-kernel

Hi Steffen,

Thanks a lot for the guidance, much appreciated.

Your three points make sense. For IPTFS, the skbs freed without the
receive callback are the outer xfrm skbs, and it's only a handful of
places in xfrm_iptfs.c -- a small shared helper would be cleaner than
open-coding it at each site.  The two xfrm_input changes (set family
before the early drop, and hold the skb->dev reference unconditionally)
look straightforward too.

Would you prefer to handle the IPTFS and xfrm_input fixes yourself
(Christian for IPTFS?), or should I send them as part of this series?
Either way is fine with me.

Thanks again,
Qihang

On Mon, Oct 12, 2026 at 3:54 PM Steffen Klassert
<steffen.klassert@secunet.com> wrote:
>
> On Thu, Oct 08, 2026 at 01:49:16AM +0000, Qihang wrote:
> > All real, and vti6 has the same problems.
> >
> > The dev_hold()/dev_put() idea assumed the callback runs exactly once
> > per skb, which xfrm_input() doesn't guarantee. IPTFS frees the outer
> > skb on its own without any callback.
>
> This is a IPTFS bug. If IPTFS frees the skb, it has to make sure
> to run the whole destruction path including all the callbacks.
>
> > The early drop when the SA is no
> > longer valid happens while family is still AF_UNSPEC, so xfrm_rcv_cb()
> > can't find the afinfo and never calls us.
>
> Assigning family before the early drop should fix this.
>
> > And on the success path I'd
> > drop the last reference before gro_cells_receive() is done with
> > skb->dev.
>
> I think we should unconditionally refcount skb->dev in the
> xfrm input path to fix that for now.
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption
  2026-10-12  9:07         ` Qihang
@ 2026-10-12 10:13           ` Steffen Klassert
  2026-10-12 11:21             ` Qihang
  0 siblings, 1 reply; 6+ messages in thread
From: Steffen Klassert @ 2026-10-12 10:13 UTC (permalink / raw)
  To: Qihang
  Cc: netdev, David Ahern, Ido Schimmel, Herbert Xu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	linux-kernel

On Mon, Oct 12, 2026 at 05:07:43PM +0800, Qihang wrote:
> Hi Steffen,
> 
> Thanks a lot for the guidance, much appreciated.
> 
> Your three points make sense. For IPTFS, the skbs freed without the
> receive callback are the outer xfrm skbs, and it's only a handful of
> places in xfrm_iptfs.c -- a small shared helper would be cleaner than
> open-coding it at each site.  The two xfrm_input changes (set family
> before the early drop, and hold the skb->dev reference unconditionally)
> look straightforward too.
> 
> Would you prefer to handle the IPTFS and xfrm_input fixes yourself
> (Christian for IPTFS?), or should I send them as part of this series?
> Either way is fine with me.

I'll handle the full patchset, but Cc Chris on IPTFS.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption
  2026-10-12 10:13           ` Steffen Klassert
@ 2026-10-12 11:21             ` Qihang
  2026-10-12 11:25               ` Steffen Klassert
  0 siblings, 1 reply; 6+ messages in thread
From: Qihang @ 2026-10-12 11:21 UTC (permalink / raw)
  To: Steffen Klassert
  Cc: netdev, David Ahern, Ido Schimmel, Herbert Xu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	linux-kernel, Christian Hopps

Hi Steffen,

Sounds good -- thanks for taking the patchset.  Ccing Chris on the IPTFS
part makes sense.  I'll follow the thread, and I'm happy to review it
if that helps.

Qihang

On Mon, Oct 12, 2026 at 6:13 PM Steffen Klassert
<steffen.klassert@secunet.com> wrote:
>
> On Mon, Oct 12, 2026 at 05:07:43PM +0800, Qihang wrote:
> > Hi Steffen,
> >
> > Thanks a lot for the guidance, much appreciated.
> >
> > Your three points make sense. For IPTFS, the skbs freed without the
> > receive callback are the outer xfrm skbs, and it's only a handful of
> > places in xfrm_iptfs.c -- a small shared helper would be cleaner than
> > open-coding it at each site.  The two xfrm_input changes (set family
> > before the early drop, and hold the skb->dev reference unconditionally)
> > look straightforward too.
> >
> > Would you prefer to handle the IPTFS and xfrm_input fixes yourself
> > (Christian for IPTFS?), or should I send them as part of this series?
> > Either way is fine with me.
>
> I'll handle the full patchset, but Cc Chris on IPTFS.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption
  2026-10-12 11:21             ` Qihang
@ 2026-10-12 11:25               ` Steffen Klassert
  0 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2026-10-12 11:25 UTC (permalink / raw)
  To: Qihang
  Cc: netdev, David Ahern, Ido Schimmel, Herbert Xu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	linux-kernel, Christian Hopps

On Mon, Oct 12, 2026 at 07:21:57PM +0800, Qihang wrote:
> Hi Steffen,
> 
> Sounds good -- thanks for taking the patchset.  Ccing Chris on the IPTFS
> part makes sense.  I'll follow the thread, and I'm happy to review it
> if that helps.

I'll handle the patchset once you've sent an updated version.
I'm reviewing and applyig the patches, but you have to submit it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-12 11:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20260930090813.73901-1-q.h.hack.winter@gmail.com>
     [not found] ` <20260930090813.73901-2-q.h.hack.winter@gmail.com>
     [not found]   ` <179110850671.434549.2584497019282941556@kernel.org>
2026-10-08  1:49     ` [PATCH net 1/2] vti: fix tunnel device use-after-free across async crypto resumption Qihang
2026-10-12  7:54       ` Steffen Klassert
2026-10-12  9:07         ` Qihang
2026-10-12 10:13           ` Steffen Klassert
2026-10-12 11:21             ` Qihang
2026-10-12 11:25               ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®