Skip to content

Commit ceb3074

Browse files
committed
Merge tag 'y2038-cleanups-5.5' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground
Pull y2038 cleanups from Arnd Bergmann: "y2038 syscall implementation cleanups This is a series of cleanups for the y2038 work, mostly intended for namespace cleaning: the kernel defines the traditional time_t, timeval and timespec types that often lead to y2038-unsafe code. Even though the unsafe usage is mostly gone from the kernel, having the types and associated functions around means that we can still grow new users, and that we may be missing conversions to safe types that actually matter. There are still a number of driver specific patches needed to get the last users of these types removed, those have been submitted to the respective maintainers" Link: https://lore.kernel.org/lkml/[email protected]/ * tag 'y2038-cleanups-5.5' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground: (26 commits) y2038: alarm: fix half-second cut-off y2038: ipc: fix x32 ABI breakage y2038: fix typo in powerpc vdso "LOPART" y2038: allow disabling time32 system calls y2038: itimer: change implementation to timespec64 y2038: move itimer reset into itimer.c y2038: use compat_{get,set}_itimer on alpha y2038: itimer: compat handling to itimer.c y2038: time: avoid timespec usage in settimeofday() y2038: timerfd: Use timespec64 internally y2038: elfcore: Use __kernel_old_timeval for process times y2038: make ns_to_compat_timeval use __kernel_old_timeval y2038: socket: use __kernel_old_timespec instead of timespec y2038: socket: remove timespec reference in timestamping y2038: syscalls: change remaining timeval to __kernel_old_timeval y2038: rusage: use __kernel_old_timeval y2038: uapi: change __kernel_time_t to __kernel_old_time_t y2038: stat: avoid 'time_t' in 'struct stat' y2038: ipc: remove __kernel_time_t reference from headers y2038: vdso: powerpc: avoid timespec references ...
2 parents 0da5221 + b111df8 commit ceb3074

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+472
-468
lines changed

arch/Kconfig

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -796,16 +796,9 @@ config OLD_SIGACTION
796796
config COMPAT_OLD_SIGACTION
797797
bool
798798

799-
config 64BIT_TIME
800-
def_bool y
801-
help
802-
This should be selected by all architectures that need to support
803-
new system calls with a 64-bit time_t. This is relevant on all 32-bit
804-
architectures, and 64-bit architectures as part of compat syscall
805-
handling.
806-
807799
config COMPAT_32BIT_TIME
808-
def_bool !64BIT || COMPAT
800+
bool "Provide system calls for 32-bit time_t"
801+
default !64BIT || COMPAT
809802
help
810803
This enables 32 bit time_t support in addition to 64 bit time_t support.
811804
This is relevant on all 32-bit architectures, and 64-bit architectures

arch/alpha/kernel/osf_sys.c

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -963,38 +963,14 @@ put_tv32(struct timeval32 __user *o, struct timespec64 *i)
963963
}
964964

965965
static inline long
966-
put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i)
966+
put_tv_to_tv32(struct timeval32 __user *o, struct __kernel_old_timeval *i)
967967
{
968968
return copy_to_user(o, &(struct timeval32){
969969
.tv_sec = i->tv_sec,
970970
.tv_usec = i->tv_usec},
971971
sizeof(struct timeval32));
972972
}
973973

974-
static inline long
975-
get_it32(struct itimerval *o, struct itimerval32 __user *i)
976-
{
977-
struct itimerval32 itv;
978-
if (copy_from_user(&itv, i, sizeof(struct itimerval32)))
979-
return -EFAULT;
980-
o->it_interval.tv_sec = itv.it_interval.tv_sec;
981-
o->it_interval.tv_usec = itv.it_interval.tv_usec;
982-
o->it_value.tv_sec = itv.it_value.tv_sec;
983-
o->it_value.tv_usec = itv.it_value.tv_usec;
984-
return 0;
985-
}
986-
987-
static inline long
988-
put_it32(struct itimerval32 __user *o, struct itimerval *i)
989-
{
990-
return copy_to_user(o, &(struct itimerval32){
991-
.it_interval.tv_sec = o->it_interval.tv_sec,
992-
.it_interval.tv_usec = o->it_interval.tv_usec,
993-
.it_value.tv_sec = o->it_value.tv_sec,
994-
.it_value.tv_usec = o->it_value.tv_usec},
995-
sizeof(struct itimerval32));
996-
}
997-
998974
static inline void
999975
jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
1000976
{
@@ -1039,47 +1015,6 @@ SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
10391015

10401016
asmlinkage long sys_ni_posix_timers(void);
10411017

1042-
SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
1043-
{
1044-
struct itimerval kit;
1045-
int error;
1046-
1047-
if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
1048-
return sys_ni_posix_timers();
1049-
1050-
error = do_getitimer(which, &kit);
1051-
if (!error && put_it32(it, &kit))
1052-
error = -EFAULT;
1053-
1054-
return error;
1055-
}
1056-
1057-
SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
1058-
struct itimerval32 __user *, out)
1059-
{
1060-
struct itimerval kin, kout;
1061-
int error;
1062-
1063-
if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
1064-
return sys_ni_posix_timers();
1065-
1066-
if (in) {
1067-
if (get_it32(&kin, in))
1068-
return -EFAULT;
1069-
} else
1070-
memset(&kin, 0, sizeof(kin));
1071-
1072-
error = do_setitimer(which, &kin, out ? &kout : NULL);
1073-
if (error || !out)
1074-
return error;
1075-
1076-
if (put_it32(out, &kout))
1077-
return -EFAULT;
1078-
1079-
return 0;
1080-
1081-
}
1082-
10831018
SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
10841019
struct timeval32 __user *, tvs)
10851020
{

arch/alpha/kernel/syscalls/syscall.tbl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@
8989
80 common setgroups sys_setgroups
9090
81 common osf_old_getpgrp sys_ni_syscall
9191
82 common setpgrp sys_setpgid
92-
83 common osf_setitimer sys_osf_setitimer
92+
83 common osf_setitimer compat_sys_setitimer
9393
84 common osf_old_wait sys_ni_syscall
9494
85 common osf_table sys_ni_syscall
95-
86 common osf_getitimer sys_osf_getitimer
95+
86 common osf_getitimer compat_sys_getitimer
9696
87 common gethostname sys_gethostname
9797
88 common sethostname sys_sethostname
9898
89 common getdtablesize sys_getdtablesize

arch/ia64/kernel/asm-offsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void foo(void)
211211
offsetof (struct cpuinfo_ia64, ptce_stride));
212212
BLANK();
213213
DEFINE(IA64_TIMESPEC_TV_NSEC_OFFSET,
214-
offsetof (struct timespec, tv_nsec));
214+
offsetof (struct __kernel_old_timespec, tv_nsec));
215215
DEFINE(IA64_TIME_SN_SPEC_SNSEC_OFFSET,
216216
offsetof (struct time_sn_spec, snsec));
217217

