Re: [PATCH] x86/mpx: Correctly report do_mpx_bt_fault() failures to user-space

From: Dave Hansen
Date: Thu Apr 20 2017 - 11:45:42 EST


On 04/20/2017 05:08 AM, Joerg Roedel wrote:
>> do_mpx_bt_fault() can fail for a bunch of reasons:
>> * unexpected or invalid value in BNDCSR
>> * out of memory (physical or virtual)
>> * unresolvable fault walking/filling bounds tables
>> * !valid and non-empty bad entry in the bounds tables
>>
>> This will end up sending a signal that *looks* like a X86_TRAP_BR for
>> all of those, including those that are not really bounds-related, like
>> unresolvable faults. We also don't populate enough information in the
>> siginfo that gets delivered for userspace to resolve the fault.
>>
>> I'm not sure this patch is the right thing.
>
> The problem is, without this patch the trap_nr reported to user-space is
> 0, which maps to divide-by-zero. I think this is wrong, and since all
> failure cases from do_mpx_bt_fault() can only happen in the #BR
> exception handler, I think that reporting X86_TRAP_BR for all failure
> cases is the right thing to do.

Urg, that does sound bogus.

How about doing X86_TRAP_PF? That would at least be consistent with
SIGBUS, which is probably the closest thing to a generic error code that
we have.