]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched/uclamp: Reject negative values in cpu_uclamp_write()
authorQais Yousef <qais.yousef@arm.com>
Tue, 14 Jan 2020 21:09:47 +0000 (21:09 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Feb 2020 18:54:10 +0000 (19:54 +0100)
commitafc7f1919c573c8e802ca5edf6627419f66eb554
tree90385e5e7e67d47ae38bbe9e9c55b5c40f25b1fc
parentacac3bcff8e07fd99abb18836a1fbe231aa8f0b6
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>
kernel/sched/core.c