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
This commit is contained in:
Arnd Bergmann 2018-04-17 12:03:19 +02:00
parent 185cfaf764
commit 4faea239e5
10 changed files with 19 additions and 8 deletions

View File

@ -22,6 +22,7 @@
#define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_COMPAT_SYS_SENDFILE #define __ARCH_WANT_COMPAT_SYS_SENDFILE
#define __ARCH_WANT_SYS_UTIME32
#define __ARCH_WANT_SYS_FORK #define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK #define __ARCH_WANT_SYS_VFORK

View File

@ -31,6 +31,7 @@
#define __ARCH_WANT_SYS_IPC #define __ARCH_WANT_SYS_IPC
#define __ARCH_WANT_SYS_PAUSE #define __ARCH_WANT_SYS_PAUSE
#define __ARCH_WANT_SYS_UTIME #define __ARCH_WANT_SYS_UTIME
#define __ARCH_WANT_SYS_UTIME32
#define __ARCH_WANT_SYS_WAITPID #define __ARCH_WANT_SYS_WAITPID
#define __ARCH_WANT_SYS_SOCKETCALL #define __ARCH_WANT_SYS_SOCKETCALL
#define __ARCH_WANT_SYS_GETPGRP #define __ARCH_WANT_SYS_GETPGRP

View File

@ -152,6 +152,7 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
#define __ARCH_WANT_COMPAT_SYS_TIME #define __ARCH_WANT_COMPAT_SYS_TIME
#define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL #define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
#define __ARCH_WANT_SYS_UTIME #define __ARCH_WANT_SYS_UTIME
#define __ARCH_WANT_SYS_UTIME32
#define __ARCH_WANT_SYS_WAITPID #define __ARCH_WANT_SYS_WAITPID
#define __ARCH_WANT_SYS_SOCKETCALL #define __ARCH_WANT_SYS_SOCKETCALL
#define __ARCH_WANT_SYS_FADVISE64 #define __ARCH_WANT_SYS_FADVISE64

View File

@ -47,6 +47,7 @@
#endif #endif
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
#define __ARCH_WANT_COMPAT_SYS_TIME #define __ARCH_WANT_COMPAT_SYS_TIME
#define __ARCH_WANT_SYS_UTIME32
#define __ARCH_WANT_SYS_NEWFSTATAT #define __ARCH_WANT_SYS_NEWFSTATAT
#define __ARCH_WANT_COMPAT_SYS_SENDFILE #define __ARCH_WANT_COMPAT_SYS_SENDFILE
#endif #endif

View File

@ -34,6 +34,7 @@
#define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_SIGPROCMASK
# ifdef CONFIG_COMPAT # ifdef CONFIG_COMPAT
# define __ARCH_WANT_COMPAT_SYS_TIME # define __ARCH_WANT_COMPAT_SYS_TIME
# define __ARCH_WANT_SYS_UTIME32
# endif # endif
#define __ARCH_WANT_SYS_FORK #define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK #define __ARCH_WANT_SYS_VFORK

View File

@ -42,6 +42,7 @@
#define __ARCH_WANT_SYS_IPC #define __ARCH_WANT_SYS_IPC
#else #else
#define __ARCH_WANT_COMPAT_SYS_TIME #define __ARCH_WANT_COMPAT_SYS_TIME
#define __ARCH_WANT_SYS_UTIME32
#define __ARCH_WANT_COMPAT_SYS_SENDFILE #define __ARCH_WANT_COMPAT_SYS_SENDFILE
#endif #endif

View File

@ -24,6 +24,7 @@
# include <asm/unistd_64.h> # include <asm/unistd_64.h>
# include <asm/unistd_64_x32.h> # include <asm/unistd_64_x32.h>
# define __ARCH_WANT_COMPAT_SYS_TIME # define __ARCH_WANT_COMPAT_SYS_TIME
# define __ARCH_WANT_SYS_UTIME32
# define __ARCH_WANT_COMPAT_SYS_PREADV64 # define __ARCH_WANT_COMPAT_SYS_PREADV64
# define __ARCH_WANT_COMPAT_SYS_PWRITEV64 # define __ARCH_WANT_COMPAT_SYS_PWRITEV64
# define __ARCH_WANT_COMPAT_SYS_PREADV64V2 # define __ARCH_WANT_COMPAT_SYS_PREADV64V2

View File

@ -218,13 +218,14 @@ SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times)
} }
#endif #endif
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT_32BIT_TIME
/* /*
* Not all architectures have sys_utime, so implement this in terms * Not all architectures have sys_utime, so implement this in terms
* of sys_utimes. * of sys_utimes.
*/ */
#ifdef __ARCH_WANT_SYS_UTIME32
COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
struct compat_utimbuf __user *, t) struct old_utimbuf32 __user *, t)
{ {
struct timespec64 tv[2]; struct timespec64 tv[2];
@ -237,6 +238,7 @@ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
} }
return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
} }
#endif
COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct old_timespec32 __user *, t, int, flags) COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct old_timespec32 __user *, t, int, flags)
{ {
@ -253,6 +255,7 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filena
return do_utimes(dfd, filename, t ? tv : NULL, flags); return do_utimes(dfd, filename, t ? tv : NULL, flags);
} }
#ifdef __ARCH_WANT_SYS_UTIME32
static long do_compat_futimesat(unsigned int dfd, const char __user *filename, static long do_compat_futimesat(unsigned int dfd, const char __user *filename,
struct old_timeval32 __user *t) struct old_timeval32 __user *t)
{ {
@ -285,3 +288,4 @@ COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct old_timeval
return do_compat_futimesat(AT_FDCWD, filename, t); return do_compat_futimesat(AT_FDCWD, filename, t);
} }
#endif #endif
#endif

View File

@ -113,11 +113,6 @@ typedef __compat_gid32_t compat_gid_t;
struct compat_sel_arg_struct; struct compat_sel_arg_struct;
struct rusage; struct rusage;
struct compat_utimbuf {
old_time32_t actime;
old_time32_t modtime;
};
struct compat_itimerval { struct compat_itimerval {
struct old_timeval32 it_interval; struct old_timeval32 it_interval;
struct old_timeval32 it_value; struct old_timeval32 it_value;
@ -942,7 +937,7 @@ asmlinkage long compat_sys_newlstat(const char __user *filename,
/* __ARCH_WANT_SYSCALL_DEPRECATED */ /* __ARCH_WANT_SYSCALL_DEPRECATED */
asmlinkage long compat_sys_time(old_time32_t __user *tloc); asmlinkage long compat_sys_time(old_time32_t __user *tloc);
asmlinkage long compat_sys_utime(const char __user *filename, asmlinkage long compat_sys_utime(const char __user *filename,
struct compat_utimbuf __user *t); struct old_utimbuf32 __user *t);
asmlinkage long compat_sys_futimesat(unsigned int dfd, asmlinkage long compat_sys_futimesat(unsigned int dfd,
const char __user *filename, const char __user *filename,
struct old_timeval32 __user *t); struct old_timeval32 __user *t);

View File

@ -30,6 +30,11 @@ struct old_itimerspec32 {
struct old_timespec32 it_value; struct old_timespec32 it_value;
}; };
struct old_utimbuf32 {
old_time32_t actime;
old_time32_t modtime;
};
extern int get_old_timespec32(struct timespec64 *, const void __user *); extern int get_old_timespec32(struct timespec64 *, const void __user *);
extern int put_old_timespec32(const struct timespec64 *, void __user *); extern int put_old_timespec32(const struct timespec64 *, void __user *);
extern int get_old_itimerspec32(struct itimerspec64 *its, extern int get_old_itimerspec32(struct itimerspec64 *its,