Skip to content

Commit 22b17db

Browse files
committed
Merge tag 'y2038-drivers-for-v5.6-signed' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground
Pull y2038 updates from Arnd Bergmann: "Core, driver and file system changes These are updates to device drivers and file systems that for some reason or another were not included in the kernel in the previous y2038 series. I've gone through all users of time_t again to make sure the kernel is in a long-term maintainable state, replacing all remaining references to time_t with safe alternatives. Some related parts of the series were picked up into the nfsd, xfs, alsa and v4l2 trees. A final set of patches in linux-mm removes the now unused time_t/timeval/timespec types and helper functions after all five branches are merged for linux-5.6, ensuring that no new users get merged. As a result, linux-5.6, or my backport of the patches to 5.4 [1], should be the first release that can serve as a base for a 32-bit system designed to run beyond year 2038, with a few remaining caveats: - All user space must be compiled with a 64-bit time_t, which will be supported in the coming musl-1.2 and glibc-2.32 releases, along with installed kernel headers from linux-5.6 or higher. - Applications that use the system call interfaces directly need to be ported to use the time64 syscalls added in linux-5.1 in place of the existing system calls. This impacts most users of futex() and seccomp() as well as programming languages that have their own runtime environment not based on libc. - Applications that use a private copy of kernel uapi header files or their contents may need to update to the linux-5.6 version, in particular for sound/asound.h, xfs/xfs_fs.h, linux/input.h, linux/elfcore.h, linux/sockios.h, linux/timex.h and linux/can/bcm.h. - A few remaining interfaces cannot be changed to pass a 64-bit time_t in a compatible way, so they must be configured to use CLOCK_MONOTONIC times or (with a y2106 problem) unsigned 32-bit timestamps. Most importantly this impacts all users of 'struct input_event'. - All y2038 problems that are present on 64-bit machines also apply to 32-bit machines. In particular this affects file systems with on-disk timestamps using signed 32-bit seconds: ext4 with ext3-style small inodes, ext2, xfs (to be fixed soon) and ufs" [1] https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=y2038-endgame * tag 'y2038-drivers-for-v5.6-signed' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground: (21 commits) Revert "drm/etnaviv: reject timeouts with tv_nsec >= NSEC_PER_SEC" y2038: sh: remove timeval/timespec usage from headers y2038: sparc: remove use of struct timex y2038: rename itimerval to __kernel_old_itimerval y2038: remove obsolete jiffies conversion functions nfs: fscache: use timespec64 in inode auxdata nfs: fix timstamp debug prints nfs: use time64_t internally sunrpc: convert to time64_t for expiry drm/etnaviv: avoid deprecated timespec drm/etnaviv: reject timeouts with tv_nsec >= NSEC_PER_SEC drm/msm: avoid using 'timespec' hfs/hfsplus: use 64-bit inode timestamps hostfs: pass 64-bit timestamps to/from user space packet: clarify timestamp overflow tsacct: add 64-bit btime field acct: stop using get_seconds() um: ubd: use 64-bit time_t where possible xtensa: ISS: avoid struct timeval dlm: use SO_SNDTIMEO_NEW instead of SO_SNDTIMEO_OLD ...
2 parents a4fe2b4 + c4e7121 commit 22b17db

Some content is hidden

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

49 files changed

+283
-266
lines changed

arch/sh/include/uapi/asm/sockios.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define SIOCSPGRP _IOW('s', 8, pid_t)
1111
#define SIOCGPGRP _IOR('s', 9, pid_t)
1212

13-
#define SIOCGSTAMP_OLD _IOR('s', 100, struct timeval) /* Get stamp (timeval) */
14-
#define SIOCGSTAMPNS_OLD _IOR('s', 101, struct timespec) /* Get stamp (timespec) */
13+
#define SIOCGSTAMP_OLD _IOR('s', 100, struct __kernel_old_timeval) /* Get stamp (timeval) */
14+
#define SIOCGSTAMPNS_OLD _IOR('s', 101, struct __kernel_old_timespec) /* Get stamp (timespec) */
1515

1616
#endif /* __ASM_SH_SOCKIOS_H */

arch/sparc/kernel/sys_sparc_64.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -548,34 +548,35 @@ SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len)
548548
return err;
549549
}
550550

