Skip to content

Commit

Permalink
Merge tag 'y2038-new-syscalls' of git://git.kernel.org:/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/arnd/playground into timers/2038

Pull y2038 - time64 system calls from Arnd Bergmann:

This series finally gets us to the point of having system calls with 64-bit
time_t on all architectures, after a long time of incremental preparation
patches.

There was actually one conversion that I missed during the summer,
i.e. Deepa's timex series, which I now updated based the 5.0-rc1 changes
and review comments.

The following system calls are now added on all 32-bit architectures using
the same system call numbers:

403 clock_gettime64
404 clock_settime64
405 clock_adjtime64
406 clock_getres_time64
407 clock_nanosleep_time64
408 timer_gettime64
409 timer_settime64
410 timerfd_gettime64
411 timerfd_settime64
412 utimensat_time64
413 pselect6_time64
414 ppoll_time64
416 io_pgetevents_time64
417 recvmmsg_time64
418 mq_timedsend_time64
419 mq_timedreceiv_time64
420 semtimedop_time64
421 rt_sigtimedwait_time64
422 futex_time64
423 sched_rr_get_interval_time64

Each one of these corresponds directly to an existing system call that
includes a 'struct timespec' argument, or a structure containing a timespec
or (in case of clock_adjtime) timeval. Not included here are new versions
of getitimer/setitimer and getrusage/waitid, which are planned for the
future but only needed to make a consistent API rather than for correct
operation beyond y2038. These four system calls are based on 'timeval', and
it has not been finally decided what the replacement kernel interface will
use instead.

So far, I have done a lot of build testing across most architectures, which
has found a number of bugs. Runtime testing so far included testing LTP on
32-bit ARM with the existing system calls, to ensure we do not regress for
existing binaries, and a test with a 32-bit x86 build of LTP against a
modified version of the musl C library that has been adapted to the new
system call interface [3].  This library can be used for testing on all
architectures supported by musl-1.1.21, but it is not how the support is
getting integrated into the official musl release. Official musl support is
planned but will require more invasive changes to the library.

Link: https://lore.kernel.org/lkml/[email protected]/T/
Link: https://lore.kernel.org/lkml/[email protected]/
Link: https://git.linaro.org/people/arnd/musl-y2038.git/ [2]
  • Loading branch information
KAGA-KOKO committed Feb 10, 2019
2 parents fd659cc + 48166e6 commit 41ea391
Show file tree
Hide file tree
Showing 65 changed files with 1,263 additions and 713 deletions.
2 changes: 1 addition & 1 deletion arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ config 64BIT_TIME
handling.

config COMPAT_32BIT_TIME
def_bool (!64BIT && 64BIT_TIME) || COMPAT
def_bool !64BIT || COMPAT
help
This enables 32 bit time_t support in addition to 64 bit time_t support.
This is relevant on all 32-bit architectures, and 64-bit architectures
Expand Down
5 changes: 3 additions & 2 deletions arch/alpha/kernel/osf_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ struct timex32 {

SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
{
struct timex txc;
struct __kernel_timex txc;
int ret;

/* copy relevant bits of struct timex. */
Expand All @@ -1270,7 +1270,8 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
(copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) -
offsetof(struct timex32, tick))) ||
(put_tv_to_tv32(&txc_p->time, &txc.time)))
(put_user(txc.time.tv_sec, &txc_p->time.tv_sec)) ||
(put_user(txc.time.tv_usec, &txc_p->time.tv_usec)))
return -EFAULT;

return ret;
Expand Down
2 changes: 2 additions & 0 deletions arch/alpha/kernel/syscalls/syscall.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,5 @@
530 common getegid sys_getegid
531 common geteuid sys_geteuid
532 common getppid sys_getppid
# all other architectures have common numbers for new syscall, alpha
# is the exception.
4 changes: 2 additions & 2 deletions arch/arm/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
#define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_OLD_MMAP
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_UTIME
#define __ARCH_WANT_SYS_UTIME32

