This is a note to let you know that I've just added the patch titled KVM: x86: emulator: em_sysexit should update ctxt->mode to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: kvm-x86-emulator-em_sysexit-should-update-ctxt-mode.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 5015bb89b58225f97df6ac44383e7e8c8662c8c9 Mon Sep 17 00:00:00 2001 From: Maxim Levitsky <mlevitsk@xxxxxxxxxx> Date: Tue, 25 Oct 2022 15:47:28 +0300 Subject: KVM: x86: emulator: em_sysexit should update ctxt->mode From: Maxim Levitsky <mlevitsk@xxxxxxxxxx> commit 5015bb89b58225f97df6ac44383e7e8c8662c8c9 upstream. SYSEXIT is one of the instructions that can change the processor mode, thus ctxt->mode should be updated after it. Note that this is likely a benign bug, because the only problematic mode change is from 32 bit to 64 bit which can lead to truncation of RIP, and it is not possible to do with sysexit, since sysexit running in 32 bit mode will be limited to 32 bit version. Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx> Message-Id: <20221025124741.228045-11-mlevitsk@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/x86/kvm/emulate.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2861,6 +2861,7 @@ static int em_sysexit(struct x86_emulate ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS); ctxt->_eip = rdx; + ctxt->mode = usermode; *reg_write(ctxt, VCPU_REGS_RSP) = rcx; return X86EMUL_CONTINUE; Patches currently in stable-queue which might be from mlevitsk@xxxxxxxxxx are queue-5.15/kvm-x86-emulator-update-the-emulation-mode-after-cr0-write.patch queue-5.15/kvm-x86-treat-dbs-from-the-emulator-as-fault-like-co.patch queue-5.15/kvm-x86-emulator-update-the-emulation-mode-after-rsm.patch queue-5.15/kvm-x86-emulator-introduce-emulator_recalc_and_set_mode.patch queue-5.15/kvm-x86-emulator-em_sysexit-should-update-ctxt-mode.patch queue-5.15/kvm-x86-trace-re-injected-exceptions.patch