nanosleep: use copy_from_user instead of direct access

This commit is contained in:
NAKAMURA Gou
2015-09-17 21:37:48 +09:00
parent 7b32f2f73b
commit b3b752ba41

View File

@@ -5031,16 +5031,15 @@ SYSCALL_DECLARE(nanosleep)
unsigned long ts = rdtsc(); unsigned long ts = rdtsc();
/* Check validity of arguments */
if (copy_from_user(&_tv, tv, sizeof(*tv))) { if (copy_from_user(&_tv, tv, sizeof(*tv))) {
return -EFAULT; return -EFAULT;
} }
if (tv->tv_sec < 0 || tv->tv_nsec >= NS_PER_SEC) { if (_tv.tv_sec < 0 || _tv.tv_nsec >= NS_PER_SEC) {
return -EINVAL; return -EINVAL;
} }
nanosecs = tv->tv_sec * NS_PER_SEC + tv->tv_nsec; nanosecs = _tv.tv_sec * NS_PER_SEC + _tv.tv_nsec;
tscs = nanosecs * 1000 / ihk_mc_get_ns_per_tsc(); tscs = nanosecs * 1000 / ihk_mc_get_ns_per_tsc();
/* Spin wait */ /* Spin wait */