projects
/
wrapfs-4.14.y.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9d4961a
)
sched/core: Check quota and period overflow at usec to nsec conversion
author
Konstantin Khlebnikov
<khlebnikov@yandex-team.ru>
Wed, 27 Feb 2019 08:10:20 +0000
(11:10 +0300)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Tue, 11 Jun 2019 10:23:58 +0000
(12:23 +0200)
[ Upstream commit
1a8b4540db732ca16c9e43ac7c08b1b8f0b252d8
]
Large values could overflow u64 and pass following sanity checks.
# echo
18446744073750000
> cpu.cfs_period_us
# cat cpu.cfs_period_us
40448
# echo
18446744073750000
> cpu.cfs_quota_us
# cat cpu.cfs_quota_us
40448
After this patch they will fail with -EINVAL.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link:
http://lkml.kernel.org/r/155125502079.293431.3947497929372138600.stgit@buzz
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/sched/core.c
patch
|
blob
|
history
diff --git
a/kernel/sched/core.c
b/kernel/sched/core.c
index d35a7d528ea667adee59aac713b85c8d24d2baf7..1ef2fb4bbd6bd8924c5de7ca7a74828f8b929f2a 100644
(file)
--- a/
kernel/sched/core.c
+++ b/
kernel/sched/core.c
@@
-8460,8
+8460,10
@@
int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us)
period = ktime_to_ns(tg->cfs_bandwidth.period);
if (cfs_quota_us < 0)
quota = RUNTIME_INF;
- else
+ else
if ((u64)cfs_quota_us <= U64_MAX / NSEC_PER_USEC)
quota = (u64)cfs_quota_us * NSEC_PER_USEC;
+ else
+ return -EINVAL;
return tg_set_cfs_bandwidth(tg, period, quota);
}
@@
-8483,6
+8485,9
@@
int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
{
u64 quota, period;
+ if ((u64)cfs_period_us > U64_MAX / NSEC_PER_USEC)
+ return -EINVAL;
+
period = (u64)cfs_period_us * NSEC_PER_USEC;
quota = tg->cfs_bandwidth.quota;