From patchwork Tue Jun 2 14:48:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49391 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2F74820BD1 for ; Tue, 2 Jun 2015 14:50:42 +0000 (UTC) Received: by labpg10 with SMTP id pg10sf12776868lab.2 for ; Tue, 02 Jun 2015 07:50:41 -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=b7Z3j8eyOjZgFgNixC/NQG1b9Ot0Vm/Vz3GG4ImfSO7nsCtK519hTD9BXHZKIfyRlV RVnlt4JmNcMIICWsOjnMcNtB6WkvHlWumTgtSMRBWTdsXo0HXjRNK1jqUF+aY3kxLOvm v8HvfOFq2Ti+ebGpDBgpZMm7XOfHuZ/UEVVv3bTJzpIZ/2zgDm8KeLcm5gZy+EbZHdQs RMPdGf1uWLV1nYw/aAShakDNAroqvcAYa4gU9y+Cd53Qd/mx+QzSlpb5QKl6MTwedtd6 4jsRL0kq3d4n3g2WgC1yv/1UxHH1kkcOdCN+UunUlDE9fE/zkxcRDKTWmn25X4Di3ld/ dYzw== X-Gm-Message-State: ALoCoQlUmRTbO4U93ZInCUdftUqyWdL+7+2kVlLc2v+bBlIij6SjCTLqkOjnIZbo8kI+UhKuWx3z X-Received: by 10.152.88.37 with SMTP id bd5mr2968210lab.0.1433256641064; Tue, 02 Jun 2015 07:50:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.135 with SMTP id e7ls855273lam.79.gmail; Tue, 02 Jun 2015 07:50:40 -0700 (PDT) X-Received: by 10.152.43.37 with SMTP id t5mr25971806lal.96.1433256640841; Tue, 02 Jun 2015 07:50:40 -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 xx2si15279922lbb.82.2015.06.02.07.50.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:50:40 -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 lbcue7 with SMTP id ue7so106087485lbc.0 for ; Tue, 02 Jun 2015 07:50:40 -0700 (PDT) X-Received: by 10.112.182.4 with SMTP id ea4mr21576284lbc.35.1433256640530; Tue, 02 Jun 2015 07:50:40 -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.108.230 with SMTP id hn6csp3129191lbb; Tue, 2 Jun 2015 07:50:39 -0700 (PDT) X-Received: by 10.68.167.162 with SMTP id zp2mr13201511pbb.105.1433256639535; Tue, 02 Jun 2015 07:50:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hv8si26697315pdb.173.2015.06.02.07.50.38; Tue, 02 Jun 2015 07:50:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759330AbbFBOui (ORCPT + 2 others); Tue, 2 Jun 2015 10:50:38 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:34194 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932307AbbFBOuh (ORCPT ); Tue, 2 Jun 2015 10:50:37 -0400 Received: by oifu123 with SMTP id u123so127411112oif.1 for ; Tue, 02 Jun 2015 07:50:37 -0700 (PDT) X-Received: by 10.202.104.223 with SMTP id o92mr21746664oik.19.1433256636932; Tue, 02 Jun 2015 07:50:36 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id c85sm9613537oig.14.2015.06.02.07.50.34 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:50:35 -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 16/32] arm/arm64: KVM: fix potential NULL dereference in user_mem_abort() Date: Tue, 2 Jun 2015 22:48:11 +0800 Message-Id: <1433256507-7856-17-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> References: <1433256507-7856-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;