From: Masami Hiramatsu <mhiramat@kernel.org>
To: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Jiri Olsa <jolsa@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/kprobes: Simplify alloc_insn_page() with __vmalloc_node_range
Date: Tue, 13 Apr 2021 22:00:30 +0900 [thread overview]
Message-ID: <20210413220030.d1cbbc63659dcbc52876696d@kernel.org> (raw)
In-Reply-To: <20210413180231.19b72601@xhacker.debian>
Hi,
On Tue, 13 Apr 2021 18:03:24 +0800
Jisheng Zhang <Jisheng.Zhang@synaptics.com> wrote:
> Use the __vmalloc_node_range() to simplify x86's alloc_insn_page()
> implementation.
Have you checked this is equivarent to the original code on
all architecture? IIRC, some arch has a special module_alloc(),
thus I NACKed similar patch previously.
Thank you,
>
> Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
> ---
> arch/x86/kernel/kprobes/core.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> index df776cdca327..75081f3dbe44 100644
> --- a/arch/x86/kernel/kprobes/core.c
> +++ b/arch/x86/kernel/kprobes/core.c
> @@ -383,26 +383,10 @@ static int prepare_boost(kprobe_opcode_t *buf, struct kprobe *p,
> /* Make page to RO mode when allocate it */
> void *alloc_insn_page(void)
> {
> - void *page;
> -
> - page = module_alloc(PAGE_SIZE);
> - if (!page)
> - return NULL;
> -
> - set_vm_flush_reset_perms(page);
> - /*
> - * First make the page read-only, and only then make it executable to
> - * prevent it from being W+X in between.
> - */
> - set_memory_ro((unsigned long)page, 1);
> -
> - /*
> - * TODO: Once additional kernel code protection mechanisms are set, ensure
> - * that the page was not maliciously altered and it is still zeroed.
> - */
> - set_memory_x((unsigned long)page, 1);
> -
> - return page;
> + return __vmalloc_node_range(PAGE_SIZE, PAGE_SIZE, VMALLOC_START,
> + VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_ROX,
> + VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
> + __builtin_return_address(0));
> }
>
> /* Recover page to RW mode before releasing it */
> --
> 2.31.0
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2021-04-13 13:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 10:03 Jisheng Zhang
2021-04-13 13:00 ` Masami Hiramatsu [this message]
2021-04-14 7:14 ` Jisheng Zhang
2021-04-14 7:27 ` Jisheng Zhang
2021-04-14 8:22 ` Masami Hiramatsu
2021-04-14 13:13 ` Jarkko Sakkinen
2021-04-14 13:12 ` Jarkko Sakkinen
2021-04-16 7:06 ` Jisheng Zhang
2021-04-16 13:11 ` Jarkko Sakkinen
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=20210413220030.d1cbbc63659dcbc52876696d@kernel.org \
--to=mhiramat@kernel.org \
--cc=Jisheng.Zhang@synaptics.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
Powered by JetHome