Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+283 -266
+2 -2
arch/sh/include/uapi/asm/sockios.h
··· 10 10 #define SIOCSPGRP _IOW('s', 8, pid_t) 11 11 #define SIOCGPGRP _IOR('s', 9, pid_t) 12 12 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) */ 15 15 16 16 #endif /* __ASM_SH_SOCKIOS_H */
+17 -16
arch/sparc/kernel/sys_sparc_64.c
··· 548 548 return err; 549 549 } 550 550 551 - SYSCALL_DEFINE1(sparc_adjtimex, struct timex __user *, txc_p) 551 + SYSCALL_DEFINE1(sparc_adjtimex, struct __kernel_timex __user *, txc_p) 552 552 { 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; 555 555 int ret; 556 556 557 557 /* Copy the user data space into the kernel copy 558 558 * structure. But bear in mind that the structures 559 559 * may change 560 560 */ 561 - if (copy_from_user(&txc, txc_p, sizeof(struct timex))) 561 + if (copy_from_user(&txc, txc_p, sizeof(txc))) 562 562 return -EFAULT; 563 563 564 564 /* 565 565 * override for sparc64 specific timeval type: tv_usec 566 566 * is 32 bit wide instead of 64-bit in __kernel_timex 567 567 */ 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; 571 571 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; 573 573 } 574 574 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) 576 577 { 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; 579 580 int ret; 580 581 581 582 if (!IS_ENABLED(CONFIG_POSIX_TIMERS)) { ··· 591 590 * structure. But bear in mind that the structures 592 591 * may change 593 592 */ 594 - if (copy_from_user(&txc, txc_p, sizeof(struct timex))) 593 + if (copy_from_user(&txc, txc_p, sizeof(txc))) 595 594 return -EFAULT; 596 595 597 596 /* 598 597 * override for sparc64 specific timeval type: tv_usec 599 598 * is 32 bit wide instead of 64-bit in __kernel_timex 600 599 */ 601 - kt->time.tv_usec = txc.time.tv_usec; 602 - ret = do_clock_adjtime(which_clock, kt); 603 - txc.time.tv_usec = kt->time.tv_usec; 600 + txc.time.tv_usec = tv->tv_usec; 601 + ret = do_clock_adjtime(which_clock, &txc); 602 + tv->tv_usec = txc.time.tv_usec; 604 603 605 - return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret; 604 + return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret; 606 605 } 607 606 608 607 SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,
+1 -1
arch/um/drivers/cow.h
··· 11 11 extern int file_reader(__u64 offset, char *buf, int len, void *arg); 12 12 extern int read_cow_header(int (*reader)(__u64, char *, int, void *), 13 13 void *arg, __u32 *version_out, 14 - char **backing_file_out, time_t *mtime_out, 14 + char **backing_file_out, long long *mtime_out, 15 15 unsigned long long *size_out, int *sectorsize_out, 16 16 __u32 *align_out, int *bitmap_offset_out); 17 17
+4 -3
arch/um/drivers/cow_user.c
··· 17 17 18 18 #define PATH_LEN_V1 256 19 19 20 + /* unsigned time_t works until year 2106 */ 20 21 typedef __u32 time32_t; 21 22 22 23 struct cow_header_v1 { ··· 198 197 int sectorsize, int alignment, unsigned long long *size) 199 198 { 200 199 struct cow_header_v3 *header; 201 - unsigned long modtime; 200 + long long modtime; 202 201 int err; 203 202 204 203 err = cow_seek_file(fd, 0); ··· 277 276 278 277 int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, 279 278 __u32 *version_out, char **backing_file_out, 280 - time_t *mtime_out, unsigned long long *size_out, 279 + long long *mtime_out, unsigned long long *size_out, 281 280 int *sectorsize_out, __u32 *align_out, 282 281 int *bitmap_offset_out) 283 282 { ··· 364 363 365 364 /* 366 365 * this was used until Dec2005 - 64bits are needed to represent 367 - * 2038+. I.e. we can safely do this truncating cast. 366 + * 2106+. I.e. we can safely do this truncating cast. 368 367 * 369 368 * Additionally, we must use be32toh() instead of be64toh(), since 370 369 * the program used to use the former (tested - I got mtime
+5 -5
arch/um/drivers/ubd_kern.c
··· 561 561 __u32 version; 562 562 __u32 align; 563 563 char *backing_file; 564 - time_t mtime; 564 + time64_t mtime; 565 565 unsigned long long size; 566 566 int sector_size; 567 567 int bitmap_offset; ··· 600 600 return 0; 601 601 } 602 602 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) 604 604 { 605 - unsigned long modtime; 605 + time64_t modtime; 606 606 unsigned long long actual; 607 607 int err; 608 608 ··· 628 628 return -EINVAL; 629 629 } 630 630 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 " 632 632 "backing file\n", mtime, modtime); 633 633 return -EINVAL; 634 634 } ··· 671 671 unsigned long *bitmap_len_out, int *data_offset_out, 672 672 int *create_cow_out) 673 673 { 674 - time_t mtime; 674 + time64_t mtime; 675 675 unsigned long long size; 676 676 __u32 version, align; 677 677 char *backing_file;
+1 -1
arch/um/include/shared/os.h
··· 150 150 extern int os_file_size(const char *file, unsigned long long *size_out); 151 151 extern int os_pread_file(int fd, void *buf, int len, unsigned long long offset); 152 152 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); 154 154 extern int os_pipe(int *fd, int stream, int close_on_exec); 155 155 extern int os_set_fd_async(int fd); 156 156 extern int os_clear_fd_async(int fd);
+1 -1
arch/um/os-Linux/file.c
··· 341 341 return 0; 342 342 } 343 343 344 - int os_file_modtime(const char *file, unsigned long *modtime) 344 + int os_file_modtime(const char *file, long long *modtime) 345 345 { 346 346 struct uml_stat buf; 347 347 int err;
+2 -2
arch/xtensa/platforms/iss/include/platform/simcall.h
··· 113 113 114 114 static inline int simc_poll(int fd) 115 115 { 116 - struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; 116 + long timeval[2] = { 0, 0 }; 117 117 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); 119 119 } 120 120 121 121 static inline int simc_lseek(int fd, uint32_t off, int whence)
+3 -8
drivers/gpu/drm/etnaviv/etnaviv_drv.c
··· 282 282 args->flags, &args->handle); 283 283 } 284 284 285 - #define TS(t) ((struct timespec){ \ 286 - .tv_sec = (t).tv_sec, \ 287 - .tv_nsec = (t).tv_nsec \ 288 - }) 289 - 290 285 static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data, 291 286 struct drm_file *file) 292 287 { ··· 296 301 if (!obj) 297 302 return -ENOENT; 298 303 299 - ret = etnaviv_gem_cpu_prep(obj, args->op, &TS(args->timeout)); 304 + ret = etnaviv_gem_cpu_prep(obj, args->op, &args->timeout); 300 305 301 306 drm_gem_object_put_unlocked(obj); 302 307 ··· 349 354 { 350 355 struct drm_etnaviv_wait_fence *args = data; 351 356 struct etnaviv_drm_private *priv = dev->dev_private; 352 - struct timespec *timeout = &TS(args->timeout); 357 + struct drm_etnaviv_timespec *timeout = &args->timeout; 353 358 struct etnaviv_gpu *gpu; 354 359 355 360 if (args->flags & ~(ETNA_WAIT_NONBLOCK)) ··· 398 403 { 399 404 struct etnaviv_drm_private *priv = dev->dev_private; 400 405 struct drm_etnaviv_gem_wait *args = data; 401 - struct timespec *timeout = &TS(args->timeout); 406 + struct drm_etnaviv_timespec *timeout = &args->timeout; 402 407 struct drm_gem_object *obj; 403 408 struct etnaviv_gpu *gpu; 404 409 int ret;
+6 -5
drivers/gpu/drm/etnaviv/etnaviv_drv.h
··· 61 61 void etnaviv_gem_prime_unpin(struct drm_gem_object *obj); 62 62 void *etnaviv_gem_vmap(struct drm_gem_object *obj); 63 63 int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, 64 - struct timespec *timeout); 64 + struct drm_etnaviv_timespec *timeout); 65 65 int etnaviv_gem_cpu_fini(struct drm_gem_object *obj); 66 66 void etnaviv_gem_free_object(struct drm_gem_object *obj); 67 67 int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file, ··· 107 107 * between the specified timeout and the current CLOCK_MONOTONIC time. 108 108 */ 109 109 static inline unsigned long etnaviv_timeout_to_jiffies( 110 - const struct timespec *timeout) 110 + const struct drm_etnaviv_timespec *timeout) 111 111 { 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 + }; 115 116 116 117 ktime_get_ts64(&ts); 117 118
+2 -2
drivers/gpu/drm/etnaviv/etnaviv_gem.c
··· 373 373 } 374 374 375 375 int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, 376 - struct timespec *timeout) 376 + struct drm_etnaviv_timespec *timeout) 377 377 { 378 378 struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); 379 379 struct drm_device *dev = obj->dev; ··· 431 431 } 432 432 433 433 int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, 434 - struct timespec *timeout) 434 + struct drm_etnaviv_timespec *timeout) 435 435 { 436 436 struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); 437 437
+1 -1
drivers/gpu/drm/etnaviv/etnaviv_gem.h
··· 112 112 void etnaviv_submit_put(struct etnaviv_gem_submit * submit); 113 113 114 114 int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, 115 - struct timespec *timeout); 115 + struct drm_etnaviv_timespec *timeout); 116 116 int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags, 117 117 const struct etnaviv_gem_ops *ops, struct etnaviv_gem_object **res); 118 118 void etnaviv_gem_obj_add(struct drm_device *dev, struct drm_gem_object *obj);
+3 -2
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
··· 1132 1132 * Cmdstream submission/retirement: 1133 1133 */ 1134 1134 int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, 1135 - u32 id, struct timespec *timeout) 1135 + u32 id, struct drm_etnaviv_timespec *timeout) 1136 1136 { 1137 1137 struct dma_fence *fence; 1138 1138 int ret; ··· 1179 1179 * that lock in this function while waiting. 1180 1180 */ 1181 1181 int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu, 1182 - struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout) 1182 + struct etnaviv_gem_object *etnaviv_obj, 1183 + struct drm_etnaviv_timespec *timeout) 1183 1184 { 1184 1185 unsigned long remaining; 1185 1186 long ret;
+3 -2
drivers/gpu/drm/etnaviv/etnaviv_gpu.h
··· 169 169 void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu); 170 170 void etnaviv_gpu_retire(struct etnaviv_gpu *gpu); 171 171 int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, 172 - u32 fence, struct timespec *timeout); 172 + u32 fence, struct drm_etnaviv_timespec *timeout); 173 173 int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu, 174 - struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout); 174 + struct etnaviv_gem_object *etnaviv_obj, 175 + struct drm_etnaviv_timespec *timeout); 175 176 struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit); 176 177 int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu); 177 178 void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu);
+1 -2
drivers/gpu/drm/msm/msm_drv.h
··· 454 454 remaining_jiffies = 0; 455 455 } else { 456 456 ktime_t rem = ktime_sub(*timeout, now); 457 - struct timespec ts = ktime_to_timespec(rem); 458 - remaining_jiffies = timespec_to_jiffies(&ts); 457 + remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ); 459 458 } 460 459 461 460 return remaining_jiffies;
+3 -3
fs/dlm/lowcomms.c
··· 1035 1035 int result; 1036 1036 int addr_len; 1037 1037 struct socket *sock; 1038 - struct timeval tv = { .tv_sec = 5, .tv_usec = 0 }; 1038 + struct __kernel_sock_timeval tv = { .tv_sec = 5, .tv_usec = 0 }; 1039 1039 1040 1040 if (con->nodeid == 0) { 1041 1041 log_print("attempt to connect sock 0 foiled"); ··· 1087 1087 * since O_NONBLOCK argument in connect() function does not work here, 1088 1088 * then, we should restore the default value of this attribute. 1089 1089 */ 1090 - kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv, 1090 + kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_NEW, (char *)&tv, 1091 1091 sizeof(tv)); 1092 1092 result = sock->ops->connect(sock, (struct sockaddr *)&daddr, addr_len, 1093 1093 0); 1094 1094 memset(&tv, 0, sizeof(tv)); 1095 - kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv, 1095 + kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_NEW, (char *)&tv, 1096 1096 sizeof(tv)); 1097 1097 1098 1098 if (result == -EINPROGRESS)
+2 -1
fs/fat/inode.c
··· 21 21 #include <linux/blkdev.h> 22 22 #include <linux/backing-dev.h> 23 23 #include <asm/unaligned.h> 24 + #include <linux/random.h> 24 25 #include <linux/iversion.h> 25 26 #include "fat.h" 26 27 ··· 522 521 inode->i_uid = sbi->options.fs_uid; 523 522 inode->i_gid = sbi->options.fs_gid; 524 523 inode_inc_iversion(inode); 525 - inode->i_generation = get_seconds(); 524 + inode->i_generation = prandom_u32(); 526 525 527 526 if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) { 528 527 inode->i_generation &= ~1;
+22 -6
fs/hfs/hfs_fs.h
··· 242 242 /* 243 243 * There are two time systems. Both are based on seconds since 244 244 * a particular time/date. 245 - * Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970 245 + * Unix: signed little-endian since 00:00 GMT, Jan. 1, 1970 246 246 * mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904 247 247 * 248 + * HFS implementations are highly inconsistent, this one matches the 249 + * traditional behavior of 64-bit Linux, giving the most useful 250 + * time range between 1970 and 2106, by treating any on-disk timestamp 251 + * under HFS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and 2106. 248 252 */ 249 - #define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60) 250 - #define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60) 253 + #define HFS_UTC_OFFSET 2082844800U 251 254 255 + static inline time64_t __hfs_m_to_utime(__be32 mt) 256 + { 257 + time64_t ut = (u32)(be32_to_cpu(mt) - HFS_UTC_OFFSET); 258 + 259 + return ut + sys_tz.tz_minuteswest * 60; 260 + } 261 + 262 + static inline __be32 __hfs_u_to_mtime(time64_t ut) 263 + { 264 + ut -= sys_tz.tz_minuteswest * 60; 265 + 266 + return cpu_to_be32(lower_32_bits(ut) + HFS_UTC_OFFSET); 267 + } 252 268 #define HFS_I(inode) (container_of(inode, struct hfs_inode_info, vfs_inode)) 253 269 #define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info) 254 270 255 - #define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) } 256 - #define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec) 257 - #define hfs_mtime() __hfs_u_to_mtime(get_seconds()) 271 + #define hfs_m_to_utime(time) (struct timespec64){ .tv_sec = __hfs_m_to_utime(time) } 272 + #define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec) 273 + #define hfs_mtime() __hfs_u_to_mtime(ktime_get_real_seconds()) 258 274 259 275 static inline const char *hfs_mdb_name(struct super_block *sb) 260 276 {
+2 -2
fs/hfs/inode.c
··· 351 351 inode->i_mode &= ~hsb->s_file_umask; 352 352 inode->i_mode |= S_IFREG; 353 353 inode->i_ctime = inode->i_atime = inode->i_mtime = 354 - timespec_to_timespec64(hfs_m_to_utime(rec->file.MdDat)); 354 + hfs_m_to_utime(rec->file.MdDat); 355 355 inode->i_op = &hfs_file_inode_operations; 356 356 inode->i_fop = &hfs_file_operations; 357 357 inode->i_mapping->a_ops = &hfs_aops; ··· 362 362 HFS_I(inode)->fs_blocks = 0; 363 363 inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask); 364 364 inode->i_ctime = inode->i_atime = inode->i_mtime = 365 - timespec_to_timespec64(hfs_m_to_utime(rec->dir.MdDat)); 365 + hfs_m_to_utime(rec->dir.MdDat); 366 366 inode->i_op = &hfs_dir_inode_operations; 367 367 inode->i_fop = &hfs_dir_operations; 368 368 break;
+23 -5
fs/hfsplus/hfsplus_fs.h
··· 533 533 void **data, int op, int op_flags); 534 534 int hfsplus_read_wrapper(struct super_block *sb); 535 535 536 - /* time macros */ 537 - #define __hfsp_mt2ut(t) (be32_to_cpu(t) - 2082844800U) 538 - #define __hfsp_ut2mt(t) (cpu_to_be32(t + 2082844800U)) 536 + /* 537 + * time helpers: convert between 1904-base and 1970-base timestamps 538 + * 539 + * HFS+ implementations are highly inconsistent, this one matches the 540 + * traditional behavior of 64-bit Linux, giving the most useful 541 + * time range between 1970 and 2106, by treating any on-disk timestamp 542 + * under HFSPLUS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and 2106. 543 + */ 544 + #define HFSPLUS_UTC_OFFSET 2082844800U 545 + 546 + static inline time64_t __hfsp_mt2ut(__be32 mt) 547 + { 548 + time64_t ut = (u32)(be32_to_cpu(mt) - HFSPLUS_UTC_OFFSET); 549 + 550 + return ut; 551 + } 552 + 553 + static inline __be32 __hfsp_ut2mt(time64_t ut) 554 + { 555 + return cpu_to_be32(lower_32_bits(ut) + HFSPLUS_UTC_OFFSET); 556 + } 539 557 540 558 /* compatibility */ 541 - #define hfsp_mt2ut(t) (struct timespec){ .tv_sec = __hfsp_mt2ut(t) } 559 + #define hfsp_mt2ut(t) (struct timespec64){ .tv_sec = __hfsp_mt2ut(t) } 542 560 #define hfsp_ut2mt(t) __hfsp_ut2mt((t).tv_sec) 543 - #define hfsp_now2mt() __hfsp_ut2mt(get_seconds()) 561 + #define hfsp_now2mt() __hfsp_ut2mt(ktime_get_real_seconds()) 544 562 545 563 #endif
+6 -6
fs/hfsplus/inode.c
··· 504 504 hfsplus_get_perms(inode, &folder->permissions, 1); 505 505 set_nlink(inode, 1); 506 506 inode->i_size = 2 + be32_to_cpu(folder->valence); 507 - inode->i_atime = timespec_to_timespec64(hfsp_mt2ut(folder->access_date)); 508 - inode->i_mtime = timespec_to_timespec64(hfsp_mt2ut(folder->content_mod_date)); 509 - inode->i_ctime = timespec_to_timespec64(hfsp_mt2ut(folder->attribute_mod_date)); 507 + inode->i_atime = hfsp_mt2ut(folder->access_date); 508 + inode->i_mtime = hfsp_mt2ut(folder->content_mod_date); 509 + inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date); 510 510 HFSPLUS_I(inode)->create_date = folder->create_date; 511 511 HFSPLUS_I(inode)->fs_blocks = 0; 512 512 if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) { ··· 542 542 init_special_inode(inode, inode->i_mode, 543 543 be32_to_cpu(file->permissions.dev)); 544 544 } 545 - inode->i_atime = timespec_to_timespec64(hfsp_mt2ut(file->access_date)); 546 - inode->i_mtime = timespec_to_timespec64(hfsp_mt2ut(file->content_mod_date)); 547 - inode->i_ctime = timespec_to_timespec64(hfsp_mt2ut(file->attribute_mod_date)); 545 + inode->i_atime = hfsp_mt2ut(file->access_date); 546 + inode->i_mtime = hfsp_mt2ut(file->content_mod_date); 547 + inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date); 548 548 HFSPLUS_I(inode)->create_date = file->create_date; 549 549 } else { 550 550 pr_err("bad catalog entry used to create inode\n");
+13 -9
fs/hostfs/hostfs.h
··· 37 37 * is on, and remove the appropriate bits from attr->ia_mode (attr is a 38 38 * "struct iattr *"). -BlaisorBlade 39 39 */ 40 + struct hostfs_timespec { 41 + long long tv_sec; 42 + long long tv_nsec; 43 + }; 40 44 41 45 struct hostfs_iattr { 42 - unsigned int ia_valid; 43 - unsigned short ia_mode; 44 - uid_t ia_uid; 45 - gid_t ia_gid; 46 - loff_t ia_size; 47 - struct timespec ia_atime; 48 - struct timespec ia_mtime; 49 - struct timespec ia_ctime; 46 + unsigned int ia_valid; 47 + unsigned short ia_mode; 48 + uid_t ia_uid; 49 + gid_t ia_gid; 50 + loff_t ia_size; 51 + struct hostfs_timespec ia_atime; 52 + struct hostfs_timespec ia_mtime; 53 + struct hostfs_timespec ia_ctime; 50 54 }; 51 55 52 56 struct hostfs_stat { ··· 60 56 unsigned int uid; 61 57 unsigned int gid; 62 58 unsigned long long size; 63 - struct timespec atime, mtime, ctime; 59 + struct hostfs_timespec atime, mtime, ctime; 64 60 unsigned int blksize; 65 61 unsigned long long blocks; 66 62 unsigned int maj;
+9 -6
fs/hostfs/hostfs_kern.c
··· 549 549 set_nlink(ino, st.nlink); 550 550 i_uid_write(ino, st.uid); 551 551 i_gid_write(ino, st.gid); 552 - ino->i_atime = timespec_to_timespec64(st.atime); 553 - ino->i_mtime = timespec_to_timespec64(st.mtime); 554 - ino->i_ctime = timespec_to_timespec64(st.ctime); 552 + ino->i_atime = (struct timespec64){ st.atime.tv_sec, st.atime.tv_nsec }; 553 + ino->i_mtime = (struct timespec64){ st.mtime.tv_sec, st.mtime.tv_nsec }; 554 + ino->i_ctime = (struct timespec64){ st.ctime.tv_sec, st.ctime.tv_nsec }; 555 555 ino->i_size = st.size; 556 556 ino->i_blocks = st.blocks; 557 557 return 0; ··· 820 820 } 821 821 if (attr->ia_valid & ATTR_ATIME) { 822 822 attrs.ia_valid |= HOSTFS_ATTR_ATIME; 823 - attrs.ia_atime = timespec64_to_timespec(attr->ia_atime); 823 + attrs.ia_atime = (struct hostfs_timespec) 824 + { attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec }; 824 825 } 825 826 if (attr->ia_valid & ATTR_MTIME) { 826 827 attrs.ia_valid |= HOSTFS_ATTR_MTIME; 827 - attrs.ia_mtime = timespec64_to_timespec(attr->ia_mtime); 828 + attrs.ia_mtime = (struct hostfs_timespec) 829 + { attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec }; 828 830 } 829 831 if (attr->ia_valid & ATTR_CTIME) { 830 832 attrs.ia_valid |= HOSTFS_ATTR_CTIME; 831 - attrs.ia_ctime = timespec64_to_timespec(attr->ia_ctime); 833 + attrs.ia_ctime = (struct hostfs_timespec) 834 + { attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec }; 832 835 } 833 836 if (attr->ia_valid & ATTR_ATIME_SET) { 834 837 attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
+4 -2
fs/nfs/fscache-index.c
··· 84 84 return FSCACHE_CHECKAUX_OBSOLETE; 85 85 86 86 memset(&auxdata, 0, sizeof(auxdata)); 87 - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); 88 - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); 87 + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; 88 + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; 89 + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; 90 + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; 89 91 90 92 if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) 91 93 auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
+12 -6
fs/nfs/fscache.c
··· 238 238 return; 239 239 240 240 memset(&auxdata, 0, sizeof(auxdata)); 241 - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); 242 - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); 241 + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; 242 + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; 243 + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; 244 + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; 243 245 244 246 if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) 245 247 auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode); ··· 265 263 dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie); 266 264 267 265 memset(&auxdata, 0, sizeof(auxdata)); 268 - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); 269 - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); 266 + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; 267 + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; 268 + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; 269 + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; 270 270 fscache_relinquish_cookie(cookie, &auxdata, false); 271 271 nfsi->fscache = NULL; 272 272 } ··· 309 305 return; 310 306 311 307 memset(&auxdata, 0, sizeof(auxdata)); 312 - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); 313 - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); 308 + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; 309 + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; 310 + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; 311 + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; 314 312 315 313 if (inode_is_open_for_write(inode)) { 316 314 dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
+5 -3
fs/nfs/fscache.h
··· 62 62 * cache object. 63 63 */ 64 64 struct nfs_fscache_inode_auxdata { 65 - struct timespec mtime; 66 - struct timespec ctime; 67 - u64 change_attr; 65 + s64 mtime_sec; 66 + s64 mtime_nsec; 67 + s64 ctime_sec; 68 + s64 ctime_nsec; 69 + u64 change_attr; 68 70 }; 69 71 70 72 /*
+5 -5
fs/nfs/nfs4xdr.c
··· 4097 4097 status = NFS_ATTR_FATTR_ATIME; 4098 4098 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; 4099 4099 } 4100 - dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); 4100 + dprintk("%s: atime=%lld\n", __func__, time->tv_sec); 4101 4101 return status; 4102 4102 } 4103 4103 ··· 4115 4115 status = NFS_ATTR_FATTR_CTIME; 4116 4116 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; 4117 4117 } 4118 - dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); 4118 + dprintk("%s: ctime=%lld\n", __func__, time->tv_sec); 4119 4119 return status; 4120 4120 } 4121 4121 ··· 4132 4132 status = decode_attr_time(xdr, time); 4133 4133 bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; 4134 4134 } 4135 - dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, 4136 - (long)time->tv_nsec); 4135 + dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec, 4136 + time->tv_nsec); 4137 4137 return status; 4138 4138 } 4139 4139 ··· 4197 4197 status = NFS_ATTR_FATTR_MTIME; 4198 4198 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; 4199 4199 } 4200 - dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); 4200 + dprintk("%s: mtime=%lld\n", __func__, time->tv_sec); 4201 4201 return status; 4202 4202 } 4203 4203
-20
include/linux/jiffies.h
··· 422 422 extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); 423 423 extern void jiffies_to_timespec64(const unsigned long jiffies, 424 424 struct timespec64 *value); 425 - static inline unsigned long timespec_to_jiffies(const struct timespec *value) 426 - { 427 - struct timespec64 ts = timespec_to_timespec64(*value); 428 - 429 - return timespec64_to_jiffies(&ts); 430 - } 431 - 432 - static inline void jiffies_to_timespec(const unsigned long jiffies, 433 - struct timespec *value) 434 - { 435 - struct timespec64 ts; 436 - 437 - jiffies_to_timespec64(jiffies, &ts); 438 - *value = timespec64_to_timespec(ts); 439 - } 440 - 441 - extern unsigned long timeval_to_jiffies(const struct timeval *value); 442 - extern void jiffies_to_timeval(const unsigned long jiffies, 443 - struct timeval *value); 444 - 445 425 extern clock_t jiffies_to_clock_t(unsigned long x); 446 426 static inline clock_t jiffies_delta_to_clock_t(long delta) 447 427 {
+23 -19
include/linux/sunrpc/cache.h
··· 45 45 */ 46 46 struct cache_head { 47 47 struct hlist_node cache_list; 48 - time_t expiry_time; /* After time time, don't use the data */ 49 - time_t last_refresh; /* If CACHE_PENDING, this is when upcall was 48 + time64_t expiry_time; /* After time time, don't use the data */ 49 + time64_t last_refresh; /* If CACHE_PENDING, this is when upcall was 50 50 * sent, else this is when update was 51 51 * received, though it is alway set to 52 52 * be *after* ->flush_time. ··· 95 95 /* fields below this comment are for internal use 96 96 * and should not be touched by cache owners 97 97 */ 98 - time_t flush_time; /* flush all cache items with 98 + time64_t flush_time; /* flush all cache items with 99 99 * last_refresh at or earlier 100 100 * than this. last_refresh 101 101 * is never set at or earlier 102 102 * than this. 103 103 */ 104 104 struct list_head others; 105 - time_t nextcheck; 105 + time64_t nextcheck; 106 106 int entries; 107 107 108 108 /* fields for communication over channel */ 109 109 struct list_head queue; 110 110 111 111 atomic_t writers; /* how many time is /channel open */ 112 - time_t last_close; /* if no writers, when did last close */ 113 - time_t last_warn; /* when we last warned about no writers */ 112 + time64_t last_close; /* if no writers, when did last close */ 113 + time64_t last_warn; /* when we last warned about no writers */ 114 114 115 115 union { 116 116 struct proc_dir_entry *procfs; ··· 147 147 * timestamps kept in the cache are expressed in seconds 148 148 * since boot. This is the best for measuring differences in 149 149 * real time. 150 + * This reimplemnts ktime_get_boottime_seconds() in a slightly 151 + * faster but less accurate way. When we end up converting 152 + * back to wallclock (CLOCK_REALTIME), that error often 153 + * cancels out during the reverse operation. 150 154 */ 151 - static inline time_t seconds_since_boot(void) 155 + static inline time64_t seconds_since_boot(void) 152 156 { 153 - struct timespec boot; 154 - getboottime(&boot); 155 - return get_seconds() - boot.tv_sec; 157 + struct timespec64 boot; 158 + getboottime64(&boot); 159 + return ktime_get_real_seconds() - boot.tv_sec; 156 160 } 157 161 158 - static inline time_t convert_to_wallclock(time_t sinceboot) 162 + static inline time64_t convert_to_wallclock(time64_t sinceboot) 159 163 { 160 - struct timespec boot; 161 - getboottime(&boot); 164 + struct timespec64 boot; 165 + getboottime64(&boot); 162 166 return boot.tv_sec + sinceboot; 163 167 } 164 168 ··· 277 273 return 0; 278 274 } 279 275 280 - static inline int get_time(char **bpp, time_t *time) 276 + static inline int get_time(char **bpp, time64_t *time) 281 277 { 282 278 char buf[50]; 283 279 long long ll; ··· 291 287 if (kstrtoll(buf, 0, &ll)) 292 288 return -EINVAL; 293 289 294 - *time = (time_t)ll; 290 + *time = ll; 295 291 return 0; 296 292 } 297 293 298 - static inline time_t get_expiry(char **bpp) 294 + static inline time64_t get_expiry(char **bpp) 299 295 { 300 - time_t rv; 301 - struct timespec boot; 296 + time64_t rv; 297 + struct timespec64 boot; 302 298 303 299 if (get_time(bpp, &rv)) 304 300 return 0; 305 301 if (rv < 0) 306 302 return 0; 307 - getboottime(&boot); 303 + getboottime64(&boot); 308 304 return rv - boot.tv_sec; 309 305 } 310 306
+2 -2
include/linux/sunrpc/gss_api.h
··· 48 48 size_t bufsize, 49 49 struct gss_api_mech *mech, 50 50 struct gss_ctx **ctx_id, 51 - time_t *endtime, 51 + time64_t *endtime, 52 52 gfp_t gfp_mask); 53 53 u32 gss_get_mic( 54 54 struct gss_ctx *ctx_id, ··· 108 108 const void *input_token, 109 109 size_t bufsize, 110 110 struct gss_ctx *ctx_id, 111 - time_t *endtime, 111 + time64_t *endtime, 112 112 gfp_t gfp_mask); 113 113 u32 (*gss_get_mic)( 114 114 struct gss_ctx *ctx_id,
+1 -1
include/linux/sunrpc/gss_krb5.h
··· 106 106 struct crypto_sync_skcipher *initiator_enc_aux; 107 107 u8 Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */ 108 108 u8 cksum[GSS_KRB5_MAX_KEYLEN]; 109 - s32 endtime; 110 109 atomic_t seq_send; 111 110 atomic64_t seq_send64; 111 + time64_t endtime; 112 112 struct xdr_netobj mech_used; 113 113 u8 initiator_sign[GSS_KRB5_MAX_KEYLEN]; 114 114 u8 acceptor_sign[GSS_KRB5_MAX_KEYLEN];
+4 -5
include/linux/syscalls.h
··· 16 16 struct iocb; 17 17 struct io_event; 18 18 struct iovec; 19 - struct itimerspec; 20 - struct itimerval; 19 + struct __kernel_old_itimerval; 21 20 struct kexec_segment; 22 21 struct linux_dirent; 23 22 struct linux_dirent64; ··· 593 594 struct old_timespec32 __user *rmtp); 594 595 595 596 /* kernel/itimer.c */ 596 - asmlinkage long sys_getitimer(int which, struct itimerval __user *value); 597 + asmlinkage long sys_getitimer(int which, struct __kernel_old_itimerval __user *value); 597 598 asmlinkage long sys_setitimer(int which, 598 - struct itimerval __user *value, 599 - struct itimerval __user *ovalue); 599 + struct __kernel_old_itimerval __user *value, 600 + struct __kernel_old_itimerval __user *ovalue); 600 601 601 602 /* kernel/kexec.c */ 602 603 asmlinkage long sys_kexec_load(unsigned long entry, unsigned long nr_segments,
+2
include/uapi/linux/acct.h
··· 49 49 __u16 ac_uid16; /* LSB of Real User ID */ 50 50 __u16 ac_gid16; /* LSB of Real Group ID */ 51 51 __u16 ac_tty; /* Control Terminal */ 52 + /* __u32 range means times from 1970 to 2106 */ 52 53 __u32 ac_btime; /* Process Creation Time */ 53 54 comp_t ac_utime; /* User Time */ 54 55 comp_t ac_stime; /* System Time */ ··· 82 81 __u32 ac_gid; /* Real Group ID */ 83 82 __u32 ac_pid; /* Process ID */ 84 83 __u32 ac_ppid; /* Parent Process ID */ 84 + /* __u32 range means times from 1970 to 2106 */ 85 85 __u32 ac_btime; /* Process Creation Time */ 86 86 #ifdef __KERNEL__ 87 87 __u32 ac_etime; /* Elapsed Time */
+5 -1
include/uapi/linux/taskstats.h
··· 34 34 */ 35 35 36 36 37 - #define TASKSTATS_VERSION 9 37 + #define TASKSTATS_VERSION 10 38 38 #define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN 39 39 * in linux/sched.h */ 40 40 ··· 112 112 __u32 ac_gid; /* Group ID */ 113 113 __u32 ac_pid; /* Process ID */ 114 114 __u32 ac_ppid; /* Parent process ID */ 115 + /* __u32 range means times from 1970 to 2106 */ 115 116 __u32 ac_btime; /* Begin time [sec since 1970] */ 116 117 __u64 ac_etime __attribute__((aligned(8))); 117 118 /* Elapsed time [usec] */ ··· 169 168 /* Delay waiting for thrashing page */ 170 169 __u64 thrashing_count; 171 170 __u64 thrashing_delay_total; 171 + 172 + /* v10: 64-bit btime to avoid overflow */ 173 + __u64 ac_btime64; /* 64-bit begin time */ 172 174 }; 173 175 174 176
+5
include/uapi/linux/time_types.h
··· 33 33 long tv_nsec; /* nanoseconds */ 34 34 }; 35 35 36 + struct __kernel_old_itimerval { 37 + struct __kernel_old_timeval it_interval;/* timer interval */ 38 + struct __kernel_old_timeval it_value; /* current value */ 39 + }; 40 + 36 41 struct __kernel_sock_timeval { 37 42 __s64 tv_sec; 38 43 __s64 tv_usec;
+2
include/uapi/linux/timex.h
··· 57 57 58 58 #define NTP_API 4 /* NTP API version */ 59 59 60 + #ifndef __KERNEL__ 60 61 /* 61 62 * syscall interface - used (mainly by NTP daemon) 62 63 * to discipline kernel clock oscillator ··· 92 91 int :32; int :32; int :32; int :32; 93 92 int :32; int :32; int :32; 94 93 }; 94 + #endif 95 95 96 96 struct __kernel_timex_timeval { 97 97 __kernel_time64_t tv_sec;
+3 -1
kernel/acct.c
··· 416 416 { 417 417 struct pacct_struct *pacct = &current->signal->pacct; 418 418 u64 elapsed, run_time; 419 + time64_t btime; 419 420 struct tty_struct *tty; 420 421 421 422 /* ··· 449 448 } 450 449 #endif 451 450 do_div(elapsed, AHZ); 452 - ac->ac_btime = get_seconds() - elapsed; 451 + btime = ktime_get_real_seconds() - elapsed; 452 + ac->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX); 453 453 #if ACCT_VERSION==2 454 454 ac->ac_ahz = AHZ; 455 455 #endif
+9 -9
kernel/time/itimer.c
··· 97 97 return 0; 98 98 } 99 99 100 - static int put_itimerval(struct itimerval __user *o, 100 + static int put_itimerval(struct __kernel_old_itimerval __user *o, 101 101 const struct itimerspec64 *i) 102 102 { 103 - struct itimerval v; 103 + struct __kernel_old_itimerval v; 104 104 105 105 v.it_interval.tv_sec = i->it_interval.tv_sec; 106 106 v.it_interval.tv_usec = i->it_interval.tv_nsec / NSEC_PER_USEC; 107 107 v.it_value.tv_sec = i->it_value.tv_sec; 108 108 v.it_value.tv_usec = i->it_value.tv_nsec / NSEC_PER_USEC; 109 - return copy_to_user(o, &v, sizeof(struct itimerval)) ? -EFAULT : 0; 109 + return copy_to_user(o, &v, sizeof(struct __kernel_old_itimerval)) ? -EFAULT : 0; 110 110 } 111 111 112 112 113 - SYSCALL_DEFINE2(getitimer, int, which, struct itimerval __user *, value) 113 + SYSCALL_DEFINE2(getitimer, int, which, struct __kernel_old_itimerval __user *, value) 114 114 { 115 115 struct itimerspec64 get_buffer; 116 116 int error = do_getitimer(which, &get_buffer); ··· 314 314 315 315 #endif 316 316 317 - static int get_itimerval(struct itimerspec64 *o, const struct itimerval __user *i) 317 + static int get_itimerval(struct itimerspec64 *o, const struct __kernel_old_itimerval __user *i) 318 318 { 319 - struct itimerval v; 319 + struct __kernel_old_itimerval v; 320 320 321 - if (copy_from_user(&v, i, sizeof(struct itimerval))) 321 + if (copy_from_user(&v, i, sizeof(struct __kernel_old_itimerval))) 322 322 return -EFAULT; 323 323 324 324 /* Validate the timevals in value. */ ··· 333 333 return 0; 334 334 } 335 335 336 - SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, 337 - struct itimerval __user *, ovalue) 336 + SYSCALL_DEFINE3(setitimer, int, which, struct __kernel_old_itimerval __user *, value, 337 + struct __kernel_old_itimerval __user *, ovalue) 338 338 { 339 339 struct itimerspec64 set_buffer, get_buffer; 340 340 int error;
+5 -53
kernel/time/time.c
··· 626 626 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec 627 627 * value to a scaled second value. 628 628 */ 629 - static unsigned long 630 - __timespec64_to_jiffies(u64 sec, long nsec) 629 + 630 + unsigned long 631 + timespec64_to_jiffies(const struct timespec64 *value) 631 632 { 632 - nsec = nsec + TICK_NSEC - 1; 633 + u64 sec = value->tv_sec; 634 + long nsec = value->tv_nsec + TICK_NSEC - 1; 633 635 634 636 if (sec >= MAX_SEC_IN_JIFFIES){ 635 637 sec = MAX_SEC_IN_JIFFIES; ··· 641 639 (((u64)nsec * NSEC_CONVERSION) >> 642 640 (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; 643 641 644 - } 645 - 646 - static unsigned long 647 - __timespec_to_jiffies(unsigned long sec, long nsec) 648 - { 649 - return __timespec64_to_jiffies((u64)sec, nsec); 650 - } 651 - 652 - unsigned long 653 - timespec64_to_jiffies(const struct timespec64 *value) 654 - { 655 - return __timespec64_to_jiffies(value->tv_sec, value->tv_nsec); 656 642 } 657 643 EXPORT_SYMBOL(timespec64_to_jiffies); 658 644 ··· 657 667 value->tv_nsec = rem; 658 668 } 659 669 EXPORT_SYMBOL(jiffies_to_timespec64); 660 - 661 - /* 662 - * We could use a similar algorithm to timespec_to_jiffies (with a 663 - * different multiplier for usec instead of nsec). But this has a 664 - * problem with rounding: we can't exactly add TICK_NSEC - 1 to the 665 - * usec value, since it's not necessarily integral. 666 - * 667 - * We could instead round in the intermediate scaled representation 668 - * (i.e. in units of 1/2^(large scale) jiffies) but that's also 669 - * perilous: the scaling introduces a small positive error, which 670 - * combined with a division-rounding-upward (i.e. adding 2^(scale) - 1 671 - * units to the intermediate before shifting) leads to accidental 672 - * overflow and overestimates. 673 - * 674 - * At the cost of one additional multiplication by a constant, just 675 - * use the timespec implementation. 676 - */ 677 - unsigned long 678 - timeval_to_jiffies(const struct timeval *value) 679 - { 680 - return __timespec_to_jiffies(value->tv_sec, 681 - value->tv_usec * NSEC_PER_USEC); 682 - } 683 - EXPORT_SYMBOL(timeval_to_jiffies); 684 - 685 - void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value) 686 - { 687 - /* 688 - * Convert jiffies to nanoseconds and separate with 689 - * one divide. 690 - */ 691 - u32 rem; 692 - 693 - value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC, 694 - NSEC_PER_SEC, &rem); 695 - value->tv_usec = rem / NSEC_PER_USEC; 696 - } 697 - EXPORT_SYMBOL(jiffies_to_timeval); 698 670 699 671 /* 700 672 * Convert jiffies/jiffies_64 to clock_t and back.
+6 -3
kernel/tsacct.c
··· 24 24 const struct cred *tcred; 25 25 u64 utime, stime, utimescaled, stimescaled; 26 26 u64 delta; 27 + time64_t btime; 27 28 28 29 BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); 29 30 ··· 33 32 /* Convert to micro seconds */ 34 33 do_div(delta, NSEC_PER_USEC); 35 34 stats->ac_etime = delta; 36 - /* Convert to seconds for btime */ 37 - do_div(delta, USEC_PER_SEC); 38 - stats->ac_btime = get_seconds() - delta; 35 + /* Convert to seconds for btime (note y2106 limit) */ 36 + btime = ktime_get_real_seconds() - div_u64(delta, USEC_PER_SEC); 37 + stats->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX); 38 + stats->ac_btime64 = btime; 39 + 39 40 if (thread_group_leader(tsk)) { 40 41 stats->ac_exitcode = tsk->exit_code; 41 42 if (tsk->flags & PF_FORKNOEXEC)
+17 -10
net/packet/af_packet.c
··· 408 408 } 409 409 } 410 410 411 - static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec *ts, 411 + static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec64 *ts, 412 412 unsigned int flags) 413 413 { 414 414 struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); 415 415 416 416 if (shhwtstamps && 417 417 (flags & SOF_TIMESTAMPING_RAW_HARDWARE) && 418 - ktime_to_timespec_cond(shhwtstamps->hwtstamp, ts)) 418 + ktime_to_timespec64_cond(shhwtstamps->hwtstamp, ts)) 419 419 return TP_STATUS_TS_RAW_HARDWARE; 420 420 421 - if (ktime_to_timespec_cond(skb->tstamp, ts)) 421 + if (ktime_to_timespec64_cond(skb->tstamp, ts)) 422 422 return TP_STATUS_TS_SOFTWARE; 423 423 424 424 return 0; ··· 428 428 struct sk_buff *skb) 429 429 { 430 430 union tpacket_uhdr h; 431 - struct timespec ts; 431 + struct timespec64 ts; 432 432 __u32 ts_status; 433 433 434 434 if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) 435 435 return 0; 436 436 437 437 h.raw = frame; 438 + /* 439 + * versions 1 through 3 overflow the timestamps in y2106, since they 440 + * all store the seconds in a 32-bit unsigned integer. 441 + * If we create a version 4, that should have a 64-bit timestamp, 442 + * either 64-bit seconds + 32-bit nanoseconds, or just 64-bit 443 + * nanoseconds. 444 + */ 438 445 switch (po->tp_version) { 439 446 case TPACKET_V1: 440 447 h.h1->tp_sec = ts.tv_sec; ··· 776 769 * It shouldn't really happen as we don't close empty 777 770 * blocks. See prb_retire_rx_blk_timer_expired(). 778 771 */ 779 - struct timespec ts; 780 - getnstimeofday(&ts); 772 + struct timespec64 ts; 773 + ktime_get_real_ts64(&ts); 781 774 h1->ts_last_pkt.ts_sec = ts.tv_sec; 782 775 h1->ts_last_pkt.ts_nsec = ts.tv_nsec; 783 776 } ··· 807 800 static void prb_open_block(struct tpacket_kbdq_core *pkc1, 808 801 struct tpacket_block_desc *pbd1) 809 802 { 810 - struct timespec ts; 803 + struct timespec64 ts; 811 804 struct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1; 812 805 813 806 smp_rmb(); ··· 820 813 BLOCK_NUM_PKTS(pbd1) = 0; 821 814 BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1->blk_sizeof_priv); 822 815 823 - getnstimeofday(&ts); 816 + ktime_get_real_ts64(&ts); 824 817 825 818 h1->ts_first_pkt.ts_sec = ts.tv_sec; 826 819 h1->ts_first_pkt.ts_nsec = ts.tv_nsec; ··· 2170 2163 unsigned long status = TP_STATUS_USER; 2171 2164 unsigned short macoff, netoff, hdrlen; 2172 2165 struct sk_buff *copy_skb = NULL; 2173 - struct timespec ts; 2166 + struct timespec64 ts; 2174 2167 __u32 ts_status; 2175 2168 bool is_drop_n_account = false; 2176 2169 bool do_vnet = false; ··· 2302 2295 skb_copy_bits(skb, 0, h.raw + macoff, snaplen); 2303 2296 2304 2297 if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) 2305 - getnstimeofday(&ts); 2298 + ktime_get_real_ts64(&ts); 2306 2299 2307 2300 status |= ts_status; 2308 2301
+9 -3
net/sunrpc/auth_gss/gss_krb5_mech.c
··· 253 253 { 254 254 u32 seq_send; 255 255 int tmp; 256 + u32 time32; 256 257 257 258 p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); 258 259 if (IS_ERR(p)) ··· 291 290 p = ERR_PTR(-ENOSYS); 292 291 goto out_err; 293 292 } 294 - p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); 293 + p = simple_get_bytes(p, end, &time32, sizeof(time32)); 295 294 if (IS_ERR(p)) 296 295 goto out_err; 296 + /* unsigned 32-bit time overflows in year 2106 */ 297 + ctx->endtime = (time64_t)time32; 297 298 p = simple_get_bytes(p, end, &seq_send, sizeof(seq_send)); 298 299 if (IS_ERR(p)) 299 300 goto out_err; ··· 590 587 { 591 588 u64 seq_send64; 592 589 int keylen; 590 + u32 time32; 593 591 594 592 p = simple_get_bytes(p, end, &ctx->flags, sizeof(ctx->flags)); 595 593 if (IS_ERR(p)) 596 594 goto out_err; 597 595 ctx->initiate = ctx->flags & KRB5_CTX_FLAG_INITIATOR; 598 596 599 - p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); 597 + p = simple_get_bytes(p, end, &time32, sizeof(time32)); 600 598 if (IS_ERR(p)) 601 599 goto out_err; 600 + /* unsigned 32-bit time overflows in year 2106 */ 601 + ctx->endtime = (time64_t)time32; 602 602 p = simple_get_bytes(p, end, &seq_send64, sizeof(seq_send64)); 603 603 if (IS_ERR(p)) 604 604 goto out_err; ··· 665 659 static int 666 660 gss_import_sec_context_kerberos(const void *p, size_t len, 667 661 struct gss_ctx *ctx_id, 668 - time_t *endtime, 662 + time64_t *endtime, 669 663 gfp_t gfp_mask) 670 664 { 671 665 const void *end = (const void *)((const char *)p + len);
+4 -4
net/sunrpc/auth_gss/gss_krb5_seal.c
··· 131 131 struct xdr_netobj md5cksum = {.len = sizeof(cksumdata), 132 132 .data = cksumdata}; 133 133 void *ptr; 134 - s32 now; 134 + time64_t now; 135 135 u32 seq_send; 136 136 u8 *cksumkey; 137 137 138 138 dprintk("RPC: %s\n", __func__); 139 139 BUG_ON(ctx == NULL); 140 140 141 - now = get_seconds(); 141 + now = ktime_get_real_seconds(); 142 142 143 143 ptr = setup_token(ctx, token); 144 144 ··· 170 170 struct xdr_netobj cksumobj = { .len = sizeof(cksumdata), 171 171 .data = cksumdata}; 172 172 void *krb5_hdr; 173 - s32 now; 173 + time64_t now; 174 174 u8 *cksumkey; 175 175 unsigned int cksum_usage; 176 176 __be64 seq_send_be64; ··· 198 198 199 199 memcpy(krb5_hdr + GSS_KRB5_TOK_HDR_LEN, cksumobj.data, cksumobj.len); 200 200 201 - now = get_seconds(); 201 + now = ktime_get_real_seconds(); 202 202 203 203 return (ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE; 204 204 }
+3 -3
net/sunrpc/auth_gss/gss_krb5_unseal.c
··· 124 124 125 125 /* it got through unscathed. Make sure the context is unexpired */ 126 126 127 - now = get_seconds(); 127 + now = ktime_get_real_seconds(); 128 128 129 129 if (now > ctx->endtime) 130 130 return GSS_S_CONTEXT_EXPIRED; ··· 149 149 char cksumdata[GSS_KRB5_MAX_CKSUM_LEN]; 150 150 struct xdr_netobj cksumobj = {.len = sizeof(cksumdata), 151 151 .data = cksumdata}; 152 - s32 now; 152 + time64_t now; 153 153 u8 *ptr = read_token->data; 154 154 u8 *cksumkey; 155 155 u8 flags; ··· 194 194 return GSS_S_BAD_SIG; 195 195 196 196 /* it got through unscathed. Make sure the context is unexpired */ 197 - now = get_seconds(); 197 + now = ktime_get_real_seconds(); 198 198 if (now > ctx->endtime) 199 199 return GSS_S_CONTEXT_EXPIRED; 200 200
+8 -8
net/sunrpc/auth_gss/gss_krb5_wrap.c
··· 163 163 .data = cksumdata}; 164 164 int blocksize = 0, plainlen; 165 165 unsigned char *ptr, *msg_start; 166 - s32 now; 166 + time64_t now; 167 167 int headlen; 168 168 struct page **tmp_pages; 169 169 u32 seq_send; ··· 172 172 173 173 dprintk("RPC: %s\n", __func__); 174 174 175 - now = get_seconds(); 175 + now = ktime_get_real_seconds(); 176 176 177 177 blocksize = crypto_sync_skcipher_blocksize(kctx->enc); 178 178 gss_krb5_add_padding(buf, offset, blocksize); ··· 268 268 char cksumdata[GSS_KRB5_MAX_CKSUM_LEN]; 269 269 struct xdr_netobj md5cksum = {.len = sizeof(cksumdata), 270 270 .data = cksumdata}; 271 - s32 now; 271 + time64_t now; 272 272 int direction; 273 273 s32 seqnum; 274 274 unsigned char *ptr; ··· 359 359 360 360 /* it got through unscathed. Make sure the context is unexpired */ 361 361 362 - now = get_seconds(); 362 + now = ktime_get_real_seconds(); 363 363 364 364 if (now > kctx->endtime) 365 365 return GSS_S_CONTEXT_EXPIRED; ··· 439 439 struct xdr_buf *buf, struct page **pages) 440 440 { 441 441 u8 *ptr, *plainhdr; 442 - s32 now; 442 + time64_t now; 443 443 u8 flags = 0x00; 444 444 __be16 *be16ptr; 445 445 __be64 *be64ptr; ··· 481 481 if (err) 482 482 return err; 483 483 484 - now = get_seconds(); 484 + now = ktime_get_real_seconds(); 485 485 return (kctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE; 486 486 } 487 487 488 488 static u32 489 489 gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf) 490 490 { 491 - s32 now; 491 + time64_t now; 492 492 u8 *ptr; 493 493 u8 flags = 0x00; 494 494 u16 ec, rrc; ··· 557 557 /* do sequencing checks */ 558 558 559 559 /* it got through unscathed. Make sure the context is unexpired */ 560 - now = get_seconds(); 560 + now = ktime_get_real_seconds(); 561 561 if (now > kctx->endtime) 562 562 return GSS_S_CONTEXT_EXPIRED; 563 563
+1 -1
net/sunrpc/auth_gss/gss_mech_switch.c
··· 376 376 gss_import_sec_context(const void *input_token, size_t bufsize, 377 377 struct gss_api_mech *mech, 378 378 struct gss_ctx **ctx_id, 379 - time_t *endtime, 379 + time64_t *endtime, 380 380 gfp_t gfp_mask) 381 381 { 382 382 if (!(*ctx_id = kzalloc(sizeof(**ctx_id), gfp_mask)))
+3 -3
net/sunrpc/auth_gss/svcauth_gss.c
··· 203 203 char *ep; 204 204 int len; 205 205 struct rsi rsii, *rsip = NULL; 206 - time_t expiry; 206 + time64_t expiry; 207 207 int status = -EINVAL; 208 208 209 209 memset(&rsii, 0, sizeof(rsii)); ··· 436 436 int id; 437 437 int len, rv; 438 438 struct rsc rsci, *rscp = NULL; 439 - time_t expiry; 439 + time64_t expiry; 440 440 int status = -EINVAL; 441 441 struct gss_api_mech *gm = NULL; 442 442 ··· 1221 1221 static atomic64_t ctxhctr; 1222 1222 long long ctxh; 1223 1223 struct gss_api_mech *gm = NULL; 1224 - time_t expiry; 1224 + time64_t expiry; 1225 1225 int status = -EINVAL; 1226 1226 1227 1227 memset(&rsci, 0, sizeof(rsci));
+8 -8
net/sunrpc/cache.c
··· 42 42 43 43 static void cache_init(struct cache_head *h, struct cache_detail *detail) 44 44 { 45 - time_t now = seconds_since_boot(); 45 + time64_t now = seconds_since_boot(); 46 46 INIT_HLIST_NODE(&h->cache_list); 47 47 h->flags = 0; 48 48 kref_init(&h->ref); ··· 139 139 140 140 static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); 141 141 142 - static void cache_fresh_locked(struct cache_head *head, time_t expiry, 142 + static void cache_fresh_locked(struct cache_head *head, time64_t expiry, 143 143 struct cache_detail *detail) 144 144 { 145 - time_t now = seconds_since_boot(); 145 + time64_t now = seconds_since_boot(); 146 146 if (now <= detail->flush_time) 147 147 /* ensure it isn't immediately treated as expired */ 148 148 now = detail->flush_time + 1; ··· 274 274 struct cache_head *h, struct cache_req *rqstp) 275 275 { 276 276 int rv; 277 - long refresh_age, age; 277 + time64_t refresh_age, age; 278 278 279 279 /* First decide return status as best we can */ 280 280 rv = cache_is_valid(h); ··· 288 288 rv = -ENOENT; 289 289 } else if (rv == -EAGAIN || 290 290 (h->expiry_time != 0 && age > refresh_age/2)) { 291 - dprintk("RPC: Want update, refage=%ld, age=%ld\n", 291 + dprintk("RPC: Want update, refage=%lld, age=%lld\n", 292 292 refresh_age, age); 293 293 if (!test_and_set_bit(CACHE_PENDING, &h->flags)) { 294 294 switch (cache_make_upcall(detail, h)) { ··· 1404 1404 return cd->cache_show(m, cd, NULL); 1405 1405 1406 1406 ifdebug(CACHE) 1407 - seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n", 1407 + seq_printf(m, "# expiry=%lld refcnt=%d flags=%lx\n", 1408 1408 convert_to_wallclock(cp->expiry_time), 1409 1409 kref_read(&cp->ref), cp->flags); 1410 1410 cache_get(cp); ··· 1477 1477 char tbuf[22]; 1478 1478 size_t len; 1479 1479 1480 - len = snprintf(tbuf, sizeof(tbuf), "%lu\n", 1480 + len = snprintf(tbuf, sizeof(tbuf), "%llu\n", 1481 1481 convert_to_wallclock(cd->flush_time)); 1482 1482 return simple_read_from_buffer(buf, count, ppos, tbuf, len); 1483 1483 } ··· 1488 1488 { 1489 1489 char tbuf[20]; 1490 1490 char *ep; 1491 - time_t now; 1491 + time64_t now; 1492 1492 1493 1493 if (*ppos || count > sizeof(tbuf)-1) 1494 1494 return -EINVAL;
+5 -5
net/sunrpc/svcauth_unix.c
··· 166 166 } 167 167 168 168 static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class, struct in6_addr *addr); 169 - static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time_t expiry); 169 + static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time64_t expiry); 170 170 171 171 static int ip_map_parse(struct cache_detail *cd, 172 172 char *mesg, int mlen) ··· 187 187 188 188 struct ip_map *ipmp; 189 189 struct auth_domain *dom; 190 - time_t expiry; 190 + time64_t expiry; 191 191 192 192 if (mesg[mlen-1] != '\n') 193 193 return -EINVAL; ··· 308 308 } 309 309 310 310 static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, 311 - struct unix_domain *udom, time_t expiry) 311 + struct unix_domain *udom, time64_t expiry) 312 312 { 313 313 struct ip_map ip; 314 314 struct cache_head *ch; ··· 328 328 } 329 329 330 330 static inline int ip_map_update(struct net *net, struct ip_map *ipm, 331 - struct unix_domain *udom, time_t expiry) 331 + struct unix_domain *udom, time64_t expiry) 332 332 { 333 333 struct sunrpc_net *sn; 334 334 ··· 491 491 int rv; 492 492 int i; 493 493 int err; 494 - time_t expiry; 494 + time64_t expiry; 495 495 struct unix_gid ug, *ugp; 496 496 497 497 if (mesg[mlen - 1] != '\n')