551-
SYSCALL_DEFINE1(sparc_adjtimex, struct timex __user *, txc_p)
551+
SYSCALL_DEFINE1(sparc_adjtimex, struct __kernel_timex __user *, txc_p)
552552
{
553-
struct timex txc; /* Local copy of parameter */
554-
struct __kernel_timex *kt = (void *)&txc;
553+
struct __kernel_timex txc;
554+
struct __kernel_old_timeval *tv = (void *)&txc_p->time;
555555
int ret;
556556

557557
/* Copy the user data space into the kernel copy
558558
* structure. But bear in mind that the structures
559559
* may change
560560
*/
561-
if (copy_from_user(&txc, txc_p, sizeof(struct timex)))
561+
if (copy_from_user(&txc, txc_p, sizeof(txc)))
562562
return -EFAULT;
563563

564564
/*
565565
* override for sparc64 specific timeval type: tv_usec
566566
* is 32 bit wide instead of 64-bit in __kernel_timex
567567
*/
568-
kt->time.tv_usec = txc.time.tv_usec;
569-
ret = do_adjtimex(kt);
570-
txc.time.tv_usec = kt->time.tv_usec;
568+
txc.time.tv_usec = tv->tv_usec;
569+
ret = do_adjtimex(&txc);
570+
tv->tv_usec = txc.time.tv_usec;
571571

572-
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
572+
return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret;
573573
}
574574

