From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range
Date: Thu, 03 Dec 2026 11:03:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-247638@kernel.org> (raw)
In-Reply-To: <20261203103345.1206548-16-hca@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] s390/execmem: EXECMEM_KPROBES skips set_memory_rox()
direct-map protection
--
commit 67943fd0e30c5ced8f7dc99734b2146fc3684f54
Author: Heiko Carstens <hca@linux.ibm.com>
s390/execmem: Add EXECMEM_KPROBES range
This commit adds an EXECMEM_KPROBES range with PAGE_KERNEL_ROX protection
and removes the s390-specific alloc_insn_page() implementation in favor of
the generic one.
> diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
> index 9bfff628c9bf1..d97fd3b9e3dbb 100644
> --- a/arch/s390/kernel/kprobes.c
> +++ b/arch/s390/kernel/kprobes.c
[ ... ]
> @@ -33,20 +31,6 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
>
> struct kretprobe_blackpoint kretprobe_blacklist[] = { };
>
> -void *alloc_insn_page(void)
> -{
> - void *page;
> -
> - page = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
> - if (!page)
> - return NULL;
> - if (set_memory_rox((unsigned long)page, 1)) {
> - execmem_free(page);
> - return NULL;
> - }
> - return page;
> -}
> -
> static void copy_instruction(struct kprobe *p)
> {
> kprobe_opcode_t insn[MAX_INSN_SIZE];
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index b9fd795cf788e..062b2b5325aff 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -331,6 +331,13 @@ struct execmem_info __init *execmem_arch_setup(void)
> .pgprot = PAGE_KERNEL,
> .alignment = MODULE_ALIGN,
> },
> + [EXECMEM_KPROBES] = {
> + .flags = EXECMEM_KASAN_SHADOW,
> + .start = start,
> + .end = MODULES_END,
> + .pgprot = PAGE_KERNEL_ROX,
> + .alignment = MODULE_ALIGN,
> + },
> },
> };
[Severity: Medium]
Does this leave kprobe instruction pages writable through the kernel direct
mapping?
Without EXECMEM_ROX_CACHE, execmem_alloc() calls execmem_vmalloc() directly
with PAGE_KERNEL_ROX, which updates only the vmalloc PTE. Because
alloc_insn_page() no longer calls set_memory_rox() ->
change_page_attr_alias(), the backing page's direct-map alias stays writable.
At this commit, large direct-map mappings on EDAT1 systems are also not split
at allocation time, deferring splitting to free_insn_page() -> vfree() ->
vm_reset_perms() -> set_area_direct_map(), where -ENOMEM triggers
WARN_ON_ONCE() and skips direct-map invalidation.
Commit "s390/execmem: Enable EXECMEM_ARCH_ROX" later enables
EXECMEM_ROX_CACHE when cpu_has_edat1() is true, but systems without EDAT1
(for example with facilities=!8) still omit EXECMEM_ROX_CACHE while keeping
PAGE_KERNEL_ROX, leaving the direct-map alias writable there.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203103345.1206548-1-hca@linux.ibm.com?part=15
next prev parent reply other threads:[~2026-12-03 11:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 10:33 [PATCH 00/17] s390/mm: Large kernel mappings for vmalloc and execmem ROX cache Heiko Carstens
2026-12-03 10:33 ` [PATCH 01/17] s390/boot: Initialize asce_limit for init_mm properly Heiko Carstens
2026-12-03 11:01 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 02/17] s390/pageattr: Only account direct mapping in direct map page counters Heiko Carstens
2026-12-03 10:33 ` [PATCH 03/17] s390/mm: Serialize kernel page table changes with init_mm mmap lock Heiko Carstens
2026-12-03 10:33 ` [PATCH 04/17] s390/vmem: Use generic page table allocators for vmem page tables Heiko Carstens
2026-12-03 11:02 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 05/17] s390/mm: Show write-combining attribute in page table dump Heiko Carstens
2026-12-03 10:33 ` [PATCH 06/17] s390/mm: Implement HAVE_ARCH_HUGE_VMAP Heiko Carstens
2026-12-03 11:03 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 07/17] s390/mm: Implement HAVE_ARCH_HUGE_VMALLOC Heiko Carstens
2026-12-03 10:33 ` [PATCH 08/17] s390/pageattr: Add helpers to replace kernel page table entries Heiko Carstens
2026-12-03 10:33 ` [PATCH 09/17] s390/mm: Add _SEGMENT_ENTRY_TYPE Heiko Carstens
2026-12-03 10:33 ` [PATCH 10/17] s390/pageattr: Use common helper to change kernel page table permissions Heiko Carstens
2026-12-03 10:33 ` [PATCH 11/17] s390/pageattr: Avoid splitting mappings if permissions do not change Heiko Carstens
2026-12-03 10:33 ` [PATCH 12/17] s390/pageattr: Mark intentional 4k kernel mappings Heiko Carstens
2026-12-03 11:00 ` sashiko-bot
2026-12-03 10:33 ` [PATCH 13/17] s390/pageattr: Collapse kernel mappings after changing page attributes Heiko Carstens
2026-12-03 10:33 ` [PATCH 14/17] s390/mm: Add PAGE_KERNEL_ROX Heiko Carstens
2026-12-03 10:33 ` [PATCH 15/17] s390/execmem: Add EXECMEM_KPROBES range Heiko Carstens
2026-12-03 11:03 ` sashiko-bot [this message]
2026-12-03 10:33 ` [PATCH 16/17] s390/execmem: Add EXECMEM_FTRACE range Heiko Carstens
2026-12-03 10:33 ` [PATCH 17/17] s390/execmem: Enable EXECMEM_ARCH_ROX Heiko Carstens
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=sashiko-outbox-247638@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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