diff options
author | Andi Kleen <andi@firstfloor.org> | 2009-01-09 15:17:43 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-12 13:24:21 -0500 |
commit | f313e12308f7c5ea645f18e759d104d088b18615 (patch) | |
tree | 4043dfa82448c1ef1bba81e58eb1fe162e82a69c /arch/x86 | |
parent | f45ac22ae2b8fc5b4c32d9b8d17ea419a8701d89 (diff) |
x86: avoid theoretical vmalloc fault loop
Ajith Kumar noticed:
I was going through the vmalloc fault handling for x86_64 and am unclear
about the following lines in the vmalloc_fault() function.
pgd = pgd_offset(current->mm ?: &init_mm, address);
pgd_ref = pgd_offset_k(address);
Here the intention is to get the pgd corresponding to the current process
and sync it up with the pgd in init_mm(obtained from pgd_offset_k).
However, for kernel threads current->mm is NULL and hence pgd =
pgd_offset(init_mm, address) = pgd_ref which means the fault handler
returns without setting the pgd entry in the MM structure in the context
of which the kernel thread has faulted. This could lead to never-ending
faults and busy looping of kernel threads like pdflush. So, shouldn't the
pgd = pgd_offset(current->mm ?: &init_mm, address); be pgd =
pgd_offset(current->active_mm ?: &init_mm, address);
We can use active_mm unconditionally because it should be always set.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/mm/fault.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9e268b6b204e..90dfae511a41 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -534,7 +534,7 @@ static int vmalloc_fault(unsigned long address) | |||
534 | happen within a race in page table update. In the later | 534 | happen within a race in page table update. In the later |
535 | case just flush. */ | 535 | case just flush. */ |
536 | 536 | ||
537 | pgd = pgd_offset(current->mm ?: &init_mm, address); | 537 | pgd = pgd_offset(current->active_mm, address); |
538 | pgd_ref = pgd_offset_k(address); | 538 | pgd_ref = pgd_offset_k(address); |
539 | if (pgd_none(*pgd_ref)) | 539 | if (pgd_none(*pgd_ref)) |
540 | return -1; | 540 | return -1; |