Re: [PATCH v6 4/7] fs: Introduce O_MAYEXEC flag for openat2(2)

From
Kees Cook <hidden>
Date
2020-07-16 15:31:44
Also in
linux-fsdevel, linux-integrity, linux-nfs, linux-security-module, lkml
Reply to
Mickaël Salaün, 2020-07-16
On Thu, Jul 16, 2020 at 04:18:27PM +0200, Mickaël Salaün wrote:
On 15/07/2020 22:06, Kees Cook wrote:
quoted
On Tue, Jul 14, 2020 at 08:16:35PM +0200, Mickaël Salaün wrote:
quoted
The implementation of O_MAYEXEC almost duplicates what execve(2) and
uselib(2) are already doing: setting MAY_OPENEXEC in acc_mode (which can
then be checked as MAY_EXEC, if enforced), and propagating FMODE_EXEC to
_fmode via __FMODE_EXEC flag (which can then trigger a
fanotify/FAN_OPEN_EXEC event).
[...]
Adding __FMODE_EXEC here will immediately change the behaviors of NFS
and fsnotify. If that's going to happen, I think it needs to be under
the control of the later patches doing the behavioral controls.
(specifically, NFS looks like it completely changes its access control
test when this is set and ignores the read/write checks entirely, which
is not what's wanted).
__FMODE_EXEC was suggested by Jan Kara and Matthew Bobrowski because of
fsnotify. However, the NFS handling of SUID binaries [1] indeed leads to
an unintended behavior. This also means that uselib(2) shouldn't work
properly with NFS. I can remove the __FMODE_EXEC flag for now.
I kind of wonder if we need to more completely fix __FMODE_EXEC?
[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f8d9a897d4384b77f13781ea813156568f68b83e
Hmpf, this implies that "fmode" should contain MAY_EXEC? It really looks
like __FMODE_EXEC is a hack for places where only "flags" were passed
around, and this only seems to be an issue for NFS at this point? And it
should be fixable for fsnotify too?

Hmm. (And nothing should use uselib anyway...)

-- 
Kees Cook
Thread (25 messages) 25 messages, 4 authors, last reply 2020-07-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help