summaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
authorValentin Schneider <valentin.schneider@arm.com>2020-10-13 15:01:15 +0100
committerPeter Zijlstra <peterz@infradead.org>2020-11-10 18:39:02 +0100
commit885b3ba47aa5cc16550beb8a42181ad5e8302ceb (patch)
tree9e98ff4b31323748169fb1f43fb4093ff91bdd34 /kernel/sched/core.c
parent86fbcd3b4ba2c3e19daf705bc13d90fb53aab648 (diff)
downloadlinux-885b3ba47aa5cc16550beb8a42181ad5e8302ceb.tar.gz
linux-885b3ba47aa5cc16550beb8a42181ad5e8302ceb.tar.bz2
linux-885b3ba47aa5cc16550beb8a42181ad5e8302ceb.zip
sched: Deny self-issued __set_cpus_allowed_ptr() when migrate_disable()
migrate_disable(); set_cpus_allowed_ptr(current, {something excluding task_cpu(current)}); affine_move_task(); <-- never returns Signed-off-by: Valentin Schneider <valentin.schneider@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20201013140116.26651-1-valentin.schneider@arm.com
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e92d7853057c..88c6fcb3bb65 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2238,8 +2238,17 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
goto out;
}
- if (!(flags & SCA_MIGRATE_ENABLE) && cpumask_equal(&p->cpus_mask, new_mask))
- goto out;
+ if (!(flags & SCA_MIGRATE_ENABLE)) {
+ if (cpumask_equal(&p->cpus_mask, new_mask))
+ goto out;
+
+ if (WARN_ON_ONCE(p == current &&
+ is_migration_disabled(p) &&
+ !cpumask_test_cpu(task_cpu(p), new_mask))) {
+ ret = -EBUSY;
+ goto out;
+ }
+ }
/*
* Picking a ~random cpu helps in cases where we are changing affinity