mirror of
https://github.com/torvalds/linux.git
synced 2026-11-23 23:11:40 +00:00
kprobes: Fix error return and slot leak in __register_kprobe()
When arm_kprobe() fails in __register_kprobe(), the probe is removed
from kprobe_table and synchronize_rcu() is executed, but the error code
ret was ignored and try_to_optimize_kprobe(p) was executed, returning 0.
Additionally, the instruction slot allocated by prepare_kprobe() was
leaked.
Fix this by releasing the instruction slot via arch_remove_kprobe(p)
and returning ret when arm_kprobe() fails.
Link: https://lore.kernel.org/all/179375030756.247640.10859474201266455798.stgit@devnote2/
Fixes: 587e8e6d64 ("kprobes: Adopt guard() and scoped_guard()")
Cc: [email protected]
Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
This commit is contained in:
@@ -1946,6 +1946,8 @@ static int __register_kprobe(struct kprobe *p)
|
||||
if (ret) {
|
||||
hlist_del_rcu(&p->hlist);
|
||||
synchronize_rcu();
|
||||
arch_remove_kprobe(p);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user