All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ptp: Add sysfs attribute to show clock is safe to open RO
@ 2025-05-14 14:36 Wojtek Wasko
  2025-05-14 14:54 ` Andrew Lunn
  2025-05-15 13:40 ` Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: Wojtek Wasko @ 2025-05-14 14:36 UTC (permalink / raw)
  To: richardcochran, vadim.fedorenko; +Cc: netdev, Wojtek Wasko

Recent patches introduced in 6.15 implement permissions checks for PTP
clocks. Prior to those, a process with readonly access could modify the
state of PTP devices, in particular the generation and consumption of
PPS signals.

Userspace (e.g. udev) managing the ownership and permissions of device
nodes lacks information as to whether kernel implements the necessary
security checks and whether it is safe to expose readonly access to
PTP devices to unprivileged users. Kernel version checks are cumbersome
and prone to failure, especially if backports are considered [1].

Add a readonly sysfs attribute to PTP clocks, "ro_safe", backed by a
static string.

[1] https://github.com/systemd/systemd/pull/37302#issuecomment-2850510329
---
 drivers/ptp/ptp_sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index 6b1b8f57cd95..763fc54cf267 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -28,6 +28,8 @@ static ssize_t max_phase_adjustment_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(max_phase_adjustment);
 
+static DEVICE_STRING_ATTR_RO(ro_safe, 0444, "1\n");
+
 #define PTP_SHOW_INT(name, var)						\
 static ssize_t var##_show(struct device *dev,				\
 			   struct device_attribute *attr, char *page)	\
@@ -320,6 +322,7 @@ static DEVICE_ATTR_RW(max_vclocks);
 
 static struct attribute *ptp_attrs[] = {
 	&dev_attr_clock_name.attr,
+	&dev_attr_ro_safe.attr.attr,
 
 	&dev_attr_max_adjustment.attr,
 	&dev_attr_max_phase_adjustment.attr,
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-05-15 13:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-14 14:36 [PATCH] ptp: Add sysfs attribute to show clock is safe to open RO Wojtek Wasko
2025-05-14 14:54 ` Andrew Lunn
2025-05-14 15:25   ` Vadim Fedorenko
2025-05-15 12:48     ` Wojtek Wasko
2025-05-15 13:40 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.