sched: Defend cfs and rt bandwidth quota against overflow
commit28a007bcf9c53509989d840ea57a2e79b4f14dc7
authorHuaixin Chang <changhuaixin@linux.alibaba.com>
Sat, 25 Apr 2020 10:52:48 +0000 (25 18:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:32:46 +0000 (22 09:32 +0200)
treeb32f688a5498760002edc0c7a438e2b7473b0f91
parent04e15b88e9c8c3fd1acaf833bb82faf405d4e0c7
sched: Defend cfs and rt bandwidth quota against overflow

[ Upstream commit d505b8af58912ae1e1a211fabc9995b19bd40828 ]

When users write some huge number into cpu.cfs_quota_us or
cpu.rt_runtime_us, overflow might happen during to_ratio() shifts of
schedulable checks.

to_ratio() could be altered to avoid unnecessary internal overflow, but
min_cfs_quota_period is less than 1 << BW_SHIFT, so a cutoff would still
be needed. Set a cap MAX_BW for cfs_quota_us and rt_runtime_us to
prevent overflow.

Signed-off-by: Huaixin Chang <changhuaixin@linux.alibaba.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Ben Segall <bsegall@google.com>
Link: https://lkml.kernel.org/r/20200425105248.60093-1-changhuaixin@linux.alibaba.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/sched/core.c
kernel/sched/rt.c
kernel/sched/sched.h