bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling
Subsystems (12)
v6 cover bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling
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_set_dentry_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 combined inode_init_security xattr context argument and claims a slot in it via the new security_lsmxattr_add() LSM helper.
v6:
- split struct lsm_xattrs / security_lsmxattr_add() into 2 patches
(Paul)
- drop the CONFIG_BPF_LSM bracketing in security_lsmxattr_add() (Paul)
- have security_lsmxattr_add() take only extra name components (Paul)
- return 0 from security_lsmxattr_add() when the filesystem does not provide an initxattrs callback (Paul)
- selftests: label files in /dev/shm and skip when the hook does not run or the filesystem does not support xattrs at inode creation, fixing BPF CI failures on the 9p rootfs
v5:
- make the kfunc non-sleepable to avoid an ext4 deadlock (sashiko)
- move xattr creation logic to security_lsmxattr_add() (Paul)
- use distinct xattr names in init_inode_xattr_slot_limit
v4:
- introduce struct lsm_xattrs in separate patch (Alexei, Paul)
- rename struct xattr_ctx to struct lsm_xattrs (Paul)
- make lsm_xattrs.xattr_count unsigned int (Paul)
- drop new_xattrs/xattr_count locals in security_inode_init_security() (Paul)
- fold __bpf_init_inode_xattr() into bpf_init_inode_xattr() (Paul)
- drop bpf_fs_kfuncs_filter() attach-point check; rely on verifier type enforcement (Alexei)
- drop attach-time cap; enforce slot budget in the kfunc (Alexei)
- allocate the combined xattr with GFP_NOFS (sashiko-bot)
- replace init_inode_xattr_attach_cap selftest with runtime init_inode_xattr_slot_limit
v3:
- rename struct lsm_xattr_ctx to struct xattr_ctx (Paul)
- increase BPF_LSM_INODE_INIT_XATTRS to 4 (Song)
- enforce per-hook attachment cap at attach time to prevent runtime rejection (Paul)
- add init_inode_xattr_attach_cap selftest
v2:
- pass the xattr state as a combined context object and drop the verifier fixup path (Kumar)
- restrict bpf_init_inode_xattr labels to bpf.* namespace (Matt)
- cap bpf_init_inode_xattr() at BPF_LSM_INODE_INIT_XATTRS slots per invocation (AI)
v5: https://lore.kernel.org/bpf/[email protected]/
David Windsor (4):
security: introduce struct lsm_xattrs
security: add security_lsmxattr_add()
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 | 41 +++++ include/linux/bpf_lsm.h | 3 + include/linux/evm.h | 9 +- include/linux/lsm_hook_defs.h | 4 +- include/linux/lsm_hooks.h | 16 +- include/linux/security.h | 15 ++ security/bpf/hooks.c | 1 + security/integrity/evm/evm_main.c | 8 +- security/security.c | 120 ++++++++++++-- security/selinux/hooks.c | 4 +- security/smack/smack_lsm.c | 27 ++- tools/testing/selftests/bpf/bpf_kfuncs.h | 5 + .../selftests/bpf/prog_tests/fs_kfuncs.c | 156 ++++++++++++++++++ .../bpf/progs/test_init_inode_xattr.c | 33 ++++ 14 files changed, 395 insertions(+), 47 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/test_init_inode_xattr.c
base-commit: 2659f94ed3be147942acbea96405efc562afb34c
Signature · 1 line
2.53.0
PATCH v6 1/4 security: introduce struct lsm_xattrs
In preparation for bpf_init_inode_xattr(), a kfunc that lets bpf LSM programs atomically label new inodes, rework how inode_init_security xattrs are managed.
inode_init_security receives the LSM xattr array and its count as separate parameters. For better compatibility with the bpf verifier, update inode_init_security and its callers to consolidate these parameters into a single context object: struct lsm_xattrs.
--- include/linux/evm.h | 9 +++++---- include/linux/lsm_hook_defs.h | 4 ++-- include/linux/lsm_hooks.h | 16 +++++++--------- include/linux/security.h | 5 +++++ security/integrity/evm/evm_main.c | 8 +++++--- security/security.c | 24 ++++++++++++------------ security/selinux/hooks.c | 4 ++-- security/smack/smack_lsm.c | 27 ++++++++++++--------------- 8 files changed, 50 insertions(+), 47 deletions(-)
include/linux/evm.h +5 -4
@@ -12,6 +12,8 @@#include <linux/integrity.h> #include <linux/xattr.h> +struct lsm_xattrs ; +#ifdef CONFIG_EVM extern int evm_set_key (void *key,size_t keylen); extern enum integrity_status evm_verifyxattr(struct dentry *dentry,
@@ -21,8 +23,8 @@ extern enum integrity_status evm_verifyxattr(struct dentry *dentry,int evm_fix_hmac (struct dentry *dentry,const char *xattr_name,const char *xattr_value,size_t xattr_value_len);int evm_inode_init_security (struct inode *inode,struct inode *dir, -const struct qstr *qstr,struct xattr *xattrs, -int *xattr_count); +const struct qstr *qstr, +struct lsm_xattrs *xattrs);extern bool evm_revalidate_status (const char *xattr_name);extern int evm_protected_xattr_if_enabled (const char *req_xattr_name); extern int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer,
@@ -63,8 +65,7 @@ static inline int evm_fix_hmac(struct dentry *dentry, const char *xattr_name,static inline int evm_inode_init_security (struct inode *inode,struct inode *dir,const struct qstr *qstr, -struct xattr *xattrs, -int *xattr_count) +struct lsm_xattrs *xattrs) {return 0 ; }
include/linux/lsm_hook_defs.h +2 -2
@@ -116,8 +116,8 @@ LSM_HOOK(int, 0, inode_alloc_security, struct inode *inode) LSM_HOOK(void, LSM_RET_VOID, inode_free_security, struct inode *inode) LSM_HOOK(void, LSM_RET_VOID, inode_free_security_rcu, void *inode_security) LSM_HOOK(int, -EOPNOTSUPP, inode_init_security, struct inode *inode, - struct inode *dir, const struct qstr *qstr, struct xattr *xattrs, - int *xattr_count) + struct inode *dir, const struct qstr *qstr, + struct lsm_xattrs *xattrs) LSM_HOOK(int, 0, inode_init_security_anon, struct inode *inode, const struct qstr *name, const struct inode *context_inode) LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry,
include/linux/lsm_hooks.h +7 -9
@@ -200,20 +200,18 @@ extern struct lsm_static_calls_table static_calls_table __ro_after_init;/** * lsm_get_xattr_slot - Return the next available slot and increment the index -* @xattrs: array storing LSM-provided xattrs -* @xattr_count: number of already stored xattrs (updated) +* @ctx: xattr state shared by inode_init_security hooks * -* Retrieve the first available slot in the @xattrs array to fill with an xattr, -* and increment @xattr_count. +* Retrieve the first available slot in the @ctx->xattrs array to fill with an +* xattr, and increment @ctx->xattr_count. * -* Return: The slot to fill in @xattrs if non-NULL, NULL otherwise. +* Return: The slot to fill in @ctx->xattrs if non-NULL, NULL otherwise. */ -static inline struct xattr *lsm_get_xattr_slot (struct xattr *xattrs, -int *xattr_count) +static inline struct xattr *lsm_get_xattr_slot (struct lsm_xattrs *ctx) { -if (unlikely (!xattrs)) +if (unlikely (!ctx || !ctx->xattrs))return NULL ; -return &xattrs[(*xattr_count)++]; +return &ctx->xattrs[ctx->xattr_count++]; }#endif /* ! __LINUX_LSM_HOOKS_H */
include/linux/security.h +5 -0
@@ -68,6 +68,11 @@ struct watch;struct watch_notification ;struct lsm_ctx ; +struct lsm_xattrs { +struct xattr *xattrs; +unsigned int xattr_count; +}; +/* Default (no) options for the capable function */ #define CAP_OPT_NONE 0x0/* If capable should audit the security request */
security/integrity/evm/evm_main.c +5 -3
@@ -1062,14 +1062,16 @@ static int evm_inode_copy_up_xattr(struct dentry *src, const char *name)* evm_inode_init_security - initializes security.evm HMAC value */ int evm_inode_init_security (struct inode *inode,struct inode *dir, -const struct qstr *qstr,struct xattr *xattrs, -int *xattr_count) +const struct qstr *qstr, +struct lsm_xattrs *lsm_xattrs) {struct evm_xattr *xattr_data;struct xattr *xattr, *evm_xattr; +struct xattr *xattrs;bool evm_protected_xattrs = false;int rc; + xattrs = lsm_xattrs ? lsm_xattrs->xattrs :NULL ;if (!(evm_initialized &EVM_INIT_HMAC ) || !xattrs)return 0 ;
@@ -1087,7 +1089,7 @@ int evm_inode_init_security(struct inode *inode, struct inode *dir,if (!evm_protected_xattrs)return 0 ; - evm_xattr =lsm_get_xattr_slot (xattrs, xattr_count); + evm_xattr =lsm_get_xattr_slot (lsm_xattrs);/* * Array terminator (xattr name = NULL) must be the first non-filled * xattr slot.
security/security.c +12 -12
@@ -1333,8 +1333,8 @@ int security_inode_init_security(struct inode *inode, struct inode *dir, const initxattrs initxattrs, void *fs_data) { struct lsm_static_call *scall; -struct xattr *new_xattrs =NULL ; -int ret = -EOPNOTSUPP , xattr_count =0 ; +struct lsm_xattrs xattrs = {}; +int ret = -EOPNOTSUPP ;if (unlikely (IS_PRIVATE (inode)))return 0 ;
@@ -1344,15 +1344,15 @@ int security_inode_init_security(struct inode *inode, struct inode *dir,if (initxattrs) {/* Allocate +1 as terminator. */ - new_xattrs =kcalloc (blob_sizes.lbs_xattr_count +1 , -sizeof (*new_xattrs),GFP_NOFS ); -if (!new_xattrs) + xattrs.xattrs =kcalloc (blob_sizes.lbs_xattr_count +1 , +sizeof (*xattrs.xattrs),GFP_NOFS ); +if (!xattrs.xattrs)return -ENOMEM ; }lsm_for_each_hook (scall, inode_init_security) { - ret = scall->hl->hook.inode_init_security (inode, dir, qstr, new_xattrs, - &xattr_count); + ret = scall->hl->hook.inode_init_security (inode, dir, qstr, + &xattrs);if (ret && ret != -EOPNOTSUPP ) goto out;/*
@@ -1364,14 +1364,14 @@ int security_inode_init_security(struct inode *inode, struct inode *dir, }/* If initxattrs() is NULL, xattr_count is zero, skip the call. */ -if (!xattr_count) +if (!xattrs.xattr_count) goto out; - ret =initxattrs (inode, new_xattrs, fs_data); + ret =initxattrs (inode, xattrs.xattrs, fs_data); out: -for (; xattr_count >0 ; xattr_count--) -kfree (new_xattrs[xattr_count -1 ].value); -kfree (new_xattrs); +for (; xattrs.xattr_count >0 ; xattrs.xattr_count--) +kfree (xattrs.xattrs[xattrs.xattr_count -1 ].value); +kfree (xattrs.xattrs);return (ret == -EOPNOTSUPP ) ?0 : ret; }EXPORT_SYMBOL (security_inode_init_security);
security/selinux/hooks.c +2 -2
@@ -2962,7 +2962,7 @@ static int selinux_dentry_create_files_as(struct dentry *dentry, int mode,static int selinux_inode_init_security (struct inode *inode,struct inode *dir,const struct qstr *qstr, -struct xattr *xattrs,int *xattr_count) +struct lsm_xattrs *xattrs) {const struct cred_security_struct *crsec =selinux_cred (current_cred ());struct superblock_security_struct *sbsec;
@@ -2992,7 +2992,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, !(sbsec->flags & SBLABEL_MNT))return -EOPNOTSUPP ; - xattr =lsm_get_xattr_slot (xattrs, xattr_count); + xattr =lsm_get_xattr_slot (xattrs);if (xattr) { rc =security_sid_to_context_force (newsid, &context, &clen);
security/smack/smack_lsm.c +12 -15
@@ -981,10 +981,10 @@ smk_rule_transmutes(struct smack_known *subject, }static int -xattr_dupval (struct xattr *xattrs,int *xattr_count, +xattr_dupval (struct lsm_xattrs *xattrs,const char *name,const void *value,unsigned int vallen) { -struct xattr *const xattr =lsm_get_xattr_slot (xattrs, xattr_count); +struct xattr *const xattr =lsm_get_xattr_slot (xattrs);if (!xattr)return 0 ;
@@ -1003,14 +1003,13 @@ xattr_dupval(struct xattr *xattrs, int *xattr_count,* @inode: the newly created inode * @dir: containing directory object * @qstr: unused -* @xattrs: where to put the attributes -* @xattr_count: current number of LSM-provided xattrs (updated) +* @xattrs: where to put attributes and update count * * Returns 0 if it all works out, -ENOMEM if there's no memory */ static int smack_inode_init_security (struct inode *inode,struct inode *dir,const struct qstr *qstr, -struct xattr *xattrs,int *xattr_count) +struct lsm_xattrs *xattrs) {struct task_smack *tsp =smack_cred (current_cred ());struct inode_smack *const issp =smack_inode (inode);
@@ -1057,21 +1056,19 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,if (S_ISDIR (inode->i_mode)) { transflag =SMK_INODE_TRANSMUTE ; -if (xattr_dupval (xattrs, xattr_count, -XATTR_SMACK_TRANSMUTE , -TRANS_TRUE , -TRANS_TRUE_SIZE - )) +if (xattr_dupval (xattrs, +XATTR_SMACK_TRANSMUTE , +TRANS_TRUE , +TRANS_TRUE_SIZE )) rc = -ENOMEM ; } }if (rc ==0 ) -if (xattr_dupval (xattrs, xattr_count, -XATTR_SMACK_SUFFIX , - issp->smk_inode->smk_known, -strlen (issp->smk_inode->smk_known) - )) +if (xattr_dupval (xattrs, +XATTR_SMACK_SUFFIX , + issp->smk_inode->smk_known, +strlen (issp->smk_inode->smk_known))) rc = -ENOMEM ; instant_inode: issp->smk_flags |= (SMK_INODE_INSTANT | transflag);
Signature · 1 line
2.53.0
PATCH v6 2/4 security: add security_lsmxattr_add()
In reply to David WindsorAdd security_lsmxattr_add(), which claims a slot in the inode_init_security xattr array on behalf of the calling LSM and fills it with a copy of the given name and value.
Callers pass only the name components beyond their LSM's standard xattr suffix; security_lsmxattr_add() builds the full xattr name from the suffix associated with the given lsm_id.
--- include/linux/bpf_lsm.h | 3 ++ include/linux/security.h | 10 +++++ security/bpf/hooks.c | 1 + security/security.c | 96 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+)
include/linux/bpf_lsm.h +3 -0
@@ -12,6 +12,9 @@#include <linux/bpf_verifier.h> #include <linux/lsm_hooks.h> +/* max bpf xattrs per inode */ +#define BPF_LSM_INODE_INIT_XATTRS 4 +#ifdef CONFIG_BPF_LSM extern bool bpf_lsm_initialized__ro_after_init ;
include/linux/security.h +10 -0
@@ -406,6 +406,9 @@ void security_inode_free(struct inode *inode);int security_inode_init_security (struct inode *inode,struct inode *dir,const struct qstr *qstr,initxattrs initxattrs,void *fs_data); +int security_lsmxattr_add (struct lsm_xattrs *xattrs,u64 lsm_id, +const char *name_extra,const void *value, +size_t value_len);int security_inode_init_security_anon (struct inode *inode,const struct qstr *name,const struct inode *context_inode);
@@ -900,6 +903,13 @@ static inline int security_inode_init_security(struct inode *inode,return 0 ; } +static inline int security_lsmxattr_add (struct lsm_xattrs *xattrs,u64 lsm_id, +const char *name_extra, +const void *value,size_t value_len) +{ +return -EOPNOTSUPP ; +} +static inline int security_inode_init_security_anon (struct inode *inode,const struct qstr *name,const struct inode *context_inode)
security/bpf/hooks.c +1 -0
@@ -33,6 +33,7 @@ static int __init bpf_lsm_init(void)struct lsm_blob_sizes bpf_lsm_blob_sizes__ro_after_init = { .lbs_inode =sizeof (struct bpf_storage_blob ), + .lbs_xattr_count =BPF_LSM_INODE_INIT_XATTRS , };DEFINE_LSM (bpf) = {
security/security.c +96 -0
108 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v6 3/4 bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling
In reply to David WindsorAdd bpf_init_inode_xattr() kfunc for BPF LSM programs to atomically set xattrs via the inode_init_security hook using security_lsmxattr_add(). The hook now passes its xattr state as a single struct lsm_xattrs object, which the kfunc takes directly.
This kfunc is only callable from inode_init_security; the verifier rejects attempts to call it elsewhere.
A previous attempt [1] required a kmalloc string output protocol for the xattr name. Since commit 6bcdfd2cac55 ("security: Allow all LSMs to provide xattrs for inode_init_security hook") [2], the xattr name is no longer allocated; it is a static constant.
--- fs/bpf_fs_kfuncs.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
fs/bpf_fs_kfuncs.c +41 -0
@@ -11,7 +11,9 @@#include <linux/file.h> #include <linux/kernfs.h> #include <linux/mm.h> +#include <linux/security.h> #include <linux/xattr.h> +#include <uapi/linux/lsm.h> __bpf_kfunc_start_defs ();
@@ -379,6 +381,44 @@ __bpf_kfunc struct inode *bpf_real_data_inode(struct file *file)return d_real_inode (file_dentry (file)); } +/** +* bpf_init_inode_xattr - set an xattr on a new inode from inode_init_security +* @xattrs: inode_init_security xattr state from the hook context +* @name__str: xattr name (e.g., "bpf.file_label") +* @value_p: dynptr containing the xattr value +* +* Only callable from lsm/inode_init_security programs. +* +* Return: 0 on success, -EOPNOTSUPP if the filesystem does not accept +* xattrs at inode creation, negative error on other failures. +*/ +__bpf_kfunc int bpf_init_inode_xattr(struct lsm_xattrs *xattrs, +const char *name__str, +const struct bpf_dynptr *value_p) +{ +struct bpf_dynptr_kern *value_ptr = (struct bpf_dynptr_kern *)value_p; +const void *value; +u32 value_len; + +if (!name__str) +return -EINVAL ; +if (strncmp (name__str,XATTR_BPF_LSM_SUFFIX , +sizeof (XATTR_BPF_LSM_SUFFIX ) -1 )) +return -EPERM ; + +if (!xattrs->xattrs) +return -EOPNOTSUPP ; + + value_len =__bpf_dynptr_size (value_ptr); + value =__bpf_dynptr_data (value_ptr, value_len); +if (!value) +return -EINVAL ; + +return security_lsmxattr_add (xattrs,LSM_ID_BPF , + name__str +sizeof (XATTR_BPF_LSM_SUFFIX ) -1 , + value, value_len); +} +__bpf_kfunc_end_defs ();BTF_KFUNCS_START (bpf_fs_kfunc_set_ids)
@@ -390,6 +430,7 @@ BTF_ID_FLAGS(func, bpf_get_file_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_set_dentry_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_remove_dentry_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_real_data_inode, KF_SLEEPABLE | KF_RET_NULL) +BTF_ID_FLAGS(func, bpf_init_inode_xattr)BTF_KFUNCS_END (bpf_fs_kfunc_set_ids) static int bpf_fs_kfuncs_filter(const struct bpf_prog *prog, u32 kfunc_id)
Signature · 1 line
2.53.0
PATCH v6 4/4 selftests/bpf: add tests for bpf_init_inode_xattr kfunc
In reply to David WindsorTest bpf atomic inode xattr labeling in inode_init_security.
--- tools/testing/selftests/bpf/bpf_kfuncs.h | 5 + .../selftests/bpf/prog_tests/fs_kfuncs.c | 156 ++++++++++++++++++ .../bpf/progs/test_init_inode_xattr.c | 33 ++++ 3 files changed, 194 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/test_init_inode_xattr.c
tools/testing/selftests/bpf/bpf_kfuncs.h +5 -0
@@ -92,4 +92,9 @@ extern int bpf_set_dentry_xattr(struct dentry *dentry, const char *name__str, const struct bpf_dynptr *value_p, int flags) __ksym __weak; extern int bpf_remove_dentry_xattr(struct dentry *dentry, const char *name__str) __ksym __weak; +struct lsm_xattrs ; +extern int bpf_init_inode_xattr(struct lsm_xattrs *xattrs, + const char *name__str, + const struct bpf_dynptr *value_p) __ksym __weak; +#endif
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +156 -0
172 lines not on this page · raw message
tools/testing/selftests/bpf/progs/test_init_inode_xattr.c new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2026 Cisco Systems, Inc. */ + +#include "vmlinux.h" +#include <bpf/bpf_tracing.h> +#include "bpf_kfuncs.h" + +char _license[] SEC("license") = "GPL"; + +__u32 monitored_pid; +int hook_ran; +int init_result =-1 ; + +const char xattr_name[16 ] ="bpf.test_label" ; +char xattr_value[] ="unconfined_u:object_r:user_home_t:s0" ; + +SEC("lsm/inode_init_security") +int BPF_PROG (test_init_inode_xattr ,struct inode *inode,struct inode *dir, +const struct qstr *qstr,struct lsm_xattrs *xattrs) +{ +struct bpf_dynptr value_ptr; +__u32 pid; + + pid =bpf_get_current_pid_tgid () >>32 ; +if (pid != monitored_pid) +return 0 ; + + hook_ran =1 ; +bpf_dynptr_from_mem (xattr_value,sizeof (xattr_value),0 , &value_ptr); + init_result =bpf_init_inode_xattr (xattrs, xattr_name, &value_ptr); + +return 0 ; +}
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v6 bpf-next 1/4] security: introduce struct lsm_xattrs
In reply to David WindsorThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Latent buffer overflow: `struct lsm_xattrs` lacks a capacity field, and `lsm_get_xattr_slot()`…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Latent buffer overflow: struct lsm_xattrs lacks a capacity field, and lsm_get_xattr_slot() increments xattr_count without bounds checking. --
--- Patch [1]: [PATCH v6 bpf-next 1/4] security: introduce struct lsm_xattrs --- commit 4d965e040bf3aa7aac8ca18905c2c3f09a037f96
Author: David Windsor <[email protected]>
security: introduce struct lsm_xattrs
This patch introduces struct lsm_xattrs to consolidate the LSM xattr array and its count into a single context object. This preparation allows better compatibility with the BPF verifier for a planned kfunc that lets BPF LSM programs atomically label new inodes.
Quoted 3 lines
include/linux/security.h +0
-0
[ ... ]
include/linux/security.h struct watch; · line 75
Quoted 9 lines
include/linux/security.h +5
-0@@ -68,6 +68,11 @@ struct watch;struct watch_notification ;struct lsm_ctx ; +struct lsm_xattrs { +struct xattr *xattrs; +unsigned int xattr_count; +}; +
[Severity: Medium]
Should this struct also track the maximum capacity of the array?
Since this object is being introduced to allow dynamically loaded BPF LSM programs to label new inodes, a BPF program calling the planned kfunc multiple times could potentially exceed the allocated capacity. Tracking the max capacity would allow for bounds checking.
Quoted 2 lines
include/linux/security.h +0
-0/* Default (no) options for the capable function */ #define CAP_OPT_NONE 0x0
[ ... ]
Quoted 3 lines
include/linux/lsm_hooks.h +0
-0
[ ... ]
include/linux/lsm_hooks.h extern struct lsm_static_calls_table static_calls_table __ro_after_init; · line 215
Quoted 10 lines
include/linux/lsm_hooks.h +3
-4-static inline struct xattr *lsm_get_xattr_slot (struct xattr *xattrs, -int *xattr_count) +static inline struct xattr *lsm_get_xattr_slot (struct lsm_xattrs *ctx) { -if (unlikely (!xattrs)) +if (unlikely (!ctx || !ctx->xattrs))return NULL ; -return &xattrs[(*xattr_count)++]; +return &ctx->xattrs[ctx->xattr_count++]; }
[Severity: Medium]
Does this increment need a bounds check against the array capacity?
If a dynamic BPF LSM program requests more slots than were allocated in security_inode_init_security() (via blob_sizes.lbs_xattr_count + 1), this would result in an out-of-bounds write to the array.
This could subsequently lead to memory corruption during the cleanup loop that calls kfree() on the array elements.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Paul Moore
maintainerQuoted 68 lines · David Windsor
Add
bpf_init_inode_xattr()kfunc for BPF LSM programs to atomically set xattrs via theinode_init_securityhook usingsecurity_lsmxattr_add(). The hook now passes its xattr state as a single structlsm_xattrsobject, which the kfunc takes directly.This kfunc is only callable from
inode_init_security; the verifier rejects attempts to call it elsewhere.A previous attempt [1] required a kmalloc string output protocol for the xattr name. Since commit
6bcdfd2cac55("security: Allow all LSMs to provide xattrs forinode_init_securityhook") [2], the xattr name is no longer allocated; it is a static constant.Suggested-by Song Liu <[email protected]>Signed-off-by David Windsor <[email protected]>--- fs/bpf_fs_kfuncs.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)fs/bpf_fs_kfuncs.c +30
-0@@ -11,7 +11,9 @@#include <linux/file.h> #include <linux/kernfs.h> #include <linux/mm.h> +#include <linux/security.h> #include <linux/xattr.h> +#include <uapi/linux/lsm.h> __bpf_kfunc_start_defs ();@@ -379,6 +381,44 @@ __bpf_kfunc struct inode *bpf_real_data_inode(struct file *file)return d_real_inode (file_dentry (file)); } +/** +* bpf_init_inode_xattr - set an xattr on a new inode from inode_init_security +* @xattrs: inode_init_security xattr state from the hook context +* @name__str: xattr name (e.g., "bpf.file_label") +* @value_p: dynptr containing the xattr value +* +* Only callable from lsm/inode_init_security programs. +* +* Return: 0 on success, -EOPNOTSUPP if the filesystem does not accept +* xattrs at inode creation, negative error on other failures. +*/ +__bpf_kfunc int bpf_init_inode_xattr(struct lsm_xattrs *xattrs, +const char *name__str, +const struct bpf_dynptr *value_p) +{ +struct bpf_dynptr_kern *value_ptr = (struct bpf_dynptr_kern *)value_p; +const void *value; +u32 value_len; + +if (!name__str) +return -EINVAL ; +if (strncmp (name__str,XATTR_BPF_LSM_SUFFIX , +sizeof (XATTR_BPF_LSM_SUFFIX ) -1 )) +return -EPERM ; + +if (!xattrs->xattrs) +return -EOPNOTSUPP ; +
fs/bpf_fs_kfuncs.c __bpf_kfunc struct inode *bpf_real_data_inode(struct file *file) · line 421
Quoted 10 lines
fs/bpf_fs_kfuncs.c +10
-0+ value_len =__bpf_dynptr_size (value_ptr); + value =__bpf_dynptr_data (value_ptr, value_len); +if (!value) +return -EINVAL ; + +return security_lsmxattr_add (xattrs,LSM_ID_BPF , + name__str +sizeof (XATTR_BPF_LSM_SUFFIX ) -1 , + value, value_len); +} +
Based on our discussion in the v5 patchset, I was expecting to see this under security/; did something happen, or was there some confusion?
Signature · 1 line
paul-moore.com
[email protected]
AI reviewRe: [PATCH v6 bpf-next 4/4] selftests/bpf: add tests for bpf_init_inode_xattr kfunc
In reply to David WindsorThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Silent test skipping if the testfile exists from a previous aborted run. - [Low] Multi-line…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Silent test skipping if the testfile exists from a previous aborted run.
- [Low] Multi-line comment does not follow the required BPF subsystem style. --
--- Patch [4]: [PATCH v6 bpf-next 4/4] selftests/bpf: add tests for bpf_init_inode_xattr kfunc --- commit a299ac47c44a77d98dbdf43f3ba7c981f13fd930
Author: David Windsor <[email protected]>
selftests/bpf: add tests for bpf_init_inode_xattr kfunc
This commit adds selftests for BPF atomic inode xattr labeling in the inode_init_security hook.
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +0
-0
[ ... ]
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c static void test_fsverity(void) · line 280
Quoted 13 lines
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +9
-0@@ -268,6 +269,155 @@ static void test_fsverity(void)remove (testfile); } +static void test_init_inode_xattr (void ) +{ +struct test_init_inode_xattr *skel =NULL ; +int fd =-1 , err; +char value_out[64 ]; + +/* This test must be run from a fs that calls +* security_inode_init_security(). +*/
[Severity: Low]
This isn't a bug, but does this multi-line comment violate the BPF subsystem style guidelines? The guidelines prefer the opening /* on its own line:
/* * This test must be run from a fs that calls * security_inode_init_security(). */
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c static void test_fsverity(void) · line 293
Quoted 13 lines
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +13
-0+const char *testfile_new ="/dev/shm/test_progs_fs_kfuncs_new" ; + + skel =test_init_inode_xattr__open_and_load (); +if (!ASSERT_OK_PTR (skel,"test_init_inode_xattr__open_and_load" )) +return ; + + skel->bss->monitored_pid =getpid (); + err =test_init_inode_xattr__attach (skel); +if (!ASSERT_OK (err,"test_init_inode_xattr__attach" )) + goto out; + +/* Trigger inode_init_security */ + fd =open (testfile_new,O_CREAT |O_RDWR ,0644 );
[Severity: Medium]
Could this result in silently skipping the test if the file already exists from a previous aborted run?
By omitting O_EXCL, if the test file is already present, open() will not create a new inode. This means the inode_init_security hook won't trigger, and the test will hit the skip condition below. Should we use O_CREAT | O_EXCL | O_RDWR here to ensure we always create a new inode?
Quoted 14 lines
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +14
-0+if (!ASSERT_GE (fd,0 ,"create_file" )) + goto out; + +/* +* Probably should not be needed as we will be labeling a file +* in /dev/shm, but just in case we check if the hook was actually +* called. +*/ +if (!skel->bss->hook_ran) { +printf ("%s:SKIP:inode_init_security hook was not invoked\n" , + __func__); +test__skip (); + goto out; + }
[ ... ]
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +2
-0+static void test_init_inode_xattr_slot_limit (void ) +{
[ ... ]
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c static void test_fsverity(void) · line 379
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +2
-0+/* Trigger inode_init_security once with all programs attached. */ + fd =open (testfile_slot,O_CREAT |O_RDWR ,0644 );
[Severity: Medium]
Does this face the same issue where a pre-existing file from a previous aborted run could cause the test to silently skip?
Adding O_EXCL would guarantee the inode is created and the hook is triggered.
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c +2
-0+if (!ASSERT_GE (fd,0 ,"create_file" )) + goto out;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH v6 bpf-next 2/4] security: add security_lsmxattr_add()
In reply to David WindsorThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The dynamically allocated `xattr->name` pointer is used after being freed by…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The dynamically allocated xattr->name pointer is used after being freed by security_inode_init_security() in the ocfs2 filesystem. --
--- Patch [2]: [PATCH v6 bpf-next 2/4] security: add security_lsmxattr_add() --- commit cefa37d110516b84cf53133f4f60bba93ba53641
Author: David Windsor <[email protected]>
security: add security_lsmxattr_add()
This commit adds security_lsmxattr_add(), which claims a slot in the inode_init_security xattr array on behalf of the calling LSM. It fills the slot with a dynamically allocated copy of the given name and value.
Quoted 4 lines
security/security.c +0
-0
[ ... ]
Quoted 1 line
security/security.c +0
-0@@ -1376,6 +1377,101 @@ int security_inode_init_security(struct inode *inode, struct inode *dir,
[ ... ]
Quoted 4 lines
security/security.c +4
-0+int security_lsmxattr_add (struct lsm_xattrs *xattrs,u64 lsm_id, +const char *name_extra,const void *value, +size_t value_len) +{
[ ... ]
Quoted 10 lines
security/security.c +10
-0+/* Combine xattr value + name into one allocation. */ + xattr_value =kmalloc (value_len + name_len +1 ,GFP_NOWAIT ); +if (!xattr_value) +return -ENOMEM ; + +memcpy (xattr_value, value, value_len); +memcpy (xattr_value + value_len, suffix, suffix_len); +if (extra_len) +memcpy (xattr_value + value_len + suffix_len, name_extra, + extra_len);
security/security.c int security_inode_init_security(struct inode *inode, struct inode *dir, · line 1469
Quoted 10 lines
security/security.c +10
-0+ ((char *)xattr_value)[value_len + name_len] ='\0' ; + + xattr =lsm_get_xattr_slot (xattrs); +if (!xattr) { +kfree (xattr_value); +return -ENOSPC ; + } + + xattr->value = xattr_value; + xattr->name = (const char *)xattr_value + value_len;
[Severity: High]
Does this code cause a use-after-free for filesystems like ocfs2?
Looking at ocfs2, the ocfs2_initxattrs() callback saves the xattr->name pointer directly into si->name, assuming it has a static lifetime (which was true for SELinux and Smack):
fs/ocfs2/xattr.c:ocfs2_initxattrs() {
...
si->name = xattr_array->name;
...
}But here xattr->name points inside the dynamically allocated xattr->value block. When security_inode_init_security() completes, it frees xattr->value:
security/security.c:security_inode_init_security() {
...
ret = initxattrs(inode, xattrs.xattrs, fs_data);
out:
for (; xattrs.xattr_count > 0; xattrs.xattr_count--)
kfree(xattrs.xattrs[xattrs.xattr_count - 1].value);
...
}After this free, ocfs2_mknod() will call ocfs2_calc_xattr_init(), which dereferences the now-dangling si->name pointer:
fs/ocfs2/xattr.c:ocfs2_calc_xattr_init() {
...
s_size = ocfs2_xattr_entry_real_size(strlen(si->name),
si->value_len);
...
}Could the dynamically allocated name trigger a use-after-free here?
Quoted 4 lines
security/security.c +4
-0+ xattr->value_len = value_len; + +return 0 ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Quoted 5 lines · Paul Moore
Based on our discussion in the v5 patchset, I was expecting to see this under
security/; did something happen, or was there some confusion?
Nothing happened, perhaps some confusion. I was basing the placement off of Kumar's comment in v5:
Quoted 1 line
I don't think we should do that in v6 though. What you're describing affects all
other xattr kfuncs. That's a broader discussion we should have separately when folks are back from vacation, and more importantly involve FS folks where the code currently lives. As you say yourself, the lines are blurry, xattrs are as much a filesystem concept.
My take on this was, leave it in fs/ for now and then litigate the placement of all of the fs-related kfuncs after bpf_init_inode_xattr lands.
Happy to place this in security/ in v7, if that's preferred. Apologies if I misread the thread.
-David
Quoted 2 lines
--
paul-moore.com
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 13 lines
Add
bpf_init_inode_xattr()kfunc for BPF LSM programs to atomically set xattrs via theinode_init_securityhook usingsecurity_lsmxattr_add(). The hook now passes its xattr state as a single structlsm_xattrsobject, which the kfunc takes directly.This kfunc is only callable from
inode_init_security; the verifier rejects attempts to call it elsewhere.A previous attempt [1] required a kmalloc string output protocol for the xattr name. Since commit
6bcdfd2cac55("security: Allow all LSMs to provide xattrs forinode_init_securityhook") [2], the xattr name is no longer allocated; it is a static constant.
Quoted 4 lines
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v6 bpf-next 2/4] security: add security_lsmxattr_add()
In reply to [email protected]Quoted 56 lines · On Thu, Jul 30, 2026 at 8:00 PM <[email protected]> wrote:
Quoted 5 lines
security/security.c +4
-0+int security_lsmxattr_add (struct lsm_xattrs *xattrs,u64 lsm_id, +const char *name_extra,const void *value, +size_t value_len) +{[ ... ]
Quoted 10 lines
security/security.c +10
-0+/* Combine xattr value + name into one allocation. */ + xattr_value =kmalloc (value_len + name_len +1 ,GFP_NOWAIT ); +if (!xattr_value) +return -ENOMEM ; + +memcpy (xattr_value, value, value_len); +memcpy (xattr_value + value_len, suffix, suffix_len); +if (extra_len) +memcpy (xattr_value + value_len + suffix_len, name_extra, + extra_len);security/security.c int security_inode_init_security(struct inode *inode, struct inode *dir, · line 1469
Quoted 10 lines
security/security.c +10
-0+ ((char *)xattr_value)[value_len + name_len] ='\0' ; + + xattr =lsm_get_xattr_slot (xattrs); +if (!xattr) { +kfree (xattr_value); +return -ENOSPC ; + } + + xattr->value = xattr_value; + xattr->name = (const char *)xattr_value + value_len;[Severity: High]
Does this code cause a use-after-free for filesystems like ocfs2?Looking at ocfs2, the
ocfs2_initxattrs()callback saves thexattr->namepointer directly intosi->name, assuming it has a static lifetime (which was true for SELinux and Smack):fs/ocfs2/xattr.c:ocfs2_initxattrs() { ... si->name = xattr_array->name; ... }But here
xattr->namepoints inside the dynamically allocatedxattr->valueblock. Whensecurity_inode_init_security()completes, it freesxattr->value:security/security.c:security_inode_init_security() { ... ret = initxattrs(inode, xattrs.xattrs, fs_data); out: for (; xattrs.xattr_count > 0; xattrs.xattr_count--) kfree(xattrs.xattrs[xattrs.xattr_count - 1].value); ... }After this free,
ocfs2_mknod()will callocfs2_calc_xattr_init(), which dereferences the now-danglingsi->namepointer:
Quoted 9 lines
fs/ocfs2/xattr.c:ocfs2_calc_xattr_init() { ... s_size = ocfs2_xattr_entry_real_size(strlen(si->name), si->value_len); ... }Could the dynamically allocated name trigger a use-after-free here?
This is real. ocfs stashes the name pointer beyond the call; it's the only fs who does so. We can special-case ocfs and be done with it. Will do this in v7.
Quoted 7 lines
security/security.c int security_inode_init_security(struct inode *inode, struct inode *dir, · line 1473
Quoted 4 lines
security/security.c +4
-0+ xattr->value_len = value_len; + +return 0 ; +}--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Paul Moore
maintainerQuoted 16 lines · David Windsor
Quoted 5 lines · Paul Moore
Based on our discussion in the v5 patchset, I was expecting to see this under
security/; did something happen, or was there some confusion?Nothing happened, perhaps some confusion. I was basing the placement off of Kumar's comment in v5:
Quoted 1 line
I don't think we should do that in v6 though. What you're describing affects all
other xattr kfuncs. That's a broader discussion we should have separately when folks are back from vacation, and more importantly involve FS folks where the code currently lives. As you say yourself, the lines are blurry, xattrs are as much a filesystem concept.
Quoted 6 lines
My take on this was, leave it in
fs/for now and then litigate the placement of all of the fs-related kfuncs afterbpf_init_inode_xattrlands.Happy to place this in
security/in v7, if that's preferred. Apologies if I misread the thread.
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)
However, regardless of Kumar's intent, speaking as the LSM maintainer, my stance on this is that the kfunc you are proposing must live in security/bpf_lsm_kfuncs.c to be acceptable.
Signature · 1 line
paul-moore.com
Quoted 10 lines · Paul Moore
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in
fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)
Yes, after another reading, that does appear to be the case =).
We'll need v7 anyway to fix the ocfs-related UAF the bot found.
Quoted 4 lines
However, regardless of Kumar's intent, speaking as the LSM maintainer, my stance on this is that the kfunc you are proposing must live in
security/bpf_lsm_kfuncs.cto be acceptable.
Ack, will do this in v7.
The Landlock series currently up for discussion [1] is proposing placing its kfuncs in a new kernel/bpf/bpf_lsm.c. Should these maybe go there?
[1] https://lore.kernel.org/bpf/[email protected]/
Quoted 2 lines
--
paul-moore.com
Paul Moore
maintainerQuoted 21 lines · David Windsor
Quoted 10 lines · Paul Moore
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in
fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)Yes, after another reading, that does appear to be the case =).
We'll need v7 anyway to fix the ocfs-related UAF the bot found.
Quoted 4 lines
However, regardless of Kumar's intent, speaking as the LSM maintainer, my stance on this is that the kfunc you are proposing must live in
security/bpf_lsm_kfuncs.cto be acceptable.
Quoted 5 lines
Ack, will do this in v7.
The Landlock series currently up for discussion [1] is proposing placing its kfuncs in a new
kernel/bpf/bpf_lsm.c. Should these maybe go there?
Nope. That patchset has its own issues, one of which is the location of the kfuncs outside of security/; I simply haven't had the time to review that in full and reply.
Signature · 1 line
paul-moore.com
Quoted 5 lines · Paul Moore
Nope. That patchset has its own issues, one of which is the location of the kfuncs outside of
security/; I simply haven't had the time to review that in full and reply.
Makes sense, thanks, just wanted to avoid churn if possible.
Quoted 2 lines
--
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 12 lines · David Windsor
Quoted 10 lines · Paul Moore
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in
fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)
Quoted 4 lines
Yes, after another reading, that does appear to be the case =).
We'll need v7 anyway to fix the ocfs-related UAF the bot found.
Since there is confusion, let me clear it up.
I meant it for all of them. I don't think it makes sense to keep this one in security/ when others are in fs/bpf_fs_kfuncs.c. That confusing limbo state is worse than just placing it where others already are.
As I already said, the discussion around whether all of them they should go in security/ is orthogonal and should be done separately; it isn't productive to repeatedly bring it up in the context of this patch set.
I honestly don't get the urgency; it will be a mechanical change if we need to make such changes. The worst outcome would be stalling David's work over it.
As for landing this stuff, we can let Paul take the patches touching security/ and route the rest (3-4) through bpf-next after the merge window. We need them to go through BPF CI anyway to ensure nothing breaks.
Quoted 15 lines
Quoted 4 lines
However, regardless of Kumar's intent, speaking as the LSM maintainer, my stance on this is that the kfunc you are proposing must live in
security/bpf_lsm_kfuncs.cto be acceptable.Ack, will do this in v7.
The Landlock series currently up for discussion [1] is proposing placing its kfuncs in a new
kernel/bpf/bpf_lsm.c. Should these maybe go there?[1] https://lore.kernel.org/bpf/[email protected]/
Quoted 2 lines
--
paul-moore.com
Paul Moore
maintainerQuoted 28 lines · Kumar Kartikeya Dwivedi
Quoted 12 lines · David Windsor
Quoted 10 lines · Paul Moore
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in
fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)Quoted 4 lines
Yes, after another reading, that does appear to be the case =).
We'll need v7 anyway to fix the ocfs-related UAF the bot found.
Since there is confusion, let me clear it up.
I meant it for all of them. I don't think it makes sense to keep this one in
security/when others are infs/bpf_fs_kfuncs.c. That confusing limbo state is worse than just placing it where others already are.As I already said, the discussion around whether all of them they should go in
security/is orthogonal and should be done separately; it isn't productive to repeatedly bring it up in the context of this patch set.
Quoted 6 lines
I honestly don't get the urgency; it will be a mechanical change if we need to make such changes. The worst outcome would be stalling David's work over it.
As for landing this stuff, we can let Paul take the patches touching
security/and route the rest (3-4) through bpf-next after the merge window. We need them to go through BPF CI anyway to ensure nothing breaks.
Some existing LSM kfuncs are located in the wrong files. I'm not suggesting that David needs to fix the existing problems, but there is no reason to keep making the same mistakes. The new LSM kfunc must go in security/bpf_lsm_kfuncs.c; if that isn't acceptable to the BPF developers then David will need to find a new way that doesn't involve kfuncs.
Signature · 1 line
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 37 lines · Paul Moore
Quoted 28 lines · Kumar Kartikeya Dwivedi
Quoted 12 lines · David Windsor
Quoted 10 lines · Paul Moore
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in
fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)Quoted 4 lines
Yes, after another reading, that does appear to be the case =).
We'll need v7 anyway to fix the ocfs-related UAF the bot found.
Since there is confusion, let me clear it up.
I meant it for all of them. I don't think it makes sense to keep this one in
security/when others are infs/bpf_fs_kfuncs.c. That confusing limbo state is worse than just placing it where others already are.As I already said, the discussion around whether all of them they should go in
security/is orthogonal and should be done separately; it isn't productive to repeatedly bring it up in the context of this patch set.Quoted 6 lines
I honestly don't get the urgency; it will be a mechanical change if we need to make such changes. The worst outcome would be stalling David's work over it.
As for landing this stuff, we can let Paul take the patches touching
security/and route the rest (3-4) through bpf-next after the merge window. We need them to go through BPF CI anyway to ensure nothing breaks.
Quoted 6 lines
Some existing LSM kfuncs are located in the wrong files. I'm not suggesting that David needs to fix the existing problems, but there is no reason to keep making the same mistakes. The new LSM kfunc must go in
security/bpf_lsm_kfuncs.c; if that isn't acceptable to the BPF developers then David will need to find a new way that doesn't involve kfuncs.
What "mistakes"? Really? It's just code organization bureaucracy. Calling it a mistake is just blowing things out of proportion.
I don't think you can simply decide this unilaterally either. Do you take full responsibility that kfuncs going there won't introduce BPF side regressions? Who makes sure patches touching the new location run through BPF CI? All of this needs to be thought through before we decide upon anything.
Thus, I am simply asking you to be reasonable: let's help David make progress, and get the changes landed. FS, BPF, and LSM folks can then decide on where to copy paste the existing kfuncs later.
So David, please send the v7 once you've address Sashiko's concern. We are almost there, and you've been at it for a long time.
Paul Moore
maintainerQuoted 45 lines · Kumar Kartikeya Dwivedi
Quoted 37 lines · Paul Moore
Quoted 28 lines · Kumar Kartikeya Dwivedi
Quoted 12 lines · David Windsor
Quoted 10 lines · Paul Moore
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in
fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)Quoted 4 lines
Yes, after another reading, that does appear to be the case =).
We'll need v7 anyway to fix the ocfs-related UAF the bot found.
Since there is confusion, let me clear it up.
I meant it for all of them. I don't think it makes sense to keep this one in
security/when others are infs/bpf_fs_kfuncs.c. That confusing limbo state is worse than just placing it where others already are.As I already said, the discussion around whether all of them they should go in
security/is orthogonal and should be done separately; it isn't productive to repeatedly bring it up in the context of this patch set.Quoted 6 lines
I honestly don't get the urgency; it will be a mechanical change if we need to make such changes. The worst outcome would be stalling David's work over it.
As for landing this stuff, we can let Paul take the patches touching
security/and route the rest (3-4) through bpf-next after the merge window. We need them to go through BPF CI anyway to ensure nothing breaks.Quoted 6 lines
Some existing LSM kfuncs are located in the wrong files. I'm not suggesting that David needs to fix the existing problems, but there is no reason to keep making the same mistakes. The new LSM kfunc must go in
security/bpf_lsm_kfuncs.c; if that isn't acceptable to the BPF developers then David will need to find a new way that doesn't involve kfuncs.
Quoted 2 lines
What "mistakes"? Really? It's just code organization bureaucracy. Calling it a mistake is just blowing things out of proportion.
:D
You've no doubt seen the challenging interactions between some of the BPF and LSM developers over the past several years. A recent BPF LSM bug/vulnerability as well as these interactions between the BPF/LSM devs, has caused me to take a much closer look at how things have been done regarding the BPF LSM and there are a number of things that should be addressed. Not all of those things will be addressed now, but I won't support patches that continue to do things the wrong way because I currently have very little faith in our ability to correct them later. I do hope that at some time in the future we can reach a point where there is more cooperation between the two communities, but given the recent difficulties over even the small things, we are not there yet.
Quoted 4 lines
I don't think you can simply decide this unilaterally either. Do you take full responsibility that kfuncs going there won't introduce BPF side regressions? Who makes sure patches touching the new location run through BPF CI? All of this needs to be thought through before we decide upon anything.
I would expect, and require, that patch submitters perform the necessary testing for the patches they submit; this is no different from any other patch today that is submitted for the LSM framework. Patch submitters would also be required to CC the BPF mailing list and I would encourage interested BPF community members to offer their feedback and review; once again, this is no different from any other cross-subsystem patch today submitted for the LSM framework.
Quoted 3 lines
Thus, I am simply asking you to be reasonable: let's help David make progress, and get the changes landed. FS, BPF, and LSM folks can then decide on where to copy paste the existing kfuncs later.
I view my position as both entirely reasonable and consistent with the current LSM approach to cross-subsystem patches. The location of the kfunc David is proposing is dictated largely by the kfunc's contents and interactions; it is only legal to be called from an LSM hook callback, it manipulates LSM-only data structures, and aside from some BPF kfunc boilerplate, it only calls into LSM hooks/functions.
Signature · 1 line
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 52 lines · Paul Moore
Quoted 45 lines · Kumar Kartikeya Dwivedi
Quoted 37 lines · Paul Moore
Quoted 28 lines · Kumar Kartikeya Dwivedi
Quoted 12 lines · David Windsor
Quoted 10 lines · Paul Moore
Okay, it looks like there was some confusion/misunderstanding.
My understanding of Kumar's comments was that he was referring to the exisiting LSM related kfuncs that are located in
fs/bpf_fs_kfuncs.c, not necessarily the new kfunc you are proposing in this patchset. Kumar is welcome to correct either one or both of us, if we read that wrong :)Quoted 4 lines
Yes, after another reading, that does appear to be the case =).
We'll need v7 anyway to fix the ocfs-related UAF the bot found.
Since there is confusion, let me clear it up.
I meant it for all of them. I don't think it makes sense to keep this one in
security/when others are infs/bpf_fs_kfuncs.c. That confusing limbo state is worse than just placing it where others already are.As I already said, the discussion around whether all of them they should go in
security/is orthogonal and should be done separately; it isn't productive to repeatedly bring it up in the context of this patch set.Quoted 6 lines
I honestly don't get the urgency; it will be a mechanical change if we need to make such changes. The worst outcome would be stalling David's work over it.
As for landing this stuff, we can let Paul take the patches touching
security/and route the rest (3-4) through bpf-next after the merge window. We need them to go through BPF CI anyway to ensure nothing breaks.Quoted 6 lines
Some existing LSM kfuncs are located in the wrong files. I'm not suggesting that David needs to fix the existing problems, but there is no reason to keep making the same mistakes. The new LSM kfunc must go in
security/bpf_lsm_kfuncs.c; if that isn't acceptable to the BPF developers then David will need to find a new way that doesn't involve kfuncs.Quoted 2 lines
What "mistakes"? Really? It's just code organization bureaucracy. Calling it a mistake is just blowing things out of proportion.
:D
Quoted 9 lines
You've no doubt seen the challenging interactions between some of the BPF and LSM developers over the past several years. A recent BPF LSM bug/vulnerability as well as these interactions between the BPF/LSM devs, has caused me to take a much closer look at how things have been done regarding the BPF LSM and there are a number of things that should be addressed. Not all of those things will be addressed now, but I won't support patches that continue to do things the wrong way because I currently have very little faith in our ability to correct them later.
I am not sure whether you shared whatever concerns you are talking about. If they are valid, we would be happy to engage and resolve them.
I am aware of the past discussions, but we did spend additional effort to find a way that worked well for everyone in the end.
Quoted 5 lines
I do hope that at some time in the future we can reach a point where there is more cooperation between the two communities, but given the recent difficulties over even the small things, we are not there yet.
I think it takes two hands to clap.
So far, I have tried to engage constructively, and offered to discuss where these kfuncs collectively should stay in a separate discussion. Explained why it cannot be done unilaterally, and that we need consensus from all stakeholders (FS, BPF, LSM). Explained that we need to figure out how the testing strategy for such cross-cutting changes would work if they don't go through BPF tree.
In response, I have only seen you continually tried to derail the whole thing over the location of the kfunc, threatening to not let it move forward.
Yes, I understand you feel it should be placed under security/. You are entitled to your opinion.
No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
It is calling a single security_lsmxattr_add() kfunc cleanly abstracted and already placed under security/, where it belongs.
Quoted 8 lines
Quoted 4 lines
I don't think you can simply decide this unilaterally either. Do you take full responsibility that kfuncs going there won't introduce BPF side regressions? Who makes sure patches touching the new location run through BPF CI? All of this needs to be thought through before we decide upon anything.
I would expect, and require, that patch submitters perform the necessary testing for the patches they submit; this is no different from any other patch today that is submitted for the LSM framework.
It doesn't scale. The amount of combinations (architectures x compilers x modes) that need to be tested for the BPF subsystem is beyond reasonable for any patch submitter to test themselves. The only realistic approach is letting it go through BPF CI and exercising the full matrix on submission.
It is fairly apparent to me that you do not have a clear picture how BPF code gets tested (which is fine and understandable).
It only underscores my point: we need to move this discussion elsewhere, and have a broader dialogue and form consensus. Not litigate over it in this thread.
David spent considerable effort on this set, and has carefully reworked his code several times. Blocking his work over this terriotrial argument would be a loss for everyone, including the users of the kernel.
Anyhow, I cannot stop you, but it would be unfortunate if you continue to double down, in that case we'll have to figure out other ways of moving things forward.
Quoted 1 line
[...]
Paul Moore
maintainerQuoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 8 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in security/bpf_lsm_kfuncs.c.
Signature · 1 line
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 16 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 3 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.
Quoted 8 lines
Quoted 5 lines
No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in
security/bpf_lsm_kfuncs.c.
Right, and for that file to exist, you need to get everyone (FS, BPF folks) to agree on whether placing all such kfuncs there makes sense. It is not for both of us to decide on our own. So let's revisit this whole topic once you've done that exercise.
Paul Moore
maintainerQuoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 22 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 8 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
Quoted 7 lines
Quoted 2 lines
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in
security/bpf_lsm_kfuncs.c.Right, and for that file to exist, you need to get everyone (FS, BPF folks) to agree on whether placing all such kfuncs there makes sense. It is not for both of us to decide on our own. So let's revisit this whole topic once you've done that exercise.
The kfunc that David has proposed must be located in security/bpf_lsm_kfuncs.c, similar to the VFS kfuncs and fs/bpf_fs_kfuncs.c. If you read David's bpf_init_inode_xattr() kfunc you will notice there is nothing in the function relating to the VFS, well other than the "inode" and "xattr" in the name of the function; this is purely a LSM kfunc and I stand by my previous comments. The BPF maintainers have seen fit to decide quite a few things LSM related solely on their own, I see no reason why requiring a LSM kfunc be located in security/bpf_lsm_kfuncs.c is unreasonable given our current situation.
As I said earlier, I'm happy to work with you, David, or anyone else on ensuring security/bpf_lsm_kfuncs.c has the proper test coverage, but I'm not going to continue to go back and forth about the location of the bpf_init_inode_xattr() kfunc that is proposed in this patchset. If you, or any of the other BPF maintainers, are not able to live with that location then David will need to find another way.
Signature · 1 line
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 28 lines · Paul Moore
Quoted 26 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 8 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in
security/bpf_lsm_kfuncs.c.
Quoted 8 lines
Quoted 4 lines
Right, and for that file to exist, you need to get everyone (FS, BPF folks) to agree on whether placing all such kfuncs there makes sense. It is not for both of us to decide on our own. So let's revisit this whole topic once you've done that exercise.
The kfunc that David has proposed must be located in
security/bpf_lsm_kfuncs.c, similar to the VFS kfuncs andfs/bpf_fs_kfuncs.c. If you read David'sbpf_init_inode_xattr()kfunc
Sigh.
I now went and read the archives, and Christian already told you no before [0], which I missed in my first read. So two people whom this code affects already objected to your proposal.
[0]: https://lore.kernel.org/bpf/20260625-schnabel-rennmaschine-parieren-bcb352c3cf59@brauner
Quoted 2 lines
you will notice there is nothing in the function relating to the VFS, well other than the "inode" and "xattr" in the name of the function;
I can also read it the other way. There is only one "security_lsmxattr_add()" call that is LSM related, and the rest is VFS or BPF specific stuff.
There would be no xattr support in LSM code without filesystems implementing them.
Please avoid making absurd and non-sensical arguments.
If we went by this logic, we would have to move the entirety of the kernel under security/, since anything that calls into LSM code becomes eligible to go there.
Quoted 6 lines
this is purely a LSM kfunc and I stand by my previous comments. The BPF maintainers have seen fit to decide quite a few things LSM related solely on their own, I see no reason why requiring a LSM kfunc be located in
security/bpf_lsm_kfuncs.cis unreasonable given our current situation.
Quoted 6 lines
As I said earlier, I'm happy to work with you, David, or anyone else on ensuring
security/bpf_lsm_kfuncs.chas the proper test coverage, but I'm not going to continue to go back and forth about the location of thebpf_init_inode_xattr()kfunc that is proposed in this patchset. If you, or any of the other BPF maintainers, are not able to live with that location then David will need to find another way.
Yeah, I think we've spilled enough ink on this. We'll figure out a way to move things forward. Since VFS people disagree too, the kfunc should stay where it is in this series.
I am always open to revisiting all this once you can convince others by making useful arguments, instead of imposing your will onto them and throwing a tantrum.
Paul Moore
maintainerQuoted 38 lines · Kumar Kartikeya Dwivedi
Quoted 28 lines · Paul Moore
Quoted 26 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 8 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in
security/bpf_lsm_kfuncs.c.Quoted 8 lines
Quoted 4 lines
Right, and for that file to exist, you need to get everyone (FS, BPF folks) to agree on whether placing all such kfuncs there makes sense. It is not for both of us to decide on our own. So let's revisit this whole topic once you've done that exercise.
The kfunc that David has proposed must be located in
security/bpf_lsm_kfuncs.c, similar to the VFS kfuncs andfs/bpf_fs_kfuncs.c. If you read David'sbpf_init_inode_xattr()kfunc
Quoted 5 lines
Sigh.
I now went and read the archives, and Christian already told you no before [0], which I missed in my first read. So two people whom this code affects already objected to your proposal.
As mentioned previously, David's kfunc has nothing to do with the VFS. Look at the code if you haven't already and you'll see what I mean. The only relevance to the VFS is the fact that "inode" and "xattr" are used in the name; David's currently proposed kfunc is an LSM kfunc, not a VFS kfunc.
If you find yourself required to abide by Christian's comment, despite this not being a VFS kfunc, that's fine, but this puts us at a stalemate and David will need to find another approach for his work.
Signature · 1 line
paul-moore.com
Paul Moore
maintainerQuoted 2 lines · Paul Moore
...
Completely unrelated to everything else in this thread, does anyone reading this know if Matt Bobrowski is still at Google? I've been getting bounces on his @google.com address for a few weeks now, I'm assuming others have as well? If anyone is still in touch with Matt, can you ask him to update his address in MAINTAINERS? Failing that, can we at least remove his email from MAINTAINERS (feel free to leave his name if possible?) so we don't keep getting bounces on postings?
[NOTE: for obvious reasons I dropped Matt's address from this email]
Signature · 1 line
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 46 lines · Paul Moore
Quoted 38 lines · Kumar Kartikeya Dwivedi
Quoted 28 lines · Paul Moore
Quoted 26 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 8 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in
security/bpf_lsm_kfuncs.c.Quoted 8 lines
Quoted 4 lines
Right, and for that file to exist, you need to get everyone (FS, BPF folks) to agree on whether placing all such kfuncs there makes sense. It is not for both of us to decide on our own. So let's revisit this whole topic once you've done that exercise.
The kfunc that David has proposed must be located in
security/bpf_lsm_kfuncs.c, similar to the VFS kfuncs andfs/bpf_fs_kfuncs.c. If you read David'sbpf_init_inode_xattr()kfuncQuoted 5 lines
Sigh.
I now went and read the archives, and Christian already told you no before [0], which I missed in my first read. So two people whom this code affects already objected to your proposal.
Quoted 5 lines
As mentioned previously, David's kfunc has nothing to do with the VFS. Look at the code if you haven't already and you'll see what I mean. The only relevance to the VFS is the fact that "inode" and "xattr" are used in the name; David's currently proposed kfunc is an LSM kfunc, not a VFS kfunc.
I am sorry, I read it and I don't see why it is an LSM kfunc. It is absolutely a VFS kfunc, that is using LSM APIs to some end. The LSM specific bits are already in security/.
At the very least, it is a mix of both, but definitely not one or the other. Therefore, the situation is already ideal, code owned by different people is in the files they signed up to maintain.
Quoted 4 lines
If you find yourself required to abide by Christian's comment, despite this not being a VFS kfunc, that's fine, but this puts us at a stalemate and David will need to find another approach for his work.
Paul, let me remind you of another email you sent [0], in which you contradict yourself. I don't know what caused you to get confused over the month.
In it, you tell David to move *LSM* bits into security_lsmxattr_add(), which has been done in patch 2. Thus, by your own characterization, it means the rest is *not LSM* code.
Quoting you verbatim:
Quoted 2 lines
As I said previously, if you absolutely insist on the kfunc being in the VFS kfunc file, the LSM specific bits need to be abstracted out
^^^^^^^^^^^^^^^
Quoted 1 line
into an LSM function.
You yourself made the point in that same email that the kfunc can stay in the current file once LSM bits were moved out, and your request was honored.
At this point, anybody reading this thread will only see your position as a way to undermine David's work and waste everyone's time, such that you can grind an axe against BPF folks. It's a repeating pattern.
I tried my best to engage in good faith, but it is clearly not working.
[0]: https://lore.kernel.org/bpf/CAHC9VhQd0-N1g=g8gspeV7bhLz0LA6DF5HZyB7mW6VW_7oSt2w@mail.gmail.com
Paul Moore
maintainerQuoted 53 lines · Kumar Kartikeya Dwivedi
Quoted 46 lines · Paul Moore
Quoted 38 lines · Kumar Kartikeya Dwivedi
Quoted 28 lines · Paul Moore
Quoted 26 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 8 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in
security/bpf_lsm_kfuncs.c.Quoted 8 lines
Quoted 4 lines
Right, and for that file to exist, you need to get everyone (FS, BPF folks) to agree on whether placing all such kfuncs there makes sense. It is not for both of us to decide on our own. So let's revisit this whole topic once you've done that exercise.
The kfunc that David has proposed must be located in
security/bpf_lsm_kfuncs.c, similar to the VFS kfuncs andfs/bpf_fs_kfuncs.c. If you read David'sbpf_init_inode_xattr()kfuncQuoted 5 lines
Sigh.
I now went and read the archives, and Christian already told you no before [0], which I missed in my first read. So two people whom this code affects already objected to your proposal.
Quoted 5 lines
As mentioned previously, David's kfunc has nothing to do with the VFS. Look at the code if you haven't already and you'll see what I mean. The only relevance to the VFS is the fact that "inode" and "xattr" are used in the name; David's currently proposed kfunc is an LSM kfunc, not a VFS kfunc.
Quoted 3 lines
I am sorry, I read it and I don't see why it is an LSM kfunc. It is absolutely a VFS kfunc, that is using LSM APIs to some end. The LSM specific bits are already in
security/.
We clearly have different opinions on the matter. I've mentioned why I believe it is a LSM kfunc, I would be interested to hear why you believe it is a VFS kfunc (what VFS functions does it call, what VFS variables does it manipulate, etc.).
Quoted 15 lines
Quoted 3 lines
If you find yourself required to abide by Christian's comment, despite this not being a VFS kfunc, that's fine, but this puts us at a stalemate and David will need to find another approach for his work.
Paul, let me remind you of another email you sent [0], in which you contradict yourself. I don't know what caused you to get confused over the month.
In it, you tell David to move *LSM* bits into
security_lsmxattr_add(), which has been done in patch 2. Thus, by your own characterization, it means the rest is *not LSM* code.Quoting you verbatim:
Quoted 2 lines
As I said previously, if you absolutely insist on the kfunc being in the VFS kfunc file, the LSM specific bits need to be abstracted out
^^^^^^^^^^^^^^^
Quoted 8 lines
Quoted 1 line
into an LSM function.
You yourself made the point in that same email that the kfunc can stay in the current file once LSM bits were moved out, and your request was honored.
At this point, anybody reading this thread will only see your position as a way to undermine David's work and waste everyone's time, such that you can grind an axe against BPF folks. It's a repeating pattern.
It seems foolish to speculate on what *everyone* reading this thread might be thinking, but since the discussion has decayed to the point where we are spelunking archives for quotes, let me provide my comment from David's v5 patchset where I explain myself:
"I'm sorry David, now that I'm seeing this function again, especially with the LSM specific bits extracted into a LSM function, this absolutely belongs somewhere under security/. It's only callable from within a BPF LSM callback and all it does outside of some BPF pointer boilerplate is call right back into a LSM helper function."
You are welcome to view that however you like. I saw the v5 patchset and the nature of the kfunc became painfully obvious to me so I changed my opinion.
Quoted 1 line
I tried my best to engage in good faith, but it is clearly not working.
I've been working with David and providing feedback for a while now (perhaps before you started commenting? not sure on that), and I'm continuing to engage with David, you, and anyone else who wants to comment on this thread.
[NOTE: Dropped Matt's address due to bounces, see my other email in this thread about that.]
Signature · 1 line
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 90 lines · Paul Moore
Quoted 56 lines · Kumar Kartikeya Dwivedi
Quoted 46 lines · Paul Moore
Quoted 38 lines · Kumar Kartikeya Dwivedi
Quoted 28 lines · Paul Moore
Quoted 26 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
Quoted 1 line · David Windsor
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 8 lines
Yes, I understand you feel it should be placed under
security/. You are entitled to your opinion.No, I do not think the newly added kfunc is a big enough layering violation such that we need to do it ASAP, disregarding everything else outlined above. I am sure you see that too. There are several other instances of similar kfuncs.
Therefore, please attempt to meet me halfway here.
I'm happy to work with you, and/or anyone else, who wants to work on finding a way to test kfuncs that live in
security/bpf_lsm_kfuncs.c.Quoted 8 lines
Quoted 4 lines
Right, and for that file to exist, you need to get everyone (FS, BPF folks) to agree on whether placing all such kfuncs there makes sense. It is not for both of us to decide on our own. So let's revisit this whole topic once you've done that exercise.
The kfunc that David has proposed must be located in
security/bpf_lsm_kfuncs.c, similar to the VFS kfuncs andfs/bpf_fs_kfuncs.c. If you read David'sbpf_init_inode_xattr()kfuncQuoted 5 lines
Sigh.
I now went and read the archives, and Christian already told you no before [0], which I missed in my first read. So two people whom this code affects already objected to your proposal.
Quoted 5 lines
As mentioned previously, David's kfunc has nothing to do with the VFS. Look at the code if you haven't already and you'll see what I mean. The only relevance to the VFS is the fact that "inode" and "xattr" are used in the name; David's currently proposed kfunc is an LSM kfunc, not a VFS kfunc.
I am sorry, I read it and I don't see why it is an LSM kfunc. It is absolutely a VFS kfunc, that is using LSM APIs to some end. The LSM specific bits are already in
security/.[...]
Quoted 15 lines
Quoted 3 lines
If you find yourself required to abide by Christian's comment, despite this not being a VFS kfunc, that's fine, but this puts us at a stalemate and David will need to find another approach for his work.
Paul, let me remind you of another email you sent [0], in which you contradict yourself. I don't know what caused you to get confused over the month.
In it, you tell David to move *LSM* bits into
security_lsmxattr_add(), which has been done in patch 2. Thus, by your own characterization, it means the rest is *not LSM* code.Quoting you verbatim:
Quoted 2 lines
As I said previously, if you absolutely insist on the kfunc being in the VFS kfunc file, the LSM specific bits need to be abstracted out
^^^^^^^^^^^^^^^Quoted 8 lines
Quoted 1 line
into an LSM function.
You yourself made the point in that same email that the kfunc can stay in the current file once LSM bits were moved out, and your request was honored.
At this point, anybody reading this thread will only see your position as a way to undermine David's work and waste everyone's time, such that you can grind an axe against BPF folks. It's a repeating pattern.
It seems foolish to speculate on what *everyone* reading this thread might be thinking, but since the discussion has decayed to the point where we are spelunking archives for quotes, let me provide my comment from David's v5 patchset where I explain myself:
Quoted 5 lines
"I'm sorry David, now that I'm seeing this function again, especially with the LSM specific bits extracted into a LSM function, this absolutely belongs somewhere under
security/. It's only callable from within a BPF LSM callback and all it does outside of some BPF pointer boilerplate is call right back into a LSM helper function."
I think you keep forgetting that you cannot unilaterally decide this. Both VFS and BPF people have told you that it does not make sense. What was clearly LSM specific code has been moved under security/ already.
It's all BPF code otherwise, and topical for the VFS subsystem, hence it should stay there. That is why it's a VFS kfunc. The rest of the kernel calls LSM APIs and hooks, but it does not make them LSM code.
It needs to be reviewed by VFS and BPF maintainers. Yes, it's only called from BPF LSM callbacks, but plenty of kfuncs for those are already outside security/.
The right way to do address that is to get people who added and maintain that code to agree with you, not take the work of unsuspecting contributors hostage to meet your goals, and threatening to block their work.
And to set expectations, it is clear people do not agree with your stated move. When everyone tells you that you are wrong about something, sometimes, it is helpful to revisit your position.
Quoted 4 lines
You are welcome to view that however you like. I saw the v5 patchset and the nature of the kfunc became painfully obvious to me so I changed my opinion.
I think you have difficulties in recognizing that a piece of code can be cross-cutting, and affect several subsystems at once. The code that was clearly belonging to LSMs was already moved in patch 2. The unrelated stuff is where it has belonged in the past already, so that it can be reviewed by the right folks.
The best course of action IMO is channeling your version from 1 month ago, where you saw things more clearly, and help everyone move forward with this by landing the first two patches once you think they are in good shape. We will then take the rest through BPF tree. It will be a better, more productive outcome for everyone.
If you cannot do that, let's agree to disagree and not waste each others' time. We will work on figuring out some other way to help David.
Paul Moore
maintainerQuoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
Quoted 2 lines · Kumar Kartikeya Dwivedi
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 3 lines
I think you keep forgetting that you cannot unilaterally decide this. Both VFS and BPF people have told you that it does not make sense. What was clearly LSM specific code has been moved under
security/already.
I'm charged with doing the Right Thing for the LSM framework, and in my opinion it is in the best interest of the LSM framework that the kfunc being proposed lives in security/bpf_lsm_kfuncs.c, just as the VFS kfuncs live in fs/bpf_fs_kfuncs.c.
Quoted 2 lines
The right way to do address that is to get people who added and maintain that code to agree with you ...
I think that statement should be read by everyone, including the original author ;)
From what I can see the only issue we disagree on is the location of the kfunc in the codebase. Based on your earlier comments your concern about the location was based around testing, review, etc. while my primary concern about the location was based around the content, calling context, and general behavior of the hook with secondary concerns around visibility, code ownership, etc. Once again, I believe your review concerns are already addressed by our standard process around cross-subsystem reviews, and I'm happy to work with you, or anyone else, to address the testing issues. If you are unable or unwilling to work on resolving your testing concerns then we are at a stalemate as previously mentioned (a few times now).
Signature · 1 line
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 25 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Paul Moore
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 9 lines
Quoted 3 lines
I think you keep forgetting that you cannot unilaterally decide this. Both VFS and BPF people have told you that it does not make sense. What was clearly LSM specific code has been moved under
security/already.I'm charged with doing the Right Thing for the LSM framework, and in my opinion it is in the best interest of the LSM framework that the kfunc being proposed lives in
security/bpf_lsm_kfuncs.c, just as the VFS kfuncs live infs/bpf_fs_kfuncs.c.
I think the "Right Thing" would be caring about your users and the project moving forward, who want this functionality, and figuring out the best way to make it happen while working collaboratively with others. Life is full of tradeoffs.
Instead of dictating how others should bend over backwards to agree to your arbitrary rules on code organization, which they don't agree with.
Everyone you've pitched your idea on code organization to disagrees with you. Yet, you remain adamant that it's the only way forward.
Materially, both you and I know nothing of consequence would happen if the kfunc stays where it is.
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
Not only is that a disservice to your users, but also people who've reviewed code (apart from you), and more importantly the person who worked on this patch set for several months.
At least a month ago, you had the good sense of not dying over this hill.
Quoted 1 line
[...]
[email protected]
AI reviewRe: [PATCH v6 bpf-next 1/4] security: introduce struct lsm_xattrs
In reply to David WindsorThis isn't a bug, but could the changelog note the int -> unsigned int change of the xattr count, since that is not just a parameter consolidation?
Quoted 8 lines
In preparation for
bpf_init_inode_xattr(), a kfunc that lets bpf LSM programs atomically label new inodes, rework howinode_init_securityxattrs are managed.
inode_init_securityreceives the LSM xattr array and its count as separate parameters. For better compatibility with the bpf verifier, updateinode_init_securityand its callers to consolidate these parameters into a single context object: structlsm_xattrs.
This isn't a bug, but could the changelog note the int -> unsigned int change of the xattr count, since that is not just a parameter consolidation?
The xattr count changes from int xattr_count in security_inode_init_security() to unsigned int xattr_count in struct lsm_xattrs:
include/linux/security.h:
+struct lsm_xattrs {
+ struct xattr *xattrs;
+ unsigned int xattr_count;
+};
security/security.c:security_inode_init_security() {
- int ret = -EOPNOTSUPP, xattr_count = 0;
+ struct lsm_xattrs xattrs = {};
+ int ret = -EOPNOTSUPP;The cleanup loop changes accordingly:
- for (; xattr_count > 0; xattr_count--)
+ for (; xattrs.xattr_count > 0; xattrs.xattr_count--)
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/30592505811
Paul Moore
maintainerQuoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 22 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:
...
Quoted 3 lines
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
That's not a reasonble or truthful summary of things, I've only requested that David locate his proposed kfunc in security/bpf_lsm_kfuncs.c, I never suggested he move any others.
Signature · 1 line
paul-moore.com
[email protected]
AI reviewPaul Moore raised a concern about the location of this kfunc. As the LSM maintainer, he stated that this kfunc must be placed in security/bpf_lsm_kfuncs.c to be acceptable.
Quoted 22 lines
fs/bpf_fs_kfuncs.c +6
-0@@ -11,7 +11,9 @@#include <linux/file.h> #include <linux/kernfs.h> #include <linux/mm.h> +#include <linux/security.h> #include <linux/xattr.h> +#include <uapi/linux/lsm.h> __bpf_kfunc_start_defs ();@@ -379,6 +381,44 @@ __bpf_kfunc struct inode *bpf_real_data_inode(struct file *file)return d_real_inode (file_dentry (file)); } +/** +* bpf_init_inode_xattr - set an xattr on a new inode from inode_init_security +* @xattrs: inode_init_security xattr state from the hook context +* @name__str: xattr name (e.g., "bpf.file_label")
fs/bpf_fs_kfuncs.c __bpf_kfunc struct inode *bpf_real_data_inode(struct file *file) · line 397
Quoted 10 lines
fs/bpf_fs_kfuncs.c +10
-0+* @value_p: dynptr containing the xattr value +* +* Only callable from lsm/inode_init_security programs. +* +* Return: 0 on success, -EOPNOTSUPP if the filesystem does not accept +* xattrs at inode creation, negative error on other failures. +*/ +__bpf_kfunc int bpf_init_inode_xattr(struct lsm_xattrs *xattrs, +const char *name__str, +const struct bpf_dynptr *value_p)
Paul Moore raised a concern about the location of this kfunc. As the LSM maintainer, he stated that this kfunc must be placed in security/bpf_lsm_kfuncs.c to be acceptable.
In the v6 discussion, he explained: "The new LSM kfunc must go in security/bpf_lsm_kfuncs.c; if that isn't acceptable to the BPF developers then David will need to find a new way that doesn't involve kfuncs."
Kumar Kartikeya Dwivedi disagreed with this placement requirement, arguing that it should remain in fs/ with other kfuncs. This represents an unresolved maintainer disagreement.
Should this kfunc be moved to security/bpf_lsm_kfuncs.c as the LSM maintainer requested, or does this need further discussion between the BPF and LSM maintainers before merging?
Reference: https://lore.kernel.org/all/CAHC9VhTS7rSnBqg00ZxNkcZyh_=EeJmn_4z3CTCCxreEEDtTtg@mail.gmail.com/
Quoted 28 lines
fs/bpf_fs_kfuncs.c +24
-0+{ +struct bpf_dynptr_kern *value_ptr = (struct bpf_dynptr_kern *)value_p; +const void *value; +u32 value_len; + +if (!name__str) +return -EINVAL ; +if (strncmp (name__str,XATTR_BPF_LSM_SUFFIX , +sizeof (XATTR_BPF_LSM_SUFFIX ) -1 )) +return -EPERM ; + +if (!xattrs->xattrs) +return -EOPNOTSUPP ; + + value_len =__bpf_dynptr_size (value_ptr); + value =__bpf_dynptr_data (value_ptr, value_len); +if (!value) +return -EINVAL ; + +return security_lsmxattr_add (xattrs,LSM_ID_BPF , + name__str +sizeof (XATTR_BPF_LSM_SUFFIX ) -1 , + value, value_len); +} +__bpf_kfunc_end_defs ();BTF_KFUNCS_START (bpf_fs_kfunc_set_ids)
fs/bpf_fs_kfuncs.c BTF_ID_FLAGS(func, bpf_get_file_xattr, KF_SLEEPABLE) · line 434
Quoted 5 lines
fs/bpf_fs_kfuncs.c +1
-0@@ -390,6 +430,7 @@ BTF_ID_FLAGS(func, bpf_get_file_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_set_dentry_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_remove_dentry_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_real_data_inode, KF_SLEEPABLE | KF_RET_NULL) +BTF_ID_FLAGS(func, bpf_init_inode_xattr)BTF_KFUNCS_END (bpf_fs_kfunc_set_ids)
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/30592505811
Casey Schaufler
maintainerQuoted 33 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
Quoted 5 lines · Kumar Kartikeya Dwivedi
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 8 lines
Quoted 3 lines
I think you keep forgetting that you cannot unilaterally decide this. Both VFS and BPF people have told you that it does not make sense. What was clearly LSM specific code has been moved under
security/already.I'm charged with doing the Right Thing for the LSM framework, and in my opinion it is in the best interest of the LSM framework that the kfunc being proposed lives in
security/bpf_lsm_kfuncs.c, just as the VFS kfuncs live infs/bpf_fs_kfuncs.c.
Quoted 4 lines
I think the "Right Thing" would be caring about your users and the project moving forward, who want this functionality, and figuring out the best way to make it happen while working collaboratively with others. Life is full of tradeoffs.
It certainly is. Paul has taken a stance that supports the ongoing maintenance of the LSM subsystem. It does not have a stable API in support of the rapid development of Linux kernel features *outside of* the LSM infrastructure. That is, people like you. If LSM hook implementations were spread throughout the kernel code it would be much more difficult for poor hobbyist LSM developers like me to track them down when making changes. Changes like the ones you require. This is about being able to continue supporting the latest and greatest additions to the system. Like yours, io_uring and the network protocol d'jour.
Please don't lecture us on collaboration and trade-offs. We live and breath that.
Quoted 21 lines
Instead of dictating how others should bend over backwards to agree to your arbitrary rules on code organization, which they don't agree with.
Everyone you've pitched your idea on code organization to disagrees with you. Yet, you remain adamant that it's the only way forward.
Materially, both you and I know nothing of consequence would happen if the kfunc stays where it is.
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
Not only is that a disservice to your users, but also people who've reviewed code (apart from you), and more importantly the person who worked on this patch set for several months.
At least a month ago, you had the good sense of not dying over this hill.
Quoted 1 line
[...]
Kumar Kartikeya Dwivedi
maintainerQuoted 39 lines · Casey Schaufler
Quoted 33 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 8 lines
Quoted 3 lines
I think you keep forgetting that you cannot unilaterally decide this. Both VFS and BPF people have told you that it does not make sense. What was clearly LSM specific code has been moved under
security/already.I'm charged with doing the Right Thing for the LSM framework, and in my opinion it is in the best interest of the LSM framework that the kfunc being proposed lives in
security/bpf_lsm_kfuncs.c, just as the VFS kfuncs live infs/bpf_fs_kfuncs.c.Quoted 4 lines
I think the "Right Thing" would be caring about your users and the project moving forward, who want this functionality, and figuring out the best way to make it happen while working collaboratively with others. Life is full of tradeoffs.
Quoted 6 lines
It certainly is. Paul has taken a stance that supports the ongoing maintenance of the LSM subsystem. It does not have a stable API in support of the rapid development of Linux kernel features *outside of* the LSM infrastructure. That is, people like you. If LSM hook implementations were spread throughout the kernel code it would be much more difficult for poor hobbyist LSM developers like me to track them down when making changes. Changes like the ones you require.
I would recommend reading the patches before commenting. All LSM code is under security/ (patch 2), as it should be.
Quoted 3 lines
This is about being able to continue supporting the latest and greatest additions to the system. Like yours,
io_uringand the network protocol d'jour.
I don't know what you're on about.
Quoted 2 lines
Please don't lecture us on collaboration and trade-offs. We live and breath that.
Paul is free to take a stance for LSM code, just like the BPF maintainers get to decide on where BPF related code should live. I'm sure you know that.
Thus, please avoid justifying his overreach on where others maintainers should keep their code.
Casey Schaufler
maintainerQuoted 39 lines · Kumar Kartikeya Dwivedi
Quoted 38 lines · Casey Schaufler
Quoted 37 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
On Fri Jul 31, 2026 at 6:59 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 8 lines
Quoted 3 lines
I think you keep forgetting that you cannot unilaterally decide this. Both VFS and BPF people have told you that it does not make sense. What was clearly LSM specific code has been moved under
security/already.I'm charged with doing the Right Thing for the LSM framework, and in my opinion it is in the best interest of the LSM framework that the kfunc being proposed lives in
security/bpf_lsm_kfuncs.c, just as the VFS kfuncs live infs/bpf_fs_kfuncs.c.I think the "Right Thing" would be caring about your users and the project moving forward, who want this functionality, and figuring out the best way to make it happen while working collaboratively with others. Life is full of tradeoffs.
Quoted 8 lines
Quoted 6 lines
It certainly is. Paul has taken a stance that supports the ongoing maintenance of the LSM subsystem. It does not have a stable API in support of the rapid development of Linux kernel features *outside of* the LSM infrastructure. That is, people like you. If LSM hook implementations were spread throughout the kernel code it would be much more difficult for poor hobbyist LSM developers like me to track them down when making changes. Changes like the ones you require.
I would recommend reading the patches before commenting. All LSM code is under
security/(patch 2), as it should be.
Pa-lease. I have in fact read the patch. I disagree with you assessment.
Quoted 5 lines
Quoted 3 lines
This is about being able to continue supporting the latest and greatest additions to the system. Like yours,
io_uringand the network protocol d'jour.I don't know what you're on about.
Quoted 7 lines
Quoted 2 lines
Please don't lecture us on collaboration and trade-offs. We live and breath that.
Paul is free to take a stance for LSM code, just like the BPF maintainers get to decide on where BPF related code should live. I'm sure you know that.
Thus, please avoid justifying his overreach on where others maintainers should keep their code.
I have been developing kernel code since the 1970's (UNIX and Linux) and have a fair bit of understanding about source code organization. Without rational layering and co-location chaos ensues. The BPF developers are newbies relative to the security maintainers, and would do well to pay some attention to the wisdom of the aged.
Quoted 29 lines · Paul Moore
Quoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 22 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
Quoted 7 lines · Paul Moore
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 8 lines
Quoted 3 lines
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
That's not a reasonble or truthful summary of things, I've only requested that David locate his proposed kfunc in
security/bpf_lsm_kfuncs.c, I never suggested he move any others.
Looking at what's left of the kfunc itself, it's basically nothing. Everything meaningful has been moved into security/ already.
Aside from bpf dynptr ops, what's left is:
if (!name__str)
return -EINVAL;
if (strncmp(name__str, XATTR_BPF_LSM_SUFFIX, sizeof(XATTR_BPF_LSM_SUFFIX) - 1))
return -EPERM;
if (!xattrs->xattrs)
return -EOPNOTSUPP;
... then a call to security_lsmxattr_add. Why not move this chunk into security_lsmxattr_add, and leave the remaining bits, which are pure bpf, in fs/ for now, and litigate the total placement of all of them once v7 lands?
Quoted 2 lines
--
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 61 lines · Casey Schaufler
Quoted 39 lines · Kumar Kartikeya Dwivedi
Quoted 38 lines · Casey Schaufler
Quoted 37 lines · Kumar Kartikeya Dwivedi
Quoted 24 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
On Fri, Jul 31, 2026 at 2:18 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:59 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 8 lines
Quoted 3 lines
I think you keep forgetting that you cannot unilaterally decide this. Both VFS and BPF people have told you that it does not make sense. What was clearly LSM specific code has been moved under
security/already.I'm charged with doing the Right Thing for the LSM framework, and in my opinion it is in the best interest of the LSM framework that the kfunc being proposed lives in
security/bpf_lsm_kfuncs.c, just as the VFS kfuncs live infs/bpf_fs_kfuncs.c.I think the "Right Thing" would be caring about your users and the project moving forward, who want this functionality, and figuring out the best way to make it happen while working collaboratively with others. Life is full of tradeoffs.
Quoted 8 lines
Quoted 6 lines
It certainly is. Paul has taken a stance that supports the ongoing maintenance of the LSM subsystem. It does not have a stable API in support of the rapid development of Linux kernel features *outside of* the LSM infrastructure. That is, people like you. If LSM hook implementations were spread throughout the kernel code it would be much more difficult for poor hobbyist LSM developers like me to track them down when making changes. Changes like the ones you require.
I would recommend reading the patches before commenting. All LSM code is under
security/(patch 2), as it should be.Pa-lease. I have in fact read the patch. I disagree with you assessment.
Quoted 10 lines
Quoted 3 lines
This is about being able to continue supporting the latest and greatest additions to the system. Like yours,
io_uringand the network protocol d'jour.I don't know what you're on about.
Quoted 2 lines
Please don't lecture us on collaboration and trade-offs. We live and breath that.
Paul is free to take a stance for LSM code, just like the BPF maintainers get to decide on where BPF related code should live. I'm sure you know that.
Quoted 8 lines
Quoted 2 lines
Thus, please avoid justifying his overreach on where others maintainers should keep their code.
I have been developing kernel code since the 1970's (UNIX and Linux) and have a fair bit of understanding about source code organization. Without rational layering and co-location chaos ensues. The BPF developers are newbies relative to the security maintainers, and would do well to pay some attention to the wisdom of the aged.
I am certainly more inexperienced than you, granted. But I don't think we resolve issues by older people forcing their opinions on younger people.
We do that by providing sensibile rationale behind technical choices. I am constantly doing that and receiving unsubstantiated wisdom in response.
Common sense suggests related code (all xattr kfuncs) should stay together in one file. If they need moving, they should move together.
There is disagreement on where this file should be located between Paul and the BPF maintainers (even VFS maintainters), therefore Paul does not get to make a mess of our code.
Having one kfunc stay in one file (Paul's suggestion) while others are in another file is the worst option.
There is no layering violation, all LSM logic resides in the LSM subsystem, with clean APIs exported for use elsewhere. I am sure you don't consider BPF dynptr as LSM logic.
The hodge podge state you're arguing against is what Paul is suggesting.
Thanks
Kumar Kartikeya Dwivedi
maintainerQuoted 39 lines · David Windsor
Quoted 29 lines · Paul Moore
Quoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 22 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
On Fri Jul 31, 2026 at 6:59 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 8 lines
Quoted 3 lines
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
That's not a reasonble or truthful summary of things, I've only requested that David locate his proposed kfunc in
security/bpf_lsm_kfuncs.c, I never suggested he move any others.
Quoted 8 lines
Looking at what's left of the kfunc itself, it's basically nothing. Everything meaningful has been moved into
security/already.Aside from bpf dynptr ops, what's left is:
if (!name__str)
return -EINVAL;
You can actually lose this one, the verifier should prevent passing NULL for name__str. Other functions don't check it either. Feel free to check it, or add a negative test in case you're worried about it.
Quoted 11 lines
if (
strncmp(name__str, XATTR_BPF_LSM_SUFFIX, sizeof(XATTR_BPF_LSM_SUFFIX) - 1))return -EPERM;if (!xattrs->xattrs)
return -EOPNOTSUPP;... then a call to
security_lsmxattr_add. Why not move this chunk intosecurity_lsmxattr_add, and leave the remaining bits, which are pure bpf, infs/for now, and litigate the total placement of all of them once v7 lands?
I wouldn't bother, everything LSM specific is already where it belongs. That said, your question is a good demonstration of the absurdity of the ask here.
Quoted 2 lines
Quoted 2 lines
--
paul-moore.com
Kumar Kartikeya Dwivedi
maintainerQuoted 43 lines · Kumar Kartikeya Dwivedi
Quoted 42 lines · David Windsor
Quoted 29 lines · Paul Moore
Quoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 22 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
On Fri, Jul 31, 2026 at 2:18 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:59 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 8 lines
Quoted 3 lines
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
That's not a reasonble or truthful summary of things, I've only requested that David locate his proposed kfunc in
security/bpf_lsm_kfuncs.c, I never suggested he move any others.Looking at what's left of the kfunc itself, it's basically nothing. Everything meaningful has been moved into
security/already.
Quoted 8 lines
Quoted 5 lines
Aside from bpf dynptr ops, what's left is:
if (!name__str)
return -EINVAL;You can actually lose this one, the verifier should prevent passing NULL for
name__str. Other functions don't check it either. Feel free to check it, or add
.. and I meant, feel free to double check that passing NULL indeed fails just in case.
Quoted 19 lines
a negative test in case you're worried about it.
Quoted 11 lines
if (
strncmp(name__str, XATTR_BPF_LSM_SUFFIX, sizeof(XATTR_BPF_LSM_SUFFIX) - 1))return -EPERM;if (!xattrs->xattrs)
return -EOPNOTSUPP;... then a call to
security_lsmxattr_add. Why not move this chunk intosecurity_lsmxattr_add, and leave the remaining bits, which are pure bpf, infs/for now, and litigate the total placement of all of them once v7 lands?I wouldn't bother, everything LSM specific is already where it belongs. That said, your question is a good demonstration of the absurdity of the ask here.
Quoted 2 lines
Quoted 2 lines
--
paul-moore.com
Matt Bobrowski
maintainerYes, I've recently left Google. Unfortunatley I lost access to my [email protected] mail address before having a chance to update the relevant MAINTAINERS entry with my new mail address. Anyway, I've literally just sent a patch to the mailing list to address this.
Paul Moore
maintainerQuoted 48 lines · David Windsor
Quoted 28 lines · Paul Moore
Quoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 22 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
Quoted 8 lines · Kumar Kartikeya Dwivedi
On Fri Jul 31, 2026 at 6:59 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 7 lines
Quoted 3 lines
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
That's not a reasonble or truthful summary of things, I've only requested that David locate his proposed kfunc in
security/bpf_lsm_kfuncs.c, I never suggested he move any others.Looking at what's left of the kfunc itself, it's basically nothing. Everything meaningful has been moved into
security/already.Aside from bpf dynptr ops, what's left is:
if (!name__str)
return -EINVAL;if (
strncmp(name__str, XATTR_BPF_LSM_SUFFIX, sizeof(XATTR_BPF_LSM_SUFFIX) - 1))return -EPERM;
Quoted 7 lines
if (!xattrs->xattrs)
return -EOPNOTSUPP;... then a call to
security_lsmxattr_add. Why not move this chunk intosecurity_lsmxattr_add, and leave the remaining bits, which are pure bpf, infs/for now, and litigate the total placement of all of them once v7 lands?
Thanks David, but my comments and decision are based on the kfunc as a whole, not necessarily how the work is divided between the kfunc and the LSM hook it calls; shuffling bits of code between the two doesn't change the character of the function.
Signature · 1 line
paul-moore.com
Paul Moore
maintainerQuoted 57 lines · Paul Moore
Quoted 48 lines · David Windsor
Quoted 28 lines · Paul Moore
Quoted 23 lines · Kumar Kartikeya Dwivedi
Quoted 22 lines · Paul Moore
Quoted 20 lines · Kumar Kartikeya Dwivedi
Quoted 19 lines · Paul Moore
Quoted 17 lines · Kumar Kartikeya Dwivedi
Quoted 16 lines · Paul Moore
Quoted 14 lines · Kumar Kartikeya Dwivedi
Quoted 13 lines · Paul Moore
Quoted 11 lines · Kumar Kartikeya Dwivedi
Quoted 10 lines · Paul Moore
On Fri, Jul 31, 2026 at 2:18 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:59 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 12:32 PM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 6:02 PM CEST, Paul Moore wrote:
On Fri, Jul 31, 2026 at 11:44 AM Kumar Kartikeya Dwivedi
<[email protected]> wrote:
On Fri Jul 31, 2026 at 5:30 PM CEST, David Windsor wrote:
On Fri, Jul 31, 2026 at 11:17 AM Paul Moore <[email protected]> wrote:...
Quoted 7 lines
Quoted 3 lines
As a consequence, everyone suffers because they first need to satisfy your whims on how all code and kfuncs written thus far are wrong, and need to be moved around ASAP, including the one being proposed.
That's not a reasonble or truthful summary of things, I've only requested that David locate his proposed kfunc in
security/bpf_lsm_kfuncs.c, I never suggested he move any others.Looking at what's left of the kfunc itself, it's basically nothing. Everything meaningful has been moved into
security/already.Aside from bpf dynptr ops, what's left is:
if (!name__str)
return -EINVAL;if (
strncmp(name__str, XATTR_BPF_LSM_SUFFIX, sizeof(XATTR_BPF_LSM_SUFFIX) - 1))return -EPERM;Quoted 7 lines
if (!xattrs->xattrs)
return -EOPNOTSUPP;... then a call to
security_lsmxattr_add. Why not move this chunk intosecurity_lsmxattr_add, and leave the remaining bits, which are pure bpf, infs/for now, and litigate the total placement of all of them once v7 lands?
Quoted 4 lines
Thanks David, but my comments and decision are based on the kfunc as a whole, not necessarily how the work is divided between the kfunc and the LSM hook it calls; shuffling bits of code between the two doesn't change the character of the function.
To be clear, this means I would still need to see the proposed kfunc in security/bpf_lsm_kfuncs.c to be deemed acceptable. Also to be clear, I'm not suggesting, or even requiring, that you move any of the other existing kfuncs in your patchset; I never suggested that as a requirement for your work.
Signature · 1 line
paul-moore.com