]> git.baikalelectronics.ru Git - kernel.git/commit
kretprobe: Avoid re-registration of the same kretprobe earlier
authorWang ShaoBo <bobo.shaobowang@huawei.com>
Thu, 28 Jan 2021 12:44:27 +0000 (20:44 +0800)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 29 Jan 2021 22:29:16 +0000 (17:29 -0500)
commit771f81c8bc89311ce151e52e5cbcfa7e733e1f54
tree34f29e84d41767848b3f637b209cec1308e98782
parent27a097050b1eca4ff89a9cc5a92986ff73319acc
kretprobe: Avoid re-registration of the same kretprobe earlier

Our system encountered a re-init error when re-registering same kretprobe,
where the kretprobe_instance in rp->free_instances is illegally accessed
after re-init.

Implementation to avoid re-registration has been introduced for kprobe
before, but lags for register_kretprobe(). We must check if kprobe has
been re-registered before re-initializing kretprobe, otherwise it will
destroy the data struct of kretprobe registered, which can lead to memory
leak, system crash, also some unexpected behaviors.

We use check_kprobe_rereg() to check if kprobe has been re-registered
before running register_kretprobe()'s body, for giving a warning message
and terminate registration process.

Link: https://lkml.kernel.org/r/20210128124427.2031088-1-bobo.shaobowang@huawei.com
Cc: stable@vger.kernel.org
Fixes: 5dd6583715770 ("kprobes: Prevent re-registration of the same kprobe")
[ The above commit should have been done for kretprobes too ]
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Ananth N Mavinakayanahalli <ananth@linux.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
Signed-off-by: Cheng Jian <cj.chengjian@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/kprobes.c