summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0019-sched-Deny-self-issued-__set_cpus_allowed_ptr-when-m.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches-rt/0019-sched-Deny-self-issued-__set_cpus_allowed_ptr-when-m.patch')
-rw-r--r--debian/patches-rt/0019-sched-Deny-self-issued-__set_cpus_allowed_ptr-when-m.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/debian/patches-rt/0019-sched-Deny-self-issued-__set_cpus_allowed_ptr-when-m.patch b/debian/patches-rt/0019-sched-Deny-self-issued-__set_cpus_allowed_ptr-when-m.patch
new file mode 100644
index 000000000..ca7d5923b
--- /dev/null
+++ b/debian/patches-rt/0019-sched-Deny-self-issued-__set_cpus_allowed_ptr-when-m.patch
@@ -0,0 +1,46 @@
+From 5857482efa6b272402feb4b063c4273e70dd67fb Mon Sep 17 00:00:00 2001
+From: Valentin Schneider <valentin.schneider@arm.com>
+Date: Fri, 23 Oct 2020 12:12:16 +0200
+Subject: [PATCH 019/323] sched: Deny self-issued __set_cpus_allowed_ptr() when
+ migrate_disable()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.10/older/patches-5.10.204-rt100.tar.xz
+
+ 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
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/sched/core.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/kernel/sched/core.c b/kernel/sched/core.c
+index b5f35b512577..3b7bb01eecc0 100644
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -2254,8 +2254,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
+--
+2.43.0
+