From patchwork Tue Jun 30 10:48:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50454 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0FB98229DF for ; Tue, 30 Jun 2015 10:50:22 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf2471503wgb.2 for ; Tue, 30 Jun 2015 03:50:21 -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=NVZ/w6ejri4XpzeJ9VMuuHfrPqzzxlAXjArZSY7A4k2U8X2woSxvFTON4xCj89zQx7 yseewLfEhxUZAI1hC9neHjFzFmQWJFOweEJ8Er8zeHmcSv2PHA2iXEAwSQuwFiG6fS+2 pf1zzLmvhxDNUO3Jr9OB7f+1awAtYIxBBeew9RKFs356o+OLppjobkqeuNboRygGN7Qq d6PQY9qBeueGRF3RziepPbnU7jq6Taw4dMQekj7xe71Uvg/kdq+7V8N7zkrun/8G1v0R 2mtaM6owgp5/0QGzCJmRugcgTWbtzEIDwzjKPXw/cgqZh8ieyOKJIKuE/yAfnInTq9jf Tbdw== X-Gm-Message-State: ALoCoQnEC6r/QjpV35s42/GBJmi2f07Ymn0z6G26+37Pk/PlxlBlR4BW3LkOld27SKxWjln12Xu4 X-Received: by 10.113.11.3 with SMTP id ee3mr13745769lbd.9.1435661421014; Tue, 30 Jun 2015 03:50:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.105 with SMTP id x9ls27579laj.11.gmail; Tue, 30 Jun 2015 03:50:20 -0700 (PDT) X-Received: by 10.112.199.10 with SMTP id jg10mr18881310lbc.24.1435661420798; Tue, 30 Jun 2015 03:50:20 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id r1si37776896lar.2.2015.06.30.03.50.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2015 03:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lagh6 with SMTP id h6so8090279lag.2 for ; Tue, 30 Jun 2015 03:50:20 -0700 (PDT) X-Received: by 10.112.93.37 with SMTP id cr5mr19116862lbb.106.1435661420700; Tue, 30 Jun 2015 03:50:20 -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 hn6csp2352668lbb; Tue, 30 Jun 2015 03:50:19 -0700 (PDT) X-Received: by 10.68.173.197 with SMTP id bm5mr42635963pbc.13.1435661418759; Tue, 30 Jun 2015 03:50:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si66313267par.87.2015.06.30.03.50.17; Tue, 30 Jun 2015 03:50:18 -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 S1752602AbbF3KuQ (ORCPT + 2 others); Tue, 30 Jun 2015 06:50:16 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:35277 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752130AbbF3KuP (ORCPT ); Tue, 30 Jun 2015 06:50:15 -0400 Received: by pactm7 with SMTP id tm7so3801944pac.2 for ; Tue, 30 Jun 2015 03:50:15 -0700 (PDT) X-Received: by 10.70.90.103 with SMTP id bv7mr42823567pdb.160.1435661415247; Tue, 30 Jun 2015 03:50:15 -0700 (PDT) Received: from localhost ([120.136.36.232]) by mx.google.com with ESMTPSA id fr2sm45227514pdb.22.2015.06.30.03.50.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Jun 2015 03:50:14 -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 06/22] arm/arm64: KVM: fix potential NULL dereference in user_mem_abort() Date: Tue, 30 Jun 2015 18:48:54 +0800 Message-Id: <1435661350-8060-7-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1435661350-8060-1-git-send-email-shannon.zhao@linaro.org> References: <1435661350-8060-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.215.54 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;