aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQais Yousef <qais.yousef@arm.com>2020-01-14 21:09:47 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-19 19:53:07 +0100
commit9f6f61c61a84515d1533a0c71ab3159f39960236 (patch)
tree610fddaead598295a2f31f6c4e99e2fa64099213
parent115402ee80cef6560be9d3456b4e61eab0afcf52 (diff)
downloadlinux-yocto-9f6f61c61a84515d1533a0c71ab3159f39960236.tar.gz
linux-yocto-9f6f61c61a84515d1533a0c71ab3159f39960236.tar.bz2
linux-yocto-9f6f61c61a84515d1533a0c71ab3159f39960236.zip
sched/uclamp: Reject negative values in cpu_uclamp_write()
commit b562d140649966d4daedd0483a8fe59ad3bb465a upstream. The check to ensure that the new written value into cpu.uclamp.{min,max} is within range, [0:100], wasn't working because of the signed comparison 7301 if (req.percent > UCLAMP_PERCENT_SCALE) { 7302 req.ret = -ERANGE; 7303 return req; 7304 } # echo -1 > cpu.uclamp.min # cat cpu.uclamp.min 42949671.96 Cast req.percent into u64 to force the comparison to be unsigned and work as intended in capacity_from_percent(). # echo -1 > cpu.uclamp.min sh: write error: Numerical result out of range Fixes: 2480c093130f ("sched/uclamp: Extend CPU's cgroup controller") Signed-off-by: Qais Yousef <qais.yousef@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lkml.kernel.org/r/20200114210947.14083-1-qais.yousef@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--kernel/sched/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 00743684a549..dfaefb175ba0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7250,7 +7250,7 @@ capacity_from_percent(char *buf)
&req.percent);
if (req.ret)
return req;
- if (req.percent > UCLAMP_PERCENT_SCALE) {
+ if ((u64)req.percent > UCLAMP_PERCENT_SCALE) {
req.ret = -ERANGE;
return req;
}