]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
sched: Fix sched_policy < 0 comparison
authorRichard Weinberger <richard@nod.at>
Mon, 2 Jun 2014 20:38:34 +0000 (22:38 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 5 Jun 2014 09:07:43 +0000 (11:07 +0200)
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

index 86f3890c3d088a879c0f39896dc2125a79a79e5e..540542b93f9f9820fabb7c353907f391498bd4a2 100644 (file)
@@ -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();