From patchwork Wed Sep 17 21:56:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 37546 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A5EC32054D for ; Wed, 17 Sep 2014 21:58:51 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id m15sf1212654wgh.11 for ; Wed, 17 Sep 2014 14:58:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=reJMQWPhbcl2XCE6iPprEVBKdqDCYz+yUihWP7Subls=; b=Xaml9wq57RdyYYrIZ/5MotKopszH9cVs8Tbbfzg2/3hUmQUrxgRiWuuJIzOWfLcP9S Zx0hZy4WVsEXQB6DQknti4LWMK6rdQE/jRqF9dzK1udAv+/a822kZ/lMo+bfPHxI7Aaj QBdWNSuKD6WbHcKD9aKYPbFnbKL//kCetzPCcEP94XSy1GMSQs3x9Pl6o1SyPGPbjFCz cM2ArkeQZ5b1HQf9ERE1F0BXj51DrEqtpbfbMVUIfwKPOoXI6cS5tCVE3MQuBKzP5j56 iPihHRDhCg3sKp6/o+IH/VEzqsEgalUjgIyJ5r6HSvtWqYAh5k8ghaQ4u9FwMb9d70r0 t3TQ== X-Gm-Message-State: ALoCoQlR2HhzrpMTsg0kveaANmXtS3sQ9UcewhH4qZ/pa2t1SJmEQZnbE0eWE9jHT2ZgJotzTc// X-Received: by 10.152.42.229 with SMTP id r5mr15018lal.8.1410991130537; Wed, 17 Sep 2014 14:58:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.101 with SMTP id j5ls164155laj.1.gmail; Wed, 17 Sep 2014 14:58:50 -0700 (PDT) X-Received: by 10.112.13.132 with SMTP id h4mr89800lbc.45.1410991130073; Wed, 17 Sep 2014 14:58:50 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) by mx.google.com with ESMTPS id o6si30204380lbc.99.2014.09.17.14.58.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Sep 2014 14:58:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id z11so2787572lbi.35 for ; Wed, 17 Sep 2014 14:58:50 -0700 (PDT) X-Received: by 10.112.53.230 with SMTP id e6mr141404lbp.100.1410991130001; Wed, 17 Sep 2014 14:58:50 -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.130.169 with SMTP id of9csp661955lbb; Wed, 17 Sep 2014 14:58:49 -0700 (PDT) X-Received: by 10.70.35.108 with SMTP id g12mr125633pdj.34.1410991128554; Wed, 17 Sep 2014 14:58:48 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d7si36770078pdf.132.2014.09.17.14.58.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Sep 2014 14:58:48 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XUNDZ-0001nH-IW; Wed, 17 Sep 2014 21:56:53 +0000 Received: from mail-pd0-f182.google.com ([209.85.192.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XUNDW-0001kq-20 for linux-arm-kernel@lists.infradead.org; Wed, 17 Sep 2014 21:56:50 +0000 Received: by mail-pd0-f182.google.com with SMTP id w10so2950883pde.13 for ; Wed, 17 Sep 2014 14:56:32 -0700 (PDT) X-Received: by 10.68.225.9 with SMTP id rg9mr642794pbc.72.1410990991961; Wed, 17 Sep 2014 14:56:31 -0700 (PDT) Received: from ards-macbook-pro.swisscom.com (70-35-38-154.static.wiline.com. [70.35.38.154]) by mx.google.com with ESMTPSA id v1sm17771310pdn.93.2014.09.17.14.56.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Sep 2014 14:56:30 -0700 (PDT) From: Ard Biesheuvel To: christoffer.dall@linaro.org, marc.zyngier@arm.com, linux@arm.linux.org.uk, catalin.marinas@arm.com Subject: [PATCH 2/6] arm/arm64: KVM: fix potential NULL dereference in user_mem_abort() Date: Wed, 17 Sep 2014 14:56:17 -0700 Message-Id: <1410990981-665-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1410990981-665-1-git-send-email-ard.biesheuvel@linaro.org> References: <1410990981-665-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140917_145650_134215_96F72698 X-CRM114-Status: GOOD ( 10.49 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.182 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.182 listed in wl.mailspike.net] Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.176 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 Handle the potential NULL return value of find_vma_intersection() before dereferencing it. Signed-off-by: Ard Biesheuvel Acked-by: Marc Zyngier Acked-by: Marc Zyngier --- arch/arm/kvm/mmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 152e0f896e63..c093e95ff7ef 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -776,7 +776,11 @@ 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 (is_vm_hugetlb_page(vma)) { + if (unlikely(!vma)) { + kvm_err("Failed to find VMA for hva 0x%lx\n", hva); + up_read(¤t->mm->mmap_sem); + return -EFAULT; + } else if (is_vm_hugetlb_page(vma)) { hugetlb = true; gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT; } else {