public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: David Windsor <dwindsor@gmail.com>
Cc: David Windsor <dwindsor@gmail.com>, bpf@vger.kernel.org
Subject: [PATCH bpf-next 0/2] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling
Date: Sun, 26 Apr 2026 20:15:56 -0400	[thread overview]
Message-ID: <20260427001602.38353-1-dwindsor@gmail.com> (raw)

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


             reply	other threads:[~2026-04-27  0:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27  0:15 David Windsor [this message]
2026-04-27  0:15 ` [PATCH bpf-next 1/2] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling 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-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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260427001602.38353-1-dwindsor@gmail.com \
    --to=dwindsor@gmail.com \
    --cc=bpf@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox