AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/08/01 09:24 flow patch-triage
1m Args:
null

Results:
{
  "EnableConfigs": [
    "BPF_LSM",
    "SECURITY_SELINUX",
    "SECURITY_SMACK",
    "EVM",
    "BPF_SYSCALL",
    "BPF_JIT"
  ],
  "FocusSymbols": [
    "bpf_init_inode_xattr",
    "security_lsmxattr_add",
    "security_inode_init_security",
    "evm_inode_init_security"
  ],
  "Reasoning": "The patch introduces a new BPF kfunc `bpf_init_inode_xattr` that allows BPF LSM programs to set xattrs during inode creation. It also refactors `security_inode_init_security` to use a new `struct lsm_xattrs` and updates EVM, SELinux, and SMACK to use it. This is a functional change in the core security and BPF subsystems that should be fuzzed.",
  "WorthFuzzing": true
}

1/1 2026/08/01 09:24 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 9980131719c0513ff3b73b398251a713002044b8\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sat Aug 1 09:23:59 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c\nindex f1863a891db64..7b55073934e0b 100644\n--- a/fs/bpf_fs_kfuncs.c\n+++ b/fs/bpf_fs_kfuncs.c\n@@ -11,7 +11,9 @@\n #include \u003clinux/file.h\u003e\n #include \u003clinux/kernfs.h\u003e\n #include \u003clinux/mm.h\u003e\n+#include \u003clinux/security.h\u003e\n #include \u003clinux/xattr.h\u003e\n+#include \u003cuapi/linux/lsm.h\u003e\n \n __bpf_kfunc_start_defs();\n \n@@ -379,6 +381,44 @@ __bpf_kfunc struct inode *bpf_real_data_inode(struct file *file)\n \treturn d_real_inode(file_dentry(file));\n }\n \n+/**\n+ * bpf_init_inode_xattr - set an xattr on a new inode from inode_init_security\n+ * @xattrs: inode_init_security xattr state from the hook context\n+ * @name__str: xattr name (e.g., \"bpf.file_label\")\n+ * @value_p: dynptr containing the xattr value\n+ *\n+ * Only callable from lsm/inode_init_security programs.\n+ *\n+ * Return: 0 on success, -EOPNOTSUPP if the filesystem does not accept\n+ *         xattrs at inode creation, negative error on other failures.\n+ */\n+__bpf_kfunc int bpf_init_inode_xattr(struct lsm_xattrs *xattrs,\n+\t\t\t\t     const char *name__str,\n+\t\t\t\t     const struct bpf_dynptr *value_p)\n+{\n+\tstruct bpf_dynptr_kern *value_ptr = (struct bpf_dynptr_kern *)value_p;\n+\tconst void *value;\n+\tu32 value_len;\n+\n+\tif (!name__str)\n+\t\treturn -EINVAL;\n+\tif (strncmp(name__str, XATTR_BPF_LSM_SUFFIX,\n+\t\t    sizeof(XATTR_BPF_LSM_SUFFIX) - 1))\n+\t\treturn -EPERM;\n+\n+\tif (!xattrs-\u003exattrs)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tvalue_len = __bpf_dynptr_size(value_ptr);\n+\tvalue = __bpf_dynptr_data(value_ptr, value_len);\n+\tif (!value)\n+\t\treturn -EINVAL;\n+\n+\treturn security_lsmxattr_add(xattrs, LSM_ID_BPF,\n+\t\t\t\t     name__str + sizeof(XATTR_BPF_LSM_SUFFIX) - 1,\n+\t\t\t\t     value, value_len);\n+}\n+\n __bpf_kfunc_end_defs();\n \n BTF_KFUNCS_START(bpf_fs_kfunc_set_ids)\n@@ -390,6 +430,7 @@ BTF_ID_FLAGS(func, bpf_get_file_xattr, KF_SLEEPABLE)\n BTF_ID_FLAGS(func, bpf_set_dentry_xattr, KF_SLEEPABLE)\n BTF_ID_FLAGS(func, bpf_remove_dentry_xattr, KF_SLEEPABLE)\n BTF_ID_FLAGS(func, bpf_real_data_inode, KF_SLEEPABLE | KF_RET_NULL)\n+BTF_ID_FLAGS(func, bpf_init_inode_xattr)\n BTF_KFUNCS_END(bpf_fs_kfunc_set_ids)\n \n static int bpf_fs_kfuncs_filter(const struct bpf_prog *prog, u32 kfunc_id)\ndiff --git a/include/linux/bpf_lsm.h b/include/linux/bpf_lsm.h\nindex dda272d78f013..4bf350ef02f48 100644\n--- a/include/linux/bpf_lsm.h\n+++ b/include/linux/bpf_lsm.h\n@@ -12,6 +12,9 @@\n #include \u003clinux/bpf_verifier.h\u003e\n #include \u003clinux/lsm_hooks.h\u003e\n \n+/* max bpf xattrs per inode */\n+#define BPF_LSM_INODE_INIT_XATTRS 4\n+\n #ifdef CONFIG_BPF_LSM\n \n extern bool bpf_lsm_initialized __ro_after_init;\ndiff --git a/include/linux/evm.h b/include/linux/evm.h\nindex 913f4573b2038..528f360f3308d 100644\n--- a/include/linux/evm.h\n+++ b/include/linux/evm.h\n@@ -12,6 +12,8 @@\n #include \u003clinux/integrity.h\u003e\n #include \u003clinux/xattr.h\u003e\n \n+struct lsm_xattrs;\n+\n #ifdef CONFIG_EVM\n extern int evm_set_key(void *key, size_t keylen);\n extern enum integrity_status evm_verifyxattr(struct dentry *dentry,\n@@ -21,8 +23,8 @@ extern enum integrity_status evm_verifyxattr(struct dentry *dentry,\n int evm_fix_hmac(struct dentry *dentry, const char *xattr_name,\n \t\t const char *xattr_value, size_t xattr_value_len);\n int evm_inode_init_security(struct inode *inode, struct inode *dir,\n-\t\t\t    const struct qstr *qstr, struct xattr *xattrs,\n-\t\t\t    int *xattr_count);\n+\t\t\t    const struct qstr *qstr,\n+\t\t\t    struct lsm_xattrs *xattrs);\n extern bool evm_revalidate_status(const char *xattr_name);\n extern int evm_protected_xattr_if_enabled(const char *req_xattr_name);\n extern int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer,\n@@ -63,8 +65,7 @@ static inline int evm_fix_hmac(struct dentry *dentry, const char *xattr_name,\n \n static inline int evm_inode_init_security(struct inode *inode, struct inode *dir,\n \t\t\t\t\t  const struct qstr *qstr,\n-\t\t\t\t\t  struct xattr *xattrs,\n-\t\t\t\t\t  int *xattr_count)\n+\t\t\t\t\t  struct lsm_xattrs *xattrs)\n {\n \treturn 0;\n }\ndiff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h\nindex 65c9609ec2077..5b2de7865ce81 100644\n--- a/include/linux/lsm_hook_defs.h\n+++ b/include/linux/lsm_hook_defs.h\n@@ -116,8 +116,8 @@ LSM_HOOK(int, 0, inode_alloc_security, struct inode *inode)\n LSM_HOOK(void, LSM_RET_VOID, inode_free_security, struct inode *inode)\n LSM_HOOK(void, LSM_RET_VOID, inode_free_security_rcu, void *inode_security)\n LSM_HOOK(int, -EOPNOTSUPP, inode_init_security, struct inode *inode,\n-\t struct inode *dir, const struct qstr *qstr, struct xattr *xattrs,\n-\t int *xattr_count)\n+\t struct inode *dir, const struct qstr *qstr,\n+\t struct lsm_xattrs *xattrs)\n LSM_HOOK(int, 0, inode_init_security_anon, struct inode *inode,\n \t const struct qstr *name, const struct inode *context_inode)\n LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry,\ndiff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h\nindex b4f8cad53ddb0..7afe06a8d4c6c 100644\n--- a/include/linux/lsm_hooks.h\n+++ b/include/linux/lsm_hooks.h\n@@ -200,20 +200,18 @@ extern struct lsm_static_calls_table static_calls_table __ro_after_init;\n \n /**\n  * lsm_get_xattr_slot - Return the next available slot and increment the index\n- * @xattrs: array storing LSM-provided xattrs\n- * @xattr_count: number of already stored xattrs (updated)\n+ * @ctx: xattr state shared by inode_init_security hooks\n  *\n- * Retrieve the first available slot in the @xattrs array to fill with an xattr,\n- * and increment @xattr_count.\n+ * Retrieve the first available slot in the @ctx-\u003exattrs array to fill with an\n+ * xattr, and increment @ctx-\u003exattr_count.\n  *\n- * Return: The slot to fill in @xattrs if non-NULL, NULL otherwise.\n+ * Return: The slot to fill in @ctx-\u003exattrs if non-NULL, NULL otherwise.\n  */\n-static inline struct xattr *lsm_get_xattr_slot(struct xattr *xattrs,\n-\t\t\t\t\t       int *xattr_count)\n+static inline struct xattr *lsm_get_xattr_slot(struct lsm_xattrs *ctx)\n {\n-\tif (unlikely(!xattrs))\n+\tif (unlikely(!ctx || !ctx-\u003exattrs))\n \t\treturn NULL;\n-\treturn \u0026xattrs[(*xattr_count)++];\n+\treturn \u0026ctx-\u003exattrs[ctx-\u003exattr_count++];\n }\n \n #endif /* ! __LINUX_LSM_HOOKS_H */\ndiff --git a/include/linux/security.h b/include/linux/security.h\nindex 153e9043058f8..d35fde7aa11f0 100644\n--- a/include/linux/security.h\n+++ b/include/linux/security.h\n@@ -68,6 +68,11 @@ struct watch;\n struct watch_notification;\n struct lsm_ctx;\n \n+struct lsm_xattrs {\n+\tstruct xattr *xattrs;\n+\tunsigned int xattr_count;\n+};\n+\n /* Default (no) options for the capable function */\n #define CAP_OPT_NONE 0x0\n /* If capable should audit the security request */\n@@ -401,6 +406,9 @@ void security_inode_free(struct inode *inode);\n int security_inode_init_security(struct inode *inode, struct inode *dir,\n \t\t\t\t const struct qstr *qstr,\n \t\t\t\t initxattrs initxattrs, void *fs_data);\n+int security_lsmxattr_add(struct lsm_xattrs *xattrs, u64 lsm_id,\n+\t\t\t  const char *name_extra, const void *value,\n+\t\t\t  size_t value_len);\n int security_inode_init_security_anon(struct inode *inode,\n \t\t\t\t      const struct qstr *name,\n \t\t\t\t      const struct inode *context_inode);\n@@ -895,6 +903,13 @@ static inline int security_inode_init_security(struct inode *inode,\n \treturn 0;\n }\n \n+static inline int security_lsmxattr_add(struct lsm_xattrs *xattrs, u64 lsm_id,\n+\t\t\t\t\tconst char *name_extra,\n+\t\t\t\t\tconst void *value, size_t value_len)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n static inline int security_inode_init_security_anon(struct inode *inode,\n \t\t\t\t\t\t    const struct qstr *name,\n \t\t\t\t\t\t    const struct inode *context_inode)\ndiff --git a/security/bpf/hooks.c b/security/bpf/hooks.c\nindex 7b98f5d1e2be8..8f8c3de3035f0 100644\n--- a/security/bpf/hooks.c\n+++ b/security/bpf/hooks.c\n@@ -33,6 +33,7 @@ static int __init bpf_lsm_init(void)\n \n struct lsm_blob_sizes bpf_lsm_blob_sizes __ro_after_init = {\n \t.lbs_inode = sizeof(struct bpf_storage_blob),\n+\t.lbs_xattr_count = BPF_LSM_INODE_INIT_XATTRS,\n };\n \n DEFINE_LSM(bpf) = {\ndiff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c\nindex b59e3f121b8a8..b7158fc63543e 100644\n--- a/security/integrity/evm/evm_main.c\n+++ b/security/integrity/evm/evm_main.c\n@@ -1062,14 +1062,16 @@ static int evm_inode_copy_up_xattr(struct dentry *src, const char *name)\n  * evm_inode_init_security - initializes security.evm HMAC value\n  */\n int evm_inode_init_security(struct inode *inode, struct inode *dir,\n-\t\t\t    const struct qstr *qstr, struct xattr *xattrs,\n-\t\t\t    int *xattr_count)\n+\t\t\t    const struct qstr *qstr,\n+\t\t\t    struct lsm_xattrs *lsm_xattrs)\n {\n \tstruct evm_xattr *xattr_data;\n \tstruct xattr *xattr, *evm_xattr;\n+\tstruct xattr *xattrs;\n \tbool evm_protected_xattrs = false;\n \tint rc;\n \n+\txattrs = lsm_xattrs ? lsm_xattrs-\u003exattrs : NULL;\n \tif (!(evm_initialized \u0026 EVM_INIT_HMAC) || !xattrs)\n \t\treturn 0;\n \n@@ -1087,7 +1089,7 @@ int evm_inode_init_security(struct inode *inode, struct inode *dir,\n \tif (!evm_protected_xattrs)\n \t\treturn 0;\n \n-\tevm_xattr = lsm_get_xattr_slot(xattrs, xattr_count);\n+\tevm_xattr = lsm_get_xattr_slot(lsm_xattrs);\n \t/*\n \t * Array terminator (xattr name = NULL) must be the first non-filled\n \t * xattr slot.\ndiff --git a/security/security.c b/security/security.c\nindex 71aea8fdf0142..ae72102cd29b8 100644\n--- a/security/security.c\n+++ b/security/security.c\n@@ -12,6 +12,7 @@\n #define pr_fmt(fmt) \"LSM: \" fmt\n \n #include \u003clinux/bpf.h\u003e\n+#include \u003clinux/bpf_lsm.h\u003e\n #include \u003clinux/capability.h\u003e\n #include \u003clinux/dcache.h\u003e\n #include \u003clinux/export.h\u003e\n@@ -1333,8 +1334,8 @@ int security_inode_init_security(struct inode *inode, struct inode *dir,\n \t\t\t\t const initxattrs initxattrs, void *fs_data)\n {\n \tstruct lsm_static_call *scall;\n-\tstruct xattr *new_xattrs = NULL;\n-\tint ret = -EOPNOTSUPP, xattr_count = 0;\n+\tstruct lsm_xattrs xattrs = {};\n+\tint ret = -EOPNOTSUPP;\n \n \tif (unlikely(IS_PRIVATE(inode)))\n \t\treturn 0;\n@@ -1344,15 +1345,15 @@ int security_inode_init_security(struct inode *inode, struct inode *dir,\n \n \tif (initxattrs) {\n \t\t/* Allocate +1 as terminator. */\n-\t\tnew_xattrs = kcalloc(blob_sizes.lbs_xattr_count + 1,\n-\t\t\t\t     sizeof(*new_xattrs), GFP_NOFS);\n-\t\tif (!new_xattrs)\n+\t\txattrs.xattrs = kcalloc(blob_sizes.lbs_xattr_count + 1,\n+\t\t\t\t\tsizeof(*xattrs.xattrs), GFP_NOFS);\n+\t\tif (!xattrs.xattrs)\n \t\t\treturn -ENOMEM;\n \t}\n \n \tlsm_for_each_hook(scall, inode_init_security) {\n-\t\tret = scall-\u003ehl-\u003ehook.inode_init_security(inode, dir, qstr, new_xattrs,\n-\t\t\t\t\t\t  \u0026xattr_count);\n+\t\tret = scall-\u003ehl-\u003ehook.inode_init_security(inode, dir, qstr,\n+\t\t\t\t\t\t\t  \u0026xattrs);\n \t\tif (ret \u0026\u0026 ret != -EOPNOTSUPP)\n \t\t\tgoto out;\n \t\t/*\n@@ -1364,18 +1365,113 @@ int security_inode_init_security(struct inode *inode, struct inode *dir,\n \t}\n \n \t/* If initxattrs() is NULL, xattr_count is zero, skip the call. */\n-\tif (!xattr_count)\n+\tif (!xattrs.xattr_count)\n \t\tgoto out;\n \n-\tret = initxattrs(inode, new_xattrs, fs_data);\n+\tret = initxattrs(inode, xattrs.xattrs, fs_data);\n out:\n-\tfor (; xattr_count \u003e 0; xattr_count--)\n-\t\tkfree(new_xattrs[xattr_count - 1].value);\n-\tkfree(new_xattrs);\n+\tfor (; xattrs.xattr_count \u003e 0; xattrs.xattr_count--)\n+\t\tkfree(xattrs.xattrs[xattrs.xattr_count - 1].value);\n+\tkfree(xattrs.xattrs);\n \treturn (ret == -EOPNOTSUPP) ? 0 : ret;\n }\n EXPORT_SYMBOL(security_inode_init_security);\n \n+static unsigned int lsm_xattrs_used(const struct lsm_xattrs *xattrs,\n+\t\t\t\t    const char *prefix)\n+{\n+\tsize_t prefix_len = strlen(prefix);\n+\tunsigned int i, n = 0;\n+\n+\tfor (i = 0; i \u003c xattrs-\u003exattr_count; i++) {\n+\t\tconst char *name = xattrs-\u003exattrs[i].name;\n+\n+\t\tif (name \u0026\u0026 !strncmp(name, prefix, prefix_len))\n+\t\t\tn++;\n+\t}\n+\treturn n;\n+}\n+\n+/**\n+ * security_lsmxattr_add() - Add an xattr during inode_init_security\n+ * @xattrs: xattr state shared by inode_init_security hooks\n+ * @lsm_id: LSM_ID_* value identifying the calling LSM\n+ * @name_extra: xattr name components beyond the calling LSM's standard\n+ *              xattr suffix, NULL if the standard suffix is the full name\n+ * @value: xattr value\n+ * @value_len: length of @value\n+ *\n+ * Claim an xattr slot in @xattrs on behalf of the LSM identified by\n+ * @lsm_id and fill it with a copy of @value. The xattr name is built from\n+ * the standard xattr suffix of the calling LSM, followed by @name_extra.\n+ * Callers can invoke this function from non-sleepable context.\n+ *\n+ * Return: Returns 0 on success or if the filesystem does not accept xattrs\n+ *         at inode creation, -ENOSPC if the calling LSM's slot budget is\n+ *         exhausted, negative values on other errors.\n+ */\n+int security_lsmxattr_add(struct lsm_xattrs *xattrs, u64 lsm_id,\n+\t\t\t  const char *name_extra, const void *value,\n+\t\t\t  size_t value_len)\n+{\n+\tstruct xattr *xattr;\n+\tvoid *xattr_value;\n+\tconst char *suffix;\n+\tsize_t suffix_len, extra_len, name_len;\n+\n+\tif (!xattrs || !value)\n+\t\treturn -EINVAL;\n+\n+\t/* The filesystem did not provide an initxattrs callback. */\n+\tif (!xattrs-\u003exattrs)\n+\t\treturn 0;\n+\n+\tswitch (lsm_id) {\n+\tcase LSM_ID_BPF:\n+\t\tif (!name_extra || !name_extra[0])\n+\t\t\treturn -EINVAL;\n+\t\tsuffix = XATTR_BPF_LSM_SUFFIX;\n+\t\tif (lsm_xattrs_used(xattrs, XATTR_BPF_LSM_SUFFIX) \u003e=\n+\t\t    BPF_LSM_INODE_INIT_XATTRS)\n+\t\t\treturn -ENOSPC;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tsuffix_len = strlen(suffix);\n+\textra_len = name_extra ? strlen(name_extra) : 0;\n+\tname_len = suffix_len + extra_len;\n+\tif (name_len \u003e XATTR_NAME_MAX)\n+\t\treturn -EINVAL;\n+\tif (value_len == 0 || value_len \u003e XATTR_SIZE_MAX)\n+\t\treturn -EINVAL;\n+\n+\t/* Combine xattr value + name into one allocation. */\n+\txattr_value = kmalloc(value_len + name_len + 1, GFP_NOWAIT);\n+\tif (!xattr_value)\n+\t\treturn -ENOMEM;\n+\n+\tmemcpy(xattr_value, value, value_len);\n+\tmemcpy(xattr_value + value_len, suffix, suffix_len);\n+\tif (extra_len)\n+\t\tmemcpy(xattr_value + value_len + suffix_len, name_extra,\n+\t\t       extra_len);\n+\t((char *)xattr_value)[value_len + name_len] = '\\0';\n+\n+\txattr = lsm_get_xattr_slot(xattrs);\n+\tif (!xattr) {\n+\t\tkfree(xattr_value);\n+\t\treturn -ENOSPC;\n+\t}\n+\n+\txattr-\u003evalue = xattr_value;\n+\txattr-\u003ename = (const char *)xattr_value + value_len;\n+\txattr-\u003evalue_len = value_len;\n+\n+\treturn 0;\n+}\n+\n /**\n  * security_inode_init_security_anon() - Initialize an anonymous inode\n  * @inode: the inode\ndiff --git a/security/selinux/hooks.c b/security/selinux/hooks.c\nindex 8d6945edae7aa..21544c775c176 100644\n--- a/security/selinux/hooks.c\n+++ b/security/selinux/hooks.c\n@@ -2962,7 +2962,7 @@ static int selinux_dentry_create_files_as(struct dentry *dentry, int mode,\n \n static int selinux_inode_init_security(struct inode *inode, struct inode *dir,\n \t\t\t\t       const struct qstr *qstr,\n-\t\t\t\t       struct xattr *xattrs, int *xattr_count)\n+\t\t\t\t       struct lsm_xattrs *xattrs)\n {\n \tconst struct cred_security_struct *crsec = selinux_cred(current_cred());\n \tstruct superblock_security_struct *sbsec;\n@@ -2992,7 +2992,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,\n \t    !(sbsec-\u003eflags \u0026 SBLABEL_MNT))\n \t\treturn -EOPNOTSUPP;\n \n-\txattr = lsm_get_xattr_slot(xattrs, xattr_count);\n+\txattr = lsm_get_xattr_slot(xattrs);\n \tif (xattr) {\n \t\trc = security_sid_to_context_force(newsid,\n \t\t\t\t\t\t   \u0026context, \u0026clen);\ndiff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c\nindex ff115068c5c06..4501078430ca0 100644\n--- a/security/smack/smack_lsm.c\n+++ b/security/smack/smack_lsm.c\n@@ -981,10 +981,10 @@ smk_rule_transmutes(struct smack_known *subject,\n }\n \n static int\n-xattr_dupval(struct xattr *xattrs, int *xattr_count,\n+xattr_dupval(struct lsm_xattrs *xattrs,\n \t     const char *name, const void *value, unsigned int vallen)\n {\n-\tstruct xattr * const xattr = lsm_get_xattr_slot(xattrs, xattr_count);\n+\tstruct xattr * const xattr = lsm_get_xattr_slot(xattrs);\n \n \tif (!xattr)\n \t\treturn 0;\n@@ -1003,14 +1003,13 @@ xattr_dupval(struct xattr *xattrs, int *xattr_count,\n  * @inode: the newly created inode\n  * @dir: containing directory object\n  * @qstr: unused\n- * @xattrs: where to put the attributes\n- * @xattr_count: current number of LSM-provided xattrs (updated)\n+ * @xattrs: where to put attributes and update count\n  *\n  * Returns 0 if it all works out, -ENOMEM if there's no memory\n  */\n static int smack_inode_init_security(struct inode *inode, struct inode *dir,\n \t\t\t\t     const struct qstr *qstr,\n-\t\t\t\t     struct xattr *xattrs, int *xattr_count)\n+\t\t\t\t     struct lsm_xattrs *xattrs)\n {\n \tstruct task_smack *tsp = smack_cred(current_cred());\n \tstruct inode_smack * const issp = smack_inode(inode);\n@@ -1057,21 +1056,19 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,\n \t\tif (S_ISDIR(inode-\u003ei_mode)) {\n \t\t\ttransflag = SMK_INODE_TRANSMUTE;\n \n-\t\t\tif (xattr_dupval(xattrs, xattr_count,\n-\t\t\t\tXATTR_SMACK_TRANSMUTE,\n-\t\t\t\tTRANS_TRUE,\n-\t\t\t\tTRANS_TRUE_SIZE\n-\t\t\t))\n+\t\t\tif (xattr_dupval(xattrs,\n+\t\t\t\t\t XATTR_SMACK_TRANSMUTE,\n+\t\t\t\t\t TRANS_TRUE,\n+\t\t\t\t\t TRANS_TRUE_SIZE))\n \t\t\t\trc = -ENOMEM;\n \t\t}\n \t}\n \n \tif (rc == 0)\n-\t\tif (xattr_dupval(xattrs, xattr_count,\n-\t\t\t    XATTR_SMACK_SUFFIX,\n-\t\t\t    issp-\u003esmk_inode-\u003esmk_known,\n-\t\t     strlen(issp-\u003esmk_inode-\u003esmk_known)\n-\t\t))\n+\t\tif (xattr_dupval(xattrs,\n+\t\t\t\t XATTR_SMACK_SUFFIX,\n+\t\t\t\t issp-\u003esmk_inode-\u003esmk_known,\n+\t\t\t\t strlen(issp-\u003esmk_inode-\u003esmk_known)))\n \t\t\trc = -ENOMEM;\n instant_inode:\n \tissp-\u003esmk_flags |= (SMK_INODE_INSTANT | transflag);\ndiff --git a/tools/testing/selftests/bpf/bpf_kfuncs.h b/tools/testing/selftests/bpf/bpf_kfuncs.h\nindex ae71e9b690518..2639f9f941955 100644\n--- a/tools/testing/selftests/bpf/bpf_kfuncs.h\n+++ b/tools/testing/selftests/bpf/bpf_kfuncs.h\n@@ -92,4 +92,9 @@ extern int bpf_set_dentry_xattr(struct dentry *dentry, const char *name__str,\n \t\t\t\tconst struct bpf_dynptr *value_p, int flags) __ksym __weak;\n extern int bpf_remove_dentry_xattr(struct dentry *dentry, const char *name__str) __ksym __weak;\n \n+struct lsm_xattrs;\n+extern int bpf_init_inode_xattr(struct lsm_xattrs *xattrs,\n+\t\t\t\tconst char *name__str,\n+\t\t\t\tconst struct bpf_dynptr *value_p) __ksym __weak;\n+\n #endif\ndiff --git a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c\nindex 43a26ec69a8e3..b208522dbd33d 100644\n--- a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c\n+++ b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c\n@@ -10,6 +10,7 @@\n #include \"test_get_xattr.skel.h\"\n #include \"test_set_remove_xattr.skel.h\"\n #include \"test_fsverity.skel.h\"\n+#include \"test_init_inode_xattr.skel.h\"\n \n static const char testfile[] = \"/tmp/test_progs_fs_kfuncs\";\n \n@@ -268,6 +269,155 @@ static void test_fsverity(void)\n \tremove(testfile);\n }\n \n+static void test_init_inode_xattr(void)\n+{\n+\tstruct test_init_inode_xattr *skel = NULL;\n+\tint fd = -1, err;\n+\tchar value_out[64];\n+\n+\t/* This test must be run from a fs that calls\n+\t * security_inode_init_security().\n+\t */\n+\tconst char *testfile_new = \"/dev/shm/test_progs_fs_kfuncs_new\";\n+\n+\tskel = test_init_inode_xattr__open_and_load();\n+\tif (!ASSERT_OK_PTR(skel, \"test_init_inode_xattr__open_and_load\"))\n+\t\treturn;\n+\n+\tskel-\u003ebss-\u003emonitored_pid = getpid();\n+\terr = test_init_inode_xattr__attach(skel);\n+\tif (!ASSERT_OK(err, \"test_init_inode_xattr__attach\"))\n+\t\tgoto out;\n+\n+\t/* Trigger inode_init_security */\n+\tfd = open(testfile_new, O_CREAT | O_RDWR, 0644);\n+\tif (!ASSERT_GE(fd, 0, \"create_file\"))\n+\t\tgoto out;\n+\n+\t/*\n+\t * Probably should not be needed as we will be labeling a file\n+\t * in /dev/shm, but just in case we check if the hook was actually\n+\t * called.\n+\t */\n+\tif (!skel-\u003ebss-\u003ehook_ran) {\n+\t\tprintf(\"%s:SKIP:inode_init_security hook was not invoked\\n\",\n+\t\t       __func__);\n+\t\ttest__skip();\n+\t\tgoto out;\n+\t}\n+\n+\t/* The filesystem does not accept xattrs at inode creation. */\n+\tif (skel-\u003edata-\u003einit_result == -EOPNOTSUPP) {\n+\t\tprintf(\"%s:SKIP:filesystem does not support LSM init xattrs\\n\",\n+\t\t       __func__);\n+\t\ttest__skip();\n+\t\tgoto out;\n+\t}\n+\n+\tASSERT_EQ(skel-\u003edata-\u003einit_result, 0, \"init_result\");\n+\n+\t/* initxattrs prepends \"security.\" to the name. */\n+\terr = getxattr(testfile_new, \"security.bpf.test_label\", value_out,\n+\t\t       sizeof(value_out));\n+\tif (err \u003c 0 \u0026\u0026 errno == ENODATA) {\n+\t\tprintf(\"%s:SKIP:filesystem did not apply LSM xattrs\\n\",\n+\t\t       __func__);\n+\t\ttest__skip();\n+\t\tgoto out;\n+\t}\n+\tif (!ASSERT_GE(err, 0, \"getxattr\"))\n+\t\tgoto out;\n+\n+\tASSERT_EQ(err, (int)sizeof(skel-\u003edata-\u003exattr_value), \"xattr_size\");\n+\tASSERT_EQ(strncmp(value_out, \"unconfined_u:object_r:user_home_t:s0\",\n+\t\t\t  sizeof(\"unconfined_u:object_r:user_home_t:s0\")), 0,\n+\t\t  \"xattr_value\");\n+\n+out:\n+\tclose(fd);\n+\ttest_init_inode_xattr__destroy(skel);\n+\tremove(testfile_new);\n+}\n+\n+/* Keep in sync with BPF_LSM_INODE_INIT_XATTRS in include/linux/bpf_lsm.h. */\n+#define INIT_INODE_XATTR_MAX 4\n+\n+/*\n+ * Programs may attach to inode_init_security without an attach-time limit, but\n+ * the kfunc only lets BPF claim INIT_INODE_XATTR_MAX xattr slots per inode.\n+ * Calls beyond that budget are rejected at runtime with -ENOSPC.\n+ */\n+static void test_init_inode_xattr_slot_limit(void)\n+{\n+\tstruct test_init_inode_xattr *skel[INIT_INODE_XATTR_MAX + 1] = {};\n+\tstruct bpf_link *link[INIT_INODE_XATTR_MAX + 1] = {};\n+\tconst char *testfile_slot = \"/dev/shm/test_progs_fs_kfuncs_slot\";\n+\tint ok = 0, nospc = 0, notrun = 0, other = 0;\n+\tint i, fd = -1;\n+\n+\t/* All programs attach successfully; there is no attach-time cap. */\n+\tfor (i = 0; i \u003c= INIT_INODE_XATTR_MAX; i++) {\n+\t\tskel[i] = test_init_inode_xattr__open();\n+\t\tif (!ASSERT_OK_PTR(skel[i], \"open\"))\n+\t\t\tgoto out;\n+\n+\t\tsnprintf(skel[i]-\u003erodata-\u003exattr_name,\n+\t\t\t sizeof(skel[i]-\u003erodata-\u003exattr_name), \"bpf.label_%d\",\n+\t\t\t i);\n+\n+\t\tif (!ASSERT_OK(test_init_inode_xattr__load(skel[i]), \"load\"))\n+\t\t\tgoto out;\n+\n+\t\tskel[i]-\u003ebss-\u003emonitored_pid = getpid();\n+\n+\t\tlink[i] = bpf_program__attach_lsm(skel[i]-\u003eprogs.test_init_inode_xattr);\n+\t\tif (!ASSERT_OK_PTR(link[i], \"attach\"))\n+\t\t\tgoto out;\n+\t}\n+\n+\t/* Trigger inode_init_security once with all programs attached. */\n+\tfd = open(testfile_slot, O_CREAT | O_RDWR, 0644);\n+\tif (!ASSERT_GE(fd, 0, \"create_file\"))\n+\t\tgoto out;\n+\n+\t/*\n+\t * Exactly INIT_INODE_XATTR_MAX programs claim a slot; test\n+\t * xattr budget accounting with -ENOSPC.\n+\t */\n+\tfor (i = 0; i \u003c= INIT_INODE_XATTR_MAX; i++) {\n+\t\tint res = skel[i]-\u003edata-\u003einit_result;\n+\n+\t\tif (!skel[i]-\u003ebss-\u003ehook_ran || res == -EOPNOTSUPP)\n+\t\t\tnotrun++;\n+\t\telse if (res == 0)\n+\t\t\tok++;\n+\t\telse if (res == -ENOSPC)\n+\t\t\tnospc++;\n+\t\telse\n+\t\t\tother++;\n+\t}\n+\n+\tif (notrun == INIT_INODE_XATTR_MAX + 1) {\n+\t\tprintf(\"%s:SKIP:hook not invoked or fs lacks LSM init xattrs\\n\",\n+\t\t       __func__);\n+\t\ttest__skip();\n+\t\tgoto out;\n+\t}\n+\n+\tASSERT_EQ(ok, INIT_INODE_XATTR_MAX, \"slots_within_budget\");\n+\tASSERT_EQ(nospc, 1, \"slot_over_budget\");\n+\tASSERT_EQ(other, 0, \"unexpected_result\");\n+\n+out:\n+\tif (fd \u003e= 0)\n+\t\tclose(fd);\n+\tfor (i = 0; i \u003c= INIT_INODE_XATTR_MAX; i++) {\n+\t\tbpf_link__destroy(link[i]);\n+\t\ttest_init_inode_xattr__destroy(skel[i]);\n+\t}\n+\tremove(testfile_slot);\n+}\n+\n void test_fs_kfuncs(void)\n {\n \t/* Matches xattr_names in progs/test_get_xattr.c */\n@@ -288,4 +438,10 @@ void test_fs_kfuncs(void)\n \n \tif (test__start_subtest(\"fsverity\"))\n \t\ttest_fsverity();\n+\n+\tif (test__start_subtest(\"init_inode_xattr\"))\n+\t\ttest_init_inode_xattr();\n+\n+\tif (test__start_subtest(\"init_inode_xattr_slot_limit\"))\n+\t\ttest_init_inode_xattr_slot_limit();\n }\ndiff --git a/tools/testing/selftests/bpf/progs/test_init_inode_xattr.c b/tools/testing/selftests/bpf/progs/test_init_inode_xattr.c\nnew file mode 100644\nindex 0000000000000..ce3d8d39de9ca\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/progs/test_init_inode_xattr.c\n@@ -0,0 +1,33 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright (c) 2026 Cisco Systems, Inc. */\n+\n+#include \"vmlinux.h\"\n+#include \u003cbpf/bpf_tracing.h\u003e\n+#include \"bpf_kfuncs.h\"\n+\n+char _license[] SEC(\"license\") = \"GPL\";\n+\n+__u32 monitored_pid;\n+int hook_ran;\n+int init_result = -1;\n+\n+const char xattr_name[16] = \"bpf.test_label\";\n+char xattr_value[] = \"unconfined_u:object_r:user_home_t:s0\";\n+\n+SEC(\"lsm/inode_init_security\")\n+int BPF_PROG(test_init_inode_xattr, struct inode *inode, struct inode *dir,\n+\t     const struct qstr *qstr, struct lsm_xattrs *xattrs)\n+{\n+\tstruct bpf_dynptr value_ptr;\n+\t__u32 pid;\n+\n+\tpid = bpf_get_current_pid_tgid() \u003e\u003e 32;\n+\tif (pid != monitored_pid)\n+\t\treturn 0;\n+\n+\thook_ran = 1;\n+\tbpf_dynptr_from_mem(xattr_value, sizeof(xattr_value), 0, \u0026value_ptr);\n+\tinit_result = bpf_init_inode_xattr(xattrs, xattr_name, \u0026value_ptr);\n+\n+\treturn 0;\n+}\n"
}

2/1 2026/08/01 09:24 agent patch-evaluator
1m Model:
best-expensive

Args:
null

Results:
{
  "EnableConfigs": [
    "BPF_LSM",
    "SECURITY_SELINUX",
    "SECURITY_SMACK",
    "EVM",
    "BPF_SYSCALL",
    "BPF_JIT"
  ],
  "FocusSymbols": [
    "bpf_init_inode_xattr",
    "security_lsmxattr_add",
    "security_inode_init_security",
    "evm_inode_init_security"
  ],
  "Reasoning": "The patch introduces a new BPF kfunc `bpf_init_inode_xattr` that allows BPF LSM programs to set xattrs during inode creation. It also refactors `security_inode_init_security` to use a new `struct lsm_xattrs` and updates EVM, SELinux, and SMACK to use it. This is a functional change in the core security and BPF subsystems that should be fuzzed.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
  even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).
- Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed,
  ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU.
- Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove)
  that are executed only during PCI hot-unplug or sysfs driver unbind operations.

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
   Prefer non-static, non-inlined API entrypoint functions over internal static helper functions
   (which are inlined by the compiler and do not have distinct symbol addresses).
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs
   needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs
   output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit 9980131719c0513ff3b73b398251a713002044b8
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Aug 1 09:23:59 2026 +0000

    syz-cluster: applied patch under review

diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
index f1863a891db64..7b55073934e0b 100644
--- a/fs/bpf_fs_kfuncs.c
+++ b/fs/bpf_fs_kfuncs.c
@@ -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)
diff --git a/include/linux/bpf_lsm.h b/include/linux/bpf_lsm.h
index dda272d78f013..4bf350ef02f48 100644
--- a/include/linux/bpf_lsm.h
+++ b/include/linux/bpf_lsm.h
@@ -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;
diff --git a/include/linux/evm.h b/include/linux/evm.h
index 913f4573b2038..528f360f3308d 100644
--- a/include/linux/evm.h
+++ b/include/linux/evm.h
@@ -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;
 }
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 65c9609ec2077..5b2de7865ce81 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -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,
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index b4f8cad53ddb0..7afe06a8d4c6c 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -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 */
diff --git a/include/linux/security.h b/include/linux/security.h
index 153e9043058f8..d35fde7aa11f0 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -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 */
@@ -401,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);
@@ -895,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)
diff --git a/security/bpf/hooks.c b/security/bpf/hooks.c
index 7b98f5d1e2be8..8f8c3de3035f0 100644
--- a/security/bpf/hooks.c
+++ b/security/bpf/hooks.c
@@ -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) = {
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index b59e3f121b8a8..b7158fc63543e 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -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.
diff --git a/security/security.c b/security/security.c
index 71aea8fdf0142..ae72102cd29b8 100644
--- a/security/security.c
+++ b/security/security.c
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt) "LSM: " fmt
 
 #include <linux/bpf.h>
