From patchwork Tue Jan 12 21:46:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 8021121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 408AC9F716 for ; Tue, 12 Jan 2016 21:48:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7194D203C3 for ; Tue, 12 Jan 2016 21:48:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B4D62011D for ; Tue, 12 Jan 2016 21:48:50 +0000 (UTC) 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 1aJ6mF-0001UT-M8; Tue, 12 Jan 2016 21:46:55 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJ6mC-0001PJ-Ms for linux-arm-kernel@lists.infradead.org; Tue, 12 Jan 2016 21:46:53 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 97520744; Tue, 12 Jan 2016 21:46:31 +0000 (UTC) Received: from labbott-redhat-machine.redhat.com (ovpn-112-96.phx2.redhat.com [10.3.112.96]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0CLkTuV007797; Tue, 12 Jan 2016 16:46:30 -0500 From: Laura Abbott To: Catalin Marinas , Will Deacon , Mark Rutland Subject: [PATCH] arm64: Allow vmalloc regions to be set with set_memory_* Date: Tue, 12 Jan 2016 13:46:27 -0800 Message-Id: <1452635187-8057-1-git-send-email-labbott@fedoraproject.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160112_134652_794687_60F022D9 X-CRM114-Status: GOOD ( 15.17 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kees Cook , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Laura Abbott MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The range of set_memory_* is currently restricted to the module address range because of difficulties in breaking down larger block sizes. vmalloc maps PAGE_SIZE pages so it is safe to use as well. Update the function ranges and add a comment explaining why the range is restricted the way it is. Signed-off-by: Laura Abbott --- This should let the protections for the eBPF work as expected, I don't know if there is some sort of self test for thatL. --- arch/arm64/mm/pageattr.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c index 3571c73..274208e 100644 --- a/arch/arm64/mm/pageattr.c +++ b/arch/arm64/mm/pageattr.c @@ -36,6 +36,26 @@ static int change_page_range(pte_t *ptep, pgtable_t token, unsigned long addr, return 0; } +static bool validate_addr(unsigned long start, unsigned long end) +{ + /* + * This check explicitly excludes most kernel memory. Most kernel + * memory is mapped with a larger page size and breaking down the + * larger page size without causing TLB conflicts is very difficult. + * + * If you need to call set_memory_* on a range, the recommendation is + * to use vmalloc since that range is mapped with pages. + */ + if (start >= MODULES_VADDR && start < MODULES_END && + end >= MODULES_VADDR && end < MODULES_END) + return true; + + if (is_vmalloc_addr(start) && is_vmalloc_addr(end)) + return true; + + return false; +} + static int change_memory_common(unsigned long addr, int numpages, pgprot_t set_mask, pgprot_t clear_mask) { @@ -51,10 +71,7 @@ static int change_memory_common(unsigned long addr, int numpages, WARN_ON_ONCE(1); } - if (start < MODULES_VADDR || start >= MODULES_END) - return -EINVAL; - - if (end < MODULES_VADDR || end >= MODULES_END) + if (!validate_addr(start, end)) return -EINVAL; data.set_mask = set_mask;