Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
       [not found] <6afdcf01.ca6cd63e.174a34.0001.GAE@google.com>
@ 2026-11-19  5:08 ` Shuai Liu
  2026-11-25 12:22   ` Paolo Abeni
  2026-11-26  9:00   ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 7+ messages in thread
From: Shuai Liu @ 2026-11-19  5:08 UTC (permalink / raw)
  To: netdev, steffen.klassert
  Cc: herbert, edumazet, kuba, pabeni, horms, q.h.hack.winter, stable,
	syzbot+d29af9ef5c96a3f5e96c, Shuai Liu

AF_XDP sockets bound to an xfrm interface submit skbs with
skb->protocol unset (0) and skb->network_header still 0 from the
__alloc_skb() zero-initialization; skb_reserve() only moves data
NET_SKB_PAD bytes into the headroom.

Since commit 86de3a1118a16 ("xfrm: interface: validate the IP header
on xmit"), xfrmi_xmit() calls pskb_inet_may_pull() unconditionally.
For such a skb, pskb_inet_may_pull_reason() selects nhlen = 0 for the
unknown protocol and pskb_may_pull_reason() receives
len = skb_network_offset(skb) = network_header - data = -64, which as
unsigned int exceeds INT_MAX and trips the
DEBUG_NET_WARN_ON_ONCE(len > INT_MAX) in pskb_may_pull_reason():

  WARNING: ./include/linux/skbuff.h:2856 at pskb_may_pull_reason [inline]
  WARNING: ./include/linux/skbuff.h:3286 at pskb_network_may_pull_reason [inline]
  WARNING: ./include/net/ip_tunnels.h:483 at pskb_inet_may_pull_reason [inline]
  WARNING: ./include/net/ip_tunnels.h:488 at pskb_inet_may_pull [inline]
  WARNING: ./include/net/ip_tunnels.h:488 at xfrmi_xmit+0x1844/0x1eb0
    net/xfrm/xfrm_interface_core.c:534
  RIP: 0010:pskb_may_pull_reason include/linux/skbuff.h:2856 [inline]
  Call Trace:
   __dev_direct_xmit+0x4b6/0x730 net/core/dev.c:5164
   __xsk_generic_xmit net/xdp/xsk.c:1288 [inline]
   xsk_generic_xmit+0x27d8/0x47a0 net/xdp/xsk.c:1344
   xsk_poll+0x326/0x670 net/xdp/xsk.c:1472

The packet is dropped by the pull returning PKT_TOO_SMALL and hitting
the default case afterwards anyway, so the only visible effect is the
warning; reject unknown protocols before the pull to restore the
pre-86de3a1118a16 behavior of dropping them silently via the switch
default.

Reported-by: syzbot+d29af9ef5c96a3f5e96c@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=d29af9ef5c96a3f5e96c
Fixes: 86de3a1118a16 ("xfrm: interface: validate the IP header on xmit")
Cc: stable@vger.kernel.org
Signed-off-by: Shuai Liu <847807867@qq.com>
---
 net/xfrm/xfrm_interface_core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c
index 9835fbe63ccb8..aa6e42c3e0e2e 100644
--- a/net/xfrm/xfrm_interface_core.c
+++ b/net/xfrm/xfrm_interface_core.c
@@ -531,6 +531,14 @@ static netdev_tx_t xfrmi_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	memset(&fl, 0, sizeof(fl));
 
+	switch (skb->protocol) {
+	case htons(ETH_P_IPV6):
+	case htons(ETH_P_IP):
+		break;
+	default:
+		goto tx_err;
+	}
+
 	if (!pskb_inet_may_pull(skb))
 		goto tx_err;
 
-- 
2.43.0


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

* Re: [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
  2026-11-19  5:08 ` [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Shuai Liu
@ 2026-11-25 12:22   ` Paolo Abeni
  2026-11-25 12:24     ` Paolo Abeni
  2026-11-26  9:00   ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 7+ messages in thread
From: Paolo Abeni @ 2026-11-25 12:22 UTC (permalink / raw)
  To: Shuai Liu, netdev, steffen.klassert
  Cc: herbert, edumazet, kuba, horms, q.h.hack.winter, stable,
	syzbot+d29af9ef5c96a3f5e96c

On 11/19/26 06:08, Shuai Liu wrote:
> AF_XDP sockets bound to an xfrm interface submit skbs with
> skb->protocol unset (0) and skb->network_header still 0 from the
> __alloc_skb() zero-initialization; skb_reserve() only moves data
> NET_SKB_PAD bytes into the headroom.
> 
> Since commit 86de3a1118a16 ("xfrm: interface: validate the IP header
> on xmit"), xfrmi_xmit() calls pskb_inet_may_pull() unconditionally.
> For such a skb, pskb_inet_may_pull_reason() selects nhlen = 0 for the
> unknown protocol and pskb_may_pull_reason() receives
> len = skb_network_offset(skb) = network_header - data = -64, which as
> unsigned int exceeds INT_MAX and trips the
> DEBUG_NET_WARN_ON_ONCE(len > INT_MAX) in pskb_may_pull_reason():
> 
>    WARNING: ./include/linux/skbuff.h:2856 at pskb_may_pull_reason [inline]
>    WARNING: ./include/linux/skbuff.h:3286 at pskb_network_may_pull_reason [inline]
>    WARNING: ./include/net/ip_tunnels.h:483 at pskb_inet_may_pull_reason [inline]
>    WARNING: ./include/net/ip_tunnels.h:488 at pskb_inet_may_pull [inline]
>    WARNING: ./include/net/ip_tunnels.h:488 at xfrmi_xmit+0x1844/0x1eb0
>      net/xfrm/xfrm_interface_core.c:534
>    RIP: 0010:pskb_may_pull_reason include/linux/skbuff.h:2856 [inline]
>    Call Trace:
>     __dev_direct_xmit+0x4b6/0x730 net/core/dev.c:5164
>     __xsk_generic_xmit net/xdp/xsk.c:1288 [inline]
>     xsk_generic_xmit+0x27d8/0x47a0 net/xdp/xsk.c:1344
>     xsk_poll+0x326/0x670 net/xdp/xsk.c:1472
> 
> The packet is dropped by the pull returning PKT_TOO_SMALL and hitting
> the default case afterwards anyway, so the only visible effect is the
> warning; reject unknown protocols before the pull to restore the
> pre-86de3a1118a16 behavior of dropping them silently via the switch
> default.
> 
> Reported-by: syzbot+d29af9ef5c96a3f5e96c@syzkaller.appspotmail.com
> Closes: https://syzbot.org/bug?extid=d29af9ef5c96a3f5e96c
> Fixes: 86de3a1118a16 ("xfrm: interface: validate the IP header on xmit")
> Cc: stable@vger.kernel.org

The blamed commit is in the current release, Cc: stable is not needed
No need to resubmit just for this, I can drop the tag while applying.

> Signed-off-by: Shuai Liu <847807867@qq.com>
@Steffen: looks good?

/P


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

* Re: [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
  2026-11-25 12:22   ` Paolo Abeni
@ 2026-11-25 12:24     ` Paolo Abeni
  2026-11-25 16:26       ` Steffen Klassert
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Abeni @ 2026-11-25 12:24 UTC (permalink / raw)
  To: steffen.klassert
  Cc: herbert, edumazet, kuba, horms, q.h.hack.winter, stable,
	syzbot+d29af9ef5c96a3f5e96c, Shuai Liu, netdev

On 11/25/26 13:22, Paolo Abeni wrote:
> On 11/19/26 06:08, Shuai Liu wrote:
>> AF_XDP sockets bound to an xfrm interface submit skbs with
>> skb->protocol unset (0) and skb->network_header still 0 from the
>> __alloc_skb() zero-initialization; skb_reserve() only moves data
>> NET_SKB_PAD bytes into the headroom.
>>
>> Since commit 86de3a1118a16 ("xfrm: interface: validate the IP header
>> on xmit"), xfrmi_xmit() calls pskb_inet_may_pull() unconditionally.
>> For such a skb, pskb_inet_may_pull_reason() selects nhlen = 0 for the
>> unknown protocol and pskb_may_pull_reason() receives
>> len = skb_network_offset(skb) = network_header - data = -64, which as
>> unsigned int exceeds INT_MAX and trips the
>> DEBUG_NET_WARN_ON_ONCE(len > INT_MAX) in pskb_may_pull_reason():
>>
>>    WARNING: ./include/linux/skbuff.h:2856 at pskb_may_pull_reason [inline]
>>    WARNING: ./include/linux/skbuff.h:3286 at pskb_network_may_pull_reason [inline]
>>    WARNING: ./include/net/ip_tunnels.h:483 at pskb_inet_may_pull_reason [inline]
>>    WARNING: ./include/net/ip_tunnels.h:488 at pskb_inet_may_pull [inline]
>>    WARNING: ./include/net/ip_tunnels.h:488 at xfrmi_xmit+0x1844/0x1eb0
>>      net/xfrm/xfrm_interface_core.c:534
>>    RIP: 0010:pskb_may_pull_reason include/linux/skbuff.h:2856 [inline]
>>    Call Trace:
>>     __dev_direct_xmit+0x4b6/0x730 net/core/dev.c:5164
>>     __xsk_generic_xmit net/xdp/xsk.c:1288 [inline]
>>     xsk_generic_xmit+0x27d8/0x47a0 net/xdp/xsk.c:1344
>>     xsk_poll+0x326/0x670 net/xdp/xsk.c:1472
>>
>> The packet is dropped by the pull returning PKT_TOO_SMALL and hitting
>> the default case afterwards anyway, so the only visible effect is the
>> warning; reject unknown protocols before the pull to restore the
>> pre-86de3a1118a16 behavior of dropping them silently via the switch
>> default.
>>
>> Reported-by: syzbot+d29af9ef5c96a3f5e96c@syzkaller.appspotmail.com
>> Closes: https://syzbot.org/bug?extid=d29af9ef5c96a3f5e96c
>> Fixes: 86de3a1118a16 ("xfrm: interface: validate the IP header on xmit")
>> Cc: stable@vger.kernel.org
> 
> The blamed commit is in the current release, Cc: stable is not needed
> No need to resubmit just for this, I can drop the tag while applying.
> 
>> Signed-off-by: Shuai Liu <847807867@qq.com>
> @Steffen: looks good?
I forgot to mention. Since this is one of the very rare regression we
have nowadays, I would like to have it in this week PR, taking it
directly via the 'net' tree would help. Ok with that?

Thanks,

Paolo


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

* Re: [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
  2026-11-25 12:24     ` Paolo Abeni
@ 2026-11-25 16:26       ` Steffen Klassert
  0 siblings, 0 replies; 7+ messages in thread
From: Steffen Klassert @ 2026-11-25 16:26 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: herbert, edumazet, kuba, horms, q.h.hack.winter, stable,
	syzbot+d29af9ef5c96a3f5e96c, Shuai Liu, netdev

On Wed, Nov 25, 2026 at 01:24:54PM +0100, Paolo Abeni wrote:
> On 11/25/26 13:22, Paolo Abeni wrote:
> > On 11/19/26 06:08, Shuai Liu wrote:
> > > AF_XDP sockets bound to an xfrm interface submit skbs with
> > > skb->protocol unset (0) and skb->network_header still 0 from the
> > > __alloc_skb() zero-initialization; skb_reserve() only moves data
> > > NET_SKB_PAD bytes into the headroom.
> > > 
> > > Since commit 86de3a1118a16 ("xfrm: interface: validate the IP header
> > > on xmit"), xfrmi_xmit() calls pskb_inet_may_pull() unconditionally.
> > > For such a skb, pskb_inet_may_pull_reason() selects nhlen = 0 for the
> > > unknown protocol and pskb_may_pull_reason() receives
> > > len = skb_network_offset(skb) = network_header - data = -64, which as
> > > unsigned int exceeds INT_MAX and trips the
> > > DEBUG_NET_WARN_ON_ONCE(len > INT_MAX) in pskb_may_pull_reason():
> > > 
> > >    WARNING: ./include/linux/skbuff.h:2856 at pskb_may_pull_reason [inline]
> > >    WARNING: ./include/linux/skbuff.h:3286 at pskb_network_may_pull_reason [inline]
> > >    WARNING: ./include/net/ip_tunnels.h:483 at pskb_inet_may_pull_reason [inline]
> > >    WARNING: ./include/net/ip_tunnels.h:488 at pskb_inet_may_pull [inline]
> > >    WARNING: ./include/net/ip_tunnels.h:488 at xfrmi_xmit+0x1844/0x1eb0
> > >      net/xfrm/xfrm_interface_core.c:534
> > >    RIP: 0010:pskb_may_pull_reason include/linux/skbuff.h:2856 [inline]
> > >    Call Trace:
> > >     __dev_direct_xmit+0x4b6/0x730 net/core/dev.c:5164
> > >     __xsk_generic_xmit net/xdp/xsk.c:1288 [inline]
> > >     xsk_generic_xmit+0x27d8/0x47a0 net/xdp/xsk.c:1344
> > >     xsk_poll+0x326/0x670 net/xdp/xsk.c:1472
> > > 
> > > The packet is dropped by the pull returning PKT_TOO_SMALL and hitting
> > > the default case afterwards anyway, so the only visible effect is the
> > > warning; reject unknown protocols before the pull to restore the
> > > pre-86de3a1118a16 behavior of dropping them silently via the switch
> > > default.
> > > 
> > > Reported-by: syzbot+d29af9ef5c96a3f5e96c@syzkaller.appspotmail.com
> > > Closes: https://syzbot.org/bug?extid=d29af9ef5c96a3f5e96c
> > > Fixes: 86de3a1118a16 ("xfrm: interface: validate the IP header on xmit")
> > > Cc: stable@vger.kernel.org
> > 
> > The blamed commit is in the current release, Cc: stable is not needed
> > No need to resubmit just for this, I can drop the tag while applying.
> > 
> > > Signed-off-by: Shuai Liu <847807867@qq.com>
> > @Steffen: looks good?
> I forgot to mention. Since this is one of the very rare regression we
> have nowadays, I would like to have it in this week PR, taking it
> directly via the 'net' tree would help. Ok with that?

Ok. If it helps, take it into net.

Acked-by: Steffen Klassert <steffen.klassert@secunet.com>

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

* Re: [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
@ 2026-11-26  3:04 Shuai Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Shuai Liu @ 2026-11-26  3:04 UTC (permalink / raw)
  To: pabeni
  Cc: steffen.klassert, netdev, edumazet, kuba, herms, q.hack.winter,
	stable

Hi Paolo,

Yes, thanks! That works for me.

/P

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

* Re: [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
@ 2026-11-26  3:05 Shuai Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Shuai Liu @ 2026-11-26  3:05 UTC (permalink / raw)
  To: pabeni; +Cc: steffen.klassert, netdev, edumazet, kuba, stable

Hi Paolo,

Yes, thanks! That works for me.

/P

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

* Re: [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
  2026-11-19  5:08 ` [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Shuai Liu
  2026-11-25 12:22   ` Paolo Abeni
@ 2026-11-26  9:00   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-26  9:00 UTC (permalink / raw)
  To: Shuai Liu
  Cc: netdev, steffen.klassert, herbert, edumazet, kuba, pabeni, horms,
	q.h.hack.winter, stable, syzbot+d29af9ef5c96a3f5e96c

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu, 19 Nov 2026 13:08:14 +0800 you wrote:
> AF_XDP sockets bound to an xfrm interface submit skbs with
> skb->protocol unset (0) and skb->network_header still 0 from the
> __alloc_skb() zero-initialization; skb_reserve() only moves data
> NET_SKB_PAD bytes into the headroom.
> 
> Since commit 86de3a1118a16 ("xfrm: interface: validate the IP header
> on xmit"), xfrmi_xmit() calls pskb_inet_may_pull() unconditionally.
> For such a skb, pskb_inet_may_pull_reason() selects nhlen = 0 for the
> unknown protocol and pskb_may_pull_reason() receives
> len = skb_network_offset(skb) = network_header - data = -64, which as
> unsigned int exceeds INT_MAX and trips the
> DEBUG_NET_WARN_ON_ONCE(len > INT_MAX) in pskb_may_pull_reason():
> 
> [...]

Here is the summary with links:
  - [net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
    https://git.kernel.org/netdev/net/c/e509726660dd

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-11-26  9:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <6afdcf01.ca6cd63e.174a34.0001.GAE@google.com>
2026-11-19  5:08 ` [PATCH net] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Shuai Liu
2026-11-25 12:22   ` Paolo Abeni
2026-11-25 12:24     ` Paolo Abeni
2026-11-25 16:26       ` Steffen Klassert
2026-11-26  9:00   ` patchwork-bot+netdevbpf
2026-11-26  3:04 Shuai Liu
  -- strict thread matches above, loose matches on Subject: below --
2026-11-26  3:05 Shuai Liu

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