mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Anton Blanchard <anton@samba.org>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, anton@samba.org, hpa@zytor.com,
	mingo@redhat.com, travis@sgi.com, torvalds@linux-foundation.org,
	peterz@infradead.org, rja@sgi.com, sharyath@in.ibm.com,
	drepper@redhat.com, steiner@sgi.com, tglx@linutronix.de,
	kosaki.motohiro@jp.fujitsu.com, mingo@elte.hu
Subject: [tip:sched/urgent] sched: Fix sched_getaffinity()
Date: Tue, 6 Apr 2010 08:32:20 GMT	[thread overview]
Message-ID: <tip-84fba5ec91f11c0efb27d0ed6098f7447491f0df@git.kernel.org> (raw)
In-Reply-To: <20100406070218.GM5594@kryten>

Commit-ID:  84fba5ec91f11c0efb27d0ed6098f7447491f0df
Gitweb:     http://git.kernel.org/tip/84fba5ec91f11c0efb27d0ed6098f7447491f0df
Author:     Anton Blanchard <anton@samba.org>
AuthorDate: Tue, 6 Apr 2010 17:02:19 +1000
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 6 Apr 2010 10:01:35 +0200

sched: Fix sched_getaffinity()

taskset on 2.6.34-rc3 fails on one of my ppc64 test boxes with
the following error:

  sched_getaffinity(0, 16, 0x10029650030) = -1 EINVAL (Invalid argument)

This box has 128 threads and 16 bytes is enough to cover it.

Commit cd3d8031eb4311e516329aee03c79a08333141f1 (sched:
sched_getaffinity(): Allow less than NR_CPUS length) is
comparing this 16 bytes agains nr_cpu_ids.

Fix it by comparing nr_cpu_ids to the number of bits in the
cpumask we pass in.

Signed-off-by: Anton Blanchard <anton@samba.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Sharyathi Nagesh <sharyath@in.ibm.com>
Cc: Ulrich Drepper <drepper@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jack Steiner <steiner@sgi.com>
Cc: Russ Anderson <rja@sgi.com>
Cc: Mike Travis <travis@sgi.com>
LKML-Reference: <20100406070218.GM5594@kryten>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 528a105..eaf5c73 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4902,7 +4902,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
 	int ret;
 	cpumask_var_t mask;
 
-	if (len < nr_cpu_ids)
+	if ((len * BITS_PER_BYTE) < nr_cpu_ids)
 		return -EINVAL;
 	if (len & (sizeof(unsigned long)-1))
 		return -EINVAL;

      parent reply	other threads:[~2010-04-06  8:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06  7:02 [PATCH] sched: Fix sched_getaffinity Anton Blanchard
2010-04-06  7:20 ` KOSAKI Motohiro
2010-04-06  8:32 ` tip-bot for Anton Blanchard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-84fba5ec91f11c0efb27d0ed6098f7447491f0df@git.kernel.org \
    --to=anton@samba.org \
    --cc=drepper@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rja@sgi.com \
    --cc=sharyath@in.ibm.com \
    --cc=steiner@sgi.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=travis@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome