From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796491244; b=rSZtCKBGf6gRVfj2EjxsGcAab51JnguI7RLh4TAjtNUrZFt8yfMcly4Qyb0Ww2qoSCSh Sr0kV+31FXoJdZdCXUm9i3qxr4pe+hAAiuGN0GmmN9Poo+ecVY9Xkp1QDVSX3HYOsBWbq reHDrZa/zD8ix6oSN5LO4zemHzLL51oJ7jkZJQ3yDM+N80sodbiNmblfe0MVKBc+GfIqP ZGVOR6Iw6xkAiykhYdPPjkOeDfaqp+gP6+TiokQpiKuNYsc2GUUYQJheDi3mxuZJ4GBbz o4Be2NnDzXnP9LOcA7HSv10ddtn18dfZY8qo3opfD0/1M6gkLDPPhfElB8S8J9RgDcg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796491244; 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=chXBKNUtsuwNV+MoiLKi8//rixMQDv2/Av3d0oG2K2M=; b=EMa9LYZwc+aI4LEvnzx6XTJiCpSIAZRExBgZqPbywztYKTrPpR9G64Dgr5Cn9lM3iR8K FaiJIAUMJcWDgd4sDz7m0aKUCOuEhxLiWLg4p82RTMPgrOv/WZD/uvAdtY/yOHXgLYyHP DS/qmTY1oSW/KIP2hCwRH3Wp8E5OlZdyn2Hh7/rmKkXm88MbjJMT4IWJcjnVaoy4q0PYN zQNT+NBBBP5+kKlP/hyRcZE454BdX+teIcCPVLD3ASi0Df6w2U8L/1cVZBneSNa5EZ2Gd 4JNqfani9fCjTzf2OYNhXHxiT2BwXYRcHaEfqxFPkQ0Iut7wTChdzlCuutYv969CjHQ== 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=JzbQ+SBM; arc=none smtp.remote-ip=100.103.45.18 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 CE55E606A31F for ; Sat, 5 Dec 2026 17:20:44 +0000 (UTC) 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=JzbQ+SBM Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87FDA1F00936; Sat, 5 Dec 2026 17:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796491244; bh=chXBKNUtsuwNV+MoiLKi8//rixMQDv2/Av3d0oG2K2M=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=JzbQ+SBMeH1QMqc8O+etaRoG0IckTaTcT0H+nhAl72effFeudbuBIa1f1C2R5Y0pj 3jF5uYp8AotcRRKs1KAnpV0nmxDeiK91zMbD+BBoroF/agQgG76mGyRednOf8HShAZ WGgYTa7pb+mOBSqaULUo9DchS5KsTm3l10QzgNeIC0ZAy28NgxRmPIe8cqFsuC9uDF mr5lwCog5Qo5wSKBGRTpDOxICg1WCZaTcf29M7ifgpAXmLvujDrcRlshLBCrhJlscH OKnTI2xWiGimVL9gusB1poQsBHxtI8VbYoPDOeL9WJViioVFvEL0Fb7QtR++k6ro1+ Z9PK8cvubm8Ag== Subject: Re: [PATCH net] net: ps3: Unregister Ethernet when wireless probe fails From: netdev-bot+sashiko@kernel.org To: fuwh1120@163.com Cc: geoff@infradead.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com, mokuno@sm.sony.co.jp, dcbw@redhat.com, jeff@garzik.org, linville@tuxdriver.com, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Sat, 05 Dec 2026 17:20:43 +0000 Message-ID: <179649124305.3146.2081352787535255828@kernel.org> In-Reply-To: <20261204164508.2083305-1-fuwh1120@163.com> References: <20261204164508.2083305-1-fuwh1120@163.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0 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). - [Medium] In ps3_gelic_driver_probe() (drivers/net/ethernet/toshiba/ps3_gelic_net.c), the new wireless-… Pre-existing issues: - [High] This problem wasn't introduced by this patch, but it is a use- after-free on the very teardown path the patch fixes. -- net: ps3: Unregister Ethernet when wireless probe fails This patch adds an unregister_netdev() call on the wireless probe failure path in ps3_gelic_driver_probe(). The goal is to unregister the already registered Ethernet netdev before the shared error unwind calls free_netdev(). > diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c > index d35d1f3c10a18..dc660326bc122 100644 > --- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c > +++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c > @@ -1801,6 +1801,7 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev) > result = gelic_wl_driver_probe(card); > if (result) { > dev_dbg(&dev->core, "%s: WL init failed\n", __func__); > + unregister_netdev(netdev); > goto fail_setup_netdev; [Severity: Medium] Can card->tx_timeout_task still be pending or running when the unwind frees the card? gelic_net_setup_netdev() has already registered eth0 by the time gelic_wl_driver_probe() runs, so userspace can bring eth0 up. If the TX watchdog then fires, gelic_net_tx_timeout() queues the driver-owned work: atomic_inc(&card->tx_timeout_task_counter); if (netdev->flags & IFF_UP) schedule_work(&card->tx_timeout_task); unregister_netdev()->dev_close() stops the core watchdog timer. Neither it nor gelic_net_stop() cancels tx_timeout_task. The unwind then reaches: fail_status_indicator: ps3_system_bus_set_drvdata(dev, NULL); kfree(netdev_card(netdev)->unalign); free_netdev(netdev); If the work is still pending, gelic_net_tx_timeout_task() calls container_of() on the freed card and reads card->netdev[0]->flags. If the work is already running inside gelic_net_open()->gelic_card_up(), it can turn the IRQ mask, RX DMAC and NAPI back on while the unwind is freeing the descriptor chains. ps3_gelic_driver_remove() waits for this work before it frees the card: wait_event(card->waitq, atomic_read(&card->tx_timeout_task_counter) == 0); Should this path have a matching step, such as cancel_work_sync(&card->tx_timeout_task) after unregister_netdev()? To hit this window, eth0 has to be opened and the watchdog (5*HZ) has to fire while gelic_wl_driver_probe() is still running. That may be hard to trigger in practice. [Severity: High] This isn't a bug introduced by this patch, but the unwind that this path now reaches appears to have a use-after-free of card->napi. The card is kzalloc'd separately from the netdev, and napi is its first member. gelic_ether_setup_netdev_ops() links it into the netdev: netif_napi_add(netdev, napi, gelic_net_poll); The error tail then frees the card before it frees the netdev: kfree(netdev_card(netdev)->unalign); free_netdev(netdev); free_netdev()->netdev_napi_exit() walks dev->napi_list and calls __netif_napi_del_locked() on &card->napi. That function runs test_and_clear_bit() on napi->state, hrtimer_cancel(&napi->timer) and list_del_rcu(&napi->dev_list), all on the card that was already freed. ps3_gelic_driver_remove(), which is also the .shutdown callback, frees in the same order: unregister_netdev(netdev0); kfree(netdev_card(netdev0)->unalign); free_netdev(netdev0); With this patch, the wireless failure path avoids the reg_state BUG_ON() in free_netdev() but still reaches this use-after-free. The gelic_net_setup_netdev() failure path and every remove and shutdown reach it too. Would it make sense to call free_netdev() before kfree(card->unalign), or to call netif_napi_del(&card->napi) before the card is freed? That change would be needed in both the probe unwind and ps3_gelic_driver_remove(). > } > #endif -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204164508.2083305-1-fuwh1120%40163.com