* [PATCH] Transparently handle <.symbol> lookup for kprobes
@ 2007-04-23 5:58 Srinivasa Ds
2007-04-24 5:59 ` Paul Mackerras
0 siblings, 1 reply; 3+ messages in thread
From: Srinivasa Ds @ 2007-04-23 5:58 UTC (permalink / raw)
To: linux-kernel; +Cc: ananth, Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
When data symbols are not present in kernel image, user needs to add
dot(".") before function name explicitly, that he wants to probe in kprobe
module on ppc64.
for ex:-
When data symbols are missing on ppc64,
====================
[root@llm27lp1 ~]# cat /proc/kallsyms | grep do_fork
c00000000006283c T .do_fork
==============================
User needs add "." to "do_fork"
kp.symbol_name = ".do_fork";
============================
This makes kprobe modules unportable. Below patch fixes the problem.
Signed-off-by: Srinivasa Ds <srinivasa@in.ibm.com>
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
[-- Attachment #2: final.patch --]
[-- Type: text/x-diff, Size: 730 bytes --]
---
include/asm-powerpc/kprobes.h | 6 ++++++
1 file changed, 6 insertions(+)
Index: linux-2.6.21-rc7/include/asm-powerpc/kprobes.h
===================================================================
--- linux-2.6.21-rc7.orig/include/asm-powerpc/kprobes.h
+++ linux-2.6.21-rc7/include/asm-powerpc/kprobes.h
@@ -64,6 +64,12 @@ typedef unsigned int kprobe_opcode_t;
addr = *(kprobe_opcode_t **)addr; \
} else if (name[0] != '.') \
addr = *(kprobe_opcode_t **)addr; \
+ } else { \
+ char dot_name[KSYM_NAME_LEN+1]; \
+ dot_name[0] = '.'; \
+ dot_name[1] = '\0'; \
+ strncat(dot_name, name, KSYM_NAME_LEN); \
+ addr = (kprobe_opcode_t *)kallsyms_lookup_name(dot_name); \
} \
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Transparently handle <.symbol> lookup for kprobes
2007-04-23 5:58 [PATCH] Transparently handle <.symbol> lookup for kprobes Srinivasa Ds
@ 2007-04-24 5:59 ` Paul Mackerras
2007-04-24 6:44 ` Srinivasa Ds
0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2007-04-24 5:59 UTC (permalink / raw)
To: Srinivasa Ds; +Cc: linux-kernel, ananth, Andrew Morton
Srinivasa Ds writes:
> + } else { \
> + char dot_name[KSYM_NAME_LEN+1]; \
> + dot_name[0] = '.'; \
> + dot_name[1] = '\0'; \
> + strncat(dot_name, name, KSYM_NAME_LEN); \
Assuming the kernel strncat works like the userspace one does, there
is a possibility that dot_name[] won't be properly null-terminated
here. If strlen(name) >= KSYM_NAME_LEN-1, then strncat will set
dot_name[KSYM_NAME_LEN-1] to something non-null and won't touch
dot_name[KSYM_NAME_LEN].
Paul.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Transparently handle <.symbol> lookup for kprobes
2007-04-24 5:59 ` Paul Mackerras
@ 2007-04-24 6:44 ` Srinivasa Ds
0 siblings, 0 replies; 3+ messages in thread
From: Srinivasa Ds @ 2007-04-24 6:44 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linux-kernel, ananth, Andrew Morton
Paul Mackerras wrote:
> Srinivasa Ds writes:
>
>> + } else { \
>> + char dot_name[KSYM_NAME_LEN+1]; \
>> + dot_name[0] = '.'; \
>> + dot_name[1] = '\0'; \
>> + strncat(dot_name, name, KSYM_NAME_LEN); \
>
> Assuming the kernel strncat works like the userspace one does, there
> is a possibility that dot_name[] won't be properly null-terminated
> here. If strlen(name) >= KSYM_NAME_LEN-1, then strncat will set
> dot_name[KSYM_NAME_LEN-1] to something non-null and won't touch
> dot_name[KSYM_NAME_LEN].
Irrespective of length of the string, kernel implementation of
strncat(lib/string.c) ensures that last character of string is set to
null. So dot_name[] is always null terminated.
========================
char *strncat(char *dest, const char *src, size_t count)
{
char *tmp = dest;
if (count) {
while (*dest)
dest++;
while ((*dest++ = *src++) != 0) {
if (--count == 0) {
*dest = '\0';
break;
}
}
}
return tmp;
}
EXPORT_SYMBOL(strncat);
===============================
Is this OK then ??
Thanks
Srinivasa DS
>
> Paul.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-24 6:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-23 5:58 [PATCH] Transparently handle <.symbol> lookup for kprobes Srinivasa Ds
2007-04-24 5:59 ` Paul Mackerras
2007-04-24 6:44 ` Srinivasa Ds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox