Commit bd1ed1b7 authored by Cheng Jian's avatar Cheng Jian Committed by Yang Yingliang
Browse files

kretprobe: check re-registration of the same kretprobe earlier

hulk inclusion
category: bugfix
bugzilla: 31369
CVE: NA

---------------------------

Our system encountered a use-after-free when re-register the same
kretprobe, it access the kretprobe_instance in rp->free_instances
which has been released already.

Prevent re-registration has been implemented for kprobe before, but
it's too late for kretprobe. We must check the re-registration before
re-initializing the kretprobe, otherwise it will destroy the data and
struct of the kretprobe registered, it can lead to use-after-free,
memory leak, system crash, and even other unexpected behaviors.

Use check_kprobe_rereg() to check re-registration, also give a warning
message.

Link: https://lkml.org/lkml/2020/3/6/167


Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent 9012956d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment