Re: Linux 2.6.35.2

From: Linus Torvalds
Date: Sat Aug 14 2010 - 13:15:10 EST


On Sat, Aug 14, 2010 at 5:37 AM, Sedat Dilek <sedat.dilek@xxxxxxxxxxxxxx> wrote:
>
> root@tbox:~# grep "Aug 14 13:00:5" /var/log/syslog
> Aug 14 13:00:53 tbox kernel: [ 1084.804086] BUG: scheduling while atomic: bash/3256/0x10000001

Gaah. Locking problem. We really should have let this one simmer in
-devel a bit longer before rushing it into -stable.

Attached potential patch. Untested, but I forgot about the locking in
the first version of the patch, and then the "trivial one-liner fix"
missed the deeper problem.

Greg - please don't use this patch yet. I'll test it. And wait for
verification that it fixes other peoblems too.

Linus
mm/memory.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 9b3b73f..b6e5fd2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2792,24 +2792,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
spinlock_t *ptl;
pte_t entry;

- if (check_stack_guard_page(vma, address) < 0) {
- pte_unmap(page_table);
+ pte_unmap(page_table);
+
+ /* Check if we need to add a guard page to the stack */
+ if (check_stack_guard_page(vma, address) < 0)
return VM_FAULT_SIGBUS;
- }

+ /* Use the zero-page for reads */
if (!(flags & FAULT_FLAG_WRITE)) {
entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
vma->vm_page_prot));
- ptl = pte_lockptr(mm, pmd);
- spin_lock(ptl);
+ page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
if (!pte_none(*page_table))
goto unlock;
goto setpte;
}

/* Allocate our own private page. */
- pte_unmap(page_table);
-
if (unlikely(anon_vma_prepare(vma)))
goto oom;
page = alloc_zeroed_user_highpage_movable(vma, address);