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=1796196112; b=gBD6EhpjhTjTRlKb5RwXtbzDCnyjIUUMr6cnRAO3qy/+cwW5UXSZD8Gqydu7ARuN56VC 9R+W21KtNrqI63gQdpuAUAGrU6zYUGC5WROHYhdUSbPxJvMhMQU0UMdNmC5ClVd/QN8D1 3DnAgyL8HpJ5/R/u2BhGxEtjLyncMYQw5WdRcS7uV4I2rgCfN+OEOoPojVzjemyBuV67k 1EezKONbiBBBysEOLiyolM2sNeFoVGP6mjwaLSSP9in63uJi+aJur1a2eeUCXzpXXWjY5 G7xS4Rvy2UDzteNU2AfEyrBwWb+0x3GT0JyL9AGMZIL+WL56U05Y4YBO4BRnjOR9fUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796196112; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=PCcdLsOIQOUI4GEuQuAaEFe5Sxsaj6yF6SmOWm4DE6E=; b=oJ6OvkzlL2n4LI7LAkZqFJP23wJMTvdTlNgQ0PSPBvjbqC3s/6x98clHGomsuyL5sGN2 Budf0rrDHcppdKTfBAUozYgHupTTTNKoNmFS3QSZvxDiK82rglAtbiiMBkFcPsvWMPLU7 23137A4cgwUFfwf9kJzQjo/Be/6ylwbIkBrhzjS7JlW/mmlb0Y3ePEE8IKMnDa9hRmVBj 5fThAAtZ27L+vd2bKh5slHGkQMWgQ8cQSttpnPI3LbfyxMo81FXCGN+bGmf8c2cMsfDHD 81rh/mmdM4I2UcRkwhD9x/2ZiI9Q6cMcWZKKF9i5BGzVYyRBTsJ7FoSWonk7apQ/d8A== 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=Ai0voB8Q; 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 5C237606A32E for ; Wed, 2 Dec 2026 07:21:52 +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=Ai0voB8Q Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF8281F00896; Wed, 2 Dec 2026 07:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796196111; bh=PCcdLsOIQOUI4GEuQuAaEFe5Sxsaj6yF6SmOWm4DE6E=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Ai0voB8QSqBuYdqrtM40mDxqd0s9wtm95/TvZWCXR1YinI9c7im6KaKAkugspQxit 6zD+UcfPciPzhmgkjC6cNQOah7NXKs7EpvFM3alU4aEkxHruTix9+Iv/+ZP51xBYWe LQUSXnOiF7RG+xl3HlW/AwGPlspxfRQl+27ApJXOg08NLY1hZoI1AquvtFa4tiNuVZ 5HMmaH4dmJJas+Y3ydJ7Hpml9eTmGQcY90szLPAeND1sshd0wxisMISVxTeqApgGOy cGWSNJ9bwmz19g3OVIJSuVw6a3jKl3WX2zsLJ8dl1sICzmGc/j1saEpf2/69MEhfth C2lBS0WInNbSg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH iwl-next 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: <20261201-e1000-phylink-v1-2-21e6f1c816a0@telaak.dev> References: <20261201-e1000-phylink-v1-0-21e6f1c816a0@telaak.dev> <20261201-e1000-phylink-v1-2-21e6f1c816a0@telaak.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 07:21:51 +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 1 potential issue to consider: - [Medium] e1000: race on TCTL transmit disable between e1000_down() and e1000_mac_link_up() It also noticed 1 related pre-existing issue this patch does not introduce: - [Critical] e1000: use-after-free in e1000_remove() [1] -- commit 98cabf3b3791ddf89994822f980e3b1c0d669af1 Author: Joseph Telaak e1000: use phylink for a CE4100 fixed link This commit adds phylink support for CE4100 GbE MAC devices configured with an RGMII fixed-link in Device Tree, delegating link state, ethtool settings, and MII ioctls to phylink. > diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/= ethernet/intel/e1000/e1000_main.c > index a52fff0259a17..2343252b89fa6 100644 > --- a/drivers/net/ethernet/intel/e1000/e1000_main.c > +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c [ ... ] > @@ -901,6 +933,131 @@ static int e1000_init_hw_struct(struct e1000_adapte= r *adapter, > return 0; > } > =20 > +static struct e1000_adapter *e1000_from_phylink(struct phylink_config *c= onfig) > +{ > + return netdev_priv(to_net_dev(config->dev)); > +} > + > +static void e1000_mac_config(struct phylink_config *config, unsigned int= mode, > + const struct phylink_link_state *state) > +{ > +} > + > +static void e1000_mac_link_down(struct phylink_config *config, > + unsigned int mode, phy_interface_t interface) > +{ > + struct e1000_adapter *adapter =3D e1000_from_phylink(config); > + struct e1000_hw *hw =3D &adapter->hw; > + > + mutex_lock(&adapter->phylink_lock); > + adapter->phylink_up =3D false; > + adapter->link_speed =3D 0; > + adapter->link_duplex =3D 0; > + ew32(TCTL, er32(TCTL) & ~E1000_TCTL_EN); > + mutex_unlock(&adapter->phylink_lock); > +} > + > +static void e1000_mac_link_up(struct phylink_config *config, > + struct phy_device *phy, unsigned int mode, > + phy_interface_t interface, int speed, int duplex, > + bool tx_pause, bool rx_pause) > +{ > + struct e1000_adapter *adapter =3D e1000_from_phylink(config); > + struct e1000_hw *hw =3D &adapter->hw; > + > + mutex_lock(&adapter->phylink_lock); > + hw->forced_speed =3D speed; > + hw->forced_full_duplex =3D duplex =3D=3D DUPLEX_FULL; > + if (tx_pause && rx_pause) > + hw->fc =3D E1000_FC_FULL; > + else if (tx_pause) > + hw->fc =3D E1000_FC_TX_PAUSE; > + else if (rx_pause) > + hw->fc =3D E1000_FC_RX_PAUSE; > + else > + hw->fc =3D E1000_FC_NONE; > + hw->original_fc =3D hw->fc; > + > + e1000_setup_forced_link(hw); > + e1000_set_fc_watermarks(hw); > + > + adapter->link_speed =3D speed; > + adapter->link_duplex =3D duplex =3D=3D DUPLEX_FULL ? FULL_DUPLEX : > + HALF_DUPLEX; > + adapter->tx_timeout_factor =3D speed =3D=3D SPEED_10 ? 16 : 1; > + adapter->phylink_up =3D true; > + > + if (!test_bit(__E1000_DOWN, &adapter->flags)) > + ew32(TCTL, er32(TCTL) | E1000_TCTL_EN); > + mutex_unlock(&adapter->phylink_lock); > +} [Severity: Medium] Can e1000_mac_link_up() race with e1000_down() and re-enable E1000_TCTL_EN while the adapter is being brought down? During an online reset or reconfiguration (such as e1000_reinit_locked() or e1000_change_mtu()), phylink remains running while e1000_down() executes. e1000_down() clears E1000_TCTL_EN without holding adapter->phylink_lock and only sets __E1000_DOWN after sleeping for 10ms and disabling NAPI and IRQs: CPU0 CPU1 (kworker) e1000_reinit_locked() e1000_down() tctl =3D er32(TCTL); tctl &=3D ~E1000_TCTL_EN; ew32(TCTL, tctl); msleep(10); phylink_resolve() e1000_mac_link_up() mutex_lock(&adapter->phylink_lock= ); if (!test_bit(__E1000_DOWN, ...)) ew32(TCTL, er32(TCTL) | E1000_TCTL_EN= ); <-- TX re-enabled mid-tear= down mutex_unlock(&adapter->phylink_lo= ck); ... e1000_down_and_stop() set_bit(__E1000_DOWN, ...); This re-enables hardware transmit DMA while e1000_down() proceeds to disable NAPI and interrupts, reset the MAC, and clean the TX rings. [ ... ] > @@ -1270,6 +1436,8 @@ static void e1000_remove(struct pci_dev *pdev) > =20 > unregister_netdev(netdev); > =20 > + e1000_phylink_destroy(adapter); > + > /* Only kill reset task if adapter is not resetting */ > if (!test_bit(__E1000_RESETTING, &adapter->flags)) > cancel_work_sync(&adapter->reset_task); [Severity: Critical] This problem wasn't introduced by this patch, but skipping cancel_work_sync(&adapter->reset_task) when __E1000_RESETTING is set [1] allows e1000_remove() to call free_netdev() while adapter->reset_task is still running or pending, causing a use-after-free in e1000_reset_task(). [1] https://sashiko.dev/#/bug/linux-07ec582b-3a47-4b03-b81c-05ee2026cfe7 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-e1000-phyl= ink-v1-0-21e6f1c816a0@telaak.dev?part=3D2