bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <zhe.he@windriver.com>
To: <linux@armlinux.org.uk>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<kafai@fb.com>, <songliubraving@fb.com>, <yhs@fb.com>,
	<matthias.schiffer@ew.tq-group.com>, <info@metux.net>,
	<gregkh@linuxfoundation.org>, <tglx@linutronix.de>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>, <zhe.he@windriver.com>
Subject: [PATCH] ARM: module: Avoid W and X mappings at the beginning
Date: Sat, 10 Aug 2019 16:09:35 +0800	[thread overview]
Message-ID: <1565424575-346010-1-git-send-email-zhe.he@windriver.com> (raw)

From: He Zhe <zhe.he@windriver.com>

It is more secure to map module memory as not-execute at the beginning.
Memory sections that need to be executable will be turned to executable
later in complete_formation.

This is a corresponding change for ARM to the following commit
commit f2c65fb3221a ("x86/modules: Avoid breaking W^X while loading modules")

Tested with test_bpf:
test_bpf: Summary: 378 PASSED, 0 FAILED, [0/366 JIT'ed]

Signed-off-by: He Zhe <zhe.he@windriver.com>
---
 arch/arm/kernel/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index deef17f..197b3b9 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -45,12 +45,12 @@ void *module_alloc(unsigned long size)
 		gfp_mask |= __GFP_NOWARN;
 
 	p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
-				gfp_mask, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
+				gfp_mask, PAGE_KERNEL, 0, NUMA_NO_NODE,
 				__builtin_return_address(0));
 	if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p)
 		return p;
 	return __vmalloc_node_range(size, 1,  VMALLOC_START, VMALLOC_END,
-				GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
+				GFP_KERNEL, PAGE_KERNEL, 0, NUMA_NO_NODE,
 				__builtin_return_address(0));
 }
 #endif
-- 
2.7.4


                 reply	other threads:[~2019-08-10  8:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1565424575-346010-1-git-send-email-zhe.he@windriver.com \
    --to=zhe.he@windriver.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=info@metux.net \
    --cc=kafai@fb.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=matthias.schiffer@ew.tq-group.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).