Re: [PATCH] exec: Check __FMODE_EXEC instead of in_execve for LSMs

From: Kees Cook
Date: Wed Jan 24 2024 - 14:52:05 EST


On Wed, Jan 24, 2024 at 12:39:38PM -0700, Kevin Locke wrote:
> On Wed, 2024-01-24 at 11:22 -0800, Kees Cook wrote:
> > After commit 978ffcbf00d8 ("execve: open the executable file before
> > doing anything else"), current->in_execve was no longer in sync with the
> > open(). This broke AppArmor and TOMOYO which depend on this flag to
> > distinguish "open" operations from being "exec" operations.
> >
> > Instead of moving around in_execve, switch to using __FMODE_EXEC, which
> > is where the "is this an exec?" intent is stored. Note that TOMOYO still
> > uses in_execve around cred handling.
>
> It solves the AppArmor issue I was experiencing and I don't notice any
> other issues.
>
> Tested-by: Kevin Locke <kevin@xxxxxxxxxxxxxxx>

Thanks!

Sounds like Linus has taken the patch directly, and I'll send a follow-up
PR with other clean-ups.

-Kees

--
Kees Cook