Skip to content

Commit

Permalink
prevent kprobes from catching spurious page faults
Browse files Browse the repository at this point in the history
Prevent kprobes from catching spurious faults which will cause infinite
recursive page-fault and memory corruption by stack overflow.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: <stable@kernel.org>		[2.6.28.x]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Masami Hiramatsu authored and Linus Torvalds committed Feb 6, 2009
1 parent 767b582 commit 9be260a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,6 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)

si_code = SEGV_MAPERR;

if (notify_page_fault(regs))
return;
if (unlikely(kmmio_fault(regs, address)))
return;

Expand Down Expand Up @@ -634,13 +632,19 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
if (spurious_fault(address, error_code))
return;

/* kprobes don't want to hook the spurious faults. */
if (notify_page_fault(regs))
return;
/*
* Don't take the mm semaphore here. If we fixup a prefetch
* fault we could otherwise deadlock.
*/
goto bad_area_nosemaphore;
}

/* kprobes don't want to hook the spurious faults. */
if (notify_page_fault(regs))
return;

/*
* It's safe to allow irq's after cr2 has been saved and the
Expand Down

0 comments on commit 9be260a

Please sign in to comment.