Re: objtool clac/stac handling change..
From: Andy Lutomirski
Date: Wed Jul 01 2020 - 16:36:28 EST
> On Jul 1, 2020, at 12:35 PM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> ïOn Wed, Jul 1, 2020 at 11:29 AM Andy Lutomirski <luto@xxxxxxxxxx> wrote:
>>
>> Do we really want the exception handling to do the CLAC? Having
>> unsafe_get_user() do CLAC seems surprising to me, and it will break
>> use cases like:
>>
>> if (!user_access_begin(...)
>> goto out;
>>
>> ret = unsafe_get_user(...);
>>
>> user_access_end();
>>
>> check ret;
>
> That's not how unsafe_get_user() works.
>
> unsafe_get_user() always jumps to the error label, it never returns a
> value. So the code is actually now what you claim above, but
>
> if (!user_access_begin(...)
> goto out;
>
> unsafe_get_user(..., out_fault);
> user_access_end();
> .. this is good, use the value we got..
>
> out_fault:
> user_access_end();
> out:
> return -EFAULT;
Ugh, right. But maybe, with the asm goto magic, we canât get rid of this. Iâve always disliked the pattern where we enable user access, do a bunch of accesses that branch on error, and finish up. We ought to be able to do it the way I described and get decent code generation too.
If we do this extable change, we end up with a different mess: some exception handlers will clear AC and some wonât. Iâm sure objtool can deal with this with some effort, but Iâm not convinced itâs worth it.