Re: [PATCH] x86/bhi: BHI mitigation can trigger warning in #DB handler

From: Andrew Cooper
Date: Thu May 23 2024 - 11:34:24 EST


On 23/05/2024 3:52 pm, Alexandre Chartre wrote:
>
> On 5/23/24 16:28, Dave Hansen wrote:
>> On 5/23/24 05:33, Alexandre Chartre wrote:
>>> The problem can be reproduced with the following sequence:
>>>
>>>   $ cat sysenter_step.c
>>>   int main()
>>>   { asm("pushf; pop %ax; bts $8,%ax; push %ax; popf; sysenter"); }
>>>
>>>   $ gcc -o sysenter_step sysenter_step.c
>>>
>>>   $ ./sysenter_step
>>>   Segmentation fault (core dumped)
>>>
>>> The program is expected to crash, and the #DB handler will issue a
>>> warning.
>>
>> Should we wrap up this gem and put it with the other entry selftests?
>
> It looks like tools/testing/selftests/x86/single_step_syscall.c tests
> sysenter with TF set but it doesn't check if the kernel issues any
> warning.

But shouldn't the SIGSEGV still cause the selftest to notice?

Also, there should be a selftest for NT.  (mis)handling of that will
take the entire kernel down.

AC for good measure too, as that's the other flag handled specially.

~Andrew