Re: [PATCH 00/17] sched/mmcid: fixes for execve, mode switches and affinity

From: Thomas Gleixner

Date: Sat Nov 28 2026 - 17:41:02 EST


On Sat, Nov 28 2026 at 20:22, Karl Mehltretter wrote:
> On Sat, 28 Nov 2026 11:28:05 +0100, Thomas Gleixner wrote:
>> + /*
>> + * Reactivating MM CID is only required for the success case. The
>> + * exec()'ing task deactivates MM CID after bprm->point_of_no_return has
>> + * been set true, so any failure after that point will prevent the task
>> + * from going back to user space.
>> + */
>> sched_mm_cid_after_execve(current);
>
> That doesn't hold under ptrace.
>
> bprm_execve() uses force_fatal_sig(SIGSEGV), so a tracer can suppress the
> SIGSEGV with PTRACE_CONT(pid, 0) and let the task return to user space with
> mm_cid.active == 0 and mm_cid == MM_CID_UNSET.
>
> I reproduced this on tip/sched/core (arm64 KVM, RT and !RT). A traced
> child unregisters its rseq area and calls execve() on a static ELF with
> an invalid e_entry, which fails in load_elf_binary() after
> begin_new_exec() has already run.
>
> The tracer catches SIGSEGV, sets PC to the mapped _start, and continues with
> signal 0. The child then registers a new rseq area and reads mm_cid:

TBH, I hate ptrace and the completely made up use cases which come with it.

I'll think about that tomorrow with brain awake, but I really want to
avoid all these corner case conditionals and the re-initialization. This
code has already grown too many warts again...

Thanks,

tglx