Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp542263pxf; Wed, 31 Mar 2021 09:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLndei4Cse084QDYTRemX8pjeqLGwEmxw4f+FdmIuOi6fCoKIuQxjPn3R2ZOWKBswOt9PU X-Received: by 2002:a05:6402:30a2:: with SMTP id df2mr4740715edb.29.1617208558852; Wed, 31 Mar 2021 09:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617208558; cv=none; d=google.com; s=arc-20160816; b=geJ/KdEqnnc8Mz9AAB1qpE0xnXgZXJKqC8zhMYHA81cUSq+eeKmeF9I93s6cPFE76I Cf58V+FYAC4op9ubU5F9XP9R6SPX79QA8u6xSXOobX3mK93xZfGQLdV2UdLfTo8yD7dL lM0LK5IecLzyLMYCgSb+b5GdeJFLMKJgJuHsG+pGEoFCY6qOWxRr3DWNlH9o+TNoLVoq QQUFAIitb5es8H9Q4bAbkjQOsFWnBgz2q2gZ/ULE7c4JWjwhvyWF0t5Y/zVgCUOIp9Lp qT8gIUDq9A0373Im7U8X6Jw7j472gHbUWYLwQBLrnOsth1+lAlvvXR+bLCw8qtkR4CSE Be0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=rWZY9UwzK3VhbJb3NlTJX8W59dG2h3SG5jHHtJwc4J0=; b=WV6Ag2q/9/EhJIyja5UiATgdJitSJh/v07irECAHE+EyqkrzFmReQTrEIx5uu8lDFK /V8fcHiAZVFsBbVbCpevXXdIcnMyiKIvXnZpegGY+yjdrjHYG1jgSslV59vjgk588IB8 8KrBC0gCyP3WRSQ713pBYpUpfgO8z+J5ylNa+lbVAUuopjkR4St9b6Ppm24huAZjjYZw nvi+2ClJLX0ZL/GFWoWp9QlApRXZUm5bdnDZgPJnTAjwN3C2kxFiynm3lqGqNcH9yQ2L wQ8qyG2UfMXxszwRS3qHITyyZF51o6g0g3tAWPekVR3SOvF4Cn9evpZEBcy3GzuVfvd8 B88w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=H8FUPEu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si2174072eds.451.2021.03.31.09.35.35; Wed, 31 Mar 2021 09:35:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=H8FUPEu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234047AbhCaQec (ORCPT + 99 others); Wed, 31 Mar 2021 12:34:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbhCaQeP (ORCPT ); Wed, 31 Mar 2021 12:34:15 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 36A4AC061574; Wed, 31 Mar 2021 09:34:14 -0700 (PDT) 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=rWZY9UwzK3VhbJb3NlTJX8W59dG2h3SG5j HHtJwc4J0=; b=H8FUPEu6pKHAwwuYYRBKOKNjGGOKNFVwdUIA/ZFoeose4zCZTu iz2T5jwJFwrqPRrc0r5Ag5n/AYAMR73E2g65OQ8ojROH0hkSvXaZL/sml+V2fwVX +IB+EPdfRa28Cu2e07XizxteA9sdAQ7pYE3Psh77p+GWcPwg77hfrOpYc= Received: from xhacker (unknown [101.86.19.180]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygAHD0t1pGRgMb96AA--.13595S2; Thu, 01 Apr 2021 00:33:58 +0800 (CST) Date: Thu, 1 Apr 2021 00:29:00 +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 , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v2 8/9] riscv: module: Create module allocations without exec permissions Message-ID: <20210401002900.470f3413@xhacker> In-Reply-To: <20210401002442.2fe56b88@xhacker> References: <20210401002442.2fe56b88@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygAHD0t1pGRgMb96AA--.13595S2 X-Coremail-Antispam: 1UD129KBjvJXoW7GFyfWF4rGrWktry5Wr1xXwb_yoW8JrWUpr 4xCrn0vrWrWw4xG3ySyF1vgF95Cws7Gr4Sga9rWFy7AanxJr4rAwn0gwn5Zry2qFy8ur48 Wr43ur1SvFyUA37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkEb7Iv0xC_KF4lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjc xK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG 64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v26r 1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwACI402YVCY1x02628vn2kI c2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07jnCz tUUUUU= X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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 -- 2.31.0