Skip to content

Commit 7ed64f6

Browse files
CKI Backport BotHangbin Liu
authored andcommitted
ptp: Properly handle compat ioctls
JIRA: https://issues.redhat.com/browse/RHEL-84646 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: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent c48a7f1 commit 7ed64f6

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>
@@ -176,6 +177,9 @@ long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
176177
struct timespec64 ts;
177178
int enable, err = 0;
178179

180+
if (in_compat_syscall() && cmd != PTP_ENABLE_PPS && cmd != PTP_ENABLE_PPS2)
181+
arg = (unsigned long)compat_ptr(arg);
182+
179183
tsevq = pccontext->private_clkdata;
180184

181185
switch (cmd) {

0 commit comments

Comments
 (0)