Re: [RFC] [PATCH] To vunmap correct address in text_poke()(kprobes)

2007-07-25 Thread Srinivasa Ds
Resending patch according to Prasanna's suggestion, CC'ing Andi Kleen.

Hit this issue when testing kprobes on x86_64 systems. We need to align 
vunmap() address to a page boundary in text_poke(). Patch below
==
Trying to vfree() bad address (c20002233199)
WARNING: at mm/vmalloc.c:330 __vunmap()
 
  Call Trace:
  [] sys_gettimeofday+0x0/0x62
   [] text_poke+0x119/0x124
   [] arch_arm_kprobe+0x1c/0x21
   [] __register_kprobe+0x28a/0x2ed
   [] :gettimeofday:kprobe_init+0x39/0x65
   [] sys_init_module+0x1626/0x1788
   [] dput+0x3f/0xfa
   [] audit_syscall_entry+0x141/0x174
   [] tracesys+0xdc/0xe1


Signed-off-by: Srinivasa DS <[EMAIL PROTECTED]>
Signed-off-by: Suzuki K P   <[EMAIL PROTECTED]>
Signed-off-by: Prasanna S Panchamukhi <[EMAIL PROTECTED]>

Index: linux-2.6.23-rc1/arch/i386/kernel/alternative.c
===
--- linux-2.6.23-rc1.orig/arch/i386/kernel/alternative.c2007-07-23 
02:11:00.0 +0530
+++ linux-2.6.23-rc1/arch/i386/kernel/alternative.c 2007-07-25 
20:27:13.0 +0530
@@ -447,5 +447,5 @@ void __kprobes text_poke(void *oaddr, un
if (cpu_has_clflush)
asm("clflush (%0) " :: "r" (oaddr) : "memory");
if (addr != oaddr)
-   vunmap(addr);
+   vunmap((u8 *)((unsigned long)addr & PAGE_MASK));
 }


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] [PATCH] To vunmap correct address in text_poke()(kprobes)

2007-07-25 Thread S. P. Prasanna
On Wed, Jul 25, 2007 at 12:21:49PM +0530, Srinivasa Ds wrote:
> 
> When I was testing kprobes on x86_64 and I come across the below error 
> message 
> on latest 2.6.23-rc1 kernel.
> ==
> Trying to vfree() bad address (c20002233199)
>  WARNING: at mm/vmalloc.c:330 __vunmap()
> 
>  Call Trace:
>  [] sys_gettimeofday+0x0/0x62
>   [] text_poke+0x119/0x124
>   [] arch_arm_kprobe+0x1c/0x21
>   [] __register_kprobe+0x28a/0x2ed
>   [] :gettimeofday:kprobe_init+0x39/0x65
>   [] sys_init_module+0x1626/0x1788
>   [] dput+0x3f/0xfa
>   [] audit_syscall_entry+0x141/0x174
>   [] tracesys+0xdc/0xe1
> 
> ==
> 
> This indicates that vunmap() is not receving the page-aligned address in 
> text_poke(). So the below attached patch will address this issue. Please let 
> me know your comments.
> 
> Signed-off-by: Srinivasa DS <[EMAIL PROTECTED]>
> Signed-off-by: Suzuki K P   <[EMAIL PROTECTED]>
> 
> 
> Index: linux-2.6.23-rc1/arch/i386/kernel/alternative.c
> ===
> --- linux-2.6.23-rc1.orig/arch/i386/kernel/alternative.c  2007-07-23 
> 02:11:00.0 +0530
> +++ linux-2.6.23-rc1/arch/i386/kernel/alternative.c   2007-07-25 
> 11:45:53.0 +0530
> @@ -447,5 +447,5 @@ void __kprobes text_poke(void *oaddr, un
>   if (cpu_has_clflush)
>   asm("clflush (%0) " :: "r" (oaddr) : "memory");
>   if (addr != oaddr)
> - vunmap(addr);
> + vunmap(addr-(((unsigned long)oaddr) % PAGE_SIZE));

It is appropriate to use PAGE_MASK rather than doing all this,
as shown below.

vunmap((u8 *)((unsigned long)addr & PAGE_MASK));

Thanks
Prasanna

-- 
Prasanna S.P.
Linux Technology Center
India Software Labs, IBM Bangalore
Email: [EMAIL PROTECTED]
Ph: 91-80-41776329
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC] [PATCH] To vunmap correct address in text_poke()(kprobes)

2007-07-24 Thread Srinivasa Ds

When I was testing kprobes on x86_64 and I come across the below error message 
on latest 2.6.23-rc1 kernel.
==
Trying to vfree() bad address (c20002233199)
 WARNING: at mm/vmalloc.c:330 __vunmap()

 Call Trace:
 [] sys_gettimeofday+0x0/0x62
  [] text_poke+0x119/0x124
  [] arch_arm_kprobe+0x1c/0x21
  [] __register_kprobe+0x28a/0x2ed
  [] :gettimeofday:kprobe_init+0x39/0x65
  [] sys_init_module+0x1626/0x1788
  [] dput+0x3f/0xfa
  [] audit_syscall_entry+0x141/0x174
  [] tracesys+0xdc/0xe1

==

This indicates that vunmap() is not receving the page-aligned address in 
text_poke(). So the below attached patch will address this issue. Please let 
me know your comments.

Signed-off-by: Srinivasa DS <[EMAIL PROTECTED]>
Signed-off-by: Suzuki K P   <[EMAIL PROTECTED]>


Index: linux-2.6.23-rc1/arch/i386/kernel/alternative.c
===
--- linux-2.6.23-rc1.orig/arch/i386/kernel/alternative.c2007-07-23 
02:11:00.0 +0530
+++ linux-2.6.23-rc1/arch/i386/kernel/alternative.c 2007-07-25 
11:45:53.0 +0530
@@ -447,5 +447,5 @@ void __kprobes text_poke(void *oaddr, un
if (cpu_has_clflush)
asm("clflush (%0) " :: "r" (oaddr) : "memory");
if (addr != oaddr)
-   vunmap(addr);
+   vunmap(addr-(((unsigned long)oaddr) % PAGE_SIZE));
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/