Skip to content

fs/mount: Report no execute permission on a mount with MS_NOEXEC. - #20762

Merged
acassis merged 2 commits into
apache:masterfrom
casaroli:fs-mount-noexec
Oct 18, 2026
Merged

acassis merged 2 commits into
apache:masterfrom
casaroli:fs-mount-noexec

Conversation

@casaroli

@casaroli casaroli commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

mount() accepted MS_NOEXEC, but ignored it. Nothing kept the flag, so a file on such a mount looked executable.

This PR keeps MS_NOEXEC in the flags of the mount point inode (a new bit, FSNODEFLAG_NOEXEC), and clears it on umount(). stat(), lstat() and fstat() 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_NOEXEC changes. 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:

Check master this PR
file on a mount with MS_NOEXEC, stat() and fstat() 0777 0666
directory on that mount 0777 0777
file on a mount without MS_NOEXEC 0777 0777
file after umount() and a mount without MS_NOEXEC at the same place 0777 0777

ostest on qemu-armv8a:knsh and qemu-armv8a:nsh gives the same result as master (it stops only at rr_test, which fails on master too when the host is busy). tools/checkpatch.sh -c -u -m -g passes.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report

esp32-devkitc

  • ROM: .flash.text +164 B (+0.1%, 126,364 B / 4,194,272 B, total: 3% used)
  • irom0_0_seg: .flash.text +164 B (+0.2%, 90,560 B / 3,342,304 B, total: 3% used)

hifive1-revb

  • flash: .text +60 B (+0.1%, 84,080 B / 4,194,304 B, total: 2% used)

qemu-armv8a

  • Code: .rodata +56 B, .text.cp_handler +32 B, .text.get_primes_thread +80 B, .text.nx_mount +24 B, .text.nx_stat +48 B, .text.nx_umount2 +4 B, .text.rr_test +116 B (+0.3%, 349,628 B)
  • Data: -3 B (-0.0%, 77,687 B)

qemu-intel64

  • Code: .text +683 B (+0.0%, 8,684,305 B)

rx65n-rsk2mb

  • ROM: .text +384 B (+0.4%, 87,796 B / 2,097,152 B, total: 4% used)

s698pm-dkit

Comment thread include/nuttx/fs/fs.h Resolved
Comment thread include/nuttx/fs/fs.h Resolved
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]>
@acassis
acassis merged commit 24e3b54 into apache:master Oct 18, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants