x86/mm: Fix exception table comments
The comments here are wrong. They are too absolute about where faults can occur when running in the kernel. The comments are also a bit hard to match up with the code. Trim down the comments, and make them more precise. Also add a comment explaining why we are doing the bad_area_nosemaphore() path here. Cc: x86@kernel.org Cc: Jann Horn <jannh@google.com> Cc: Sean Christopherson <sean.j.christopherson@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@kernel.org> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: http://lkml.kernel.org/r/20180928160227.077DDD7A@viggo.jf.intel.com
This commit is contained in:
Родитель
5b0c2cac54
Коммит
88259744e2
|
@ -1351,24 +1351,26 @@ void do_user_addr_fault(struct pt_regs *regs,
|
||||||
flags |= FAULT_FLAG_INSTRUCTION;
|
flags |= FAULT_FLAG_INSTRUCTION;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When running in the kernel we expect faults to occur only to
|
* Kernel-mode access to the user address space should only occur
|
||||||
* addresses in user space. All other faults represent errors in
|
* on well-defined single instructions listed in the exception
|
||||||
* the kernel and should generate an OOPS. Unfortunately, in the
|
* tables. But, an erroneous kernel fault occurring outside one of
|
||||||
* case of an erroneous fault occurring in a code path which already
|
* those areas which also holds mmap_sem might deadlock attempting
|
||||||
* holds mmap_sem we will deadlock attempting to validate the fault
|
* to validate the fault against the address space.
|
||||||
* against the address space. Luckily the kernel only validly
|
|
||||||
* references user space from well defined areas of code, which are
|
|
||||||
* listed in the exceptions table.
|
|
||||||
*
|
*
|
||||||
* As the vast majority of faults will be valid we will only perform
|
* Only do the expensive exception table search when we might be at
|
||||||
* the source reference check when there is a possibility of a
|
* risk of a deadlock. This happens if we
|
||||||
* deadlock. Attempt to lock the address space, if we cannot we then
|
* 1. Failed to acquire mmap_sem, and
|
||||||
* validate the source. If this is invalid we can skip the address
|
* 2. The access did not originate in userspace. Note: either the
|
||||||
* space check, thus avoiding the deadlock:
|
* hardware or earlier page fault code may set X86_PF_USER
|
||||||
|
* in sw_error_code.
|
||||||
*/
|
*/
|
||||||
if (unlikely(!down_read_trylock(&mm->mmap_sem))) {
|
if (unlikely(!down_read_trylock(&mm->mmap_sem))) {
|
||||||
if (!(sw_error_code & X86_PF_USER) &&
|
if (!(sw_error_code & X86_PF_USER) &&
|
||||||
!search_exception_tables(regs->ip)) {
|
!search_exception_tables(regs->ip)) {
|
||||||
|
/*
|
||||||
|
* Fault from code in kernel from
|
||||||
|
* which we do not expect faults.
|
||||||
|
*/
|
||||||
bad_area_nosemaphore(regs, sw_error_code, address, NULL);
|
bad_area_nosemaphore(regs, sw_error_code, address, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче