Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1915939pxb; Mon, 12 Apr 2021 09:34:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtQtHnIi4/AXEs0VkvTR2aOZYkp+AF5uvwcQJoLlqYOu13JGLJ4OGilza6TPpx2FfN9+j0 X-Received: by 2002:aa7:cd12:: with SMTP id b18mr30045638edw.340.1618245242890; Mon, 12 Apr 2021 09:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618245242; cv=none; d=google.com; s=arc-20160816; b=TfXrlGjMdCVcYsOT4YkDXdZLTU+u4WVRcQyotjwYJjG6QzQ/QHi4/774irK6TrE+/c KOSmPv5UaSXCYf5oAadFqTFYeBDJiZoqEKH55Ihqmkoz5Ryd0voOshrjUtSrmcKbPgjx Kbg8pMw+AfpFb5twQTj5OXIq1rHXecx6WzfKA0TOw+dlr+7LM6aJTo+Hv2AYkcIH9Iee /sfE6nF8pV3UlDIZWP8567pcMtEeoz0Zzt0Ug21WOJN75t/GM483LMSAsBEZOjBqKazl iiuUO6wfj1wVpAEbwQkP5y6tkCJD/T6uhQgcJ1aVRHHAOlX4GPvr4r6EBRyLCazXjkaT KZ2Q== 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=tgiV723OwAJ2pykk1xV95dqYNKcllTshDqSw0LXtNlE=; b=VViOa73uupQpUtDF+/4cOquFQ6OAuZLGS68nyRiRca0zNVBhrrWCP3vJ0THRIkgXV9 X1ndwbRijJ4D4oMfzxbhVKwMjlxBiujmDSmsIgpne6P+Plpbt7mKiONigvgreghPX4xi koOddLtKuo2fMKovkSxYR/A995WvaxJFxjGTq1UU759aqO06AMFTO9ze70g6ek9wWsuD DhzWcdY+Or9jtVUlM+HqwpRWFPj8uQEWTu2jFU59HbUGZwR/rXHupjSez1DdHk71Eb7T N7AuS1By50bQhjD6krzM3A0RJTohnSHLhBzjaA9qbrO2yIehpnovUE8AIvoErKSotTf0 kd6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=J5o+pzkk; 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 b9si7733794eds.573.2021.04.12.09.33.39; Mon, 12 Apr 2021 09:34:02 -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=J5o+pzkk; 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 S244566AbhDLQaw (ORCPT + 99 others); Mon, 12 Apr 2021 12:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243859AbhDLQZN (ORCPT ); Mon, 12 Apr 2021 12:25:13 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 63EE3C06135A for ; Mon, 12 Apr 2021 09:24:50 -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=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@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygAXIqw_dHRgwUHLAA--.44340S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KFyfWw4rXF4xKFyrJF1DKFg_yoW8JFW5pr 4xCrn0vrWrWw1xG3ySkF1vgF95Cws7Gr4Sga9rWFy7Aan8Jw4rAw1Ygwn5Zr9FqFy8Wr4r Wr43ur1Sva4UA37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkEb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjc xK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG 64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v26r 4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwACI402YVCY1x02628vn2kI c2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07bo-e rUUUUU= 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 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 -- 2.31.0