summaryrefslogtreecommitdiffstats
path: root/include/linux/compat.h
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-07-13 06:52:28 -0400
committerArnd Bergmann <arnd@arndb.de>2018-08-27 08:48:48 -0400
commit9afc5eee65ca7d717a99d6fe8f4adfe32a40940a (patch)
tree4e5585234e71076c0a5a470b157e0b9de96b8da6 /include/linux/compat.h
parent33e26418193f58d1895f2f968e1953b1caf8deb7 (diff)
y2038: globally rename compat_time to old_time32
Christoph Hellwig suggested a slightly different path for handling backwards compatibility with the 32-bit time_t based system calls: Rather than simply reusing the compat_sys_* entry points on 32-bit architectures unchanged, we get rid of those entry points and the compat_time types by renaming them to something that makes more sense on 32-bit architectures (which don't have a compat mode otherwise), and then share the entry points under the new name with the 64-bit architectures that use them for implementing the compatibility. The following types and interfaces are renamed here, and moved from linux/compat_time.h to linux/time32.h: old new --- --- compat_time_t old_time32_t struct compat_timeval struct old_timeval32 struct compat_timespec struct old_timespec32 struct compat_itimerspec struct old_itimerspec32 ns_to_compat_timeval() ns_to_old_timeval32() get_compat_itimerspec64() get_old_itimerspec32() put_compat_itimerspec64() put_old_itimerspec32() compat_get_timespec64() get_old_timespec32() compat_put_timespec64() put_old_timespec32() As we already have aliases in place, this patch addresses only the instances that are relevant to the system call interface in particular, not those that occur in device drivers and other modules. Those will get handled separately, while providing the 64-bit version of the respective interfaces. I'm not renaming the timex, rusage and itimerval structures, as we are still debating what the new interface will look like, and whether we will need a replacement at all. This also doesn't change the names of the syscall entry points, which can be done more easily when we actually switch over the 32-bit architectures to use them, at that point we need to change COMPAT_SYSCALL_DEFINEx to SYSCALL_DEFINEx with a new name, e.g. with a _time32 suffix. Suggested-by: Christoph Hellwig <hch@infradead.org> Link: https://lore.kernel.org/lkml/20180705222110.GA5698@infradead.org/ Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/linux/compat.h')
-rw-r--r--include/linux/compat.h96
1 files changed, 48 insertions, 48 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 1a3c4f37e908..0e058792ecf6 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/compat_time.h> 10#include <linux/time.h>
11 11
12#include <linux/stat.h> 12#include <linux/stat.h>
13#include <linux/param.h> /* for HZ */ 13#include <linux/param.h> /* for HZ */
@@ -116,13 +116,13 @@ struct compat_sel_arg_struct;
116struct rusage; 116struct rusage;
117 117
118struct compat_utimbuf { 118struct compat_utimbuf {
119 compat_time_t actime; 119 old_time32_t actime;
120 compat_time_t modtime; 120 old_time32_t modtime;
121}; 121};
122 122
123struct compat_itimerval { 123struct compat_itimerval {
124 struct compat_timeval it_interval; 124 struct old_timeval32 it_interval;
125 struct compat_timeval it_value; 125 struct old_timeval32 it_value;
126}; 126};
127 127
128struct itimerval; 128struct itimerval;
@@ -146,7 +146,7 @@ struct compat_timex {
146 compat_long_t constant; 146 compat_long_t constant;
147 compat_long_t precision; 147 compat_long_t precision;
148 compat_long_t tolerance; 148 compat_long_t tolerance;
149 struct compat_timeval time; 149 struct old_timeval32 time;
150 compat_long_t tick; 150 compat_long_t tick;
151 compat_long_t ppsfreq; 151 compat_long_t ppsfreq;
152 compat_long_t jitter; 152 compat_long_t jitter;
@@ -307,8 +307,8 @@ struct compat_rlimit {
307}; 307};
308 308
309struct compat_rusage { 309struct compat_rusage {
310 struct compat_timeval ru_utime; 310 struct old_timeval32 ru_utime;
311 struct compat_timeval ru_stime; 311 struct old_timeval32 ru_stime;
312 compat_long_t ru_maxrss; 312 compat_long_t ru_maxrss;
313 compat_long_t ru_ixrss; 313 compat_long_t ru_ixrss;
314 compat_long_t ru_idrss; 314 compat_long_t ru_idrss;
@@ -457,8 +457,8 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *fr
457int get_compat_sigevent(struct sigevent *event, 457int get_compat_sigevent(struct sigevent *event,
458 const struct compat_sigevent __user *u_event); 458 const struct compat_sigevent __user *u_event);
459 459
460static inline int compat_timeval_compare(struct compat_timeval *lhs, 460static inline int old_timeval32_compare(struct old_timeval32 *lhs,
461 struct compat_timeval *rhs) 461 struct old_timeval32 *rhs)
462{ 462{
463 if (lhs->tv_sec < rhs->tv_sec) 463 if (lhs->tv_sec < rhs->tv_sec)
464 return -1; 464 return -1;
@@ -467,8 +467,8 @@ static inline int compat_timeval_compare(struct compat_timeval *lhs,
467 return lhs->tv_usec - rhs->tv_usec; 467 return lhs->tv_usec - rhs->tv_usec;
468} 468}
469 469
470static inline int compat_timespec_compare(struct compat_timespec *lhs, 470static inline int old_timespec32_compare(struct old_timespec32 *lhs,
471 struct compat_timespec *rhs) 471 struct old_timespec32 *rhs)
472{ 472{
473 if (lhs->tv_sec < rhs->tv_sec) 473 if (lhs->tv_sec < rhs->tv_sec)
474 return -1; 474 return -1;
@@ -552,12 +552,12 @@ asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id,
552 compat_long_t min_nr, 552 compat_long_t min_nr,
553 compat_long_t nr, 553 compat_long_t nr,
554 struct io_event __user *events, 554 struct io_event __user *events,
555 struct compat_timespec __user *timeout); 555 struct old_timespec32 __user *timeout);
556asmlinkage long compat_sys_io_pgetevents(compat_aio_context_t ctx_id, 556asmlinkage long compat_sys_io_pgetevents(compat_aio_context_t ctx_id,
557 compat_long_t min_nr, 557 compat_long_t min_nr,
558 compat_long_t nr, 558 compat_long_t nr,
559 struct io_event __user *events, 559 struct io_event __user *events,
560 struct compat_timespec __user *timeout, 560 struct old_timespec32 __user *timeout,
561 const struct __compat_aio_sigset __user *usig); 561 const struct __compat_aio_sigset __user *usig);
562 562
563/* fs/cookies.c */ 563/* fs/cookies.c */
@@ -642,11 +642,11 @@ asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
642asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, 642asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
643 compat_ulong_t __user *outp, 643 compat_ulong_t __user *outp,
644 compat_ulong_t __user *exp, 644 compat_ulong_t __user *exp,
645 struct compat_timespec __user *tsp, 645 struct old_timespec32 __user *tsp,
646 void __user *sig); 646 void __user *sig);
647asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, 647asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
648 unsigned int nfds, 648 unsigned int nfds,
649 struct compat_timespec __user *tsp, 649 struct old_timespec32 __user *tsp,
650 const compat_sigset_t __user *sigmask, 650 const compat_sigset_t __user *sigmask,
651 compat_size_t sigsetsize); 651 compat_size_t sigsetsize);
652 652
@@ -671,15 +671,15 @@ asmlinkage long compat_sys_newfstat(unsigned int fd,
671 671
672/* fs/timerfd.c */ 672/* fs/timerfd.c */
673asmlinkage long compat_sys_timerfd_gettime(int ufd, 673asmlinkage long compat_sys_timerfd_gettime(int ufd,
674 struct compat_itimerspec __user *otmr); 674 struct old_itimerspec32 __user *otmr);
675asmlinkage long compat_sys_timerfd_settime(int ufd, int flags, 675asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
676 const struct compat_itimerspec __user *utmr, 676 const struct old_itimerspec32 __user *utmr,
677 struct compat_itimerspec __user *otmr); 677 struct old_itimerspec32 __user *otmr);
678 678
679/* fs/utimes.c */ 679/* fs/utimes.c */
680asmlinkage long compat_sys_utimensat(unsigned int dfd, 680asmlinkage long compat_sys_utimensat(unsigned int dfd,
681 const char __user *filename, 681 const char __user *filename,
682 struct compat_timespec __user *t, 682 struct old_timespec32 __user *t,
683 int flags); 683 int flags);
684 684
685/* kernel/exit.c */ 685/* kernel/exit.c */
@@ -691,7 +691,7 @@ asmlinkage long compat_sys_waitid(int, compat_pid_t,
691 691
692/* kernel/futex.c */ 692/* kernel/futex.c */
693asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val, 693asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
694 struct compat_timespec __user *utime, u32 __user *uaddr2, 694 struct old_timespec32 __user *utime, u32 __user *uaddr2,
695 u32 val3); 695 u32 val3);
696asmlinkage long 696asmlinkage long
697compat_sys_set_robust_list(struct compat_robust_list_head __user *head, 697compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
@@ -701,8 +701,8 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
701 compat_size_t __user *len_ptr); 701 compat_size_t __user *len_ptr);
702 702
703/* kernel/hrtimer.c */ 703/* kernel/hrtimer.c */
704asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, 704asmlinkage long compat_sys_nanosleep(struct old_timespec32 __user *rqtp,
705 struct compat_timespec __user *rmtp); 705 struct old_timespec32 __user *rmtp);
706 706
707/* kernel/itimer.c */ 707/* kernel/itimer.c */
708asmlinkage long compat_sys_getitimer(int which, 708asmlinkage long compat_sys_getitimer(int which,
@@ -722,19 +722,19 @@ asmlinkage long compat_sys_timer_create(clockid_t which_clock,
722 struct compat_sigevent __user *timer_event_spec, 722 struct compat_sigevent __user *timer_event_spec,
723 timer_t __user *created_timer_id); 723 timer_t __user *created_timer_id);
724asmlinkage long compat_sys_timer_gettime(timer_t timer_id, 724asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
725 struct compat_itimerspec __user *setting); 725 struct old_itimerspec32 __user *setting);
726asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags, 726asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
727 struct compat_itimerspec __user *new, 727 struct old_itimerspec32 __user *new,
728 struct compat_itimerspec __user *old); 728 struct old_itimerspec32 __user *old);
729asmlinkage long compat_sys_clock_settime(clockid_t which_clock, 729asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
730 struct compat_timespec __user *tp); 730 struct old_timespec32 __user *tp);
731asmlinkage long compat_sys_clock_gettime(clockid_t which_clock, 731asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
732 struct compat_timespec __user *tp); 732 struct old_timespec32 __user *tp);
733asmlinkage long compat_sys_clock_getres(clockid_t which_clock, 733asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
734 struct compat_timespec __user *tp); 734 struct old_timespec32 __user *tp);
735asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags, 735asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
736 struct compat_timespec __user *rqtp, 736 struct old_timespec32 __user *rqtp,
737 struct compat_timespec __user *rmtp); 737 struct old_timespec32 __user *rmtp);
738 738
739/* kernel/ptrace.c */ 739/* kernel/ptrace.c */
740asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, 740asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
@@ -748,7 +748,7 @@ asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
748 unsigned int len, 748 unsigned int len,
749 compat_ulong_t __user *user_mask_ptr); 749 compat_ulong_t __user *user_mask_ptr);
750asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, 750asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
751 struct compat_timespec __user *interval); 751 struct old_timespec32 __user *interval);
752 752
753/* kernel/signal.c */ 753/* kernel/signal.c */
754asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr, 754asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
@@ -768,7 +768,7 @@ asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset,
768 compat_size_t sigsetsize); 768 compat_size_t sigsetsize);
769asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese, 769asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
770 struct compat_siginfo __user *uinfo, 770 struct compat_siginfo __user *uinfo,
771 struct compat_timespec __user *uts, compat_size_t sigsetsize); 771 struct old_timespec32 __user *uts, compat_size_t sigsetsize);
772asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig, 772asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
773 struct compat_siginfo __user *uinfo); 773 struct compat_siginfo __user *uinfo);
774/* No generic prototype for rt_sigreturn */ 774/* No generic prototype for rt_sigreturn */
@@ -782,9 +782,9 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource,
782asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru); 782asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
783 783
784/* kernel/time.c */ 784/* kernel/time.c */
785asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv, 785asmlinkage long compat_sys_gettimeofday(struct old_timeval32 __user *tv,
786 struct timezone __user *tz); 786 struct timezone __user *tz);
787asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv, 787asmlinkage long compat_sys_settimeofday(struct old_timeval32 __user *tv,
788 struct timezone __user *tz); 788 struct timezone __user *tz);
789asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 789asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
790 790
@@ -798,11 +798,11 @@ asmlinkage long compat_sys_mq_open(const char __user *u_name,
798asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes, 798asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
799 const char __user *u_msg_ptr, 799 const char __user *u_msg_ptr,
800 compat_size_t msg_len, unsigned int msg_prio, 800 compat_size_t msg_len, unsigned int msg_prio,
801 const struct compat_timespec __user *u_abs_timeout); 801 const struct old_timespec32 __user *u_abs_timeout);
802asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes, 802asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
803 char __user *u_msg_ptr, 803 char __user *u_msg_ptr,
804 compat_size_t msg_len, unsigned int __user *u_msg_prio, 804 compat_size_t msg_len, unsigned int __user *u_msg_prio,
805 const struct compat_timespec __user *u_abs_timeout); 805 const struct old_timespec32 __user *u_abs_timeout);
806asmlinkage long compat_sys_mq_notify(mqd_t mqdes, 806asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
807 const struct compat_sigevent __user *u_notification); 807 const struct compat_sigevent __user *u_notification);
808asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes, 808asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
@@ -819,7 +819,7 @@ asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
819/* ipc/sem.c */ 819/* ipc/sem.c */
820asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg); 820asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
821asmlinkage long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, 821asmlinkage long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
822 unsigned nsems, const struct compat_timespec __user *timeout); 822 unsigned nsems, const struct old_timespec32 __user *timeout);
823 823
824/* ipc/shm.c */ 824/* ipc/shm.c */
825asmlinkage long compat_sys_shmctl(int first, int second, void __user *uptr); 825asmlinkage long compat_sys_shmctl(int first, int second, void __user *uptr);
@@ -876,7 +876,7 @@ asmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid,
876 struct compat_siginfo __user *uinfo); 876 struct compat_siginfo __user *uinfo);
877asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, 877asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
878 unsigned vlen, unsigned int flags, 878 unsigned vlen, unsigned int flags,
879 struct compat_timespec __user *timeout); 879 struct old_timespec32 __user *timeout);
880asmlinkage long compat_sys_wait4(compat_pid_t pid, 880asmlinkage long compat_sys_wait4(compat_pid_t pid,
881 compat_uint_t __user *stat_addr, int options, 881 compat_uint_t __user *stat_addr, int options,
882 struct compat_rusage __user *ru); 882 struct compat_rusage __user *ru);
@@ -928,7 +928,7 @@ asmlinkage long compat_sys_pwritev64v2(unsigned long fd,
928asmlinkage long compat_sys_open(const char __user *filename, int flags, 928asmlinkage long compat_sys_open(const char __user *filename, int flags,
929 umode_t mode); 929 umode_t mode);
930asmlinkage long compat_sys_utimes(const char __user *filename, 930asmlinkage long compat_sys_utimes(const char __user *filename,
931 struct compat_timeval __user *t); 931 struct old_timeval32 __user *t);
932 932
933/* __ARCH_WANT_SYSCALL_NO_FLAGS */ 933/* __ARCH_WANT_SYSCALL_NO_FLAGS */
934asmlinkage long compat_sys_signalfd(int ufd, 934asmlinkage long compat_sys_signalfd(int ufd,
@@ -942,15 +942,15 @@ asmlinkage long compat_sys_newlstat(const char __user *filename,
942 struct compat_stat __user *statbuf); 942 struct compat_stat __user *statbuf);
943 943
944/* __ARCH_WANT_SYSCALL_DEPRECATED */ 944/* __ARCH_WANT_SYSCALL_DEPRECATED */
945asmlinkage long compat_sys_time(compat_time_t __user *tloc); 945asmlinkage long compat_sys_time(old_time32_t __user *tloc);
946asmlinkage long compat_sys_utime(const char __user *filename, 946asmlinkage long compat_sys_utime(const char __user *filename,
947 struct compat_utimbuf __user *t); 947 struct compat_utimbuf __user *t);
948asmlinkage long compat_sys_futimesat(unsigned int dfd, 948asmlinkage long compat_sys_futimesat(unsigned int dfd,
949 const char __user *filename, 949 const char __user *filename,
950 struct compat_timeval __user *t); 950 struct old_timeval32 __user *t);
951asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, 951asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
952 compat_ulong_t __user *outp, compat_ulong_t __user *exp, 952 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
953 struct compat_timeval __user *tvp); 953 struct old_timeval32 __user *tvp);
954asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32); 954asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
955asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len, 955asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len,
956 unsigned flags); 956 unsigned flags);
@@ -983,7 +983,7 @@ asmlinkage long compat_sys_sigaction(int sig,
983#endif 983#endif
984 984
985/* obsolete: kernel/time/time.c */ 985/* obsolete: kernel/time/time.c */
986asmlinkage long compat_sys_stime(compat_time_t __user *tptr); 986asmlinkage long compat_sys_stime(old_time32_t __user *tptr);
987 987
988/* obsolete: net/socket.c */ 988/* obsolete: net/socket.c */
989asmlinkage long compat_sys_socketcall(int call, u32 __user *args); 989asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
@@ -1002,15 +1002,15 @@ static inline bool in_compat_syscall(void) { return is_compat_task(); }
1002#endif 1002#endif
1003 1003
1004/** 1004/**
1005 * ns_to_compat_timeval - Compat version of ns_to_timeval 1005 * ns_to_old_timeval32 - Compat version of ns_to_timeval
1006 * @nsec: the nanoseconds value to be converted 1006 * @nsec: the nanoseconds value to be converted
1007 * 1007 *
1008 * Returns the compat_timeval representation of the nsec parameter. 1008 * Returns the old_timeval32 representation of the nsec parameter.
1009 */ 1009 */
1010static inline struct compat_timeval ns_to_compat_timeval(s64 nsec) 1010static inline struct old_timeval32 ns_to_old_timeval32(s64 nsec)
1011{ 1011{
1012 struct timeval tv; 1012 struct timeval tv;
1013 struct compat_timeval ctv; 1013 struct old_timeval32 ctv;
1014 1014
1015 tv = ns_to_timeval(nsec); 1015 tv = ns_to_timeval(nsec);
1016 ctv.tv_sec = tv.tv_sec; 1016 ctv.tv_sec = tv.tv_sec;