From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227cYvUJKAXnwiuFUm5sa8enVJb8m+1R8dUHAAKkwS0POJA2RAyOdcnR1xPKSrmi/JnWEMDw ARC-Seal: i=1; a=rsa-sha256; t=1516611280; cv=none; d=google.com; s=arc-20160816; b=RXqVynTUFE6uQQUdWoAH8EqMPmHU+Y1UK47kr2H9vXtU0eTzZDJ6fHsAX+nlyiJmEi pki5yjTHYifw99VuW8gy//wSWvPyX4PV4BE6BE0ERc3jfCBtBiFvVzvc7N263Rnyjysn XY8LPBGfuB2zAnUVy7DXl9Yo5c3XT+/l9b0JXA2O3EJYPEf05x4GdQc6HOWZV+kXZJra n5qvuTUq8dyncAUddlHe7pWGMtKBx3IDrR/35aF8PnhLUJ2wbSU2JypOcskpKYQ3ASsk dureWUEaoaVmV1GGL6Kv28JebPoDUTkIhSn3tsa52ra9HTwPcvVBTVNU4vdLzGsCL9Vd nKmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=NdLaMx5IbDj3eLj3Ogo1accNI56uBcB3Rlzu28v/MRA=; b=MChoHIgh87QRXqak4BVe5PoYghKpl86yi3Px1uGroI0ggtTbufJVne0qYqLsKSukSc rff4azdQvZXlHAiDlUqLbZmwN6tRCcLiSQkx/Rqgm9CFnaIdOVLZ74JV6ht4xdjW8GhW eTBFm1o9344bLNmc8cLP6mwvpi8E0q2JuiFb3Xyham5MjLdI0EiUpoViCWeOWOV9Vqpb Hd02crEh2CL3QRtDw1NxYNZs/YDEhMJt3Bpn3YgI4b3BAb+Aq/O3SZWbypKDjq/llCNZ UMt+uIaYerzsejVswOgkRi0ovTN+Wm/lvRiV0HTZUDgRb4GhYKLlA2m5x4ty1k/b/8pG iGiw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org 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.14 79/89] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Date: Mon, 22 Jan 2018 09:45:59 +0100 Message-Id: <20180122084002.349818588@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083954.683903493@linuxfoundation.org> References: <20180122083954.683903493@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590282189783367781?= X-GMAIL-MSGID: =?utf-8?q?1590282189783367781?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-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 --- virt/kvm/arm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1310,7 +1310,7 @@ static int user_mem_abort(struct kvm_vcp return -EFAULT; } - if (is_vm_hugetlb_page(vma) && !logging_active) { + if (vma_kernel_pagesize(vma) == PMD_SIZE && !logging_active) { hugetlb = true; gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT; } else {