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

From: Nadav Amit
Date: Mon Oct 16 2023 - 16:35:34 EST



> On Oct 16, 2023, at 10:24 PM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> So there's some serious corruption there, but from the oops itself I
> can't tell the source. I guess if we get 'current' wrong anywhere, all
> bets are off.

I don’t think it means that it the aliasing does not work; I think it all means that
it actually works *too well*.

I have encountered several such issues before [1], and while some have been fixed,
some have not (I looked at switch_fpu_finish()), and might under the right/wrong
circumstances use the wrongly-“cached” current. Moreover, perhaps new problems
have been added since my old patch.

Perhaps the whack-a-mole approach that I took in [1] is wrong. Instead, perhaps it
is better to use an uncached version of current when compiling
arch/x86/kernel/process_64.c and arch/x86/kernel/process_32.c , so they would not
use the const alias, but instead use the original (non-const) one. Some macro
magic and an additional "-D” build flag can do that.

But first, there is a need to confirm that’s actually the problem. I’ll try to do
it tomorrow.

Regards,
Nadav


[1] https://lore.kernel.org/all/20190823224424.15296-5-namit@xxxxxxxxxx/