mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
	Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
	linux-kernel@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Shrikanth Hegde <sshegde@linux.ibm.com>,
	Hari Bathini <hbathini@linux.ibm.com>
Subject: Re: [PATCHv2 1/3] powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n
Date: Tue, 17 Nov 2026 15:08:34 +0100	[thread overview]
Message-ID: <9a7963a6-0033-45ab-90d5-b1f580a4882c@kernel.org> (raw)
In-Reply-To: <f75f2cf97f44375fd2c8820e0caeab703cdb371c.1794572365.git.ritesh.list@gmail.com>



Le 13/11/2026 à 13:31, Ritesh Harjani (IBM) a écrit :
> commit 2e83e2ce34ff ("arch, mm: promote DEBUG_WX to CHECK_WX"), made
> CHECK_WX default STRICT_KERNEL_RWX.
> 
> Now on powerpc, when we boot with CONFIG_KPROBES=y and CONFIG_MODULES=n,
> we can see the following warning splat at boot:
> 
>      powerpc/mm: Found insecure W+X mapping at address 000000002ea08992/0xc008000000000000
>      WARNING: arch/powerpc/mm/ptdump/ptdump.c:194 at note_page+0x4dc/0x4fc, CPU#0: swapper/0/1
>      NIP [c0000000000ac204] note_page+0x4dc/0x4fc
>      LR [c0000000000ac200] note_page+0x4d8/0x4fc
>      Call Trace:
>       note_page+0x4d8/0x4fc (unreliable)
>       ptdump_pte_entry+0x70/0x94
>       walk_pte_range_inner+0x15c/0x260
>       walk_pgd_range+0x6d8/0xd5c
>       walk_page_range_debug+0xa4/0xf0
>       ptdump_walk_pgd+0xec/0x304
>       ptdump_check_wx+0xd8/0x154
>       kernel_init+0x94/0x26c
>       ret_from_kernel_user_thread+0x14/0x1c
>      Checked W+X mappings: FAILED, 1 W+X pages found
> 
> This happens because CHECK_WX noted a writeable + executable mapping.
> 
> This happens because execmem_arch_setup(), checks for
> struct_modules_rwx_enabled(), while kprobes depenency on modules was
> earlier removed via commit:
>      7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")
> Since the insn slots are only written with patch_instruction(), which
> does not need this mapping to be writable. This patch fixes it by
> checking for strict_kernel_rwx_enabled() instead.
> 
> Fixes: 7582b7be16d0 ("kprobes: remove dependency on CONFIG_MODULES")
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> ---
>   arch/powerpc/mm/mem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index b617b69452cd..77b63b52d8f2 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -388,7 +388,7 @@ static void prealloc_execmem_pgtable(void) { }
>   
>   struct execmem_info __init *execmem_arch_setup(void)
>   {
> -	pgprot_t kprobes_prot = strict_module_rwx_enabled() ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
> +	pgprot_t kprobes_prot = strict_kernel_rwx_enabled() ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
>   	pgprot_t prot = strict_module_rwx_enabled() ? PAGE_KERNEL : PAGE_KERNEL_EXEC;

Looking at this, I'd use PAGE_KERNEL_X instead of PAGE_KERNEL_EXEC.

Then we could get rid of PAGE_KERNEL_EXEC completely for powerpc.

>   	unsigned long fallback_start = 0, fallback_end = 0;
>   	unsigned long start, end;


  reply	other threads:[~2026-11-17 14:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 12:31 [PATCHv2 0/3] powerpc: kprobes insn page fixes Ritesh Harjani (IBM)
2026-11-13 12:31 ` [PATCHv2 1/3] powerpc/execmem: Don't leave kprobes insn pages W+X when CONFIG_MODULES=n Ritesh Harjani (IBM)
2026-11-17 14:08   ` Christophe Leroy (CS GROUP) [this message]
2026-11-13 12:31 ` [PATCHv2 2/3] powerpc/execmem: Allocate kprobes insn pages from the modules area on book3s/32 Ritesh Harjani (IBM)
2026-11-15  8:29   ` Mike Rapoport
2026-11-16 15:11     ` Christophe Leroy (CS GROUP)
2026-11-16 15:57       ` Mike Rapoport
2026-11-17 12:33         ` Ritesh Harjani
2026-11-17 14:04           ` Christophe Leroy (CS GROUP)
2026-11-17 14:15             ` Mike Rapoport
2026-11-13 12:31 ` [PATCHv2 3/3] powerpc/ptdump: Show the exec flag of kernel mappings on e500 Ritesh Harjani (IBM)
2026-11-17 14:09   ` Christophe Leroy (CS GROUP)

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=9a7963a6-0033-45ab-90d5-b1f580a4882c@kernel.org \
    --to=chleroy@kernel.org \
    --cc=hbathini@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=sshegde@linux.ibm.com \
    --cc=venkat88@linux.ibm.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

all inboxes | Powered by JetHome®