[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200112235217.26647-1-qais.yousef@arm.com>
Date: Sun, 12 Jan 2020 23:52:17 +0000
From: Qais Yousef <qais.yousef@....com>
To: Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>
Cc: Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Patrick Bellasi <patrick.bellasi@...bug.net>,
linux-kernel@...r.kernel.org, Qais Yousef <qais.yousef@....com>
Subject: [PATCH] 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 }
Cast req.percent into u64 to force the comparison to be unsigned and
work as intended in capacity_from_percent().
Fixes: 2480c093130f ("sched/uclamp: Extend CPU's cgroup controller")
Signed-off-by: Qais Yousef <qais.yousef@....com>
---
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 90e4b00ace89..e66b131e3aeb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7254,7 +7254,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;
}
--
2.17.1
Powered by blists - more mailing lists