arch/mips/include/uapi/asm/msgbuf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#if defined(__mips64)
1616
struct msqid64_ds {
1717
struct ipc64_perm msg_perm;
18-
__kernel_time_t msg_stime; /* last msgsnd time */
19-
__kernel_time_t msg_rtime; /* last msgrcv time */
20-
__kernel_time_t msg_ctime; /* last change time */
18+
long msg_stime; /* last msgsnd time */
19+
long msg_rtime; /* last msgrcv time */
20+
long msg_ctime; /* last change time */
2121
unsigned long msg_cbytes; /* current number of bytes on queue */
2222
unsigned long msg_qnum; /* number of messages in queue */
2323
unsigned long msg_qbytes; /* max number of bytes on queue */

arch/mips/include/uapi/asm/sembuf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#ifdef __mips64
1515
struct semid64_ds {
1616
struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
17-
__kernel_time_t sem_otime; /* last semop time */
18-
__kernel_time_t sem_ctime; /* last change time */
17+
long sem_otime; /* last semop time */
18+
long sem_ctime; /* last change time */
1919
unsigned long sem_nsems; /* no. of semaphores in array */
2020
unsigned long __unused1;
2121
unsigned long __unused2;

arch/mips/include/uapi/asm/shmbuf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
struct shmid64_ds {
1818
struct ipc64_perm shm_perm; /* operation perms */
1919
size_t shm_segsz; /* size of segment (bytes) */
20-
__kernel_time_t shm_atime; /* last attach time */
21-
__kernel_time_t shm_dtime; /* last detach time */
22-
__kernel_time_t shm_ctime; /* last change time */
20+
long shm_atime; /* last attach time */
21+
long shm_dtime; /* last detach time */
22+
long shm_ctime; /* last change time */
2323
__kernel_pid_t shm_cpid; /* pid of creator */
2424
__kernel_pid_t shm_lpid; /* pid of last operator */
2525
unsigned long shm_nattch; /* no. of current attaches */

arch/mips/include/uapi/asm/stat.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ struct stat {
2626
gid_t st_gid;
2727
unsigned st_rdev;
2828
long st_pad2[2];
29-
off_t st_size;
29+
long st_size;
3030
long st_pad3;
3131
/*
3232
* Actually this should be timestruc_t st_atime, st_mtime and st_ctime
3333
* but we don't have it under Linux.
3434
*/
35-
time_t st_atime;
35+
long st_atime;
3636
long st_atime_nsec;
37-
time_t st_mtime;
37+
long st_mtime;
3838
long st_mtime_nsec;
39-
time_t st_ctime;
39+
long st_ctime;
4040
long st_ctime_nsec;
4141
long st_blksize;
4242
long st_blocks;
@@ -70,13 +70,13 @@ struct stat64 {
7070
* Actually this should be timestruc_t st_atime, st_mtime and st_ctime
7171
* but we don't have it under Linux.
7272
*/
73-
time_t st_atime;
73+
long st_atime;
7474
unsigned long st_atime_nsec; /* Reserved for st_atime expansion */
7575

76-
time_t st_mtime;
76+
long st_mtime;
7777
unsigned long st_mtime_nsec; /* Reserved for st_mtime expansion */
7878

79-
time_t st_ctime;
79+
long st_ctime;
8080
unsigned long st_ctime_nsec; /* Reserved for st_ctime expansion */
8181

8282
unsigned long st_blksize;
@@ -105,7 +105,7 @@ struct stat {
105105
unsigned int st_rdev;
106106
unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
107107

108-
off_t st_size;
108+
long st_size;
109109

110110
/*
111111
* Actually this should be timestruc_t st_atime, st_mtime and st_ctime

arch/mips/kernel/binfmt_elfn32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value)
100100
#undef TASK_SIZE
101101
#define TASK_SIZE TASK_SIZE32
102102

103-
#undef ns_to_timeval
104-
#define ns_to_timeval ns_to_old_timeval32
103+
#undef ns_to_kernel_old_timeval
104+
#define ns_to_kernel_old_timeval ns_to_old_timeval32
105105

106106
#include "../../../fs/binfmt_elf.c"

arch/mips/kernel/binfmt_elfo32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value)
103103
#undef TASK_SIZE
104104
#define TASK_SIZE TASK_SIZE32
105105

106-
#undef ns_to_timeval
107-
#define ns_to_timeval ns_to_old_timeval32
106+
#undef ns_to_kernel_old_timeval
107+
#define ns_to_kernel_old_timeval ns_to_old_timeval32
108108

109109
#include "../../../fs/binfmt_elf.c"

0 commit comments

Comments
 (0)