login
Header Space

 
 

Re: [PATCH][2.6.25-rc2-mm1] fix a null pointer bug in register_kretprobe

Previous thread: Re: [PATCH] input: driver for USB VoIP phones with CM109 chipset by Alfred E. Heggestad on Monday, March 3, 2008 - 6:10 pm. (1 message)

Next thread: Re: [PATCH 2.6.20-rc2-git1] start_kernel: Test if irq's got enabled early, barf, and disable them again by Tony Luck on Monday, March 3, 2008 - 6:46 pm. (2 messages)
To: LKML <linux-kernel@...>, Andrew Morton <akpm@...>
Cc: Ananth N Mavinakayanahalli <ananth@...>, systemtap-ml <systemtap@...>, Jim Keniston <jkenisto@...>
Date: Monday, March 3, 2008 - 6:26 pm

Fix a bug in regiseter_kretprobe() which does not check
 rp-&gt;kp.symbol_name == NULL before calling kprobe_lookup_name.

 For maintainability, this introduces kprobe_addr helper function which
 resolves addr field. It is used by register_kprobe and register_kretprobe.

Signed-off-by: Masami Hiramatsu &lt;mhiramat@redhat.com&gt;
CC: Ananth N Mavinakayanahalli &lt;ananth@in.ibm.com&gt;
CC: Jim Keniston &lt;jkenisto@us.ibm.com&gt;
---
 kernel/kprobes.c |   43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

Index: 2.6.25-rc2-mm1/kernel/kprobes.c
===================================================================
--- 2.6.25-rc2-mm1.orig/kernel/kprobes.c	2008-02-18 11:37:18.000000000 -0500
+++ 2.6.25-rc2-mm1/kernel/kprobes.c	2008-02-18 11:37:18.000000000 -0500
@@ -498,27 +498,36 @@ static int __kprobes in_kprobes_function
 	return 0;
 }

+/*
+ * If we have a symbol_name argument, look it up and add the offset field
+ * to it. This way, we can specify a relative address to a symbol.
+ */
+static kprobe_opcode_t __kprobes *kprobe_addr(struct kprobe *p)
+{
+	kprobe_opcode_t *addr = p-&gt;addr;
+	if (p-&gt;symbol_name) {
+		if (addr)
+			return NULL;
+		kprobe_lookup_name(p-&gt;symbol_name, addr);
+	}
+
+	if (!addr)
+		return NULL;
+	return (kprobe_opcode_t *)(((char *)addr) + p-&gt;offset);
+}
+
 static int __kprobes __register_kprobe(struct kprobe *p,
 	unsigned long called_from)
 {
 	int ret = 0;
 	struct kprobe *old_p;
 	struct module *probed_mod;
+	kprobe_opcode_t *addr;

-	/*
-	 * If we have a symbol_name argument look it up,
-	 * and add it to the address.  That way the addr
-	 * field can either be global or relative to a symbol.
-	 */
-	if (p-&gt;symbol_name) {
-		if (p-&gt;addr)
-			return -EINVAL;
-		kprobe_lookup_name(p-&gt;symbol_name, p-&gt;addr);
-	}
-
-	if (!p-&gt;addr)
+	addr = kprobe_addr(p);
+	if (!addr)
 		return -EINVAL;
-	p-&gt;addr = (kprobe_opcode_t *)(((char *)p-&gt;addr)+ p-&gt;offset);...
To: Masami Hiramatsu <mhiramat@...>
Cc: LKML <linux-kernel@...>, Andrew Morton <akpm@...>, systemtap-ml <systemtap@...>, Jim Keniston <jkenisto@...>
Date: Monday, March 3, 2008 - 10:13 pm

Acked-by: Ananth N Mavinakayanahalli &lt;ananth@in.ibm.com&gt;

--
To: Masami Hiramatsu <mhiramat@...>
Cc: <linux-kernel@...>, <ananth@...>, <systemtap@...>, <jkenisto@...>
Date: Monday, March 3, 2008 - 6:36 pm

On Mon, 03 Mar 2008 17:26:36 -0500


implies (to me) that the patch fixes a bug which is only in -mm.  But
afacit this is a bugfix against mainline, yes?


--
To: Andrew Morton <akpm@...>
Cc: <linux-kernel@...>, <ananth@...>, <systemtap@...>, <jkenisto@...>
Date: Monday, March 3, 2008 - 6:59 pm

Yes, that bug is also in mainline...

Thank you,


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

--
Previous thread: Re: [PATCH] input: driver for USB VoIP phones with CM109 chipset by Alfred E. Heggestad on Monday, March 3, 2008 - 6:10 pm. (1 message)

Next thread: Re: [PATCH 2.6.20-rc2-git1] start_kernel: Test if irq's got enabled early, barf, and disable them again by Tony Luck on Monday, March 3, 2008 - 6:46 pm. (2 messages)
speck-geostationary