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=1796364846; b=ClMuSwmi3TTYnDD3aVbz9Y+GYvSN04Gr0UEljImJTA7RpZGem2b/cwifvyOuu4+6zxm/ KC+SyD+RqhbRPOdZ/Gt5xWzORNoR23infnTuZO/gphgGXT5/UGQed75tlnAB0+1Uu/V1I n0u59fFOdvSDYU5VwiBtNhUuSuEzusPJvGUvzCjRVK+FHAc6asEr8JKmKEK6ZrPfNsRBv jnBeopZwslJlaeA55E+sZQAS123mgzHpuaCw01DRMPcg9pjXLsuHecizLkwvXQ6yarFuO pIJWjTXlse7TEQCMP3XqwU1mB+xYGL/0AS67oY1EeYgz7SwDuV4NoHKS9QWHFgCr+hw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796364846; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=a62BVquLYiI58Fjvq3dB3LaJbiA5E8TAgnkRbArn1ws=; b=W/1wcLDATvfW94KWEuaJzsD450Qb2sQGsIbZHJdrMYbK1YAG9ufQcnYrUO4xPBTlKEl8 wZzr//JjLCwmm5uFXauGlKYGAz2v+bKCjyKXc8h4hqb8BjV2XbIuWNv+169CDsaIUFKX6 MbM7bsj6Ve6iH5Rhjbs5NQ2x4iMvHQDVmnuPfjgPqDFp5VAikv0ywabuFi4k8kv/vXjER HFzE1o2W5DGzMTh12H3AfCsoV3auOUWuF92p6aOMeaXc+SGvH/IVZqql56oocdxY3Y5DA cxnaFu6g1ekrcpOkpfdUthNxsv4FZAvdZ5Q9/HYg67rVKPYf39ezE+D11K+ja7K8Bcw== 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=Z8loGAns; 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 82D54606A32C for ; Fri, 4 Dec 2026 06:14:06 +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=Z8loGAns Received: by smtp.kernel.org (Postfix) with ESMTPSA id E66D21F000CE; Fri, 4 Dec 2026 06:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796364846; bh=a62BVquLYiI58Fjvq3dB3LaJbiA5E8TAgnkRbArn1ws=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Z8loGAnsSA8vW6mzGgIYjRx2uywgX/BELxZ5tDTv30S6lYsq0xYMcoJlcB6EDS3tX wPu5TgtdvwYBPG0CIj2j17RUVJiXw4AZaFoW1nFwIdMgZaCFPcoLgaK6usIDEEhcxw iMb5pQXOR6/kxzFY9iqwkWtTyR9oIpG6M+pIO6vQLLJ78V8gawcvKGH5e3fIqaqDQ4 U8QIfsoNb5nwt2pZwNVKcORPert5dj1yUBF0QTknnxszzYRQewYPSOmYjBpXAAWogn 0Hr3JwCgfLfAjhNNQethUBX52KLOdzL71bex4QmB+j9XwurPD5hyijB1beXsYI4DeQ l6HEQu+aDN9SQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH iwl-next v2 2/4] e1000: use phylink for a CE4100 fixed link Reply-To: sashiko-reviews@lists.linux.dev To: "Joseph Telaak" Cc: intel-wired-lan@lists.osuosl.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203-e1000-phylink-v2-2-0a8f80515363@telaak.dev> References: <20261203-e1000-phylink-v2-0-0a8f80515363@telaak.dev> <20261203-e1000-phylink-v2-2-0a8f80515363@telaak.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 06:14:05 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] e1000: unlocked netif_running() races phylink start/resume/suspend with close - [Low] e1000: unlocked data race on adapter->phylink_up - [Low] e1000: e1000_probe() pulses PHY_RST when e1000_phylink_init() fails -- commit ba7508c7349c5b00062c75577f7323e893d36d78 Author: Joseph Telaak e1000: use phylink for a CE4100 fixed link This commit adds phylink support for CE4100 devices with a fixed-link OF node so the MAC forces speed, duplex, and flow control from phylink instead of scanning for an MDIO PHY. Link state, ethtool link and pause settings, and MII ioctls are delegated to phylink while guarding MAC register updates against resets and transmit setup with a mutex. > diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/= ethernet/intel/e1000/e1000_main.c > index a52fff0259a17..f07afc451d098 100644 > --- a/drivers/net/ethernet/intel/e1000/e1000_main.c > +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c [ ... ] > @@ -1182,8 +1348,14 @@ static int e1000_probe(struct pci_dev *pdev, const= struct pci_device_id *ent) > adapter->wol =3D adapter->eeprom_wol; > device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); > =20 > - /* Auto detect PHY address */ > if (hw->mac_type =3D=3D e1000_ce4100) { > + err =3D e1000_phylink_init(adapter); > + if (err) > + goto err_eeprom; > + } [ ... ] > @@ -1227,6 +1403,7 @@ static int e1000_probe(struct pci_dev *pdev, const = struct pci_device_id *ent) > err_register: > err_eeprom: > e1000_phy_hw_reset(hw); > + e1000_phylink_destroy(adapter); [Severity: Low] Does jumping to err_eeprom pulse E1000_CTRL_PHY_RST when e1000_phylink_init= () fails? If phylink_create() returns -EPROBE_DEFER (for example via phylink_parse_fixedlink() waiting on link-gpios), adapter->phylink is still NULL. At err_eeprom, e1000_phy_hw_reset() checks e1000_uses_phylink(hw), sees NULL, and asserts E1000_CTRL_PHY_RST for 10 ms plus the 10 ms wait in e1000_get_phy_cfg_done(), which can disrupt an externally managed peer on every deferred probe retry. Jumping past e1000_phy_hw_reset() (for instance to err_mdio_ioremap) when e1000_phylink_init() fails would avoid pulsing PHY_RST. [ ... ] > @@ -2397,6 +2586,9 @@ bool e1000_has_link(struct e1000_adapter *adapter) > struct e1000_hw *hw =3D &adapter->hw; > bool link_active =3D false; > =20 > + if (adapter->phylink) > + return adapter->phylink_up; > + [Severity: Low] Is there a data race on adapter->phylink_up here and in e1000_link_test()? e1000_mac_link_up() and e1000_mac_link_down() write adapter->phylink_up under adapter->phylink_lock from phylink_resolve() without rtnl_lock, while e1000_has_link() (from e1000_watchdog() and e1000_get_link()) and e1000_link_test() read it without adapter->phylink_lock or READ_ONCE(). During e1000_open(), firing E1000_ICS_LSC before phylink_start() runs e1000_watchdog() concurrently with phylink_resolve(), producing a KCSAN data race. Reading adapter->phylink_up under adapter->phylink_lock (as e1000_up= () does) or using READ_ONCE()/WRITE_ONCE() would resolve it. [ ... ] > @@ -5091,6 +5292,8 @@ static int __e1000_shutdown(struct pci_dev *pdev, b= ool *enable_wake) > =20 > WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); > rtnl_lock(); > + if (adapter->phylink) > + phylink_suspend(adapter->phylink, !!adapter->wol); > e1000_down(adapter); > rtnl_unlock(); > } [ ... ] > @@ -5204,8 +5407,14 @@ static int e1000_resume(struct device *dev) > =20 > e1000_init_manageability(adapter); > =20 > - if (netif_running(netdev)) > + if (netif_running(netdev)) { > e1000_up(adapter); > + if (adapter->phylink) { > + rtnl_lock(); > + phylink_resume(adapter->phylink); > + rtnl_unlock(); > + } > + } [ ... ] > @@ -5329,6 +5541,11 @@ static void e1000_io_resume(struct pci_dev *pdev) > pr_info("can't bring device back up after reset\n"); > return; > } > + if (adapter->phylink) { > + rtnl_lock(); > + phylink_start(adapter->phylink); > + rtnl_unlock(); > + } > } [Severity: Medium] Can e1000_io_resume(), e1000_resume(), and __e1000_shutdown() race with e1000_close() because netif_running(netdev) is checked outside rtnl_lock()? __dev_close_many() allows e1000_close() to run under rtnl_lock() even while the netdev is detached: CPU0 CPU1 e1000_io_resume() if (netif_running(netdev)) e1000_up(adapter) dev_close() /* holds rtnl_lock */ __dev_close_many() e1000_close() phylink_stop(adapter->phylink) e1000_down(adapter) rtnl_lock() phylink_start(adapter->phylink) <-- started on closed netdev rtnl_unlock() This leaves phylink running on a closed interface. A later e1000_remove() skips e1000_close() because the interface is down, so phylink_destroy() frees pl and puts pl->link_gpio without stopping pl->link_poll or freeing pl->link_irq, causing a use-after-free and an IRQ leak. The same unlocked netif_running(netdev) check happens in e1000_resume() before phylink_resume(), and in __e1000_shutdown() before sleeping and calling phylink_suspend(). In __e1000_shutdown(), calling phylink_suspend() on a closed interface with WoL enabled leaves PHYLINK_DISABLE_MAC_WOL set because e1000_resume() will skip phylink_resume(). Holding rtnl_lock() across the netif_running(netdev) check, e1000_up()/e1000_down(), and the phylink call (matching e1000_io_error_detected()) would avoid these races. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-e1000-phyl= ink-v2-0-0a8f80515363@telaak.dev?part=3D2