lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 01 Apr 2010 23:10:04 +0800
From:	Alex Shi <alex.shi@...el.com>
To:	linux-kernel@...r.kernel.org
Cc:	alex.shi@...el.com
Subject: [PATCH] sched: Fix sched_getaffinity(): Invalid argument issue


commit cd3d8031eb fixed NU_CPUS > 1024 issue for old glibc binary
code compatibility. But it forget another situation: if the
nr_cpu_ids < len, the system call will return  -EINVAL incorrectly.

The situation happened on my NHM-EP machine with 16 LCPUs.
$ taskset -c 0 ls
sched_getaffinity: Invalid argument
failed to get pid 0's affinity.

Signed-off-by: Alex Shi <alex.shi@...el.com>
---
 kernel/sched.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 49d2fa7..fb9661b 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4901,8 +4901,9 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
 {
 	int ret;
 	cpumask_var_t mask;
+	size_t retlen = min_t(size_t, nr_cpu_ids, cpumask_size());
 
-	if (len < nr_cpu_ids)
+	if (len < retlen)
 		return -EINVAL;
 	if (len & (sizeof(unsigned long)-1))
 		return -EINVAL;
@@ -4912,8 +4913,6 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
 
 	ret = sched_getaffinity(pid, mask);
 	if (ret == 0) {
-		size_t retlen = min_t(size_t, len, cpumask_size());
-
 		if (copy_to_user(user_mask_ptr, mask, retlen))
 			ret = -EFAULT;
 		else
-- 
1.6.3



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