From: "Wei Fang (OSS)" <wei.fang@oss.nxp.com>
To: "sashiko-reviews@lists.linux.dev" <sashiko-reviews@lists.linux.dev>
Cc: "Frank.Li@kernel.org" <Frank.Li@kernel.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: RE: [PATCH v3 net-next 7/8] net: dsa: netc: add PTP two-step timestamping support
Date: Wed, 2 Sep 2026 02:12:41 +0000 [thread overview]
Message-ID: <GV2PR04MB117394B3CEEB1CA71CAC28AFC88B72@GV2PR04MB11739.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20260901082026.7F3911F00A3E@smtp.kernel.org>
> > +static void netc_twostep_tstamp_process(struct netc_tag_th_subtype2 *tag,
> > + struct sk_buff *skb)
> > +{
> > + u8 ts_req_id = FIELD_GET(NETC_TAG_TS_REQ_ID, tag->hr_tsreq_id);
> > + struct dsa_port *dp = dsa_user_to_port(skb->dev);
> > + u64 ts = get_unaligned_be64(&tag->timestamp);
> > + struct netc_tagger_data *tagger_data;
> > + struct dsa_switch *ds = dp->ds;
> > +
> > + tagger_data = ds->tagger_data;
> > + if (unlikely(!tagger_data->twostep_tstamp_handler))
>
> [Severity: High]
> Can tagger_data be NULL here, leading to a kernel panic?
>
> In the DSA teardown sequence (dsa_tree_teardown()),
> dsa_switch_teardown_tag_protocol() is called first, invoking
> netc_disconnect() which frees ds->tagger_data and sets it to NULL.
>
> However, the conduit device's rx_handler is not removed until
> dsa_tree_teardown_conduits() is called later. If a hardware-generated To_Host
> subtype 2 response arrives in this window, the conduit's rx_handler will still
> invoke netc_rcv(), eventually calling netc_twostep_tstamp_process().
> This would result in a NULL pointer dereference when
> evaluating !tagger_data->twostep_tstamp_handler.
>
> Note that a follow-up patch (8/8) introduces a similar unchecked dereference
> in netc_onestep_sync_enqueue(), so this issue might still be present at the end
> of the series.
False positive — the teardown ordering is reversed.
In dsa_tree_teardown(), the conduit is torn down before the switch.
netc_disconnect() (which frees tagger_data and sets it NULL) runs during
switch teardown, which happens after the conduit is already shut down.
DSA RX into the tagger is gated by the conduit's dsa_ptr. Conduit teardown
clears dsa_ptr (with a barrier), so no further frames reach netc_rcv() from
that point on. By the time tagger_data is freed, the RX path is already stopped,
so the window you describe ("tagger_data NULL but frames still arriving") never
occurs. No NULL dereference is possible, and the same ordering covers the 8/8
case too. No check needed.
next prev parent reply other threads:[~2026-09-02 2:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 8:23 [PATCH v3 net-next 0/8] net: dsa: netc: add PTP support for NETC switch wei.fang
2026-08-31 8:23 ` [PATCH v3 net-next 1/8] ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access wei.fang
[not found] ` <20260901082024.E6F931F000E9@smtp.kernel.org>
2026-09-02 1:56 ` Wei Fang (OSS)
2026-08-31 8:23 ` [PATCH v3 net-next 2/8] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-08-31 8:23 ` [PATCH v3 net-next 3/8] ptp: netc: export netc_timer_get_current_time() for cross-driver use wei.fang
[not found] ` <20260901082025.AF94B1F00A3D@smtp.kernel.org>
2026-09-02 2:02 ` Wei Fang (OSS)
2026-08-31 8:23 ` [PATCH v3 net-next 4/8] net: dsa: netc: use entry ID instead of pointer to track host flood rule wei.fang
2026-08-31 8:23 ` [PATCH v3 net-next 5/8] net: dsa: netc: check return value of ntmp_ipft_delete_entry() wei.fang
2026-08-31 8:23 ` [PATCH v3 net-next 6/8] net: dsa: netc: enable ingress port filtering lookup by default wei.fang
2026-08-31 8:23 ` [PATCH v3 net-next 7/8] net: dsa: netc: add PTP two-step timestamping support wei.fang
[not found] ` <20260901082026.7F3911F00A3E@smtp.kernel.org>
2026-09-02 2:12 ` Wei Fang (OSS) [this message]
2026-08-31 8:23 ` [PATCH v3 net-next 8/8] net: dsa: netc: add PTP one-step " wei.fang
[not found] ` <20260901082027.461281F00A3F@smtp.kernel.org>
2026-09-02 3:00 ` Wei Fang (OSS)
2026-09-02 3:05 ` Wei Fang (OSS)
2026-09-01 15:09 ` [PATCH v3 net-next 0/8] net: dsa: netc: add PTP support for NETC switch Jakub Kicinski
2026-09-02 1:43 ` 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=GV2PR04MB117394B3CEEB1CA71CAC28AFC88B72@GV2PR04MB11739.eurprd04.prod.outlook.com \
--to=wei.fang@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=netdev@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox