]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/kprobes: Fix to check non boostable prefixes correctly
authorMasami Hiramatsu <mhiramat@kernel.org>
Thu, 25 Mar 2021 10:08:31 +0000 (19:08 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 08:49:53 +0000 (10:49 +0200)
commitcb06ac294f585dc3780d912eac755b2cbb44e3d3
tree3204ad6cbff22bdca9c0cb21671d63eb36609ac7
parent5d4d0687a99b78293502ee424e6e34a25dbe628b
x86/kprobes: Fix to check non boostable prefixes correctly

[ Upstream commit 6dd3b8c9f58816a1354be39559f630cd1bd12159 ]

There are 2 bugs in the can_boost() function because of using
x86 insn decoder. Since the insn->opcode never has a prefix byte,
it can not find CS override prefix in it. And the insn->attr is
the attribute of the opcode, thus inat_is_address_size_prefix(
insn->attr) always returns false.

Fix those by checking each prefix bytes with for_each_insn_prefix
loop and getting the correct attribute for each prefix byte.
Also, this removes unlikely, because this is a slow path.

Fixes: a8d11cd0714f ("kprobes/x86: Consolidate insn decoder users for copying code")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/161666691162.1120877.2808435205294352583.stgit@devnote2
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/kprobes/core.c