+#include <linux/bpf_lsm.h>
 #include <linux/capability.h>
 #include <linux/dcache.h>
 #include <linux/export.h>
@@ -1333,8 +1334,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 +1345,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,18 +1365,113 @@ 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);
 
+static unsigned int lsm_xattrs_used(const struct lsm_xattrs *xattrs,
+				    const char *prefix)
+{
+	size_t prefix_len = strlen(prefix);
+	unsigned int i, n = 0;
+
+	for (i = 0; i < xattrs->xattr_count; i++) {
+		const char *name = xattrs->xattrs[i].name;
+
+		if (name && !strncmp(name, prefix, prefix_len))
+			n++;
+	}
+	return n;
+}
+
+/**
+ * security_lsmxattr_add() - Add an xattr during inode_init_security
+ * @xattrs: xattr state shared by inode_init_security hooks
+ * @lsm_id: LSM_ID_* value identifying the calling LSM
+ * @name_extra: xattr name components beyond the calling LSM's standard
+ *              xattr suffix, NULL if the standard suffix is the full name
+ * @value: xattr value
+ * @value_len: length of @value
+ *
+ * Claim an xattr slot in @xattrs on behalf of the LSM identified by
+ * @lsm_id and fill it with a copy of @value. The xattr name is built from
+ * the standard xattr suffix of the calling LSM, followed by @name_extra.
+ * Callers can invoke this function from non-sleepable context.
+ *
+ * Return: Returns 0 on success or if the filesystem does not accept xattrs
+ *         at inode creation, -ENOSPC if the calling LSM's slot budget is
+ *         exhausted, negative values on other errors.
+ */
+int security_lsmxattr_add(struct lsm_xattrs *xattrs, u64 lsm_id,
+			  const char *name_extra, const void *value,
+			  size_t value_len)
+{
+	struct xattr *xattr;
+	void *xattr_value;
+	const char *suffix;
+	size_t suffix_len, extra_len, name_len;
+
+	if (!xattrs || !value)
+		return -EINVAL;
+
+	/* The filesystem did not provide an initxattrs callback. */
+	if (!xattrs->xattrs)
+		return 0;
+
+	switch (lsm_id) {
+	case LSM_ID_BPF:
+		if (!name_extra || !name_extra[0])
+			return -EINVAL;
+		suffix = XATTR_BPF_LSM_SUFFIX;
+		if (lsm_xattrs_used(xattrs, XATTR_BPF_LSM_SUFFIX) >=
+		    BPF_LSM_INODE_INIT_XATTRS)
+			return -ENOSPC;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	suffix_len = strlen(suffix);
+	extra_len = name_extra ? strlen(name_extra) : 0;
+	name_len = suffix_len + extra_len;
+	if (name_len > XATTR_NAME_MAX)
+		return -EINVAL;
+	if (value_len == 0 || value_len > XATTR_SIZE_MAX)
+		return -EINVAL;
+
+	/* 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);
+	((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;
+	xattr->value_len = value_len;
+
+	return 0;
+}
+
 /**
  * security_inode_init_security_anon() - Initialize an anonymous inode
  * @inode: the inode
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 8d6945edae7aa..21544c775c176 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -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);
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index ff115068c5c06..4501078430ca0 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -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);
diff --git a/tools/testing/selftests/bpf/bpf_kfuncs.h b/tools/testing/selftests/bpf/bpf_kfuncs.h
index ae71e9b690518..2639f9f941955 100644
--- a/tools/testing/selftests/bpf/bpf_kfuncs.h
+++ b/tools/testing/selftests/bpf/bpf_kfuncs.h
@@ -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
diff --git a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
index 43a26ec69a8e3..b208522dbd33d 100644
--- a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
+++ b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
@@ -10,6 +10,7 @@
 #include "test_get_xattr.skel.h"
 #include "test_set_remove_xattr.skel.h"
 #include "test_fsverity.skel.h"
+#include "test_init_inode_xattr.skel.h"
 
 static const char testfile[] = "/tmp/test_progs_fs_kfuncs";
 
@@ -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().
+	 */
+	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);
+	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;
+	}
+
+	/* The filesystem does not accept xattrs at inode creation. */
+	if (skel->data->init_result == -EOPNOTSUPP) {
+		printf("%s:SKIP:filesystem does not support LSM init xattrs\n",
+		       __func__);
+		test__skip();
+		goto out;
+	}
+
+	ASSERT_EQ(skel->data->init_result, 0, "init_result");
+
+	/* initxattrs prepends "security." to the name. */
+	err = getxattr(testfile_new, "security.bpf.test_label", value_out,
+		       sizeof(value_out));
+	if (err < 0 && errno == ENODATA) {
+		printf("%s:SKIP:filesystem did not apply LSM xattrs\n",
+		       __func__);
+		test__skip();
+		goto out;
+	}
+	if (!ASSERT_GE(err, 0, "getxattr"))
+		goto out;
+
+	ASSERT_EQ(err, (int)sizeof(skel->data->xattr_value), "xattr_size");
+	ASSERT_EQ(strncmp(value_out, "unconfined_u:object_r:user_home_t:s0",
+			  sizeof("unconfined_u:object_r:user_home_t:s0")), 0,
+		  "xattr_value");
+
+out:
+	close(fd);
+	test_init_inode_xattr__destroy(skel);
+	remove(testfile_new);
+}
+
+/* Keep in sync with BPF_LSM_INODE_INIT_XATTRS in include/linux/bpf_lsm.h. */
+#define INIT_INODE_XATTR_MAX 4
+
+/*
+ * Programs may attach to inode_init_security without an attach-time limit, but
+ * the kfunc only lets BPF claim INIT_INODE_XATTR_MAX xattr slots per inode.
+ * Calls beyond that budget are rejected at runtime with -ENOSPC.
+ */
+static void test_init_inode_xattr_slot_limit(void)
+{
+	struct test_init_inode_xattr *skel[INIT_INODE_XATTR_MAX + 1] = {};
+	struct bpf_link *link[INIT_INODE_XATTR_MAX + 1] = {};
+	const char *testfile_slot = "/dev/shm/test_progs_fs_kfuncs_slot";
+	int ok = 0, nospc = 0, notrun = 0, other = 0;
+	int i, fd = -1;
+
+	/* All programs attach successfully; there is no attach-time cap. */
+	for (i = 0; i <= INIT_INODE_XATTR_MAX; i++) {
+		skel[i] = test_init_inode_xattr__open();
+		if (!ASSERT_OK_PTR(skel[i], "open"))
+			goto out;
+
+		snprintf(skel[i]->rodata->xattr_name,
+			 sizeof(skel[i]->rodata->xattr_name), "bpf.label_%d",
+			 i);
+
+		if (!ASSERT_OK(test_init_inode_xattr__load(skel[i]), "load"))
+			goto out;
+
+		skel[i]->bss->monitored_pid = getpid();
+
+		link[i] = bpf_program__attach_lsm(skel[i]->progs.test_init_inode_xattr);
+		if (!ASSERT_OK_PTR(link[i], "attach"))
+			goto out;
+	}
+
+	/* Trigger inode_init_security once with all programs attached. */
+	fd = open(testfile_slot, O_CREAT | O_RDWR, 0644);
+	if (!ASSERT_GE(fd, 0, "create_file"))
+		goto out;
+
+	/*
+	 * Exactly INIT_INODE_XATTR_MAX programs claim a slot; test
+	 * xattr budget accounting with -ENOSPC.
+	 */
+	for (i = 0; i <= INIT_INODE_XATTR_MAX; i++) {
+		int res = skel[i]->data->init_result;
+
+		if (!skel[i]->bss->hook_ran || res == -EOPNOTSUPP)
+			notrun++;
+		else if (res == 0)
+			ok++;
+		else if (res == -ENOSPC)
+			nospc++;
+		else
+			other++;
+	}
+
+	if (notrun == INIT_INODE_XATTR_MAX + 1) {
+		printf("%s:SKIP:hook not invoked or fs lacks LSM init xattrs\n",
+		       __func__);
+		test__skip();
+		goto out;
+	}
+
+	ASSERT_EQ(ok, INIT_INODE_XATTR_MAX, "slots_within_budget");
+	ASSERT_EQ(nospc, 1, "slot_over_budget");
+	ASSERT_EQ(other, 0, "unexpected_result");
+
+out:
+	if (fd >= 0)
+		close(fd);
+	for (i = 0; i <= INIT_INODE_XATTR_MAX; i++) {
+		bpf_link__destroy(link[i]);
+		test_init_inode_xattr__destroy(skel[i]);
+	}
+	remove(testfile_slot);
+}
+
 void test_fs_kfuncs(void)
 {
 	/* Matches xattr_names in progs/test_get_xattr.c */
@@ -288,4 +438,10 @@ void test_fs_kfuncs(void)
 
 	if (test__start_subtest("fsverity"))
 		test_fsverity();
+
+	if (test__start_subtest("init_inode_xattr"))
+		test_init_inode_xattr();
+
+	if (test__start_subtest("init_inode_xattr_slot_limit"))
+		test_init_inode_xattr_slot_limit();
 }
diff --git a/tools/testing/selftests/bpf/progs/test_init_inode_xattr.c b/tools/testing/selftests/bpf/progs/test_init_inode_xattr.c
new file mode 100644
index 0000000000000..ce3d8d39de9ca
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_init_inode_xattr.c
@@ -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;
+}

3/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 11933
							output: 23
							thoughts: 351
						

Thoughts:
**Initial Thoughts on the New BPF Xattr Kfunc Patch**

Okay, so we've got a new patch introducing a BPF kfunc, `bpf_init_inode_xattr`, which is designed to allow BPF LSM programs to set extended attributes (xattrs) during `inode_init_security`. That's interesting, and potentially quite powerful. The patch is fairly broad, updating several security subsystems to accommodate this change. They've opted for a `struct lsm_xattrs` to manage these attributes instead of the raw array previously used, which makes sense for maintainability. It seems they've updated `evm`, `selinux`, and `smack` to take advantage of this new structure and a new function, `security_lsmxattr_add`, which is called by this new kfunc.

Let me take a closer look at the implementation. The core of `bpf_init_inode_xattr` is in `fs/bpf_fs_kfuncs.c`, and it looks like it just delegates to `security_lsmxattr_add`. I'll want to dig into that function now to understand what's actually going on. This patch modifies `security/security.c` to contain this implementation. I should also check how the other subsystems have been modified. It also updates `security/integrity/evm/evm_main.c`, `security/selinux/hooks.c`, and `security/smack/smack_lsm.c` to use the `struct lsm_xattrs`.

