mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched: Fix sched_policy < 0 comparison
@ 2014-06-02 20:38 Richard Weinberger
  2014-06-03  8:26 ` Peter Zijlstra
  2014-06-05 14:33 ` [tip:sched/urgent] " tip-bot for Richard Weinberger
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Weinberger @ 2014-06-02 20:38 UTC (permalink / raw)
  To: peterz; +Cc: linux-kernel, Richard Weinberger, Michael Kerrisk, Ingo Molnar

attr.sched_policy is u32, therefore a comparison against < 0 is never true.
Fix this by casting sched_policy to int.

This issue was reported by coverity CID 1219934.

Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b8cd08f..d579476 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3726,7 +3726,7 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
 	if (retval)
 		return retval;
 
-	if (attr.sched_policy < 0)
+	if ((int)attr.sched_policy < 0)
 		return -EINVAL;
 
 	rcu_read_lock();
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: Fix sched_policy < 0 comparison
  2014-06-02 20:38 [PATCH] sched: Fix sched_policy < 0 comparison Richard Weinberger
@ 2014-06-03  8:26 ` Peter Zijlstra
  2014-06-05 14:33 ` [tip:sched/urgent] " tip-bot for Richard Weinberger
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2014-06-03  8:26 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-kernel, Michael Kerrisk, Ingo Molnar

[-- Attachment #1: Type: text/plain, Size: 448 bytes --]

On Mon, Jun 02, 2014 at 10:38:34PM +0200, Richard Weinberger wrote:
> attr.sched_policy is u32, therefore a comparison against < 0 is never true.
> Fix this by casting sched_policy to int.
> 
> This issue was reported by coverity CID 1219934.
> 
> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Richard Weinberger <richard@nod.at>

Thanks!

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:sched/urgent] sched: Fix sched_policy < 0 comparison
  2014-06-02 20:38 [PATCH] sched: Fix sched_policy < 0 comparison Richard Weinberger
  2014-06-03  8:26 ` Peter Zijlstra
@ 2014-06-05 14:33 ` tip-bot for Richard Weinberger
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Richard Weinberger @ 2014-06-05 14:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, torvalds, peterz, richard, tglx, mtk.manpages

Commit-ID:  b14ed2c273f8ab872ae4e6735fe5ab09cb14b8c3
Gitweb:     http://git.kernel.org/tip/b14ed2c273f8ab872ae4e6735fe5ab09cb14b8c3
Author:     Richard Weinberger <richard@nod.at>
AuthorDate: Mon, 2 Jun 2014 22:38:34 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Jun 2014 11:07:43 +0200

sched: Fix sched_policy < 0 comparison

attr.sched_policy is u32, therefore a comparison against < 0 is never true.
Fix this by casting sched_policy to int.

This issue was reported by coverity CID 1219934.

Fixes: dbdb22754fde ("sched: Disallow sched_attr::sched_policy < 0")
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1401741514-7045-1-git-send-email-richard@nod.at
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 86f3890..540542b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3685,7 +3685,7 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
 	if (retval)
 		return retval;
 
-	if (attr.sched_policy < 0)
+	if ((int)attr.sched_policy < 0)
 		return -EINVAL;
 
 	rcu_read_lock();

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-05 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-02 20:38 [PATCH] sched: Fix sched_policy < 0 comparison Richard Weinberger
2014-06-03  8:26 ` Peter Zijlstra
2014-06-05 14:33 ` [tip:sched/urgent] " tip-bot for Richard Weinberger

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