Skip to content

Commit 0245ed5

Browse files
t-8chmehmetb0
authored andcommitted
ptp: Properly handle compat ioctls
BugLink: https://bugs.launchpad.net/bugs/2103829 [ Upstream commit 19ae40f ] 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 <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Fixes: d94ba80 ("ptp: Added a brand new class driver for ptp clocks.") Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Cyrill Gorcunov <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Acked-by: Richard Cochran <[email protected]> Link: https://patch.msgid.link/20250125-posix-clock-compat_ioctl-v2-1-11c865c500eb@weissschuh.net Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 5c7f3c4 commit 0245ed5

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>
@@ -178,6 +179,9 @@ long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
178179

179180
tsevq = pccontext->private_clkdata;
180181

182+
if (in_compat_syscall() && cmd != PTP_ENABLE_PPS && cmd != PTP_ENABLE_PPS2)
183+
arg = (unsigned long)compat_ptr(arg);
184+
181185
switch (cmd) {
182186

183187
case PTP_CLOCK_GETCAPS:

0 commit comments

Comments
 (0)