This certainly looks like a functional patch, and ripe for fuzzing. Given the new functionality, those key functions are definitely the starting points for fuzzing. We should zero in on:
*   `bpf_init_inode_xattr`
*   `security_lsmxattr_add`
*   `security_inode_init_security`

Before we move on, I want to confirm if there are any specific kernel configurations required for this to work. I'll need to check the Kconfig for `fs/bpf_fs_kfuncs.c`.



4/2 2026/08/01 09:24 tool grepper
0m Args:
{
  "Expression": "bpf_fs_kfuncs.o"
}

Results:
{
  "Output": "fs/Makefile=129=obj-$(CONFIG_ZONEFS_FS)\t\t+= zonefs/\nfs/Makefile:130:obj-$(CONFIG_BPF_LSM)\t\t+= bpf_fs_kfuncs.o\nfs/Makefile-131-obj-$(CONFIG_RESCTRL_FS)\t+= resctrl/\n"
}

5/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 12858
							output: 20
							thoughts: 37
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert's internal monologue:

**Investigating BPF LSM Configuration**

Right, so we're dealing with a BPF LSM issue, and it seems `CONFIG_BPF_LSM` is the key. Makes sense. Before I dive deeper, let's just confirm that that's the correct config option to be focusing on. I'll quickly check its definition to make sure I'm not chasing a red herring. Time to crack open `security/bpf/Kconfig` and verify the `CONFIG_BPF_LSM` definition and dependencies to get the lay of the land. It's always smart to double-check these things when dealing with security features. That should give me a solid foundation for understanding the problem and figuring out the best next steps.



6/2 2026/08/01 09:24 tool grepper
0m Args:
{
  "Expression": "config BPF_LSM"
}

Results:
{
  "Output": "kernel/bpf/Kconfig=90=source \"kernel/bpf/preload/Kconfig\"\nkernel/bpf/Kconfig-91-\nkernel/bpf/Kconfig:92:config BPF_LSM\nkernel/bpf/Kconfig-93-\tbool \"Enable BPF LSM Instrumentation\"\n"
}

7/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 13180
							output: 34
							thoughts: 19
						

Thoughts:
Here's my attempt at summarizing the thought process, tailored for an expert audience:

**Diving into BPF Configuration**

Okay, so I need to understand how some specific BPF functionality is being configured within this kernel. Let's see...I'm thinking, based on the context, that the most relevant information might reside within `kernel/bpf/Kconfig`. It's where the compilation options for the BPF subsystem are laid out. I have a hunch that there's something specific, likely around line 92, pertaining to the area I'm currently investigating. It's a good place to start digging for the specific config options I need to know about. I'll take a look at the surrounding code as well to find out all of the options.



8/2 2026/08/01 09:24 tool read-file
0m Args:
{
  "File": "kernel/bpf/Kconfig",
  "FirstLine": 85,
  "LineCount": 20
}

Results:
{
  "Contents": "  85:\t\t  speculative execution side-channel vulnerabilities on unmitigated\n  86:\t\t  affected hardware.\n  87:\t\n  88:\t\t  If you are unsure how to answer this question, answer Y.\n  89:\t\n  90:\tsource \"kernel/bpf/preload/Kconfig\"\n  91:\t\n  92:\tconfig BPF_LSM\n  93:\t\tbool \"Enable BPF LSM Instrumentation\"\n  94:\t\tdepends on BPF_EVENTS\n  95:\t\tdepends on BPF_SYSCALL\n  96:\t\tdepends on SECURITY\n  97:\t\tdepends on BPF_JIT\n  98:\t\thelp\n  99:\t\t  Enables instrumentation of the security hooks with BPF programs for\n 100:\t\t  implementing dynamic MAC and Audit Policies.\n 101:\t\n 102:\t\t  If you are unsure how to answer this question, answer N.\n 103:\t\n 104:\tendmenu # \"BPF subsystem\"\n"
}

9/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 13660
							output: 20
							thoughts: 548
						

Thoughts:
**Analyzing the BPF LSM Patch Dependencies and Impact**

Okay, so I'm digging into this `BPF_LSM` patch. My initial thought is to trace the dependencies; it looks like `BPF_LSM` relies on `BPF_EVENTS`, `BPF_SYSCALL`, `SECURITY`, and `BPF_JIT`. That's the baseline.

First, I need to understand how the existing security infrastructure is being integrated with BPF. I'm going to check `security_inode_init_security` within `security/security.c` to see how it's defined. Right, it is compiled if `CONFIG_SECURITY` is enabled, which is expected.

Now, let's consider the broader implications. The patch touches `EVM`, `SELINUX`, and `SMACK` configurations, but the core functionality seems to stem from the new BPF kfunc. If I enable `BPF_LSM`, I should be able to focus on testing that kfunc's integration. The modification to those security modules appears to be about hooking into `inode_init_security` but I'll make sure to get comprehensive coverage on the changes there. So, to ensure I can comprehensively test those changes, enabling `SECURITY_SELINUX`, `SECURITY_SMACK`, and `EVM` is a good idea. That will ensure the modified hooks are tested.

Next, I need to see how the xattr functions come into play. I'll look at `security_lsmxattr_add` in `security/security.c`. Okay, it's defined and doesn't appear to be guarded by any conditional compilation, so it's directly included when `CONFIG_SECURITY` is set.

Now, let's look at the BPF side. I'll examine `bpf_init_inode_xattr` in `fs/bpf_fs_kfuncs.c`. Ah, there it is, compiled with `CONFIG_BPF_LSM`, as expected. So, it calls `security_lsmxattr_add`.

To summarize the key configurations I need:

*   `BPF_LSM`
*   `SECURITY`
*   `BPF_SYSCALL`
*   `BPF_JIT`

And I'll make a note to double-check if there are any *other* configs that I'm missing.

The critical pieces of this are:

*   `bpf_init_inode_xattr`
*   `security_lsmxattr_add`
*   `security_inode_init_security`

Finally, a quick double-check on those `evm`, `selinux`, and `smack` changes. The patch modifies the signature of the `inode_init_security` hook and uses `lsm_get_xattr_slot`. Oh, and `lsm_get_xattr_slot` is an inline function in `include/linux/lsm_hooks.h`. I'll want to enable those configs to verify the signature updates are correct, so:

*   `SECURITY_SELINUX`
*   `SECURITY_SMACK`
*   `EVM`

Just to be absolutely sure. This should give me comprehensive test coverage.



10/2 2026/08/01 09:24 tool grepper
0m Args:
{
  "Expression": "config SECURITY_SELINUX"
}

Results:
{
  "Output": "security/selinux/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nsecurity/selinux/Kconfig:2:config SECURITY_SELINUX\nsecurity/selinux/Kconfig-3-\tbool \"SELinux Support\"\n--\nsecurity/selinux/Kconfig-11-\nsecurity/selinux/Kconfig:12:config SECURITY_SELINUX_BOOTPARAM\nsecurity/selinux/Kconfig-13-\tbool \"SELinux boot parameter\"\n--\nsecurity/selinux/Kconfig-25-\nsecurity/selinux/Kconfig:26:config SECURITY_SELINUX_DEVELOP\nsecurity/selinux/Kconfig-27-\tbool \"SELinux Development Support\"\n--\nsecurity/selinux/Kconfig-39-\nsecurity/selinux/Kconfig:40:config SECURITY_SELINUX_AVC_STATS\nsecurity/selinux/Kconfig-41-\tbool \"SELinux AVC Statistics\"\n--\nsecurity/selinux/Kconfig-48-\nsecurity/selinux/Kconfig:49:config SECURITY_SELINUX_SIDTAB_HASH_BITS\nsecurity/selinux/Kconfig-50-\tint \"SELinux sidtab hashtable size\"\n--\nsecurity/selinux/Kconfig-60-\nsecurity/selinux/Kconfig:61:config SECURITY_SELINUX_SID2STR_CACHE_SIZE\nsecurity/selinux/Kconfig-62-\tint \"SELinux SID to context string translation cache size\"\n--\nsecurity/selinux/Kconfig-71-\nsecurity/selinux/Kconfig:72:config SECURITY_SELINUX_AVC_HASH_BITS\nsecurity/selinux/Kconfig-73-\tint \"SELinux avc hashtable size\"\n--\nsecurity/selinux/Kconfig-82-\nsecurity/selinux/Kconfig:83:config SECURITY_SELINUX_DEBUG\nsecurity/selinux/Kconfig-84-\tbool \"SELinux kernel debugging support\"\n"
}

11/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 15442
							output: 17
							thoughts: 10
						

Thoughts:
Here's my attempt at summarizing the thought process, tailored for an expert audience:

**EVM Configuration Assessment**

Alright, let's dive in. My immediate thought is to verify the configuration of the `EVM`. This is the jumping-off point; before I consider any deeper diagnostics or potential issues, I need to understand its current state. I need to make sure the environment is set up as I would expect. What are the key parameters? Are the gas limits appropriate for the anticipated transaction load? Is the block time configured correctly? What about the consensus mechanism settings? Are there any obvious flags or overrides that could be influencing performance or behavior? I want to know everything. This will tell me if the behavior I'm seeing is a product of some underlying configuration.



12/2 2026/08/01 09:24 tool grepper
0m Args:
{
  "Expression": "config EVM"
}

Results:
{
  "Output": "security/integrity/evm/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nsecurity/integrity/evm/Kconfig:2:config EVM\nsecurity/integrity/evm/Kconfig-3-\tbool \"EVM support\"\n--\nsecurity/integrity/evm/Kconfig-16-\nsecurity/integrity/evm/Kconfig:17:config EVM_ATTR_FSUUID\nsecurity/integrity/evm/Kconfig-18-\tbool \"FSUUID (version 2)\"\n--\nsecurity/integrity/evm/Kconfig-30-\nsecurity/integrity/evm/Kconfig:31:config EVM_EXTRA_SMACK_XATTRS\nsecurity/integrity/evm/Kconfig-32-\tbool \"Additional SMACK xattrs\"\n--\nsecurity/integrity/evm/Kconfig-47-\nsecurity/integrity/evm/Kconfig:48:config EVM_ADD_XATTRS\nsecurity/integrity/evm/Kconfig-49-\tbool \"Add additional EVM extended attributes at runtime\"\n--\nsecurity/integrity/evm/Kconfig-58-\nsecurity/integrity/evm/Kconfig:59:config EVM_LOAD_X509\nsecurity/integrity/evm/Kconfig-60-\tbool \"Load an X509 certificate onto the '.evm' trusted keyring\"\n--\nsecurity/integrity/evm/Kconfig-70-\nsecurity/integrity/evm/Kconfig:71:config EVM_X509_PATH\nsecurity/integrity/evm/Kconfig-72-\tstring \"EVM X509 certificate path\"\n"
}

13/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 16036
							output: 19
							thoughts: 10
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:

**Initial Assessment: A Quick Scan for the Obvious**

Alright, the first thing that jumps into my mind is a quick sanity check. When dealing with security, you always start with the most likely culprits, the low-hanging fruit. Let's start by looking at `SECURITY_SMACK`. I'm going to run it by my mental checklist. Is it a variable, a function, a module, a library? Is it something internal or external? Is this something I've worked with before? Is there a known vulnerability, a configuration issue, or a common misinterpretation associated with this name? This is basic triage, but it's essential to prevent getting side-tracked by something trivial.



14/2 2026/08/01 09:24 tool grepper
0m Args:
{
  "Expression": "config SECURITY_SMACK"
}

Results:
{
  "Output": "security/smack/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nsecurity/smack/Kconfig:2:config SECURITY_SMACK\nsecurity/smack/Kconfig-3-\tbool \"Simplified Mandatory Access Control Kernel Support\"\n--\nsecurity/smack/Kconfig-15-\nsecurity/smack/Kconfig:16:config SECURITY_SMACK_BRINGUP\nsecurity/smack/Kconfig-17-\tbool \"Reporting on access granted by Smack rules\"\n--\nsecurity/smack/Kconfig-33-\nsecurity/smack/Kconfig:34:config SECURITY_SMACK_NETFILTER\nsecurity/smack/Kconfig-35-\tbool \"Packet marking using secmarks for netfilter\"\n--\nsecurity/smack/Kconfig-44-\nsecurity/smack/Kconfig:45:config SECURITY_SMACK_APPEND_SIGNALS\nsecurity/smack/Kconfig-46-\tbool \"Treat delivering signals as an append operation\"\n"
}

15/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 16485
							output: 23
							thoughts: 296
						

Thoughts:
**Analyzing the Impact of the New `bpf_init_inode_xattr` kfunc**

Okay, so this patch introduces a new kernel function, `bpf_init_inode_xattr`, specifically designed to allow BPF LSM programs to set extended attributes (xattrs) during the `inode_init_security` phase. This is a clear functional change, and my first instinct is to highlight that this needs thorough fuzzing.

My primary focus points for investigation will be: `bpf_init_inode_xattr` (of course!), alongside the other critical functions affected: `security_lsmxattr_add`, `security_inode_init_security`, `evm_inode_init_security`, `selinux_inode_init_security`, and `smack_inode_init_security`. I'll also need to keep an eye on the relevant configuration options: `BPF_LSM`, `SECURITY`, `SECURITY_SELINUX`, `SECURITY_SMACK`, and `EVM`.

I'm now thinking about the interplay between this new functionality and existing security modules. Specifically, I'm curious about how `evm_inode_init_security` behaves, so I'm going to quickly check if that's a static function. Looks like in `security/integrity/evm/evm_main.c` it's defined as `int evm_inode_init_security(...)` - so, not static.

Now, wait a second. I need to be more careful. Thinking about it, the fact that `selinux_inode_init_security` *is* static (in `security/selinux/hooks.c`, I'll double-check), means it could be inlined, or might not have a distinct symbol address. That could be problematic, so let me quickly go back and confirm how that function is implemented...



16/2 2026/08/01 09:24 tool grepper
0m Args:
{
  "Expression": "selinux_inode_init_security"
}

Results:
{
  "Output": "security/selinux/hooks.c=2942=static int selinux_dentry_create_files_as(struct dentry *dentry, int mode,\n--\nsecurity/selinux/hooks.c-2962-\nsecurity/selinux/hooks.c:2963:static int selinux_inode_init_security(struct inode *inode, struct inode *dir,\nsecurity/selinux/hooks.c-2964-\t\t\t\t       const struct qstr *qstr,\n--\nsecurity/selinux/hooks.c-3008-\nsecurity/selinux/hooks.c:3009:static int selinux_inode_init_security_anon(struct inode *inode,\nsecurity/selinux/hooks.c-3010-\t\t\t\t\t    const struct qstr *name,\n--\nsecurity/selinux/hooks.c=7553=static struct security_hook_list selinux_hooks[] __ro_after_init = {\n--\nsecurity/selinux/hooks.c-7591-\tLSM_HOOK_INIT(inode_free_security, selinux_inode_free_security),\nsecurity/selinux/hooks.c:7592:\tLSM_HOOK_INIT(inode_init_security, selinux_inode_init_security),\nsecurity/selinux/hooks.c:7593:\tLSM_HOOK_INIT(inode_init_security_anon, selinux_inode_init_security_anon),\nsecurity/selinux/hooks.c-7594-\tLSM_HOOK_INIT(inode_create, selinux_inode_create),\n"
}

17/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 17623
							output: 22
							thoughts: 94
						

Thoughts:
Okay, here's my take on those thoughts, framed as my own:

**Analyzing LSM Hook Initialization**

Alright, so I'm looking at how this security module gets initialized, and I've got a key point in mind: because this function's being passed as a function pointer to `LSM_HOOK_INIT`, there's no way the compiler's going to inline it. That's just the nature of how function pointers work. But, and this is important, this particular function is also declared as `static`, which gives me a good place to start my deep dive.

Given that, I think the critical areas to scrutinize are `bpf_init_inode_xattr`, `security_lsmxattr_add`, `security_inode_init_security`, and `evm_inode_init_security`. Those are the prime candidates for where the actual initialization logic resides, and where I'm going to find the core mechanisms.

Before I go further, I'm just going to double-check `smack_inode_init_security`, just to be sure I'm not missing something obvious. I'll need to know whether any other security module overrides this module's initialization strategy.



18/2 2026/08/01 09:24 tool grepper
0m Args:
{
  "Expression": "smack_inode_init_security"
}

Results:
{
  "Output": "security/smack/smack_lsm.c=984=xattr_dupval(struct lsm_xattrs *xattrs,\n--\nsecurity/smack/smack_lsm.c-1001-/**\nsecurity/smack/smack_lsm.c:1002: * smack_inode_init_security - copy out the smack from an inode\nsecurity/smack/smack_lsm.c-1003- * @inode: the newly created inode\n--\nsecurity/smack/smack_lsm.c-1009- */\nsecurity/smack/smack_lsm.c:1010:static int smack_inode_init_security(struct inode *inode, struct inode *dir,\nsecurity/smack/smack_lsm.c-1011-\t\t\t\t     const struct qstr *qstr,\n--\nsecurity/smack/smack_lsm.c=5121=static struct security_hook_list smack_hooks[] __ro_after_init = {\n--\nsecurity/smack/smack_lsm.c-5138-\tLSM_HOOK_INIT(inode_alloc_security, smack_inode_alloc_security),\nsecurity/smack/smack_lsm.c:5139:\tLSM_HOOK_INIT(inode_init_security, smack_inode_init_security),\nsecurity/smack/smack_lsm.c-5140-\tLSM_HOOK_INIT(inode_link, smack_inode_link),\n"
}

19/2 2026/08/01 09:24 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 18381
							output: 213
							thoughts: 359
						

Thoughts:
**My Analysis of this Patch**

Okay, so I'm looking at this patch and immediately, I see a clear direction. I'm focusing on these symbols: `bpf_init_inode_xattr`, `security_lsmxattr_add`, `security_inode_init_security`, and `evm_inode_init_security`. I know exactly what these things are.

Right away, I see that I need to include these configs in any testing scenario: `BPF_LSM`, `SECURITY_SELINUX`, `SECURITY_SMACK`, and `EVM`. And, wait, I also need `BPF_SYSCALL` and `BPF_JIT` as dependencies. Noted.

Now, let's look at what this patch actually *does*. It's introducing a new BPF kfunc: `bpf_init_inode_xattr`. This is key. It's giving BPF LSM programs the capability to set extended attributes (xattrs) during `inode_init_security`. That's a significant functionality addition, and opens new attack surfaces. It also refactors `security_inode_init_security` to use `struct lsm_xattrs` instead of a raw array - improving the architecture. And, it updates several LSMs to use it: `evm`, `selinux`, and `smack`. The new function `security_lsmxattr_add`, called by the new kfunc, warrants scrutiny.

In short, this is definitely functional, introduces new attack surfaces, and, therefore, is *absolutely* worth fuzzing. I will use the set-results tool to document my analysis and the results.



20/2 2026/08/01 09:25 tool set-results
0m Args:
{
  "EnableConfigs": [
    "BPF_LSM",
    "SECURITY_SELINUX",
    "SECURITY_SMACK",
    "EVM",
    "BPF_SYSCALL",
    "BPF_JIT"
  ],
  "FocusSymbols": [
    "bpf_init_inode_xattr",
    "security_lsmxattr_add",
    "security_inode_init_security",
    "evm_inode_init_security"
  ],
  "Reasoning": "The patch introduces a new BPF kfunc `bpf_init_inode_xattr` that allows BPF LSM programs to set xattrs during inode creation. It also refactors `security_inode_init_security` to use a new `struct lsm_xattrs` and updates EVM, SELinux, and SMACK to use it. This is a functional change in the core security and BPF subsystems that should be fuzzed.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "BPF_LSM",
    "SECURITY_SELINUX",
    "SECURITY_SMACK",
    "EVM",
    "BPF_SYSCALL",
    "BPF_JIT"
  ],
  "FocusSymbols": [
    "bpf_init_inode_xattr",
    "security_lsmxattr_add",
    "security_inode_init_security",
    "evm_inode_init_security"
  ],
  "Reasoning": "The patch introduces a new BPF kfunc `bpf_init_inode_xattr` that allows BPF LSM programs to set xattrs during inode creation. It also refactors `security_inode_init_security` to use a new `struct lsm_xattrs` and updates EVM, SELinux, and SMACK to use it. This is a functional change in the core security and BPF subsystems that should be fuzzed.",
  "WorthFuzzing": true
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)