Skip to content

Commit

Permalink
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/tip/linux-2.6-tip

* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86: fix compat-vdso
  x86/mm: unify init task OOM handling
  x86/mm: do not trigger a kernel warning if user-space disables interrupts and generates a page fault
  • Loading branch information
torvalds committed Oct 16, 2008
2 parents 70a3075 + f61f1b5 commit 0999d97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
45 changes: 17 additions & 28 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,24 +640,23 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
}


#ifdef CONFIG_X86_32
/* It's safe to allow irq's after cr2 has been saved and the vmalloc
fault has been handled. */
if (regs->flags & (X86_EFLAGS_IF | X86_VM_MASK))
local_irq_enable();

/*
* If we're in an interrupt, have no user context or are running in an
* atomic region then we must not take the fault.
* It's safe to allow irq's after cr2 has been saved and the
* vmalloc fault has been handled.
*
* User-mode registers count as a user access even for any
* potential system fault or CPU buglet.
*/
if (in_atomic() || !mm)
goto bad_area_nosemaphore;
#else /* CONFIG_X86_64 */
if (likely(regs->flags & X86_EFLAGS_IF))
if (user_mode_vm(regs)) {
local_irq_enable();
error_code |= PF_USER;
} else if (regs->flags & X86_EFLAGS_IF)
local_irq_enable();

#ifdef CONFIG_X86_64
if (unlikely(error_code & PF_RSVD))
pgtable_bad(address, regs, error_code);
#endif

/*
* If we're in an interrupt, have no user context or are running in an
Expand All @@ -666,15 +665,9 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
if (unlikely(in_atomic() || !mm))
goto bad_area_nosemaphore;

/*
* User-mode registers count as a user access even for any
* potential system fault or CPU buglet.
*/
if (user_mode_vm(regs))
error_code |= PF_USER;
again:
#endif
/* When running in the kernel we expect faults to occur only to
/*
* When running in the kernel we expect faults to occur only to
* addresses in user space. All other faults represent errors in the
* kernel and should generate an OOPS. Unfortunately, in the case of an
* erroneous fault occurring in a code path which already holds mmap_sem
Expand Down Expand Up @@ -737,9 +730,6 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
goto bad_area;
}

#ifdef CONFIG_X86_32
survive:
#endif
/*
* If for any reason at all we couldn't handle the fault,
* make sure we exit gracefully rather than endlessly redo
Expand Down Expand Up @@ -874,12 +864,11 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
up_read(&mm->mmap_sem);
if (is_global_init(tsk)) {
yield();
#ifdef CONFIG_X86_32
down_read(&mm->mmap_sem);
goto survive;
#else
/*
* Re-lookup the vma - in theory the vma tree might
* have changed:
*/
goto again;
#endif
}

printk("VM: killing process %s\n", tsk->comm);
Expand Down
7 changes: 6 additions & 1 deletion include/asm-x86/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@
#ifdef CONFIG_X86_64
#define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
#else
/*
* For PDE_IDENT_ATTR include USER bit. As the PDE and PTE protection
* bits are combined, this will alow user to access the high address mapped
* VDSO in the presence of CONFIG_COMPAT_VDSO
*/
#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
#define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
#endif

Expand Down

0 comments on commit 0999d97

Please sign in to comment.