Solved mount_nullfs(8) doesn't respect noexec option of the filesystem mounted on the choosen target directory on its own mountpoint.

Hello all!
I experienced the following behaviour with nullfs, and wanted to know if it's supposed to be the correct one:
I used mount_nullfs(8) to share my /tmp directory with a Linux chroot (/compat/linux/tmp).
My /tmp filesystem is mounted with these options:
Code:
tmpfs on /tmp (tmpfs, local, noexec, nosuid)
and this is how mount(8) reports the options of the nullfs mount ( mount -t nullfs /tmp /compat/linux/tmp):
Code:
/tmp on /compat/linux/tmp (nullfs, local, noexec, nosuid)
However, when I tried to execute a binary that I temporarily placed in /compat/linux/tmp it was flawlessly executed, with my surprise!
I observed this behaviour even outside of the chroot, and with regular datasets, so it's not something related to the fact that /tmp is a tmpfs(5).
To prevent this, I must explicitly use -o noexec with mount_nullfs(8); this way I get the behaviour I expected.

Since the ouput of mount(8) reports the correct options (in both cases), shouldn't this mean that mount_nullfs(8) must respect the noexec option of the filesystem mounted on its target directory to its own mountpoint (like it does, e.g. for the readonly flag)?

Thank you in advance for your response!
 
Would PR 283425 related?
That's it! I didn't expect this outcome though, I believed that nullfs mounts inherit the flags from the original mountpoint (which seems more coherent to me).
Well, at least now I know that mount options must be explicitly set, and since there is a commit that addresses this in -STABLE the thread can be marked as solved.

Thank you again for finding the PR T-Aoki! :)
 
Last edited:
Back
Top