From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68BA9C2D0EA for ; Wed, 8 Apr 2020 12:38:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21E462074F for ; Wed, 8 Apr 2020 12:38:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O8K0WFA4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21E462074F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+Laj3if3k8Il5sMCHozwJVRBl9lF+HZAQnioL1rT/Mo=; b=O8K0WFA46XcyYs JUuwEujMiCZ+QWqX306WrsWza4J7j0MLa+s8ZILCwtA8NmqonTg3N3q/TZrGnNlPgdN+C+FaeksqE 5tW/e+HqqYFFSE6IJBkLFEBNaKhd0SOGN8WvhsUzUWXRh4e2gV7mGVuxQhLjKrrgQ9E7naJzbCkZ3 aQIJPngJjKeoh5fbn1fU9MYYPOBu700EW36i8D1slXjvEB1no95WseNqCPF1layktELW/+KzddZAX CCCxYFhlOF5A7Bc/PxIojy/FJOl99u3+kOzPLndQ2dqmRmHwfkbUdsdofbRVHXSiEdpfR3cdEbo6g GDVFNVmSr+JAh8ZEfvsQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jM9ye-0002jn-Fk; Wed, 08 Apr 2020 12:38:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jM9yc-0002jM-5c for linux-arm-kernel@lists.infradead.org; Wed, 08 Apr 2020 12:38:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87C1331B; Wed, 8 Apr 2020 05:38:41 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0ADA83F73D; Wed, 8 Apr 2020 05:38:37 -0700 (PDT) Date: Wed, 8 Apr 2020 13:38:36 +0100 From: Mark Rutland To: Christoph Hellwig Subject: Re: [PATCH 18/28] mm: enforce that vmap can't map pages executable Message-ID: <20200408123835.GB36478@lakrids.cambridge.arm.com> References: <20200408115926.1467567-1-hch@lst.de> <20200408115926.1467567-19-hch@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200408115926.1467567-19-hch@lst.de> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200408_053842_299556_F648C481 X-CRM114-Status: GOOD ( 17.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-hyperv@vger.kernel.org, David Airlie , Catalin marinas , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, "K. Y. Srinivasan" , Will Deacon , Sumit Semwal , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Wei Liu , Stephen Hemminger , x86@kernel.org, Peter Zijlstra , Laura Abbott , Nitin Gupta , Daniel Vetter , Haiyang Zhang , linaro-mm-sig@lists.linaro.org, bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christophe Leroy , Robin Murphy , linux-kernel@vger.kernel.org, Minchan Kim , iommu@lists.linux-foundation.org, Sakari Ailus , Andrew Morton , linuxppc-dev@lists.ozlabs.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 08, 2020 at 01:59:16PM +0200, Christoph Hellwig wrote: > To help enforcing the W^X protection don't allow remapping existing > pages as executable. > > Based on patch from Peter Zijlstra . > > Signed-off-by: Christoph Hellwig > --- > arch/x86/include/asm/pgtable_types.h | 6 ++++++ > include/asm-generic/pgtable.h | 4 ++++ > mm/vmalloc.c | 2 +- > 3 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h > index 947867f112ea..2e7c442cc618 100644 > --- a/arch/x86/include/asm/pgtable_types.h > +++ b/arch/x86/include/asm/pgtable_types.h > @@ -282,6 +282,12 @@ typedef struct pgprot { pgprotval_t pgprot; } pgprot_t; > > typedef struct { pgdval_t pgd; } pgd_t; > > +static inline pgprot_t pgprot_nx(pgprot_t prot) > +{ > + return __pgprot(pgprot_val(prot) | _PAGE_NX); > +} > +#define pgprot_nx pgprot_nx > + > #ifdef CONFIG_X86_PAE I reckon for arm64 we can do similar in our : #define pgprot_nx(pgprot_t prot) \ __pgprot_modify(prot, 0, PTE_PXN) ... matching the style of our existing pgprot_*() modifier helpers. Mark. > > /* > diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h > index 329b8c8ca703..8c5f9c29698b 100644 > --- a/include/asm-generic/pgtable.h > +++ b/include/asm-generic/pgtable.h > @@ -491,6 +491,10 @@ static inline int arch_unmap_one(struct mm_struct *mm, > #define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address) > #endif > > +#ifndef pgprot_nx > +#define pgprot_nx(prot) (prot) > +#endif > + > #ifndef pgprot_noncached > #define pgprot_noncached(prot) (prot) > #endif > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 7356b3f07bd8..334c75251ddb 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2390,7 +2390,7 @@ void *vmap(struct page **pages, unsigned int count, > if (!area) > return NULL; > > - if (map_kernel_range((unsigned long)area->addr, size, prot, > + if (map_kernel_range((unsigned long)area->addr, size, pgprot_nx(prot), > pages) < 0) { > vunmap(area->addr); > return NULL; > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel