linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] [regression?] bpf lsm breaks /proc/*/attr/current with security= on commandline
@ 2025-09-13 17:01 Filip Hejsek
  2025-09-24 21:24 ` Paul Moore
  0 siblings, 1 reply; 6+ messages in thread
From: Filip Hejsek @ 2025-09-13 17:01 UTC (permalink / raw)
  To: linux-security-module, Paul Moore, James Morris, Serge E. Hallyn
  Cc: bpf, linux-kernel, regressions

Hello,

TLDR: because of bpf lsm, putting security=selinux on commandline
      results in /proc/*/attr/current returning errors.

When the legacy security= commandline option is used, the specified lsm
is added to the end of the lsm list. For example, security=apparmor
results in the following order of security modules:

   capability,landlock,lockdown,yama,bpf,apparmor

In particular, the bpf lsm will be ordered before the chosen major lsm.

This causes reads and writes of /proc/*/attr/current to fail, because
the bpf hook overrides the apparmor/selinux hook.

As you can see in the code below, only the first registered hook is
called (when reading attr/current, lsmid is 0):

int security_getprocattr(struct task_struct *p, int lsmid, const char *name,
			 char **value)
{
	struct lsm_static_call *scall;

	lsm_for_each_hook(scall, getprocattr) {
		if (lsmid != 0 && lsmid != scall->hl->lsmid->id)
			continue;
		return scall->hl->hook.getprocattr(p, name, value);
	}
	return LSM_RET_DEFAULT(getprocattr);
}

Even though the bpf lsm doesn't allow attaching bpf programs to this
hook, it still prevents the other hooks from being called.

This is maybe a regression, because with the same commandline, reading
from /proc/*/attr/current probably worked before the introduction of
bpf lsm.

Regards,
Filip Hejsek

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

end of thread, other threads:[~2025-09-25 19:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-13 17:01 [bug report] [regression?] bpf lsm breaks /proc/*/attr/current with security= on commandline Filip Hejsek
2025-09-24 21:24 ` Paul Moore
2025-09-25 14:56   ` Filip Hejsek
2025-09-25 15:28     ` Paul Moore
2025-09-25 16:25       ` Filip Hejsek
2025-09-25 19:07         ` 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).