From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v3 net-next 03/15] net: enetc: add link status message support to PF driver
Date: Tue, 01 Sep 2026 03:23:59 +0000 [thread overview]
Message-ID: <20260901032359.788A11F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260831025441.635045-4-wei.fang@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Denial of Service via Synchronous Polling of Untrusted VF
- [High] Logic Error and TOCTOU Race Permanently Dropping Link State Notifications
--
commit 0897c02e67549130fea1a46e3080e9af30c83727
Author: Wei Fang <wei.fang@nxp.com>
net: enetc: add link status message support to PF driver
Add link status message support to the PF driver using three command IDs
under message class 0x80 (ENETC_MSG_CLASS_ID_LINK_STATUS).
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_msg.c b/drivers/net/ethernet/freescale/enetc/enetc_msg.c
> index a89a5a418a23d..e21414acdc0d0 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_msg.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_msg.c
[ ... ]
> +static int enetc_pf_send_msg(struct enetc_pf *pf, u32 msg_code, u16 ms_mask)
> +{
> + struct enetc_hw *hw = &pf->si->hw;
> + u16 old_ms_mask = ms_mask;
> + u16 ms_status;
> + u32 val;
> +
> + /* The MS bit is set, indicating that the corresponding VF has not
> + * read the last message, PF cannot send new message to the VF. To
> + * avoid sending messages to such a VF, the bit corresponding to VF
> + * is cleared from ms_mask. Because the MS bit can only be written
> + * as 1, writing a 0 has no effect. Writing a 1 when the bit is
> + * already set is undefined.
> + */
> + ms_status = enetc_rd(hw, ENETC_PSIMSGSR) & 0xffff;
> + ms_mask &= ~ms_status;
> + if (!ms_mask)
> + return -EIO;
[Severity: High]
Does this logic introduce a time-of-check to time-of-use race condition?
If a VF acknowledges a previous message by clearing its MS bit immediately
after ms_status is read, the mask will remain zero and this early return
will prevent the link state from being updated.
Because the early return prevents the shared MC payload from being updated
in hardware, and there is no retry logic, will the VF receive the old link
state when it eventually reads the register and be left permanently out of
sync with the PF?
> +
> + if (ms_mask != old_ms_mask)
> + dev_warn_ratelimited(&pf->si->pdev->dev,
> + "PF cannot send message to VF(s) 0x%x\n",
> + ms_mask ^ old_ms_mask);
> +
> + enetc_wr(hw, ENETC_PSIMSGSR,
> + FIELD_PREP(PSIMSGSR_MC, msg_code) | ms_mask);
> +
> + return read_poll_timeout(enetc_rd, val, !(val & ms_mask), 1000,
> + 200000, false, hw, ENETC_PSIMSGSR);
[Severity: High]
Can an untrusted VF use this synchronous polling to intentionally stall the
PF's execution thread?
This blocks for up to 200ms waiting for the VF to acknowledge the message.
Since this is reachable by untrusted VFs (e.g., running in a VM), can a
malicious VF ignore the message and tie up the PF thread?
[ ... ]
> +static void enetc_msg_register_link_status_notifier(struct enetc_pf *pf,
> + int vf_id)
> +{
> + u16 pf_msg = FIELD_PREP(ENETC_PF_MSG_CLASS_ID,
> + ENETC_MSG_CLASS_ID_CMD_SUCCESS);
> +
> + mutex_lock(&pf->msg_lock);
> +
> + enetc_pf_reply_msg(&pf->si->hw, vf_id, pf_msg);
> +
> + /* SR-IOV is being disabled if pf->sriov_enabled is false, so no
> + * need to set link_status_ms_mask and notify the link status.
> + */
> + if (!pf->sriov_enabled)
> + goto msg_unlock;
> +
> + pf->link_status_ms_mask |= PSIMSGSR_MS(vf_id);
> +
> + /* Notify VF the current link status */
> + enetc_msg_notify_vf_link_status(pf, PSIMSGSR_MS(vf_id));
[Severity: High]
Does calling enetc_msg_notify_vf_link_status() here block other mailbox
operations?
Because enetc_msg_notify_vf_link_status() eventually calls
enetc_pf_send_msg() which can poll for 200ms, and we are holding
pf->msg_lock, will a slow or malicious VF block all other VF mailbox
operations and link state processing for this PF?
> +
> +msg_unlock:
> + mutex_unlock(&pf->msg_lock);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831025441.635045-1-wei.fang@oss.nxp.com?part=3
next prev parent reply other threads:[~2026-09-01 3:23 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 2:54 [PATCH v3 net-next 00/15] net: enetc: SR-IOV improvements and ENETC v4 VF support wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 01/15] net: enetc: add trusted " wei.fang
2026-09-01 3:23 ` sashiko-bot
2026-09-01 6:13 ` Wei Fang (OSS)
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 6:29 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 02/15] net: enetc: move msg_task and msg_int_name to struct enetc_si wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 03/15] net: enetc: add link status message support to PF driver wei.fang
2026-08-31 12:00 ` Andrew Lunn
2026-09-01 2:31 ` Wei Fang
2026-09-01 3:05 ` Andrew Lunn
2026-09-01 3:40 ` Wei Fang
2026-09-01 3:23 ` sashiko-bot [this message]
2026-09-01 6:46 ` Wei Fang (OSS)
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 7:16 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 04/15] net: enetc: add link speed " wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 7:52 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 05/15] net: enetc: use enetc_set_si_hw_addr() to set VF MAC address wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 06/15] net: enetc: relocate enetc_pf_set_vf_mac() for common PF support wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 07/15] net: enetc: add .ndo_set_vf_mac() to the enetc v4 driver wei.fang
2026-09-01 3:23 ` sashiko-bot
2026-09-01 6:59 ` Wei Fang (OSS)
2026-08-31 2:54 ` [PATCH v3 net-next 08/15] net: enetc: move mac_filter from struct enetc_pf to struct enetc_si wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 09/15] net: enetc: add MAC address filtering support for VFs of ENETC v4 wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-08-31 2:54 ` [PATCH v3 net-next 10/15] net: enetc: simplify and rename PSIIER enable/disable helpers wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 11/15] net: enetc: restore VF MAC promiscuous mode after FLR for ENETC v4 wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 8:40 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 12/15] net: enetc: add VF support for i.MX94 and i.MX95 wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 9:05 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 13/15] net: enetc: implement ndo_set_rx_mode_async for ENETC v4 VF wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 9:53 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 14/15] net: enetc: add PSI-to-VSI link status notification support for VF wei.fang
2026-09-01 3:23 ` sashiko-bot
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 10:47 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 15/15] net: enetc: add ndo_get_vf_config() support wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-03 2:56 ` [PATCH v3 net-next 00/15] net: enetc: SR-IOV improvements and ENETC v4 VF support Jakub Kicinski
2026-09-03 3:24 ` Wei Fang (OSS)
2026-09-03 23:22 ` Jakub Kicinski
2026-09-04 2:02 ` Wei Fang
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=20260901032359.788A11F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wei.fang@oss.nxp.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox