Re: [kernel-hardening] [PATCH v4 26/29] sched: Allow putting thread_info into task_struct

From: Linus Torvalds
Date: Mon Jul 11 2016 - 12:42:49 EST


On Mon, Jul 11, 2016 at 9:31 AM, Mark Rutland <mark.rutland@xxxxxxx> wrote:
>>
>> So until you do the wire that actually disables preemption you can
>> schedule away as much as you want, and after that write you no longer
>> will.
>
> I was assuming a percpu pointer to current (or preempt count).

So for the same reason that is ok *iff* you have

- some kind of dedicated percpu register (or other base pointer - x86
has the segment thing) that gets updated when you schedule.

- an instruction that can load 'current' directly off that register atomically.

But yes, percpu data in general is obviously not safe to access
without preemption.

Linus