diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c index 3783d07d60ba038736e6566eecc9d72b00fe6487..3aee5a0c61ed54cab050603036e7c56c43727c12 100644 --- a/kernel/time/posix-stubs.c +++ b/kernel/time/posix-stubs.c @@ -250,4 +250,4 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags, HRTIMER_MODE_ABS : HRTIMER_MODE_REL, which_clock); } -#endif +#endif \ No newline at end of file diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 7a18690e511012cb09c9b837c0cfb90293d19790..e5555b48b3fd87d443c7305eed5a0ab69b3baf90 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,21 @@ 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) - return -EINVAL; - - if (get_timespec64(&new_tp, tp)) + if (!kc || !kc->clock_set){ + pr_err("wt:timers 1"); + return -EINVAL; + } + pr_err("wt:timers 2"); + if (get_timespec64(&new_tp, tp)){ + pr_err("wt:timers 3"); return -EFAULT; + } + pr_err("wt:timers 4"); return kc->clock_set(which_clock, &new_tp); } @@ -1423,4 +1430,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..441d47c98ba8a4b030e954c65975331a4d816628 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -43,6 +43,8 @@ #include #include "timekeeping.h" +#include + /* * The timezone where the local system is located. Used as a default by some * programs who obtain this value by using gettimeofday. @@ -168,16 +170,23 @@ 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)) + if (tv && !timespec64_valid_settod(tv)){ + pr_err("wt:do_sys_settimeofday64 1"); return -EINVAL; + } + error = security_settime64(tv, tz); - if (error) + if (error){ + pr_err("wt:do_sys_settimeofday64 2"); return error; + } + pr_err("wt:do_sys_settimeofday64 3"); if (tz) { /* Verify we're within the +-15 hrs range */ if (tz->tz_minuteswest > 15*60 || tz->tz_minuteswest < -15*60) @@ -191,8 +200,11 @@ 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 5"); return do_settimeofday64(tv); + } + return 0; } @@ -781,6 +793,7 @@ struct timespec64 timespec64_add_safe(const struct timespec64 lhs, int get_timespec64(struct timespec64 *ts, const struct __kernel_timespec __user *uts) { + pr_err("wt:get_timespec64 0"); struct __kernel_timespec kts; int ret; @@ -788,6 +801,7 @@ int get_timespec64(struct timespec64 *ts, if (ret) return -EFAULT; + ts->tv_sec = kts.tv_sec; /* Zero out the padding in compat mode */ @@ -906,4 +920,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..df3d8b21b136c04b7fc34fc74c7e3d7b625da0fc 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" @@ -1298,13 +1299,16 @@ EXPORT_SYMBOL_GPL(get_device_system_crosststamp); */ int do_settimeofday64(const struct timespec64 *ts) { + pr_err("wt:do_settimeofday64 0"); struct timekeeper *tk = &tk_core.timekeeper; struct timespec64 ts_delta, xt; unsigned long flags; int ret = 0; - if (!timespec64_valid_settod(ts)) + if (!timespec64_valid_settod(ts)){ + pr_err("wt:do_settimeofday64 1"); return -EINVAL; + } raw_spin_lock_irqsave(&timekeeper_lock, flags); write_seqcount_begin(&tk_core.seq); @@ -1314,7 +1318,9 @@ int do_settimeofday64(const struct timespec64 *ts) xt = tk_xtime(tk); ts_delta = timespec64_sub(*ts, xt); + pr_err("wt:do_settimeofday64 2"); if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) { + pr_err("wt:do_settimeofday64 3"); ret = -EINVAL; goto out; } @@ -1336,6 +1342,7 @@ int do_settimeofday64(const struct timespec64 *ts) add_device_randomness(ts, sizeof(*ts)); } + pr_err("wt:do_settimeofday64 4"); return ret; } EXPORT_SYMBOL(do_settimeofday64); @@ -2495,4 +2502,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