๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7181

Re: [PATCH net 1/2] ipmr: fully initialize the synthetic IP header in ipmr_get_route()

#7181
From: Eric Dumazet
Date: Sun, 25 Oct 2026 10:50
98 lines
11887 bytes
Le dim. 25 oct. 2026 ร  08:18, Ido Schimmel <idosch@nvidia.com> a รฉcrit :
>
> For an unresolved multicast route query, ipmr_get_route() builds a
> synthetic IP header in the headroom obtained from
> skb_realloc_headroom(), which does not zero the memory it allocates.
> Only a few fields are initialized, leaving others as stale heap
> contents.
>
> ipmr_cache_report() copies this header into the IGMPMSG_NOCACHE report
> that is queued to the mroute socket, so a recvmsg() on that socket leaks
> the uninitialized bytes to user space: the 'tos' field [1] and the 'id'
> and 'frag_off' fields [2].
>
> Fix by zeroing the IP header before filling in the few fields that are
> used, so that the entire header is initialized, as in ip6mr_get_route().
>
> [1]
> BUG: KMSAN: kernel-infoleak in _copy_to_iter
>  raw_recvmsg
>
> Uninit was stored to memory at:
>  ipmr_cache_report
>  ipmr_cache_unresolved
>  ipmr_get_route
>
> Uninit was created at:
>  pskb_expand_head
>  skb_realloc_headroom
>  ipmr_get_route
>
> Byte 1 of 28 is uninitialized
>
> [2]
> BUG: KMSAN: kernel-infoleak in _copy_to_iter
>  raw_recvmsg
>
> Uninit was stored to memory at:
>  ipmr_cache_report
>  ipmr_cache_unresolved
>  ipmr_get_route
>
> Uninit was created at:
>  pskb_expand_head
>  skb_realloc_headroom
>  ipmr_get_route
>
> Bytes 4-7 of 28 are uninitialized
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Reported-by: Sashiko <netdev-bot+sashiko@kernel.org>
> Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/0545f0c83f5ee2f6696210f87268e811ef655715.1792476357.git.zhilinz%40nebusec.ai
> Assisted-by: LLM
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
>  net/ipv4/ipmr.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
> index acacaae05cc4..eac23f251bfd 100644
> --- a/net/ipv4/ipmr.c
> +++ b/net/ipv4/ipmr.c
> @@ -2506,6 +2506,7 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb,
>                 skb_push(skb2, sizeof(struct iphdr));
>                 skb_reset_network_header(skb2);
>                 iph = ip_hdr(skb2);
> +               memset(iph, 0, sizeof(*iph));
>                 iph->ihl = sizeof(struct iphdr) >> 2;
>                 iph->saddr = saddr;
>                 iph->daddr = daddr;

Reviewed-by: Eric Dumazet <edumazet@kernel.org>

SGTM, I will send this follow up as a separate patch.

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index acacaae05cc49dc15910f23f7539865432518587..8b84142fd7754d95aa1f2facf68ac554916efd27
100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -550,6 +550,11 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff
*skb, struct net_device *dev)
        DEV_STATS_ADD(dev, tx_bytes, skb->len);
        DEV_STATS_INC(dev, tx_packets);

+       /* skb->cb[] holds qdisc/tc state at this point, not IPCB.
+        * ipmr_cache_report() reads it as IPCB to build IP_PKTINFO.
+        */
+       memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
+
        /* Pairs with WRITE_ONCE() in vif_add() and vif_delete() */
        ipmr_cache_report(mrt, skb, READ_ONCE(mrt->mroute_reg_vif_num),
                          IGMPMSG_WHOLEPKT);
Technical Details
Message-ID: <CAL4WiiovWOOQ9PBPbnPk2=rK+V5WgMpOFh814-D6_A-k5ope_A@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351529-linux-kernel-netdev=dewy.ru
References: <20261025071729.34967-1-idosch@nvidia.com> <20261025071729.34967-2-idosch@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351529-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/2] ipmr: fully initialize the synthetic IP header in ipmr_get_route()
Date: Sun, 25 Oct 2026 11:50:17 +0100
Organization: Usenet Network
Message-ID: <CAL4WiiovWOOQ9PBPbnPk2=rK+V5WgMpOFh814-D6_A-k5ope_A@mail.gmail.com>
References: <20261025071729.34967-1-idosch@nvidia.com> <20261025071729.34967-2-idosch@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="992904"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:fsis6XRwDuGkkLhEhbPF/DcJSGw= sha256:/UpriPVTya9XIdtAesL7fISroI2DWpmlO42gdz6M2kA=
	sha1:CN7sCiQ0mMGOyto1nY8Wnoj07C0= sha256:YeKi5RIHAyp1SQahcJNphITEl/33J/7/hBjkQjnNeGA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id AC265125B2F; Sun, 25 Oct 2026 13:50:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 4PIiJ0x5K8rj;
	Sun, 25 Oct 2026 13:50:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351529-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 3B3C4125B2D; Sun, 25 Oct 2026 13:50:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C2C243119B; Sun, 25 Oct 2026 10:50:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792925430;
	b=UPNntEGDHQ3nMKqLxn3jSeJRDjmdvDitsSMqIvtQYco6+tEtoOuSlCBHbdPLYFKy4wtf
	 dmz7T4t6rc0ZZcAdLDHVO91MV3ZcEzec9Uj5y6Eghsk3JmKytWVWQowIAXalitIiY1wCN
	 gQ6FfbFdzKFBjexcvhmqz4AH+V+q7zhgbjPvLLJU3fHk8XdSrS2sS7wH/tYkQ6MgDaWQ9
	 CcXJEyawoRHaXvGLjX8moZCAsZoObozTUzdeoX0dJmxrcpdvzU0k/dgsagjshx4qipn0G
	 NeqTpjQpZZHoa6tljHRObnOhwA8f8R6honASnRLftLS23F/v9jKp5H82XBl8SK/c6LA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792925430;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Gm-Message-State:X-Received:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=Z34xT/KTKRp/P6iMZZaSFLF0nWR84Andajbw0zEcAS8=;
	b=3Vi2imkyxvJ1IEz0SAsArx/cAnjxkZmDAALUmGqEU4SBl2Itlp5wJksSDrpjadsx5KDv
	 DULxjoEDtJNuUYRb+DoW5pgwM63KohGAsvUnXUS9cmp49Xr5ajPrYJt0lvl5TVbnEkeaH
	 KwGWbWA1Bvw6TRclc6791BgXRZKSuhyL2Z5Ez+laUCgCbVk58BqvBLVCKqBvWw1bB6r/1
	 TeKL0fnBwTgUgnlSMTV4vC0+Xs69uJ2IB88e7GjkY1xvW4Wuku1yZlBWkdKvaBJ2u9Zp/
	 cae2Smu3oZFAHxdmUJ2XM/dBVsQl/r/ogJcRFJT7H/BTt28bmcd2fgiVUlXMMpKKMBA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TFwr+M2m;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 47F29606A31B;
	Sun, 25 Oct 2026 10:50:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TFwr+M2m
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792925429;
	b=0QMd0A5wzhQKVzQRyECNH0pmnCtB4Xg6OzNwPoZ2XQXRnKY2aNkgO44345FQuCs6kddF
	 W2pIUn5Wae4c7iOnF4PtufMZFW4XwWNNAjafF4n9Hm3T0hq6eEtNVvRLfY8ckHaDwjB7J
	 CLwwDaK7QDyFZqHaf2PwU41ksUguYpIaIwEOsJ7q+JZerEp7NHa2d/QY3+juHo9FPfuKu
	 xgS89Qok936G7sQi5Cskd96mZLQwbZL+i/uVg4fNadZvYCXElgy0pH5pZZgBW3aymdONw
	 GVK3LW+htpTkC8wzalv3MSW5hqEr6+vs5GUtJ+iGQ89rsi2nKGPsmH9V7/8IbK0b+1g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792925429;
	h=Received:DKIM-Signature:Received:X-Gm-Message-State:X-Received:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=Z34xT/KTKRp/P6iMZZaSFLF0nWR84Andajbw0zEcAS8=;
	b=DENaqdKksalfVM7yzIMePfeGor67Xdahm3arpyHejZqdeiPDzmtMTzr1naUQOOFYzSpC
	 ReYAtzpnH9biNIb7nAe9Wjgi3QxfyzG7wX1gwZUku0p19tMM6NmBby/66uO7hR5kQ8jgU
	 TsfXf6x82ioU1MCenspS1pWG8Gz4X/VUY67ZLt33Pd+jKE0ttc8ANxVrXPxs7+unxzUUi
	 8mBwqb7QsZMamvlmY0qhqpfVE4fhePVbg7H9B3QfIZRt6UkqxVuh2Wc8nbE1jy1AaDrlv
	 xRMJkMJGc3chY8xPbhw4ni2tqZQUlIZ7pX2lvWtyj0jDbWvCK4HVWcTalPDKV8AQFHQ==
