From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 268881F0092B; Sat, 5 Dec 2026 05:54:48 +0000 (UTC) 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== Subject: Re: [PATCH ipsec] xfrm: iptfs: initialize unset MAC headers on inner skbs From: netdev-bot+sashiko@kernel.org To: kyuwon.cho@skku.edu 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 Date: Sat, 05 Dec 2026 05:54:47 +0000 Message-ID: <179645008761.3146.4279511890634013937@kernel.org> In-Reply-To: <179633878834.538813.3134233076431912228@skku.edu> References: <179633878834.538813.3134233076431912228@skku.edu> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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