struct timex is not y2038 safe. Replace all uses of timex with y2038 safe __kernel_timex. Note that struct __kernel_timex is an ABI interface definition. We could define a new structure based on __kernel_timex that is only available internally instead. Right now, there isn't a strong motivation for this as the structure is isolated to a few defined struct timex interfaces and such a structure would be exactly the same as struct timex. The patch was generated by the following coccinelle script: virtual patch @depends on patch forall@ identifier ts; expression e; @@ ( - struct timex ts; + struct __kernel_timex ts; | - struct timex ts = {}; + struct __kernel_timex ts = {}; | - struct timex ts = e; + struct __kernel_timex ts = e; | - struct timex *ts; + struct __kernel_timex *ts; | (memset \| copy_from_user \| copy_to_user \)(..., - sizeof(struct timex)) + sizeof(struct __kernel_timex)) ) @depends on patch forall@ identifier ts; identifier fn; @@ fn(..., - struct timex *ts, + struct __kernel_timex *ts, ...) { ... } @depends on patch forall@ identifier ts; identifier fn; @@ fn(..., - struct timex *ts) { + struct __kernel_timex *ts) { ... }
Showing the changes to include/linux (3 of 13 files). Show all
Unified · Split
| @@ -51,7 +51,7 @@ struct posix_clock; · 50 unmodified lines | |||
| 51 | struct posix_clock_operations { | 51 | struct posix_clock_operations { |
| 52 | struct module *owner; | 52 | struct module *owner; |
| 53 | 53 | ||
| 54 | int (*clock_adjtime)(struct posix_clock *pc, struct timex *tx); | 54 | int (*clock_adjtime)(struct posix_clock *pc, struct __kernel_timex *tx); |
| 55 | 55 | ||
| 56 | int (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts); | 56 | int (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts); |
| 57 | 57 | ||
| @@ -69,9 +69,9 @@ extern int get_old_itimerspec32(struct itimerspec64 *its, · 68 unmodified lines | |||
| 69 | const struct old_itimerspec32 __user *uits); | 69 | const struct old_itimerspec32 __user *uits); |
| 70 | extern int put_old_itimerspec32(const struct itimerspec64 *its, | 70 | extern int put_old_itimerspec32(const struct itimerspec64 *its, |
| 71 | struct old_itimerspec32 __user *uits); | 71 | struct old_itimerspec32 __user *uits); |
| 72 | struct timex; | 72 | struct __kernel_timex; |
| 73 | int get_old_timex32(struct timex *, const struct old_timex32 __user *); | 73 | int get_old_timex32(struct __kernel_timex *, const struct old_timex32 __user *); |
| 74 | int put_old_timex32(struct old_timex32 __user *, const struct timex *); | 74 | int put_old_timex32(struct old_timex32 __user *, const struct __kernel_timex *); |
| 75 | 75 | ||
| 76 | #if __BITS_PER_LONG == 64 | 76 | #if __BITS_PER_LONG == 64 |
| 77 | 77 | ||
| @@ -158,8 +158,8 @@ extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */ · 157 unmodified lines | |||
| 158 | #define NTP_INTERVAL_FREQ (HZ) | 158 | #define NTP_INTERVAL_FREQ (HZ) |
| 159 | #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) | 159 | #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) |
| 160 | 160 | ||
| 161 | extern int do_adjtimex(struct timex *); | 161 | extern int do_adjtimex(struct __kernel_timex *); |
| 162 | extern int do_clock_adjtime(const clockid_t which_clock, struct timex * ktx); | 162 | extern int do_clock_adjtime(const clockid_t which_clock, struct __kernel_timex * ktx); |
| 163 | 163 | ||
| 164 | extern void hardpps(const struct timespec64 *, const struct timespec64 *); | 164 | extern void hardpps(const struct timespec64 *, const struct timespec64 *); |
| 165 | 165 | ||