Skip to contentSkip to conversation

Patch "KVM: x86: fix singlestepping over syscall" has been added to the 4.11-stable tree

PATCH [email protected] 1 participant 1 message Jun 26, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

KVM: x86: fix singlestepping over syscall

to the 4.11-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-fix-singlestepping-over-syscall.patch
and it can be found in the queue-4.11 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From c8401dda2f0a00cd25c0af6a95ed50e478d25de4 Mon Sep 17 00:00:00 2001

From: Paolo Bonzini <[email protected]>
Date: Wed, 7 Jun 2017 15:13:14 +0200
Subject: KVM: x86: fix singlestepping over syscall
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: Paolo Bonzini <[email protected]>

commit c8401dda2f0a00cd25c0af6a95ed50e478d25de4 upstream.

TF is handled a bit differently for syscall and sysret, compared to the other instructions: TF is checked after the instruction completes, so that the OS can disable #DB at a syscall by adding TF to FMASK. When the sysret is executed the #DB is taken "as if" the syscall insn just completed.

KVM emulates syscall so that it can trap 32-bit syscall on Intel processors. Fix the behavior, otherwise you could get #DB on a user stack which is not nice. This does not affect Linux guests, as they use an IST or task gate for #DB.

This fixes CVE-2017-7518.

---
 arch/x86/include/asm/kvm_emulate.h |    1 
 arch/x86/kvm/emulate.c             |    1 
 arch/x86/kvm/x86.c                 |   62 +++++++++++++++++++------------------
 3 files changed, 34 insertions(+), 30 deletions(-)
arch/x86/include/asm/kvm_emulate.h +1 -0
@@ -294,6 +294,7 @@ struct x86_emulate_ctxt {
 
 	bool perm_ok; /* do not check permissions if true */
 	bool ud;	/* inject an #UD if host doesn't support insn */
+	bool tf;	/* TF value before instruction (after for syscall/sysret) */
 
 	bool have_exception;
 	struct x86_exception exception;
arch/x86/kvm/emulate.c +1 -0
@@ -2742,6 +2742,7 @@ static int em_syscall(struct x86_emulate
 		ctxt->eflags &= ~(X86_EFLAGS_VM | X86_EFLAGS_IF);
 	}
 
+	ctxt->tf = (ctxt->eflags & X86_EFLAGS_TF) != 0;
 	return X86EMUL_CONTINUE;
 }
 
arch/x86/kvm/x86.c +32 -30

89 lines not on this page · raw message

Patches currently in stable-queue which might be from [email protected] are

queue-4.11/kvm-x86-fix-singlestepping-over-syscall.patch