Article View: linux.kernel.netdev
Article #7304Re: [PATCH] ipv6: raw: fix use-after-free in rawv6_send_hdrinc()
From: Hangbin Liu
Date: Mon, 26 Oct 2026 03:11
Date: Mon, 26 Oct 2026 03:11
78 lines
10738 bytes
10738 bytes
Hi Qiuyue,
On Thu, Oct 22, 2026 at 08:31:41PM -0700, Zhou Qiuyue wrote:
> rawv6_send_hdrinc() saves a pointer to the dst/rt6_info before calling
> l3mdev_ip6_out():
>
> skb_dst_set(skb, &rt->dst);
> *dstp = NULL;
> skb = l3mdev_ip6_out(sk, skb);
>
> When the egress device is enslaved to a VRF with a non-default qdisc
> (e.g. fq), l3mdev_ip6_out() takes the vrf_ip6_out_redirect() path,
> which does:
>
> skb_dst_drop(skb); // drops refcount on old dst -> call_rcu
> skb_dst_set(skb, dst); // installs VRF's own rt6
>
> The old dst entry (the one `rt` still points to) now has refcount 0 and
> is queued for RCU-deferred destruction via dst_destroy_rcu(). After
> l3mdev_ip6_out() returns, rawv6_send_hdrinc() continues to use the
> stale `rt` pointer:
>
> IP6_INC_STATS(net, rt->rt6i_idev, ...); // UAF read
> err = NF_HOOK(..., rt->dst.dev, ...); // UAF read
>
> With expedited RCU grace periods (rcupdate.rcu_expedited=1) and
> CONFIG_PREEMPT=y, the RCU callback fires quickly enough to free the
> object before the stale accesses, producing a slab-use-after-free
> detectable by KASAN.
>
> Fix this by reloading `rt` from skb_dst(skb) after l3mdev_ip6_out()
> returns, so subsequent code uses the (possibly replaced) dst entry.
>
> Fixes: a8e3e1a9f020 ("net: l3mdev: Add hook in output path")
> Signed-off-by: Zhou Qiuyue <n0ps1edzz@gmail.com>
You need add a target repo for patch subject. e.g. [PATCH net] ...
BTW, you patch doesn't apply to the current net tree.
Applying: ipv6: raw: fix use-after-free in rawv6_send_hdrinc()
Patch failed at 0001 ipv6: raw: fix use-after-free in rawv6_send_hdrinc()
error: corrupt patch at /net/.git/worktrees/tests/rebase-apply/patch:25
Please rebase you patch with latest code.
BTW, please remember cc all the needed maintainers with scripts/get_maintainer.pl.
> ---
> net/ipv6/raw.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
> index XXXXXXX..XXXXXXX 100644
> --- a/net/ipv6/raw.c
> +++ b/net/ipv6/raw.c
> @@ -648,6 +648,13 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
> if (unlikely(!skb))
> return 0;
>
> + /*
> + * l3mdev_ip6_out() may have replaced skb's dst via
> + * vrf_ip6_out_redirect(), in which case the original dst has been
> + * released and may be freed asynchronously. Reload rt from the
> + * current 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.
> --
> 2.43.0
The change looks good to me.
Thanks
Hangbin
Technical Details
Message-ID:
<at7E0uc5oU8AWZcD@fedora>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351669-linux-kernel-netdev=dewy.ruReferences:
<6adad51d.8fc0b0c9.1ec657.1868@mx.google.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-351669-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] ipv6: raw: fix use-after-free in rawv6_send_hdrinc() Date: Mon, 26 Oct 2026 11:11:14 +0800 Organization: Usenet Network Message-ID: <at7E0uc5oU8AWZcD@fedora> References: <6adad51d.8fc0b0c9.1ec657.1868@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1209741"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:NOAuzJsA3fjEboLJdtJJC3YbHjQ= sha256:HCK2nQkcaN1IXIdWUwXLju/EEQTboKM1Rgtlf6Zt/JY= sha1:+4+BqiQOi3CkzBmNLtJk1FsYaNU= sha256:255lC1k/tA/u+ueCg/O9yBdQDWStcblafdshDXacHnc= Content-Disposition: inline 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 07E87125B87; Mon, 26 Oct 2026 06:13:14 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 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, 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 (1024-bit key) header.d=linux.dev 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 8MsWzz4EBOQx; Mon, 26 Oct 2026 06:13:10 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351669-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 4FB0C125B7B; Mon, 26 Oct 2026 06:13:01 +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 B49D027886; Mon, 26 Oct 2026 03:11:29 +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=1792984289; b=iuDGkwZ+U+42Ob4iZCvAgwmZqlVSf/MAK6AhYC6h+3MIHSx/QgT7gcUbik70i1xrc8ZL Hn1yVpfmPpQstzK9ZxjsEsz8Ds1EfwdxLDl3zdsPdO4xZgKvdwnvrpa594nrbfArQM+47 bjSDIeLvfMBG7fHJ8yz5vL4dFeqsUbGc686Fbpjd1GhS8xK0K8Y+bH5sVIl31Ds3CL894 CwQGTK8LN0f4ipGVZma5p7q2xBVj3teLap0kVjY6vni6hncC7j55zHfmlOVl8LaiuLktd kXxYBUJ9BXlDeuito9EODTr4d91J02PUicZrvuMlPJZudWhUTwZzJTVgBkhKWT7F97g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792984289; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=+LYv4FFAPGIAsOArb3pNFw7gnJa7ff2ymguPx9gtgLE=; b=sFvsJfVMTdEdxXDaJqYYGmHpZCRV1GDLST0SozCiThgK4MxhXfKW2xIsjdsI+Xi5z7H+ WME/ANa8lNYXxrWez4822cB0V2+zVld/u+v8cAmEvZA0RakHtg4cw6UfQVnQiM60pGlwg wA2sZa18GLY3Bo2CUWTYyPB6mwSaDcDnhPUledTyK7M9+/B/pGrWQBL9W8C5WayHCagWu 1Vb7wV3/1ZMxpunOnImO4M58MeJhpvo+DtSGToRNkHHs3N+viwlfDfW5C2c8gxycnfWGc VCg4qKCSE3gFIWOe48pAs1DFXiyUShPiT/hAgM1yCumqrD6qu/mwzHW3NMCx7P2uYug== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=lv94U6cm; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 881A7606A321; Mon, 26 Oct 2026 03:11:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=lv94U6cm X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.134 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792984288; b=U8lY3gbSNcWZDXHIaUHH6K/uz2Eu1uuouKXy3//daGNI2KCpYVHfWeJDBtWLU/yvbABV WKeSflh43U5saxkvMEgegYXLsg8QkkYEdLcIz2Asac7DyOqjx8GSkfr3e6u4a2qnpV90h ZtgFehfHcuMzhARGrPdrRfqBuwNwzSMPL4ubFhRij4ohNq3nLVlXkk+hRrjRJbXX+bFOL KxYWhnAO1WtZITocNbAxgCzqn4FUJrbw2VvesDxSltvWaSjvgPG25hrYj0TuPwA/EhP12 sTzyFL5nCrB73p01mCP6YEqN6MICE+IIgrqcnTElaQNnBuz9Ov4sH5ciD1LcM1IE0HA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792984288; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=+LYv4FFAPGIAsOArb3pNFw7gnJa7ff2ymguPx9gtgLE=; b=XRKixp+hcHhd0PeXqZ5x+kOc1VPUyYK4u6iceAtC/qZttpSPdF3iMYG+M7ClyYvJSLai cPsQB9VEMzVBbrcr+f2hryQXpIFLGBizol/Rpqqsbiq2E5oqJLn87QaF7nj1Ux30j75pt 5owngKkkyEFDVJ04kl5ANyyd7HKwHRfKBBRyGk1UxpIbkIZ2x2nMI7qL1tujIuIE2K9SU B/vBJO/yxk16dHo5A7rgmhT5Z0DI6gHu+iSrugso/IW29Nj17myzG8sJQ7OLr+lqVi8Cv yc8uLW/YGJOd8Xzp7W7e0vSXJ95Esrcalf39eLv8+Dl1Jgx3ez7aYO5U5zi8WU9lR2A== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=lv94U6cm; arc=none smtp.remote-ip=91.218.175.134 X-Received: from mta0.migadu.com (out-134.mta0.migadu.com [91.218.175.134]) (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 C1880606A31B for <netdev@vger.kernel.org>; Mon, 26 Oct 2026 03:11:26 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1880606A31B X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=LCccKxR1YRRVCuIaocwIJsSOibmvazapcXVPPlxCnPs=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792984284; v=1; x=1793589084; b=lv94U6cmrmkza8kVMga5PF3q1XrYhDfXCeRh4PK1Wb9lMkuXd4t/TF4GcKSVLHkwCBw9hEBd 41WsdCUKZ2O8Lluv/j5LaQIq2KLS9B0U036HWrriUKzeqjfMecclbJdvEnAvKUETCh1REijIKHn xmg5nypxKF3O9NjwWRKtzSM4= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta10.migadu.com with ESMTPS id 3f44c337d3a366c3; Mon, 26 Oct 2026 03:11:24 +0000 X-Mizu-Trace-ID: 3f44c337d3a366c3 X-Migadu-Flow: FLOW_OUT X-Cc: netdev@vger.kernel.org, dsahern@kernel.org 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: <6adad51d.8fc0b0c9.1ec657.1868@mx.google.com>