Article View: linux.kernel.netdev
Article #21751Re: [PATCH net] r8152: do not (un)register the PM notifier under RTNL
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 12:30
Date: Tue, 24 Nov 2026 12:30
127 lines
12494 bytes
12494 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] Moving unregister_pm_notifier() out of rtl8152_close() removes
the only thing that kept rtl_notifier() from racing ndo_stop.
- [Low] The commit author address does not match the Signed-off-by
address.
--
r8152: do not (un)register the PM notifier under RTNL
This patch moves register_pm_notifier() and unregister_pm_notifier() out
of the ndo_open and ndo_stop handlers. They now run in
rtl8152_probe_once(), its error path and rtl8152_disconnect(), which
avoids a deadlock between RTNL and the PM notifier chain rwsem. It also
adds a PM_NOTIFIER_AUTOPM_HELD flag, so the runtime PM reference taken
by rtl_notifier() is only dropped if it was actually taken.
> Fixes: 5ee3c60c8d3b ("r8152: fix the wake event")
> Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com>
[Severity: Low]
The Author line uses yuanhsinte@chromium.org, but the only Signed-off-by
uses yuanhsinte@google.com. Should these match?
checkpatch reports this as FROM_SIGN_OFF_MTCH ("From:/Signed-off-by:
email address mismatch").
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index d3bb7ee9c9bf3..fea47a8924149 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
[ ... ]
> @@ -7155,9 +7158,6 @@ static int rtl8152_close(struct net_device *netdev)
> struct r8152 *tp = netdev_priv(netdev);
> int res = 0;
>
> -#ifdef CONFIG_PM_SLEEP
> - unregister_pm_notifier(&tp->pm_notifier);
> -#endif
> tasklet_disable(&tp->tx_tl);
> clear_bit(WORK_ENABLE, &tp->flags);
> usb_kill_urb(tp->intr_urb);
[Severity: High]
Can rtl_notifier() now race with rtl8152_close()?
Before this patch, rtl8152_close() started with unregister_pm_notifier(),
which does down_write(&pm_chain_head.rwsem). That call waited for the
whole PM_SUSPEND_PREPARE chain to finish, including the synchronous
runtime resume started from rtl_notifier():
rtl_notifier()
usb_autopm_get_interface()
rtl8152_resume() /* takes tp->control */
rtl8152_runtime_resume()
The notifier now stays registered for the whole lifetime of the device.
Nothing seems to stop this path from overlapping ndo_stop.
rtl8152_runtime_resume() checks netif_running() once and then does:
tp->rtl_ops.autosuspend_en(tp, false);
napi_disable(napi);
set_bit(WORK_ENABLE, &tp->flags);
...
napi_enable(napi);
...
usb_submit_urb(tp->intr_urb, GFP_NOIO);
At the same time, __dev_close_many() holds RTNL, clears
__LINK_STATE_START and calls rtl8152_close(). That function does the
following without tp->control or an autopm reference:
tasklet_disable(&tp->tx_tl);
clear_bit(WORK_ENABLE, &tp->flags);
usb_kill_urb(tp->intr_urb);
cancel_delayed_work_sync(&tp->schedule);
napi_disable(&tp->napi);
If the napi_disable() in close runs first, would the napi_disable() in
rtl8152_runtime_resume() loop forever? NAPI stays disabled until the
next open. The resuming task holds tp->control and holds
pm_chain_head.rwsem for read.
rtl8152_close() would then block in usb_autopm_get_interface(), waiting
for that resume while still holding RTNL. That looks like the same
suspend/RTNL hang the commit message describes.
If the napi_disable() in the resume path runs first, close waits for its
napi_enable(). The resume path then sets WORK_ENABLE and resubmits
tp->intr_urb, which undoes the teardown. Close then continues into
rtl_ops.down() and free_all_mem():
free_all_mem()
usb_free_urb(tp->intr_urb);
tp->intr_urb = NULL;
kfree(tp->intr_buff);
tp->intr_buff = NULL;
Is the interrupt URB still queued at the HCD at that point? If so,
intr_callback() would read the freed tp->intr_buff and resubmit the URB.
That would be a use-after-free, with DMA into freed memory.
Other autoresume sources, such as remote wakeup or hw_phy_work, can
already race close this way. The PM notifier, though, is a new trigger
added by this change.
This needs an interface that is up but runtime-suspended, and an ifdown
that runs at the same time as the start of system suspend or
hibernation. PREPARE notifiers run before tasks are frozen, so these two
can overlap.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-r8152-pm-notifier-rtnl-v1-1-31e011a2ee51%40google.com
Technical Details
Message-ID:
<179552343569.3135.5205506648034787768@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370327-linux-kernel-netdev=dewy.ruReferences:
<20261123-r8152-pm-notifier-rtnl-v1-1-31e011a2ee51@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370327-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] r8152: do not (un)register the PM notifier under RTNL Date: Tue, 24 Nov 2026 12:30:35 +0000 Organization: Usenet Network Message-ID: <179552343569.3135.5205506648034787768@kernel.org> References: <20261123-r8152-pm-notifier-rtnl-v1-1-31e011a2ee51@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4133120"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:nIzNwgvABc95q8y1WU6RvWchVno= sha256:/z7CJZ01qVVYr4C78ac/hVY5Y82amUNuaWi12uWgXAA= sha1:hSGD3UBCTU2BajXcs1vshwt2Z+I= sha256:n8TVM0bmH2IJMvg9kSNPcgGWxV+HZT+itZtwi0aknl4= 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 63E38125E13; Tue, 24 Nov 2026 15:31:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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, URIBL_BLOCKED=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 KN3PeYDRJc0S; Tue, 24 Nov 2026 15:31:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370327-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 1867D125E0A; Tue, 24 Nov 2026 15:30:55 +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 6449A398BE; Tue, 24 Nov 2026 12:30:40 +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=1795523438; b=Jk+O6yN75zPkH9hOP2K9n4pvAzt6rIKje/11lwxS5jZlNRTTp7Hc9eln8HOL2g299lEN HGFYmfM/+4kPQjsKcU2QEGwESj1isoEpglpBq25XZj6bKenqX8SGcQva48mVwS1QNfUj6 xcEsGKKaDyeVGhxajxzk5lYVM1/Hl9mya3oWS7/ZtFLogYDjk5NsYvfEm14HOH8Vt1zxS fSRxoXpDT4AVSF/ta+hR09V5IIDQWfrARnziMXNr/LN+PL5dNfJvsnwTypXibCFVxpawg 2huEbXEWRPASzcYZy03/vysp+ByTvGUOEk00FLps2cIrg8vc1yqNQMxEYGYDZC0t4hw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795523438; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=DMPNZchYUXAtwehIK7vlljCTJPCza5ZwhkvTZtKsMCs=; b=mkjhTlJVVAXRPd75mpXOnOGY5meEDgsRYzFiV+aOLzFoyyhIdETeJyVRYSouAjH7IMcH PJQOdOPMjxto9IAcfsfElilDIc6u9KkB7ph6n4zCtJzUmM+LHAVSr9D+j9D3jZlwhoZqG VVV7JpV5ctnO/gDm7cwrhwV7PRXVH5HzlHHvjNpx7oHwCQ13PX3TUZsKiT4cm3FHsYkDS Lk7+BhpJPThuafvny+1tVySMsVgjFJXGFJGZY4pQBDAWWppFB5B4Q5HZsS7W1YAsd4Gke P5o+j+8Ws+XNP8eiwpvrXxmr2SyqNpuzwDzDg+LbdqML/aFDYU7bVuxjn6P0I31w9xw== 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=ddjD9Lta; 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 0EF53606A69C; Tue, 24 Nov 2026 12:30:38 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ddjD9Lta 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=1795523437; b=CDkaOKeyf/jtF8UBtiSyhTWIf2Doj0QmI7C+iUHkDB6kpxM5E3xolLzvRShVM05+l23h CRIfHW9LdzktU8aleIABcLmxPDKTtA3Moc6e477BI9gnhVqQVzaAc3toHF4Sy5YL+RWAh tA06Rx4oyf93MzwoW2KzTiJupZGE02rR4FfKro794RPJ2SIMv8eBMdmbd/rv+aiHxVXag UOUsYnaxQ7G/4nIUOfqen2hd8WtmE6EYp+mWYe/ZcDM2HbLzvNV4xoT9gydN4UHrPgLH7 MTLF3DFAPzWyJp6mJT21Xt/7qHisGF/VfAzHomfHGotKgSv2rh7ItE6hj5DLPJTxJNA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795523437; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=DMPNZchYUXAtwehIK7vlljCTJPCza5ZwhkvTZtKsMCs=; b=Tpme4ShFxiC/xVJLFC6Sfeee6hx80ZjhcACAiGFH4SmBJZsgF37EZVPWt1KpuPQ8RTgh 0XI2AUhV5uXEDCmWIAeOzshDywnHKe3L2I1UeRDCeNsLyEB5Ydo61wr0agpJ7fk2JrDdM yFJZSgAIHnCTlVr5t+COj1hLsculWHHoLQ4dsnIGEywwxjZ7kupgkMN0JZULJ42GSmUg+ Y3+/b//CLPbHpxlKI5P2639OTNnajcHVQiY5RxWyvwwZ7O2Z8xUt7NjcjXK53gxQBGc+u p4iohCg0Rev17rQ5PE55gDiMQVym+y0jEdKETFRo4ZadEwafEADNMfvsleXiUyJLWaA== 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=ddjD9Lta; 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 302C1606A32C; Tue, 24 Nov 2026 12:30:36 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 311301F000E1; Tue, 24 Nov 2026 12:30:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795523436; bh=DMPNZchYUXAtwehIK7vlljCTJPCza5ZwhkvTZtKsMCs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ddjD9LtaKuCVkbyojVHPhNS4t+pc55bD4CUt6VEN1qwQhxvzSRKM1oI7yFCfQlNme hEeDcowmUheWXIIiTXTk5YSG5WeoiWo1QFQ/VW76y8vl1m2rpuZzlmPZE2+c0ZjiWV 2cKXHfoiPP3AyoQySMWUAd19CJsdSvaLakRVxz/BVAYig15XmJVT8odLnXFa0JhY+R u5LheZ3nyc7ldOIKxmPY5i9visrPOXSz68/V7aBCJrvdYkolQG/cMXGRa+ZHCFlH15 bMz8Q8O11rx10h+n62Kd7KxjnyKV7EvOBl5CORhghTQFACIEFqVyaUoW6qBjuAC9pK u/ZTp38una2eQ== X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, hayeswang@realtek.com, linux-usb@vger.kernel.org, netdev@vger.kernel.org, yuanhsinte@google.com X-In-Reply-To: <20261123-r8152-pm-notifier-rtnl-v1-1-31e011a2ee51@google.com> X-sashiko-severity: High 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