* [PATCH v2] time: compat settimeofday: Validate the values of tv from user
@ 2019-07-07 0:51 zhengbin
2019-07-07 10:10 ` [tip:timers/core] time: Validate user input in compat_settimeofday() tip-bot for zhengbin
0 siblings, 1 reply; 2+ messages in thread
From: zhengbin @ 2019-07-07 0:51 UTC (permalink / raw)
To: john.stultz, tglx, sboyd, linux-kernel; +Cc: yi.zhang, zhangxiaoxu5
Similar to commit 6ada1fc0e1c4
("time: settimeofday: Validate the values of tv from user"),
for a wide range of negative tv_usec values the multiplication overflow
turns them in positive numbers. So the 'validated later' is not catching
the invalid input.
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
kernel/time/time.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 7f7d691..5c54ca6 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -251,6 +251,10 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv,
if (tv) {
if (compat_get_timeval(&user_tv, tv))
return -EFAULT;
+
+ if (!timeval_valid(&user_tv))
+ return -EINVAL;
+
new_ts.tv_sec = user_tv.tv_sec;
new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:timers/core] time: Validate user input in compat_settimeofday()
2019-07-07 0:51 [PATCH v2] time: compat settimeofday: Validate the values of tv from user zhengbin
@ 2019-07-07 10:10 ` tip-bot for zhengbin
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for zhengbin @ 2019-07-07 10:10 UTC (permalink / raw)
To: linux-tip-commits; +Cc: mingo, tglx, hpa, linux-kernel, zhengbin13
Commit-ID: 9176ab1b848059a0cd9caf39f0cebaa1b7ec5ec2
Gitweb: https://git.kernel.org/tip/9176ab1b848059a0cd9caf39f0cebaa1b7ec5ec2
Author: zhengbin <zhengbin13@huawei.com>
AuthorDate: Sun, 7 Jul 2019 08:51:41 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 7 Jul 2019 12:05:40 +0200
time: Validate user input in compat_settimeofday()
The user value is validated after converting the timeval to a timespec, but
for a wide range of negative tv_usec values the multiplication overflow turns
them in positive numbers. So the 'validated later' is not catching the
invalid input.
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/1562460701-113301-1-git-send-email-zhengbin13@huawei.com
---
kernel/time/time.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 7f7d6914ddd5..5c54ca632d08 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -251,6 +251,10 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv,
if (tv) {
if (compat_get_timeval(&user_tv, tv))
return -EFAULT;
+
+ if (!timeval_valid(&user_tv))
+ return -EINVAL;
+
new_ts.tv_sec = user_tv.tv_sec;
new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-07 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-07 0:51 [PATCH v2] time: compat settimeofday: Validate the values of tv from user zhengbin
2019-07-07 10:10 ` [tip:timers/core] time: Validate user input in compat_settimeofday() tip-bot for zhengbin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox