Commit ec02feff authored by Cheng Jian's avatar Cheng Jian Committed by Zheng Zengkai
Browse files

kretprobe: check re-registration of the same kretprobe earlier

hulk inclusion
category: bugfix
bugzilla: 47256
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.

v2: cherry pick and merge WARN_ON bugfix commit
6ca427f53643100fdb795bd88073fd7bba256702.

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 avataryangerkun <yangerkun@huawei.com>
Signed-off-by: default avatarLi Huafei <lihuafei1@huawei.com>
Reviewed-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 317f9f64
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment