Commit bbd0b031 authored by Mathieu Desnoyers's avatar Mathieu Desnoyers Committed by Borislav Petkov (AMD)

sched/rseq: 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.

Fixes: af7f588d ("sched: Introduce per-memory-map concurrency ID")
Reported-by: default avatarkernel test robot <yujie.liu@intel.com>
Reported-by: default avatarBorislav Petkov <bp@alien8.de>
Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/oe-lkp/202212301353.5c959d72-yujie.liu@intel.com
parent c8997020
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment