x86/emul: Reject LGDT/LIDT attempts with non-canonical base addresses
PATCH 1/1 x86/emul: Reject LGDT/LIDT attempts with non-canonical base addresses
No sane OS would deliberately try this, but make Xen's emulation match real hardware by delivering #GP(0), rather than suffering a VMEntry failure.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/x86_emulate/x86_emulate.c | 2 ++ 1 file changed, 2 insertions(+)
xen/arch/x86/x86_emulate/x86_emulate.c +2 -0
@@ -4443,6 +4443,8 @@ x86_emulate( (rc = read_ulong(ea.mem.seg, ea.mem.off+2, &base, mode_64bit() ? 8 : 4, ctxt, ops)) ) goto done; +generate_exception_if (mode_64bit () && + !is_canonical_address (base),EXC_GP ,0 ); sreg.base = base; sreg.limit = limit;if ( op_bytes ==2 )
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 02.11.16 at 15:52, <[email protected]> wrote:
No sane OS would deliberately try this, but make Xen's emulation match real hardware by delivering #GP(0), rather than suffering a VMEntry failure.
Signed-off-by Andrew Cooper <[email protected]>
albeit ...
xen/arch/x86/x86_emulate/x86_emulate.c x86_emulate( · line 4447
Quoted 8 lines
xen/arch/x86/x86_emulate/x86_emulate.c +2
-0@@ -4443,6 +4443,8 @@ x86_emulate( (rc = read_ulong(ea.mem.seg, ea.mem.off+2, &base, mode_64bit() ? 8 : 4, ctxt, ops)) ) goto done; +generate_exception_if (mode_64bit () && + !is_canonical_address (base),EXC_GP ,0 );
... I don't think the mode_64bit() part is needed.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 8 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 02.11.16 at 15:52, <[email protected]> wrote:
No sane OS would deliberately try this, but make Xen's emulation match real hardware by delivering #GP(0), rather than suffering a VMEntry failure.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>albeit ...
Quoted 9 lines
xen/arch/x86/x86_emulate/x86_emulate.c x86_emulate( · line 4447
Quoted 8 lines
xen/arch/x86/x86_emulate/x86_emulate.c +2
-0@@ -4443,6 +4443,8 @@ x86_emulate( (rc = read_ulong(ea.mem.seg, ea.mem.off+2, &base, mode_64bit() ? 8 : 4, ctxt, ops)) ) goto done; +generate_exception_if (mode_64bit () && + !is_canonical_address (base),EXC_GP ,0 );... I don't think the
mode_64bit()part is needed.
True - as we explicitly zero sreg to start with, the canonical base check is safe in all modes. I will drop it from v2.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 02.11.16 at 15:52, <[email protected]> wrote:
No sane OS would deliberately try this, but make Xen's emulation match real hardware by delivering #GP(0), rather than suffering a VMEntry failure.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel