Skip to contentSkip to conversation

i386: fix recursive fault in page-fault handler

PATCH Chuck Ebbert 1 participant 1 message Jul 17, 2006

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <[email protected]>

Quoted 8 lines · Linus Torvalds
Quoted 4 lines · Chuck Ebbert

Krzysztof Halasa reported recursive faults in do_page_fault() causing a stream of partial oops messages on the console. Fix by adding a fixup for that code.

This patch is really too ugly to live.

I was afraid to use __put_user, but I guess it's OK?

arch/i386/mm/fault.c +4 -3
@@ -585,9 +585,10 @@ no_context:
 		printk(KERN_ALERT "*pte = %08lx\n", page);
 	}
 #endif
-	tsk->thread.cr2 = address;
-	tsk->thread.trap_no = 14;
-	tsk->thread.error_code = error_code;
+	/* avoid possible fault here if tsk is garbage */
+	__put_user(address, &tsk->thread.cr2);
+	__put_user(14, &tsk->thread.trap_no);
+	__put_user(error_code, &tsk->thread.error_code);
 	die("Oops", regs, error_code);
 	bust_spinlocks(0);
 	do_exit(SIGKILL);
Quoted 7 lines

Does it even work? If 'tsk' is
broken, I'd expect the die() to oops anyway - it does

if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_no, SIGSEG...

anyway (where that "current->thread.trap_no" gets dereferenced).

This should at least stop the endless faults because recursive faulting in die() is handled properly. Right now the original error message (incomplete but still possibly useful) scrolls away.

I was going to fix handling of bad task pointer in die() and show_registers() after I got feedback from the first patch.

Signature · 1 line
Chuck