sys_stime needs a compat function.
Subsystems (4)
PATCH 1/1 sys_stime needs a compat function.
Hi,
I got a bugzilla report about sys_stime failures on s390 (Suse bugzilla #48295 if anybody wants to have a look).
The problem is that time_t is defined as a "long" for the 64 bit architectures that do 32 bit system call emulation. sys_stime gets a pointer to a time_t which needs to get converted in a compat system call handler. I think that of the seven 32/64 bit archs mips, parisc, s390, sparc64 and x68_64 need fixing. ia64 doesn't support sys_stime and ppc64 has its own sys_stime functions.
blue skies,
Martin.
---
[patch] sys_stime needs a compat function.
From: Martin Schwidefsky <[email protected]>
Convert compat_time_t to time_t in 32 bit emulation for sys_stime.
diffstat
arch/mips/kernel/scall64-o32.S | 2 +- arch/parisc/kernel/syscall_table.S | 2 +- arch/s390/kernel/compat_wrapper.S | 4 ++-- arch/sparc64/kernel/systbls.S | 2 +- arch/x86_64/ia32/ia32entry.S | 2 +- kernel/compat.c | 27 +++++++++++++++++++++++++++ 6 files changed, 33 insertions(+), 6 deletions(-)
arch/mips/kernel/scall64-o32.S +1 -1
@@ -283,7 +283,7 @@ sys sys_oldumount 1 sys sys_setuid 1 sys sys_getuid 0 - sys sys_stime 1 /* 4025 */ + sys compat_sys_stime 1 /* 4025 */ sys sys32_ptrace 4 sys sys_alarm 1 sys sys_ni_syscall 0 /* was sys_fstat */
arch/parisc/kernel/syscall_table.S +1 -1
@@ -91,7 +91,7 @@ ENTRY_SAME(bind) ENTRY_SAME(setuid) ENTRY_SAME(getuid) - ENTRY_SAME(stime) /* 25 */ + ENTRY_COMP(stime) /* 25 */ ENTRY_SAME(ptrace) ENTRY_SAME(alarm) /* see stat comment */
arch/s390/kernel/compat_wrapper.S +2 -2
@@ -1076,8 +1076,8 @@ .globl sys32_stime_wrapper sys32_stime_wrapper: - llgtr %r2,%r2 # int * - jg sys_stime # branch to system call + llgtr %r2,%r2 # long * + jg compat_sys_stime # branch to system call .globl sys32_sysctl_wrapper sys32_sysctl_wrapper:
arch/sparc64/kernel/systbls.S +1 -1
@@ -66,7 +66,7 @@ .word sys32_ipc, sys32_sigreturn, sys_clone, sys_nis_syscall, sys32_adjtimex /*220*/ .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16 -/*230*/ .word sys32_select, sys_time, sys_nis_syscall, sys_stime, compat_sys_statfs64 +/*230*/ .word sys32_select, sys_time, sys_nis_syscall, compat_sys_stime, compat_sys_statfs64 .word compat_sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys32_mlockall /*240*/ .word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler .word sys_sched_yield, sys32_sched_get_priority_max, sys32_sched_get_priority_min, sys32_sched_rr_get_interval, compat_sys_nanosleep
arch/x86_64/ia32/ia32entry.S +1 -1
@@ -327,7 +327,7 @@ .quad sys_oldumount /* old_umount */ .quad sys_setuid16 .quad sys_getuid16 - .quad sys_stime /* stime */ /* 25 */ + .quad compat_sys_stime /* stime */ /* 25 */ .quad sys32_ptrace /* ptrace */ .quad sys_alarm .quad sys_fstat /* (old)fstat */
kernel/compat.c +27 -0
@@ -680,3 +680,30 @@return 0 ; } + +#ifdef __ARCH_WANT_SYS_TIME + +/* +* sys_stime() can be implemented in user-level using +* sys_settimeofday(). Is this for backwards compatibility? If so, +* why not move it into the appropriate arch directory (for those +* architectures that need it). +*/ + +asmlinkage long compat_sys_stime (compat_time_t __user *tptr) +{ +struct timespec tv; +compat_time_t time; + +if (!capable (CAP_SYS_TIME )) +return -EPERM ; +if (get_user (time, tptr)) +return -EFAULT ; + + tv.tv_sec = (time_t ) time; + tv.tv_nsec =0 ; +do_settimeofday (&tv); +return 0 ; +} + +#endif /* __ARCH_WANT_SYS_TIME */
Arnd Bergmann
maintainerQuoted 1 line · Martin Schwidefsky
ia64 doesn't support
sys_stime
I'd call that a bug, too.
Quoted 1 line
and ppc64 has its own
sys_stimefunctions.
This one is identical to the generic sys_stime function (despite the comment above it), so it should be merged as well.
kernel/compat.c line 693
Quoted 11 lines
kernel/compat.c +11
-0+ +#ifdef __ARCH_WANT_SYS_TIME + +/* +* sys_stime() can be implemented in user-level using +* sys_settimeofday(). Is this for backwards compatibility? If so, +* why not move it into the appropriate arch directory (for those +* architectures that need it). +*/ + +asmlinkage long compat_sys_stime (compat_time_t __user *tptr)
I'd prefer having an extra __ARCH_WANT_COMPAT_SYS_TIME flag. Mips, x86_64, ia64 and s390 only need compat_sys_stime, but not sys_stime for 64 bit kernels.
Also, the comment you copied from sys_stime is apparently superceded by introduction of __ARCH_WANT_XYZ.
Arnd <><