]> xenbits.xensource.com Git - qemu-xen.git/commit
target/i386/tcg: Allow IRET from user mode to user mode with SMAP
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 11 Jun 2024 20:04:56 +0000 (22:04 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Jul 2024 16:18:24 +0000 (18:18 +0200)
commit0bd385e7e3c33e987d7a8879918be6df7b111ac4
treeec66fef17e5abf5c6f38c60ef820bf2472dc08bd
parenta7cf4949938743e9ecb73efcb51d27bd18d3c3fa
target/i386/tcg: Allow IRET from user mode to user mode with SMAP

This fixes a bug wherein i386/tcg assumed an interrupt return using
the IRET instruction was always returning from kernel mode to either
kernel mode or user mode. This assumption is violated when IRET is used
as a clever way to restore thread state, as for example in the dotnet
runtime. There, IRET returns from user mode to user mode.

This bug is that stack accesses from IRET and RETF, as well as accesses
to the parameters in a call gate, are normal data accesses using the
current CPL.  This manifested itself as a page fault in the guest Linux
kernel due to SMAP preventing the access.

This bug appears to have been in QEMU since the beginning.

Analyzed-by: Robert R. Henry <rrh.henry@gmail.com>
Co-developed-by: Robert R. Henry <rrh.henry@gmail.com>
Signed-off-by: Robert R. Henry <rrh.henry@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/tcg/seg_helper.c