提交 4234e575 编写于 作者: Z zhengbin 提交者: Xie XiuQi

time: Validate user input in compat_settimeofday()

mainline inclusion
from mainline-v5.2
commit 9176ab1b848059a0cd9caf39f0cebaa1b7ec5ec2
category: bugfix
bugzilla: 16631
CVE: NA
---------------------------

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: Nzhengbin <zhengbin13@huawei.com>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/1562460701-113301-1-git-send-email-zhengbin13@huawei.comSigned-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 775b3ed5
...@@ -251,6 +251,10 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, ...@@ -251,6 +251,10 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
if (tv) { if (tv) {
if (compat_get_timeval(&user_tv, tv)) if (compat_get_timeval(&user_tv, tv))
return -EFAULT; return -EFAULT;
if (!timeval_valid(&user_tv))
return -EINVAL;
new_ts.tv_sec = user_tv.tv_sec; new_ts.tv_sec = user_tv.tv_sec;
new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC; new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册