mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 13:22:57 +00:00
x86/kprobes: Fix __recover_optprobed_insn check optimizing logic
commit868a6fc0ca
upstream. Since the following commit: commitf66c0447cc
("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:f66c0447cc
("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>
This commit is contained in:
parent
23b1a4346f
commit
31f7904bef
3 changed files with 4 additions and 3 deletions
|
@ -56,8 +56,8 @@ unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr)
|
|||
/* This function only handles jump-optimized kprobe */
|
||||
if (kp && kprobe_optimized(kp)) {
|
||||
op = container_of(kp, struct optimized_kprobe, kp);
|
||||
/* If op->list is not empty, op is under optimizing */
|
||||
if (list_empty(&op->list))
|
||||
/* If op is optimized or under unoptimizing */
|
||||
if (list_empty(&op->list) || optprobe_queued_unopt(op))
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,6 +353,7 @@ extern int proc_kprobes_optimization_handler(struct ctl_table *table,
|
|||
size_t *length, loff_t *ppos);
|
||||
#endif
|
||||
extern void wait_for_kprobe_optimizer(void);
|
||||
bool optprobe_queued_unopt(struct optimized_kprobe *op);
|
||||
#else
|
||||
static inline void wait_for_kprobe_optimizer(void) { }
|
||||
#endif /* CONFIG_OPTPROBES */
|
||||
|
|
|
@ -626,7 +626,7 @@ void wait_for_kprobe_optimizer(void)
|
|||
mutex_unlock(&kprobe_mutex);
|
||||
}
|
||||
|
||||
static bool optprobe_queued_unopt(struct optimized_kprobe *op)
|
||||
bool optprobe_queued_unopt(struct optimized_kprobe *op)
|
||||
{
|
||||
struct optimized_kprobe *_op;
|
||||
|
||||
|
|
Loading…
Reference in a new issue