From patchwork Fri Apr 8 07:24:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 90273 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 462EFB7004 for ; Fri, 8 Apr 2011 17:24:12 +1000 (EST) Received: by ozlabs.org (Postfix) id 81A8BB6F7D; Fri, 8 Apr 2011 17:24:01 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: by ozlabs.org (Postfix, from userid 1034) id 8009FB6F8D; Fri, 8 Apr 2011 17:24:01 +1000 (EST) To: Message-Id: <10e5cbf67c850b6ae511979bdbad1761236ad9b0.1302247435.git.michael@ellerman.id.au> From: Michael Ellerman Subject: [PATCH] mm: Check we have the right vma in __access_remote_vm() Date: Fri, 8 Apr 2011 17:24:01 +1000 (EST) Cc: aarcange@redhat.com, Andrew Morton , riel@redhat.com, linuxppc-dev@ozlabs.org, hughd@google.com, linux-mm@kvack.org, walken@google.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org In __access_remote_vm() we need to check that we have found the right vma, not the following vma, before we try to access it. Otherwise we might call the vma's access routine with an address which does not fall inside the vma. Signed-off-by: Michael Ellerman --- mm/memory.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 9da8cab..ce999ca 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3678,7 +3678,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm, */ #ifdef CONFIG_HAVE_IOREMAP_PROT vma = find_vma(mm, addr); - if (!vma) + if (!vma || vma->vm_start > addr) break; if (vma->vm_ops && vma->vm_ops->access) ret = vma->vm_ops->access(vma, addr, buf,