]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
x86/kprobes: Fix __recover_optprobed_insn check optimizing logic
authorYang Jihong <yangjihong1@huawei.com>
Mon, 20 Feb 2023 23:49:16 +0000 (08:49 +0900)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 14 Mar 2023 15:47:27 +0000 (16:47 +0100)
commit59fc83663e5c29185c9af34670f7b0b30d6134a2
treec5ef6ce8a6039c8d4b834d80235b9fed8bff3f28
parentc27639ce8f147c7c084d3f97f7ef3cf53e148dd6
x86/kprobes: Fix __recover_optprobed_insn check optimizing logic

BugLink: https://bugs.launchpad.net/bugs/2011425
commit 868a6fc0ca2407622d2833adefe1c4d284766c4c upstream.

Since the following commit:

  commit f66c0447cca1 ("kprobes: Set unoptimized flag after unoptimizing code")

modified the update timing of the KPROBE_FLAG_OPTIMIZED, a optimized_kprobe
may be in the optimizing or unoptimizing state when op.kp->flags
has KPROBE_FLAG_OPTIMIZED and op->list is not empty.

The __recover_optprobed_insn check logic is incorrect, a kprobe in the
unoptimizing state may be incorrectly determined as unoptimizing.
As a result, incorrect instructions are copied.

The optprobe_queued_unopt function needs to be exported for invoking in
arch directory.

Link: https://lore.kernel.org/all/20230216034247.32348-2-yangjihong1@huawei.com/
Fixes: f66c0447cca1 ("kprobes: Set unoptimized flag after unoptimizing code")
Cc: stable@vger.kernel.org
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
arch/x86/kernel/kprobes/opt.c
include/linux/kprobes.h
kernel/kprobes.c