Re: [tip:sched/core] [sched] af7f588d8f: WARNING:at_kernel/sched/core.c:#sched_mm_cid_after_execve

From: Mathieu Desnoyers
Date: Fri Dec 30 2022 - 08:46:47 EST


On 2022-12-30 01:48, kernel test robot wrote:
Greeting,

FYI, we noticed WARNING:at_kernel/sched/core.c:#sched_mm_cid_after_execve due to commit (built with gcc-11):

[...]

[ 17.747520][ T48] bprm_execve (exec.c:?)
[ 17.748358][ T48] ? call_usermodehelper_exec_work (umh.c:?)
[ 17.749462][ T48] kernel_execve (??:?)
[ 17.750332][ T48] call_usermodehelper_exec_async (umh.c:?)
[ 17.751363][ T48] ? call_usermodehelper_exec_work (umh.c:?)
[ 17.752163][ T48] ret_from_fork (??:?)

I suspect this check:

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);

is too strict. AFAIU the usermodehelper thread is a kernel thread, which happens to have a non-NULL mm after execve. We want to allow usermodehelper threads to use rseq, so I think the appropriate approach here would be to just warn if !t->mm:

WARN_ON_ONCE(!t->mm);

We should probably apply a similar change to the warning in sched_mm_cid_fork() as well.

Thoughts ?

Thanks,

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com