[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <149076505311.24574.3646383930433662308.stgit@devbox>
Date: Wed, 29 Mar 2017 14:24:23 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>
Cc: Alban Crequy <alban.crequy@...il.com>,
Alban Crequy <alban@...volk.io>,
Alexei Starovoitov <ast@...nel.org>,
Jonathan Corbet <corbet@....net>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Omar Sandoval <osandov@...com>, linux-doc@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
iago@...volk.io, michael@...volk.io,
Dorau Lukasz <lukasz.dorau@...el.com>, systemtap@...rceware.org
Subject: [RFC PATCH tip/master 3/3] kprobes: Limit kretprobe maximum instances
Limit kretprobe maximum instance up to MAXACTIVE_ALLOC.
Without this limit, kretprobe user can specify huge number
(e.g. forget to zero-fill struct kretprobe) to maxactive
and may cause out-of-memory.
Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
---
kernel/kprobes.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 75c5390..f1bebcf 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1942,6 +1942,9 @@ int register_kretprobe(struct kretprobe *rp)
rp->kp.break_handler = NULL;
/* Pre-allocate memory for max kretprobe instances */
+ if (rp->maxactive > KRETPROBE_MAXACTIVE_ALLOC)
+ return -E2BIG;
+
if (rp->maxactive <= 0) {
#ifdef CONFIG_PREEMPT
rp->maxactive = max_t(unsigned int, 10, 2*num_possible_cpus());
Powered by blists - more mailing lists