]> git.baikalelectronics.ru Git - kernel.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)
committerIngo Molnar <mingo@kernel.org>
Tue, 28 Jan 2020 20:36:56 +0000 (21:36 +0100)
commiteebd1f82099ab2d37ad1747c4ff152c774045581
tree51ebb6a78780b085099f205877f23c0b7a58911b
parent355670a1891ff1ac39919827880060d7125cab38
sched/uclamp: Reject negative values in cpu_uclamp_write()

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: a09771b9e02d ("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
kernel/sched/core.c