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=1796388155; b=PXCGmWX3Me3J8GayBiidZt6Y+sfD0yvgtsLR0M4sYxyF49dp5ZxPzy1iODiz/Qr4XY1t 6HtRW5n4Y+E3MkbxCnzOJO28VldNzctj12SiRUBYjnFoyDggl00u1VsdHATUjztLlucRO zanuLN+9zZwv83POMBPU6t/42HtFRwUaUPrjD9g78WgTPGUi14EWKT2tlQaXWy7jtgoYk DUtSH0wcalZamapRt8xk4fPfrdt5kDPEFHENHjz4b1zFPs21NsTPmhMgx0+ANT16iKrVh YwrGXo6BoHAWtnRkg/FknZupDqNn+npPQH1Fdft/gw4p7s9WuF7wWgQsUyvo4uQrwCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388155; 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=HhrW39GAtXiu2PDEaWzCLwAzaDjEqfAT4WWn3HV2goE=; b=Ry4t71ZqQAVF8QWtTDpm+gyDwbkEjPdD/E5J7+WYa+9PSW1vXYJP6nE95vuaW8wf7XlG ljQa0dZBGU+ceNldKbn1rMB9BQV8w+VXok8FO84UX9SbRqS9y3lKqjAio3h0LRifeW5Pg 8RLgKL7pjmWHvmJGSRjvYiL9iLpDbdrgf8kC7n6KU4yG2Sgm1i/1+eY1Ni3AIC9EHUhf0 lwe5mYlu5DI0uOXayLzvFY3LuXWUuBgBvPCAzkOBsQJJJNGGIrz77t/kFQd1iwIv3P6iO TgFqT2DwMsvLlBA/BHlHoXLPPwR4ri87kcOzOVhCeAB0sjDYPinuGa8ppzyZIkH4M5A== 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=nHWw07Fk; 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 6CD23606A322; Fri, 4 Dec 2026 12:42:35 +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=nHWw07Fk Received: by smtp.kernel.org (Postfix) with ESMTPSA id D74101F000C2; Fri, 4 Dec 2026 12:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388155; bh=HhrW39GAtXiu2PDEaWzCLwAzaDjEqfAT4WWn3HV2goE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nHWw07FkWj7Pjaaz8cWYgaJ1odAVvMrQr8svo0ZXByfWjhnq3piF7vDgofv1Y/LnX LI99rb7xiUQZiDh3WyOes7WJ3oPdrS2mkr2coS5lnbmW7LBzOMBzYB6sSShObn6WRV hFgdWBUh0aij+jm2wU2EdICAwfCI9H6YEwV4j47M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, shaos , Victor Nogueira , Jamal Hadi Salim , Simon Horman , Jakub Kicinski Subject: [PATCH 6.1 0506/1059] net/sched: act_ife: encode configured zero metadata values Date: Fri, 4 Dec 2026 19:00:37 +0900 Message-ID: <20261204100657.358717287@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jamal Hadi Salim commit 7d02c07c738bf5c4b9a7d7ef498fbf465c446853 upstream. Reported by shaos with a reproducer for the 32-bit case, which was reproduced and verified in our test environment. The issue: ife_check_meta_u32() and ife_check_meta_u16() both reserve eight bytes of metadata for a configured value even when that value is zero, but the matching encoder returns without calling ife_tlv_meta_encode(). The encoder therefore writes neither the TLV header nor its value, while the enclosing IFE length still includes the reserved bytes, exposing stale skb headroom contents to the peer. The 32-bit helper has been present since the IFE action was introduced (v4.6); the 16-bit helper was added with the 16-bit metadata helpers used by the skbtcindex callback (v4.9). Both defects predate the oldest supported stable kernel (5.10), so they are fixed together in this patch. Each hunk keeps its own Fixes: tag for provenance. The fix: Encode any configured value, including zero; skip the TLV only when there is neither a configured nor a runtime value. The runtime fallback is unchanged. A raw TCA_IFE_METALST netlink request is needed to express the configured zero: the IFE_META_SKBMARK attribute carries four zero payload bytes for the u32 helper, and IFE_META_TCINDEX two zero payload bytes for the 16-bit helper (not an absent or zero-length attribute). Stock tc cannot build these requests; "use mark 0x0" emits no mark attribute and "allow mark" emits a zero-length one. Conditions to recreate the bug: CONFIG_NET_ACT_IFE=y, CONFIG_NET_IFE_SKBMARK=y, CONFIG_NET_IFE_SKBTCINDEX=y, CONFIG_NET_CLS_MATCHALL=y, CONFIG_NET_SCH_INGRESS=y, CONFIG_USER_NS=y, CONFIG_NET_NS=y, CONFIG_VETH=y. In a fresh user and network namespace create a veth pair and attach clsact to the egress side. Install a matchall filter whose ife encode action carries a zero skb mark (or a zero tcindex) in TCA_IFE_METALST. Send a frame through the veth and inspect the IFE metadata in the received frame. The metadata region is eight bytes but holds neither a valid TLV header nor a value; it exposes prior headroom contents. Setting the value to a nonzero one does not trigger the leak. The namespace needs CAP_NET_ADMIN; no additional privilege is required. With the fix the zero TLVs are 0001000800000000 (u32) and 0005000600000000 (u16). Fixes: ef6980b6becb ("introduce IFE action") Fixes: 6a5d58b67e20 ("net sched ife action: add 16 bit helpers") Reported-by: shaos Link: https://lore.kernel.org/netdev/20261022144739.61342-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-1@mojatatu.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sched/act_ife.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -49,8 +49,7 @@ int ife_encode_meta_u16(u16 metaval, voi edata = *(u16 *)mi->metaval; else if (metaval) edata = metaval; - - if (!edata) /* will not encode */ + else return 0; edata = htons(edata); @@ -93,8 +92,7 @@ int ife_encode_meta_u32(u32 metaval, voi edata = *(u32 *)mi->metaval; else if (metaval) edata = metaval; - - if (!edata) /* will not encode */ + else return 0; edata = htonl(edata);