| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/11/08 18:00 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch series adds support for file metadata (extended attributes) in the initramfs:\n1. The changes in usr/ (gen_init_cpio.c, gen_initramfs.sh, Kconfig, Makefile) modify host-side user-space build tools used during kernel compilation to generate the cpio archive.\n2. The modifications in init/initramfs.c affect only early boot functions marked __init and __initdata (do_header, do_name, do_collect_metadata, do_setxattrs, unpack_to_rootfs, etc.), which execute strictly before userspace launches and are unmapped and freed by free_initmem() prior to any fuzzing activity.\n3. The change in security/integrity/ima/ima_appraise.c introduces an early-boot check `if (!ima_initramfs_populated) return 0;` guarded by a variable set to true before userspace starts and marked __ro_after_init, making this path completely dead and unreachable at runtime.\n\nBecause none of the modified code is reachable by userspace syscall fuzzing in a running kernel, the patch series does not warrant fuzzing.",
"WorthFuzzing": false
} |
| 1/1 | 2026/11/08 18:00 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 1ab5c708719e3bd26c954e1a6ab9145624353146\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sun Nov 8 18:00:15 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/linux/initramfs.h b/include/linux/initramfs.h\nnew file mode 100644\nindex 00000000000000..9b3839dc88a1e0\n--- /dev/null\n+++ b/include/linux/initramfs.h\n@@ -0,0 +1,19 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/*\n+ * Include file for file metadata in the initial ram disk.\n+ */\n+#ifndef _LINUX_INITRAMFS_H\n+#define _LINUX_INITRAMFS_H\n+\n+#define METADATA_FILENAME \"METADATA!!!\"\n+\n+enum metadata_types { TYPE_NONE, TYPE_XATTR, TYPE__LAST };\n+\n+struct metadata_hdr {\n+\tchar c_size[8]; /* total size including c_size field */\n+\tchar c_version; /* header version */\n+\tchar c_type; /* metadata type */\n+\tchar c_metadata[]; /* metadata */\n+} __packed;\n+\n+#endif /*LINUX_INITRAMFS_H*/\ndiff --git a/init/initramfs.c b/init/initramfs.c\nindex ebddde9c8f0d91..a17c26fde5f573 100644\n--- a/init/initramfs.c\n+++ b/init/initramfs.c\n@@ -10,7 +10,9 @@\n #include \u003clinux/hex.h\u003e\n #include \u003clinux/init.h\u003e\n #include \u003clinux/init_syscalls.h\u003e\n+#include \u003clinux/initramfs.h\u003e\n #include \u003clinux/kstrtox.h\u003e\n+#include \u003clinux/limits.h\u003e\n #include \u003clinux/memblock.h\u003e\n #include \u003clinux/mm.h\u003e\n #include \u003clinux/namei.h\u003e\n@@ -22,6 +24,7 @@\n #include \u003clinux/types.h\u003e\n #include \u003clinux/umh.h\u003e\n #include \u003clinux/utime.h\u003e\n+#include \u003clinux/xattr.h\u003e\n \n #include \u003casm/byteorder.h\u003e\n \n@@ -31,6 +34,17 @@\n static __initdata bool csum_present;\n static __initdata u32 io_csum;\n \n+static void __init update_csum(const unsigned char *buf, size_t len)\n+{\n+\tsize_t i;\n+\n+\tif (!csum_present)\n+\t\treturn;\n+\n+\tfor (i = 0; i \u003c len; i++)\n+\t\tio_csum += buf[i];\n+}\n+\n static ssize_t __init xwrite(struct file *file, const unsigned char *p,\n \t\tsize_t count, loff_t *pos)\n {\n@@ -47,12 +61,7 @@ static ssize_t __init xwrite(struct file *file, const unsigned char *p,\n \t\t} else if (rv == 0)\n \t\t\tbreak;\n \n-\t\tif (csum_present) {\n-\t\t\tssize_t i;\n-\n-\t\t\tfor (i = 0; i \u003c rv; i++)\n-\t\t\t\tio_csum += p[i];\n-\t\t}\n+\t\tupdate_csum(p, rv);\n \n \t\tp += rv;\n \t\tout += rv;\n@@ -189,7 +198,7 @@ static __initdata time64_t mtime;\n \n static __initdata unsigned long ino, major, minor, nlink;\n static __initdata umode_t mode;\n-static __initdata unsigned long body_len, name_len;\n+static __initdata unsigned long body_len, name_len, metadata_len;\n static __initdata uid_t uid;\n static __initdata gid_t gid;\n static __initdata unsigned rdev;\n@@ -230,6 +239,7 @@ static __initdata enum state {\n \tSkipIt,\n \tGotName,\n \tCopyFile,\n+\tCollectMetadata,\n \tGotSymlink,\n \tReset\n } state, next_state;\n@@ -263,7 +273,8 @@ static void __init read_into(char *buf, unsigned size, enum state next)\n \t}\n }\n \n-static __initdata char *header_buf, *symlink_buf, *name_buf;\n+static __initdata char *header_buf, *symlink_buf, *name_buf, *previous_name_buf;\n+static __initdata char *metadata_buf;\n \n static int __init do_start(void)\n {\n@@ -304,10 +315,10 @@ static int __init do_header(void)\n \tnext_header = (next_header + 3) \u0026 ~3;\n \tstate = SkipIt;\n \tif (name_len \u003c= 0 || name_len \u003e PATH_MAX)\n-\t\treturn 0;\n+\t\tgoto skip;\n \tif (S_ISLNK(mode)) {\n \t\tif (body_len \u003e PATH_MAX)\n-\t\t\treturn 0;\n+\t\t\tgoto skip;\n \t\tcollect = collected = symlink_buf;\n \t\tremains = N_ALIGN(name_len) + body_len;\n \t\tnext_state = GotSymlink;\n@@ -316,6 +327,11 @@ static int __init do_header(void)\n \t}\n \tif (S_ISREG(mode) || !body_len)\n \t\tread_into(name_buf, N_ALIGN(name_len), GotName);\n+\telse\n+\t\tgoto skip;\n+\treturn 0;\n+skip:\n+\tprevious_name_buf[0] = '\\0';\n \treturn 0;\n }\n \n@@ -365,11 +381,110 @@ static int __init maybe_link(void)\n \treturn 0;\n }\n \n+static int __init do_setxattrs(char *pathname, char *buf, size_t size)\n+{\n+\tstruct path path;\n+\tchar *xattr_name, *xattr_value;\n+\tu32 xattr_name_size, xattr_value_size;\n+\tint ret;\n+\n+\txattr_name = buf;\n+\txattr_name_size = strnlen(xattr_name, size);\n+\tif (xattr_name_size == size) {\n+\t\terror(\"malformed xattrs\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (!xattr_name_size || xattr_name_size \u003e XATTR_NAME_MAX) {\n+\t\terror(\"invalid xattr name length\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\txattr_value = xattr_name + xattr_name_size + 1;\n+\txattr_value_size = buf + size - xattr_value;\n+\tif (xattr_value_size \u003e XATTR_SIZE_MAX) {\n+\t\terror(\"xattr value exceeds size limit\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tret = kern_path(pathname, 0, \u0026path);\n+\tif (!ret) {\n+\t\t/*\n+\t\t * POSIX ACL restoration is currently unsupported.\n+\t\t * vfs_setxattr() rejects POSIX ACL xattrs with -EOPNOTSUPP.\n+\t\t */\n+\t\tret = vfs_setxattr(\u0026nop_mnt_idmap, path.dentry, xattr_name, xattr_value,\n+\t\t\t\t xattr_value_size, 0);\n+\n+\t\tpath_put(\u0026path);\n+\t}\n+\n+\tpr_debug(\"%s: %s size: %u (ret: %d)\\n\", pathname, xattr_name,\n+\t\t xattr_value_size, ret);\n+\tprint_hex_dump_debug(\"xattr value: \", DUMP_PREFIX_OFFSET,\n+\t\t\t 16, 1, xattr_value, xattr_value_size, false);\n+\n+\treturn ret;\n+}\n+\n+static int __init __maybe_unused do_parse_metadata(char *pathname)\n+{\n+\tchar *buf = metadata_buf;\n+\tchar *bufend = metadata_buf + metadata_len;\n+\tstruct metadata_hdr *hdr;\n+\tchar str[sizeof(hdr-\u003ec_size) + 1];\n+\tu32 entry_size;\n+\n+\tif (!metadata_len)\n+\t\treturn 0;\n+\n+\tstr[sizeof(hdr-\u003ec_size)] = 0;\n+\n+\twhile (buf \u003c bufend) {\n+\t\tint ret;\n+\n+\t\tif (bufend - buf \u003c sizeof(*hdr)) {\n+\t\t\terror(\"malformed metadata\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\thdr = (struct metadata_hdr *)buf;\n+\t\tif (hdr-\u003ec_version != 1) {\n+\t\t\tpr_debug(\"Unsupported header version\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tmemcpy(str, hdr-\u003ec_size, sizeof(hdr-\u003ec_size));\n+\t\tret = kstrtou32(str, 16, \u0026entry_size);\n+\t\tif (ret || entry_size \u003c sizeof(*hdr) ||\n+\t\t entry_size \u003e bufend - buf) {\n+\t\t\terror(\"malformed xattrs\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tswitch (hdr-\u003ec_type) {\n+\t\tcase TYPE_XATTR:\n+\t\t\tdo_setxattrs(pathname, buf + sizeof(*hdr),\n+\t\t\t\t entry_size - sizeof(*hdr));\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tpr_debug(\"Unsupported metadata type\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tbuf += entry_size;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static __initdata struct file *wfile;\n static __initdata loff_t wfile_pos;\n \n static int __init do_name(void)\n {\n+\tbool target_ready = false;\n+\n \tstate = SkipIt;\n \tnext_state = Reset;\n \n@@ -381,6 +496,19 @@ static int __init do_name(void)\n \t\treturn 1;\n \t}\n \n+\tif (S_ISREG(mode) \u0026\u0026 strcmp(collected, METADATA_FILENAME) == 0) {\n+\t\tmetadata_len = body_len;\n+\t\tif (metadata_len)\n+\t\t\tmetadata_buf = kmalloc(metadata_len, GFP_KERNEL);\n+\t\telse\n+\t\t\tmetadata_buf = NULL;\n+\t\tio_csum = 0;\n+\t\tstate = CollectMetadata;\n+\t\treturn 0;\n+\t}\n+\n+\t/* Clear metadata target only after checking entry is not metadata */\n+\tprevious_name_buf[0] = '\\0';\n \tif (strcmp(collected, \"TRAILER!!!\") == 0) {\n \t\tfree_hash();\n \t\treturn 0;\n@@ -403,24 +531,65 @@ static int __init do_name(void)\n \t\t\tif (body_len)\n \t\t\t\tvfs_truncate(\u0026wfile-\u003ef_path, body_len);\n \t\t\tstate = CopyFile;\n+\t\t\ttarget_ready = true;\n \t\t}\n \t} else if (S_ISDIR(mode)) {\n-\t\tinit_mkdir(collected, mode);\n+\t\tint ret = init_mkdir(collected, mode);\n+\n+\t\ttarget_ready = !ret || ret == -EEXIST;\n \t\tinit_chown(collected, uid, gid, 0);\n \t\tinit_chmod(collected, mode);\n \t\tdir_add(collected, name_len, mtime);\n \t} else if (S_ISBLK(mode) || S_ISCHR(mode) ||\n \t\t S_ISFIFO(mode) || S_ISSOCK(mode)) {\n-\t\tif (maybe_link() == 0) {\n-\t\t\tinit_mknod(collected, mode, rdev);\n+\t\tint ml = maybe_link();\n+\n+\t\tif (ml == 0) {\n+\t\t\tint ret = init_mknod(collected, mode, rdev);\n+\n+\t\t\ttarget_ready = !ret || ret == -EEXIST;\n \t\t\tinit_chown(collected, uid, gid, 0);\n \t\t\tinit_chmod(collected, mode);\n \t\t\tdo_utime(collected, mtime);\n+\t\t} else if (ml == 1) {\n+\t\t\ttarget_ready = true;\n \t\t}\n \t}\n+\tif (target_ready)\n+\t\tmemcpy(previous_name_buf, collected, strlen(collected) + 1);\n \treturn 0;\n }\n \n+static void __init do_process_metadata(const char *buf, size_t len)\n+{\n+\t/* Still checksum the body if allocation failed. */\n+\tupdate_csum((const unsigned char *)buf, len);\n+\tif (metadata_buf)\n+\t\tmemcpy(metadata_buf + (metadata_len - body_len), buf, len);\n+}\n+\n+static int __init do_collect_metadata(void)\n+{\n+\tif (byte_count \u003e= body_len) {\n+\t\tdo_process_metadata(victim, body_len);\n+\t\tif (csum_present \u0026\u0026 io_csum != hdr_csum)\n+\t\t\terror(\"bad data checksum\");\n+\t\telse if (metadata_buf \u0026\u0026 previous_name_buf[0])\n+\t\t\tdo_parse_metadata(previous_name_buf);\n+\t\tkfree(metadata_buf);\n+\t\tmetadata_buf = NULL;\n+\t\tmetadata_len = 0;\n+\t\teat(body_len);\n+\t\tstate = SkipIt;\n+\t\treturn 0;\n+\t}\n+\n+\tdo_process_metadata(victim, byte_count);\n+\tbody_len -= byte_count;\n+\teat(byte_count);\n+\treturn 1;\n+}\n+\n static int __init do_copy(void)\n {\n \tif (byte_count \u003e= body_len) {\n@@ -445,6 +614,7 @@ static int __init do_copy(void)\n \n static int __init do_symlink(void)\n {\n+\tprevious_name_buf[0] = '\\0';\n \tif (collected[name_len - 1] != '\\0') {\n \t\tpr_err(\"initramfs symlink without nulterm: %.*s\\n\",\n \t\t (int)name_len, collected);\n@@ -453,7 +623,8 @@ static int __init do_symlink(void)\n \t}\n \tcollected[N_ALIGN(name_len) + body_len] = '\\0';\n \tclean_path(collected, 0);\n-\tinit_symlink(collected + N_ALIGN(name_len), collected);\n+\tif (!init_symlink(collected + N_ALIGN(name_len), collected))\n+\t\tmemcpy(previous_name_buf, collected, strlen(collected) + 1);\n \tinit_chown(collected, uid, gid, AT_SYMLINK_NOFOLLOW);\n \tdo_utime(collected, mtime);\n \tstate = SkipIt;\n@@ -468,6 +639,7 @@ static __initdata int (*actions[])(void) = {\n \t[SkipIt]\t= do_skip,\n \t[GotName]\t= do_name,\n \t[CopyFile]\t= do_copy,\n+\t[CollectMetadata] = do_collect_metadata,\n \t[GotSymlink]\t= do_symlink,\n \t[Reset]\t\t= do_reset,\n };\n@@ -527,6 +699,7 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)\n \t\tchar header[CPIO_HDRLEN];\n \t\tchar symlink[PATH_MAX + N_ALIGN(PATH_MAX) + 1];\n \t\tchar name[N_ALIGN(PATH_MAX)];\n+\t\tchar prev_name[PATH_MAX + N_ALIGN(PATH_MAX) + 1];\n \t} *bufs = kmalloc_obj(*bufs);\n \n \tif (!bufs)\n@@ -535,6 +708,8 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)\n \theader_buf = bufs-\u003eheader;\n \tsymlink_buf = bufs-\u003esymlink;\n \tname_buf = bufs-\u003ename;\n+\tprevious_name_buf = bufs-\u003eprev_name;\n+\tprevious_name_buf[0] = '\\0';\n \n \tstate = Start;\n \tthis_header = 0;\n@@ -577,6 +752,9 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)\n \tdir_utime();\n \t/* free any hardlink state collected without optional TRAILER!!! */\n \tfree_hash();\n+\tkfree(metadata_buf);\n+\tmetadata_buf = NULL;\n+\tmetadata_len = 0;\n \tkfree(bufs);\n \treturn message;\n }\ndiff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c\nindex 63b0cb957c6528..1403f56539734f 100644\n--- a/security/integrity/ima/ima_appraise.c\n+++ b/security/integrity/ima/ima_appraise.c\n@@ -20,6 +20,14 @@\n \n #include \"ima.h\"\n \n+static bool ima_initramfs_populated __ro_after_init =\n+\t!IS_ENABLED(CONFIG_BLK_DEV_INITRD);\n+\n+static void ima_notify_initramfs_populated(void)\n+{\n+\tima_initramfs_populated = true;\n+}\n+\n #ifdef CONFIG_IMA_APPRAISE_BOOTPARAM\n static char *ima_appraise_cmdline_default __initdata;\n core_param(ima_appraise, ima_appraise_cmdline_default, charp, 0);\n@@ -738,6 +746,22 @@ static int validate_hash_algo(struct dentry *dentry,\n \t\tif (likely(xattr_hash_algo == ima_hash_algo))\n \t\t\treturn 0;\n \n+\t\t/*\n+\t\t * IMA validates the crypto algorithm whenever the security.ima\n+\t\t * xattr is set. Restoring xattrs during initramfs unpacking\n+\t\t * can call crypto_has_alg() before unpacking has completed.\n+\t\t *\n+\t\t * If the algo is unavailable, crypto_has_alg() may\n+\t\t * synchronously request a module. The userspace helper waits\n+\t\t * for initramfs unpacking to finish and creates a circular\n+\t\t * dependency.\n+\t\t *\n+\t\t * Skip the algorithm availability check until initramfs is\n+\t\t * populated to avoid this deadlock.\n+\t\t */\n+\t\tif (!ima_initramfs_populated)\n+\t\t\treturn 0;\n+\n \t\t/* allow any xattr using an algorithm built in the kernel */\n \t\tif (crypto_has_alg(hash_algo_name[xattr_hash_algo], 0, 0))\n \t\t\treturn 0;\n@@ -829,6 +853,7 @@ static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(inode_set_acl, ima_inode_set_acl),\n \tLSM_HOOK_INIT(inode_removexattr, ima_inode_removexattr),\n \tLSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),\n+\tLSM_HOOK_INIT(initramfs_populated, ima_notify_initramfs_populated),\n };\n \n void __init init_ima_appraise_lsm(const struct lsm_id *lsmid)\ndiff --git a/usr/Kconfig b/usr/Kconfig\nindex 9279a2893ab0ee..135a9248bba267 100644\n--- a/usr/Kconfig\n+++ b/usr/Kconfig\n@@ -227,3 +227,22 @@ config INITRAMFS_COMPRESSION_NONE\n \t filesystem image will be present in memory simultaneously\n \n endchoice\n+\n+choice\n+\tprompt \"File metadata type\"\n+\tdefault INITRAMFS_FILE_METADATA_NONE\n+\thelp\n+\t Specify the metadata types to be included in the image.\n+\n+\t If you are not sure, leave unchanged.\n+\n+\tconfig INITRAMFS_FILE_METADATA_NONE\n+\t\tbool \"no xattrs (default)\"\n+\tconfig INITRAMFS_FILE_METADATA_XATTR\n+\t\tbool \"xattr\"\n+endchoice\n+\n+config INITRAMFS_FILE_METADATA\n+\tstring\n+\tdefault \"\" if INITRAMFS_FILE_METADATA_NONE\n+\tdefault \"xattr\" if INITRAMFS_FILE_METADATA_XATTR\ndiff --git a/usr/Makefile b/usr/Makefile\nindex e8f42478a0b765..dc4a1f4b3da213 100644\n--- a/usr/Makefile\n+++ b/usr/Makefile\n@@ -65,7 +65,8 @@ quiet_cmd_initfs = GEN $@\n \t$(addprefix -u , $(CONFIG_INITRAMFS_ROOT_UID)) \\\n \t$(addprefix -g , $(CONFIG_INITRAMFS_ROOT_GID)) \\\n \t$(if $(KBUILD_BUILD_TIMESTAMP), -d \"$(KBUILD_BUILD_TIMESTAMP)\") \\\n-\t$(ramfs-input)\n+\t$(if $(filter-out \"\",$(CONFIG_INITRAMFS_FILE_METADATA)), \\\n+\t -e $(CONFIG_INITRAMFS_FILE_METADATA)) $(ramfs-input)\n \n # We rebuild initramfs_data.cpio if:\n # 1) Any included file is newer than initramfs_data.cpio\ndiff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c\nindex b7296edc6626fb..64ac78e68087a1 100644\n--- a/usr/gen_init_cpio.c\n+++ b/usr/gen_init_cpio.c\n@@ -6,6 +6,7 @@\n #include \u003cstdbool.h\u003e\n #include \u003csys/types.h\u003e\n #include \u003csys/stat.h\u003e\n+#include \u003csys/xattr.h\u003e\n #include \u003cstring.h\u003e\n #include \u003cunistd.h\u003e\n #include \u003ctime.h\u003e\n@@ -14,6 +15,12 @@\n #include \u003cctype.h\u003e\n #include \u003climits.h\u003e\n \n+#ifndef __packed\n+#define __packed __attribute__((__packed__))\n+#endif\n+\n+#include \"../include/linux/initramfs.h\"\n+\n /*\n * Original work by Jeff Garzik\n *\n@@ -37,12 +44,126 @@ static bool do_file_mtime;\n static bool do_csum = false;\n static int outfd = STDOUT_FILENO;\n static unsigned int dalign;\n+static char metadata_path[] = \"/tmp/cpio-metadata-XXXXXX\";\n+static int metadata_fd = -1;\n \n struct file_handler {\n \tconst char *type;\n \tint (*handler)(const char *line);\n };\n \n+static enum metadata_types parse_metadata_type(char *arg)\n+{\n+\tstatic char *metadata_type_str[TYPE__LAST] = {\n+\t\t[TYPE_NONE] = \"none\",\n+\t\t[TYPE_XATTR] = \"xattr\",\n+\t};\n+\tint i;\n+\n+\tfor (i = 0; i \u003c TYPE__LAST; i++)\n+\t\tif (!strcmp(metadata_type_str[i], arg))\n+\t\t\treturn i;\n+\n+\treturn TYPE_NONE;\n+}\n+\n+static int cpio_mkfile(const char *name, const char *location,\n+\t\t unsigned int mode, uid_t uid, gid_t gid,\n+\t\t unsigned int nlinks);\n+\n+static char *cpio_replace_env(char *new_location);\n+\n+static int write_xattrs(const char *path)\n+{\n+\tstruct metadata_hdr hdr = { .c_version = 1, .c_type = TYPE_XATTR };\n+\tchar str[sizeof(hdr.c_size) + 1];\n+\tchar *xattr_list, *list_ptr;\n+\tchar *xattr_value = NULL;\n+\tssize_t list_len, name_len, value_len, len;\n+\tint ret = -EINVAL;\n+\n+\tif (metadata_fd \u003c 0 || !path)\n+\t\treturn 0;\n+\n+\tif (path == metadata_path)\n+\t\treturn 0;\n+\n+\tlist_len = llistxattr(path, NULL, 0);\n+\tif (list_len \u003c= 0)\n+\t\treturn 0;\n+\n+\tlist_ptr = xattr_list = malloc(list_len);\n+\tif (!list_ptr) {\n+\t\tfprintf(stderr, \"out of memory\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tlen = llistxattr(path, xattr_list, list_len);\n+\tif (len != list_len)\n+\t\tgoto out;\n+\n+\tif (ftruncate(metadata_fd, 0))\n+\t\tgoto out;\n+\n+\tlseek(metadata_fd, 0, SEEK_SET);\n+\n+\twhile (list_ptr \u003c xattr_list + list_len) {\n+\t\tname_len = strlen(list_ptr);\n+\n+\t\tvalue_len = lgetxattr(path, list_ptr, NULL, 0);\n+\t\tif (value_len \u003c 0) {\n+\t\t\tfprintf(stderr, \"cannot get xattrs\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (value_len) {\n+\t\t\txattr_value = malloc(value_len);\n+\t\t\tif (!xattr_value) {\n+\t\t\t\tfprintf(stderr, \"out of memory\\n\");\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t} else {\n+\t\t\txattr_value = NULL;\n+\t\t}\n+\n+\t\tlen = lgetxattr(path, list_ptr, xattr_value, value_len);\n+\t\tif (len != value_len)\n+\t\t\tbreak;\n+\n+\t\tsnprintf(str, sizeof(str), \"%.8zx\",\n+\t\t\t sizeof(hdr) + name_len + 1 + value_len);\n+\n+\t\tmemcpy(hdr.c_size, str, sizeof(hdr.c_size));\n+\n+\t\tif (write(metadata_fd, \u0026hdr, sizeof(hdr)) != sizeof(hdr))\n+\t\t\tbreak;\n+\n+\t\tif (write(metadata_fd, list_ptr, name_len + 1) != name_len + 1)\n+\t\t\tbreak;\n+\n+\t\tif (write(metadata_fd, xattr_value, value_len) != value_len)\n+\t\t\tbreak;\n+\n+\t\tif (fsync(metadata_fd))\n+\t\t\tbreak;\n+\n+\t\tlist_ptr += name_len + 1;\n+\t\tfree(xattr_value);\n+\t\txattr_value = NULL;\n+\t}\n+\n+\tfree(xattr_value);\n+out:\n+\tif (list_ptr != xattr_list + list_len) {\n+\t\tfree(xattr_list);\n+\t\treturn ret;\n+\t}\n+\n+\tfree(xattr_list);\n+\n+\treturn cpio_mkfile(METADATA_FILENAME, metadata_path, S_IFREG, 0, 0, 1);\n+}\n+\n static int push_buf(const char *name, size_t name_len)\n {\n \tssize_t len;\n@@ -119,7 +240,8 @@ static int cpio_trailer(void)\n }\n \n static int cpio_mkslink(const char *name, const char *target,\n-\t\t\t unsigned int mode, uid_t uid, gid_t gid)\n+\t\t\tconst char *location, unsigned int mode,\n+\t\t\tuid_t uid, gid_t gid)\n {\n \tint len;\n \tunsigned int namesize, targetsize = strlen(target) + 1;\n@@ -150,7 +272,8 @@ static int cpio_mkslink(const char *name, const char *target,\n \t push_buf(name, namesize) \u003c 0 ||\n \t push_pad(padlen(offset, 4)) \u003c 0 ||\n \t push_buf(target, targetsize) \u003c 0 ||\n-\t push_pad(padlen(offset, 4)) \u003c 0)\n+\t push_pad(padlen(offset, 4)) \u003c 0 ||\n+\t write_xattrs(location) \u003c 0)\n \t\treturn -1;\n \n \treturn 0;\n@@ -161,22 +284,29 @@ static int cpio_mkslink_line(const char *line)\n {\n \tchar name[PATH_MAX + 1];\n \tchar target[PATH_MAX + 1];\n+\tchar location[PATH_MAX + 1];\n \tunsigned int mode;\n \tint uid;\n \tint gid;\n+\tint nfields;\n \tint rc = -1;\n \n-\tif (5 != sscanf(line, \"%\" str(PATH_MAX) \"s %\" str(PATH_MAX) \"s %o %d %d\", name, target, \u0026mode, \u0026uid, \u0026gid)) {\n-\t\tfprintf(stderr, \"Unrecognized dir format '%s'\", line);\n+\tnfields = sscanf(line, \"%\" str(PATH_MAX) \"s %\" str(PATH_MAX)\n+\t\t\t \"s %o %d %d %\" str(PATH_MAX) \"s\",\n+\t\t\t name, target, \u0026mode, \u0026uid, \u0026gid, location);\n+\tif (nfields \u003c 5) {\n+\t\tfprintf(stderr, \"Unrecognized slink format '%s'\", line);\n \t\tgoto fail;\n \t}\n-\trc = cpio_mkslink(name, target, mode, uid, gid);\n+\trc = cpio_mkslink(name, target,\n+\t\t\t nfields == 6 ? cpio_replace_env(location) : NULL,\n+\t\t\t mode, uid, gid);\n fail:\n \treturn rc;\n }\n \n-static int cpio_mkgeneric(const char *name, unsigned int mode,\n-\t\t uid_t uid, gid_t gid)\n+static int cpio_mkgeneric(const char *name, const char *location,\n+\t\t\t unsigned int mode, uid_t uid, gid_t gid)\n {\n \tint len;\n \tunsigned int namesize;\n@@ -204,7 +334,8 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,\n \toffset += len;\n \n \tif (len != CPIO_HDR_LEN ||\n-\t push_rest(name, namesize) \u003c 0)\n+\t push_rest(name, namesize) \u003c 0 ||\n+\t write_xattrs(location) \u003c 0)\n \t\treturn -1;\n \n \treturn 0;\n@@ -239,18 +370,24 @@ static const struct generic_type generic_type_table[] = {\n static int cpio_mkgeneric_line(const char *line, enum generic_types gt)\n {\n \tchar name[PATH_MAX + 1];\n+\tchar location[PATH_MAX + 1];\n \tunsigned int mode;\n \tint uid;\n \tint gid;\n+\tint nfields;\n \tint rc = -1;\n \n-\tif (4 != sscanf(line, \"%\" str(PATH_MAX) \"s %o %d %d\", name, \u0026mode, \u0026uid, \u0026gid)) {\n+\tnfields = sscanf(line, \"%\" str(PATH_MAX) \"s %o %d %d %\"\n+\t\t\t str(PATH_MAX) \"s\", name, \u0026mode, \u0026uid, \u0026gid, location);\n+\tif (nfields \u003c 4) {\n \t\tfprintf(stderr, \"Unrecognized %s format '%s'\",\n-\t\t\tline, generic_type_table[gt].type);\n+\t\t\tgeneric_type_table[gt].type, line);\n \t\tgoto fail;\n \t}\n \tmode |= generic_type_table[gt].mode;\n-\trc = cpio_mkgeneric(name, mode, uid, gid);\n+\trc = cpio_mkgeneric(name,\n+\t\t\t nfields == 5 ? cpio_replace_env(location) : NULL,\n+\t\t\t mode, uid, gid);\n fail:\n \treturn rc;\n }\n@@ -270,9 +407,9 @@ static int cpio_mksock_line(const char *line)\n \treturn cpio_mkgeneric_line(line, GT_SOCK);\n }\n \n-static int cpio_mknod(const char *name, unsigned int mode,\n-\t\t uid_t uid, gid_t gid, char dev_type,\n-\t\t unsigned int maj, unsigned int min)\n+static int cpio_mknod(const char *name, const char *location,\n+\t\t unsigned int mode, uid_t uid, gid_t gid, char dev_type,\n+\t\t unsigned int maj, unsigned int min)\n {\n \tint len;\n \tunsigned int namesize;\n@@ -305,7 +442,8 @@ static int cpio_mknod(const char *name, unsigned int mode,\n \toffset += len;\n \n \tif (len != CPIO_HDR_LEN ||\n-\t push_rest(name, namesize) \u003c 0)\n+\t push_rest(name, namesize) \u003c 0 ||\n+\t write_xattrs(location) \u003c 0)\n \t\treturn -1;\n \n \treturn 0;\n@@ -314,20 +452,26 @@ static int cpio_mknod(const char *name, unsigned int mode,\n static int cpio_mknod_line(const char *line)\n {\n \tchar name[PATH_MAX + 1];\n+\tchar location[PATH_MAX + 1];\n \tunsigned int mode;\n \tint uid;\n \tint gid;\n \tchar dev_type;\n \tunsigned int maj;\n \tunsigned int min;\n+\tint nfields;\n \tint rc = -1;\n \n-\tif (7 != sscanf(line, \"%\" str(PATH_MAX) \"s %o %d %d %c %u %u\",\n-\t\t\t name, \u0026mode, \u0026uid, \u0026gid, \u0026dev_type, \u0026maj, \u0026min)) {\n+\tnfields = sscanf(line, \"%\" str(PATH_MAX) \"s %o %d %d %c %u %u %\"\n+\t\t\t str(PATH_MAX) \"s\", name, \u0026mode, \u0026uid, \u0026gid, \u0026dev_type,\n+\t\t\t \u0026maj, \u0026min, location);\n+\tif (nfields \u003c 7) {\n \t\tfprintf(stderr, \"Unrecognized nod format '%s'\", line);\n \t\tgoto fail;\n \t}\n-\trc = cpio_mknod(name, mode, uid, gid, dev_type, maj, min);\n+\trc = cpio_mknod(name,\n+\t\t\tnfields == 8 ? cpio_replace_env(location) : NULL,\n+\t\t\tmode, uid, gid, dev_type, maj, min);\n fail:\n \treturn rc;\n }\n@@ -490,7 +634,7 @@ static int cpio_mkfile(const char *name, const char *location,\n \t\tname += namesize;\n \t}\n \tino++;\n-\trc = 0;\n+\trc = write_xattrs(location);\n \n error:\n \tif (file \u003e= 0)\n@@ -570,22 +714,24 @@ static int cpio_mkfile_line(const char *line)\n static void usage(const char *prog)\n {\n \tfprintf(stderr, \"Usage:\\n\"\n-\t\t\"\\t%s [-t \u003ctimestamp\u003e] [-c] [-o \u003coutput_file\u003e] [-a \u003cdata_align\u003e] \u003ccpio_list\u003e\\n\"\n+\t\t\"\\t%s [-t \u003ctimestamp\u003e] [-c] [-o \u003coutput_file\u003e] [-a \u003cdata_align\u003e] [-e \u003ctype\u003e] \u003ccpio_list\u003e\\n\"\n \t\t\"\\n\"\n \t\t\"\u003ccpio_list\u003e is a file containing newline separated entries that\\n\"\n \t\t\"describe the files to be included in the initramfs archive:\\n\"\n \t\t\"\\n\"\n \t\t\"# a comment\\n\"\n \t\t\"file \u003cname\u003e \u003clocation\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e [\u003chard links\u003e]\\n\"\n-\t\t\"dir \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e\\n\"\n-\t\t\"nod \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e \u003cdev_type\u003e \u003cmaj\u003e \u003cmin\u003e\\n\"\n-\t\t\"slink \u003cname\u003e \u003ctarget\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e\\n\"\n-\t\t\"pipe \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e\\n\"\n-\t\t\"sock \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e\\n\"\n+\t\t\"dir \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e [\u003clocation\u003e]\\n\"\n+\t\t\"nod \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e \u003cdev_type\u003e \u003cmaj\u003e \u003cmin\u003e [\u003clocation\u003e]\\n\"\n+\t\t\"slink \u003cname\u003e \u003ctarget\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e [\u003clocation\u003e]\\n\"\n+\t\t\"pipe \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e [\u003clocation\u003e]\\n\"\n+\t\t\"sock \u003cname\u003e \u003cmode\u003e \u003cuid\u003e \u003cgid\u003e [\u003clocation\u003e]\\n\"\n \t\t\"\\n\"\n \t\t\"\u003cname\u003e name of the file/dir/nod/etc in the archive\\n\"\n \t\t\"\u003clocation\u003e location of the file in the current filesystem\\n\"\n \t\t\" expands shell variables quoted with ${}\\n\"\n+\t\t\" optional for nonregular entries; used to read xattrs\\n\"\n+\t\t\" with -e xattr. If omitted, no xattrs are included.\\n\"\n \t\t\"\u003ctarget\u003e link target\\n\"\n \t\t\"\u003cmode\u003e mode/permissions of the file\\n\"\n \t\t\"\u003cuid\u003e user id (0=root)\\n\"\n@@ -611,7 +757,8 @@ static void usage(const char *prog)\n \t\t\"\u003coutput_file\u003e: write cpio to this file instead of stdout\\n\"\n \t\t\"\u003cdata_align\u003e: attempt to align file data by zero-padding the\\n\"\n \t\t\"filename field up to data_align. Must be a multiple of 4.\\n\"\n-\t\t\"Alignment is best-effort; PATH_MAX limits filename padding.\\n\",\n+\t\t\"Alignment is best-effort; PATH_MAX limits filename padding.\\n\"\n+\t\t\"\u003ctype\u003e: include file metadata: none (default) or xattr.\\n\",\n \t\tprog);\n }\n \n@@ -640,7 +787,7 @@ static const struct file_handler file_handler_table[] = {\n \t}\n };\n \n-#define LINE_SIZE (2 * PATH_MAX + 50)\n+#define LINE_SIZE (3 * PATH_MAX + 50)\n \n int main (int argc, char *argv[])\n {\n@@ -650,10 +797,11 @@ int main (int argc, char *argv[])\n \tint ec = 0;\n \tint line_nr = 0;\n \tconst char *filename;\n+\tenum metadata_types metadata_type = TYPE_NONE;\n \n \tdefault_mtime = time(NULL);\n \twhile (1) {\n-\t\tint opt = getopt(argc, argv, \"t:cho:a:\");\n+\t\tint opt = getopt(argc, argv, \"t:e:cho:a:\");\n \t\tchar *invalid;\n \n \t\tif (opt == -1)\n@@ -669,6 +817,9 @@ int main (int argc, char *argv[])\n \t\t\t}\n \t\t\tdo_file_mtime = true;\n \t\t\tbreak;\n+\t\tcase 'e':\n+\t\t\tmetadata_type = parse_metadata_type(optarg);\n+\t\t\tbreak;\n \t\tcase 'c':\n \t\t\tdo_csum = true;\n \t\t\tbreak;\n@@ -721,6 +872,13 @@ int main (int argc, char *argv[])\n \t\tusage(argv[0]);\n \t\texit(1);\n \t}\n+\tif (metadata_type != TYPE_NONE) {\n+\t\tmetadata_fd = mkstemp(metadata_path);\n+\t\tif (metadata_fd \u003c 0) {\n+\t\t\tfprintf(stderr, \"cannot create temporary file\\n\");\n+\t\t\texit(1);\n+\t\t}\n+\t}\n \n \twhile (fgets(line, LINE_SIZE, cpio_list)) {\n \t\tint type_idx;\n@@ -777,5 +935,12 @@ int main (int argc, char *argv[])\n \tif (ec == 0)\n \t\tec = cpio_trailer();\n \n+\tif (metadata_type != TYPE_NONE) {\n+\t\tclose(metadata_fd);\n+\t\tif (unlink(metadata_path))\n+\t\t\tfprintf(stderr,\n+\t\t\t\t\"warning: cannot remove temporary file %s: %s\\n\",\n+\t\t\t\tmetadata_path, strerror(errno));\n+\t}\n \texit(ec);\n }\ndiff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh\nindex 7eba2fddf0ef2e..fea88d761d6276 100755\n--- a/usr/gen_initramfs.sh\n+++ b/usr/gen_initramfs.sh\n@@ -14,7 +14,7 @@ set -e\n usage() {\n cat \u003c\u003c EOF\n Usage:\n-$0 [-o \u003cfile\u003e] [-l \u003cdep_list\u003e] [-u \u003cuid\u003e] [-g \u003cgid\u003e] {-d | \u003ccpio_source\u003e} ...\n+$0 [-o \u003cfile\u003e] [-l \u003cdep_list\u003e] [-u \u003cuid\u003e] [-g \u003cgid\u003e] {-d | \u003ccpio_source\u003e} [-e \u003ctype\u003e]...\n \t-o \u003cfile\u003e Create initramfs file named \u003cfile\u003e by using gen_init_cpio\n \t-l \u003cdep_list\u003e Create dependency list named \u003cdep_list\u003e\n \t-u \u003cuid\u003e User ID to map to user ID 0 (root).\n@@ -27,6 +27,7 @@ $0 [-o \u003cfile\u003e] [-l \u003cdep_list\u003e] [-u \u003cuid\u003e] [-g \u003cgid\u003e] {-d | \u003ccpio_source\u003e} ...\n \t\u003ccpio_source\u003e File list or directory for cpio archive.\n \t\t If \u003ccpio_source\u003e is a .cpio file it will be used\n \t\t as direct input to initramfs.\n+\t-e \u003ctype\u003e File metadata type to include in the cpio archive.\n \n All options except -o and -l may be repeated and are interpreted\n sequentially and immediately. -u and -g states are preserved across\n@@ -113,14 +114,14 @@ parse() {\n \n \t\t\t[ -b \"${location}\" ] \u0026\u0026 dev=\"b\" || dev=\"c\"\n \n-\t\t\tstr=\"${ftype} ${name} ${str} ${dev} ${maj} ${min}\"\n+\t\t\tstr=\"${ftype} ${name} ${str} ${dev} ${maj} ${min} ${location}\"\n \t\t\t;;\n \t\t\"slink\")\n \t\t\tlocal target=`readlink \"${location}\"`\n-\t\t\tstr=\"${ftype} ${name} ${target} ${str}\"\n+\t\t\tstr=\"${ftype} ${name} ${target} ${str} ${location}\"\n \t\t\t;;\n \t\t*)\n-\t\t\tstr=\"${ftype} ${name} ${str}\"\n+\t\t\tstr=\"${ftype} ${name} ${str} ${location}\"\n \t\t\t;;\n \tesac\n \n@@ -228,6 +229,10 @@ while [ $# -gt 0 ]; do\n \t\t\tfi\n \t\t\tshift\n \t\t\t;;\n+\t\t\"-e\") # file metadata type\n+\t\t\tmetadata_arg=\"-e $1\"\n+\t\t\tshift\n+\t\t\t;;\n \t\t\"-h\")\n \t\t\tusage\n \t\t\texit 0\n@@ -247,4 +252,4 @@ done\n \n # If output_file is set we will generate cpio archive\n # we are careful to delete tmp files\n-usr/gen_init_cpio $output $timestamp $cpio_list\n+usr/gen_init_cpio $output $metadata_arg $timestamp $cpio_list\n"
} |
| 2/1 | 2026/11/08 18:00 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series adds support for file metadata (extended attributes) in the initramfs:\n1. The changes in usr/ (gen_init_cpio.c, gen_initramfs.sh, Kconfig, Makefile) modify host-side user-space build tools used during kernel compilation to generate the cpio archive.\n2. The modifications in init/initramfs.c affect only early boot functions marked __init and __initdata (do_header, do_name, do_collect_metadata, do_setxattrs, unpack_to_rootfs, etc.), which execute strictly before userspace launches and are unmapped and freed by free_initmem() prior to any fuzzing activity.\n3. The change in security/integrity/ima/ima_appraise.c introduces an early-boot check `if (!ima_initramfs_populated) return 0;` guarded by a variable set to true before userspace starts and marked __ro_after_init, making this path completely dead and unreachable at runtime.\n\nBecause none of the modified code is reachable by userspace syscall fuzzing in a running kernel, the patch series does not warrant fuzzing.",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any '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: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 1ab5c708719e3bd26c954e1a6ab9145624353146
Author: syz-cluster <triage@syzkaller.com>
Date: Sun Nov 8 18:00:15 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/initramfs.h b/include/linux/initramfs.h
new file mode 100644
index 00000000000000..9b3839dc88a1e0
--- /dev/null
+++ b/include/linux/initramfs.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Include file for file metadata in the initial ram disk.
+ */
+#ifndef _LINUX_INITRAMFS_H
+#define _LINUX_INITRAMFS_H
+
+#define METADATA_FILENAME "METADATA!!!"
+
+enum metadata_types { TYPE_NONE, TYPE_XATTR, TYPE__LAST };
+
+struct metadata_hdr {
+ char c_size[8]; /* total size including c_size field */
+ char c_version; /* header version */
+ char c_type; /* metadata type */
+ char c_metadata[]; /* metadata */
+} __packed;
+
+#endif /*LINUX_INITRAMFS_H*/
diff --git a/init/initramfs.c b/init/initramfs.c
index ebddde9c8f0d91..a17c26fde5f573 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -10,7 +10,9 @@
#include <linux/hex.h>
#include <linux/init.h>
#include <linux/init_syscalls.h>
+#include <linux/initramfs.h>
#include <linux/kstrtox.h>
+#include <linux/limits.h>
#include <linux/memblock.h>
#include <linux/mm.h>
#include <linux/namei.h>
@@ -22,6 +24,7 @@
#include <linux/types.h>
#include <linux/umh.h>
#include <linux/utime.h>
+#include <linux/xattr.h>
#include <asm/byteorder.h>
@@ -31,6 +34,17 @@
static __initdata bool csum_present;
static __initdata u32 io_csum;
+static void __init update_csum(const unsigned char *buf, size_t len)
+{
+ size_t i;
+
+ if (!csum_present)
+ return;
+
+ for (i = 0; i < len; i++)
+ io_csum += buf[i];
+}
+
static ssize_t __init xwrite(struct file *file, const unsigned char *p,
size_t count, loff_t *pos)
{
@@ -47,12 +61,7 @@ static ssize_t __init xwrite(struct file *file, const unsigned char *p,
} else if (rv == 0)
break;
- if (csum_present) {
- ssize_t i;
-
- for (i = 0; i < rv; i++)
- io_csum += p[i];
- }
+ update_csum(p, rv);
p += rv;
out += rv;
@@ -189,7 +198,7 @@ static __initdata time64_t mtime;
static __initdata unsigned long ino, major, minor, nlink;
static __initdata umode_t mode;
-static __initdata unsigned long body_len, name_len;
+static __initdata unsigned long body_len, name_len, metadata_len;
static __initdata uid_t uid;
static __initdata gid_t gid;
static __initdata unsigned rdev;
@@ -230,6 +239,7 @@ static __initdata enum state {
SkipIt,
GotName,
CopyFile,
+ CollectMetadata,
GotSymlink,
Reset
} state, next_state;
@@ -263,7 +273,8 @@ static void __init read_into(char *buf, unsigned size, enum state next)
}
}
-static __initdata char *header_buf, *symlink_buf, *name_buf;
+static __initdata char *header_buf, *symlink_buf, *name_buf, *previous_name_buf;
+static __initdata char *metadata_buf;
static int __init do_start(void)
{
@@ -304,10 +315,10 @@ static int __init do_header(void)
next_header = (next_header + 3) & ~3;
state = SkipIt;
if (name_len <= 0 || name_len > PATH_MAX)
- return 0;
+ goto skip;
if (S_ISLNK(mode)) {
if (body_len > PATH_MAX)
- return 0;
+ goto skip;
collect = collected = symlink_buf;
remains = N_ALIGN(name_len) + body_len;
next_state = GotSymlink;
@@ -316,6 +327,11 @@ static int __init do_header(void)
}
if (S_ISREG(mode) || !body_len)
read_into(name_buf, N_ALIGN(name_len), GotName);
+ else
+ goto skip;
+ return 0;
+skip:
+ previous_name_buf[0] = '\0';
return 0;
}
@@ -365,11 +381,110 @@ static int __init maybe_link(void)
return 0;
}
+static int __init do_setxattrs(char *pathname, char *buf, size_t size)
+{
+ struct path path;
+ char *xattr_name, *xattr_value;
+ u32 xattr_name_size, xattr_value_size;
+ int ret;
+
+ xattr_name = buf;
+ xattr_name_size = strnlen(xattr_name, size);
+ if (xattr_name_size == size) {
+ error("malformed xattrs");
+ return -EINVAL;
+ }
+
+ if (!xattr_name_size || xattr_name_size > XATTR_NAME_MAX) {
+ error("invalid xattr name length");
+ return -EINVAL;
+ }
+
+ xattr_value = xattr_name + xattr_name_size + 1;
+ xattr_value_size = buf + size - xattr_value;
+ if (xattr_value_size > XATTR_SIZE_MAX) {
+ error("xattr value exceeds size limit");
+ return -EINVAL;
+ }
+
+ ret = kern_path(pathname, 0, &path);
+ if (!ret) {
+ /*
+ * POSIX ACL restoration is currently unsupported.
+ * vfs_setxattr() rejects POSIX ACL xattrs with -EOPNOTSUPP.
+ */
+ ret = vfs_setxattr(&nop_mnt_idmap, path.dentry, xattr_name, xattr_value,
+ xattr_value_size, 0);
+
+ path_put(&path);
+ }
+
+ pr_debug("%s: %s size: %u (ret: %d)\n", pathname, xattr_name,
+ xattr_value_size, ret);
+ print_hex_dump_debug("xattr value: ", DUMP_PREFIX_OFFSET,
+ 16, 1, xattr_value, xattr_value_size, false);
+
+ return ret;
+}
+
+static int __init __maybe_unused do_parse_metadata(char *pathname)
+{
+ char *buf = metadata_buf;
+ char *bufend = metadata_buf + metadata_len;
+ struct metadata_hdr *hdr;
+ char str[sizeof(hdr->c_size) + 1];
+ u32 entry_size;
+
+ if (!metadata_len)
+ return 0;
+
+ str[sizeof(hdr->c_size)] = 0;
+
+ while (buf < bufend) {
+ int ret;
+
+ if (bufend - buf < sizeof(*hdr)) {
+ error("malformed metadata");
+ break;
+ }
+
+ hdr = (struct metadata_hdr *)buf;
+ if (hdr->c_version != 1) {
+ pr_debug("Unsupported header version\n");
+ break;
+ }
+
+ memcpy(str, hdr->c_size, sizeof(hdr->c_size));
+ ret = kstrtou32(str, 16, &entry_size);
+ if (ret || entry_size < sizeof(*hdr) ||
+ entry_size > bufend - buf) {
+ error("malformed xattrs");
+ break;
+ }
+
+ switch (hdr->c_type) {
+ case TYPE_XATTR:
+ do_setxattrs(pathname, buf + sizeof(*hdr),
+ entry_size - sizeof(*hdr));
+ break;
+ default:
+ pr_debug("Unsupported metadata type\n");
+ break;
+ }
+
+ buf += entry_size;
+ }
+
+ return 0;
+}
+
static __initdata struct file *wfile;
static __initdata loff_t wfile_pos;
static int __init do_name(void)
{
+ bool target_ready = false;
+
state = SkipIt;
next_state = Reset;
@@ -381,6 +496,19 @@ static int __init do_name(void)
return 1;
}
+ if (S_ISREG(mode) && strcmp(collected, METADATA_FILENAME) == 0) {
+ metadata_len = body_len;
+ if (metadata_len)
+ metadata_buf = kmalloc(metadata_len, GFP_KERNEL);
+ else
+ metadata_buf = NULL;
+ io_csum = 0;
+ state = CollectMetadata;
+ return 0;
+ }
+
+ /* Clear metadata target only after checking entry is not metadata */
+ previous_name_buf[0] = '\0';
if (strcmp(collected, "TRAILER!!!") == 0) {
free_hash();
return 0;
@@ -403,24 +531,65 @@ static int __init do_name(void)
if (body_len)
vfs_truncate(&wfile->f_path, body_len);
state = CopyFile;
+ target_ready = true;
}
} else if (S_ISDIR(mode)) {
- init_mkdir(collected, mode);
+ int ret = init_mkdir(collected, mode);
+
+ target_ready = !ret || ret == -EEXIST;
init_chown(collected, uid, gid, 0);
init_chmod(collected, mode);
dir_add(collected, name_len, mtime);
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
S_ISFIFO(mode) || S_ISSOCK(mode)) {
- if (maybe_link() == 0) {
- init_mknod(collected, mode, rdev);
+ int ml = maybe_link();
+
+ if (ml == 0) {
+ int ret = init_mknod(collected, mode, rdev);
+
+ target_ready = !ret || ret == -EEXIST;
init_chown(collected, uid, gid, 0);
init_chmod(collected, mode);
do_utime(collected, mtime);
+ } else if (ml == 1) {
+ target_ready = true;
}
}
+ if (target_ready)
+ memcpy(previous_name_buf, collected, strlen(collected) + 1);
return 0;
}
+static void __init do_process_metadata(const char *buf, size_t len)
+{
+ /* Still checksum the body if allocation failed. */
+ update_csum((const unsigned char *)buf, len);
+ if (metadata_buf)
+ memcpy(metadata_buf + (metadata_len - body_len), buf, len);
+}
+
+static int __init do_collect_metadata(void)
+{
+ if (byte_count >= body_len) {
+ do_process_metadata(victim, body_len);
+ if (csum_present && io_csum != hdr_csum)
+ error("bad data checksum");
+ else if (metadata_buf && previous_name_buf[0])
+ do_parse_metadata(previous_name_buf);
+ kfree(metadata_buf);
+ metadata_buf = NULL;
+ metadata_len = 0;
+ eat(body_len);
+ state = SkipIt;
+ return 0;
+ }
+
+ do_process_metadata(victim, byte_count);
+ body_len -= byte_count;
+ eat(byte_count);
+ return 1;
+}
+
static int __init do_copy(void)
{
if (byte_count >= body_len) {
@@ -445,6 +614,7 @@ static int __init do_copy(void)
static int __init do_symlink(void)
{
+ previous_name_buf[0] = '\0';
if (collected[name_len - 1] != '\0') {
pr_err("initramfs symlink without nulterm: %.*s\n",
(int)name_len, collected);
@@ -453,7 +623,8 @@ static int __init do_symlink(void)
}
collected[N_ALIGN(name_len) + body_len] = '\0';
clean_path(collected, 0);
- init_symlink(collected + N_ALIGN(name_len), collected);
+ if (!init_symlink(collected + N_ALIGN(name_len), collected))
+ memcpy(previous_name_buf, collected, strlen(collected) + 1);
init_chown(collected, uid, gid, AT_SYMLINK_NOFOLLOW);
do_utime(collected, mtime);
state = SkipIt;
@@ -468,6 +639,7 @@ static __initdata int (*actions[])(void) = {
[SkipIt] = do_skip,
[GotName] = do_name,
[CopyFile] = do_copy,
+ [CollectMetadata] = do_collect_metadata,
[GotSymlink] = do_symlink,
[Reset] = do_reset,
};
@@ -527,6 +699,7 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)
char header[CPIO_HDRLEN];
char symlink[PATH_MAX + N_ALIGN(PATH_MAX) + 1];
char name[N_ALIGN(PATH_MAX)];
+ char prev_name[PATH_MAX + N_ALIGN(PATH_MAX) + 1];
} *bufs = kmalloc_obj(*bufs);
if (!bufs)
@@ -535,6 +708,8 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)
header_buf = bufs->header;
symlink_buf = bufs->symlink;
name_buf = bufs->name;
+ previous_name_buf = bufs->prev_name;
+ previous_name_buf[0] = '\0';
state = Start;
this_header = 0;
@@ -577,6 +752,9 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)
dir_utime();
/* free any hardlink state collected without optional TRAILER!!! */
free_hash();
+ kfree(metadata_buf);
+ metadata_buf = NULL;
+ metadata_len = 0;
kfree(bufs);
return message;
}
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 63b0cb957c6528..1403f56539734f 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -20,6 +20,14 @@
#include "ima.h"
+static bool ima_initramfs_populated __ro_after_init =
+ !IS_ENABLED(CONFIG_BLK_DEV_INITRD);
+
+static void ima_notify_initramfs_populated(void)
+{
+ ima_initramfs_populated = true;
+}
+
#ifdef CONFIG_IMA_APPRAISE_BOOTPARAM
static char *ima_appraise_cmdline_default __initdata;
core_param(ima_appraise, ima_appraise_cmdline_default, charp, 0);
@@ -738,6 +746,22 @@ static int validate_hash_algo(struct dentry *dentry,
if (likely(xattr_hash_algo == ima_hash_algo))
return 0;
+ /*
+ * IMA validates the crypto algorithm whenever the security.ima
+ * xattr is set. Restoring xattrs during initramfs unpacking
+ * can call crypto_has_alg() before unpacking has completed.
+ *
+ * If the algo is unavailable, crypto_has_alg() may
+ * synchronously request a module. The userspace helper waits
+ * for initramfs unpacking to finish and creates a circular
+ * dependency.
+ *
+ * Skip the algorithm availability check until initramfs is
+ * populated to avoid this deadlock.
+ */
+ if (!ima_initramfs_populated)
+ return 0;
+
/* allow any xattr using an algorithm built in the kernel */
if (crypto_has_alg(hash_algo_name[xattr_hash_algo], 0, 0))
return 0;
@@ -829,6 +853,7 @@ static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {
LSM_HOOK_INIT(inode_set_acl, ima_inode_set_acl),
LSM_HOOK_INIT(inode_removexattr, ima_inode_removexattr),
LSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),
+ LSM_HOOK_INIT(initramfs_populated, ima_notify_initramfs_populated),
};
void __init init_ima_appraise_lsm(const struct lsm_id *lsmid)
diff --git a/usr/Kconfig b/usr/Kconfig
index 9279a2893ab0ee..135a9248bba267 100644
--- a/usr/Kconfig
+++ b/usr/Kconfig
@@ -227,3 +227,22 @@ config INITRAMFS_COMPRESSION_NONE
filesystem image will be present in memory simultaneously
endchoice
+
+choice
+ prompt "File metadata type"
+ default INITRAMFS_FILE_METADATA_NONE
+ help
+ Specify the metadata types to be included in the image.
+
+ If you are not sure, leave unchanged.
+
+ config INITRAMFS_FILE_METADATA_NONE
+ bool "no xattrs (default)"
+ config INITRAMFS_FILE_METADATA_XATTR
+ bool "xattr"
+endchoice
+
+config INITRAMFS_FILE_METADATA
+ string
+ default "" if INITRAMFS_FILE_METADATA_NONE
+ default "xattr" if INITRAMFS_FILE_METADATA_XATTR
diff --git a/usr/Makefile b/usr/Makefile
index e8f42478a0b765..dc4a1f4b3da213 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -65,7 +65,8 @@ quiet_cmd_initfs = GEN $@
$(addprefix -u , $(CONFIG_INITRAMFS_ROOT_UID)) \
$(addprefix -g , $(CONFIG_INITRAMFS_ROOT_GID)) \
$(if $(KBUILD_BUILD_TIMESTAMP), -d "$(KBUILD_BUILD_TIMESTAMP)") \
- $(ramfs-input)
+ $(if $(filter-out "",$(CONFIG_INITRAMFS_FILE_METADATA)), \
+ -e $(CONFIG_INITRAMFS_FILE_METADATA)) $(ramfs-input)
# We rebuild initramfs_data.cpio if:
# 1) Any included file is newer than initramfs_data.cpio
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index b7296edc6626fb..64ac78e68087a1 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -6,6 +6,7 @@
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/xattr.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
@@ -14,6 +15,12 @@
#include <ctype.h>
#include <limits.h>
+#ifndef __packed
+#define __packed __attribute__((__packed__))
+#endif
+
+#include "../include/linux/initramfs.h"
+
/*
* Original work by Jeff Garzik
*
@@ -37,12 +44,126 @@ static bool do_file_mtime;
static bool do_csum = false;
static int outfd = STDOUT_FILENO;
static unsigned int dalign;
+static char metadata_path[] = "/tmp/cpio-metadata-XXXXXX";
+static int metadata_fd = -1;
struct file_handler {
const char *type;
int (*handler)(const char *line);
};
+static enum metadata_types parse_metadata_type(char *arg)
+{
+ static char *metadata_type_str[TYPE__LAST] = {
+ [TYPE_NONE] = "none",
+ [TYPE_XATTR] = "xattr",
+ };
+ int i;
+
+ for (i = 0; i < TYPE__LAST; i++)
+ if (!strcmp(metadata_type_str[i], arg))
+ return i;
+
+ return TYPE_NONE;
+}
+
+static int cpio_mkfile(const char *name, const char *location,
+ unsigned int mode, uid_t uid, gid_t gid,
+ unsigned int nlinks);
+
+static char *cpio_replace_env(char *new_location);
+
+static int write_xattrs(const char *path)
+{
+ struct metadata_hdr hdr = { .c_version = 1, .c_type = TYPE_XATTR };
+ char str[sizeof(hdr.c_size) + 1];
+ char *xattr_list, *list_ptr;
+ char *xattr_value = NULL;
+ ssize_t list_len, name_len, value_len, len;
+ int ret = -EINVAL;
+
+ if (metadata_fd < 0 || !path)
+ return 0;
+
+ if (path == metadata_path)
+ return 0;
+
+ list_len = llistxattr(path, NULL, 0);
+ if (list_len <= 0)
+ return 0;
+
+ list_ptr = xattr_list = malloc(list_len);
+ if (!list_ptr) {
+ fprintf(stderr, "out of memory\n");
+ return ret;
+ }
+
+ len = llistxattr(path, xattr_list, list_len);
+ if (len != list_len)
+ goto out;
+
+ if (ftruncate(metadata_fd, 0))
+ goto out;
+
+ lseek(metadata_fd, 0, SEEK_SET);
+
+ while (list_ptr < xattr_list + list_len) {
+ name_len = strlen(list_ptr);
+
+ value_len = lgetxattr(path, list_ptr, NULL, 0);
+ if (value_len < 0) {
+ fprintf(stderr, "cannot get xattrs\n");
+ break;
+ }
+
+ if (value_len) {
+ xattr_value = malloc(value_len);
+ if (!xattr_value) {
+ fprintf(stderr, "out of memory\n");
+ break;
+ }
+ } else {
+ xattr_value = NULL;
+ }
+
+ len = lgetxattr(path, list_ptr, xattr_value, value_len);
+ if (len != value_len)
+ break;
+
+ snprintf(str, sizeof(str), "%.8zx",
+ sizeof(hdr) + name_len + 1 + value_len);
+
+ memcpy(hdr.c_size, str, sizeof(hdr.c_size));
+
+ if (write(metadata_fd, &hdr, sizeof(hdr)) != sizeof(hdr))
+ break;
+
+ if (write(metadata_fd, list_ptr, name_len + 1) != name_len + 1)
+ break;
+
+ if (write(metadata_fd, xattr_value, value_len) != value_len)
+ break;
+
+ if (fsync(metadata_fd))
+ break;
+
+ list_ptr += name_len + 1;
+ free(xattr_value);
+ xattr_value = NULL;
+ }
+
+ free(xattr_value);
+out:
+ if (list_ptr != xattr_list + list_len) {
+ free(xattr_list);
+ return ret;
+ }
+
+ free(xattr_list);
+
+ return cpio_mkfile(METADATA_FILENAME, metadata_path, S_IFREG, 0, 0, 1);
+}
+
static int push_buf(const char *name, size_t name_len)
{
ssize_t len;
@@ -119,7 +240,8 @@ static int cpio_trailer(void)
}
static int cpio_mkslink(const char *name, const char *target,
- unsigned int mode, uid_t uid, gid_t gid)
+ const char *location, unsigned int mode,
+ uid_t uid, gid_t gid)
{
int len;
unsigned int namesize, targetsize = strlen(target) + 1;
@@ -150,7 +272,8 @@ static int cpio_mkslink(const char *name, const char *target,
push_buf(name, namesize) < 0 ||
push_pad(padlen(offset, 4)) < 0 ||
push_buf(target, targetsize) < 0 ||
- push_pad(padlen(offset, 4)) < 0)
+ push_pad(padlen(offset, 4)) < 0 ||
+ write_xattrs(location) < 0)
return -1;
return 0;
@@ -161,22 +284,29 @@ static int cpio_mkslink_line(const char *line)
{
char name[PATH_MAX + 1];
char target[PATH_MAX + 1];
+ char location[PATH_MAX + 1];
unsigned int mode;
int uid;
int gid;
+ int nfields;
int rc = -1;
- if (5 != sscanf(line, "%" str(PATH_MAX) "s %" str(PATH_MAX) "s %o %d %d", name, target, &mode, &uid, &gid)) {
- fprintf(stderr, "Unrecognized dir format '%s'", line);
+ nfields = sscanf(line, "%" str(PATH_MAX) "s %" str(PATH_MAX)
+ "s %o %d %d %" str(PATH_MAX) "s",
+ name, target, &mode, &uid, &gid, location);
+ if (nfields < 5) {
+ fprintf(stderr, "Unrecognized slink format '%s'", line);
goto fail;
}
- rc = cpio_mkslink(name, target, mode, uid, gid);
+ rc = cpio_mkslink(name, target,
+ nfields == 6 ? cpio_replace_env(location) : NULL,
+ mode, uid, gid);
fail:
return rc;
}
-static int cpio_mkgeneric(const char *name, unsigned int mode,
- uid_t uid, gid_t gid)
+static int cpio_mkgeneric(const char *name, const char *location,
+ unsigned int mode, uid_t uid, gid_t gid)
{
int len;
unsigned int namesize;
@@ -204,7 +334,8 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,
offset += len;
if (len != CPIO_HDR_LEN ||
- push_rest(name, namesize) < 0)
+ push_rest(name, namesize) < 0 ||
+ write_xattrs(location) < 0)
return -1;
return 0;
@@ -239,18 +370,24 @@ static const struct generic_type generic_type_table[] = {
static int cpio_mkgeneric_line(const char *line, enum generic_types gt)
{
char name[PATH_MAX + 1];
+ char location[PATH_MAX + 1];
unsigned int mode;
int uid;
int gid;
+ int nfields;
int rc = -1;
- if (4 != sscanf(line, "%" str(PATH_MAX) "s %o %d %d", name, &mode, &uid, &gid)) {
+ nfields = sscanf(line, "%" str(PATH_MAX) "s %o %d %d %"
+ str(PATH_MAX) "s", name, &mode, &uid, &gid, location);
+ if (nfields < 4) {
fprintf(stderr, "Unrecognized %s format '%s'",
- line, generic_type_table[gt].type);
+ generic_type_table[gt].type, line);
goto fail;
}
mode |= generic_type_table[gt].mode;
- rc = cpio_mkgeneric(name, mode, uid, gid);
+ rc = cpio_mkgeneric(name,
+ nfields == 5 ? cpio_replace_env(location) : NULL,
+ mode, uid, gid);
fail:
return rc;
}
@@ -270,9 +407,9 @@ static int cpio_mksock_line(const char *line)
return cpio_mkgeneric_line(line, GT_SOCK);
}
-static int cpio_mknod(const char *name, unsigned int mode,
- uid_t uid, gid_t gid, char dev_type,
- unsigned int maj, unsigned int min)
+static int cpio_mknod(const char *name, const char *location,
+ unsigned int mode, uid_t uid, gid_t gid, char dev_type,
+ unsigned int maj, unsigned int min)
{
int len;
unsigned int namesize;
@@ -305,7 +442,8 @@ static int cpio_mknod(const char *name, unsigned int mode,
offset += len;
if (len != CPIO_HDR_LEN ||
- push_rest(name, namesize) < 0)
+ push_rest(name, namesize) < 0 ||
+ write_xattrs(location) < 0)
return -1;
return 0;
@@ -314,20 +452,26 @@ static int cpio_mknod(const char *name, unsigned int mode,
static int cpio_mknod_line(const char *line)
{
char name[PATH_MAX + 1];
+ char location[PATH_MAX + 1];
unsigned int mode;
int uid;
int gid;
char dev_type;
unsigned int maj;
unsigned int min;
+ int nfields;
int rc = -1;
- if (7 != sscanf(line, "%" str(PATH_MAX) "s %o %d %d %c %u %u",
- name, &mode, &uid, &gid, &dev_type, &maj, &min)) {
+ nfields = sscanf(line, "%" str(PATH_MAX) "s %o %d %d %c %u %u %"
+ str(PATH_MAX) "s", name, &mode, &uid, &gid, &dev_type,
+ &maj, &min, location);
+ if (nfields < 7) {
fprintf(stderr, "Unrecognized nod format '%s'", line);
goto fail;
}
- rc = cpio_mknod(name, mode, uid, gid, dev_type, maj, min);
+ rc = cpio_mknod(name,
+ nfields == 8 ? cpio_replace_env(location) : NULL,
+ mode, uid, gid, dev_type, maj, min);
fail:
return rc;
}
@@ -490,7 +634,7 @@ static int cpio_mkfile(const char *name, const char *location,
name += namesize;
}
ino++;
- rc = 0;
+ rc = write_xattrs(location);
error:
if (file >= 0)
@@ -570,22 +714,24 @@ static int cpio_mkfile_line(const char *line)
static void usage(const char *prog)
{
fprintf(stderr, "Usage:\n"
- "\t%s [-t <timestamp>] [-c] [-o <output_file>] [-a <data_align>] <cpio_list>\n"
+ "\t%s [-t <timestamp>] [-c] [-o <output_file>] [-a <data_align>] [-e <type>] <cpio_list>\n"
"\n"
"<cpio_list> is a file containing newline separated entries that\n"
"describe the files to be included in the initramfs archive:\n"
"\n"
"# a comment\n"
"file <name> <location> <mode> <uid> <gid> [<hard links>]\n"
- "dir <name> <mode> <uid> <gid>\n"
- "nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>\n"
- "slink <name> <target> <mode> <uid> <gid>\n"
- "pipe <name> <mode> <uid> <gid>\n"
- "sock <name> <mode> <uid> <gid>\n"
+ "dir <name> <mode> <uid> <gid> [<location>]\n"
+ "nod <name> <mode> <uid> <gid> <dev_type> <maj> <min> [<location>]\n"
+ "slink <name> <target> <mode> <uid> <gid> [<location>]\n"
+ "pipe <name> <mode> <uid> <gid> [<location>]\n"
+ "sock <name> <mode> <uid> <gid> [<location>]\n"
"\n"
"<name> name of the file/dir/nod/etc in the archive\n"
"<location> location of the file in the current filesystem\n"
" expands shell variables quoted with ${}\n"
+ " optional for nonregular entries; used to read xattrs\n"
+ " with -e xattr. If omitted, no xattrs are included.\n"
"<target> link target\n"
"<mode> mode/permissions of the file\n"
"<uid> user id (0=root)\n"
@@ -611,7 +757,8 @@ static void usage(const char *prog)
"<output_file>: write cpio to this file instead of stdout\n"
"<data_align>: attempt to align file data by zero-padding the\n"
"filename field up to data_align. Must be a multiple of 4.\n"
- "Alignment is best-effort; PATH_MAX limits filename padding.\n",
+ "Alignment is best-effort; PATH_MAX limits filename padding.\n"
+ "<type>: include file metadata: none (default) or xattr.\n",
prog);
}
@@ -640,7 +787,7 @@ static const struct file_handler file_handler_table[] = {
}
};
-#define LINE_SIZE (2 * PATH_MAX + 50)
+#define LINE_SIZE (3 * PATH_MAX + 50)
int main (int argc, char *argv[])
{
@@ -650,10 +797,11 @@ int main (int argc, char *argv[])
int ec = 0;
int line_nr = 0;
const char *filename;
+ enum metadata_types metadata_type = TYPE_NONE;
default_mtime = time(NULL);
while (1) {
- int opt = getopt(argc, argv, "t:cho:a:");
+ int opt = getopt(argc, argv, "t:e:cho:a:");
char *invalid;
if (opt == -1)
@@ -669,6 +817,9 @@ int main (int argc, char *argv[])
}
do_file_mtime = true;
break;
+ case 'e':
+ metadata_type = parse_metadata_type(optarg);
+ break;
case 'c':
do_csum = true;
break;
@@ -721,6 +872,13 @@ int main (int argc, char *argv[])
usage(argv[0]);
exit(1);
}
+ if (metadata_type != TYPE_NONE) {
+ metadata_fd = mkstemp(metadata_path);
+ if (metadata_fd < 0) {
+ fprintf(stderr, "cannot create temporary file\n");
+ exit(1);
+ }
+ }
while (fgets(line, LINE_SIZE, cpio_list)) {
int type_idx;
@@ -777,5 +935,12 @@ int main (int argc, char *argv[])
if (ec == 0)
ec = cpio_trailer();
+ if (metadata_type != TYPE_NONE) {
+ close(metadata_fd);
+ if (unlink(metadata_path))
+ fprintf(stderr,
+ "warning: cannot remove temporary file %s: %s\n",
+ metadata_path, strerror(errno));
+ }
exit(ec);
}
diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
index 7eba2fddf0ef2e..fea88d761d6276 100755
--- a/usr/gen_initramfs.sh
+++ b/usr/gen_initramfs.sh
@@ -14,7 +14,7 @@ set -e
usage() {
cat << EOF
Usage:
-$0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
+$0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} [-e <type>]...
-o <file> Create initramfs file named <file> by using gen_init_cpio
-l <dep_list> Create dependency list named <dep_list>
-u <uid> User ID to map to user ID 0 (root).
@@ -27,6 +27,7 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
<cpio_source> File list or directory for cpio archive.
If <cpio_source> is a .cpio file it will be used
as direct input to initramfs.
+ -e <type> File metadata type to include in the cpio archive.
All options except -o and -l may be repeated and are interpreted
sequentially and immediately. -u and -g states are preserved across
@@ -113,14 +114,14 @@ parse() {
[ -b "${location}" ] && dev="b" || dev="c"
- str="${ftype} ${name} ${str} ${dev} ${maj} ${min}"
+ str="${ftype} ${name} ${str} ${dev} ${maj} ${min} ${location}"
;;
"slink")
local target=`readlink "${location}"`
- str="${ftype} ${name} ${target} ${str}"
+ str="${ftype} ${name} ${target} ${str} ${location}"
;;
*)
- str="${ftype} ${name} ${str}"
+ str="${ftype} ${name} ${str} ${location}"
;;
esac
@@ -228,6 +229,10 @@ while [ $# -gt 0 ]; do
fi
shift
;;
+ "-e") # file metadata type
+ metadata_arg="-e $1"
+ shift
+ ;;
"-h")
usage
exit 0
@@ -247,4 +252,4 @@ done
# If output_file is set we will generate cpio archive
# we are careful to delete tmp files
-usr/gen_init_cpio $output $timestamp $cpio_list
+usr/gen_init_cpio $output $metadata_arg $timestamp $cpio_list
|
| 3/2 | 2026/11/08 18:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13897 output: 20 thoughts: 283 Thoughts: **Kernel Patch Series Evaluation for Syzkaller Fuzzing** Okay, so they want me to take a look at this kernel patch series and decide if it's worth the effort of fuzzing with syzkaller. Sounds straightforward, but I know the drill. My primary concern, as always, is *reachability*. Syzkaller is great, but it's only going to find bugs in code that actually *runs* in our standard fuzzing environment (GCE or QEMU, probably emulated devices like USB gadgets, netdev, and tun/tap). If the modified code is structurally unreachable, we're wasting everyone's time, including the syzkaller bot's resources. I'm not going to blindly trust any "no functional change" statements. I've seen enough "minor" changes cause major headaches to know better. New or modified assertions in reachable code? Absolutely, those *demand* fuzzing. Those are little landmines just waiting to be triggered. Now, let's get into the negative criteria. Anything non-kernel or non-executable (usr/, tools/, etc.) is an automatic "no". Also, any code that can't be reached in the fuzzing environment needs to be disregarded. For example, is the initramfs parsing reachable from userspace during fuzzing? This is a crucial question. Can `unpack_to_rootfs` or the initramfs code be reached at runtime by syzkaller / userspace? I need to check where `unpack_to_rootfs` is called. Can initramfs be loaded via syscalls or sysfs or anything exploitable? Let's search for `unpack_to_rootfs` or any runtime callers of initramfs unpacking. That's the key. |
| 4/2 | 2026/11/08 18:00 | tool | grepper |
0mArgs:{
"Expression": "unpack_to_rootfs"
}Results: {
"Output": "init/initramfs.c=680=static unsigned long my_inptr __initdata; /* index of next byte to be processed in inbuf */\n--\ninit/initramfs.c-684-/**\ninit/initramfs.c:685: * unpack_to_rootfs - decompress and extract an initramfs archive\ninit/initramfs.c-686- * @buf: input initramfs archive to extract\n--\ninit/initramfs.c-692- */\ninit/initramfs.c:693:char * __init unpack_to_rootfs(char *buf, unsigned long len)\ninit/initramfs.c-694-{\n--\ninit/initramfs.c=899=static void __init unpack_initramfs(async_cookie_t cookie)\n--\ninit/initramfs.c-901-\t/* Load the built in initramfs */\ninit/initramfs.c:902:\tchar *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);\ninit/initramfs.c-903-\tif (err)\n--\ninit/initramfs.c-913-\ninit/initramfs.c:914:\terr = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start);\ninit/initramfs.c-915-\tif (err) {\n--\ninit/initramfs_internal.h-4-\ninit/initramfs_internal.h:5:char *unpack_to_rootfs(char *buf, unsigned long len);\ninit/initramfs_internal.h-6-#define CPIO_HDRLEN 110\n--\ninit/initramfs_test.c=78=static void __init initramfs_test_extract(struct kunit *test)\n--\ninit/initramfs_test.c-120-\tktime_get_real_ts64(\u0026ts_before);\ninit/initramfs_test.c:121:\terr = unpack_to_rootfs(cpio_srcbuf, len);\ninit/initramfs_test.c-122-\tktime_get_real_ts64(\u0026ts_after);\n--\ninit/initramfs_test.c=161=static void __init initramfs_test_fname_overrun(struct kunit *test)\n--\ninit/initramfs_test.c-200-\ninit/initramfs_test.c:201:\terr = unpack_to_rootfs(cpio_srcbuf, len);\ninit/initramfs_test.c-202-\tKUNIT_EXPECT_NOT_NULL(test, err);\n--\ninit/initramfs_test.c=207=static void __init initramfs_test_data(struct kunit *test)\n--\ninit/initramfs_test.c-236-\ninit/initramfs_test.c:237:\terr = unpack_to_rootfs(cpio_srcbuf, len);\ninit/initramfs_test.c-238-\tKUNIT_EXPECT_NULL(test, err);\n--\ninit/initramfs_test.c=257=static void __init initramfs_test_csum(struct kunit *test)\n--\ninit/initramfs_test.c-291-\ninit/initramfs_test.c:292:\terr = unpack_to_rootfs(cpio_srcbuf, len);\ninit/initramfs_test.c-293-\tKUNIT_EXPECT_NULL(test, err);\n--\ninit/initramfs_test.c-301-\ninit/initramfs_test.c:302:\terr = unpack_to_rootfs(cpio_srcbuf, len);\ninit/initramfs_test.c-303-\tKUNIT_EXPECT_NOT_NULL(test, err);\n--\ninit/initramfs_test.c=318=static void __init initramfs_test_hardlink(struct kunit *test)\n--\ninit/initramfs_test.c-347-\ninit/initramfs_test.c:348:\terr = unpack_to_rootfs(cpio_srcbuf, len);\ninit/initramfs_test.c-349-\tKUNIT_EXPECT_NULL(test, err);\n--\ninit/initramfs_test.c=366=static void __init initramfs_test_many(struct kunit *test)\n--\ninit/initramfs_test.c-390-\tlen = p - cpio_srcbuf;\ninit/initramfs_test.c:391:\terr = unpack_to_rootfs(cpio_srcbuf, len);\ninit/initramfs_test.c-392-\tKUNIT_EXPECT_NULL(test, err);\n--\ninit/initramfs_test.c=410=static void __init initramfs_test_fname_pad(struct kunit *test)\n--\ninit/initramfs_test.c-442-\ninit/initramfs_test.c:443:\terr = unpack_to_rootfs(tbufs-\u003ecpio_srcbuf, len);\ninit/initramfs_test.c-444-\tKUNIT_EXPECT_NULL(test, err);\n--\ninit/initramfs_test.c=463=static void __init initramfs_test_fname_path_max(struct kunit *test)\n--\ninit/initramfs_test.c-499-\t/* unpack skips over fname_oversize instead of returning an error */\ninit/initramfs_test.c:500:\terr = unpack_to_rootfs(tbufs-\u003ecpio_src, len);\ninit/initramfs_test.c-501-\tKUNIT_EXPECT_NULL(test, err);\n--\ninit/initramfs_test.c=510=static void __init initramfs_test_hdr_hex(struct kunit *test)\n--\ninit/initramfs_test.c-542-\ninit/initramfs_test.c:543:\terr = unpack_to_rootfs(tbufs-\u003ecpio_src, len);\ninit/initramfs_test.c-544-\tKUNIT_EXPECT_NOT_NULL(test, err);\n--\ninit/initramfs_test.c=566=static int __init initramfs_suite_init(struct kunit_suite *suite)\n--\ninit/initramfs_test.c-568-\t/*\ninit/initramfs_test.c:569:\t * unpack_to_rootfs() uses module-static state (victim, byte_count,\ninit/initramfs_test.c-570-\t * state, ...). The boot-time async do_populate_rootfs() may still be\ninit/initramfs_test.c:571:\t * running, so wait for it to finish before we call unpack_to_rootfs()\ninit/initramfs_test.c-572-\t * from the test thread, otherwise the two writers race and crash.\n"
} |
| 5/2 | 2026/11/08 18:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16356 output: 40 thoughts: 1002 Thoughts: **Analyzing Initramfs and IMA Changes for Security Implications** Okay, so I'm looking at this diff and immediately I see `unpack_to_rootfs` has an `__init` attribute. Naturally, my first instinct is to check all the functions in `init/initramfs.c`, and, as expected, they are all marked as `__init`. This triggers my memory of how the kernel manages `__init` functions and data. After boot, specifically after userspace starts, but crucially *before* any fuzzing, `free_initmem()` unmaps and frees all memory in the `.init.text` and `.init.data` sections. This means that *all* of the code related to initramfs unpacking, including `unpack_to_rootfs` itself, is gone before syzkaller, or any user-space process, even has a chance to execute. This immediately tells me that direct invocation via syscall, ioctl, or netlink of anything marked `__init` is impossible because it's been freed. It also means, implicitly, that any vulnerability within that code is likely to be very difficult to exploit since it will require a very specific, and possibly timing-dependent, trigger during early boot. Then, I shifted my focus to the other modified files. I see the header file (`include/linux/initramfs.h`) which defines structures and constants, and the initramfs unpacking logic in `init/initramfs.c`, which is all `__init` as expected. The files in `usr/` are just build-time tooling, so they are not directly relevant to runtime behavior. The real interesting point is the change in `security/integrity/ima/ima_appraise.c`. Let me dive in further! The key is the `ima_initramfs_populated` flag. This flag is being set by the `ima_notify_initramfs_populated` function, which is registered as an LSM hook. The purpose of this change is to *defer* certain IMA checks until *after* the initramfs has been unpacked. It does this because restoring extended attributes (xattrs) during initramfs unpacking can lead to issues with IMA's algorithm checks. The critical line is that `validate_hash_algo()`'s checks are skipped if `ima_initramfs_populated` is false. Specifically, the `crypto_has_alg()` call, which potentially requests a module, can be synchronous. If this request happens *before* initramfs is unpacked, it can lead to a deadlock. So the intention is to avoid the deadlock by delaying the IMA checks. Now, it is important to analyze how `validate_hash_algo()` is called. If its caller has other preconditions that would not happen during early boot, then its invocation is not as sensitive. Otherwise, we'll need to look at how the hooks are initialized, and where else in the kernel `validate_hash_algo()` is invoked. The goal is to see if any runtime conditions during syzkaller's execution are affected by this deferred check. We have to analyze the calling paths and conditions to confirm whether it introduces any new exploitable surface. |
| 6/2 | 2026/11/08 18:00 | tool | read-file |
0mArgs:{
"File": "security/integrity/ima/ima_appraise.c",
"FirstLine": 725,
"LineCount": 50
}Results: {
"Contents": " 725:\t\tchar *path = NULL, *pathbuf = NULL;\n 726:\t\tenum hash_algo xattr_hash_algo;\n 727:\t\tconst char *errmsg = \"unavailable-hash-algorithm\";\n 728:\t\tunsigned int allowed_hashes;\n 729:\t\n 730:\t\txattr_hash_algo = ima_get_hash_algo(xattr_value, xattr_value_len);\n 731:\t\n 732:\t\tallowed_hashes = atomic_read(\u0026ima_setxattr_allowed_hash_algorithms);\n 733:\t\n 734:\t\tif (allowed_hashes) {\n 735:\t\t\t/* success if the algorithm is allowed in the ima policy */\n 736:\t\t\tif (allowed_hashes \u0026 (1U \u003c\u003c xattr_hash_algo))\n 737:\t\t\t\treturn 0;\n 738:\t\n 739:\t\t\t/*\n 740:\t\t\t * We use a different audit message when the hash algorithm\n 741:\t\t\t * is denied by a policy rule, instead of not being built\n 742:\t\t\t * in the kernel image\n 743:\t\t\t */\n 744:\t\t\terrmsg = \"denied-hash-algorithm\";\n 745:\t\t} else {\n 746:\t\t\tif (likely(xattr_hash_algo == ima_hash_algo))\n 747:\t\t\t\treturn 0;\n 748:\t\n 749:\t\t\t/*\n 750:\t\t\t * IMA validates the crypto algorithm whenever the security.ima\n 751:\t\t\t * xattr is set. Restoring xattrs during initramfs unpacking\n 752:\t\t\t * can call crypto_has_alg() before unpacking has completed.\n 753:\t\t\t *\n 754:\t\t\t * If the algo is unavailable, crypto_has_alg() may\n 755:\t\t\t * synchronously request a module. The userspace helper waits\n 756:\t\t\t * for initramfs unpacking to finish and creates a circular\n 757:\t\t\t * dependency.\n 758:\t\t\t *\n 759:\t\t\t * Skip the algorithm availability check until initramfs is\n 760:\t\t\t * populated to avoid this deadlock.\n 761:\t\t\t */\n 762:\t\t\tif (!ima_initramfs_populated)\n 763:\t\t\t\treturn 0;\n 764:\t\n 765:\t\t\t/* allow any xattr using an algorithm built in the kernel */\n 766:\t\t\tif (crypto_has_alg(hash_algo_name[xattr_hash_algo], 0, 0))\n 767:\t\t\t\treturn 0;\n 768:\t\t}\n 769:\t\n 770:\t\tpathbuf = kmalloc(PATH_MAX, GFP_KERNEL);\n 771:\t\tif (!pathbuf)\n 772:\t\t\treturn -EACCES;\n 773:\t\n 774:\t\tpath = dentry_path(dentry, pathbuf, PATH_MAX);\n"
} |
| 7/2 | 2026/11/08 18:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18830 output: 19 thoughts: 110 Thoughts: **Investigating the IMA Initramfs Appraisal** Okay, let's dive into this IMA initramfs situation. I'm starting by examining `security/integrity/ima/ima_appraise.c`. I see `ima_initramfs_populated` is initially set to the opposite of `CONFIG_BLK_DEV_INITRD`, which makes sense. I understand that the logic assumes that when the initramfs is actually populated, `ima_notify_initramfs_populated()` flips the `ima_initramfs_populated` flag to true. Now the million-dollar question: where *is* that `initramfs_populated` hook actually getting called? I need to find the specific Security Module hook to understand how the system knows the initramfs is loaded. It is time to execute the command: grep for a call such as `security_initramfs_populated`, or some equivalent LSM-specific function. That should lead me to the relevant kernel code where this all ties together. |
| 8/2 | 2026/11/08 18:00 | tool | grepper |
0mArgs:{
"Expression": "initramfs_populated"
}Results: {
"Output": "include/linux/lsm_hook_defs.h=470=LSM_HOOK(int, 0, uring_allowed, void)\n--\ninclude/linux/lsm_hook_defs.h-472-\ninclude/linux/lsm_hook_defs.h:473:LSM_HOOK(void, LSM_RET_VOID, initramfs_populated, void)\ninclude/linux/lsm_hook_defs.h-474-\n--\ninclude/linux/security.h=2427=static inline int security_uring_allowed(void)\n--\ninclude/linux/security.h-2434-#ifdef CONFIG_SECURITY\ninclude/linux/security.h:2435:extern void security_initramfs_populated(void);\ninclude/linux/security.h-2436-#else\ninclude/linux/security.h:2437:static inline void security_initramfs_populated(void)\ninclude/linux/security.h-2438-{\n--\ninit/initramfs.c=924=static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)\n--\ninit/initramfs.c-927-\t\tunpack_initramfs(cookie);\ninit/initramfs.c:928:\t\tsecurity_initramfs_populated();\ninit/initramfs.c-929-\t}\n--\nsecurity/integrity/ima/ima_appraise.c-22-\nsecurity/integrity/ima/ima_appraise.c:23:static bool ima_initramfs_populated __ro_after_init =\nsecurity/integrity/ima/ima_appraise.c-24-\t!IS_ENABLED(CONFIG_BLK_DEV_INITRD);\nsecurity/integrity/ima/ima_appraise.c-25-\nsecurity/integrity/ima/ima_appraise.c:26:static void ima_notify_initramfs_populated(void)\nsecurity/integrity/ima/ima_appraise.c-27-{\nsecurity/integrity/ima/ima_appraise.c:28:\tima_initramfs_populated = true;\nsecurity/integrity/ima/ima_appraise.c-29-}\n--\nsecurity/integrity/ima/ima_appraise.c=721=static int validate_hash_algo(struct dentry *dentry,\n--\nsecurity/integrity/ima/ima_appraise.c-761-\t\t */\nsecurity/integrity/ima/ima_appraise.c:762:\t\tif (!ima_initramfs_populated)\nsecurity/integrity/ima/ima_appraise.c-763-\t\t\treturn 0;\n--\nsecurity/integrity/ima/ima_appraise.c=850=static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {\n--\nsecurity/integrity/ima/ima_appraise.c-855-\tLSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),\nsecurity/integrity/ima/ima_appraise.c:856:\tLSM_HOOK_INIT(initramfs_populated, ima_notify_initramfs_populated),\nsecurity/integrity/ima/ima_appraise.c-857-};\n--\nsecurity/ipe/ipe.c=48=static struct security_hook_list ipe_hooks[] __ro_after_init = {\n--\nsecurity/ipe/ipe.c-54-\tLSM_HOOK_INIT(kernel_load_data, ipe_kernel_load_data),\nsecurity/ipe/ipe.c:55:\tLSM_HOOK_INIT(initramfs_populated, ipe_unpack_initramfs),\nsecurity/ipe/ipe.c-56-#ifdef CONFIG_IPE_PROP_DM_VERITY\n--\nsecurity/security.c=5703=int security_uring_allowed(void)\n--\nsecurity/security.c-5709-/**\nsecurity/security.c:5710: * security_initramfs_populated() - Notify LSMs that initramfs has been loaded\nsecurity/security.c-5711- *\n--\nsecurity/security.c-5713- */\nsecurity/security.c:5714:void security_initramfs_populated(void)\nsecurity/security.c-5715-{\nsecurity/security.c:5716:\tcall_void_hook(initramfs_populated);\nsecurity/security.c-5717-}\n"
} |
| 9/2 | 2026/11/08 18:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20270 output: 41 thoughts: 457 Thoughts: **My Analysis of `ima_initramfs_populated`** Okay, let's break this down. I'm looking at how `ima_initramfs_populated` is being used and it's starting to click. I see that `do_populate_rootfs()` calls `security_initramfs_populated()`. And that function, crucially, sets `ima_initramfs_populated` to `true`. The important thing is the timing. Userspace starts, and therefore Syzkaller starts, *after* `security_initramfs_populated()` has already been called. That means `ima_initramfs_populated` is *already* true when the fuzzer gets going. So, when Syzkaller runs, the check `if (!ima_initramfs_populated) return 0;` will *never* evaluate to true at runtime. Never! Because `ima_initramfs_populated` was set in the early boot sequence by `do_populate_rootfs()`. And further, the variable is `__ro_after_init`. Once the system is up, it's read-only and *always* true. Now, wait a second... Can `security_initramfs_populated()` ever be called after boot? No, that's right. `do_populate_rootfs` is part of the `__init` sequence, so it's only called during kernel initialization, well before PID 1 is even launched. Hold on a sec, can `ima_initramfs_populated` even start as false? It's initialized to `!IS_ENABLED(CONFIG_BLK_DEV_INITRD)` and then set to `true` at boot, no matter what. If the config option is not enabled, then it starts true. If enabled, it is set to true when the initramfs is populated. But...wait... what about `init/initramfs.c`? Is anything in there even called during runtime? I need to verify that and see if anything non-`__init` is in there. Let me inspect `init/initramfs.c` to be certain. |
| 10/2 | 2026/11/08 18:00 | tool | grepper |
0mArgs:{
"Expression": "^[a-zA-Z0-9_].*\\(",
"PathPrefixes": [
"init/initramfs.c"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 215 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (1 files in total):\ninit/initramfs.c:55\n\ninit/initramfs.c=35=static __initdata u32 io_csum;\ninit/initramfs.c-36-\ninit/initramfs.c:37:static void __init update_csum(const unsigned char *buf, size_t len)\ninit/initramfs.c-38-{\n--\ninit/initramfs.c-47-\ninit/initramfs.c:48:static ssize_t __init xwrite(struct file *file, const unsigned char *p,\ninit/initramfs.c-49-\t\tsize_t count, loff_t *pos)\n--\ninit/initramfs.c=74=static __initdata char *message;\ninit/initramfs.c:75:static void __init error(char *x)\ninit/initramfs.c-76-{\n--\ninit/initramfs.c=94=static __initdata bool hardlink_seen;\ninit/initramfs.c-95-\ninit/initramfs.c:96:static inline int hash(int major, int minor, int ino)\ninit/initramfs.c-97-{\n--\ninit/initramfs.c-102-\ninit/initramfs.c:103:static char __init *find_link(int major, int minor, int ino,\ninit/initramfs.c-104-\t\t\t umode_t mode, const char *name, size_t nlen)\n--\ninit/initramfs.c-132-\ninit/initramfs.c:133:static void __init free_hash(void)\ninit/initramfs.c-134-{\n--\ninit/initramfs.c-146-#ifdef CONFIG_INITRAMFS_PRESERVE_MTIME\ninit/initramfs.c:147:static void __init do_utime(char *filename, time64_t mtime)\ninit/initramfs.c-148-{\n--\ninit/initramfs.c-152-\ninit/initramfs.c:153:static void __init do_utime_path(const struct path *path, time64_t mtime)\ninit/initramfs.c-154-{\n--\ninit/initramfs.c-158-\ninit/initramfs.c:159:static __initdata LIST_HEAD(dir_list);\ninit/initramfs.c-160-struct dir_entry {\n--\ninit/initramfs.c-165-\ninit/initramfs.c:166:static void __init dir_add(const char *name, size_t nlen, time64_t mtime)\ninit/initramfs.c-167-{\n--\ninit/initramfs.c-178-\ninit/initramfs.c:179:static void __init dir_utime(void)\ninit/initramfs.c-180-{\n--\ninit/initramfs.c-188-#else\ninit/initramfs.c:189:static void __init do_utime(char *filename, time64_t mtime) {}\ninit/initramfs.c:190:static void __init do_utime_path(const struct path *path, time64_t mtime) {}\ninit/initramfs.c:191:static void __init dir_add(const char *name, size_t nlen, time64_t mtime) {}\ninit/initramfs.c:192:static void __init dir_utime(void) {}\ninit/initramfs.c-193-#endif\n--\ninit/initramfs.c=205=static __initdata u32 hdr_csum;\ninit/initramfs.c-206-\ninit/initramfs.c:207:static int __init parse_header(char *s)\ninit/initramfs.c-208-{\n--\ninit/initramfs.c=249=static __initdata loff_t this_header, next_header;\ninit/initramfs.c-250-\ninit/initramfs.c:251:static inline void __init eat(unsigned n)\ninit/initramfs.c-252-{\n--\ninit/initramfs.c=260=static __initdata char *collect;\ninit/initramfs.c-261-\ninit/initramfs.c:262:static void __init read_into(char *buf, unsigned size, enum state next)\ninit/initramfs.c-263-{\n--\ninit/initramfs.c=277=static __initdata char *metadata_buf;\ninit/initramfs.c-278-\ninit/initramfs.c:279:static int __init do_start(void)\ninit/initramfs.c-280-{\n--\ninit/initramfs.c-284-\ninit/initramfs.c:285:static int __init do_collect(void)\ninit/initramfs.c-286-{\n--\ninit/initramfs.c-298-\ninit/initramfs.c:299:static int __init do_header(void)\ninit/initramfs.c-300-{\n--\ninit/initramfs.c-337-\ninit/initramfs.c:338:static int __init do_skip(void)\ninit/initramfs.c-339-{\n--\ninit/initramfs.c-349-\ninit/initramfs.c:350:static int __init do_reset(void)\ninit/initramfs.c-351-{\n--\ninit/initramfs.c-358-\ninit/initramfs.c:359:static void __init clean_path(char *path, umode_t fmode)\ninit/initramfs.c-360-{\n--\ninit/initramfs.c-371-\ninit/initramfs.c:372:static int __init maybe_link(void)\ninit/initramfs.c-373-{\n--\ninit/initramfs.c-383-\ninit/initramfs.c:384:static int __init do_setxattrs(char *pathname, char *buf, size_t size)\ninit/initramfs.c-385-{\n--\ninit/initramfs.c-429-\ninit/initramfs.c:430:static int __init __maybe_unused do_parse_metadata(char *pathname)\ninit/initramfs.c-431-{\n--\ninit/initramfs.c=482=static __initdata loff_t wfile_pos;\ninit/initramfs.c-483-\ninit/initramfs.c:484:static int __init do_name(void)\ninit/initramfs.c-485-{\n--\ninit/initramfs.c-562-\ninit/initramfs.c:563:static void __init do_process_metadata(const char *buf, size_t len)\ninit/initramfs.c-564-{\n--\ninit/initramfs.c-570-\ninit/initramfs.c:571:static int __init do_collect_metadata(void)\ninit/initramfs.c-572-{\n--\ninit/initramfs.c-592-\ninit/initramfs.c:593:static int __init do_copy(void)\ninit/initramfs.c-594-{\n--\ninit/initramfs.c-614-\ninit/initramfs.c:615:static int __init do_symlink(void)\ninit/initramfs.c-616-{\n--\ninit/initramfs.c-634-\ninit/initramfs.c:635:static __initdata int (*actions[])(void) = {\ninit/initramfs.c-636-\t[Start]\t\t= do_start,\n--\ninit/initramfs.c-646-\ninit/initramfs.c:647:static long __init write_buffer(char *buf, unsigned long len)\ninit/initramfs.c-648-{\n--\ninit/initramfs.c-656-\ninit/initramfs.c:657:static long __init flush_buffer(void *bufv, unsigned long len)\ninit/initramfs.c-658-{\n--\ninit/initramfs.c=680=static unsigned long my_inptr __initdata; /* index of next byte to be processed in inbuf */\n--\ninit/initramfs.c-692- */\ninit/initramfs.c:693:char * __init unpack_to_rootfs(char *buf, unsigned long len)\ninit/initramfs.c-694-{\n--\ninit/initramfs.c=762=static int __initdata do_retain_initrd;\ninit/initramfs.c-763-\ninit/initramfs.c:764:static int __init retain_initrd_param(char *str)\ninit/initramfs.c-765-{\n--\ninit/initramfs.c-770-}\ninit/initramfs.c:771:__setup(\"retain_initrd\", retain_initrd_param);\ninit/initramfs.c-772-\ninit/initramfs.c-773-#ifdef CONFIG_ARCH_HAS_KEEPINITRD\ninit/initramfs.c:774:static int __init keepinitrd_setup(char *__unused)\ninit/initramfs.c-775-{\n--\ninit/initramfs.c-778-}\ninit/initramfs.c:779:__setup(\"keepinitrd\", keepinitrd_setup);\ninit/initramfs.c-780-#endif\n--\ninit/initramfs.c=782=static bool __initdata initramfs_async = true;\ninit/initramfs.c:783:static int __init initramfs_async_setup(char *str)\ninit/initramfs.c-784-{\n--\ninit/initramfs.c-786-}\ninit/initramfs.c:787:__setup(\"initramfs_async=\", initramfs_async_setup);\ninit/initramfs.c-788-\n--\ninit/initramfs.c=790=extern unsigned long __initramfs_size;\n--\ninit/initramfs.c-793-\ninit/initramfs.c:794:static BIN_ATTR(initrd, 0440, sysfs_bin_attr_simple_read, NULL, 0);\ninit/initramfs.c-795-\ninit/initramfs.c:796:void __init reserve_initrd_mem(void)\ninit/initramfs.c-797-{\n--\ninit/initramfs.c-840-\ninit/initramfs.c:841:void __weak __init free_initrd_mem(unsigned long start, unsigned long end)\ninit/initramfs.c-842-{\n--\ninit/initramfs.c-847-#ifdef CONFIG_CRASH_RESERVE\ninit/initramfs.c:848:static bool __init kexec_free_initrd(void)\ninit/initramfs.c-849-{\n--\ninit/initramfs.c-870-#else\ninit/initramfs.c:871:static inline bool kexec_free_initrd(void)\ninit/initramfs.c-872-{\n--\ninit/initramfs.c-877-#ifdef CONFIG_BLK_DEV_RAM\ninit/initramfs.c:878:static void __init populate_initrd_image(char *err)\ninit/initramfs.c-879-{\n--\ninit/initramfs.c-898-\ninit/initramfs.c:899:static void __init unpack_initramfs(async_cookie_t cookie)\ninit/initramfs.c-900-{\n--\ninit/initramfs.c-923-\ninit/initramfs.c:924:static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)\ninit/initramfs.c-925-{\n--\n\n"
} |
| 11/2 | 2026/11/08 18:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24409 output: 35 thoughts: 22 Thoughts: Okay, let's dive into this. Here's my take on those lines: **Analyzing `initramfs.c` from Line 925 Onward** Right, so I'm focusing in on `init/initramfs.c`, specifically from line 925 to the end. I know this section is crucial for understanding how the initial RAM filesystem is set up, so I'll need to piece together the later stages of its initialization. I'm expecting this part deals with things like mounting the root filesystem from the initramfs, setting up essential devices, and probably handing off control to the real root file system at the end. I'm looking for where the root filesystem is mounted and how it's handled. Maybe I'll also see some device-specific setup as well. Let's see what gems are waiting to be uncovered! |
| 12/2 | 2026/11/08 18:00 | tool | read-file |
0mArgs:{
"File": "init/initramfs.c",
"FirstLine": 920,
"LineCount": 60
}Results: {
"Contents": " 920:\t#endif\n 921:\t\t}\n 922:\t}\n 923:\t\n 924:\tstatic void __init do_populate_rootfs(void *unused, async_cookie_t cookie)\n 925:\t{\n 926:\t\tscoped_with_init_fs() {\n 927:\t\t\tunpack_initramfs(cookie);\n 928:\t\t\tsecurity_initramfs_populated();\n 929:\t\t}\n 930:\t\n 931:\t\t/*\n 932:\t\t * If the initrd region is overlapped with crashkernel reserved region,\n 933:\t\t * free only memory that is not part of crashkernel region.\n 934:\t\t */\n 935:\t\tif (!do_retain_initrd \u0026\u0026 initrd_start \u0026\u0026 !kexec_free_initrd()) {\n 936:\t\t\tfree_initrd_mem(initrd_start, initrd_end);\n 937:\t\t} else if (do_retain_initrd \u0026\u0026 initrd_start) {\n 938:\t\t\tbin_attr_initrd.size = initrd_end - initrd_start;\n 939:\t\t\tbin_attr_initrd.private = (void *)initrd_start;\n 940:\t\t\tif (sysfs_create_bin_file(firmware_kobj, \u0026bin_attr_initrd))\n 941:\t\t\t\tpr_err(\"Failed to create initrd sysfs file\");\n 942:\t\t}\n 943:\t\tinitrd_start = 0;\n 944:\t\tinitrd_end = 0;\n 945:\t\n 946:\t\tinit_flush_fput();\n 947:\t}\n 948:\t\n 949:\tstatic ASYNC_DOMAIN_EXCLUSIVE(initramfs_domain);\n 950:\tstatic async_cookie_t initramfs_cookie;\n 951:\t\n 952:\tvoid wait_for_initramfs(void)\n 953:\t{\n 954:\t\tif (!initramfs_cookie) {\n 955:\t\t\t/*\n 956:\t\t\t * Something before rootfs_initcall wants to access\n 957:\t\t\t * the filesystem/initramfs. Probably a bug. Make a\n 958:\t\t\t * note, avoid deadlocking the machine, and let the\n 959:\t\t\t * caller's access fail as it used to.\n 960:\t\t\t */\n 961:\t\t\tpr_warn_once(\"wait_for_initramfs() called before rootfs_initcalls\\n\");\n 962:\t\t\treturn;\n 963:\t\t}\n 964:\t\tasync_synchronize_cookie_domain(initramfs_cookie + 1, \u0026initramfs_domain);\n 965:\t}\n 966:\tEXPORT_SYMBOL_GPL(wait_for_initramfs);\n 967:\t\n 968:\tstatic int __init populate_rootfs(void)\n 969:\t{\n 970:\t\tinitramfs_cookie = async_schedule_domain(do_populate_rootfs, NULL,\n 971:\t\t\t\t\t\t\t \u0026initramfs_domain);\n 972:\t\tusermodehelper_enable();\n 973:\t\tif (!initramfs_async)\n 974:\t\t\twait_for_initramfs();\n 975:\t\treturn 0;\n 976:\t}\n 977:\trootfs_initcall(populate_rootfs);\n"
} |
| 13/2 | 2026/11/08 18:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25553 output: 23 thoughts: 1703 Thoughts: **WorthFuzzing Analysis: Initramfs and IMA Appraisals** Okay, let's break this down. First, I see a patch modifying several functions in `init/initramfs.c`: `update_csum`, `xwrite`, `do_header`, and so on, all the way to `unpack_to_rootfs`. But hold on, all of these are marked `__init`. This means they're executed *only* during the kernel's initial boot sequence, before userspace is even up and running. Syzkaller runs in userspace, sending syscalls. By definition, syzkaller *cannot* execute any `__init` code because that memory is freed before syzkaller even gets a chance to breathe. It's physically impossible. Plus, there's no runtime syscall or interface to unpack an initramfs. Now, could kexec be relevant here? I need to check. A quick grep shows that `unpack_to_rootfs` is only called within the initramfs code itself or in KUnit tests, which are also `__init`. So, that's a dead end. And syzkaller doesn't fuzz KUnit tests. Alright, let's step back and consider the reachability criteria. Syzkaller operates in standard, emulated environments, so any code structurally unreachable in those environments shouldn't be fuzzed. Early boot code, like those `__init` functions, falls squarely into that category. It's executed and freed before syzkaller can even dream of interacting with it. Then, there's the change in `security/integrity/ima/ima_appraise.c`. Let's dig in. I see `ima_initramfs_populated`, initialized to false if `CONFIG_BLK_DEV_INITRD` is not enabled, and set to true later by `ima_notify_initramfs_populated`. Now, the important bit: inside `validate_hash_algo`, there's a conditional `if (!ima_initramfs_populated) return 0;`. But when syzkaller is running, `ima_initramfs_populated` *is* true. Why? Because it's set by `do_populate_rootfs()`, and it's `__ro_after_init`. This means the condition in that `if` statement will *always* be false during runtime. The code that's fuzzed by syzkaller will skip it. Okay, so what was the overall intent of the patch? Based on the information I've assessed, which is that it only applies to boot-time code paths, I am pretty sure it's not worth fuzzing, based on the reachability rules. |
| 14/2 | 2026/11/08 18:01 | tool | grepper |
0mArgs:{
"Expression": "initramfs: add support for file metadata"
}Results: {
"Output": "no matches"
} |
| 15/2 | 2026/11/08 18:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27877 output: 28 thoughts: 12 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the Commit History** Right, let's dive in. My immediate instinct, when needing to understand the evolution of this codebase, is to reach for `git log`. I want a quick, comprehensive view of the commit history. I'm thinking I need to understand what's been happening, who's been doing what, and when. Specifically, I'm looking for the key information that `git log` provides by default – the commit hashes, author details, date stamps, and most importantly, the commit messages. I'm mentally preparing to parse this output, filtering perhaps by author, date range, or keywords depending on the specific questions I'm trying to answer. The log is a critical tool for understanding the flow of changes. I want to build a narrative of the development timeline. |
| 16/2 | 2026/11/08 18:01 | tool | grepper |
0mArgs:{
"Expression": "initramfs_populated",
"PathPrefixes": [
"security/"
]
}Results: {
"Output": "security/integrity/ima/ima_appraise.c-22-\nsecurity/integrity/ima/ima_appraise.c:23:static bool ima_initramfs_populated __ro_after_init =\nsecurity/integrity/ima/ima_appraise.c-24-\t!IS_ENABLED(CONFIG_BLK_DEV_INITRD);\nsecurity/integrity/ima/ima_appraise.c-25-\nsecurity/integrity/ima/ima_appraise.c:26:static void ima_notify_initramfs_populated(void)\nsecurity/integrity/ima/ima_appraise.c-27-{\nsecurity/integrity/ima/ima_appraise.c:28:\tima_initramfs_populated = true;\nsecurity/integrity/ima/ima_appraise.c-29-}\n--\nsecurity/integrity/ima/ima_appraise.c=721=static int validate_hash_algo(struct dentry *dentry,\n--\nsecurity/integrity/ima/ima_appraise.c-761-\t\t */\nsecurity/integrity/ima/ima_appraise.c:762:\t\tif (!ima_initramfs_populated)\nsecurity/integrity/ima/ima_appraise.c-763-\t\t\treturn 0;\n--\nsecurity/integrity/ima/ima_appraise.c=850=static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {\n--\nsecurity/integrity/ima/ima_appraise.c-855-\tLSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),\nsecurity/integrity/ima/ima_appraise.c:856:\tLSM_HOOK_INIT(initramfs_populated, ima_notify_initramfs_populated),\nsecurity/integrity/ima/ima_appraise.c-857-};\n--\nsecurity/ipe/ipe.c=48=static struct security_hook_list ipe_hooks[] __ro_after_init = {\n--\nsecurity/ipe/ipe.c-54-\tLSM_HOOK_INIT(kernel_load_data, ipe_kernel_load_data),\nsecurity/ipe/ipe.c:55:\tLSM_HOOK_INIT(initramfs_populated, ipe_unpack_initramfs),\nsecurity/ipe/ipe.c-56-#ifdef CONFIG_IPE_PROP_DM_VERITY\n--\nsecurity/security.c=5703=int security_uring_allowed(void)\n--\nsecurity/security.c-5709-/**\nsecurity/security.c:5710: * security_initramfs_populated() - Notify LSMs that initramfs has been loaded\nsecurity/security.c-5711- *\n--\nsecurity/security.c-5713- */\nsecurity/security.c:5714:void security_initramfs_populated(void)\nsecurity/security.c-5715-{\nsecurity/security.c:5716:\tcall_void_hook(initramfs_populated);\nsecurity/security.c-5717-}\n"
} |
| 17/2 | 2026/11/08 18:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28859 output: 18 thoughts: 546 Thoughts: **My Analysis of Initramfs Population and Security**
Okay, so I'm looking at this patch and tracing how the initramfs gets populated and secured. I see that the `security_initramfs_populated()` function is already established in `security/security.c`, and IPE has been utilizing the `initramfs_populated` hook via `ipe_unpack_initramfs`. That's the starting point.
This patch, though, seems to be about generating and handling the initramfs itself. I see a `usr/gen_init_cpio.c` userspace tool to create cpio archives, along with the necessary build configuration (`usr/Kconfig` and `usr/Makefile`) and a header file (`include/linux/initramfs.h`) defining the metadata format. Then, there's `init/initramfs.c`, containing the crucial early boot code for unpacking the initramfs, involving `__init` functions and data structures.
The key change, it seems, is in `security/integrity/ima/ima_appraise.c`. This adds `ima_notify_initramfs_populated()` to the `initramfs_populated` LSM hook, setting `ima_initramfs_populated = true`. And there's this conditional check within `validate_hash_algo()`: `if (!ima_initramfs_populated) return 0;`. This is only active *before* the initramfs is fully loaded early in boot, which is critical. It's essentially a security gate to trust the initial state.
But now I have to ask myself an important question: can the initramfs be loaded or unpacked at runtime? Is there a way for it to be repopulated after the initial boot process?
Let's dig back into `init/initramfs.c`. Is `unpack_to_rootfs` exported for external use? Line 693 shows `char * __init unpack_to_rootfs(char *buf, unsigned long len)`. And there it is: `__init`! That means it's *not* exported to modules; there's no `EXPORT_SYMBOL`. And the `__init` attribute... What does that *really* mean in the Linux kernel context? It's defined as something like `__section(".init.text") __cold...`. Essentially, that code is only meant to be loaded and executed during early boot.
So, after `kernel_init()` has run, mounted the rootfs, and launched `/sbin/init`, `free_initmem()` is called, right? The memory allocated for those initialization routines is freed. Let me just confirm where `free_initmem()` is called...
|
| 18/2 | 2026/11/08 18:01 | tool | grepper |
0mArgs:{
"Expression": "free_initmem"
}Results: {
"Output": "arch/arm/mm/init.c=410=static inline void fix_kernmem_perms(void) { }\n--\narch/arm/mm/init.c-412-\narch/arm/mm/init.c:413:void free_initmem(void)\narch/arm/mm/init.c-414-{\n--\narch/arm/mm/init.c-418-\tif (!machine_is_integrator() \u0026\u0026 !machine_is_cintegrator())\narch/arm/mm/init.c:419:\t\tfree_initmem_default(-1);\narch/arm/mm/init.c-420-}\n--\narch/arm64/mm/init.c=383=void __init mem_init(void)\n--\narch/arm64/mm/init.c-388-\narch/arm64/mm/init.c:389:void free_initmem(void)\narch/arm64/mm/init.c-390-{\n--\narch/csky/kernel/vmlinux.lds.S=21=SECTIONS\n--\narch/csky/kernel/vmlinux.lds.S-43-\narch/csky/kernel/vmlinux.lds.S:44:\t/* __init_begin __init_end must be page aligned for free_initmem */\narch/csky/kernel/vmlinux.lds.S-45-\t. = ALIGN(PAGE_SIZE);\n--\narch/csky/mm/init.c=40=EXPORT_SYMBOL(invalid_pte_table);\narch/csky/mm/init.c-41-\narch/csky/mm/init.c:42:void free_initmem(void)\narch/csky/mm/init.c-43-{\narch/csky/mm/init.c:44:\tfree_initmem_default(-1);\narch/csky/mm/init.c-45-}\n--\narch/loongarch/mm/init.c=46=void __init arch_zone_limits_init(unsigned long *max_zone_pfns)\n--\narch/loongarch/mm/init.c-56-\narch/loongarch/mm/init.c:57:void __ref free_initmem(void)\narch/loongarch/mm/init.c-58-{\narch/loongarch/mm/init.c:59:\tfree_initmem_default(POISON_FREE_INITMEM);\narch/loongarch/mm/init.c-60-}\n--\narch/m68k/mm/init.c=58=void __init paging_init(void)\n--\narch/m68k/mm/init.c-70-\narch/m68k/mm/init.c:71:void free_initmem(void)\narch/m68k/mm/init.c-72-{\narch/m68k/mm/init.c-73-#ifndef CONFIG_MMU_SUN3\narch/m68k/mm/init.c:74:\tfree_initmem_default(-1);\narch/m68k/mm/init.c-75-#endif /* CONFIG_MMU_SUN3 */\n--\narch/mips/mm/init.c=483=void __weak __init prom_free_prom_memory(void)\n--\narch/mips/mm/init.c-487-\narch/mips/mm/init.c:488:void __ref free_initmem(void)\narch/mips/mm/init.c-489-{\n--\narch/mips/mm/init.c-498-\telse\narch/mips/mm/init.c:499:\t\tfree_initmem_default(POISON_FREE_INITMEM);\narch/mips/mm/init.c-500-}\n--\narch/parisc/mm/init.c=438=void __init set_kernel_text_rw(int enable_read_write)\n--\narch/parisc/mm/init.c-450-\narch/parisc/mm/init.c:451:void free_initmem(void)\narch/parisc/mm/init.c-452-{\n--\narch/parisc/mm/init.c-480-\narch/parisc/mm/init.c:481:\tfree_initmem_default(POISON_FREE_INITMEM);\narch/parisc/mm/init.c-482-\n--\narch/powerpc/mm/mem.c=271=void __init arch_mm_preinit(void)\n--\narch/powerpc/mm/mem.c-312-\narch/powerpc/mm/mem.c:313:void free_initmem(void)\narch/powerpc/mm/mem.c-314-{\n--\narch/powerpc/mm/mem.c-316-\tmark_initmem_nx();\narch/powerpc/mm/mem.c:317:\tfree_initmem_default(POISON_FREE_INITMEM);\narch/powerpc/mm/mem.c-318-\tftrace_free_init_tramp();\n--\narch/riscv/kernel/setup.c=373=bool arch_cpu_is_hotpluggable(int cpu)\n--\narch/riscv/kernel/setup.c-377-\narch/riscv/kernel/setup.c:378:void free_initmem(void)\narch/riscv/kernel/setup.c-379-{\n--\narch/riscv/kernel/setup.c-385-\narch/riscv/kernel/setup.c:386:\tfree_initmem_default(POISON_FREE_INITMEM);\narch/riscv/kernel/setup.c-387-}\n--\narch/sparc/mm/init_64.c=2487=void __init mem_init(void)\n--\narch/sparc/mm/init_64.c-2492-\narch/sparc/mm/init_64.c:2493:void free_initmem(void)\narch/sparc/mm/init_64.c-2494-{\n--\narch/um/kernel/mem.c=80=void __init arch_zone_limits_init(unsigned long *max_zone_pfns)\n--\narch/um/kernel/mem.c-89-\narch/um/kernel/mem.c:90:void free_initmem(void)\narch/um/kernel/mem.c-91-{\n--\narch/x86/kernel/e820.c=688=__init void e820__setup_pci_gap(void)\n--\narch/x86/kernel/e820.c-716-/*\narch/x86/kernel/e820.c:717: * Called late during init, in free_initmem().\narch/x86/kernel/e820.c-718- *\n--\narch/x86/kernel/e820.c-725- * All functions which modify them are __init functions, which won't exist\narch/x86/kernel/e820.c:726: * after free_initmem().\narch/x86/kernel/e820.c-727- */\n--\narch/x86/mm/init.c=946=void free_kernel_image_pages(const char *what, void *begin, void *end)\n--\narch/x86/mm/init.c-972-\narch/x86/mm/init.c:973:void __ref free_initmem(void)\narch/x86/mm/init.c-974-{\n--\narch/x86/mm/pti.c=626=void __init pti_init(void)\n--\narch/x86/mm/pti.c-662-\t * This is very early in boot. Device and Late initcalls can do\narch/x86/mm/pti.c:663:\t * modprobe before free_initmem() and mark_readonly(). This\narch/x86/mm/pti.c-664-\t * pti_clone_entry_text() allows those user-mode-helpers to function,\n--\narch/x86/mm/pti.c=679=void pti_finalize(void)\n--\narch/x86/mm/pti.c-683-\t/*\narch/x86/mm/pti.c:684:\t * This is after free_initmem() (all initcalls are done) and we've done\narch/x86/mm/pti.c-685-\t * mark_readonly(). Text is now NX which might've split some PMDs\n--\ninclude/linux/mm.h=4065=extern void __init pagecache_init(void);\ninclude/linux/mm.h:4066:extern void free_initmem(void);\ninclude/linux/mm.h-4067-\n--\ninclude/linux/mm.h=4092=static inline void free_reserved_ptdesc(struct ptdesc *pt)\n--\ninclude/linux/mm.h-4102- */\ninclude/linux/mm.h:4103:static inline unsigned long free_initmem_default(int poison)\ninclude/linux/mm.h-4104-{\n--\ninit/main.c=614=static void __init setup_command_line(char *command_line)\n--\ninit/main.c-672- * between the root thread and the init thread may cause start_kernel to\ninit/main.c:673: * be reaped by free_initmem before the root thread has proceeded to\ninit/main.c-674- * cpu_idle.\n--\ninit/main.c=1526=static void mark_readonly(void)\n--\ninit/main.c-1548-\ninit/main.c:1549:void __weak free_initmem(void)\ninit/main.c-1550-{\ninit/main.c:1551:\tfree_initmem_default(POISON_FREE_INITMEM);\ninit/main.c-1552-}\n--\ninit/main.c=1554=static int __ref kernel_init(void *unused)\n--\ninit/main.c-1573-\texit_boot_config();\ninit/main.c:1574:\tfree_initmem();\ninit/main.c-1575-\tmark_readonly();\n"
} |
| 19/2 | 2026/11/08 18:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32667 output: 280 thoughts: 1387 Thoughts: **Analysis of Code Reachability for Fuzzing**
Okay, let's break this down. From what I'm seeing in `init/main.c`, the kernel initializes, and crucially, `free_initmem()` and `mark_readonly()` are called *before* userspace even starts. This is the key. Those two functions are what effectively nullify this patch series' impact on fuzzing.
Specifically, `free_initmem()` wipes out all the `.init.text` and `.init.data` sections. That means anything annotated with `__init` or `__initdata` – which, looking at the code, includes *all* the modified functions in `init/initramfs.c` (like `update_csum`, `xwrite`, `do_header`, etc.) – are completely gone from memory *before* syzkaller, or any other user-space process, can even get a look-in. The same applies to the variables like `body_len, name_len, metadata_len` and others, they're all purged too.
And `mark_readonly()` makes `__ro_after_init` data read-only. This means that variables like `ima_initramfs_populated` are locked down to read-only after they've been initialized, and *before* user-space starts. And the change within `security/integrity/ima/ima_appraise.c` boils down to a conditional check: `if (!ima_initramfs_populated) return 0;`. But since `ima_initramfs_populated` is permanently true *at runtime*, that check is dead code. It's never going to be executed.
Then we have `usr/gen_init_cpio.c`, `usr/gen_initramfs.sh`, and the associated Kconfig and Makefile files. These are all *host* tooling; they're used to build the initramfs image at compile time. They don't run on the target system, and therefore, cannot be reached by syzkaller. And `include/linux/initramfs.h` is just header definitions.
So, in essence, *none* of the kernel code modified or added by these patches is reachable during runtime fuzzing. It's either freed, permanently read-only and unchangeable, or not even part of the kernel runtime at all.
Let's apply the triage guidelines:
- The primary question is reachability, and we've established that the modified code is *not* reachable in a standard environment like QEMU. It's early boot code and host tooling.
- Section 2 lists specific categories for `WorthFuzzing=false`. The changes fall squarely into:
- "Non-kernel and non-executable changes" (the `usr/` stuff).
- "Unreachable execution paths" (the early boot code that's freed).
The `ima_appraise.c` change is effectively unreachable too, because the flag that controls its execution becomes permanently `true`.
Therefore, the only conclusion is: `WorthFuzzing=false`. There's no point in attempting to fuzz this code because it's unreachable in the target environment.
And since we have a clear reasoning for why it's not worth fuzzing, there are no special configs or focus symbols to return.
Ready to call `set-results`.
|
| 20/2 | 2026/11/08 18:01 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch series adds support for file metadata (extended attributes) in the initramfs:\n1. The changes in usr/ (gen_init_cpio.c, gen_initramfs.sh, Kconfig, Makefile) modify host-side user-space build tools used during kernel compilation to generate the cpio archive.\n2. The modifications in init/initramfs.c affect only early boot functions marked __init and __initdata (do_header, do_name, do_collect_metadata, do_setxattrs, unpack_to_rootfs, etc.), which execute strictly before userspace launches and are unmapped and freed by free_initmem() prior to any fuzzing activity.\n3. The change in security/integrity/ima/ima_appraise.c introduces an early-boot check `if (!ima_initramfs_populated) return 0;` guarded by a variable set to true before userspace starts and marked __ro_after_init, making this path completely dead and unreachable at runtime.\n\nBecause none of the modified code is reachable by userspace syscall fuzzing in a running kernel, the patch series does not warrant fuzzing.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series adds support for file metadata (extended attributes) in the initramfs:\n1. The changes in usr/ (gen_init_cpio.c, gen_initramfs.sh, Kconfig, Makefile) modify host-side user-space build tools used during kernel compilation to generate the cpio archive.\n2. The modifications in init/initramfs.c affect only early boot functions marked __init and __initdata (do_header, do_name, do_collect_metadata, do_setxattrs, unpack_to_rootfs, etc.), which execute strictly before userspace launches and are unmapped and freed by free_initmem() prior to any fuzzing activity.\n3. The change in security/integrity/ima/ima_appraise.c introduces an early-boot check `if (!ima_initramfs_populated) return 0;` guarded by a variable set to true before userspace starts and marked __ro_after_init, making this path completely dead and unreachable at runtime.\n\nBecause none of the modified code is reachable by userspace syscall fuzzing in a running kernel, the patch series does not warrant fuzzing.",
"WorthFuzzing": false
} |
| 21/1 | 2026/11/08 18:01 | action | If |
0mArgs:{
"WorthFuzzing": false
}Results: null |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|