diff options
author | Andi Kleen <ak@suse.de> | 2006-12-06 20:14:06 -0500 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-12-06 20:14:06 -0500 |
commit | 11a4180c0b03e2ee0c948fd8430ee092dc1625b3 (patch) | |
tree | c0f5018983f859d84b0832ea793ba0c49d344935 /arch/i386/kernel/traps.c | |
parent | ab2bf0c1c689905b628dca94d0acd9c50e152468 (diff) |
[PATCH] i386: Use probe_kernel_address instead of __get_user in fault paths
Makes the intention of the code cleaner to read and avoids
a potential deadlock on mmap_sem. Also change the types of
the arguments to not include __user because they're really
not user addresses.
Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch/i386/kernel/traps.c')
-rw-r--r-- | arch/i386/kernel/traps.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c index 237f4884a1e1..7b2f9f022089 100644 --- a/arch/i386/kernel/traps.c +++ b/arch/i386/kernel/traps.c | |||
@@ -380,7 +380,7 @@ void show_registers(struct pt_regs *regs) | |||
380 | * time of the fault.. | 380 | * time of the fault.. |
381 | */ | 381 | */ |
382 | if (in_kernel) { | 382 | if (in_kernel) { |
383 | u8 __user *eip; | 383 | u8 *eip; |
384 | int code_bytes = 64; | 384 | int code_bytes = 64; |
385 | unsigned char c; | 385 | unsigned char c; |
386 | 386 | ||
@@ -389,18 +389,20 @@ void show_registers(struct pt_regs *regs) | |||
389 | 389 | ||
390 | printk(KERN_EMERG "Code: "); | 390 | printk(KERN_EMERG "Code: "); |
391 | 391 | ||
392 | eip = (u8 __user *)regs->eip - 43; | 392 | eip = (u8 *)regs->eip - 43; |
393 | if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) { | 393 | if (eip < (u8 *)PAGE_OFFSET || |
394 | probe_kernel_address(eip, c)) { | ||
394 | /* try starting at EIP */ | 395 | /* try starting at EIP */ |
395 | eip = (u8 __user *)regs->eip; | 396 | eip = (u8 *)regs->eip; |
396 | code_bytes = 32; | 397 | code_bytes = 32; |
397 | } | 398 | } |
398 | for (i = 0; i < code_bytes; i++, eip++) { | 399 | for (i = 0; i < code_bytes; i++, eip++) { |
399 | if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) { | 400 | if (eip < (u8 *)PAGE_OFFSET || |
401 | probe_kernel_address(eip, c)) { | ||
400 | printk(" Bad EIP value."); | 402 | printk(" Bad EIP value."); |
401 | break; | 403 | break; |
402 | } | 404 | } |
403 | if (eip == (u8 __user *)regs->eip) | 405 | if (eip == (u8 *)regs->eip) |
404 | printk("<%02x> ", c); | 406 | printk("<%02x> ", c); |
405 | else | 407 | else |
406 | printk("%02x ", c); | 408 | printk("%02x ", c); |
@@ -416,7 +418,7 @@ static void handle_BUG(struct pt_regs *regs) | |||
416 | 418 | ||
417 | if (eip < PAGE_OFFSET) | 419 | if (eip < PAGE_OFFSET) |
418 | return; | 420 | return; |
419 | if (probe_kernel_address((unsigned short __user *)eip, ud2)) | 421 | if (probe_kernel_address((unsigned short *)eip, ud2)) |
420 | return; | 422 | return; |
421 | if (ud2 != 0x0b0f) | 423 | if (ud2 != 0x0b0f) |
422 | return; | 424 | return; |
@@ -429,11 +431,11 @@ static void handle_BUG(struct pt_regs *regs) | |||
429 | char *file; | 431 | char *file; |
430 | char c; | 432 | char c; |
431 | 433 | ||
432 | if (probe_kernel_address((unsigned short __user *)(eip + 2), | 434 | if (probe_kernel_address((unsigned short *)(eip + 2), line)) |
433 | line)) | ||
434 | break; | 435 | break; |
435 | if (__get_user(file, (char * __user *)(eip + 4)) || | 436 | if (probe_kernel_address((char **)(eip + 4), file) || |
436 | (unsigned long)file < PAGE_OFFSET || __get_user(c, file)) | 437 | (unsigned long)file < PAGE_OFFSET || |
438 | probe_kernel_address(file, c)) | ||
437 | file = "<bad filename>"; | 439 | file = "<bad filename>"; |
438 | 440 | ||
439 | printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line); | 441 | printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line); |