]> git.baikalelectronics.ru Git - 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)
committerIngo Molnar <mingo@kernel.org>
Sun, 14 Aug 2022 09:27:17 +0000 (11:27 +0200)
commit06ff6af38001d80f6e994c50f6bc225429f5b4b4
tree2018f44948641800482808fa1fd6724ef0e83de9
parentbaf9500b22d5c76a85f0177afe453b2d40e689d9
x86/kprobes: Fix JNG/JNLE emulation

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: 432b2fbbf21b ("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
arch/x86/kernel/kprobes/core.c