[GIT PULL] Add trusted_for(2) (was O_MAYEXEC)
Linus Torvalds
torvalds at linux-foundation.org
Tue Apr 5 16:17:44 UTC 2022
On Tue, Apr 5, 2022 at 9:08 AM Mickaël Salaün <mic at digikod.net> wrote:
>
> I think we don't. I think the only corner case that could be different
> is for files that are executable, SUID and non-readable. In this case it
> wouldn't matter because userspace could not read the file, which is
> required for interpretation/execution. Anyway, S[GU]ID bits in scripts
> are just ignored by execve and we want to follow the same semantic.
So I just want to bring up the possibility that somebody wants to just
implement execve() in user space for some reason - not just "script
interpreter".
It's *doable*.
Don't ask me if it's sane or useful, but people have done insane
things before. Things like "emulate other operating systems in user
space" etc
Such a user can trivially see the suid/sgid bit on the file (just do
fstat() on it), but wouldn't necessarily see if that file is then in a
mount that is mounted nosuid.
Now, I think the right thing to do is to just say "we don't support
it", but I do think it should perhaps be mentioned somewhere
explicitly.
Particularly since I can well imagine that a security policy might
have some "no, I don't allow suid exec" and return an actual error for
it, and then the access() call would fail for that case.
(Ok, so the security policies would look at the actual bprm data on a
real exec, not the inode executable, so that's kind of made up and
theoretical, but I just want this issue to be mentioned somewhere so
that people are aware that the "it's the same basic file checking that
execve does, but a _real_ execve might then have _other_ issues going
on, including suid bits etc")
Linus
More information about the Linux-security-module-archive
mailing list