Repository navigation
fs/mount: Report no execute permission on a mount with MS_NOEXEC. - #20762
Merged
Merged
Conversation
casaroli
requested review from
Donny9,
GUIDINGLI,
gustavonihei,
pkarashchenko,
pussuw and
xiaoxiang781216
as code owners
October 17, 2026 22:30
|
mount() accepted MS_NOEXEC, but ignored it. Nothing kept the flag, so a file on such a mount looked executable. Keep MS_NOEXEC in the flags of the mount point inode, and clear it on umount(). stat(), lstat() and fstat() then report regular files of the mount without execute permission. Directories keep their search permission. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
The mount() description said only that the flags qualify how the file system is mounted. Say what MS_RDONLY and MS_NOEXEC do, and that the other flags are ignored. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
casaroli
force-pushed
the
fs-mount-noexec
branch
from
October 18, 2026 12:29
4c6dd2d to
54dfe37
Compare
xiaoxiang781216
approved these changes
Oct 18, 2026
acassis
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mount()acceptedMS_NOEXEC, but ignored it. Nothing kept the flag, so a file on such a mount looked executable.This PR keeps
MS_NOEXECin the flags of the mount point inode (a new bit,FSNODEFLAG_NOEXEC), and clears it onumount().stat(),lstat()andfstat()then report the regular files of the mount without execute permission. Directories keep their search permission.The second commit says in the
mount()description which flags have an effect.Impact
Only a mount with
MS_NOEXECchanges. Nothing else checks the execute bits today; with the execute permission check of #20764, such a file cannot be started.Testing
A test program on
qemu-armv8a:knsh(QEMU 11 with HVF on an Apple M4) with tmpfs mounts:MS_NOEXEC,stat()andfstat()0777066607770777MS_NOEXEC07770777umount()and a mount withoutMS_NOEXECat the same place07770777ostestonqemu-armv8a:knshandqemu-armv8a:nshgives the same result as master (it stops only atrr_test, which fails on master too when the host is busy).tools/checkpatch.sh -c -u -m -gpasses.