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=1794065278; b=nDys9RqVA+BQclatf1JMvhzkloTDkYDnv14CxslNg8F4pJzsR23KqkeTxY/Un3YRxlby BmbXV8yT0Z+m71lmsC9/NMU2oZL4hjOgsbnlgv9yHhlGNj1/UKj/PNQigwUuaiAmFXqOb t/uBBV6X1nJSgEcEdcn0cP67Jmawr8ihrnN8YoC1bmZF/N93lk2zGIb37eQ4TdqUhDJf7 XuOS+jM2RKXxOAhYled72fms2p8zuMzbXp4ZLqoazXH9W/yHkdZplTBOw9D7AhTTli/4N NYWDz+n4juD4qWMoVAU3eD44RXwEpljt/IDqZshUK264kJjkQAy8ovf3dE9qpFQnl4g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794065278; 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=EdQfCyygFAI4von9AOdZixr4H320DETDR158Nar4RjY=; b=XNQQHgZ3mASL+yYqeaUeZITgwhGw5Q4kAinjLGj8kUWxQsAZJxOzLpc3HNxCJ1+oHlBN MPEQmiaAZybRtPcILTUQNCGL2XQyKjzhv7L2ZJ1ZkLXzXzVAF/t1XDeRoMvhnYHQCTdlg bOR3rLR0QXOZY6QtcJMwBhd3rxuiJAzhxm/5K/53U5EfYs8RlBbl3Ck56486vBsNNsX6H +a2fxrzJoe+CeYB/tq3iHrsVkrtVUiqjwLSWgLZBDKL5934QHaN3P14KYkMN6eUacUEAb bmRHT7J07J6zzWSNz8YBjSB3Db5t44ThwpGlGLvnaWuxS7EB9tzA+gC/vQTcG7MLkGw== 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=uYgiqtwy; 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 88C2B606A337; Sat, 7 Nov 2026 15:27:58 +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=uYgiqtwy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0758B1F008A6; Sat, 7 Nov 2026 15:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794065278; bh=EdQfCyygFAI4von9AOdZixr4H320DETDR158Nar4RjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uYgiqtwyvYl4IL3gxiuqWy1u8z4Rk5Rsd8jk0UYvl1HuyiUNVOFKBttrJyu4Wzt+u yoKWA/GrRT/KGCfQth7fC29LOYrp2+v+g09j5sxI+/30lfnZ1l2yrhgpmtDT6iRz0E yAkIy6a9PVU7iW3eokaR4zdrVYXs+fFj7C9A0ZN4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Ido Schimmel , Eric Dumazet , Zhiling Zou , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 7.3 1040/1257] ipmr: only copy pktinfo to cache reports Date: Sat, 7 Nov 2026 08:55:36 -0500 Message-ID: <20261107135008.039458010@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134939.434104957@linuxfoundation.org> References: <20261107134939.434104957@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhiling Zou [ Upstream commit 94a6736bb5abe6b2ef38490d0cab19c1c6a7c71f ] ipmr_cache_report() prepares IP_PKTINFO on the original skb. The ipv4_pktinfo_prepare() helper updates skb->cb and clears the pktinfo fields when packet info is disabled. Since the skb can continue through the data path, preserve and restore its original control block around the helper. The original implementation copies the entire control block to the report skb. For synthetic RTM_GETROUTE packets, NETLINK_CB data is interpreted as IPCB by the raw IPv4 receive path. With IP_RECVOPTS or IP_RETOPTS enabled, corrupted option offsets cause out-of-bounds reads or a stack buffer overflow. WHOLEPKT and WRVIFWHOLE reports also inherit stale IP option offsets when their header is prepended. Clear the report skb control block. Only prepare and copy pktinfo when the input skb has an IPv4 header. Synthetic route-query skbs use NETLINK_CB, not IPCB, so leave their report control block zeroed. Restore pkt->cb after preparing pktinfo for regular IPv4 packets. Fixes: bb7403655b3c ("ipmr: support IP_PKTINFO on cache report IGMP msg") Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Reported-by: Vega Link: https://lore.kernel.org/netdev/20260903113055.GA90787@shredder/ Suggested-by: Ido Schimmel Suggested-by: Eric Dumazet Signed-off-by: Zhiling Zou Reviewed-by: Ido Schimmel Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/0545f0c83f5ee2f6696210f87268e811ef655715.1792476357.git.zhilinz@nebusec.ai Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/ipmr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index b9c544d48c452..6635ea6b9209a 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -1057,6 +1057,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt, static int ipmr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, vifi_t vifi, int assert) { + unsigned char pkt_cb[sizeof(pkt->cb)]; const int ihl = ip_hdrlen(pkt); struct sock *mroute_sk; struct igmphdr *igmp; @@ -1112,8 +1113,6 @@ static int ipmr_cache_report(const struct mr_table *mrt, msg = (struct igmpmsg *)skb_network_header(skb); msg->im_vif = vifi; msg->im_vif_hi = vifi >> 8; - ipv4_pktinfo_prepare(mroute_sk, pkt, false); - memcpy(skb->cb, pkt->cb, sizeof(skb->cb)); /* Add our header. * Note that code, csum and group fields are cleared. */ @@ -1124,6 +1123,15 @@ static int ipmr_cache_report(const struct mr_table *mrt, skb->transport_header = skb->network_header; } + memset(skb->cb, 0, sizeof(skb->cb)); + /* Route queries from ipmr_get_route() carry NETLINK_CB, not IPCB. */ + if (ip_hdr(pkt)->version) { + memcpy(pkt_cb, pkt->cb, sizeof(pkt_cb)); + ipv4_pktinfo_prepare(mroute_sk, pkt, false); + *PKTINFO_SKB_CB(skb) = *PKTINFO_SKB_CB(pkt); + memcpy(pkt->cb, pkt_cb, sizeof(pkt_cb)); + } + igmpmsg_netlink_event(mrt, skb); /* Deliver to mrouted */ -- 2.53.0