]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
x86/kprobes: Fix JNG/JNLE emulation
authorNadav Amit <namit@vmware.com>
Sat, 13 Aug 2022 22:59:43 +0000 (15:59 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 17 Oct 2022 09:57:14 +0000 (11:57 +0200)
commitb11f12b21ada445397c43c07dbd5d63c480f7b1f
tree1d28773507e3bd04092873df499b510aafa3e737
parent10a4fc9499ac373fef6fbdcc3b09fdc97a6ca1e2
x86/kprobes: Fix JNG/JNLE emulation

BugLink: https://bugs.launchpad.net/bugs/1990564
commit 8924779df820c53875abaeb10c648e9cb75b46d4 upstream.

When kprobes emulates JNG/JNLE instructions on x86 it uses the wrong
condition. For JNG (opcode: 0F 8E), according to Intel SDM, the jump is
performed if (ZF == 1 or SF != OF). However the kernel emulation
currently uses 'and' instead of 'or'.

As a result, setting a kprobe on JNG/JNLE might cause the kernel to
behave incorrectly whenever the kprobe is hit.

Fix by changing the 'and' to 'or'.

Fixes: 6256e668b7af ("x86/kprobes: Use int3 instead of debug trap for single-step")
Signed-off-by: Nadav Amit <namit@vmware.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220813225943.143767-1-namit@vmware.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/kernel/kprobes/core.c