Hi Kevin,

Thanks for reporting this problem. Looking more into KGDB patches, this seems 
to be present on all platforms.

KGDB shouldn't access user level memory at all. There is a comparison of 
requested address against TASK_SIZE in kernel/kgdb.c functions to take care 
of this. kgdb_set_mem and kgdb_get_mem functions in present kernel/kgdb.c 
contain this check but kgdb_mem2hex, kgdb_ebin2mem, kgdb_hex2mem don't. We 
need to add this check to these three functions also.

-Amit

On Thursday 10 August 2006 04:00, Kevin Hilman wrote:
> There's a problem in handling kgdb-triggered memory faults on ARM when
> the process in question has a user context.
>
> To reproduce, set a breakpoint at a system call (sys_sync for example),
> once the breakpoint is hit, do an 'info threads'.  In the process of
> doing this, kgdb_mem2hex may trigger a memory fault, but since this
> process has a user context, it doesn't take the path with the kgdb
> setjmp/longjmp fixups.  Even worse, it eventually ends up in do_no_page
> which can sleep, and since kgdb has disabled interrupts, a 'scheduling
> while atomic' BUG appears.
>
> It seems to work OK with no preemption, but this bug arises under
> CONFIG_PREEMPT.
>
> Patch below has been verified on a MontaVista 2.6.10 kernel (ARMv5, and
> v6) but should be same on newer kernels.
>
> Kevin
>
>  Index: linux-2.6.10/arch/arm/mm/fault.c
> ===================================================================
> --- linux-2.6.10.orig/arch/arm/mm/fault.c
> +++ linux-2.6.10/arch/arm/mm/fault.c
> @@ -217,6 +217,10 @@ out:
>       return fault;
>  }
>
> +#ifdef CONFIG_KGDB
> +extern int kgdb_may_fault;
> +#endif
> +
>  static int
>  do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
>  {
> @@ -227,6 +231,11 @@ do_page_fault(unsigned long addr, unsign
>       tsk = current;
>       mm  = tsk->mm;
>
> +#ifdef CONFIG_KGDB
> +     if (kgdb_may_fault)
> +             goto no_context;
> +#endif
> +
>       /*
>        * If we're in an interrupt or have no user
>        * context, we must not take the fault..
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Kgdb-bugreport mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to