Netdev List
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Ahmad Byagowi <ahmadexp@gmail.com>, netdev@vger.kernel.org
Cc: richardcochran@gmail.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	vladimir.oltean@nxp.com, andrew+netdev@lunn.ch, arnd@arndb.de,
	john.stultz@linaro.org, rmk+kernel@armlinux.org.uk
Subject: Re: [PATCH net v6 1/2] ptp: serialize sysfs enable requests with ioctl paths
Date: Sat, 28 Nov 2026 14:01:07 +0000	[thread overview]
Message-ID: <b757a1a0-ee68-4ec0-90a5-40556af6ef05@linux.dev> (raw)
In-Reply-To: <20261126-timecard-core-v6-1-ahmadexp@gmail.com>

On 26/11/2026 16:41, Ahmad Byagowi wrote:
> From: ahmadexp <ahmadexp@gmail.com>
> 
> EXTTS, PPS and period sysfs stores invoke the clock driver callback without the pincfg_mux mutex. The ioctl paths and pin configuration changes use that mutex, so sysfs can race with those operations and with other sysfs requests.
> 
> Take pincfg_mux around each enable callback. Keep validation and permission checks outside the critical section, propagate callback failures, and return -ERESTARTSYS when mutex acquisition is interrupted. The mutex is required because disable callbacks may sleep while draining an IRQ.
> 
> A coding assistant helped identify the missing serialization, develop the fix and regression tests, and prepare this changelog. The source-derived tests exercise the actual callbacks with controlled scheduling; KUnit coverage uses the actual stores under lock contention.

"The body of the explanation, line wrapped at 75 columns,"
Please, read
https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format
before sending patches


> 
> Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")

no empty lines between tags

> Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org
> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
> ---
>   drivers/ptp/ptp_sysfs.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
> index 8e0e0aa09981..90fdddc1e6a7 100644
> --- a/drivers/ptp/ptp_sysfs.c
> +++ b/drivers/ptp/ptp_sysfs.c
> @@ -60,7 +60,10 @@ static ssize_t extts_enable_store(struct device *dev,
>   	if (req.extts.index >= ops->n_ext_ts)
>   		goto out;
>   
> +	if (mutex_lock_interruptible(&ptp->pincfg_mux))
> +		return -ERESTARTSYS;
>   	err = ops->enable(ops, &req, enable ? 1 : 0);
> +	mutex_unlock(&ptp->pincfg_mux);
>   	if (err)
>   		goto out;
>   
> @@ -130,7 +133,10 @@ static ssize_t period_store(struct device *dev,
>   		goto out;
>   
>   	enable = req.perout.period.sec || req.perout.period.nsec;
> +	if (mutex_lock_interruptible(&ptp->pincfg_mux))
> +		return -ERESTARTSYS;
>   	err = ops->enable(ops, &req, enable);
> +	mutex_unlock(&ptp->pincfg_mux);
>   	if (err)
>   		goto out;
>   
> @@ -157,7 +163,10 @@ static ssize_t pps_enable_store(struct device *dev,
>   	if (cnt != 1)
>   		goto out;
>   
> +	if (mutex_lock_interruptible(&ptp->pincfg_mux))
> +		return -ERESTARTSYS;
>   	err = ops->enable(ops, &req, enable ? 1 : 0);
> +	mutex_unlock(&ptp->pincfg_mux);
>   	if (err)
>   		goto out;
>   


  parent reply	other threads:[~2026-11-28 14:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 16:41 [PATCH net v6 0/2] ptp: serialize requests and stop unassigned timestamps Ahmad Byagowi
2026-11-26 16:41 ` [PATCH net v6 1/2] ptp: serialize sysfs enable requests with ioctl paths Ahmad Byagowi
2026-11-27 17:09   ` netdev-bot+sashiko
2026-11-28 14:01   ` Vadim Fedorenko [this message]
2026-11-26 16:41 ` [PATCH net v6 2/2] ptp: disable unassigned timestamp channels on unregister Ahmad Byagowi
2026-11-27 17:09   ` netdev-bot+sashiko

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=b757a1a0-ee68-4ec0-90a5-40556af6ef05@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=ahmadexp@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=john.stultz@linaro.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vladimir.oltean@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