🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7315

[PATCH net v2] ipv6: raw: fix use-after-free in rawv6_send_hdrinc()

#7315
From: Zhou Qiuyue
Date: Mon, 26 Oct 2026 04:48
53 lines
12553 bytes
rawv6_send_hdrinc() caches the route before handing the skb to
l3mdev_ip6_out(). The VRF output path may replace skb->dst and release
the original route, leaving the cached pointer stale.

The function later dereferences that pointer for statistics accounting
and as the output device passed to NF_HOOK(). Its RCU read-side critical
section starts after l3mdev_ip6_out(), so it cannot prevent the old route
from being reclaimed in between.

Reload the route from the current skb destination after
l3mdev_ip6_out() returns.

KASAN reports a slab-use-after-free in rawv6_sendmsg(), with the route
allocated by ip6_dst_alloc(), freed by dst_destroy() from rcu_core(), and
the related RCU callback queued from vrf_l3_out().

Fixes: 4c1feac58e06 ("net: vrf: Flip IPv6 output path from FIB lookup hook to out hook")
Cc: stable@vger.kernel.org
Signed-off-by: Zhou Qiuyue <n0ps1edzz@gmail.com>
---
Changes in v2:
- Rebased onto the current net tree at 7076f684d513.
- Regenerated the patch with git-format-patch so it applies cleanly.
- Corrected the Fixes tag to the commit that made the IPv6 VRF path reachable.
- Shortened the code comment and added the required recipients.

v1: https://lore.kernel.org/r/6adad51d.8fc0b0c9.1ec657.1868@mx.google.com

Thank you to Hangbin Liu for reviewing v1 and pointing out the submission
issues.

 net/ipv6/raw.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index b965258cf..bdea82543 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -654,6 +654,9 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
 	if (unlikely(!skb))
 		return 0;
 
+	/* l3mdev_ip6_out() may have replaced the skb dst. */
+	rt = dst_rt6_info(skb_dst(skb));
+
 	/* Acquire rcu_read_lock() in case we need to use rt->rt6i_idev
 	 * in the error path. Since skb has been freed, the dst could
 	 * have been queued for deletion.

base-commit: 7076f684d5132e6a6145e1da2fa74771ecd052e5
-- 
2.50.1.windows.1
Technical Details
Message-ID: <20261026044808.613-1-n0ps1edzz@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-351684-linux-kernel-netdev=dewy.ru

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-351684-linux-kernel-netdev=dewy.ru
From: n0ps1edzz@gmail.com (Zhou Qiuyue)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] ipv6: raw: fix use-after-free in rawv6_send_hdrinc()
Date: Mon, 26 Oct 2026 12:48:08 +0800
Organization: Usenet Network
Message-ID: <20261026044808.613-1-n0ps1edzz@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1223312"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:tOtIYsoXQVntVdkLT9Qh/nmsSc0= sha256:PHLZQx7cNkwJveIVycoqGvhFn8mP/dXM3L1X/gzwLM8=
	sha1:bklTy9oQzaQDUJWqTfCIF/DiULE= sha256:IVWBqm7eM+b+fsWStcqPW9e1fwabX2juNPR6ekS9roU=
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 A815C125B8A; Mon, 26 Oct 2026 07:48:36 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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=gmail.com
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 VFxIaXfU3Hsq;
	Mon, 26 Oct 2026 07:48:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-351684-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id DA9CE125B87; Mon, 26 Oct 2026 07:48:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id A2B01600EA4; Mon, 26 Oct 2026 04:48:19 +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=1792990096;
	b=pFFujIfeO7pzmxpzVLbCQ6nZp/1vbxIkXtAlVa77wpVsTeKRJMpYhqhYnCwrIKX7roQA
	 JciX3EMlZCL+GOHZA0ss2VVy5TTsM+nyHt3/da130rfa/2A6HmbubPMiu0cRXPwyeTnZe
	 SfRj5FI2oAHZLkQAP2vKZuchHaHCRmVY9MCyusP7NYr4rhRxi2fCUbJzptLT4msKZ7FXI
	 P6jEQPAlfz3ZOx/9kKTNQaWu+wtKQKn9dv70npeRdv1xP9iySMwhvDgPS9mLPILD30PNE
	 h+UM4gh9luEEK4wM6CEB6i2oFBDlPBZQepXb5MQtq+f5RHg7ZzdA1wPI4Qj/swL+Y6g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792990096;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=k/JB2/vnEe/nhNkdsVP6HUPiRtdVAo3aP+vpEA0X8co=;
	b=I5Oc6rSoI1qO7V91jjX920Z3z1INstevUm3LUUqg/ui3/1INJV5MZwjsuOn2vG0j/mOa
	 ReE4go++Yaum0KYkjbnw9yGeWhqePQsDDXiU7s9zdtdY9kB0WTDzpYzpS1DBLRcJm9uP7
	 HUHlP8G2vXbHljE4DussjSvjSdd+p6dgr/wPUsMYTgVOY0bC8GghyqZ9n/QRsLmIIwqXs
	 S5PB6E+gvhFeW5MPfuesMYPbyQ17MckLjZHqGwcTFOnHBSskhuI/i0MdJYVTL6BighpQm
	 RYvvjKKhRqdLT9dGEYGRaJInv6yuKN0rQnH1HcMTpDaG6GcPgqPB2tdnnUKVR2MaLWg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=EJ4WlZTI;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	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 571D4606A32D;
	Mon, 26 Oct 2026 04:48:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=EJ4WlZTI
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.227.130
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792990095;
	b=qtNDtyWXd6sGcvzp8QwgVLsVp+HdocAJp47aSp9GgInvJ3flg/JF3SjeFrOpH4xrV6jn
	 V+TJXg6eWONfLq3YbnupnFVWug4JkARnfFI7Itjyc5JqY1wUmVArhfyR/8YkR0vOlq0i/
	 17Tpcn/ZplTB3WCVBOk/6PmTbj+9DjvrDItJ/VjAXA/nfkVs051l4GmFmYu/Fqhb0Vb06
	 Etf7bcwCHkCe+gLaaQVnQAGHJbhCivlcyuW2qCMnp8BjhY+rVbYpR6PEoIYn3kk6TFD2j
	 0eCdqU8P+7qzSBeU6L7683U2l5puVFCcQv788pI/0gCJjOVDIQm3gwEtj3XU3qkXDvA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792990095;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=k/JB2/vnEe/nhNkdsVP6HUPiRtdVAo3aP+vpEA0X8co=;
	b=dMWH9IYCECfLHBaNnwx+3s7/bUgqwceTcNUGgrQmKHKxwAxGK2MiTPuOMilDyfxtyJSp
	 kuPuLUVO7UkSDRri78GURkcvzF8Pmj/SDNMMnWuZYRI1Rhl7FpfgeAIW0TunCbaz1rk3Y
	 UxwoG0J6iYdTZQhIEBviEUf4vZ8Ca37fzxQPzizeUxhFAc+zT5KvMA3Z6KWnk+Kd0p2ZS
	 66t4PGGHJg8v/3iaE8qqxxRmNFd62TM9JPQP2dXjhPnACjgxLeT7MabamZ/95bpgwZUcE
	 uEXnLgWYuNDGrx9yatAEJS8JZ7q1gJQ1zuT5YISFTJmPuPdy4tylymjvhwV3v2ANzTw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=EJ4WlZTI;
	arc=none smtp.remote-ip=74.125.227.130
X-Received: from mail-pj2-f2.google.com (mail-pj2-f2.google.com [74.125.227.130])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6674C606A31D
	for <netdev@vger.kernel.org>; Mon, 26 Oct 2026 04:48:14 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6674C606A31D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj2-f2.google.com with SMTP id d9443c01a7336-2e613f813b0so4026405ad.1
        for <netdev@vger.kernel.org>; Sun, 25 Oct 2026 21:48:14 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792990094; x=1793594894; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=k/JB2/vnEe/nhNkdsVP6HUPiRtdVAo3aP+vpEA0X8co=;
        b=EJ4WlZTIcbgcuKmwpDrhJsKZFt4OasvMx1uaaMfnCbhaVB6Ea1F7Y+cZqMypQOXwiz
         kjbvhoR27SoMV2Qd5nAecC2UwvkICePmaWHKy4f7rsompsKYuHIM00xbm1QzYwo4Vees
         PrEiq48okHVRgJf2K24pzMrQ6avEYt5Efo8E9Pz43NvR8bPM1x2BrLud/DjVXhl1Bkbh
         LNht6Fx0WANuYi/OPP6T3O7Zt78LfSv44bnEz7hkanPLZERqvk1Ce9His2omPpYiNuIj
         S9Oe0yOmatN+pzhxEPHbYECcxbi51p8pmbigwifs9dKspLf2Yw6W1+h26/LqlenfOvCA
         Qgiw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792990094; x=1793594894;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=k/JB2/vnEe/nhNkdsVP6HUPiRtdVAo3aP+vpEA0X8co=;
        b=SIlLpx+UiLMx6YVJWwSCC3Tnm63fM0hvmlazqkl8w24iaLi9kSgRgzFHHgFWU3UZ4Q
         0kLIEc+FJVStAwzUsJc4ILY6jaX4+jB96wAtMRclzxwW3N0hztKNy5pvQs31tMlevqyf
         gZXXbkkGqzG5XIQC+e7ScePYy/Y6ZyPbnZJfxNbDWZiNOngrF5CrWKwHQaiFsZmKyH5T
         i6rbsIbPEx03eZJPEjfchuA3pO5OjnWVcUonBBq3PBF/raNCq+LY3Dk2ZtU9fXLwpSqJ
         0r/Ou/rnqs/7Xv7aiTiwYNhpafCYckKtswMp0mdEOxqMo1E+YutN+Fh4Wz9/Cn4r0PEe
         u+Kw==
X-Gm-Message-State: AFq9FYIk4U0z80u34AkR2BSCwpQw9z4DaNt10m8CPXgGGQB2oryKrP92
	QI5zdTV1Om7Vt5h7KJpiSuODDLM8W+CeyaFJRi8HESP8t2YOqxQNZfMrJpcFVk9UYB70gw5T
X-Gm-Gg: AYBFou1zE8jKQ5cQ62VNfwRfKf5r/Em3APngHyGDyYtULK9ZjrsFibsUJpt7XXK2KVp
	xjF+WkQKzfMadn523ZrEDdw8BaTzSJyMl86+htpXpD7g60CwWX5PgoWKNu+e/e3PAHTHdGL2wmM
	w0XiGKxZ8XH52M5o+TIPRYvnehiM0Ifh5TT/in+3ki3ABlp2/WVZBb4xtLJg4onlp2CTMv5pypt
	12/Xk59s/oGPvK1eKtX9gPuGtZ40RaG9afk3o6y2A2Y5hPQYzFAICRxWsEpE3/hpiXzgJrEXeXL
	kGcG0JyThCZMeUNnxHFyCFEh8fttf/vRUzHEFqR5NWElkgzeQjlEK5CD1vltDUbnbkcGSOD95J6
	jiR4l4hBjslCXQqvjZOE1N2a70nGjESozdxtTiaAkrO/8cxv6qcTrXeHWHQ1c2lmt9tyfpUNkTv
	40SgpuQvJXJXrXnXzQ7jwQRaWTIzerVJ94lk4MWJoCAyI+tR1DGOhdOCqHz0Rf5WpY2iRBXQ7Om
	Kn6V6iP8iRGoDhw0EwuyiekQWCumGMX4FQwkujOt8jM4C6Ru2AoOu5Oj+f8ov4NNOzKxt+qB5LO
	NFEttyo9jwhg4CDHp4E=
X-Received: by 2002:a05:6a21:880e:b0:3de:3f4d:f2bd with SMTP id adf61e73a8af0-3e7db876af6mr2824220637.6.1792990093603;
        Sun, 25 Oct 2026 21:48:13 -0700 (PDT)
X-Received: from LAPTOP-0A59PORJ ([119.234.82.208])
        by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8a36e7fbc64sm858163b3a.24.2026.10.25.21.48.10
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sun, 25 Oct 2026 21:48:13 -0700 (PDT)
X-Cc: David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Hangbin Liu <hangbin.liu@linux.dev>,
	linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.50.1.windows.1
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