Thread (38 messages) 38 messages, 6 authors, 2017-04-25

Re: [PATCH v4 3/7] kprobes: validate the symbol name provided during probe registration

From: Naveen N. Rao <hidden>
Date: 2017-04-21 13:26:04
Also in: lkml

Excerpts from Paul Clarke's message of April 21, 2017 18:41:
a nit or two, below...
=20
On 04/21/2017 07:32 AM, Naveen N. Rao wrote:
quoted
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 6a128f3a7ed1..ff9b1ac72a38 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1383,6 +1383,34 @@ bool within_kprobe_blacklist(unsigned long addr)
 }
=20
 /*
+ * We mainly want to ensure that the provided string is of a reasonable=
 length
quoted
+ * and is of the form [<mod_name>:]<sym_name>, so that this is safe to =
process
quoted
+ * further.
+ * We don't worry about invalid characters as those will just prevent
+ * matching existing kallsyms.
+ */
+bool is_valid_kprobe_symbol_name(const char *name)
+{
+	size_t sym_len;
+	const char *s;
+
+	s =3D strnchr(name, ':', MODULE_NAME_LEN + KSYM_NAME_LEN + 1);
+	if (s) {
+		sym_len =3D (size_t)(s - name);
+		if (sym_len <=3D 0  || sym_len >=3D MODULE_NAME_LEN)
=20
"sym_len <=3D 0" looks odd here, since sym_len is likely unsigned and wou=
ld never be less than zero, anyway.

Ugh.. habits :/
I'll wait for Masami/Michael's feedback before re-spinning.

Thanks for the review,
- Naveen

=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help