#if !defined(CONFIG_AEABI) || defined(CONFIG_OABI_COMPAT)
#define __ARCH_WANT_SYS_TIME
#define __ARCH_WANT_SYS_TIME32
#define __ARCH_WANT_SYS_IPC
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_ALARM
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/kernel/sys_oabi-compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ struct oabi_sembuf {
asmlinkage long sys_oabi_semtimedop(int semid,
struct oabi_sembuf __user *tsops,
unsigned nsops,
const struct timespec __user *timeout)
const struct old_timespec32 __user *timeout)
{
struct sembuf *sops;
struct timespec local_timeout;
struct old_timespec32 local_timeout;
long err;
int i;

Expand Down Expand Up @@ -350,7 +350,7 @@ asmlinkage long sys_oabi_semtimedop(int semid,
} else {
mm_segment_t fs = get_fs();
set_fs(KERNEL_DS);
err = sys_semtimedop(semid, sops, nsops, timeout);
err = sys_semtimedop_time32(semid, sops, nsops, timeout);
set_fs(fs);
}
kfree(sops);
Expand All @@ -375,7 +375,7 @@ asmlinkage int sys_oabi_ipc(uint call, int first, int second, int third,
return sys_oabi_semtimedop(first,
(struct oabi_sembuf __user *)ptr,
second,
(const struct timespec __user *)fifth);
(const struct old_timespec32 __user *)fifth);
default:
return sys_ipc(call, first, second, third, ptr, fifth);
}
Expand Down
77 changes: 49 additions & 28 deletions arch/arm/tools/syscall.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
10 common unlink sys_unlink
11 common execve sys_execve
12 common chdir sys_chdir
13 oabi time sys_time
13 oabi time sys_time32
14 common mknod sys_mknod
15 common chmod sys_chmod
16 common lchown sys_lchown16
Expand All @@ -36,12 +36,12 @@
22 oabi umount sys_oldumount
23 common setuid sys_setuid16
24 common getuid sys_getuid16
25 oabi stime sys_stime
25 oabi stime sys_stime32
26 common ptrace sys_ptrace
27 oabi alarm sys_alarm
# 28 was sys_fstat
29 common pause sys_pause
30 oabi utime sys_utime
30 oabi utime sys_utime32
# 31 was sys_stty
# 32 was sys_gtty
33 common access sys_access
Expand Down Expand Up @@ -137,7 +137,7 @@
121 common setdomainname sys_setdomainname
122 common uname sys_newuname
# 123 was sys_modify_ldt
124 common adjtimex sys_adjtimex
124 common adjtimex sys_adjtimex_time32
125 common mprotect sys_mprotect
126 common sigprocmask sys_sigprocmask
# 127 was sys_create_module
Expand Down Expand Up @@ -174,8 +174,8 @@
158 common sched_yield sys_sched_yield
159 common sched_get_priority_max sys_sched_get_priority_max
160 common sched_get_priority_min sys_sched_get_priority_min
161 common sched_rr_get_interval sys_sched_rr_get_interval
162 common nanosleep sys_nanosleep
161 common sched_rr_get_interval sys_sched_rr_get_interval_time32
162 common nanosleep sys_nanosleep_time32
163 common mremap sys_mremap
164 common setresuid sys_setresuid16
165 common getresuid sys_getresuid16
Expand All @@ -190,7 +190,7 @@
174 common rt_sigaction sys_rt_sigaction
175 common rt_sigprocmask sys_rt_sigprocmask
176 common rt_sigpending sys_rt_sigpending
177 common rt_sigtimedwait sys_rt_sigtimedwait
177 common rt_sigtimedwait sys_rt_sigtimedwait_time32
178 common rt_sigqueueinfo sys_rt_sigqueueinfo
179 common rt_sigsuspend sys_rt_sigsuspend
180 common pread64 sys_pread64 sys_oabi_pread64
Expand Down Expand Up @@ -254,12 +254,12 @@
237 common fremovexattr sys_fremovexattr
238 common tkill sys_tkill
239 common sendfile64 sys_sendfile64
240 common futex sys_futex
240 common futex sys_futex_time32
241 common sched_setaffinity sys_sched_setaffinity
242 common sched_getaffinity sys_sched_getaffinity
243 common io_setup sys_io_setup
244 common io_destroy sys_io_destroy
245 common io_getevents sys_io_getevents
245 common io_getevents sys_io_getevents_time32
246 common io_submit sys_io_submit
247 common io_cancel sys_io_cancel
248 common exit_group sys_exit_group
Expand All @@ -272,26 +272,26 @@
# 255 for get_thread_area
256 common set_tid_address sys_set_tid_address
257 common timer_create sys_timer_create
258 common timer_settime sys_timer_settime
259 common timer_gettime sys_timer_gettime
258 common timer_settime sys_timer_settime32
259 common timer_gettime sys_timer_gettime32
260 common timer_getoverrun sys_timer_getoverrun
261 common timer_delete sys_timer_delete
262 common clock_settime sys_clock_settime
263 common clock_gettime sys_clock_gettime
264 common clock_getres sys_clock_getres
265 common clock_nanosleep sys_clock_nanosleep
262 common clock_settime sys_clock_settime32
263 common clock_gettime sys_clock_gettime32
264 common clock_getres sys_clock_getres_time32
265 common clock_nanosleep sys_clock_nanosleep_time32
266 common statfs64 sys_statfs64_wrapper
267 common fstatfs64 sys_fstatfs64_wrapper
268 common tgkill sys_tgkill
269 common utimes sys_utimes
269 common utimes sys_utimes_time32
270 common arm_fadvise64_64 sys_arm_fadvise64_64
271 common pciconfig_iobase sys_pciconfig_iobase
272 common pciconfig_read sys_pciconfig_read
273 common pciconfig_write sys_pciconfig_write
274 common mq_open sys_mq_open
275 common mq_unlink sys_mq_unlink
276 common mq_timedsend sys_mq_timedsend
277 common mq_timedreceive sys_mq_timedreceive
276 common mq_timedsend sys_mq_timedsend_time32
277 common mq_timedreceive sys_mq_timedreceive_time32
278 common mq_notify sys_mq_notify
279 common mq_getsetattr sys_mq_getsetattr
280 common waitid sys_waitid
Expand Down Expand Up @@ -326,7 +326,7 @@
309 common add_key sys_add_key
310 common request_key sys_request_key
311 common keyctl sys_keyctl
312 common semtimedop sys_semtimedop sys_oabi_semtimedop
312 common semtimedop sys_semtimedop_time32 sys_oabi_semtimedop
313 common vserver
314 common ioprio_set sys_ioprio_set
315 common ioprio_get sys_ioprio_get
Expand All @@ -340,7 +340,7 @@
323 common mkdirat sys_mkdirat
324 common mknodat sys_mknodat
325 common fchownat sys_fchownat
326 common futimesat sys_futimesat
326 common futimesat sys_futimesat_time32
327 common fstatat64 sys_fstatat64 sys_oabi_fstatat64
328 common unlinkat sys_unlinkat
329 common renameat sys_renameat
Expand All @@ -349,8 +349,8 @@
332 common readlinkat sys_readlinkat
333 common fchmodat sys_fchmodat
334 common faccessat sys_faccessat
335 common pselect6 sys_pselect6
336 common ppoll sys_ppoll
335 common pselect6 sys_pselect6_time32
336 common ppoll sys_ppoll_time32
337 common unshare sys_unshare
338 common set_robust_list sys_set_robust_list
339 common get_robust_list sys_get_robust_list
Expand All @@ -362,13 +362,13 @@
345 common getcpu sys_getcpu
346 common epoll_pwait sys_epoll_pwait
347 common kexec_load sys_kexec_load
348 common utimensat sys_utimensat
348 common utimensat sys_utimensat_time32
349 common signalfd sys_signalfd
350 common timerfd_create sys_timerfd_create
351 common eventfd sys_eventfd
352 common fallocate sys_fallocate
353 common timerfd_settime sys_timerfd_settime
354 common timerfd_gettime sys_timerfd_gettime
353 common timerfd_settime sys_timerfd_settime32
354 common timerfd_gettime sys_timerfd_gettime32
355 common signalfd4 sys_signalfd4
356 common eventfd2 sys_eventfd2
357 common epoll_create1 sys_epoll_create1
Expand All @@ -379,14 +379,14 @@
362 common pwritev sys_pwritev
363 common rt_tgsigqueueinfo sys_rt_tgsigqueueinfo
364 common perf_event_open sys_perf_event_open
365 common recvmmsg sys_recvmmsg
365 common recvmmsg sys_recvmmsg_time32
366 common accept4 sys_accept4
367 common fanotify_init sys_fanotify_init
368 common fanotify_mark sys_fanotify_mark
369 common prlimit64 sys_prlimit64
370 common name_to_handle_at sys_name_to_handle_at
371 common open_by_handle_at sys_open_by_handle_at
372 common clock_adjtime sys_clock_adjtime
372 common clock_adjtime sys_clock_adjtime32
373 common syncfs sys_syncfs
374 common sendmmsg sys_sendmmsg
375 common setns sys_setns
Expand All @@ -413,6 +413,27 @@
396 common pkey_free sys_pkey_free
397 common statx sys_statx
398 common rseq sys_rseq
399 common io_pgetevents sys_io_pgetevents
399 common io_pgetevents sys_io_pgetevents_time32
400 common migrate_pages sys_migrate_pages
401 common kexec_file_load sys_kexec_file_load
# 402 is unused
403 common clock_gettime64 sys_clock_gettime
404 common clock_settime64 sys_clock_settime
405 common clock_adjtime64 sys_clock_adjtime
406 common clock_getres_time64 sys_clock_getres
407 common clock_nanosleep_time64 sys_clock_nanosleep
408 common timer_gettime64 sys_timer_gettime
409 common timer_settime64 sys_timer_settime
410 common timerfd_gettime64 sys_timerfd_gettime
411 common timerfd_settime64 sys_timerfd_settime
412 common utimensat_time64 sys_utimensat
413 common pselect6_time64 sys_pselect6
414 common ppoll_time64 sys_ppoll
416 common io_pgetevents_time64 sys_io_pgetevents
417 common recvmmsg_time64 sys_recvmmsg
418 common mq_timedsend_time64 sys_mq_timedsend
419 common mq_timedreceive_time64 sys_mq_timedreceive
420 common semtimedop_time64 sys_semtimedop
421 common rt_sigtimedwait_time64 sys_rt_sigtimedwait
422 common futex_time64 sys_futex
423 common sched_rr_get_interval_time64 sys_sched_rr_get_interval
2 changes: 1 addition & 1 deletion arch/arm64/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)
#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800)

#define __NR_compat_syscalls 402
#define __NR_compat_syscalls 424
#endif

#define __ARCH_WANT_SYS_CLONE
Expand Down
Loading

0 comments on commit 41ea391

Please sign in to comment.