Skip to contentSkip to conversation

sched: Fix concurrency ID handling of usermodehelper kthreads

RFC PATCH New Mathieu Desnoyers 1 participant 1 message Jan 2, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 sched: Fix concurrency ID handling of usermodehelper kthreads

sched_mm_cid_after_execve does not expect NULL t->mm, but it may happen if a usermodehelper kthread fails when attempting to execute a binary.

sched_mm_cid_fork can be issued from a usermodehelper kthread, which has t->flags PF_KTHREAD set.

---
 kernel/sched/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/core.c +3 -3
index 048ec2417990..f99ee69867e3 100644
@@ -11343,8 +11343,8 @@ void sched_mm_cid_after_execve(struct task_struct *t)
 	struct mm_struct *mm = t->mm;
 	unsigned long flags;
 
-	WARN_ON_ONCE((t->flags & PF_KTHREAD) || !t->mm);
-
+	if (!mm)
+		return;
 	local_irq_save(flags);
 	t->mm_cid = mm_cid_get(mm);
 	t->mm_cid_active = 1;
@@ -11354,7 +11354,7 @@ void sched_mm_cid_after_execve(struct task_struct *t)
 
 void sched_mm_cid_fork(struct task_struct *t)
 {
-	WARN_ON_ONCE((t->flags & PF_KTHREAD) || !t->mm || t->mm_cid != -1);
+	WARN_ON_ONCE(!t->mm || t->mm_cid != -1);
 	t->mm_cid_active = 1;
 }
 #endif
Signature · 1 line
2.25.1