x86/bhi: Avoid warning in #DB handler due to BHI mitigation
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
8f51637712e4da5be410a1666f8aee0d86eef898| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
x86/bhi: Avoid warning in #DB handler due to BHI mitigation
When BHI mitigation is enabled, if SYSENTER is invoked with the TF flag set then entry_SYSENTER_compat() uses CLEAR_BRANCH_HISTORY and calls the clear_bhb_loop() before the TF flag is cleared. This causes the #DB handler (exc_debug_kernel()) to issue a warning because single-step is used outside the entry_SYSENTER_compat() function.
To address this issue, entry_SYSENTER_compat() should use CLEAR_BRANCH_HISTORY after making sure the TF flag is cleared.
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)
From the CVE record · Linux
The Linux kernel's x86 SYSENTER path can trigger a debug-handler warning when BHI mitigation is enabled. A locally run program can cause the warning by invoking SYSENTER with the trap flag set; the example program also crashes.
Engineers running Linux kernels with BHI mitigation enabled should check whether their kernel is affected; affected versions were not provided.