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=1795625708; b=wdLu64v59Z6Rr6wIXKQMFarS8pYlb+Ij5naqdxHeJ04f2jGhEmk/i+Cw6p+/9uVt0RIE ENo9iRfUB9iYPaHKHH7E4NArTHW1sG03aPESir/Bcg8IpQwB8Sm3r3cb7jShttAZT+dc9 tuD4Kw2BHHT3Am4CcpQEmeJyYdr/rW1wYZa5JVDSDhHYfmD7MekLjOey6msjW9AqGFrFQ 2YmCcD3Oqbb/CZbPkhD+ZAw3XyLWler2E6IIkcpPVvdk3gNXTTUgUFgjxUdN0A3KbYxvV 1Bd+z6RtxehgZ15+DxnFoLmU+bw02X9UcyqbFsMwAKreOeXt+u7jXiWGuecymUqOmFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795625708; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=/lrQUGw9YHDBSXOaSVW53AkfT5dTB8nAHb0QAL4mf6o=; b=2avzJ+bOGN4Y1OcYV7h328NZTgeCIiWGSCGaG00k1Q10ljFFThdmre5SoY+jTrb85dzo Lk8IxqJMOOOYTQa4kR6eivhfo+Ff3meqFF6lWG2ZM4/cyZvFUKdGXrZG2AoLffXCDTs20 al5kV9fA6++3yfo4jHu/nZ5ttCD19yzMv7Zb2lze3DwT6tzgEJ4OyHqX7+7Uj+c9G0iVo EBcrNKbV4lAcLjzTxTd2YDsQN6nv7f/MqxgHdMJMTkZ4Idmy4WOuxP39FeLSJCbeKLGaL VbbCdiHD8mNLxZE4Yb7JraApzi5VJmvscpUCiT42zq6aX+pcvEYef5+bpgdqBlVp4Dg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BI0hOkjl; 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 6B875606A336; Wed, 25 Nov 2026 16:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BI0hOkjl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98C741F000C6; Wed, 25 Nov 2026 16:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795625708; bh=/lrQUGw9YHDBSXOaSVW53AkfT5dTB8nAHb0QAL4mf6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BI0hOkjlpakxzRnElU3GHFGcOm/g3pxCVxRtc3R5hRza8etpkrnFryP0XneZyFh+q WkfwOtJKU0QNPoK6kPKJwxXqW9ylJSXj99WMcTOpX1JmDBHMmb4lyDVogrBcloCDC0 tAoAS+uIjkEwlegzMelUBShoVlw9llF2yR8B3hG4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Sashiko (nipa)" , shaos , Victor Nogueira , Jamal Hadi Salim , Simon Horman , Jakub Kicinski Subject: [PATCH 6.12 604/816] net/sched: act_ife: require a full Ethernet header on egress Date: Wed, 25 Nov 2026 15:35:52 +0100 Message-ID: <20261125143903.160169534@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143849.205329330@linuxfoundation.org> References: <20261125143849.205329330@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jamal Hadi Salim commit 11dbce09083473249c3843ff31bf8d8fa01bdeef upstream. This is a followup of commit 5b483f7791b0 ("net/sched: act_ife: Only operate on Ethernet frames") as reported by Sashiko. The finding was raised by both Sashiko providers (nipa and gemini) while reviewing the parent patchset. shaos independently reported the same undersized-egress path with a reproducer, which was reproduced and verified in our test environment. The issue: On egress tcf_ife_is_eth_skb() only checks the device type; it does not check that the skb carries a full Ethernet header. For an Ethernet or loopback device it returns true even when the skb has no Ethernet header. tcf_ife_encode() then calls ife_encode(), which copies ETH_HLEN bytes from skb->data. A short skb therefore reads past its linear data and the copied bytes, including stale kernel memory, are emitted in the outer Ethernet header. The parent commit fixed the reported ingress mac_len case but left the egress path without a length check. A total-length test is not sufficient: a non-GSO TUN skb can have a large total length while only a single byte sits in the linear area, so ife_encode() still reads past the linear header. Require instead that the Ethernet header the encoder copies is present in the linear part of the skb. The Fix: On egress require pskb_may_pull(skb, ETH_HLEN) before encoding, which ensures the Ethernet header is present in the linear data ife_encode() copies from; the ingress mac_len check is unchanged. A short egress skb is now dropped instead of being encoded. Conditions to recreate the bug: CONFIG_NET_ACT_IFE=y, CONFIG_NET_CLS_MATCHALL=y, CONFIG_NET_SCH_INGRESS=y, CONFIG_TUN=y, CONFIG_NET_ACT_MIRRED=y. In two user and network namespaces (a victim and an attacker), open a TUN device in IFF_TUN mode and attach clsact to it and to lo. Redirect ingress traffic from the TUN device to lo egress with mirred, and install an ife encode action on lo egress: tc qdisc add dev clsact tc qdisc add dev lo clsact tc filter add dev ingress matchall action mirred egress \ redirect dev lo tc filter add dev lo egress matchall action ife encode use mark 1 \ action ok Send a TUN packet shorter than ETH_HLEN (a one-byte payload is enough) and receive the emitted frame on the other side. Without the fix the outer Ethernet header contains bytes copied past the short packet; with the fix the short skb is dropped. The attacker needs CAP_NET_ADMIN in its user namespace; no init-net privilege is required. The same path is reachable when the total length is large but the Ethernet header is not linear: write a non-GSO virtio header with hdr_len=1 followed by an 8192-byte packet so that only one byte stays linear. Without the fix the copied header reads past the linear data; with the fix the header is pulled into the linear area before the copy. Fixes: 295a6e06d21e ("net/sched: act_ife: Change to use ife module") Reported-by: Sashiko (nipa) Reported-by: Sashiko (gemini) Reported-by: shaos Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260821164031.32824-1-victor%40mojatatu.com Link: https://sashiko.dev/#/patchset/20260821164031.32824-1-victor@mojatatu.com Link: https://lore.kernel.org/netdev/20261022144736.61227-1-shawnq1@163.com/ Cc: stable@vger.kernel.org Reviewed-by: Victor Nogueira Signed-off-by: Jamal Hadi Salim Reviewed-by: Simon Horman Link: https://patch.msgid.link/SER-NSBD.v3.r0.20261103064310-2@mojatatu.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sched/act_ife.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -871,13 +871,16 @@ drop: * is an Ethernet header because the skb could've been redirected with mirred * from a non-Ethernet device. */ -static bool tcf_ife_is_eth_skb(const struct sk_buff *skb) +static bool tcf_ife_is_eth_skb(struct sk_buff *skb) { if (skb->dev->type != ARPHRD_ETHER && skb->dev->type != ARPHRD_LOOPBACK) return false; - return !skb_at_tc_ingress(skb) || skb->mac_len == ETH_HLEN; + if (skb_at_tc_ingress(skb)) + return skb->mac_len == ETH_HLEN; + + return pskb_may_pull(skb, ETH_HLEN); } TC_INDIRECT_SCOPE int tcf_ife_act(struct sk_buff *skb,