From: Konstantin Khlebnikov <khlebni...@yandex-team.ru>

[ Upstream commit 4c47acd824aaaa8fc6dc519fb4e08d1522105b7a ]

Add limit into sscanf format string for on-stack buffer.

Signed-off-by: Konstantin Khlebnikov <khlebni...@yandex-team.ru>
Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Acked-by: Tejun Heo <t...@kernel.org>
Cc: Andy Lutomirski <l...@kernel.org>
Cc: Borislav Petkov <b...@alien8.de>
Cc: Dave Hansen <dave.han...@linux.intel.com>
Cc: H. Peter Anvin <h...@zytor.com>
Cc: Johannes Weiner <han...@cmpxchg.org>
Cc: Li Zefan <lize...@huawei.com>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Rik van Riel <r...@surriel.com>
Cc: Thomas Gleixner <t...@linutronix.de>
Fixes: 0d5936344f30 ("sched: Implement interface for cgroup unified hierarchy")
Link: 
https://lkml.kernel.org/r/155189230232.2620.13120481613524200065.stgit@buzz
Signed-off-by: Ingo Molnar <mi...@kernel.org>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
 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 d8d76a65cfdd..e843fbd9012e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6941,7 +6941,7 @@ static int __maybe_unused cpu_period_quota_parse(char 
*buf,
 {
        char tok[21];   /* U64_MAX */
 
-       if (!sscanf(buf, "%s %llu", tok, periodp))
+       if (sscanf(buf, "%20s %llu", tok, periodp) < 1)
                return -EINVAL;
 
        *periodp *= NSEC_PER_USEC;
-- 
2.19.1

Reply via email to