lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3e90368f-f154-4be8-8dfe-f30fb33e980b@linux.dev>
Date: Sat, 21 Jun 2025 21:27:45 +0100
From: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
To: Thomas Gleixner <tglx@...utronix.de>, LKML <linux-kernel@...r.kernel.org>
Cc: Richard Cochran <richardcochran@...il.com>, netdev@...r.kernel.org
Subject: Re: [patch 05/13] ptp: Split out PTP_SYS_OFFSET_PRECISE ioctl code

On 20/06/2025 14:24, Thomas Gleixner wrote:
> Continue the ptp_ioctl() cleanup by splitting out the PTP_SYS_OFFSET_PRECISE
> ioctl code into a helper function.
> 
> No functional change intended.
> 
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> ---
>   drivers/ptp/ptp_chardev.c |   53 +++++++++++++++++++++++++---------------------
>   1 file changed, 29 insertions(+), 24 deletions(-)
> 
> --- a/drivers/ptp/ptp_chardev.c
> +++ b/drivers/ptp/ptp_chardev.c
> @@ -291,14 +291,40 @@ static long ptp_enable_pps(struct ptp_cl
>   		return ops->enable(ops, &req, enable);
>   }
>   
> +static long ptp_sys_offset_precise(struct ptp_clock *ptp, void __user *arg)
> +{
> +	struct ptp_sys_offset_precise precise_offset;
> +	struct system_device_crosststamp xtstamp;
> +	struct timespec64 ts;
> +	int err;
> +
> +	if (!ptp->info->getcrosststamp)
> +		return -EOPNOTSUPP;
> +
> +	err = ptp->info->getcrosststamp(ptp->info, &xtstamp);
> +	if (err)
> +		return err;
> +
> +	memset(&precise_offset, 0, sizeof(precise_offset));
> +	ts = ktime_to_timespec64(xtstamp.device);
> +	precise_offset.device.sec = ts.tv_sec;
> +	precise_offset.device.nsec = ts.tv_nsec;
> +	ts = ktime_to_timespec64(xtstamp.sys_realtime);
> +	precise_offset.sys_realtime.sec = ts.tv_sec;
> +	precise_offset.sys_realtime.nsec = ts.tv_nsec;
> +	ts = ktime_to_timespec64(xtstamp.sys_monoraw);
> +	precise_offset.sys_monoraw.sec = ts.tv_sec;
> +	precise_offset.sys_monoraw.nsec = ts.tv_nsec;
> +
> +	return copy_to_user(arg, &precise_offset, sizeof(precise_offset)) ? -EFAULT : 0;
> +}
> +
>   long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
>   	       unsigned long arg)
>   {
>   	struct ptp_clock *ptp =
>   		container_of(pccontext->clk, struct ptp_clock, clock);
>   	struct ptp_sys_offset_extended *extoff = NULL;
> -	struct ptp_sys_offset_precise precise_offset;
> -	struct system_device_crosststamp xtstamp;
>   	struct ptp_clock_info *ops = ptp->info;
>   	struct ptp_sys_offset *sysoff = NULL;
>   	struct timestamp_event_queue *tsevq;
> @@ -341,28 +367,7 @@ long ptp_ioctl(struct posix_clock_contex
>   
>   	case PTP_SYS_OFFSET_PRECISE:
>   	case PTP_SYS_OFFSET_PRECISE2:
> -		if (!ptp->info->getcrosststamp) {
> -			err = -EOPNOTSUPP;
> -			break;
> -		}
> -		err = ptp->info->getcrosststamp(ptp->info, &xtstamp);
> -		if (err)
> -			break;
> -
> -		memset(&precise_offset, 0, sizeof(precise_offset));
> -		ts = ktime_to_timespec64(xtstamp.device);
> -		precise_offset.device.sec = ts.tv_sec;
> -		precise_offset.device.nsec = ts.tv_nsec;
> -		ts = ktime_to_timespec64(xtstamp.sys_realtime);
> -		precise_offset.sys_realtime.sec = ts.tv_sec;
> -		precise_offset.sys_realtime.nsec = ts.tv_nsec;
> -		ts = ktime_to_timespec64(xtstamp.sys_monoraw);
> -		precise_offset.sys_monoraw.sec = ts.tv_sec;
> -		precise_offset.sys_monoraw.nsec = ts.tv_nsec;
> -		if (copy_to_user((void __user *)arg, &precise_offset,
> -				 sizeof(precise_offset)))
> -			err = -EFAULT;
> -		break;
> +		return ptp_sys_offset_precise(ptp, argptr);
>   
>   	case PTP_SYS_OFFSET_EXTENDED:
>   	case PTP_SYS_OFFSET_EXTENDED2:
> 

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@...ux.dev>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