Skip to content

Commit 8d48fed

Browse files
author
Hangbin Liu
committed
ptp: Properly handle compat ioctls
JIRA: https://issues.redhat.com/browse/RHEL-85028 Upstream Status: net.git commit 19ae40f Conflicts: context conflicts due to missing commit c5a445b ("ptp: support event queue reader channel masks"). commit 19ae40f Author: Thomas Weißschuh <linux@weissschuh.net> Date: Sat Jan 25 10:28:38 2025 +0100 ptp: Properly handle compat ioctls 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: d94ba80 ("ptp: Added a brand new class driver for ptp clocks.") Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Richard Cochran <richardcochran@gmail.com> Link: https://patch.msgid.link/20250125-posix-clock-compat_ioctl-v2-1-11c865c500eb@weissschuh.net Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Hangbin Liu <haliu@redhat.com>
1 parent 5d7753d commit 8d48fed

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/ptp/ptp_chardev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* Copyright (C) 2010 OMICRON electronics GmbH
66
*/
7+
#include <linux/compat.h>
78
#include <linux/module.h>
89
#include <linux/posix-clock.h>
910
#include <linux/poll.h>
@@ -124,6 +125,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
124125
struct timespec64 ts;
125126
int enable, err = 0;
126127

128+
if (in_compat_syscall() && cmd != PTP_ENABLE_PPS && cmd != PTP_ENABLE_PPS2)
129+
arg = (unsigned long)compat_ptr(arg);
130+
127131
switch (cmd) {
128132

129133
case PTP_CLOCK_GETCAPS:

0 commit comments

Comments
 (0)