On Fri, 2026-05-15 at 16:40 +0000, Arthur Kiyanovski wrote:
> 
> +static long ptp_sys_offset_precise_attrs(struct ptp_clock *ptp, void __user 
> *arg)
> +{
> +     struct ptp_sys_offset_precise_attrs precise_offset_attrs;
> +     struct system_device_crosststamp xtstamp;
> +     struct ptp_clock_attributes att = {};
> +     struct timespec64 ts;
> +     int err;
> +
> +     if (!ptp->info->getcrosststampattrs)
> +             return -EOPNOTSUPP;
> +
> +     err = ptp->info->getcrosststampattrs(ptp->info, &xtstamp, &att);
> +     if (err)
> +             return err;
> +
> +     memset(&precise_offset_attrs, 0, sizeof(precise_offset_attrs));
> +     ts = ktime_to_timespec64(xtstamp.device);
> +     precise_offset_attrs.device.pct.sec = ts.tv_sec;
> +     precise_offset_attrs.device.pct.nsec = ts.tv_nsec;
> +     precise_offset_attrs.device.att.error_bound = att.error_bound;
> +     precise_offset_attrs.device.att.timescale = att.timescale;
> +     precise_offset_attrs.device.att.status = att.status;
> +     precise_offset_attrs.device.att.counter_id = att.counter_id;
> +     precise_offset_attrs.device.att.counter_value = att.counter_value;
> +

Here you're relying on the driver to populate the counter_id and value
in the attributes. We've already talked about the need to use a
system_counterval_t, and that the system_counterval_t should be part of
each timestamp.

To clarify: in this case you should be using *THE* system_counterval_t
that get_device_system_crosststamp() already has on its local stack.
Make it copy that into the xtstamp structure, don't expect drivers to
fill it in separately in the attributes.

In this case we are only allowing userspace to see the
system_counterval_t that is *already* being populated by the drivers
that support PTP_SYS_OFFSET_PRECISE / getcrosststamp.


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to