Skip to content

Commit bb2bc55

Browse files
umgwanakikbutiIngo Molnar
authored and
Ingo Molnar
committed
sched: Fix crash if cpuset_cpumask_can_shrink() is passed an empty cpumask
While creating an exclusive cpuset, we passed cpuset_cpumask_can_shrink() an empty cpumask (cur), and dl_bw_of(cpumask_any(cur)) made boom with it: CPU: 0 PID: 6942 Comm: shield.sh Not tainted 3.19.0-master #19 Hardware name: MEDIONPC MS-7502/MS-7502, BIOS 6.00 PG 12/26/2007 task: ffff880224552450 ti: ffff8800caab8000 task.ti: ffff8800caab8000 RIP: 0010:[<ffffffff81073846>] [<ffffffff81073846>] cpuset_cpumask_can_shrink+0x56/0xb0 [...] Call Trace: [<ffffffff810cb82a>] validate_change+0x18a/0x200 [<ffffffff810cc877>] cpuset_write_resmask+0x3b7/0x720 [<ffffffff810c4d58>] cgroup_file_write+0x38/0x100 [<ffffffff811d953a>] kernfs_fop_write+0x12a/0x180 [<ffffffff8116e1a3>] vfs_write+0xb3/0x1d0 [<ffffffff8116ed06>] SyS_write+0x46/0xb0 [<ffffffff8159ced6>] system_call_fastpath+0x16/0x1b Signed-off-by: Mike Galbraith <[email protected]> Acked-by: Zefan Li <[email protected]> Fixes: f82f804 ("sched/deadline: Ensure that updates to exclusive cpusets don't break AC") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 8190747 commit bb2bc55

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/sched/core.c

+3
Original file line numberDiff line numberDiff line change
@@ -4642,6 +4642,9 @@ int cpuset_cpumask_can_shrink(const struct cpumask *cur,
46424642
struct dl_bw *cur_dl_b;
46434643
unsigned long flags;
46444644

4645+
if (!cpumask_weight(cur))
4646+
return ret;
4647+
46454648
rcu_read_lock_sched();
46464649
cur_dl_b = dl_bw_of(cpumask_any(cur));
46474650
trial_cpus = cpumask_weight(trial);

0 commit comments

Comments
 (0)