From: sashiko-bot@kernel.org
To: "Joseph Telaak" <joseph@telaak.dev>
Cc: intel-wired-lan@lists.osuosl.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH iwl-next 2/4] e1000: use phylink for a CE4100 fixed link
Date: Wed, 02 Dec 2026 07:21:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-245054@kernel.org> (raw)
In-Reply-To: <20261201-e1000-phylink-v1-2-21e6f1c816a0@telaak.dev>
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 <joseph@telaak.dev>
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_adapter *adapter,
> return 0;
> }
>
> +static struct e1000_adapter *e1000_from_phylink(struct phylink_config *config)
> +{
> + 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 = e1000_from_phylink(config);
> + struct e1000_hw *hw = &adapter->hw;
> +
> + mutex_lock(&adapter->phylink_lock);
> + adapter->phylink_up = false;
> + adapter->link_speed = 0;
> + adapter->link_duplex = 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 = e1000_from_phylink(config);
> + struct e1000_hw *hw = &adapter->hw;
> +
> + mutex_lock(&adapter->phylink_lock);
> + hw->forced_speed = speed;
> + hw->forced_full_duplex = duplex == DUPLEX_FULL;
> + if (tx_pause && rx_pause)
> + hw->fc = E1000_FC_FULL;
> + else if (tx_pause)
> + hw->fc = E1000_FC_TX_PAUSE;
> + else if (rx_pause)
> + hw->fc = E1000_FC_RX_PAUSE;
> + else
> + hw->fc = E1000_FC_NONE;
> + hw->original_fc = hw->fc;
> +
> + e1000_setup_forced_link(hw);
> + e1000_set_fc_watermarks(hw);
> +
> + adapter->link_speed = speed;
> + adapter->link_duplex = duplex == DUPLEX_FULL ? FULL_DUPLEX :
> + HALF_DUPLEX;
> + adapter->tx_timeout_factor = speed == SPEED_10 ? 16 : 1;
> + adapter->phylink_up = 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 = er32(TCTL);
tctl &= ~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-teardown
mutex_unlock(&adapter->phylink_lock);
...
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)
>
> unregister_netdev(netdev);
>
> + 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
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-e1000-phylink-v1-0-21e6f1c816a0@telaak.dev?part=2
next prev parent reply other threads:[~2026-12-02 7:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 7:21 [PATCH iwl-next 0/4] e1000: phylink for the Intel CE4100 GbE Joseph Telaak
2026-12-01 7:21 ` [PATCH iwl-next 1/4] dt-bindings: net: add " Joseph Telaak
2026-12-01 13:16 ` Andrew Lunn
2026-12-01 21:27 ` Joseph Telaak
2026-12-02 7:21 ` sashiko-bot
2026-12-01 7:21 ` [PATCH iwl-next 2/4] e1000: use phylink for a CE4100 fixed link Joseph Telaak
2026-12-01 8:58 ` Maxime Chevallier
2026-12-01 9:20 ` Joseph Telaak
2026-12-02 7:21 ` sashiko-bot [this message]
2026-12-02 8:03 ` Joseph Telaak
2026-12-01 7:21 ` [PATCH iwl-next 3/4] e1000: attach a CE4100 PHY through phylink Joseph Telaak
2026-12-01 9:02 ` Maxime Chevallier
2026-12-01 9:32 ` Joseph Telaak
2026-12-01 22:16 ` Andrew Lunn
2026-12-02 7:21 ` sashiko-bot
2026-12-01 7:21 ` [PATCH iwl-next 4/4] e1000: disable EEE on a CE4100 PHY under phylink Joseph Telaak
2026-12-01 9:04 ` Maxime Chevallier
2026-12-01 9:24 ` Joseph Telaak
2026-12-01 9:42 ` Maxime Chevallier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-245054@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=joseph@telaak.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.