summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-04-17 06:03:19 -0400
committerArnd Bergmann <arnd@arndb.de>2018-08-29 09:42:23 -0400
commit4faea239e529d1d6b3b93fbf08d5e90427961a41 (patch)
tree031bd0905a3e26e458c4f34721ed334ddd7b3fd4
parent185cfaf7641e14af85635bb2750da302e32b04e3 (diff)
y2038: utimes: Rework #ifdef guards for compat syscalls
After changing over to 64-bit time_t syscalls, many architectures will want compat_sys_utimensat() but not respective handlers for utime(), utimes() and futimesat(). This adds a new __ARCH_WANT_SYS_UTIME32 to complement __ARCH_WANT_SYS_UTIME. For now, all 64-bit architectures that support CONFIG_COMPAT set it, but future 64-bit architectures will not (tile would not have needed it either, but got removed). As older 32-bit architectures get converted to using CONFIG_64BIT_TIME, they will have to use __ARCH_WANT_SYS_UTIME32 instead of __ARCH_WANT_SYS_UTIME. Architectures using the generic syscall ABI don't need either of them as they never had a utime syscall. Since the compat_utimbuf structure is now required outside of CONFIG_COMPAT, I'm moving it into compat_time.h. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- changed from last version: - renamed __ARCH_WANT_COMPAT_SYS_UTIME to __ARCH_WANT_SYS_UTIME32
-rw-r--r--arch/arm64/include/asm/unistd.h1
-rw-r--r--arch/mips/include/asm/unistd.h1
-rw-r--r--arch/parisc/include/asm/unistd.h1
-rw-r--r--arch/powerpc/include/asm/unistd.h1
-rw-r--r--arch/s390/include/asm/unistd.h1
-rw-r--r--arch/sparc/include/asm/unistd.h1
-rw-r--r--arch/x86/include/asm/unistd.h1
-rw-r--r--fs/utimes.c8
-rw-r--r--include/linux/compat.h7
-rw-r--r--include/linux/time32.h5
10 files changed, 19 insertions, 8 deletions
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 2af308f13463..b13ca091f833 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -22,6 +22,7 @@
22#define __ARCH_WANT_SYS_SIGPENDING 22#define __ARCH_WANT_SYS_SIGPENDING
23#define __ARCH_WANT_SYS_SIGPROCMASK 23#define __ARCH_WANT_SYS_SIGPROCMASK
24#define __ARCH_WANT_COMPAT_SYS_SENDFILE 24#define __ARCH_WANT_COMPAT_SYS_SENDFILE
25#define __ARCH_WANT_SYS_UTIME32
25#define __ARCH_WANT_SYS_FORK 26#define __ARCH_WANT_SYS_FORK
26#define __ARCH_WANT_SYS_VFORK 27#define __ARCH_WANT_SYS_VFORK
27 28
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
index c2174b80e50e..c68b8ae3efcb 100644
--- a/arch/mips/include/asm/unistd.h
+++ b/arch/mips/include/asm/unistd.h
@@ -31,6 +31,7 @@
31#define __ARCH_WANT_SYS_IPC 31#define __ARCH_WANT_SYS_IPC
32#define __ARCH_WANT_SYS_PAUSE 32#define __ARCH_WANT_SYS_PAUSE
33#define __ARCH_WANT_SYS_UTIME 33#define __ARCH_WANT_SYS_UTIME
34#define __ARCH_WANT_SYS_UTIME32
34#define __ARCH_WANT_SYS_WAITPID 35#define __ARCH_WANT_SYS_WAITPID
35#define __ARCH_WANT_SYS_SOCKETCALL 36#define __ARCH_WANT_SYS_SOCKETCALL
36#define __ARCH_WANT_SYS_GETPGRP 37#define __ARCH_WANT_SYS_GETPGRP
diff --git a/arch/parisc/include/asm/unistd.h b/arch/parisc/include/asm/unistd.h
index a0c38374fff0..bc37a4953eaa 100644
--- a/arch/parisc/include/asm/unistd.h
+++ b/arch/parisc/include/asm/unistd.h
@@ -152,6 +152,7 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
152#define __ARCH_WANT_COMPAT_SYS_TIME 152#define __ARCH_WANT_COMPAT_SYS_TIME
153#define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL 153#define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
154#define __ARCH_WANT_SYS_UTIME 154#define __ARCH_WANT_SYS_UTIME
155#define __ARCH_WANT_SYS_UTIME32
155#define __ARCH_WANT_SYS_WAITPID 156#define __ARCH_WANT_SYS_WAITPID
156#define __ARCH_WANT_SYS_SOCKETCALL 157#define __ARCH_WANT_SYS_SOCKETCALL
157#define __ARCH_WANT_SYS_FADVISE64 158#define __ARCH_WANT_SYS_FADVISE64
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 9326c9133516..b0de85b477e1 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -47,6 +47,7 @@
47#endif 47#endif
48#ifdef CONFIG_PPC64 48#ifdef CONFIG_PPC64
49#define __ARCH_WANT_COMPAT_SYS_TIME 49#define __ARCH_WANT_COMPAT_SYS_TIME
50#define __ARCH_WANT_SYS_UTIME32
50#define __ARCH_WANT_SYS_NEWFSTATAT 51#define __ARCH_WANT_SYS_NEWFSTATAT
51#define __ARCH_WANT_COMPAT_SYS_SENDFILE 52#define __ARCH_WANT_COMPAT_SYS_SENDFILE
52#endif 53#endif
diff --git a/arch/s390/include/asm/unistd.h b/arch/s390/include/asm/unistd.h
index a2d583ea526d..a1fbf15d53aa 100644
--- a/arch/s390/include/asm/unistd.h
+++ b/arch/s390/include/asm/unistd.h
@@ -34,6 +34,7 @@
34#define __ARCH_WANT_SYS_SIGPROCMASK 34#define __ARCH_WANT_SYS_SIGPROCMASK
35# ifdef CONFIG_COMPAT 35# ifdef CONFIG_COMPAT
36# define __ARCH_WANT_COMPAT_SYS_TIME 36# define __ARCH_WANT_COMPAT_SYS_TIME
37# define __ARCH_WANT_SYS_UTIME32
37# endif 38# endif
38#define __ARCH_WANT_SYS_FORK 39#define __ARCH_WANT_SYS_FORK
39#define __ARCH_WANT_SYS_VFORK 40#define __ARCH_WANT_SYS_VFORK
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h
index f7514d3eae7b..00f87dbd0b17 100644
--- a/arch/sparc/include/asm/unistd.h
+++ b/arch/sparc/include/asm/unistd.h
@@ -42,6 +42,7 @@
42#define __ARCH_WANT_SYS_IPC 42#define __ARCH_WANT_SYS_IPC
43#else 43#else
44#define __ARCH_WANT_COMPAT_SYS_TIME 44#define __ARCH_WANT_COMPAT_SYS_TIME
45#define __ARCH_WANT_SYS_UTIME32
45#define __ARCH_WANT_COMPAT_SYS_SENDFILE 46#define __ARCH_WANT_COMPAT_SYS_SENDFILE
46#endif 47#endif
47 48
diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h
index 153d2a5e6b02..dc4ed8bc2382 100644
--- a/arch/x86/include/asm/unistd.h
+++ b/arch/x86/include/asm/unistd.h
@@ -24,6 +24,7 @@
24# include <asm/unistd_64.h> 24# include <asm/unistd_64.h>
25# include <asm/unistd_64_x32.h> 25# include <asm/unistd_64_x32.h>
26# define __ARCH_WANT_COMPAT_SYS_TIME 26# define __ARCH_WANT_COMPAT_SYS_TIME
27# define __ARCH_WANT_SYS_UTIME32
27# define __ARCH_WANT_COMPAT_SYS_PREADV64 28# define __ARCH_WANT_COMPAT_SYS_PREADV64
28# define __ARCH_WANT_COMPAT_SYS_PWRITEV64 29# define __ARCH_WANT_COMPAT_SYS_PWRITEV64
29# define __ARCH_WANT_COMPAT_SYS_PREADV64V2 30# define __ARCH_WANT_COMPAT_SYS_PREADV64V2
diff --git a/fs/utimes.c b/fs/utimes.c
index 2f6f08061a26..bdcf2daf39c1 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -218,13 +218,14 @@ SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times)
218} 218}
219#endif 219#endif
220 220
221#ifdef CONFIG_COMPAT 221#ifdef CONFIG_COMPAT_32BIT_TIME
222/* 222/*
223 * Not all architectures have sys_utime, so implement this in terms 223 * Not all architectures have sys_utime, so implement this in terms
224 * of sys_utimes. 224 * of sys_utimes.
225 */ 225 */
226#ifdef __ARCH_WANT_SYS_UTIME32
226COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, 227COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
227 struct compat_utimbuf __user *, t) 228 struct old_utimbuf32 __user *, t)
228{ 229{
229 struct timespec64 tv[2]; 230 struct timespec64 tv[2];
230 231
@@ -237,6 +238,7 @@ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
237 } 238 }
238 return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); 239 return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
239} 240}
241#endif
240 242
241COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct old_timespec32 __user *, t, int, flags) 243COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct old_timespec32 __user *, t, int, flags)
242{ 244{
@@ -253,6 +255,7 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filena
253 return do_utimes(dfd, filename, t ? tv : NULL, flags); 255 return do_utimes(dfd, filename, t ? tv : NULL, flags);
254} 256}
255 257
258#ifdef __ARCH_WANT_SYS_UTIME32
256static long do_compat_futimesat(unsigned int dfd, const char __user *filename, 259static long do_compat_futimesat(unsigned int dfd, const char __user *filename,
257 struct old_timeval32 __user *t) 260 struct old_timeval32 __user *t)
258{ 261{
@@ -285,3 +288,4 @@ COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct old_timeval
285 return do_compat_futimesat(AT_FDCWD, filename, t); 288 return do_compat_futimesat(AT_FDCWD, filename, t);
286} 289}
287#endif 290#endif
291#endif
diff --git a/include/linux/compat.h b/include/linux/compat.h
index d376fa8be00d..6fb5abdb87be 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -113,11 +113,6 @@ typedef __compat_gid32_t compat_gid_t;
113struct compat_sel_arg_struct; 113struct compat_sel_arg_struct;
114struct rusage; 114struct rusage;
115 115
116struct compat_utimbuf {
117 old_time32_t actime;
118 old_time32_t modtime;
119};
120
121struct compat_itimerval { 116struct compat_itimerval {
122 struct old_timeval32 it_interval; 117 struct old_timeval32 it_interval;
123 struct old_timeval32 it_value; 118 struct old_timeval32 it_value;
@@ -942,7 +937,7 @@ asmlinkage long compat_sys_newlstat(const char __user *filename,
942/* __ARCH_WANT_SYSCALL_DEPRECATED */ 937/* __ARCH_WANT_SYSCALL_DEPRECATED */
943asmlinkage long compat_sys_time(old_time32_t __user *tloc); 938asmlinkage long compat_sys_time(old_time32_t __user *tloc);
944asmlinkage long compat_sys_utime(const char __user *filename, 939asmlinkage long compat_sys_utime(const char __user *filename,
945 struct compat_utimbuf __user *t); 940 struct old_utimbuf32 __user *t);
946asmlinkage long compat_sys_futimesat(unsigned int dfd, 941asmlinkage long compat_sys_futimesat(unsigned int dfd,
947 const char __user *filename, 942 const char __user *filename,
948 struct old_timeval32 __user *t); 943 struct old_timeval32 __user *t);
diff --git a/include/linux/time32.h b/include/linux/time32.h
index 0e0d7304d1a8..61904a6c098f 100644
--- a/include/linux/time32.h
+++ b/include/linux/time32.h
@@ -30,6 +30,11 @@ struct old_itimerspec32 {
30 struct old_timespec32 it_value; 30 struct old_timespec32 it_value;
31}; 31};
32 32
33struct old_utimbuf32 {
34 old_time32_t actime;
35 old_time32_t modtime;
36};
37
33extern int get_old_timespec32(struct timespec64 *, const void __user *); 38extern int get_old_timespec32(struct timespec64 *, const void __user *);
34extern int put_old_timespec32(const struct timespec64 *, void __user *); 39extern int put_old_timespec32(const struct timespec64 *, void __user *);
35extern int get_old_itimerspec32(struct itimerspec64 *its, 40extern int get_old_itimerspec32(struct itimerspec64 *its,