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=1795045661; b=5t8RJl6fsQf+pVZ6yKkz4EEuJY1drZ6BZjRmXMfMz/8wrK5lilPY3h7GcUf9lK30wafx 9KfQu8Tki8QANtgKBaXSCK/4NmlY7QTgv5GzDUFcYUh1oneqZgF3QdwOtB9SOXguLdm+v kd2csu/ImcFxSJaapgBdxBX6F51h/PhjKZYjN5gyogbDQGSKm4qLw/YjIimFidzgkQVhj Xw3BKABaob1Ay+FCsdM9gRdmqOlO2h7w9zdVVmKN4Mh3u9UaK2HLPLlKmpxC7aUTlh6QN O0NOH+rdzdNyRXAG0yMD33WitBXpGyk78i9C1INiZgKB9QWPZzAMcUY75Bao4MriIGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795045661; 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=9DXE0AHceYMT9zr1eQUvB8L+GQJqgr02Y7tDcigXLt8=; b=EZ+kcQMfEjoJHlwvloQat9fseXTA5fngxL2KtFymNqNfb52SNdeFXTEaV2edYfNAIuwD qVvgLm0clJG8wFP3qN1EMdmSPkCd5L/Ee3A2n4JveRRhqukN+OlEoTiZtmo5iq+xHlOLW je1bTk/NmZrU1JFfHdS41Nsw1v4An0j0+FOUG1pEcM5tJzR8DMEizbdGDAX3SiabO9tx4 o60nUbc4evCz8SS4QNMVPBpqrAGzJhyjKTJ3H9oEbetf9CDQ1DXzuRdLyq/6iYdQPL9pe K2+HonM0IGNxDJS1CcJAQAJ9hflNevA5bBF7YCdwvxFoqUM+tqvlGbzB2BJCTIYvv9A== 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=XJPjrKTX; 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 BF02E606A32C; Wed, 18 Nov 2026 23:47:41 +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=XJPjrKTX Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5A7D1F000C4; Wed, 18 Nov 2026 23:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795045661; bh=9DXE0AHceYMT9zr1eQUvB8L+GQJqgr02Y7tDcigXLt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XJPjrKTXlWRe6OjUBCQGFLWj4BdSKgT7fypiYJ4DD7kFgBX3Z974r61zS1iapElmJ KTdYX0gF97QMQVdMWxrUg2UFia96i7Wqwj5B3imWYBn01L3rZyRi8JdbAwTRJ6bust mTPV9FGO21OZMu+o3qQMhiIVZID5ttDeD4mxRgKQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kyle Zeng , David Lee , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.1 0986/2857] netfilter: nf_reject: initialize IPCB at inet ingress Date: Wed, 18 Nov 2026 15:33:40 +0100 Message-ID: <20261118150237.105631914@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org 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: Kyle Zeng [ Upstream commit 73a73d442f9986353fe284bd1b504d0313d0f153 ] The inet ingress hook runs before ip_rcv_core() and ip6_rcv_core(), so neither IPCB nor IP6CB has been initialized when nft_reject_inet passes a packet to nf_send_unreach() or nf_send_unreach6(). skb->cb can therefore retain metadata from an earlier protocol layer. For IPv4, icmp_send() treats IPCB(skb)->opt as parsed IPv4 options. Stale option offsets can make __ip_options_echo() copy an attacker-controlled length into its 40-byte reply option buffer and overflow the stack. On an unpatched v7.2-rc5 kernel, the IPv4 reproducer produced: BUG: KASAN: stack-out-of-bounds in __ip_options_echo() Write of size 255 For IPv6, icmpv6_send() consumes IP6CB(skb) as parsed IPv6 metadata. It always uses iif for source selection and, when MIP6 is enabled, uses dsthao as an extension-header offset. These fields must not be stale. For NF_INET_INGRESS, clear the address-family-specific control block and restore its input interface before constructing the ICMP error. This matches similar initialization normally performed by ip_rcv_core() and ip6_rcv_core(). Fixes: 117ca1f8920c ("netfilter: nft_reject_inet: allow to use reject from inet ingress") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5.6-sol Codex:gpt-5.5-cyber Signed-off-by: Kyle Zeng Co-developed-by: David Lee Signed-off-by: David Lee Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/ipv4/netfilter/nf_reject_ipv4.c | 5 +++++ net/ipv6/netfilter/nf_reject_ipv6.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c index 549d355ebb1d9..68ad416a47c88 100644 --- a/net/ipv4/netfilter/nf_reject_ipv4.c +++ b/net/ipv4/netfilter/nf_reject_ipv4.c @@ -350,6 +350,11 @@ void nf_send_unreach(struct sk_buff *skb_in, int code, int hook) if (!skb_valid_dst(skb_in) && nf_reject_fill_skb_dst(skb_in) < 0) return; + if (hook == NF_INET_INGRESS) { + memset(IPCB(skb_in), 0, sizeof(*IPCB(skb_in))); + IPCB(skb_in)->iif = skb_in->skb_iif; + } + if (skb_csum_unnecessary(skb_in) || !nf_reject_verify_csum(skb_in, dataoff, proto)) { icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0); diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c index d565cea4cc737..76e7e13c7e5c6 100644 --- a/net/ipv6/netfilter/nf_reject_ipv6.c +++ b/net/ipv6/netfilter/nf_reject_ipv6.c @@ -431,6 +431,11 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in, if (hooknum == NF_INET_LOCAL_OUT && skb_in->dev == NULL) skb_in->dev = net->loopback_dev; + if (hooknum == NF_INET_INGRESS) { + memset(IP6CB(skb_in), 0, sizeof(*IP6CB(skb_in))); + IP6CB(skb_in)->iif = skb_in->skb_iif; + } + if (!skb_valid_dst(skb_in) && nf_reject6_fill_skb_dst(skb_in) < 0) return; -- 2.53.0