🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9013

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

#9013
From: David Laight
Date: Fri, 30 Oct 2026 19:52
43 lines
12994 bytes
On Sat, 31 Oct 2026 01:38:22 +0800
Zhou Qiuyue <n0ps1edzz@gmail.com> wrote:

> Thanks, David.
> 
> Yes, in the redirect case it passes the old rt->dst.dev, while skb->dst
> has already been replaced. That changes the NF_HOOK outdev, so it
> probably belongs in a separate fix.

Does that actually mean that it doesn't matter?
Or has no one every actually used that path.

What holds the reference on rt->dst.dev?
Something needs to stop the interface (I think that is what it is)
being deleted mid request.

> A bare rt6i_idev or dst.dev pointer looks unsafe, since dropping the old
> route drops the refs they rely on. An explicit hold/put could replace the
> RCU lock, but adds per-packet refs, and doesn't avoid the deferred route
> free. As far as I can tell, that uses the embedded dst rcu_head; the
> temporary rt6 in this path comes from the existing HDRINCL lookup, and v2
> doesn't add a new alloc/free there.
> 
> I'll test moving the RCU read lock before l3mdev_ip6_out().

IIRC the rcu free happens for every packet and uses kmalloc() to add
the item to the list of things to be freed. So an extra reference count
may be better - especially since it should let you do a not-rcu free
of the temporary rt.

In the non-redirect case the temporary rt_info would have a reference
count of 2, one owned by the skb, the other be the sending function.
That would mean it could safely be freed at the end of transmit.

I've not looked today, but I remember this code always allocating
an rt_info for our application that was sending udp using raw sockets.
The app uses a different raw socket for each thread that sends udp
in order to guarantee the sendmsg() doesn't block anywhere.
(There are associated udp sockets, they have to be unconnected and are
only used for receive - monitoring 10k of those is 'interesting'.)

David
Technical Details
Message-ID: <20261030195229.50841726@pumpkin>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353898-linux-kernel-netdev=dewy.ru
References: <20261026044808.613-1-n0ps1edzz@gmail.com> <20261030160532.4832d994@pumpkin> <179338190237.9376.13820542101227461550@gmail.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-353898-linux-kernel-netdev=dewy.ru
From: david.laight.linux@gmail.com (David Laight)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] ipv6: raw: fix use-after-free in
 rawv6_send_hdrinc()