575-
SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex __user *, txc_p)
575+
SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,
576+
struct __kernel_timex __user *, txc_p)
576577
{
577-
struct timex txc; /* Local copy of parameter */
578-
struct __kernel_timex *kt = (void *)&txc;
578+
struct __kernel_timex txc;
579+
struct __kernel_old_timeval *tv = (void *)&txc_p->time;
579580
int ret;
580581

581582
if (!IS_ENABLED(CONFIG_POSIX_TIMERS)) {
@@ -590,18 +591,18 @@ SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex _
590591
* structure. But bear in mind that the structures
591592
* may change
592593
*/
593-
if (copy_from_user(&txc, txc_p, sizeof(struct timex)))
594+
if (copy_from_user(&txc, txc_p, sizeof(txc)))
594595
return -EFAULT;
595596

596597
/*
597598
* override for sparc64 specific timeval type: tv_usec
598599
* is 32 bit wide instead of 64-bit in __kernel_timex
599600
*/
600-
kt->time.tv_usec = txc.time.tv_usec;
601-
ret = do_clock_adjtime(which_clock, kt);
602-
txc.time.tv_usec = kt->time.tv_usec;
601+
txc.time.tv_usec = tv->tv_usec;
602+
ret = do_clock_adjtime(which_clock, &txc);
603+
tv->tv_usec = txc.time.tv_usec;
603604

604-
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
605+
return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret;
605606
}
606607

607608
SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,

arch/um/drivers/cow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern int init_cow_file(int fd, char *cow_file, char *backing_file,
1111
extern int file_reader(__u64 offset, char *buf, int len, void *arg);
1212
extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
1313
void *arg, __u32 *version_out,
14-
char **backing_file_out, time_t *mtime_out,
14+
char **backing_file_out, long long *mtime_out,
1515
unsigned long long *size_out, int *sectorsize_out,
1616
__u32 *align_out, int *bitmap_offset_out);
1717

arch/um/drivers/cow_user.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#define PATH_LEN_V1 256
1919

20+
/* unsigned time_t works until year 2106 */
2021
typedef __u32 time32_t;
2122

2223
struct cow_header_v1 {
@@ -197,7 +198,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
197198
int sectorsize, int alignment, unsigned long long *size)
198199
{
199200
struct cow_header_v3 *header;
200-
unsigned long modtime;
201+
long long modtime;
201202
int err;
202203

203204
err = cow_seek_file(fd, 0);
@@ -276,7 +277,7 @@ int file_reader(__u64 offset, char *buf, int len, void *arg)
276277

277278
int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
278279
__u32 *version_out, char **backing_file_out,
279-
time_t *mtime_out, unsigned long long *size_out,
280+
long long *mtime_out, unsigned long long *size_out,
280281
int *sectorsize_out, __u32 *align_out,
281282
int *bitmap_offset_out)
282283
{
@@ -363,7 +364,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
363364

364365
/*
365366
* this was used until Dec2005 - 64bits are needed to represent
366-
* 2038+. I.e. we can safely do this truncating cast.
367+
* 2106+. I.e. we can safely do this truncating cast.
367368
*
368369
* Additionally, we must use be32toh() instead of be64toh(), since
369370
* the program used to use the former (tested - I got mtime

arch/um/drivers/ubd_kern.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
561561
__u32 version;
562562
__u32 align;
563563
char *backing_file;
564-
time_t mtime;
564+
time64_t mtime;
565565
unsigned long long size;
566566
int sector_size;
567567
int bitmap_offset;
@@ -600,9 +600,9 @@ static int read_cow_bitmap(int fd, void *buf, int offset, int len)
600600
return 0;
601601
}
602602

603-
static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
603+
static int backing_file_mismatch(char *file, __u64 size, time64_t mtime)
604604
{
605-
unsigned long modtime;
605+
time64_t modtime;
606606
unsigned long long actual;
607607
int err;
608608

@@ -628,7 +628,7 @@ static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
628628
return -EINVAL;
629629
}
630630
if (modtime != mtime) {
631-
printk(KERN_ERR "mtime mismatch (%ld vs %ld) of COW header vs "
631+
printk(KERN_ERR "mtime mismatch (%lld vs %lld) of COW header vs "
632632
"backing file\n", mtime, modtime);
633633
return -EINVAL;
634634
}
@@ -671,7 +671,7 @@ static int open_ubd_file(char *file, struct openflags *openflags, int shared,
671671
unsigned long *bitmap_len_out, int *data_offset_out,
672672
int *create_cow_out)
673673
{
674-
time_t mtime;
674+
time64_t mtime;
675675
unsigned long long size;
676676
__u32 version, align;
677677
char *backing_file;

arch/um/include/shared/os.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ extern int os_sync_file(int fd);
150150
extern int os_file_size(const char *file, unsigned long long *size_out);
151151
extern int os_pread_file(int fd, void *buf, int len, unsigned long long offset);
152152
extern int os_pwrite_file(int fd, const void *buf, int count, unsigned long long offset);
153-
extern int os_file_modtime(const char *file, unsigned long *modtime);
153+
extern int os_file_modtime(const char *file, long long *modtime);
154154
extern int os_pipe(int *fd, int stream, int close_on_exec);
155155
extern int os_set_fd_async(int fd);
156156
extern int os_clear_fd_async(int fd);

arch/um/os-Linux/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ int os_file_size(const char *file, unsigned long long *size_out)
341341
return 0;
342342
}
343343

344-
int os_file_modtime(const char *file, unsigned long *modtime)
344+
int os_file_modtime(const char *file, long long *modtime)
345345
{
346346
struct uml_stat buf;
347347
int err;

arch/xtensa/platforms/iss/include/platform/simcall.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ static inline int simc_write(int fd, const void *buf, size_t count)
113113

114114
static inline int simc_poll(int fd)
115115
{
116-
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
116+
long timeval[2] = { 0, 0 };
117117

118-
return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&tv);
118+
return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&timeval);
119119
}
120120

121121
static inline int simc_lseek(int fd, uint32_t off, int whence)

drivers/gpu/drm/etnaviv/etnaviv_drv.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,6 @@ static int etnaviv_ioctl_gem_new(struct drm_device *dev, void *data,
282282
args->flags, &args->handle);
283283
}
284284

285-
#define TS(t) ((struct timespec){ \
286-
.tv_sec = (t).tv_sec, \
287-
.tv_nsec = (t).tv_nsec \
288-
})
289-
290285
static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
291286
struct drm_file *file)
292287
{
@@ -301,7 +296,7 @@ static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
301296
if (!obj)
302297
return -ENOENT;
303298

304-
ret = etnaviv_gem_cpu_prep(obj, args->op, &TS(args->timeout));
299+
ret = etnaviv_gem_cpu_prep(obj, args->op, &args->timeout);
305300

306301
drm_gem_object_put_unlocked(obj);
307302

@@ -354,7 +349,7 @@ static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data,
354349
{
355350
struct drm_etnaviv_wait_fence *args = data;
356351
struct etnaviv_drm_private *priv = dev->dev_private;
357-
struct timespec *timeout = &TS(args->timeout);
352+
struct drm_etnaviv_timespec *timeout = &args->timeout;
358353
struct etnaviv_gpu *gpu;
359354

360355
if (args->flags & ~(ETNA_WAIT_NONBLOCK))
@@ -403,7 +398,7 @@ static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data,
403398
{
404399
struct etnaviv_drm_private *priv = dev->dev_private;
405400
struct drm_etnaviv_gem_wait *args = data;
406-
struct timespec *timeout = &TS(args->timeout);
401+
struct drm_etnaviv_timespec *timeout = &args->timeout;
407402
struct drm_gem_object *obj;
408403
struct etnaviv_gpu *gpu;
409404
int ret;

drivers/gpu/drm/etnaviv/etnaviv_drv.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
6161
void etnaviv_gem_prime_unpin(struct drm_gem_object *obj);
6262
void *etnaviv_gem_vmap(struct drm_gem_object *obj);
6363
int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
64-
struct timespec *timeout);
64+
struct drm_etnaviv_timespec *timeout);
6565
int etnaviv_gem_cpu_fini(struct drm_gem_object *obj);
6666
void etnaviv_gem_free_object(struct drm_gem_object *obj);
6767
int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
@@ -107,11 +107,12 @@ static inline size_t size_vstruct(size_t nelem, size_t elem_size, size_t base)
107107
* between the specified timeout and the current CLOCK_MONOTONIC time.
108108
*/
109109
static inline unsigned long etnaviv_timeout_to_jiffies(
110-
const struct timespec *timeout)
110+
const struct drm_etnaviv_timespec *timeout)
111111
{
112-
struct timespec64 ts, to;
113-
114-
to = timespec_to_timespec64(*timeout);
112+
struct timespec64 ts, to = {
113+
.tv_sec = timeout->tv_sec,
114+
.tv_nsec = timeout->tv_nsec,
115+
};
115116

116117
ktime_get_ts64(&ts);
117118

0 commit comments

Comments
 (0)