Received: by 10.223.176.5 with SMTP id f5csp2848217wra; Mon, 29 Jan 2018 05:06:43 -0800 (PST) X-Google-Smtp-Source: AH8x2255WTBYLS8llC2T7uqivHMOFcc3Q1tIySGmDv+VGoEz7mF2PbINVxAvu/w5kBILYMyP8SIa X-Received: by 2002:a17:902:8d97:: with SMTP id v23-v6mr17373936plo.248.1517231203066; Mon, 29 Jan 2018 05:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517231203; cv=none; d=google.com; s=arc-20160816; b=KvMXjd/m+xI9FaXL88anEax25lk/TzDFwIJw8/c83tJFEX34MMdvvjmUFdg0c6iUPz HGKKAn/yDKeS+gwZQ4Gh1/53t5xMPzsfEy+9SsTr5n9sAQsUMPsz/N7wzizQpGAyPLl8 DusOXvRcNxyN6G7yu3v5qqZXulD1CFf62pLwlWsvN3Gc/mCumjpM9GJb4Y6jIPhlXPYV ZjdSqTikzy/JPQgqH/pnv5ClZyjVSVrGztgXQHqYxmdyQ5mQfrzkIhtV/9eFGGkIFCgU gWmXNz+SNXlbsjbqVcaObEumhQzcUZRqfAtIXDF1wn/8fDXONLaReuOq/7ZElGD0mF8J y4sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1Pz0Ni+uYXHk9H6DOWWKJv8pn6BlOZkuH3RhMPxECrg=; b=o+9x1OK7VgodOKUWUYBm7G+yR6gly8WKpKSMBcQ1gevUAQkNBCUPQrKzkEYDUv2h0t jQ2rXSATDgLxSW8j/APCXcypLlRANMbKlK2QhitAEmUuOSDNVP/iR/KxyjzKuTgavsPz g5qCQir8piVZ+t2RSf2DRJPTIxBXWKQhfUlV97P/xjYttrRWJM+sMmXLV1JilFUIl9jQ r/xsGaEyKW3/x/+UTIrNbqWZyPcTnOye2GHEm8g0raJzUa7VUuCycquxDXYZJdzT7c9t bhUnDoUIE/OzHTCJtZ+CmJIcbb+30OXChouzek6xvR+UQE+JhlqzKzRUhOym/NwYTQOH DwQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si9388944ple.739.2018.01.29.05.06.28; Mon, 29 Jan 2018 05:06:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751949AbeA2NF7 (ORCPT + 99 others); Mon, 29 Jan 2018 08:05:59 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42404 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751740AbeA2NF5 (ORCPT ); Mon, 29 Jan 2018 08:05:57 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7B5C12F94; Mon, 29 Jan 2018 13:05:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Punit Agrawal , Marc Zyngier , Christoffer Dall Subject: [PATCH 4.9 09/66] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Date: Mon, 29 Jan 2018 13:56:33 +0100 Message-Id: <20180129123840.324072883@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Punit Agrawal commit c507babf10ead4d5c8cca704539b170752a8ac84 upstream. KVM only supports PMD hugepages at stage 2 but doesn't actually check that the provided hugepage memory pagesize is PMD_SIZE before populating stage 2 entries. In cases where the backing hugepage size is smaller than PMD_SIZE (such as when using contiguous hugepages), KVM can end up creating stage 2 mappings that extend beyond the supplied memory. Fix this by checking for the pagesize of userspace vma before creating PMD hugepage at stage 2. Fixes: 66b3923a1a0f77a ("arm64: hugetlb: add support for PTE contiguous bit") Signed-off-by: Punit Agrawal Cc: Marc Zyngier Reviewed-by: Christoffer Dall Signed-off-by: Christoffer Dall Signed-off-by: Greg Kroah-Hartman --- arch/arm/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -1284,7 +1284,7 @@ static int user_mem_abort(struct kvm_vcp return -EFAULT; } - if (is_vm_hugetlb_page(vma) && !logging_active) { + if (vma_kernel_pagesize(vma) && !logging_active) { hugetlb = true; gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT; } else {