From: sashiko-bot@kernel.org
To: "Hang Zhengyang" <hang.zhengyang1010@gmail.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Kees Cook" <kees@kernel.org>
Cc: "Lorenzo Stoakes" <ljs@kernel.org>,
"Chris Mason" <mason@kernel.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Joey Gouly" <joey.gouly@arm.com>,
"Christian Brauner" <brauner@kernel.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Jan Kara" <jack@suse.cz>, "David Hildenbrand" <david@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Michal Hocko" <mhocko@suse.com>,
"Suren Baghdasaryan" <surenb@google.com>,
"Shuah Khan" <shuah@kernel.org>,
"Gregory Price" <gourry@gourry.net>,
"Jann Horn" <jannh@google.com>,
"Pedro Falcato" <pfalcato@suse.de>,
"Florent Revest" <revest@chromium.org>,
linux-mm@kvack.org
Subject: Re: [PATCH 1/2] exec: don't honor PT_GNU_STACK PF_X under MDWE
Date: Sun, 06 Dec 2026 10:56:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-252373@kernel.org> (raw)
In-Reply-To: <20261205105547.1251214-2-hang.zhengyang1010@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] exec: setup_arg_pages() misses EXSTACK_DEFAULT under MDWE
--
commit 719d5e410364817edd0df97f72ec8de427ec4b30
Author: Hang Zhengyang <hang.zhengyang1010@gmail.com>
exec: don't honor PT_GNU_STACK PF_X under MDWE
This commit clears VM_EXEC on the stack VMA and logs a one-time warning
in setup_arg_pages() when EXSTACK_ENABLE_X is requested under MDWE.
> diff --git a/fs/exec.c b/fs/exec.c
> index 8d2b14e1d455c..d23f87301abf9 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -660,12 +660,21 @@ int setup_arg_pages(struct linux_binprm *bprm,
> /*
> * Adjust stack execute permissions; explicitly enable for
> * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
> - * (arch default) otherwise.
> + * (arch default) otherwise. MDWE refuses writable and executable
> + * memory, so under MDWE treat EXSTACK_ENABLE_X as EXSTACK_DISABLE_X.
> + * The marking can be an accident, so don't fail the exec.
> */
> - if (unlikely(executable_stack == EXSTACK_ENABLE_X))
> - vm_flags |= VM_EXEC;
> - else if (executable_stack == EXSTACK_DISABLE_X)
> + if (unlikely(executable_stack == EXSTACK_ENABLE_X)) {
> + if (mm_flags_test(MMF_HAS_MDWE, mm)) {
> + pr_warn_once("process '%pD4' asked for an executable stack, not granted under MDWE\n",
> + bprm->file);
> + vm_flags &= ~VM_EXEC;
> + } else {
> + vm_flags |= VM_EXEC;
> + }
> + } else if (executable_stack == EXSTACK_DISABLE_X) {
> vm_flags &= ~VM_EXEC;
> + }
[Severity: Medium]
Does this miss EXSTACK_DEFAULT when VM_STACK_FLAGS already includes VM_EXEC?
For an ELF binary lacking PT_GNU_STACK on x86_32 or IA32 compat,
load_elf_binary() sets READ_IMPLIES_EXEC and passes EXSTACK_DEFAULT to
setup_arg_pages(). Since the MMF_HAS_MDWE check only runs for
EXSTACK_ENABLE_X, the process still gets a writable and executable stack.
Checking for (vm_flags & VM_EXEC) under MMF_HAS_MDWE after the
EXSTACK_ENABLE_X / EXSTACK_DISABLE_X branches would cover both cases,
similar to do_brk_flags().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205105547.1251214-1-hang.zhengyang1010@gmail.com?part=1
next prev parent reply other threads:[~2026-12-06 10:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 10:55 [PATCH 0/2] exec: don't honor PT_GNU_STACK PF_X under MDWE Hang Zhengyang
2026-12-05 10:55 ` [PATCH 1/2] " Hang Zhengyang
2026-12-06 10:56 ` sashiko-bot [this message]
2026-12-05 10:55 ` [PATCH 2/2] selftests/mm: test exec of a PT_GNU_STACK PF_X program " Hang Zhengyang
2026-12-05 11:27 ` Alejandro Colomar
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-252373@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=hang.zhengyang1010@gmail.com \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=joey.gouly@arm.com \
--cc=kees@kernel.org \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mason@kernel.org \
--cc=mhocko@suse.com \
--cc=pfalcato@suse.de \
--cc=revest@chromium.org \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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