Skip to content

Commit ee16c8f

Browse files
arndbintel-lab-lkp
authored andcommitted
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>
1 parent cceb218 commit ee16c8f

File tree

36 files changed

+237
-245
lines changed

36 files changed

+237
-245
lines changed

arch/arm64/include/asm/compat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ struct compat_stat {
8686
compat_off_t st_size;
8787
compat_off_t st_blksize;
8888
compat_off_t st_blocks;
89-
compat_time_t st_atime;
89+
old_time32_t st_atime;
9090
compat_ulong_t st_atime_nsec;
91-
compat_time_t st_mtime;
91+
old_time32_t st_mtime;
9292
compat_ulong_t st_mtime_nsec;
93-
compat_time_t st_ctime;
93+
old_time32_t st_ctime;
9494
compat_ulong_t st_ctime_nsec;
9595
compat_ulong_t __unused4[2];
9696
};

arch/arm64/include/asm/stat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#ifdef CONFIG_COMPAT
2222

23-
#include <linux/compat_time.h>
23+
#include <linux/time.h>
2424
#include <asm/compat.h>
2525

2626
/*

arch/mips/include/asm/compat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ struct compat_stat {
5959
s32 st_pad2[2];
6060
compat_off_t st_size;
6161
s32 st_pad3;
62-
compat_time_t st_atime;
62+
old_time32_t st_atime;
6363
s32 st_atime_nsec;
64-
compat_time_t st_mtime;
64+
old_time32_t st_mtime;
6565
s32 st_mtime_nsec;
66-
compat_time_t st_ctime;
66+
old_time32_t st_ctime;
6767
s32 st_ctime_nsec;
6868
s32 st_blksize;
6969
s32 st_blocks;

arch/mips/kernel/binfmt_elfn32.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ struct elf_prstatus32
5454
pid_t pr_ppid;
5555
pid_t pr_pgrp;
5656
pid_t pr_sid;
57-
struct compat_timeval pr_utime; /* User time */
58-
struct compat_timeval pr_stime; /* System time */
59-
struct compat_timeval pr_cutime;/* Cumulative user time */
60-
struct compat_timeval pr_cstime;/* Cumulative system time */
57+
struct old_timeval32 pr_utime; /* User time */
58+
struct old_timeval32 pr_stime; /* System time */
59+
struct old_timeval32 pr_cutime;/* Cumulative user time */
60+
struct old_timeval32 pr_cstime;/* Cumulative system time */
6161
elf_gregset_t pr_reg; /* GP registers */
6262
int pr_fpvalid; /* True if math co-processor being used. */
6363
};
@@ -81,9 +81,9 @@ struct elf_prpsinfo32
8181
#define elf_caddr_t u32
8282
#define init_elf_binfmt init_elfn32_binfmt
8383

84-
#define jiffies_to_timeval jiffies_to_compat_timeval
84+
#define jiffies_to_timeval jiffies_to_old_timeval32
8585
static __inline__ void
86-
jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
86+
jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value)
8787
{
8888
/*
8989
* Convert jiffies to nanoseconds and separate with
@@ -101,6 +101,6 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
101101
#define TASK_SIZE TASK_SIZE32
102102

103103
#undef ns_to_timeval
104-
#define ns_to_timeval ns_to_compat_timeval
104+
#define ns_to_timeval ns_to_old_timeval32
105105

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

arch/mips/kernel/binfmt_elfo32.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ struct elf_prstatus32
5959
pid_t pr_ppid;
6060
pid_t pr_pgrp;
6161
pid_t pr_sid;
62-
struct compat_timeval pr_utime; /* User time */
63-
struct compat_timeval pr_stime; /* System time */
64-
struct compat_timeval pr_cutime;/* Cumulative user time */
65-
struct compat_timeval pr_cstime;/* Cumulative system time */
62+
struct old_timeval32 pr_utime; /* User time */
63+
struct old_timeval32 pr_stime; /* System time */
64+
struct old_timeval32 pr_cutime;/* Cumulative user time */
65+
struct old_timeval32 pr_cstime;/* Cumulative system time */
6666
elf_gregset_t pr_reg; /* GP registers */
6767
int pr_fpvalid; /* True if math co-processor being used. */
6868
};
@@ -86,9 +86,9 @@ struct elf_prpsinfo32
8686
#define elf_caddr_t u32
8787
#define init_elf_binfmt init_elf32_binfmt
8888

