๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10509

Re: net: rtnetlink: rtnl_link_unregister() vs in-flight RTM_GETLINK dump readers -- v7.3 lacks the synchronize_rcu() fix (Fixes:...

#10509
From: Eric Dumazet
Date: Tue, 03 Nov 2026 15:49
90 lines
13910 bytes
Le mar. 3 nov. 2026 ร  12:57, ๅพๆ™—็ฟ” <xuhx@hust.edu.cn> a รฉcrit :
>
> On v7.3, rtnl_link_unregister() removes the rtnl_link_ops from the
> global list and immediately destroys the embedded srcu_struct and
> frees the ops memory -- a concurrent RTM_GETLINK dump that already
> found the ops (rtnl_link_ops_get(), rtnetlink.c:599 hand-off inside
> an RCU read critical section at :595) but has not yet taken
> ops->srcu will, after the free, execute __srcu_read_lock() /
> __srcu_read_unlock() on freed memory: two reads of the destroyed
> object (ssp->srcu_ctrp, ssp->sda) whose subsequent percpu counter
> writes land wherever the freed percpu pointers point -- for a module
> rtnl_link_ops, the ops (and its srcu) live in module memory, so
> module_memfree() is the freeing side.  Upstream already fixed this
> with a synchronize_rcu() in rtnl_link_unregister() (the patch with
> Fixes: 6b57ff21a310; its own comment: "Wait for rtnl_link_ops_get()
> readers that found ops but have not yet taken ops->srcu").  v7.3
> does not contain it.  I verified both sides on a stock 7.3 KASAN
> kernel: parking a real dump reader (driven by an ordinary
> RTM_GETLINK + IFLA_LINKINFO dump request) exactly at the :599
> hand-off and unregistering+freeing underneath produces three KASAN
> slab-use-after-free reports (__srcu_read_lock+0xe, +0x25,
> __srcu_read_unlock+0x1a; bad address = ops+0x10 = ops->srcu); and
> rebuilding the SAME kernel with ONLY the upstream one-line fix
> flips the outcome to zero reports, with the kfree demonstrably
> delayed until the parked reader left its RCU section.  Natural
> hammering did not hit (the hand-off window is ~100 ns against a
> ~4 ms unregister -- it needs a preempted/preemptible-RCU reader),
> which matches the fix's own reasoning; the controlled run models
> exactly that preemption.  The purpose of this mail is to support
> the fix's propagation: trees still carrying the unfixed
> rtnl_link_unregister() keep a cross-CPU UAF (write) plus potential
> freed-module execution reachable by unprivileged netlink dumps
> racing a module unload.
>
>
> The detailed description:
>
> * The gap (v7.3, net/core/rtnetlink.c)
>   rtnl_dump_ifinfo() runs lockless for dumps
>   (RTNL_FLAG_DUMP_UNLOCKED), takes rcu_read_lock() at :595, calls
>   linkinfo_to_kind_ops() -> rtnl_link_ops_get() which returns the
>   ops pointer at :599, and only then takes ops->srcu
>   (srcu_read_lock) to call ops->dumpit.  rtnl_link_unregister()
>   holds rtnl_mutex, removes the ops from the list, calls
>   cleanup_srcu_struct(&ops->srcu) and returns to the module, whose
>   exit then frees the module memory.  Nothing between the :599
>   hand-off and the srcu_read_lock is waited for on the unregister
>   side in 7.3 -- hence the fix's synchronize_rcu().
>
> * Evidence (stock 7.3 KASAN, QEMU; A/B on the one-line fix;
>   reproducers attached)
>   rtnlrace.c registers a kzalloc'd rtnl_link_ops (kind "rtnlrace"),
>   parks a dump reader by kprobe at the exact hand-off (return
>   address rtnl_dump_ifinfo+0x374, ENDBR-adjusted), and unregisters
>   + kfrees from another thread (modeling module_exit ->
>   module_memfree).  nlr (userspace) sends the IFLA_LINKINFO dump
>   request that drives the reader path.
>   Defect kernel (stock 7.3):
>     park t=127041 (1004 ms) -> unregister+kfree at t=127249 (park
>     +208 ms, reader still parked 792 ms) -> park ends t=128045:
>     BUG: KASAN: slab-use-after-free in __srcu_read_lock+0xe
>     BUG: KASAN: slab-use-after-free in __srcu_read_lock+0x25
>     BUG: KASAN: slab-use-after-free in __srcu_read_unlock+0x1a
>       read stack: __srcu_read_lock <- rtnl_dump_ifinfo+0x374 <-
>         rtnl_dumpit <- netlink_dump <- rtnetlink_rcv_msg (task nlr)
>       bad address = object+0x10 == ops->srcu (matches the
>       disassembly lea 0x10(%rbx))
>       alloc: insmod kzalloc;  free: unregister thread kfree
>   Fixed kernel (same sources, ONLY the upstream synchronize_rcu()
>   added to rtnl_link_unregister()):
>     park t=191305 -> park ENDS t=192306 -> unregister+kfree
>     t=192307 -- the order literally inverts -- zero KASAN reports,
>     dump completes with zero errors.  Same module, same parking.
>   Natural runs (three samplings, up to ~267k dumps/reader plus
>   6-CPU preemption spinners): zero hits; the window arithmetic
>   (~100 ns hand-off vs ~4 ms unregister) explains it, and the
>   controlled park models precisely the preemption the upstream
>   fix's comment describes.
>

What is the point of this email ? This looks like LLM slope to me.

I think we have far more serious bugs to fix.

3b70edea393d was tagged stable+noautosel on purpose: the race needs
a module unload (CAP_SYS_MODULE in init_user_ns) to line up with a
~100ns window, which your report also shows you could not hit
without a kprobe. It is not reachable by an unprivileged user alone.
Technical Details
Message-ID: <CAL4WiiqeBmBZjmzXAqQB3rzBz_ew72euAs2uuvV2icnQ2RCc+w@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-355773-linux-kernel-netdev=dewy.ru
References: <4c7f9772.192e1.1a17d5c2ed5.Coremail.xuhx@hust.edu.cn> <2026102727-data-sequel-ce41@gregkh> <42fe949f.1d67d.1a1a145bcf0.Coremail.xuhx@hust.edu.cn>

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-355773-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: net: rtnetlink: rtnl_link_unregister() vs in-flight RTM_GETLINK
 dump readers -- v7.3 lacks the synchronize_rcu() fix (Fixes: 6b57ff21a310
 family); A/B reproduction on stock 7.3
Date: Tue, 3 Nov 2026 16:49:14 +0100
Organization: Usenet Network
Message-ID: <CAL4WiiqeBmBZjmzXAqQB3rzBz_ew72euAs2uuvV2icnQ2RCc+w@mail.gmail.com>
References: <4c7f9772.192e1.1a17d5c2ed5.Coremail.xuhx@hust.edu.cn>
 <2026102727-data-sequel-ce41@gregkh> <42fe949f.1d67d.1a1a145bcf0.Coremail.xuhx@hust.edu.cn>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3204252"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:BlHENi8tqw2453YIFPNxzUFm4Mk= sha256:3CKmqb/viIzEhM1u2mcB+rd6cwTQnMXah9mG8qWTAmA=
	sha1:8YAJhVEfL4z2TBE4doMRR6G/Iek= sha256:9b2QhFUsgw9PtYcNUh7kWhl3GfOknkZchdSwRIc4i+0=
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 C68DB11293C; Tue,  3 Nov 2026 18:56:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, 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 7tgubPRsQH_3;
	Tue,  3 Nov 2026 18:56:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355773-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 40CA011292D; Tue,  3 Nov 2026 18:56:40 +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 CA09F60A632; Tue,  3 Nov 2026 15:49:49 +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=1793720983;
	b=4P7XjbFGgJWUZ/OeYkWQs9nUKd3gELj3wwk1Ys6OTMufwWAwc0A5nSssc3up/3AkfUI4
	 t1eeqGnvumy9HPZkTbrPUw/8hbpjIXgf4UaPpUlVuM87BDRj+USv1Z2XKKyzGw5xXrhOA
	 AAYVeiAFsoMjLbfSECiiOKRXhGNv6RCNrsga67YDyWiZNyiTVDmVTliY6fVUjdHfnaf2Q
	 S9r7TL8Cd20m1yC2HuyY4NbGFO4IfEadwhUh/x5lhm4eYRucom1ODphYYA4BOIXJZTl7Q
	 831HU1WMXaNrz9CZlGspmcI4SZSvzzmj8lyFOQ4Nq+6vKOOoDTG8eJSq1gsAgrkIodQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793720983;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Forwarded-Encrypted: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=yBVvkEycBHDzcqtk64wG1ZxAfNP7O82hXAvWkVI1BMY=;
	b=hgkjji80AbwW8HzBUKiSksol0mmHqCL07gGpV1MGulxbOaQ5bjvT4/dpZX8lcZRZ8Y4A
	 RL52FMDXnz08BxAp0hLAQMX90P0WdMrredkN0ULoLfHtE3Avk3+rEH/lOKP0druVMdb4v
	 ZTEKdTvWWCXQHsmVzR0lbUpdO2kx/Gh+ZTE25q2JaUK/1QHxCgNeHuISYUq4jcSlCze0s
	 FCWXncZuBHeqcNepf3DZrGUJuVlvJCW6YsQxR9wRwXezIBjse4USRO3HdCu52yGo3VUBN
	 5fA4XlBd2j0udrYsDlEXhYbsxN/zDFisev9kFZz5yzVuaJaIpT7PTAocF7J1E6IWtmg==
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="Flj/gEvw";
	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 34CE7606A326;
	Tue,  3 Nov 2026 15:49:43 +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=Flj/gEvw
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=1793720967;
	b=fGUBVy5J4BccVoQNSf3/tg9YVM8cEMJCHrK+CjdidyfkfeiMAY9z0rdjqzpv+3f+4U+h
	 w4SU9Y35/wBKA1aYtV6OxTUVEetTy0KdlS558Xr4C54sBBqRD61fRis66PsKACGsX9euw
	 7KJGeM5NZ1vQjf8Z1URTCTvacJPE0fyaaYz5OvQGMbzvdkGUVU9rolcQdJcquqsXBlSPO
	 zqnEQvLALjBU0hvjydoPGu8Carir/C0CBcCUxSTWx5uWaUp3ZkKGJPbJt1xJJqYqol01S
	 9w0s9Ruvrop+RCyL/Gp/plTUTduMwoyzQcogEFUhP+2asTJgir3n55u6KHyX1Lx3DBg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793720967;
	h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
	 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=yBVvkEycBHDzcqtk64wG1ZxAfNP7O82hXAvWkVI1BMY=;
	b=LB0om5BlqS61/aZmGjPFtilpxdwbEcBrkJwzzym3I7qZrg5cXQbC8977uutGDw8snTvk
	 CzytQDiK1cD2zuxOTNjpVUWVEJyW2Qs2jSvfsrT+ChHLLwqqMXkjxYAZwxE4sLYL1mmgD
	 SXfuZyGUglsCNDkZFYdWQ2nLvYfnA/Zk/vKvKiFVydWk4LRwktF8Uj+1Zdjnh7VcgmnOS
	 LHE1Nx911HYG7LlFvtFb1WMOsJKcZjQP1ttDkwBLM5eGux9jmZ/gaeCFw4p6LM10CwMPH
	 BhphZJIup5MEOlXsdFlOfoherU/L40sV2lF5gmR9mQZnW/LCU6ZA/CUxEzYbyyXXecQ==
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="Flj/gEvw";
	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 81784606A329
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 15:49:27 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B0F81F00A02
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 15:49:27 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793720967;
	bh=yBVvkEycBHDzcqtk64wG1ZxAfNP7O82hXAvWkVI1BMY=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=Flj/gEvwZypjbqAT2i1vuTfp5IOXUKYT8EjKGdi7LN3DHt4HYMnZORez80eHDd1Fm
	 HAyPvUudcDmOAEOo9lywAAV8ddmcz1jT9qfebWnZnDPgwpjEKXkNyZSxqPC9gj40zh
	 ZdDyehkiL6JMFReGiCTUCibEwt/fMH3pCkT2frvcduMWbugKOnbYI13lA3eAjRTTeK
	 mrMPfWC8MmjGJRisRPHKpgo6c82qjTS82+i0cs9eTro7PTaghgQBENLso0VI2RLrl9
	 LcDuANSHauUuJNLFMTtBPMAVC+tS9P7Tugi5gVupqkrWgPaoe/KfTqtSYYLwwU4OtH
	 o9fHOKWUt6XqQ==
X-Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-4a89b4a59a1so626601fac.1
        for <netdev@vger.kernel.org>; Tue, 03 Nov 2026 07:49:27 -0800 (PST)
X-Forwarded-Encrypted: i=1; AKwUvBzERVeNSHuU2dHSa1tGt7yb5XWbSX/MAN/VprAAkCmDYp2/R5H8/ZpAZcUzOntXvy3pT+pH7i4=@vger.kernel.org
X-Gm-Message-State: APuU4Z8NJYYBBufhdfWaZybW4syG/e6h/oJLBm84xBePg8dupx8Y0ZW7
	o8yTUH/tyt4nD47W8qQF6n8brxhmrWNGoVOGHnCEwrgG+o6RubP41cqo8Yv+5S7DymbE+obe9KD
	C/hOnoNGffo1kmplH/5I0S7dYgN8QNf0=
X-Received: by 2002:a05:6871:81e:b0:490:d828:a7e5 with SMTP id
 586e51a60fabf-4a8e0a550bcmr7291633fac.30.1793720966471; Tue, 03 Nov 2026
 07:49:26 -0800 (PST)
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: <42fe949f.1d67d.1a1a145bcf0.Coremail.xuhx@hust.edu.cn>
X-Gmail-Original-Message-ID: <CAL4WiiqeBmBZjmzXAqQB3rzBz_ew72euAs2uuvV2icnQ2RCc+w@mail.gmail.com>
X-Gm-Features: AclHuK9zoFVvLkrFhmzzNCmXBvvs2C3RSpC5VfgBv-CSUvJgAvXjLkZlmpxUO7k
X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, 
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org