From 2c8cf3e2b98250121da08fd06340449177491750 Mon Sep 17 00:00:00 2001 From: wanxiaoqing Date: Wed, 7 Feb 2024 09:18:18 +0800 Subject: [PATCH] settimeofday test Signed-off-by: wanxiaoqing --- include/linux/time64.h | 4 ++++ kernel/time/time.c | 5 +++-- kernel/time/timekeeping.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/time64.h b/include/linux/time64.h index 5117cb5b5656..96a062f14465 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; @@ -86,6 +87,7 @@ static inline struct timespec64 timespec64_sub(struct timespec64 lhs, */ static inline bool timespec64_valid(const struct timespec64 *ts) { + pr_err("[ywr_debug] FUNC: %s;Incoming data: %d\n",__func__,ts->tv_sec); /* Dates before 1970 are bogus */ if (ts->tv_sec < 0) return false; @@ -107,9 +109,11 @@ static inline bool timespec64_valid_strict(const struct timespec64 *ts) static inline bool timespec64_valid_settod(const struct timespec64 *ts) { + pr_err("[ywr_debug] FUNC: %s;Incoming data: %d\n",__func__,ts->tv_sec); if (!timespec64_valid(ts)) return false; /* Disallow values which cause overflow issues vs. CLOCK_REALTIME */ + pr_err("[ywr_debug] FUNC: %s;TIME_SETTOD_SEC_MAX: %d\n",__func__,TIME_SETTOD_SEC_MAX); if ((unsigned long long)ts->tv_sec >= TIME_SETTOD_SEC_MAX) return false; return true; diff --git a/kernel/time/time.c b/kernel/time/time.c index 3985b2b32d08..6447b0a132b6 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -201,7 +202,7 @@ SYSCALL_DEFINE2(settimeofday, struct __kernel_old_timeval __user *, tv, { struct timespec64 new_ts; struct timezone new_tz; - + pr_err("[ywr_debug] FUNC: %s;Incoming data: %d\n",__func__,tv->tv_sec); if (tv) { if (get_user(new_ts.tv_sec, &tv->tv_sec) || get_user(new_ts.tv_nsec, &tv->tv_usec)) @@ -245,7 +246,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv, { struct timespec64 new_ts; struct timezone new_tz; - + pr_err("[ywr_debug] FUNC: %s;Incoming data: %d\n",__func__,tv->tv_sec); if (tv) { if (get_user(new_ts.tv_sec, &tv->tv_sec) || get_user(new_ts.tv_nsec, &tv->tv_usec)) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index d9b48f7a35e0..c61fb899d37c 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" @@ -1302,7 +1303,7 @@ int do_settimeofday64(const struct timespec64 *ts) struct timespec64 ts_delta, xt; unsigned long flags; int ret = 0; - + pr_err("[ywr_debug] FUNC: %s;Incoming data: %d\n",__func__,ts->tv_sec); if (!timespec64_valid_settod(ts)) return -EINVAL; -- Gitee