Skip to content

Commit 0190997

Browse files
deepa-hubarndb
authored andcommitted
time: Change nanosleep to safe __kernel_* types
Change over clock_nanosleep syscalls to use y2038 safe __kernel_timespec times. This will enable changing over of these syscalls to use new y2038 safe syscalls when the architectures define the CONFIG_64BIT_TIME. Note that nanosleep syscall is deprecated and does not have a plan for making it y2038 safe. But, the syscall should work as before on 64 bit machines and on 32 bit machines, the syscall works correctly until y2038 as before using the existing compat syscall version. There is no new syscall for supporting 64 bit time_t on 32 bit architectures. Cc: linux-api@vger.kernel.org Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 6d5b841 commit 0190997

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

include/linux/restart_block.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/compiler.h>
99
#include <linux/types.h>
10+
#include <linux/time64.h>
1011

1112
struct timespec;
1213
struct compat_timespec;
@@ -15,9 +16,7 @@ struct pollfd;
1516
enum timespec_type {
1617
TT_NONE = 0,
1718
TT_NATIVE = 1,
18-
#ifdef CONFIG_COMPAT
1919
TT_COMPAT = 2,
20-
#endif
2120
};
2221

2322
/*
@@ -40,10 +39,8 @@ struct restart_block {
4039
clockid_t clockid;
4140
enum timespec_type type;
4241
union {
43-
struct timespec __user *rmtp;
44-
#ifdef CONFIG_COMPAT
42+
struct __kernel_timespec __user *rmtp;
4543
struct compat_timespec __user *compat_rmtp;
46-
#endif
4744
};
4845
u64 expires;
4946
} nanosleep;

include/linux/syscalls.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
536536
size_t len);
537537

538538
/* kernel/hrtimer.c */
539-
asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp);
539+
asmlinkage long sys_nanosleep(struct __kernel_timespec __user *rqtp,
540+
struct __kernel_timespec __user *rmtp);
540541

541542
/* kernel/itimer.c */
542543
asmlinkage long sys_getitimer(int which, struct itimerval __user *value);
@@ -573,8 +574,8 @@ asmlinkage long sys_clock_gettime(clockid_t which_clock,
573574
asmlinkage long sys_clock_getres(clockid_t which_clock,
574575
struct __kernel_timespec __user *tp);
575576
asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
576-
const struct timespec __user *rqtp,
577-
struct timespec __user *rmtp);
577+
const struct __kernel_timespec __user *rqtp,
578+
struct __kernel_timespec __user *rmtp);
578579

579580
/* kernel/printk.c */
580581
asmlinkage long sys_syslog(int type, char __user *buf, int len);

kernel/time/hrtimer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,8 +1747,10 @@ long hrtimer_nanosleep(const struct timespec64 *rqtp,
17471747
return ret;
17481748
}
17491749

1750-
SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
1751-
struct timespec __user *, rmtp)
1750+
#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
1751+
1752+
SYSCALL_DEFINE2(nanosleep, struct __kernel_timespec __user *, rqtp,
1753+
struct __kernel_timespec __user *, rmtp)
17521754
{
17531755
struct timespec64 tu;
17541756

@@ -1763,6 +1765,8 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
17631765
return hrtimer_nanosleep(&tu, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
17641766
}
17651767

1768+
#endif
1769+
17661770
#ifdef CONFIG_COMPAT_32BIT_TIME
17671771

17681772
COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,

kernel/time/posix-stubs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct __kernel_time
126126
}
127127

128128
SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
129-
const struct timespec __user *, rqtp,
130-
struct timespec __user *, rmtp)
129+
const struct __kernel_timespec __user *, rqtp,
130+
struct __kernel_timespec __user *, rmtp)
131131
{
132132
struct timespec64 t;
133133

kernel/time/posix-timers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,8 +1212,8 @@ static int common_nsleep(const clockid_t which_clock, int flags,
12121212
}
12131213

12141214
SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
1215-
const struct timespec __user *, rqtp,
1216-
struct timespec __user *, rmtp)
1215+
const struct __kernel_timespec __user *, rqtp,
1216+
struct __kernel_timespec __user *, rmtp)
12171217
{
12181218
const struct k_clock *kc = clockid_to_kclock(which_clock);
12191219
struct timespec64 t;

0 commit comments

Comments
 (0)