Article View: linux.kernel.netdev
Article #23656Re: [PATCH net v6 8/8] ptp: ocp: defer timestamp shutdown to clock unregister
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 16:48
Date: Fri, 27 Nov 2026 16:48
193 lines
14755 bytes
14755 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 1 · High: 1 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Critical] In ptp_ocp_detach() (drivers/ptp/ptp_ocp.c), the patch
removes the explicit ptp_ocp_ts_enable(bp->ts0..ts4, 0, false) and…
- [High] Removing ptp_ocp_ts_enable(bp->pps, ~0, false) from
ptp_ocp_detach() leaves the core's PTP_CLK_REQ_PPS request as the only…
- [Medium] The commit is not self-contained but has a Fixes: tag for
627366c51145 ("ptp: ocp: fix resource freeing order").
--
ptp: ocp: defer timestamp shutdown to clock unregister
This patch removes the explicit ptp_ocp_ts_enable() calls for ts0..ts4 and
pps from ptp_ocp_detach(). It relies on the PTP core unregister path to
disable the timestamp channels once the user interfaces are gone. The
commit message says it depends on a separate PTP core teardown series.
Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org
> This driver patch depends on the separate PTP core teardown series.
[ ... ]
> Fixes: 627366c51145 ("ptp: ocp: fix resource freeing order")
[Severity: Medium]
Which series does this refer to? The only Link: tag points to a single
lore message, not a patch series. There is also no commit ID or stable
dependency note for the prerequisite.
In this tree, ptp_disable_all_events() and ptp_clock_unregister() do not
seem to contain the core change this patch relies on.
The Fixes: target 627366c51145 is the commit that added the early-disable
block being removed here. Because of the Fixes: tag, could stable tooling
pick up this patch without the core series? That would bring the
timestamp IRQ regression described below into stable kernels.
Could the prerequisite be named explicitly, or this patch be sent as part
of the core series?
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 0405188951768..27cf3ab3327c4 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -5768,19 +5768,6 @@ ptp_ocp_detach(struct ptp_ocp *bp)
> ptp_ocp_detach_sysfs(bp);
> ptp_ocp_attr_group_del(bp);
> timer_delete_sync(&bp->watchdog);
> - /* Disable interrupts on all timestampers */
> - if (bp->ts0)
> - ptp_ocp_ts_enable(bp->ts0, 0, false);
> - if (bp->ts1)
> - ptp_ocp_ts_enable(bp->ts1, 0, false);
> - if (bp->ts2)
> - ptp_ocp_ts_enable(bp->ts2, 0, false);
> - if (bp->ts3)
> - ptp_ocp_ts_enable(bp->ts3, 0, false);
> - if (bp->ts4)
> - ptp_ocp_ts_enable(bp->ts4, 0, false);
[Severity: Critical]
Does ptp_disable_all_events() in this tree actually disable these
channels? It only handles pins whose function is PTP_PF_EXTTS, plus one
PPS request:
drivers/ptp/ptp_chardev.c:ptp_disable_all_events() {
...
for (i = 0; i < info->n_pins; i++)
if (info->pin_config[i].func == PTP_PF_EXTTS)
ptp_disable_pinfunc(info, info->pin_config[i].func,
info->pin_config[i].chan);
/* Disable the PPS event if the driver has PPS support */
if (info->pps) {
struct ptp_clock_request req = { .type = PTP_CLK_REQ_PPS };
info->enable(info, &req, 0);
}
...
}
ptp_ocp has n_ext_ts = 6 but only 4 pins. ptp_ocp_set_pins() allocates
the pins zeroed, so by default they are all PTP_PF_NONE.
EXTTS channels can be enabled by index with no pin assigned. Both
ptp_extts_request() (PTP_EXTTS_REQUEST) and extts_enable_store() do this,
and nothing disables the channel when the fd is closed.
For bp->pps, the core request becomes
ptp_ocp_ts_enable(bp->pps, OCP_REQ_PPS, false). If OCP_REQ_TIMESTAMP
(EXTTS index 5) is also set, pps_req_map stays non-zero. The "no state
change" shortcut then returns early and the PPS/TS5 timestamper stays
armed.
In all of these cases the interrupt is still unmasked and requested when
ptp_clock_unregister() does its final put_device(). That put runs
ptp_clock_release():
drivers/ptp/ptp_clock.c:ptp_clock_release() {
...
bitmap_free(tsevq->mask);
kfree(tsevq);
debugfs_remove(ptp->debugfs_root);
xa_erase(&ptp_clocks_map, ptp->index);
kfree(ptp);
}
bp->ptp is not cleared. The IRQ is only disabled and freed later, one
source at a time, in ptp_ocp_unregister_ext():
ext->info->enable(ext, ~0, false);
pci_free_irq(ext->bp->pdev, ext->irq_vec, ext);
Can a timestamp interrupt in that window write to freed memory?
ptp_ocp_ts_irq()
ptp_clock_event(ext->bp->ptp, &ev) /* PTP_CLOCK_EXTTS */
spin_lock_irqsave(&ptp->tsevqs_lock, flags);
list_for_each_entry(tsevq, &ptp->tsevqs, qlist)
enqueue_external_timestamp(tsevq, event);
One way to hit this: enable a channel with "echo '0 1' > extts_enable",
feed a 1PPS signal on the input, then unbind or remove the device.
This seems to reopen the use-after-free that 627366c51145 ("ptp: ocp: fix
resource freeing order") closed.
> - if (bp->pps)
> - ptp_ocp_ts_enable(bp->pps, ~0, false);
> if (bp->ptp)
> ptp_clock_unregister(bp->ptp);
[Severity: High]
With this call gone, is an in-flight PPS interrupt still drained before
pps_unregister_source()?
The only teardown disable left for the PPS event is the core's
PTP_CLK_REQ_PPS request. It goes through
ptp_ocp_enable()->ptp_ocp_ts_enable(bp->pps, OCP_REQ_PPS, false).
If OCP_REQ_TIMESTAMP is also set in pps_req_map, the map stays non-zero.
The function then returns before the intr_mask write and before
synchronize_irq():
drivers/ptp/ptp_ocp.c:ptp_ocp_ts_enable() {
...
/* if no state change, just return */
if ((!!old_map ^ !!bp->pps_req_map) == 0)
return 0;
...
}
A ptp_ocp_ts_irq() already running on another CPU may have seen
OCP_REQ_PPS set. pps_req_map is a plain field, written under pincfg_mux
and read without a lock in hardirq context:
drivers/ptp/ptp_ocp.c:ptp_ocp_ts_irq() {
...
if (ext->bp->pps_req_map & OCP_REQ_PPS) {
ev.type = PTP_CLOCK_PPS;
ptp_clock_event(ext->bp->ptp, &ev);
}
...
}
Meanwhile ptp_clock_unregister() continues:
ptp_disable_all_events(ptp);
...
if (ptp->pps_source)
pps_unregister_source(ptp->pps_source);
Could pps_event(ptp->pps_source, ...) still be running in that handler
when pps_unregister_source() tears down and frees the pps_device?
Before this patch, the req = ~0 call always set pps_req_map to 0. The
source was masked and synchronize_irq() ran before ptp_clock_unregister().
> kfree(bp->ptp_info.pin_config);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-timecard-driver-v6-0-ahmadexp%40gmail.com
Technical Details
Message-ID:
<179579808820.3135.11076556680747243483@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372857-linux-kernel-netdev=dewy.ruReferences:
<20261126-timecard-driver-v6-8-ahmadexp@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372857-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v6 8/8] ptp: ocp: defer timestamp shutdown to clock unregister Date: Fri, 27 Nov 2026 16:48:08 +0000 Organization: Usenet Network Message-ID: <179579808820.3135.11076556680747243483@kernel.org> References: <20261126-timecard-driver-v6-8-ahmadexp@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="775865"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:s9Is1AB1IQ5URwMzYWPqNAy8/qw= sha256:eCE+Vb+1y2gaKQ7kc6jAAjDDwdmaFdz3R/5Jt/81P+U= sha1:gr+4d9XZWSUkyF4Bv/Mjt1SJIqk= sha256:8F5t0/AoNncn2o/4Ah/lWQWLuw1zrtTI/doXXJ8W9CM= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 29E64125F62; Fri, 27 Nov 2026 19:48:48 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qOLgRFmwLapK; Fri, 27 Nov 2026 19:48:44 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-372857-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 5A1E7125F60; Fri, 27 Nov 2026 19:48:36 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id D23FF319F3; Fri, 27 Nov 2026 16:48:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795798090; b=ueUHhgYVWUf8ZXjblhB84teEef6REIdtLe9V/HacgyekUTL5K+z+g23lERPP/mV7jJk3 EOye9bmVqrZ8BanK9kcyQb90swl6BtWI5qHchb0z0YHTFDz5O34Yyc6nK/XCCUXRXnFRN RUP3cSSjApJ0lXHE9xMlVXemkf6gmZHyTDf4AD24iQo+8qSRqK3ctccg8AikYFPWEqxHB aMdvzcVVjjZX+H/nidEJG86y5OEyMItwg9H7loxqlG9p0h09jLTjBQUsHQIeemUXjDAoa VcdRRvWqn40e5NAAFF1k/DrnLYX9ajC1o8FWbZL4sT63Dpv/OoJt5qaPXdcbdc35cUQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795798090; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=8Ke+lb+1/p0hY589hNN4tsTtbrPsUQfS/DCt9JyRMhk=; b=EGcZmq68taNHeLJxnvYb1UgdXV8rapMPWxkguFBp+v5148UrKu6i/yG5JsOJekQ0EF7R DL4gKBaJGb0d2EDOfqmfcOvA5FpBmc2M5Etlqb2kpuJqbtY59JwBKktlwTwU4cH+MoChf c4q0v5NwEx2DsQCBnEby61i1PDpzqdUSbZ2R1EIjYcGQ3hEHanCNdzK9irtf478PpLbzN NSdKDYak7w3bmOxtXLxp5tobCw08CD7cuRah2ytt68asiMDiDpPNUwpOYhDtobl2ejpWG LzFDKkXP5W0eGorZJoGon9eiiPkSMSo7N6atE+thi1i1blSYqcAGooKEchGXqlpwSqA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=o2hNAAq2; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D240D60A2620; Fri, 27 Nov 2026 16:48:10 +0000 (UTC) X-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=o2hNAAq2 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795798090; b=iMFGUdjWvlt1sMaebrn4xNcbCxtmb2jiivcdqT64vdcqbg5rgaw8zoUFS2w9Ennr4SHX 1m5dIDnl2qeXXLfH+DkiKmEJ8m3XoHLeY1OOVGbsZFId20eJt48l7C6nCnj3q+OmO/lA3 joLwfwOmtuRXDOwqQwFBO8ay9gj5e+7YITrHc320EERrY/jj2J1bwrQ0jfGWE05B+H1ir vLsdp1Qi0yZk3wvc5U1cMUcG2R6mJ4/B1U6uqUD4QbWO3EIjlOHCkBWxs7C+DgRIOCSSb emT5pRv80WBKIWu8IJZJ9vCCknCDzPnRgrhmeO9x0GLHoGnKqqqWDCX7Na6AEobrPqg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795798090; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=8Ke+lb+1/p0hY589hNN4tsTtbrPsUQfS/DCt9JyRMhk=; b=5HaapmoEv2qUijOjf3s1kLSyyp20GaDbPh861AvPXEfsuJY6u/RTptxy21FK3MbcXASz Qj0Kc9lTo1nwSlJIcrRJUXdWIYfSAdSPkYTR5tRL1f5u9U9FhHGUyXuDpGsis+WgZO7G2 dp4FF8OBHVPycSIQdU/XNl/QNoh2Noh6hGZrHBz1SrJqEd9gOfv99Y2v3tS5hrr9eB8mv CtLZYqAD+SEasvew9r90VSfxo41Wp5XI1RyNF26oQKpQVM8hbjxXf3c/Eyk4hBSrm2qJ5 YKJNQrFwCH7N4uS3D9H4kz1IHsawTQeeq+//rKKi/ne5mzakqAdcRJm1xyGWfh3la/Q== X-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=o2hNAAq2; arc=none smtp.remote-ip=100.103.45.18 X-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 F3CF060A2609; Fri, 27 Nov 2026 16:48:09 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 996CC1F00939; Fri, 27 Nov 2026 16:48:08 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795798089; bh=8Ke+lb+1/p0hY589hNN4tsTtbrPsUQfS/DCt9JyRMhk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=o2hNAAq2196yAnzTH4O21oHqlz/sFA/C4h66bdw9rV1WygWFvv3hTMokfm9Yzj0Qf mrMoKSEcuxrAJJZnQn6F6g8WsTAbd3AsFLhssBMLO3/X+fHrdbvbka2zajFB134oGr srqX11J7zFmdnnpyMrk783cGA89sCmvLQ10pmsCdqE9jWjdRjXu9gVETaA9FVkZFoG t/GHla8toozFAKGMJlYS2X23fHKmtWS7LlCgL854DFfdcZmp6QXVEJ9lgXz1LjwLd9 FcvAcDAwzz27CcNFFBikI8oCSqEYRCjS+ctiPC4o3p/E4zFM+CFNxOHdjRrOhh2Sci vGeGSl4M6xj6A== X-Cc: netdev@vger.kernel.org, richardcochran@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, vladimir.oltean@nxp.com, vadim.fedorenko@linux.dev, andrew@lunn.ch, linux-kernel@vger.kernel.org, arkadiusz.kubalewski@intel.com, jiri@resnulli.us, jonathan.lemon@gmail.com X-In-Reply-To: <20261126-timecard-driver-v6-8-ahmadexp@gmail.com> X-sashiko-severity: Critical X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list