Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()

From: Nadav Amit
Date: Tue Oct 17 2023 - 18:07:03 EST




> On Oct 18, 2023, at 12:53 AM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> but none of this should even matter, because by the time we actually
> *schedule* that thread, we'll set active_mm to the right thing.
>
> Can anybody see what's up?

Could it be related to exec_mmap() -> exec_mm_release() -> mm_release() -> deactivate_mm() ?

#define deactivate_mm(tsk, mm) \
do { \
if (!tsk->vfork_done) \
shstk_free(tsk); \
load_gs_index(0); \
loadsegment(fs, 0); \
} while (0)

We change gs_index(), so perhaps it affects later GS reads. There is also this
X86_BUG_NULL_SEG. Need to dive deeper; just initial thoughts though (i.e., I might be
completely off).