Re: [PATCH] sched/x86: Save [ER]FLAGS on context switch

From: Andy Lutomirski
Date: Thu Feb 21 2019 - 17:06:32 EST





> On Feb 21, 2019, at 4:46 AM, Will Deacon <will.deacon@xxxxxxx> wrote:
>
>> On Wed, Feb 20, 2019 at 02:55:59PM -0800, H. Peter Anvin wrote:
>>> On 2/19/19 4:48 AM, Will Deacon wrote:
>>>
>>> I think you'll still hate this, but could we not disable preemption during
>>> the uaccess-enabled region, re-enabling it on the fault path after we've
>>> toggled uaccess off and disable it again when we return back to the
>>> uaccess-enabled region? Doesn't help with tracing, but it should at least
>>> handle the common case.
>>>
>>
>> There is a worse problem with this, I still realize: this would mean blocking
>> preemption across what could possibly be a *very* large copy_from_user(), for
>> example.
>
> I don't think it's legitimate to call copy_{to,from}_user() inside a
> user_access_{begin,end} region. You'd need to add some unsafe variants,
> which could periodically disable uaccess and call cond_resched() inside
> the loop to avoid the problem you're eluding to.
>

Definitely not safe. On x86 they do CLAC and everything breaks.