diff --git a/include/linux/time64.h b/include/linux/time64.h index 5117cb5b56561878d10126cd2fbef4b65b46574b..b825810f0985a88efe4ee857f71c0845a07e6fe1 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -4,6 +4,7 @@ #include #include +#include typedef __s64 time64_t; typedef __u64 timeu64_t; @@ -90,8 +91,11 @@ static inline bool timespec64_valid(const struct timespec64 *ts) if (ts->tv_sec < 0) return false; /* Can't have more nanoseconds then a second */ - if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC) + if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC){ + pr_err("wt: timespec64_valid 1"); return false; + } + return true; } @@ -107,11 +111,18 @@ static inline bool timespec64_valid_strict(const struct timespec64 *ts) static inline bool timespec64_valid_settod(const struct timespec64 *ts) { - if (!timespec64_valid(ts)) + pr_err("wt: timespec64_valid_settod 0"); + if (!timespec64_valid(ts)){ + pr_err("wt:timespec64_valid_settod 1"); return false; + } + /* Disallow values which cause overflow issues vs. CLOCK_REALTIME */ - if ((unsigned long long)ts->tv_sec >= TIME_SETTOD_SEC_MAX) + if ((unsigned long long)ts->tv_sec >= TIME_SETTOD_SEC_MAX){ + pr_err("wt:timespec64_valid_settod 2"); return false; + } + return true; } @@ -160,4 +171,4 @@ static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns) extern struct timespec64 timespec64_add_safe(const struct timespec64 lhs, const struct timespec64 rhs); -#endif /* _LINUX_TIME64_H */ +#endif /* _LINUX_TIME64_H */ \ No newline at end of file diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 7a18690e511012cb09c9b837c0cfb90293d19790..f5d0778bc3a61471283776aef6fd1385e277b5fe 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "timekeeping.h" #include "posix-timers.h" @@ -1080,15 +1081,20 @@ void exit_itimers(struct task_struct *tsk) SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, const struct __kernel_timespec __user *, tp) { + pr_err("wt:timers 0"); const struct k_clock *kc = clockid_to_kclock(which_clock); struct timespec64 new_tp; - if (!kc || !kc->clock_set) + if (!kc || !kc->clock_set){ + pr_err("wt:timers 1"); return -EINVAL; + } + if (get_timespec64(&new_tp, tp)) return -EFAULT; + pr_err("wt:timers 2"); return kc->clock_set(which_clock, &new_tp); } @@ -1423,4 +1429,4 @@ static const struct k_clock *clockid_to_kclock(const clockid_t id) return NULL; return posix_clocks[array_index_nospec(idx, ARRAY_SIZE(posix_clocks))]; -} +} \ No newline at end of file diff --git a/kernel/time/time.c b/kernel/time/time.c index 3985b2b32d083e06acfee3c83f952426660dbe9d..8871b3579375f4da1159508ccb886c408a4ecf9e 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "timekeeping.h" @@ -168,12 +169,14 @@ SYSCALL_DEFINE2(gettimeofday, struct __kernel_old_timeval __user *, tv, int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz) { + pr_err("wt:do_sys_settimeofday64 0"); static int firsttime = 1; int error = 0; if (tv && !timespec64_valid_settod(tv)) return -EINVAL; + pr_err("wt:do_sys_settimeofday64 1"); error = security_settime64(tv, tz); if (error) return error; @@ -191,14 +194,17 @@ int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz timekeeping_warp_clock(); } } - if (tv) + if (tv){ + pr_err("wt:do_sys_settimeofday64 2"); return do_settimeofday64(tv); + } return 0; } SYSCALL_DEFINE2(settimeofday, struct __kernel_old_timeval __user *, tv, struct timezone __user *, tz) { + pr_err("SYSCALL_DEFINE2 settimeofday 0"); struct timespec64 new_ts; struct timezone new_tz; @@ -243,6 +249,7 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct old_timeval32 __user *, tv, COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv, struct timezone __user *, tz) { + pr_err("COMPAT_SYSCALL_DEFINE2 settimeofday 0"); struct timespec64 new_ts; struct timezone new_tz; @@ -906,4 +913,4 @@ int put_old_itimerspec32(const struct itimerspec64 *its, return -EFAULT; return 0; } -EXPORT_SYMBOL_GPL(put_old_itimerspec32); +EXPORT_SYMBOL_GPL(put_old_itimerspec32); \ No newline at end of file diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index d9b48f7a35e0dbcf48cb15be33f8875babf8594f..6f879cdeeef093f9ae84a35c22ca9953f8b31242 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "tick-internal.h" #include "ntp_internal.h" @@ -1303,9 +1304,12 @@ int do_settimeofday64(const struct timespec64 *ts) unsigned long flags; int ret = 0; - if (!timespec64_valid_settod(ts)) + if (!timespec64_valid_settod(ts)){ + pr_err("wt:do_settimeofday64 0"); return -EINVAL; + } + pr_err("wt:do_settimeofday64 1"); raw_spin_lock_irqsave(&timekeeper_lock, flags); write_seqcount_begin(&tk_core.seq); @@ -1315,6 +1319,7 @@ int do_settimeofday64(const struct timespec64 *ts) ts_delta = timespec64_sub(*ts, xt); if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) { + pr_err("wt:do_settimeofday64 2"); ret = -EINVAL; goto out; } @@ -1335,7 +1340,7 @@ int do_settimeofday64(const struct timespec64 *ts) audit_tk_injoffset(ts_delta); add_device_randomness(ts, sizeof(*ts)); } - + pr_err("wt:do_settimeofday64 3"); return ret; } EXPORT_SYMBOL(do_settimeofday64); @@ -2495,4 +2500,4 @@ void xtime_update(unsigned long ticks) write_seqcount_end(&jiffies_seq); raw_spin_unlock(&jiffies_lock); update_wall_time(); -} +} \ No newline at end of file