89-
#define jiffies_to_timeval jiffies_to_compat_timeval
89+
#define jiffies_to_timeval jiffies_to_old_timeval32
9090
static inline void
91-
jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
91+
jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value)
9292
{
9393
/*
9494
* Convert jiffies to nanoseconds and separate with
@@ -104,6 +104,6 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
104104
#define TASK_SIZE TASK_SIZE32
105105

106106
#undef ns_to_timeval
107-
#define ns_to_timeval ns_to_compat_timeval
107+
#define ns_to_timeval ns_to_old_timeval32
108108

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

arch/parisc/include/asm/compat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ struct compat_stat {
4848
u16 st_reserved2; /* old st_gid */
4949
compat_dev_t st_rdev;
5050
compat_off_t st_size;
51-
compat_time_t st_atime;
51+
old_time32_t st_atime;
5252
u32 st_atime_nsec;
53-
compat_time_t st_mtime;
53+
old_time32_t st_mtime;
5454
u32 st_mtime_nsec;
55-
compat_time_t st_ctime;
55+
old_time32_t st_ctime;
5656
u32 st_ctime_nsec;
5757
s32 st_blksize;
5858
s32 st_blocks;

arch/powerpc/include/asm/compat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ struct compat_stat {
5555
compat_off_t st_size;
5656
compat_off_t st_blksize;
5757
compat_off_t st_blocks;
58-
compat_time_t st_atime;
58+
old_time32_t st_atime;
5959
u32 st_atime_nsec;
60-
compat_time_t st_mtime;
60+
old_time32_t st_mtime;
6161
u32 st_mtime_nsec;
62-
compat_time_t st_ctime;
62+
old_time32_t st_ctime;
6363
u32 st_ctime_nsec;
6464
u32 __unused4[2];
6565
};

arch/powerpc/kernel/asm-offsets.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,12 @@ int main(void)
387387
OFFSET(CFG_SYSCALL_MAP64, vdso_data, syscall_map_64);
388388
OFFSET(TVAL64_TV_SEC, timeval, tv_sec);
389389
OFFSET(TVAL64_TV_USEC, timeval, tv_usec);
390-
OFFSET(TVAL32_TV_SEC, compat_timeval, tv_sec);
391-
OFFSET(TVAL32_TV_USEC, compat_timeval, tv_usec);
390+
OFFSET(TVAL32_TV_SEC, old_timeval32, tv_sec);
391+
OFFSET(TVAL32_TV_USEC, old_timeval32, tv_usec);
392392
OFFSET(TSPC64_TV_SEC, timespec, tv_sec);
393393
OFFSET(TSPC64_TV_NSEC, timespec, tv_nsec);
394-
OFFSET(TSPC32_TV_SEC, compat_timespec, tv_sec);
395-
OFFSET(TSPC32_TV_NSEC, compat_timespec, tv_nsec);
394+
OFFSET(TSPC32_TV_SEC, old_timespec32, tv_sec);
395+
OFFSET(TSPC32_TV_NSEC, old_timespec32, tv_nsec);
396396
#else
397397
OFFSET(TVAL32_TV_SEC, timeval, tv_sec);
398398
OFFSET(TVAL32_TV_USEC, timeval, tv_usec);

arch/powerpc/oprofile/backtrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* 2 of the License, or (at your option) any later version.
88
**/
99

10-
#include <linux/compat_time.h>
10+
#include <linux/time.h>
1111
#include <linux/oprofile.h>
1212
#include <linux/sched.h>
1313
#include <asm/processor.h>

arch/sparc/include/asm/compat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ struct compat_stat {
4747
__compat_gid_t st_gid;
4848
compat_dev_t st_rdev;
4949
compat_off_t st_size;
50-
compat_time_t st_atime;
50+
old_time32_t st_atime;
5151
compat_ulong_t st_atime_nsec;
52-
compat_time_t st_mtime;
52+
old_time32_t st_mtime;
5353
compat_ulong_t st_mtime_nsec;
54-
compat_time_t st_ctime;
54+
old_time32_t st_ctime;
5555
compat_ulong_t st_ctime_nsec;
5656
compat_off_t st_blksize;
5757
compat_off_t st_blocks;

fs/aio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,12 +2135,12 @@ COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id,
21352135
compat_long_t, min_nr,
21362136
compat_long_t, nr,
21372137
struct io_event __user *, events,
2138-
struct compat_timespec __user *, timeout)
2138+
struct old_timespec32 __user *, timeout)
21392139
{
21402140
struct timespec64 t;
21412141
int ret;
21422142

2143-
if (timeout && compat_get_timespec64(&t, timeout))
2143+
if (timeout && get_old_timespec32(&t, timeout))
21442144
return -EFAULT;
21452145

21462146
ret = do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &t : NULL);
@@ -2160,15 +2160,15 @@ COMPAT_SYSCALL_DEFINE6(io_pgetevents,
21602160
compat_long_t, min_nr,
21612161
compat_long_t, nr,
21622162
struct io_event __user *, events,
2163-
struct compat_timespec __user *, timeout,
2163+
struct old_timespec32 __user *, timeout,
21642164
const struct __compat_aio_sigset __user *, usig)
21652165
{
21662166
struct __compat_aio_sigset ksig = { NULL, };
21672167
sigset_t ksigmask, sigsaved;
21682168
struct timespec64 t;
21692169
int ret;
21702170

2171-
if (timeout && compat_get_timespec64(&t, timeout))
2171+
if (timeout && get_old_timespec32(&t, timeout))
21722172
return -EFAULT;
21732173

21742174
if (usig && copy_from_user(&ksig, usig, sizeof(ksig)))

fs/compat_binfmt_elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#define elf_prpsinfo compat_elf_prpsinfo
5353

5454
#undef ns_to_timeval
55-
#define ns_to_timeval ns_to_compat_timeval
55+
#define ns_to_timeval ns_to_old_timeval32
5656

5757
/*
5858
* To use this file, asm/elf.h must define compat_elf_check_arch.

fs/select.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,15 +1120,15 @@ int compat_poll_select_copy_remaining(struct timespec64 *end_time, void __user *
11201120
ts.tv_sec = ts.tv_nsec = 0;
11211121

11221122
if (timeval) {
1123-
struct compat_timeval rtv;
1123+
struct old_timeval32 rtv;
11241124

11251125
rtv.tv_sec = ts.tv_sec;
11261126
rtv.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
11271127

11281128
if (!copy_to_user(p, &rtv, sizeof(rtv)))
11291129
return ret;
11301130
} else {
1131-
if (!compat_put_timespec64(&ts, p))
1131+
if (!put_old_timespec32(&ts, p))
11321132
return ret;
11331133
}
11341134
/*
@@ -1257,10 +1257,10 @@ static int compat_core_sys_select(int n, compat_ulong_t __user *inp,
12571257

12581258
static int do_compat_select(int n, compat_ulong_t __user *inp,
12591259
compat_ulong_t __user *outp, compat_ulong_t __user *exp,
1260-
struct compat_timeval __user *tvp)
1260+
struct old_timeval32 __user *tvp)
12611261
{
12621262
struct timespec64 end_time, *to = NULL;
1263-
struct compat_timeval tv;
1263+
struct old_timeval32 tv;
12641264
int ret;
12651265

12661266
if (tvp) {
@@ -1282,7 +1282,7 @@ static int do_compat_select(int n, compat_ulong_t __user *inp,
12821282

12831283
COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp,
12841284
compat_ulong_t __user *, outp, compat_ulong_t __user *, exp,
1285-
struct compat_timeval __user *, tvp)
1285+
struct old_timeval32 __user *, tvp)
12861286
{
12871287
return do_compat_select(n, inp, outp, exp, tvp);
12881288
}
@@ -1307,15 +1307,15 @@ COMPAT_SYSCALL_DEFINE1(old_select, struct compat_sel_arg_struct __user *, arg)
13071307

13081308
static long do_compat_pselect(int n, compat_ulong_t __user *inp,
13091309
compat_ulong_t __user *outp, compat_ulong_t __user *exp,
1310-
struct compat_timespec __user *tsp, compat_sigset_t __user *sigmask,
1310+
struct old_timespec32 __user *tsp, compat_sigset_t __user *sigmask,
13111311
compat_size_t sigsetsize)
13121312
{
13131313
sigset_t ksigmask, sigsaved;
13141314
struct timespec64 ts, end_time, *to = NULL;
13151315
int ret;
13161316

13171317
if (tsp) {
1318-
if (compat_get_timespec64(&ts, tsp))
1318+
if (get_old_timespec32(&ts, tsp))
13191319
return -EFAULT;
13201320

13211321
to = &end_time;
@@ -1355,7 +1355,7 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp,
13551355

13561356
COMPAT_SYSCALL_DEFINE6(pselect6, int, n, compat_ulong_t __user *, inp,
13571357
compat_ulong_t __user *, outp, compat_ulong_t __user *, exp,
1358-
struct compat_timespec __user *, tsp, void __user *, sig)
1358+
struct old_timespec32 __user *, tsp, void __user *, sig)
13591359
{
13601360
compat_size_t sigsetsize = 0;
13611361
compat_uptr_t up = 0;
@@ -1373,15 +1373,15 @@ COMPAT_SYSCALL_DEFINE6(pselect6, int, n, compat_ulong_t __user *, inp,
13731373
}
13741374

13751375
COMPAT_SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds,
1376-
unsigned int, nfds, struct compat_timespec __user *, tsp,
1376+
unsigned int, nfds, struct old_timespec32 __user *, tsp,
13771377
const compat_sigset_t __user *, sigmask, compat_size_t, sigsetsize)
13781378
{
13791379
sigset_t ksigmask, sigsaved;
13801380
struct timespec64 ts, end_time, *to = NULL;
13811381
int ret;
13821382

13831383
if (tsp) {
1384-
if (compat_get_timespec64(&ts, tsp))
1384+
if (get_old_timespec32(&ts, tsp))
13851385
return -EFAULT;
13861386

13871387
to = &end_time;

fs/timerfd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,29 +561,29 @@ SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct __kernel_itimerspec __user *,
561561

562562
#ifdef CONFIG_COMPAT_32BIT_TIME
563563
COMPAT_SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
564-
const struct compat_itimerspec __user *, utmr,
565-
struct compat_itimerspec __user *, otmr)
564+
const struct old_itimerspec32 __user *, utmr,
565+
struct old_itimerspec32 __user *, otmr)
566566
{
567567
struct itimerspec64 new, old;
568568
int ret;
569569

570-
if (get_compat_itimerspec64(&new, utmr))
570+
if (get_old_itimerspec32(&new, utmr))
571571
return -EFAULT;
572572
ret = do_timerfd_settime(ufd, flags, &new, &old);
573573
if (ret)
574574
return ret;
575-
if (otmr && put_compat_itimerspec64(&old, otmr))
575+
if (otmr && put_old_itimerspec32(&old, otmr))
576576
return -EFAULT;
577577
return ret;
578578
}
579579

580580
COMPAT_SYSCALL_DEFINE2(timerfd_gettime, int, ufd,
581-
struct compat_itimerspec __user *, otmr)
581+
struct old_itimerspec32 __user *, otmr)
582582
{
583583
struct itimerspec64 kotmr;
584584
int ret = do_timerfd_gettime(ufd, &kotmr);
585585
if (ret)
586586
return ret;
587-
return put_compat_itimerspec64(&kotmr, otmr) ? -EFAULT : 0;
587+
return put_old_itimerspec32(&kotmr, otmr) ? -EFAULT : 0;
588588
}
589589
#endif

fs/utimes.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
245245
return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0);
246246
}
247247

248-
COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags)
248+
COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct old_timespec32 __user *, t, int, flags)
249249
{
250250
struct timespec64 tv[2];
251251

252252
if (t) {
253-
if (compat_get_timespec64(&tv[0], &t[0]) ||
254-
compat_get_timespec64(&tv[1], &t[1]))
253+
if (get_old_timespec32(&tv[0], &t[0]) ||
254+
get_old_timespec32(&tv[1], &t[1]))
255255
return -EFAULT;
256256

257257
if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT)
@@ -261,7 +261,7 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filena
261261
}
262262

263263
static long do_compat_futimesat(unsigned int dfd, const char __user *filename,
264-
struct compat_timeval __user *t)
264+
struct old_timeval32 __user *t)
265265
{
266266
struct timespec64 tv[2];
267267

@@ -282,12 +282,12 @@ static long do_compat_futimesat(unsigned int dfd, const char __user *filename,
282282

283283
COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd,
284284
const char __user *, filename,
285-
struct compat_timeval __user *, t)
285+
struct old_timeval32 __user *, t)
286286
{
287287
return do_compat_futimesat(dfd, filename, t);
288288
}
289289

290-
COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct compat_timeval __user *, t)
290+
COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct old_timeval32 __user *, t)
291291
{
292292
return do_compat_futimesat(AT_FDCWD, filename, t);
293293
}

0 commit comments

Comments
 (0)