Skip to content

Commit b5793b0

Browse files
deepa-hubarndb
authored andcommitted
posix-timers: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME
clock_gettime, clock_settime, clock_getres and clock_nanosleep compat syscalls are also repurposed to provide backward compatibility to support 32 bit time_t on 32 bit systems. Note that nanosleep compat syscall will also be treated the same way as the above syscalls as it shares common handler functions with clock_nanosleep. But, there is no plan to provide y2038 safe solution for nanosleep. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 17435e5 commit b5793b0

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

kernel/time/hrtimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
17631763
return hrtimer_nanosleep(&tu, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
17641764
}
17651765

1766-
#ifdef CONFIG_COMPAT
1766+
#ifdef CONFIG_COMPAT_32BIT_TIME
17671767

17681768
COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
17691769
struct compat_timespec __user *, rmtp)

kernel/time/posix-stubs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ COMPAT_SYS_NI(timer_settime);
160160
COMPAT_SYS_NI(timer_gettime);
161161
COMPAT_SYS_NI(getitimer);
162162
COMPAT_SYS_NI(setitimer);
163+
#endif
163164

165+
#ifdef CONFIG_COMPAT_32BIT_TIME
164166
COMPAT_SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
165167
struct compat_timespec __user *, tp)
166168
{

kernel/time/posix-timers.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
11141114
return error;
11151115
}
11161116

1117-
#ifdef CONFIG_COMPAT
1117+
#ifdef CONFIG_COMPAT_32BIT_TIME
11181118

11191119
COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
11201120
struct compat_timespec __user *, tp)
@@ -1149,6 +1149,10 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
11491149
return err;
11501150
}
11511151

1152+
#endif
1153+
1154+
#ifdef CONFIG_COMPAT
1155+
11521156
COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
11531157
struct compat_timex __user *, utp)
11541158
{
@@ -1173,6 +1177,10 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
11731177
return err;
11741178
}
11751179

1180+
#endif
1181+
1182+
#ifdef CONFIG_COMPAT_32BIT_TIME
1183+
11761184
COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
11771185
struct compat_timespec __user *, tp)
11781186
{
@@ -1228,7 +1236,8 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
12281236
return kc->nsleep(which_clock, flags, &t);
12291237
}
12301238

1231-
#ifdef CONFIG_COMPAT
1239+
#ifdef CONFIG_COMPAT_32BIT_TIME
1240+
12321241
COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
12331242
struct compat_timespec __user *, rqtp,
12341243
struct compat_timespec __user *, rmtp)
@@ -1253,6 +1262,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
12531262

12541263
return kc->nsleep(which_clock, flags, &t);
12551264
}
1265+
12561266
#endif
12571267

12581268
static const struct k_clock clock_realtime = {

0 commit comments

Comments
 (0)