🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27260

Re: [PATCH ipsec] xfrm: iptfs: initialize unset MAC headers on inner skbs

#27260
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 05:54
195 lines
15280 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The fix gives runt-reassembled inner packets a zero-length L2
  header on an Ethernet device, which is inconsistent with the other…
- [Low] The commit message understates the impact and leaves out the
  trigger.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the commit
  message relies on it ("Preserve a valid L2 header when the receive…

--

xfrm: iptfs: initialize unset MAC headers on inner skbs

When an IPTFS inner skb never had its MAC header set,
iptfs_complete_inner_skb() now resets it to the start of the inner
packet. This avoids an skb_under_panic() in packet_rcv(). A MAC header
that was already rebuilt from the outer skb is kept.

> iptfs_alloc_skb() leaves the MAC header unset.  When reassembly completes,
> iptfs_complete_inner_skb() sends the inner skb through gro_cells_receive()
> without initializing it.  An AF_PACKET listener then derives a large push
> length from the unset header and trips skb_under_panic():

[Severity: Low]
Could the commit message say where the unset header comes from and who
can trigger it?

The skb with no MAC header comes from the runt branch of
iptfs_reassem_cont():

net/xfrm/xfrm_iptfs.c:iptfs_reassem_cont() {
    ...
		/* For the runt case we don't attempt sharing currently. NOTE:
		 * Currently, this IPTFS implementation will not create runts.
		 */

		newskb = iptfs_alloc_skb(skb, ipremain, false);
    ...
}

No L2 header is rebuilt before iptfs_complete_inner_skb() runs. The
same thing happens in __input_process_payload() when the outer skb had
no MAC header.

The comment only says the Linux sender does not create runts. A remote
IPTFS peer can still create one by ending a payload with fewer than 4
(IPv4) or 6 (IPv6) bytes of an inner packet.

GRO also reads the unset header, before any packet socket sees the
packet:

xfrm_input(skb, 0, 0, -2)
  gro_cells_receive()
    gro_cell_poll()
      napi_gro_receive()
        dev_gro_receive()
          gro_list_prepare()
            compare_ether_header(skb_mac_header(p), skb_mac_header(skb))

On an Ethernet device this reads 14 bytes at head + 0xffff. That
happens whenever a held packet in the same bucket has the same raw
hash, and every skb from iptfs_alloc_skb() has hash 0.

The code change covers this case too. The message does not mention
that a remote peer can trigger an out-of-bounds read in GRO without
any packet socket. Would it help stable and security triage to say so?

> diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
> index 76272b0a18296..22f83e25a86ef 100644
> --- a/net/xfrm/xfrm_iptfs.c
> +++ b/net/xfrm/xfrm_iptfs.c
> @@ -665,6 +665,8 @@ static u32 __iptfs_iplen(u8 *data)
>   */
>  static void iptfs_complete_inner_skb(struct xfrm_state *x, struct sk_buff *skb)
>  {
> +	if (!skb_mac_header_was_set(skb))
> +		skb_reset_mac_header(skb);

[Severity: Medium]
Does this give runt-reassembled packets a zero-length L2 header on an
Ethernet device, unlike the other inner-skb paths?

In __input_process_payload(), newly allocated inner skbs get the outer
L2 header rebuilt:

net/xfrm/xfrm_iptfs.c:__input_process_payload() {
    ...
			if (old_mac) {
				/* rebuild the mac header */
				skb_set_mac_header(skb, -first_skb->mac_len);
				memcpy(skb_mac_header(skb), old_mac, first_skb->mac_len);
				eth_hdr(skb)->h_proto = skb->protocol;
			}
    ...
}

The reuse branch there also calls skb_mac_header_rebuild(). The runt
branch of iptfs_reassem_cont() never copies the outer L2 header, even
though the outer skb it holds has a valid one:

		newskb = iptfs_alloc_skb(skb, ipremain, false);

With this change that skb ends up with mac_header == data.
__netif_receive_skb_core() then computes mac_len = 0. skb->dev, which
iptfs_alloc_skb() copied from the outer packet, is still an Ethernet
device with header_ops.

So the same inner flow arrives with either a full Ethernet header or
none at all, depending only on whether its first fragment was a runt.

In packet_rcv() and tpacket_rcv(), dev_has_header(dev) is true, so this
pushes 0 bytes:

	skb_push(skb, skb->data - skb_mac_header(skb));

SOCK_RAW captures would then show the IP header as an Ethernet frame.
eth_header_parse() would report IP header bytes 6-11 as the source MAC.

Three other users would also see a missing or bogus L2 header:

  - tc flower ETH_ADDRS matching
  - generic XDP
  - mirred ingress-to-egress redirect, which pushes mac_len bytes

Could the runt path rebuild the outer L2 header the way
__input_process_payload() does? The reset to skb->data would then only
be a fallback for outer skbs that really have no MAC header.

[Severity: High]
This isn't a bug introduced by this patch, but the commit message
relies on it:

  Preserve a valid L2 header when the receive path rebuilt one from the outer
  skb.

Is the header rebuilt in the alloc branch of __input_process_payload()
always valid? That branch runs whenever old_mac is non-NULL:

	old_mac = skb_mac_header_was_set(skb) ? skb_mac_header(skb) : NULL;

It then stores h_proto without checking first_skb->mac_len:

				skb_set_mac_header(skb, -first_skb->mac_len);
				memcpy(skb_mac_header(skb), old_mac, first_skb->mac_len);
				eth_hdr(skb)->h_proto = skb->protocol;

Other code guards the same store with "if (skb->mac_len)": the reuse
branch in the same function, and xfrm4_remove_tunnel_encap() and
xfrm6_remove_tunnel_encap() in net/xfrm/xfrm_input.c.

Two receive paths set the MAC header without an L2 header:

  - PPP: ppp_receive_nonmp_frame() calls skb_reset_mac_header() and
    then netif_rx()
  - sit: ipip6_rcv() calls skb_reset_mac_header()

For an outer ESP packet on either path, skb_reset_mac_len() in
__netif_receive_skb_core() gives mac_len = 0 with the MAC header set.

In that case the MAC header lands at skb->data, the memcpy copies 0
bytes, and the h_proto store overwrites bytes 12-13 of the newly copied
inner IP header.

For IPv4 those bytes are the upper half of saddr, so the header
checksum fails in ip_rcv_core(). For IPv6 they are saddr bytes 4-5,
which become 0x86DD, so the TCP, UDP and ICMPv6 pseudo-header checksums
fail. SCTP has no pseudo-header in its CRC32c, so SCTP packets would be
delivered with a rewritten source address.

This affects every inner packet that does not take the reuse branch:
every packet after the first in an aggregated outer packet, plus any
first packet that does not meet the reuse conditions. Would IPTFS over
PPP, PPPoE, L2TP or sit lose most decapsulated traffic?

The new check keeps any MAC header that is already set, so these
corrupted packets are passed on unchanged.

>  	skb_reset_network_header(skb);
>  
>  	/* The packet is going back through gro_cells_receive no need to

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179633878834.538813.3134233076431912228%40skku.edu
Technical Details
Message-ID: <179645008761.3146.4279511890634013937@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377847-linux-kernel-netdev=dewy.ru
References: <179633878834.538813.3134233076431912228@skku.edu>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377847-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH ipsec] xfrm: iptfs: initialize unset MAC headers on inner skbs
Date: Sat, 05 Dec 2026 05:54:47 +0000
Organization: Usenet Network
Message-ID: <179645008761.3146.4279511890634013937@kernel.org>
References: <179633878834.538813.3134233076431912228@skku.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2964223"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aM9/4HrgTru7TfnAo2HrpyJzq8I= sha256:XwTr9SNWPF7panZdFmSuH+oahK8Vg+bvdWdouzlYfX4=
	sha1:6IRHj+S4ILTGd4S4ezSLtnYxg5k= sha256:QLC1oKSCtC5FXpQDsShCBCJ4dy2JqiEg1ubj1SFpDac=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 8FE6B117D7D; Sat,  5 Dec 2026 08:55:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.641
X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 6lJiyMptWXcP;
	Sat,  5 Dec 2026 08:55:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377847-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 70D1E117D63; Sat,  5 Dec 2026 08:54:53 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id BF62A2946B; Sat,  5 Dec 2026 05:54:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796450090;
	b=43m+EHS/Y3ff6VMjNj95Uqy2yhX3in1nX6W6MR7P5SzEe916rPD7gDeXYBoYPfTE2zgb
	 vuJqHiYDqwBHFLB3VizFWWEvw/K73o9dvp+q1WUlc1NoJRiGhb5QySatKEynFfCx8FWbT
	 SZbOBvfMh/tSZg1QfmsoFtm5JjO9MKTHaPci3h358VzvGKbCd5W2oA0E2+rKvi3OYJ1L+
	 OeXMEWlFjJK6eN912rLkFMtL/7NVWVAeX3ygt8463RFOQwlVsAnfo0qau0qUmCHOWvYvO
	 m+j0okHPAOds9vVL+rWXxFr1kpvh0N2f1OR9hI8tPkdztF6LhCGvGgLnwV3PN3IS3GA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796450090;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=+IpKykdi7ygAk9UlXT0YdcqPqHgi0um4otbMz0JPEbw=;
	b=kFO/8lbvUKm29jKo4OHFCs/wX9B5c1fMoB5KdRCt2YhUG55vgShCslFdDX5SdM+xDrAR
	 CCkb0J3A7d3el+j0H4pix8jew/pVkaj0cW7fNUUh1NmlHUaN0mx3C1RB7XHYZy/oGOFxL
	 SbsHCDUe7fdx3TABa2B/m3+KPlUZGwkcv/iOKJTggAum6yjp+j//7zrfrZ5N/+3Ha0YsW
	 YJ26EghqttJtYuTlzbnO+3157dasm4pbHFBxO3wrxjYwtkcMOlL/8Ihhk9Fpsbqfr0u+j
	 luNYuOKhPcebtws60QvPBWzOkBk1L03By2DLCIA67V37Y/co2KNoiSRtebGWfHY7WVA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h1GwlY9y;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 41629606A335;
	Sat,  5 Dec 2026 05:54:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h1GwlY9y
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796450089;
	b=fUxWJR5cRdVfJNP5OCCqbhX9lgKpTWLLKlS2y2lmvbujInubgBiJo6yPc7mSMC+JcrOv
	 6y+9x0HvubVgHbfhVBxmKu+1hkChy70qMh9O+Y6jnN8bzQg9zkg9U25ilVeqq+dLq/z4d
	 0NPonO5icEBQTnKgJUC6pDh2vZU3ERlnn1LX4ifGWZ+PZdAJo8wk/GaPwYuHBPDC1a0pm
	 ctBbjzDpqBWHtWqcXd64M6F1EYC0Mh7s7cp672BcwB63cTx01QD8GkASVJLi6d7OqC+Zo
	 W4rHnYTpnyeVrH0xLKn0gw43m5e2e9CWqgQ07EvP30rcDDV4jTvOdR+NO3P8F+aGClQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796450089;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=+IpKykdi7ygAk9UlXT0YdcqPqHgi0um4otbMz0JPEbw=;
	b=qxWgB1s9TeXKY6svUb2gBLOz3tjGhQ1I0krQSz+u2Q0ZvZyO93M82rpj9I0JT+jTKcqT
	 vMcnDTrQaLqUCbkaEUU+mEHCgSft0V0zcdczZl+myXmzHlTQSHE3bDCx6/cK3wwgRytAZ
	 tCZ6gm4BnEBA4q4FIDGHDbHEuHbqRVW4NFTduuXAeqziXBUGq+cXTuIcxGcGHd2L0blb/
	 xiG9bcObYj4VWErqH3zIljEFebVO2pXHNy+Vg2n0vpWexbBSo+w4y7USSh/RZoDzLQWgD
	 jN/ARusCW+DiF5v19ExuOHfzwC3bAxTxDwSTp4ZXpnl8Y8I5XIzgjHq6K3lPK5vhx6w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h1GwlY9y;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E768606A322;
	Sat,  5 Dec 2026 05:54:49 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 268881F0092B;
	Sat,  5 Dec 2026 05:54:48 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796450088;
	bh=+IpKykdi7ygAk9UlXT0YdcqPqHgi0um4otbMz0JPEbw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=h1GwlY9yqBla1I+ihn9VWupruvSeQeazekarj7JKaTqRvvg4gFpPu4jw+356/1Dt6
	 yk1L7KwpS3mrMovxw/vOWYqg9O2utCe8DmoqFSTlu+xYajaEntRKjqk2yRqUNdwzzD
	 5MobNbsATlfaCdFxYvwt5mvUAAVw5d+FhW6Heg9sBs6AkoR9fGVuoBz4xlVwRwGo5W
	 42/DN4IYKqpq7apuiOCjxj+65ChMQUQ1driQOVkn8dobrvnFHcqmS6TwNYUXigghY2
	 Ge6btofTthx4kiQXb7xFG56gTAgij/hbkpBEeXMciLCfUoBMgDnAhkviZMt3BHSdKD
	 DndC2+WeGoXYw==
X-Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 willemb@google.com, horms@kernel.org, chopps@labn.net, netdev@vger.kernel.org,
 ipsec@lists.linux.dev
X-In-Reply-To: <179633878834.538813.3134233076431912228@skku.edu>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list