From patchwork Mon May 4 01:52:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47969 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C2E362121F for ; Mon, 4 May 2015 01:56:00 +0000 (UTC) Received: by wgiv13 with SMTP id v13sf40433392wgi.3 for ; Sun, 03 May 2015 18:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=erOB7YND7dMh8lxRaSLPJEy+6/xBo1cFsK/bZSwQBAk=; b=VttfQu1Wyo+WOsbIFUsMu/2cF3wHwCPc3tKJKltsRv1nrZcQNH/2zaPw65F4iXp+iv vMfOL7updRxwlooLs0gZc7ml2UZqribu/CUi1JWULEVVWbnCjrYLaw0WbIxfc3sQkiZe tSFxP6KSD82awQjsitiYhEKY+yO5gnHj5127wdIovj1QNyzRZj4+LzAYX4+8MNj38hHh NLigsA98c0CPBrZqzYVfCBKFTrKSH4VzP2f8ZHFfZLdel/vBO3xvhIBrsXceXRXa6u2Q +y6SlzoVsJDOHqQwYpk9jKYErVVoMD+BkX53ylMkNlwCO1b3qtRLQmQpmtZuY9UNquPh qCpA== X-Gm-Message-State: ALoCoQkOf9rgY5UbFIFPkGCEL2vfl14QMx47OfT0HuS2UlX9qErITNyL911qhYRwPmoL+GwUE8l3 X-Received: by 10.112.13.200 with SMTP id j8mr16986388lbc.14.1430704560117; Sun, 03 May 2015 18:56:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.9 with SMTP id 9ls789770laq.89.gmail; Sun, 03 May 2015 18:56:00 -0700 (PDT) X-Received: by 10.153.5.8 with SMTP id ci8mr17757296lad.62.1430704560045; Sun, 03 May 2015 18:56:00 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id g10si9087404lam.78.2015.05.03.18.55.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:55:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbqq2 with SMTP id qq2so95602593lbb.3 for ; Sun, 03 May 2015 18:55:59 -0700 (PDT) X-Received: by 10.152.36.2 with SMTP id m2mr17377335laj.72.1430704559927; Sun, 03 May 2015 18:55:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1413071lbt; Sun, 3 May 2015 18:55:59 -0700 (PDT) X-Received: by 10.67.6.42 with SMTP id cr10mr38564282pad.11.1430704558170; Sun, 03 May 2015 18:55:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.55.57; Sun, 03 May 2015 18:55:58 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751954AbbEDBz5 (ORCPT + 2 others); Sun, 3 May 2015 21:55:57 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:36384 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751961AbbEDBz4 (ORCPT ); Sun, 3 May 2015 21:55:56 -0400 Received: by pdea3 with SMTP id a3so150076197pde.3 for ; Sun, 03 May 2015 18:55:56 -0700 (PDT) X-Received: by 10.68.244.73 with SMTP id xe9mr37984634pbc.98.1430704556171; Sun, 03 May 2015 18:55:56 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id sf6sm11002162pbb.82.2015.05.03.18.55.54 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:55:55 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Ard Biesheuvel Subject: [PATCH for 3.14.y stable 31/47] arm/arm64: KVM: fix potential NULL dereference in user_mem_abort() Date: Mon, 4 May 2015 09:52:26 +0800 Message-Id: <1430704362-6292-32-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Ard Biesheuvel commit 37b544087ef3f65ca68465ba39291a07195dac26 upstream. Handle the potential NULL return value of find_vma_intersection() before dereferencing it. Acked-by: Marc Zyngier Signed-off-by: Ard Biesheuvel Signed-off-by: Christoffer Dall Signed-off-by: Shannon Zhao --- arch/arm/kvm/mmu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 049c56e..8cd0387 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -778,6 +778,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, /* Let's check if we will get back a huge page backed by hugetlbfs */ down_read(¤t->mm->mmap_sem); vma = find_vma_intersection(current->mm, hva, hva + 1); + if (unlikely(!vma)) { + kvm_err("Failed to find VMA for hva 0x%lx\n", hva); + up_read(¤t->mm->mmap_sem); + return -EFAULT; + } + if (is_vm_hugetlb_page(vma)) { hugetlb = true; gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT;