From patchwork Mon Nov 5 22:46:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 1700711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id A349FDF2AB for ; Mon, 5 Nov 2012 22:50:46 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TVVSb-0000O4-Me; Mon, 05 Nov 2012 22:48:01 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TVVSA-0000IT-Ab for linux-arm-kernel@lists.infradead.org; Mon, 05 Nov 2012 22:47:35 +0000 Received: by mail-pb0-f49.google.com with SMTP id xa7so3934289pbc.36 for ; Mon, 05 Nov 2012 14:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Dv8EV5yYhMCiCcpJPLS+K4+AAeM3+Z0IlXs5zyggANI=; b=QfaXRFazO9ZwynKoJ0WqEZ6XgKPNFSFKy4i6jGn56GQwLK99bB6JW2gSxy1zMJY9PX elrFswfvvXYpU0tlVEUgNNInRVDtdkGqPMgzsnXw49fZMRViqsXKeo9ntndwjb/3zGCV dxic56UKFyyUjT/HjNLca/6R9Te3HJ8Cr1J9So0GFkLiIBEyx8WGtDcV59Ibkph4xqbh j+EB9f3nSp0o49AtBV6HZD3ecZD3q/wQljmIFWF9fTT73Q020xwScSEMzGyYbGoa8q49 dqtGFvIC1b/CqMxDi3N04/dlJQhvmTIxCnPYI80r6aoolsWMObFZyLAaRnCXZWoGYM9r sBRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Dv8EV5yYhMCiCcpJPLS+K4+AAeM3+Z0IlXs5zyggANI=; b=SwcC8tHRasdcl9ABDKNgnGZgryIjau8Px1F6W5aJRUfDfe37IsCQMPIFrxSRS1poBM o1SxNKx0mWrINornYn62Rflo0EC9yivwSgViMCzbU+GVRUE1UK6MiiIdRhoVTyqWV+xZ Pi3k+tiJf+1vWwIvYnj+RJHCTZL1ZCgonfaU2iGvGHbEU0+7aKw0CO8iw4FRbG83YVI0 kiLmi6NvIunCSX9Zyp1Jfr9cjlgBymQkUuSv8rKv0bpfRkmpOF9vjrDuBx4HAvJgUrM9 BnYjBKRRIelg4y95TxwGhTO20H0J8hFk3ukbpYGS6tco44XO8AgK9WYfjiyyeAlFgH3M wolw== Received: by 10.68.189.138 with SMTP id gi10mr34244353pbc.165.1352155652928; Mon, 05 Nov 2012 14:47:32 -0800 (PST) Received: from studio.mtv.corp.google.com (studio.mtv.corp.google.com [172.17.131.106]) by mx.google.com with ESMTPS id jx4sm11201653pbc.27.2012.11.05.14.47.31 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Nov 2012 14:47:32 -0800 (PST) From: Michel Lespinasse To: Andrew Morton , Rik van Riel , Hugh Dickins , linux-kernel@vger.kernel.org, Russell King , Ralf Baechle , Paul Mundt , "David S. Miller" , Chris Metcalf , x86@kernel.org, William Irwin Subject: [PATCH 01/16] mm: add anon_vma_lock to validate_mm() Date: Mon, 5 Nov 2012 14:46:58 -0800 Message-Id: <1352155633-8648-2-git-send-email-walken@google.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1352155633-8648-1-git-send-email-walken@google.com> References: <1352155633-8648-1-git-send-email-walken@google.com> X-Gm-Message-State: ALoCoQm1n1hYuSuRrlbQ2TCO7oIjd0csFZBuRLRx+kJEAyL+oClbwBIIayNyE41KuQPA9C6Q+CpF5l75/ddC1srSKknCzLvC9XmgP8E6dBWmDkOKcWZ5R4bCQm4g0gSwzGT7AxtSNbq60G9GxgNEiz9d6v7RoojwxsEZGasuWZNB8KGVj+YQZGf552GMUhE1ocftDfqeA2VPLK8HEjnFfMYi+pEyEjyeZA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121105_174734_736906_C088B0CA X-CRM114-Status: GOOD ( 14.15 ) X-Spam-Score: -0.4 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: sparclinux@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Iterate vma->anon_vma_chain without anon_vma_lock may cause NULL ptr deref in anon_vma_interval_tree_verify(), because the node in the chain might have been removed. [ 1523.657950] BUG: unable to handle kernel paging request at fffffffffffffff0 [ 1523.660022] IP: [] anon_vma_interval_tree_verify+0xc/0xa0 [ 1523.660022] PGD 4e28067 PUD 4e29067 PMD 0 [ 1523.675725] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC [ 1523.750066] CPU 0 [ 1523.750066] Pid: 9050, comm: trinity-child64 Tainted: G W 3.7.0-rc2-next-20121025-sasha-00001-g673f98e-dirty #77 [ 1523.750066] RIP: 0010:[] [] anon_vma_interval_tree_verify+0xc/0xa0 [ 1523.750066] RSP: 0018:ffff880045f81d48 EFLAGS: 00010296 [ 1523.750066] RAX: 0000000000000000 RBX: fffffffffffffff0 RCX: 0000000000000000 [ 1523.750066] RDX: 0000000000000000 RSI: 0000000000000001 RDI: fffffffffffffff0 [ 1523.750066] RBP: ffff880045f81d58 R08: 0000000000000000 R09: 0000000000000f14 [ 1523.750066] R10: 0000000000000f12 R11: 0000000000000000 R12: ffff8800096c8d70 [ 1523.750066] R13: ffff8800096c8d00 R14: 0000000000000000 R15: ffff8800095b45e0 [ 1523.750066] FS: 00007f7a923f3700(0000) GS:ffff880013600000(0000) knlGS:0000000000000000 [ 1523.750066] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1523.750066] CR2: fffffffffffffff0 CR3: 000000000969d000 CR4: 00000000000406f0 [ 1523.750066] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1523.750066] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 1523.750066] Process trinity-child64 (pid: 9050, threadinfo ffff880045f80000, task ffff880048eb0000) [ 1523.750066] Stack: [ 1523.750066] ffff88000d7533f0 fffffffffffffff0 ffff880045f81da8 ffffffff812361d8 [ 1523.750066] ffff880045f81d98 ffff880048ee9000 ffff8800095b4580 ffff8800095b4580 [ 1523.750066] ffff88001d1cdb00 ffff8800095b45f0 ffff880022a4d630 ffff8800095b45e0 [ 1523.750066] Call Trace: [ 1523.750066] [] validate_mm+0x58/0x1e0 [ 1523.750066] [] vma_adjust+0x635/0x6b0 [ 1523.750066] [] __split_vma.isra.22+0x161/0x220 [ 1523.750066] [] split_vma+0x24/0x30 [ 1523.750066] [] sys_madvise+0x5da/0x7b0 [ 1523.750066] [] ? rcu_eqs_exit+0x9c/0xb0 [ 1523.750066] [] ? trace_hardirqs_on+0xd/0x10 [ 1523.750066] [] tracesys+0xe1/0xe6 [ 1523.750066] Code: 4c 09 ff 48 39 ce 77 9e f3 c3 0f 1f 44 00 00 31 c0 c3 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 53 48 89 fb 48 83 ec 08 <48> 8b 17 48 8b 8a 90 00 00 00 48 39 4f 40 74 34 80 3d f7 1f 5c [ 1523.750066] RIP [] anon_vma_interval_tree_verify+0xc/0xa0 [ 1523.750066] RSP [ 1523.750066] CR2: fffffffffffffff0 [ 1523.750066] ---[ end trace e35e5fa49072faf9 ]--- Reported-by: Sasha Levin Figured-out-by: Bob Liu Signed-off-by: Michel Lespinasse Reviewed-by: Rik van Riel --- mm/mmap.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 2d942353d681..9a796c41e7d9 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -334,8 +334,10 @@ void validate_mm(struct mm_struct *mm) struct vm_area_struct *vma = mm->mmap; while (vma) { struct anon_vma_chain *avc; + vma_lock_anon_vma(vma); list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) anon_vma_interval_tree_verify(avc); + vma_unlock_anon_vma(vma); vma = vma->vm_next; i++; }