From patchwork Mon Apr 12 16:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 12198499 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=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 83462C43600 for ; Mon, 12 Apr 2021 16:25:21 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 313B661287 for ; Mon, 12 Apr 2021 16:25:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 313B661287 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=mail.ustc.edu.cn Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:Cc: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=mBVs35vT5fzRvkhRUDoVwbMOZd3ecnZASoezXaLsNf0=; b=oXYBQUTt+5+hA6mXeFD7KvqTb o0XbVWBkflITWDsqogtHsMx2aNyK4+7nl4g4BiyoGfk+aknTjq+WEmzxx0OX5bZvV0VU/8c1LNqlw 7km371voU57Ycv/KCuDDQqsO+e5upCGGwqkX+AiJ48OxLUI3WWx3zSsAnq0xugXC5fF8aFvUuwEUG AyBAYXUaNYoFcg58mvegpRhhpfrMCWgICQthwFKa99Pjo6QFwebz/dtkU12nDrknSPsbJ+r8f7j6D O5QMfnzuy2F0nkQqnAN1U5+DYTU3uM74KGhpBuIwl7coFPMWQApGQmVFV6bsiPSoCfXI7gmnQU7vO 49DWSQaMw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVzNB-007F76-5M; Mon, 12 Apr 2021 16:25:13 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVzMi-007Ewx-5g for linux-riscv@desiato.infradead.org; Mon, 12 Apr 2021 16:24:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-ID:Content-Description; bh=tgiV723OwAJ2pykk1xV95dqYNKcllTshDqSw0LXtNlE=; b=c8l3GBa5r5FcFyokXWmtib9N2g QBZsUXTT3/PXVVZq6GDFIKlqQBUVGoRbKZ/AtVMCc7I69MzC2OmzXg0l8syPWeNbLADSc2kcMTkPh kB1/T0bPHQ3XGH0jDfE5iWtQBXmPJIaWu/RBseX5Vut8etcmuDv5SuZb7inXwjkXYKPn0K6gDLiPF SI7lnh9oX1DAvpIeJAnrHLArIb3mVM2He367W3ex0CTqNnX3+Y4jeqHkcQMfaVFNngBn9iG0w/VhB y5xNAMM+zLflxaBOB/5OgJrQhNsX5o468NBnm53PyT/hgEH8xHdtoiRqWC/Q6fN2wFA2j6PcJby3e f0KrXIUA==; Received: from email6.ustc.edu.cn ([2001:da8:d800::8] helo=ustc.edu.cn) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVzMf-006OIa-Bf for linux-riscv@lists.infradead.org; Mon, 12 Apr 2021 16:24:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:Date:From:To:Cc:Subject: Message-ID:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=tgiV723OwAJ2pykk1xV95dqYNKcllTshDq Sw0LXtNlE=; b=J5o+pzkkjZg4/mI0aCtCYnK2TWTUGYl33YDcA/yMd6S4F7CJAs ELsVGZYvtJhzo9rBeK5pG+ztEyE0BnggMoAVmtbpISZ/nOJaIUP9HFJoRQ6UrJzj bBl05PKAsgXSyZmx2rN90pK/3+K+UuK6CJtpM9bBpwiwrb+dVJ5vYJkOw= Received: from xhacker (unknown [101.86.20.15]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygAXIqw_dHRgwUHLAA--.44340S2; Tue, 13 Apr 2021 00:24:32 +0800 (CST) Date: Tue, 13 Apr 2021 00:19:29 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , " =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= " , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang , Anup Patel Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/10] riscv: module: Create module allocations without exec permissions Message-ID: <20210413001929.6935dcf0@xhacker> In-Reply-To: <20210413001110.7209bae6@xhacker> References: <20210413001110.7209bae6@x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1UYxBIdaVFxhVjvjDU0xZFpf9x07bo-e rUUUUU= X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_092441_862613_4C253AB9 X-CRM114-Status: UNSURE ( 9.39 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Jisheng Zhang The core code manages the executable permissions of code regions of modules explicitly, it is not necessary to create the module vmalloc regions with RWX permissions. Create them with RW- permissions instead. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index 104fba889cf7..e89367bba7c9 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -407,14 +407,20 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, return 0; } -#if defined(CONFIG_MMU) && defined(CONFIG_64BIT) +#ifdef CONFIG_MMU + +#ifdef CONFIG_64BIT #define VMALLOC_MODULE_START \ max(PFN_ALIGN((unsigned long)&_end - SZ_2G), VMALLOC_START) +#else +#define VMALLOC_MODULE_START VMALLOC_START +#endif + void *module_alloc(unsigned long size) { return __vmalloc_node_range(size, 1, VMALLOC_MODULE_START, VMALLOC_END, GFP_KERNEL, - PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, + PAGE_KERNEL, 0, NUMA_NO_NODE, __builtin_return_address(0)); } #endif