Date: Fri, 30 Oct 2026 19:52:29 +0000
Organization: Usenet Network
Message-ID: <20261030195229.50841726@pumpkin>
References: <20261026044808.613-1-n0ps1edzz@gmail.com>
	<20261030160532.4832d994@pumpkin>
	<179338190237.9376.13820542101227461550@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2304538"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9sR7UjKCXj6suh+wsZneDlgAJ5I= sha256:a+kyXbMGmH7qAdAMFfMymnh4Wmr27pwQ31ggKcvak9c=
	sha1:WhVNjj+Ma7NDlouSIKbYp8x43Kg= sha256:Qs220j7QHZbOksOV9QLtFTAI4V1YlxnxwigL+v8bnuQ=
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 473B7125CA3; Fri, 30 Oct 2026 22:53:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.047
X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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, URIBL_BLOCKED=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 G4H8lxVB19yJ;
	Fri, 30 Oct 2026 22:53:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-353898-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 81D39125CA4; Fri, 30 Oct 2026 22:52:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id DB7A625034; Fri, 30 Oct 2026 19:52:47 +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=1793389965;
	b=CcNlobYXSciZhxxDPdyJTk91nMD84mceDNNF3jeflo5xxVKyRwSelIFL0tupMI5i3C6x
	 WgI/RiZFB81OLLqa/BQgYy4n/5A1NhTGAS2ALA26MVN7nHrOTli4NlLkQ/TJlz7iUY99l
	 CoW2QXEnEeF0BgOhSTpb9Lsit5P4MxVAJyAhaPiUYjPl6FSaAZbBqITR6J1XF/mCUns7c
	 uZm1lU5RMCSSMxR4TPqnKWNqigSoMBpPYWSNNXVfDaxH1HXcc4x1qOO808d+2o77xSWA/
	 EJb1UtW9YoRet/PWjnsJSnFHqyH5qmQPm4P3gVDeExwWND5jicwByXLLL8Qg2uTEBsQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793389965;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:
	 X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=J2FNx9D7Jgf8hIvN2HsGFMpO76oeiBS4WlAa4ihS6JU=;
	b=X0O1XHZeVk43lYFbi0oDqMqtKb3xGr8UVHtmwYrlWPOyr9rrPKHqki/o7FYPAEyPcQBO
	 0Pdd1scCHVcwTHlHXL0R7XF61ydW6PPyE3CD1Hy7nq8hkAcoR7dIm3DF8w2f4cAovpPMR
	 F8lqaTikTlxU4Kow2jDcXVmRq5XNHeibwtSc1D6+uydUKgkfQw9Q/do/Evr8GR4Sr1IWm
	 88UclaqquFlWeD4iT35MyfKztFTs7vaDfl568VRObV/Gtuprl3zcj86m10oIWfPXohYcR
	 6TQm8wIJlQKsaQfJGucz7M6si0jb4sjgnwwlnZwnPHFqndSzDvwGhFLaXwMkx0TTaOQ==
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=20260707 header.b=seQZx+ZI;
	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 0D1B6606A323;
	Fri, 30 Oct 2026 19:52:45 +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=20260707 header.b=seQZx+ZI
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793389954;
	b=aIoX4uWa+ObTO2BhY4FdAnYysZ2lSn/fJuo/xGBzdJHFLYShTwfzGO6iixKoOvhGVaBF
	 fe2m3u2L17wsuvT2dh4TDIrjpoQpltdcO9ZZwTopRB2VF0rcjD8KxS/Ijppt4Kmv7JQKk
	 OV8XLlJHaOPhWIObQwqXlwMYTL+FCaoZII7TwL9pkGYIOHXK38n8HP6pZe8dRbzGHfmK8
	 CREOg6UNbLxcnITEYggN4gInaAhcJzRTekDjS2hyz2jnuH8FG7E3S7B3yrw0ijEQjtkLy
	 qP//2Osoe1nErzWsouZ34/BwrUkYI7G+6LmxdEircw8X+orR5naWt++fNVE8HP4q5jQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793389954;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Date:From:To:Cc:
	 Subject:Message-ID:In-Reply-To:References:X-Mailer:MIME-Version:
	 Content-Type:Content-Transfer-Encoding;
	bh=J2FNx9D7Jgf8hIvN2HsGFMpO76oeiBS4WlAa4ihS6JU=;
	b=BXa/RSj0kw/3qsjgBhvtS/NQvQXsRPctmnxRtBfybxDzAXy9aH+cUtFGkiRZXhyuoyWO
	 UJcUqK3rvhDH064wP2O0642RhJWfkEwg2sYkPD94iyRxZCvGshTgsD32+stMt4gRvC94J
	 lbPauFh0TA52pNpkK9yZN6MJIRT2lLqe/VGLjwuRYyeZu/Q3XLIM/vXyzIbeZ/xVDFA/y
	 HUXDKwFVvLORwdnntsWqKRKK08Vi4g0ezUM5CSxAmzj4VxkQoetN2PoSK7ZZZmORNSyba
	 GX375T9vGP1YAMltVjftw6GdvalmznlJmkzWClSeB00/jneorNw8SMxXktC65CFFKnA==
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=20260707 header.b=seQZx+ZI;
	arc=none smtp.remote-ip=209.85.128.48
X-Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48])
	(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 C9432606A31D
	for <netdev@vger.kernel.org>; Fri, 30 Oct 2026 19:52:33 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C9432606A31D
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-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4a2d6cf958bso5799415e9.1
        for <netdev@vger.kernel.org>; Fri, 30 Oct 2026 12:52:33 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793389952; x=1793994752; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:mime-version:references
         :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=J2FNx9D7Jgf8hIvN2HsGFMpO76oeiBS4WlAa4ihS6JU=;
        b=seQZx+ZIbtq0KWnnRxo4qAuwbIfTV5M5Tt0hFEfcSZpVC/4qfxmXWAlgHkvqs7Fonf
         JP9ViFl0pEjC3CgF2HUO/WCVpmZY+4xvkwXY9cPeunqWxhvuyDIEWExuK2UJ9XZHsB7X
         PDv7KIS+vlLZU1gFWI219gYmvfDLiyVupNSrvHopLA/QfLBv7T0XmQvLIAVp+djwD5TH
         ftdz9KJ7ZJzUPr6GsdJniA5JJ+WDGjkb4enwdnu9d0Dn7D26fpf94Xjl+44GXJcWIRJX
         HeXegDYhhwLj9FqGAtu+EzOKHIf70/D95SuRDpU/wFukrpVI4VUn5VkLvVTKg65k0l+M
         /aYw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793389952; x=1793994752;
        h=content-transfer-encoding:content-type:mime-version:references
         :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=J2FNx9D7Jgf8hIvN2HsGFMpO76oeiBS4WlAa4ihS6JU=;
        b=GnACsCp8AoSIjLUaXwy97a3OP0FURSdcj99NE2P8Y1E11lyiB7M8edUr/NdCpssWBW
         AWiUYhoZZ0k3JcQx/8qxudMrkwBGAozINcu7JE5hglrtoIosFev0PP4dSDqUc0HmQbN7
         4SfaMDwB8RGFMINIJF2LMvKfOccOZ81eIn9UfPYXoM+WHAKUYAYrXRGFr+oD3trJSWNQ
         7hFskZ2JkMHpdKZD2ZHkFHf6abjS7M+cp4mqHv/yCcMuaaaTfFN86nst7rVaJHfio0Fj
         0xfZaI8cBz3sz9bR7R8lrFjb+PnNbUuEIsjZIqsiPcRjjtxcfEZai9BhxE1D0ed+seJg
         KyGg==
X-Gm-Message-State: AFq9FYJDnPELHK0tXfPh1rPW1ZPuRzVRakI0JY+T1ZP/m8DnTTuHoWVb
	6o4ASCCEpHyBqqj1t7f5eWnmUxLBneu20tjRleFSe4Oq/S3c09ZVYg4S
X-Gm-Gg: AYBFou1hF/LeS3jKj1ws0nQTBf5uKF936jWySTNI3QqooaQE5t0UBNOKt5ACfWkplKM
	FRoTYrNL/fibzoxQIvHWqa4OE1j23zj7Fxggf4afQv+DSdonWhfa4fPopDmtD95Ixskd7CEIGTG
	pC6vMcZ/8HEipK+Y4wZZ4pTC6an69yed4c0BB7l76jj+bCzkQR7H6ULFfePu3y8e7MhRtwqyIyq
	/nSqIqe8UQ6zHiuVagwFDu3kpNew/wL37tk8VZdgcYinUqpMUqTTjTchTkFlweSLNSeLXJemE7C
	aFeKXoMfSkbrhmRxlqZzUmo/r+SomwKKQlwkPb4zriMSyp5fbMeWUdopY827cUBfR+gff7RMwhO
	bpPhtCibKrkeO7joo7r4XFnStaV7pPNSBLO+TqH7g/thA5Tjvarh7QSoP6EjnzQt3M010Jcbzn8
	+P5CK22kOTASptDxEIol4BA//VuCfMh+FGAdh5orLRIZOmwqJavJU5/MgMzvDMyprfZdfUuvY2T
	EKEWVEJWnLV3/oCdjrNiCi6hNbuv9+KWpKiTrdtIgDG7eExNBR5IImSRAMsaGIEiFAy26eWlX6m
	Hxe4dphW5M24E7nrz5Wuxu55lTnyMpgCQ3IOisTq4tMfV+7c/aVsC9DwXQcVVnGRu264hzkyIpS
	Uh2YoxD3QZ3E=
X-Received: by 2002:a05:600c:630d:b0:4a1:fae2:a8ab with SMTP id 5b1f17b1804b1-4ac150b38abmr73624505e9.3.1793389951966;
        Fri, 30 Oct 2026 12:52:31 -0700 (PDT)
X-Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4aa80f04723sm179193345e9.5.2026.10.30.12.52.31
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 30 Oct 2026 12:52:31 -0700 (PDT)
X-Cc: netdev@vger.kernel.org, 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-In-Reply-To: <179338190237.9376.13820542101227461550@gmail.com>
X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf)
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