From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH net-next 2/7] ptp: netc: remove unnecessary pcie_flr() call in probe
Date: Wed, 29 Jul 2026 10:43:15 +0000 [thread overview]
Message-ID: <20260729104316.375121F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260728104548.3301214-3-wei.fang@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the driver fails to initialize NETC_TMR_TEMASK to 0 during probe, which can leave interrupts enabled from a previous kernel. Combined with the ISR masking logic, this causes unrecoverable interrupt wedging or storms.
- [High] This problem wasn't introduced by this patch, but teardown ordering allows late IRQs to access a freed ptp_clock pointer, resulting in a use-after-free vulnerability.
--
--- Patch [2]: [PATCH net-next 2/7] ptp: netc: remove unnecessary pcie_flr() call in probe ---
commit fe3a9be0d4fb11cfd834174e67a7435d22d701a7
Author: Wei Fang <wei.fang@nxp.com>
Date: Tue Jul 28 10:45:43 2026 +0000
ptp: netc: remove unnecessary pcie_flr() call in probe
This commit removes an unnecessary function level reset call from the NETC
timer probe function. According to the reference manual, this reset is not
applicable to the timer as a supporting function.
> diff --git a/drivers/ptp/ptp_netc.c b/drivers/ptp/ptp_netc.c
> index 683abcdff9ad6..072809ea7922c 100644
> --- a/drivers/ptp/ptp_netc.c
> +++ b/drivers/ptp/ptp_netc.c
> @@ -773,7 +773,6 @@ static int netc_timer_pci_probe(struct pci_dev *pdev)
> if (!priv)
> return -ENOMEM;
>
> - pcie_flr(pdev);
> err = pci_enable_device_mem(pdev);
> if (err)
> return dev_err_probe(dev, err, "Failed to enable device\n");
[Severity: High]
This isn't a bug introduced by this patch, but the driver fails to initialize
NETC_TMR_TEMASK to 0 during probe, which can leave interrupts enabled from a
previous kernel. Combined with the ISR masking logic, could this cause
unrecoverable interrupt wedging or storms?
For example, in a kexec scenario, if the previous kernel left hardware
interrupts unmasked in NETC_TMR_TEMASK, the new kernel calls request_irq()
before clearing the hardware mask:
drivers/ptp/ptp_netc.c:netc_timer_probe() {
...
err = netc_timer_init_msix_irq(priv);
if (err)
goto timer_pci_remove;
netc_timer_init(priv);
...
}
The ISR reads NETC_TMR_TEVENT, masks it with the software shadow
priv->tmr_emask (which is initialized to 0), and writes 0 back to the
write-1-to-clear register:
drivers/ptp/ptp_netc.c:netc_timer_isr() {
...
tmr_event = netc_timer_rd(priv, NETC_TMR_TEVENT);
tmr_event &= priv->tmr_emask;
/* Clear interrupts status */
netc_timer_wr(priv, NETC_TMR_TEVENT, tmr_event);
...
}
Because priv->tmr_emask is 0, tmr_event becomes 0, and writing 0 fails to
clear the hardware interrupt state.
[Severity: High]
This is a pre-existing issue, but does the teardown ordering in
netc_timer_remove() allow late IRQs to access a freed ptp_clock pointer,
resulting in a use-after-free?
In netc_timer_remove(), ptp_clock_unregister() is called before the MSI-X
interrupt is freed or synchronized via netc_timer_free_msix_irq():
drivers/ptp/ptp_netc.c:netc_timer_remove() {
...
ptp_clock_unregister(priv->clock);
netc_timer_free_msix_irq(priv);
...
}
If an interrupt is in-flight or arrives after ptp_clock_unregister() frees the
clock instance, the ISR dereferences the dangling priv->clock pointer:
drivers/ptp/ptp_netc.c:netc_timer_isr() {
...
if (tmr_event & TMR_TEVENT_PPEN_ALL) {
event.type = PTP_CLOCK_PPS;
ptp_clock_event(priv->clock, &event);
}
...
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260728104548.3301214-1-wei.fang@oss.nxp.com?part=2
next prev parent reply other threads:[~2026-07-29 10:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 10:45 [PATCH net-next 0/7] net: dsa: netc: add PTP support for NETC switch wei.fang
2026-07-28 10:45 ` [PATCH net-next 1/7] ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access wei.fang
2026-07-29 10:43 ` sashiko-bot
2026-07-28 10:45 ` [PATCH net-next 2/7] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-07-29 10:43 ` sashiko-bot [this message]
2026-07-28 10:45 ` [PATCH net-next 3/7] ptp: netc: export netc_timer_get_current_time() for cross-driver use wei.fang
2026-07-29 10:43 ` sashiko-bot
2026-07-28 10:45 ` [PATCH net-next 4/7] net: dsa: netc: use entry ID instead of pointer to track host flood rule wei.fang
2026-07-28 10:45 ` [PATCH net-next 5/7] net: dsa: netc: enable ingress port filtering lookup by default wei.fang
2026-07-28 10:45 ` [PATCH net-next 6/7] net: dsa: netc: add PTP two-step timestamping support wei.fang
2026-07-29 10:43 ` sashiko-bot
2026-07-29 13:41 ` Vadim Fedorenko
2026-07-28 10:45 ` [PATCH net-next 7/7] net: dsa: netc: add PTP one-step " wei.fang
2026-07-29 10:43 ` sashiko-bot
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=20260729104316.375121F00A3F@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