x86/IDT: Fix IDT generation for INT $0x80
PATCH 1/1 x86/IDT: Fix IDT generation for INT $0x80
When PV is enabled, entry_int80 needs to be DPL3, not DPL0.
This causes the XSA-259 PoC to fail with:
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR
(Clearly I have a bug in XTF's rendering of the error code too.)
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Luca Fancellu <[email protected]>
--- xen/arch/x86/include/asm/gen-idt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/include/asm/gen-idt.h +1 -1
@@ -77,7 +77,7 @@ GEN16(6);GEN16 (7 );#ifdef CONFIG_PV -GEN (0x80 , entry_int80,DPL0 , manual); +GEN (0x80 , entry_int80,DPL3 , manual);#else GEN (0x80 , entry_0x80,DPL0 , autogen);#endif
Signature · 1 line
2.39.5
Quoted 11 lines · Andrew Cooper
When PV is enabled,
entry_int80needs to be DPL3, not DPL0.This causes the XSA-259 PoC to fail with:
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault0x800d0802, #GP[IDT[256]] Test result: ERROR(Clearly I have a bug in XTF's rendering of the error code too.)
Adjusted locally.
~Andrew
Quoted 23 lines
Reported-by Luca Fancellu <[email protected]>Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Luca Fancellu <[email protected]>--- xen/arch/x86/include/asm/gen-idt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/include/asm/gen-idt.h +1
-1@@ -77,7 +77,7 @@ GEN16(6);GEN16 (7 );#ifdef CONFIG_PV -GEN (0x80 , entry_int80,DPL0 , manual); +GEN (0x80 , entry_int80,DPL3 , manual);#else GEN (0x80 , entry_0x80,DPL0 , autogen);#endif
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Andrew Cooper
When PV is enabled,
entry_int80needs to be DPL3, not DPL0.This causes the XSA-259 PoC to fail with:
Quoted 7 lines
Quoted 7 lines
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault0x800d0802, #GP[IDT[256]] Test result: ERROR(Clearly I have a bug in XTF's rendering of the error code too.)
Nope, it's a QEMU bug. Under QEMU, we get:
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels)
XSA-259 PoC
(XEN) [ 3.982447] *** #GP/IDT ec 00000802
(XEN) [ 3.982668] *** #GP/IDT ec 00000802, not permitted (XEN) [ 3.982849] *** #GP inject ec 00000802
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR
On real hardware:
(d1) --- Xen Test Framework ---
(d1) Environment: PV 64bit (Long mode 4 levels)
(d1) XSA-259 PoC
(XEN) *** #GP/IDT ec 00000402
(XEN) *** #GP/IDT ec 00000402, not permitted
(XEN) *** #GP inject ec 00000402
(d1) Success: Not vulnerable to XSA-259
(d1) Test result: SUCCESS
So it's by chance that Luca's testing even picked up this failure. The XSA-259 PoC can't distinguish between the #GP INT emulation path and the INT80 fastpath's error path which injects #GP.
~Andrew
Quoted 36 lines · Andrew Cooper
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Andrew Cooper
When PV is enabled,
entry_int80needs to be DPL3, not DPL0.This causes the XSA-259 PoC to fail with:
Quoted 7 lines
Quoted 7 lines
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault0x800d0802, #GP[IDT[256]] Test result: ERROR(Clearly I have a bug in XTF's rendering of the error code too.)
Nope, it's a QEMU bug. Under QEMU, we get:
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels)
XSA-259 PoC
(XEN) [ 3.982447] *** #GP/IDT ec 00000802
(XEN) [ 3.982668] *** #GP/IDT ec 00000802, not permitted (XEN) [ 3.982849] *** #GP inject ec 00000802
Error: Unexpected fault0x800d0802, #GP[IDT[256]] Test result: ERROROn real hardware:
(d1) --- Xen Test Framework ---
(d1) Environment: PV 64bit (Long mode 4 levels)
(d1) XSA-259 PoC
(XEN) *** #GP/IDT ec 00000402
(XEN) *** #GP/IDT ec 00000402, not permitted
(XEN) *** #GP inject ec 00000402
(d1) Success: Not vulnerable to XSA-259
(d1) Test result: SUCCESS
Quoted 3 lines
So it's by chance that Luca's testing even picked up this failure. The XSA-259 PoC can't distinguish between the #GP INT emulation path and the INT80 fastpath's error path which injects #GP.
And a patch submitted.
https://lore.kernel.org/qemu-devel/[email protected]/T/#u
~Andrew
Jan Beulich
Reviewed-byQuoted 11 lines · Andrew Cooper
Quoted 10 lines · Andrew Cooper
When PV is enabled,
entry_int80needs to be DPL3, not DPL0.This causes the XSA-259 PoC to fail with:
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault0x800d0802, #GP[IDT[256]] Test result: ERROR
Quoted 3 lines
Quoted 1 line
(Clearly I have a bug in XTF's rendering of the error code too.)
Fixes 3da2149cf4dc ("x86/IDT: Generate bsp_idt[] at build time")
Jan
Hi Andrew,
Quoted 12 lines · Andrew Cooper
When PV is enabled,
entry_int80needs to be DPL3, not DPL0.This causes the XSA-259 PoC to fail with:
--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault0x800d0802, #GP[IDT[256]] Test result: ERROR
Quoted 4 lines
(Clearly I have a bug in XTF's rendering of the error code too.)
Reported-by Luca Fancellu <[email protected]>Signed-off-by Andrew Cooper <[email protected]>
I’ve runned XTF on this one and I confirm it solves the issue: