]> git.karo-electronics.de Git - karo-tx-linux.git/commit
x86: avoid theoretical vmalloc fault loop
authorAndi Kleen <andi@firstfloor.org>
Fri, 9 Jan 2009 20:17:43 +0000 (12:17 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 18 Jan 2009 18:35:45 +0000 (10:35 -0800)
commit2f9297bc01dc95cc1ab93d3c1b353a04edd49135
treeda3d1371fbd2380f468ed5ee42e318c5d693f2ef
parent0dbfff01f124f6e328afdc737a63868f99138a28
x86: avoid theoretical vmalloc fault loop

commit f313e12308f7c5ea645f18e759d104d088b18615 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/mm/fault.c