I finally came across the case where CONFIG_DEBUG_PREEMPT crashes user
space processes on i386 and x86_64. When debugging a syscall, if gdb
reads any invalid memory and triggers the may_fault path, the preempt
count is not restored when doing the context restore.
The simple fix is to decrement the preempt count by 1 to account for the
exception. With this change user processes no longer die with the
scheduling while atomic error.
Signed-off-by: Jason Wessel <[EMAIL PROTECTED]>
---
arch/i386/kernel/kgdb.c | 6 ++++++
arch/x86_64/kernel/kgdb.c | 6 ++++++
2 files changed, 12 insertions(+)
Index: linux-2.6.21.1/arch/i386/kernel/kgdb.c
===================================================================
--- linux-2.6.21.1.orig/arch/i386/kernel/kgdb.c
+++ linux-2.6.21.1/arch/i386/kernel/kgdb.c
@@ -314,6 +314,12 @@ static int kgdb_notify(struct notifier_b
/* Bad memory access? */
if (cmd == DIE_PAGE_FAULT_NO_CONTEXT && atomic_read(&debugger_active)
&& kgdb_may_fault) {
+#if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT)
+ /* The exception adds a preempt count which must be erased
+ * upon the context restore
+ */
+ sub_preempt_count(1);
+#endif
kgdb_fault_longjmp(kgdb_fault_jmp_regs);
return NOTIFY_STOP;
} else if (cmd == DIE_PAGE_FAULT)
Index: linux-2.6.21.1/arch/x86_64/kernel/kgdb.c
===================================================================
--- linux-2.6.21.1.orig/arch/x86_64/kernel/kgdb.c
+++ linux-2.6.21.1/arch/x86_64/kernel/kgdb.c
@@ -388,6 +388,12 @@ static int kgdb_notify(struct notifier_b
if (cmd == DIE_PAGE_FAULT_NO_CONTEXT && atomic_read(&debugger_active)
&& kgdb_may_fault) {
+#if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT)
+ /* The exception adds a preempt count which must be erased
+ * upon the context restore
+ */
+ sub_preempt_count(1);
+#endif
kgdb_fault_longjmp(kgdb_fault_jmp_regs);
return NOTIFY_STOP;
/* CPU roundup? */
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Kgdb-bugreport mailing list
Kgdb-bugreport@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport