linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Credentials not fully initialized before bprm_check LSM hook
@ 2025-04-10 11:47 Roberto Sassu
  2025-04-10 17:24 ` sergeh
  0 siblings, 1 reply; 4+ messages in thread
From: Roberto Sassu @ 2025-04-10 11:47 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Kees Cook, Paul Moore,
	James Morris, Serge E. Hallyn, Eric W. Biederman
  Cc: linux-fsdevel, linux-mm, linux-kernel, linux-security-module,
	linux-integrity, zohar

Hi everyone

recently I discovered a problem in the implementation of our IMA
bprm_check hook, in particular when the policy is matched against the
bprm credentials (to be committed later during execve().

Before commit 56305aa9b6fab ("exec: Compute file based creds only
once"), bprm_fill_uid() was called in prepare_binprm() and filled the
euid/egid before calling security_bprm_check(), which in turns calls
IMA.

After that commit, bprm_fill_uid() was moved to begin_new_exec(), which
is when the last interpreter is found.

The consequence is that IMA still sees the not yet ready credentials
and an IMA rule like:

measure func=CREDS_CHECK euid=0

will not be matched for sudo-like applications.

It does work however with SELinux, because it computes the transition
before IMA in the bprm_creds_for_exec hook.

Since IMA needs to be involved for each execution in the chain of
interpreters, we cannot move to the bprm_creds_from_file hook.

How do we solve this problem? The commit mentioned that it is an
optimization, so probably would not be too hard to partially revert it
(and keeping what is good).

Thanks

Roberto


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-11 22:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 11:47 Credentials not fully initialized before bprm_check LSM hook Roberto Sassu
2025-04-10 17:24 ` sergeh
2025-04-11  9:07   ` Roberto Sassu
2025-04-11 22:14     ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).