netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] ptp: Properly handle compat ioctls
@ 2025-01-25  9:28 Thomas Weißschuh
  2025-01-25 10:14 ` Cyrill Gorcunov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2025-01-25  9:28 UTC (permalink / raw)
  To: Richard Cochran, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Anna-Maria Behnsen,
	Frederic Weisbecker, Thomas Gleixner, John Stultz, Arnd Bergmann,
	John Stultz
  Cc: netdev, linux-kernel, Cyrill Gorcunov, Thomas Weißschuh

Pointer arguments passed to ioctls need to pass through compat_ptr() to
work correctly on s390; as explained in Documentation/driver-api/ioctl.rst.
Detect compat mode at runtime and call compat_ptr() for those commands
which do take pointer arguments.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/lkml/1ba5d3a4-7931-455b-a3ce-85a968a7cb10@app.fastmail.com/
Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Use in_compat_syscall()
- Discard changes outside drivers/ptp/, they are independent,
  unsuited for the net tree and will be submitted on their own
- Link to v1: https://lore.kernel.org/r/20250121-posix-clock-compat_ioctl-v1-1-c70d5433a825@weissschuh.net
---
 drivers/ptp/ptp_chardev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index ea96a14d72d141a4b255563b66bac8ed568b45e9..bf6468c56419c56c0737515d614b2267264816c2 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2010 OMICRON electronics GmbH
  */
+#include <linux/compat.h>
 #include <linux/module.h>
 #include <linux/posix-clock.h>
 #include <linux/poll.h>
@@ -176,6 +177,9 @@ long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
 	struct timespec64 ts;
 	int enable, err = 0;
 
+	if (in_compat_syscall() && cmd != PTP_ENABLE_PPS && cmd != PTP_ENABLE_PPS2)
+		arg = (unsigned long)compat_ptr(arg);
+
 	tsevq = pccontext->private_clkdata;
 
 	switch (cmd) {

---
base-commit: b46c89c08f4146e7987fc355941a93b12e2c03ef
change-id: 20250103-posix-clock-compat_ioctl-96fbac549146

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


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

end of thread, other threads:[~2025-01-28 11:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-25  9:28 [PATCH net v2] ptp: Properly handle compat ioctls Thomas Weißschuh
2025-01-25 10:14 ` Cyrill Gorcunov
2025-01-25 17:04 ` Arnd Bergmann
2025-01-25 20:21 ` Richard Cochran
2025-01-28 11:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).