public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling
@ 2026-04-27  0:15 David Windsor
  2026-04-27  0:15 ` [PATCH bpf-next 1/2] " David Windsor
  2026-04-27  0:15 ` [PATCH bpf-next 2/2] selftests/bpf: add tests for bpf_init_inode_xattr kfunc David Windsor
  0 siblings, 2 replies; 17+ messages in thread
From: David Windsor @ 2026-04-27  0:15 UTC (permalink / raw)
  Cc: David Windsor, bpf

Many in-kernel LSMs (SELinux, Smack, IMA) store security labels in
extended attributes. For these LSMs, atomic labeling during inode
creation is critical: if the inode becomes accessible before its xattr
is set, it is briefly unlabeled, which can disrupt LSMs making policy
decisions based on file labels.

Existing LSMs solve this by setting xattrs directly in the
inode_init_security hook, which runs before the inode becomes
accessible. BPF LSM programs currently lack this capability because
the hook uses an output parameter (xattr_count) that BPF programs
cannot write to, and existing kfuncs like bpf_dentry_set_xattr
require a dentry that isn't available until after the inode is
accessible.

This series introduces the bpf_init_inode_xattr() kfunc, which takes
the hook's PTR_TO_CTX to access xattrs and xattr_count, and
internally writes to xattr_count via lsm_get_xattr_slot().

David Windsor (2):
  bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling
  selftests/bpf: add tests for bpf_init_inode_xattr kfunc

 fs/bpf_fs_kfuncs.c                            | 80 ++++++++++++++++++-
 include/linux/bpf_verifier.h                  |  3 +
 kernel/bpf/fixups.c                           | 20 +++++
 kernel/bpf/verifier.c                         | 54 +++++++++++++
 security/bpf/hooks.c                          |  3 +
 tools/testing/selftests/bpf/bpf_kfuncs.h      |  3 +
 .../selftests/bpf/prog_tests/fs_kfuncs.c      | 49 ++++++++++++
 .../bpf/progs/test_init_inode_xattr.c         | 32 ++++++++
 8 files changed, 243 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_init_inode_xattr.c


base-commit: 6c60b2dd5a7889a583389e95e79689191206f86f
-- 
2.53.0


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

end of thread, other threads:[~2026-04-28 11:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27  0:15 [PATCH bpf-next 0/2] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling David Windsor
2026-04-27  0:15 ` [PATCH bpf-next 1/2] " David Windsor
2026-04-27  0:51   ` bot+bpf-ci
2026-04-27  0:56   ` sashiko-bot
2026-04-27  2:10     ` David Windsor
2026-04-27  2:56   ` Kumar Kartikeya Dwivedi
2026-04-27  3:23     ` David Windsor
2026-04-27  3:32       ` Kumar Kartikeya Dwivedi
2026-04-27  3:42         ` David Windsor
2026-04-27 10:11         ` Matt Bobrowski
2026-04-27 14:20           ` Song Liu
2026-04-27 14:33             ` Kumar Kartikeya Dwivedi
2026-04-27 17:17               ` Song Liu
2026-04-28 11:03               ` Matt Bobrowski
2026-04-27  9:48   ` Matt Bobrowski
2026-04-27  0:15 ` [PATCH bpf-next 2/2] selftests/bpf: add tests for bpf_init_inode_xattr kfunc David Windsor
2026-04-27  1:10   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox