summaryrefslogtreecommitdiffstats
path: root/kernel/time/time.c
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 /kernel/time/time.c
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 'kernel/time/time.c')
-rw-r--r--kernel/time/time.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/kernel/time/time.c b/kernel/time/time.c
index de332250d6fa..f1983f468fe3 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -104,12 +104,12 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr)
104#ifdef CONFIG_COMPAT 104#ifdef CONFIG_COMPAT
105#ifdef __ARCH_WANT_COMPAT_SYS_TIME 105#ifdef __ARCH_WANT_COMPAT_SYS_TIME
106 106
107/* compat_time_t is a 32 bit "long" and needs to get converted. */ 107/* old_time32_t is a 32 bit "long" and needs to get converted. */
108COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc) 108COMPAT_SYSCALL_DEFINE1(time, old_time32_t __user *, tloc)
109{ 109{
110 compat_time_t i; 110 old_time32_t i;
111 111
112 i = (compat_time_t)ktime_get_real_seconds(); 112 i = (old_time32_t)ktime_get_real_seconds();
113 113
114 if (tloc) { 114 if (tloc) {
115 if (put_user(i,tloc)) 115 if (put_user(i,tloc))
@@ -119,7 +119,7 @@ COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
119 return i; 119 return i;
120} 120}
121 121
122COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr) 122COMPAT_SYSCALL_DEFINE1(stime, old_time32_t __user *, tptr)
123{ 123{
124 struct timespec64 tv; 124 struct timespec64 tv;
125 int err; 125 int err;
@@ -225,7 +225,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
225} 225}
226 226
227#ifdef CONFIG_COMPAT 227#ifdef CONFIG_COMPAT
228COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv, 228COMPAT_SYSCALL_DEFINE2(gettimeofday, struct old_timeval32 __user *, tv,
229 struct timezone __user *, tz) 229 struct timezone __user *, tz)
230{ 230{
231 if (tv) { 231 if (tv) {
@@ -244,7 +244,7 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
244 return 0; 244 return 0;
245} 245}
246 246
247COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, 247COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv,
248 struct timezone __user *, tz) 248 struct timezone __user *, tz)
249{ 249{
250 struct timespec64 new_ts; 250 struct timespec64 new_ts;
@@ -863,10 +863,10 @@ int put_timespec64(const struct timespec64 *ts,
863} 863}
864EXPORT_SYMBOL_GPL(put_timespec64); 864EXPORT_SYMBOL_GPL(put_timespec64);
865 865
866int __compat_get_timespec64(struct timespec64 *ts64, 866int __get_old_timespec32(struct timespec64 *ts64,
867 const struct compat_timespec __user *cts) 867 const struct old_timespec32 __user *cts)
868{ 868{
869 struct compat_timespec ts; 869 struct old_timespec32 ts;
870 int ret; 870 int ret;
871 871
872 ret = copy_from_user(&ts, cts, sizeof(ts)); 872 ret = copy_from_user(&ts, cts, sizeof(ts));
@@ -879,33 +879,33 @@ int __compat_get_timespec64(struct timespec64 *ts64,
879 return 0; 879 return 0;
880} 880}
881 881
882int __compat_put_timespec64(const struct timespec64 *ts64, 882int __put_old_timespec32(const struct timespec64 *ts64,
883 struct compat_timespec __user *cts) 883 struct old_timespec32 __user *cts)
884{ 884{
885 struct compat_timespec ts = { 885 struct old_timespec32 ts = {
886 .tv_sec = ts64->tv_sec, 886 .tv_sec = ts64->tv_sec,
887 .tv_nsec = ts64->tv_nsec 887 .tv_nsec = ts64->tv_nsec
888 }; 888 };
889 return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0; 889 return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0;
890} 890}
891 891
892int compat_get_timespec64(struct timespec64 *ts, const void __user *uts) 892int get_old_timespec32(struct timespec64 *ts, const void __user *uts)
893{ 893{
894 if (COMPAT_USE_64BIT_TIME) 894 if (COMPAT_USE_64BIT_TIME)
895 return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0; 895 return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
896 else 896 else
897 return __compat_get_timespec64(ts, uts); 897 return __get_old_timespec32(ts, uts);
898} 898}
899EXPORT_SYMBOL_GPL(compat_get_timespec64); 899EXPORT_SYMBOL_GPL(get_old_timespec32);
900 900
901int compat_put_timespec64(const struct timespec64 *ts, void __user *uts) 901int put_old_timespec32(const struct timespec64 *ts, void __user *uts)
902{ 902{
903 if (COMPAT_USE_64BIT_TIME) 903 if (COMPAT_USE_64BIT_TIME)
904 return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0; 904 return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
905 else 905 else
906 return __compat_put_timespec64(ts, uts); 906 return __put_old_timespec32(ts, uts);
907} 907}
908EXPORT_SYMBOL_GPL(compat_put_timespec64); 908EXPORT_SYMBOL_GPL(put_old_timespec32);
909 909
910int get_itimerspec64(struct itimerspec64 *it, 910int get_itimerspec64(struct itimerspec64 *it,
911 const struct __kernel_itimerspec __user *uit) 911 const struct __kernel_itimerspec __user *uit)
@@ -937,23 +937,23 @@ int put_itimerspec64(const struct itimerspec64 *it,
937} 937}
938EXPORT_SYMBOL_GPL(put_itimerspec64); 938EXPORT_SYMBOL_GPL(put_itimerspec64);
939 939
940int get_compat_itimerspec64(struct itimerspec64 *its, 940int get_old_itimerspec32(struct itimerspec64 *its,
941 const struct compat_itimerspec __user *uits) 941 const struct old_itimerspec32 __user *uits)
942{ 942{
943 943
944 if (__compat_get_timespec64(&its->it_interval, &uits->it_interval) || 944 if (__get_old_timespec32(&its->it_interval, &uits->it_interval) ||
945 __compat_get_timespec64(&its->it_value, &uits->it_value)) 945 __get_old_timespec32(&its->it_value, &uits->it_value))
946 return -EFAULT; 946 return -EFAULT;
947 return 0; 947 return 0;
948} 948}
949EXPORT_SYMBOL_GPL(get_compat_itimerspec64); 949EXPORT_SYMBOL_GPL(get_old_itimerspec32);
950 950
951int put_compat_itimerspec64(const struct itimerspec64 *its, 951int put_old_itimerspec32(const struct itimerspec64 *its,
952 struct compat_itimerspec __user *uits) 952 struct old_itimerspec32 __user *uits)
953{ 953{
954 if (__compat_put_timespec64(&its->it_interval, &uits->it_interval) || 954 if (__put_old_timespec32(&its->it_interval, &uits->it_interval) ||
955 __compat_put_timespec64(&its->it_value, &uits->it_value)) 955 __put_old_timespec32(&its->it_value, &uits->it_value))
956 return -EFAULT; 956 return -EFAULT;
957 return 0; 957 return 0;
958} 958}
959EXPORT_SYMBOL_GPL(put_compat_itimerspec64); 959EXPORT_SYMBOL_GPL(put_old_itimerspec32);