X-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=TFwr+M2m;
	arc=none smtp.remote-ip=100.103.45.18
X-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 15523606A31A
	for <netdev@vger.kernel.org>; Sun, 25 Oct 2026 10:50:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE9D81F031E0
	for <netdev@vger.kernel.org>; Sun, 25 Oct 2026 10:50:28 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792925428;
	bh=Z34xT/KTKRp/P6iMZZaSFLF0nWR84Andajbw0zEcAS8=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=TFwr+M2mBb4O4usMtJFqfWff6YuKRG6P0Ln1Ol9/aUoQpuC1DNZSwTFBFiwDH/Uy0
	 v2tx5SEKg7++6Rghsiw9TjL6HrkacDHwUhJJu69SrjamP4yA9jebgjLA61YhQwd8Qa
	 L28hbw9GSdbxLAZkHfurPEEWU3O10e97QccWhSmncFqR20vMtiSy8+ay5EHFJ5oVdV
	 G79TRVCd1brZe+H8qNhScJcdwG+ABB541TtYgqwxxrPSFZL25gIUFhuB0jDd2/JJJp
	 rz0JC6DznHKjSPmeFdfS9uSGPkWhNYuPyfmjmdtLtQMb08QExr1t4n0DBrpgQFLaZl
	 XeuRF4WL1A7/Q==
X-Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-451a49abd8aso2256682fac.3
        for <netdev@vger.kernel.org>; Sun, 25 Oct 2026 03:50:28 -0700 (PDT)
X-Gm-Message-State: AFq9FYKcX4H7d8tjcXYb+exrY+GDSDn8UVVkIGNx5MerE29O7CZYmDpz
	05oLghuorchSkv1eZkZtOL/MBs12PzNvXuYb+uJDWqManF8nffTcDK/54//bfglM5f6cRmrNdip
	ThcfXLCOHvKnxiwXAlxDLal5aa8dqFaI=
X-Received: by 2002:a05:6870:2c49:b0:491:520f:e6d0 with SMTP id
 586e51a60fabf-4a83f00d327mr2211468fac.4.1792925428140; Sun, 25 Oct 2026
 03:50:28 -0700 (PDT)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261025071729.34967-2-idosch@nvidia.com>
X-Gmail-Original-Message-ID: <CAL4WiiovWOOQ9PBPbnPk2=rK+V5WgMpOFh814-D6_A-k5ope_A@mail.gmail.com>
X-Gm-Features: AclHuK-JgswlkfMhiZ2fs2aB1d2-JI9OOSyqjldUoMV99nSOE8B2ON7VxY1KuxE
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, 
	pabeni@redhat.com, dsahern@kernel.org, horms@kernel.org, 
	yoshfuji@linux-ipv6.org, stable@vger.kernel.org