| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/09 05:05 | flow | patch-triage |
2mArgs:null Results: {
"EnableConfigs": [
"DEBUG_FS",
"BLK_DEBUG_FS"
],
"FocusSymbols": [
"blk_mq_alloc_mapped_tags",
"blk_mq_free_unmapped_tags",
"blk_mq_update_mapped_tags_bitmap",
"blk_mq_update_nr_hw_queues",
"blk_mq_tagset_debugfs_register",
"blk_mq_tagset_debugfs_unregister",
"blk_mq_tagset_tags_read",
"blk_mq_tagset_map_show",
"blk_mq_tagset_flags_show",
"blk_mq_tagset_debugfs_create_tags",
"blk_mq_tagset_debugfs_remove_tags"
],
"KMSANReasoning": "The patch introduces debugfs entries for blk-mq tag sets and manages active hardware queue mappings using a dynamically allocated bitmap (`mapped_tags_bitmap`).\n\nFrom a KMSAN perspective:\n1. No uninitialized memory or structure padding is leaked to user space: debugfs show/read handlers output formatted ASCII strings using `seq_printf` and `scnprintf` (`blk_mq_tagset_tags_read`, `blk_mq_tagset_map_show`, etc.), followed by `simple_read_from_buffer`.\n2. Stack buffers (`target[32]`, `name[20]`, `name[24]`, `buf[128]`) are safely written via `snprintf`/`scnprintf` prior to being read or passed to debugfs APIs.\n3. Newly added heap objects (`mapped_tags_bitmap`) are allocated with `bitmap_zalloc_node` (ensuring zero-initialization), and new struct fields (`debugfs_dir`, `debugfs_id`) in `struct blk_mq_tag_set` are properly initialized in `blk_mq_alloc_tag_set`.\n4. Control flow and branching rely on well-initialized tag set fields, integers, and zeroed bitmaps.\n\nContrast with KASAN/LOCKDEP:\nAny potential bugs introduced by this patch would involve tag lifetime/use-after-free (e.g. tearing down tags while a debugfs file is being read), NULL pointer dereferences, array bounds, or locking anomalies (`blk_mq_tagset_debugfs_mutex` vs queue locks). These are detected by KASAN and LOCKDEP. A dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies the core blk-mq subsystem by changing tagset management and software-to-hardware queue mapping (adding dynamic allocation/freeing of mapped/unmapped tags based on a newly introduced mapped_tags_bitmap, with defensive lock assertions). In addition, it exposes tagset debugfs attributes and directories with custom file operations and lifetime handling. These code paths are fully reachable in virtualized environments via block devices and debugfs.",
"WorthFuzzing": true
} |
| 1/1 | 2026/10/09 05:05 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 792794fe2785fe34cc6ac6fa547bf2516b3772a3\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Fri Oct 9 05:05:01 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c\nindex 6754d8f9449c1..78a91a1095bb5 100644\n--- a/block/blk-mq-debugfs.c\n+++ b/block/blk-mq-debugfs.c\n@@ -7,6 +7,7 @@\n #include \u003clinux/blkdev.h\u003e\n #include \u003clinux/build_bug.h\u003e\n #include \u003clinux/debugfs.h\u003e\n+#include \u003clinux/idr.h\u003e\n \n #include \"blk.h\"\n #include \"blk-mq.h\"\n@@ -643,11 +644,19 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent,\n \n void blk_mq_debugfs_register(struct request_queue *q)\n {\n+\tstruct blk_mq_tag_set *set = q-\u003etag_set;\n \tstruct blk_mq_hw_ctx *hctx;\n \tunsigned long i;\n+\tchar target[32];\n \n \tdebugfs_create_files(q, q-\u003edebugfs_dir, q, blk_mq_debugfs_queue_attrs);\n \n+\tif (!IS_ERR_OR_NULL(q-\u003edebugfs_dir) \u0026\u0026\n+\t !IS_ERR_OR_NULL(set-\u003edebugfs_dir) \u0026\u0026 set-\u003edebugfs_id \u003e= 0) {\n+\t\tsnprintf(target, sizeof(target), \"../../tagset/%d\", set-\u003edebugfs_id);\n+\t\tdebugfs_create_symlink(\"tagset\", q-\u003edebugfs_dir, target);\n+\t}\n+\n \tqueue_for_each_hw_ctx(q, hctx, i) {\n \t\tif (!hctx-\u003edebugfs_dir)\n \t\t\tblk_mq_debugfs_register_hctx(q, hctx);\n@@ -827,3 +836,292 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx)\n \tdebugfs_remove_recursive(hctx-\u003esched_debugfs_dir);\n \thctx-\u003esched_debugfs_dir = NULL;\n }\n+\n+/* Tag set debugfs --------------------------------------------------------- */\n+\n+static DEFINE_IDA(blk_mq_tagset_debugfs_ida);\n+static DEFINE_MUTEX(blk_mq_tagset_debugfs_mutex);\n+static struct dentry *blk_mq_tagset_debugfs_root;\n+\n+/* Prevent debugfs allocation reclaim from issuing I/O to frozen queues. */\n+static unsigned int __must_check blk_mq_tagset_debugfs_lock(void)\n+\t__acquires(\u0026blk_mq_tagset_debugfs_mutex)\n+{\n+\tunsigned int memflags = memalloc_noio_save();\n+\n+\tmutex_lock(\u0026blk_mq_tagset_debugfs_mutex);\n+\treturn memflags;\n+}\n+\n+static void blk_mq_tagset_debugfs_unlock(unsigned int memflags)\n+\t__releases(\u0026blk_mq_tagset_debugfs_mutex)\n+{\n+\tmutex_unlock(\u0026blk_mq_tagset_debugfs_mutex);\n+\tmemalloc_noio_restore(memflags);\n+}\n+\n+#define BLK_MQ_F_NAME(name) \\\n+\t[ilog2(BLK_MQ_F_##name)] = #name\n+static const char *const tagset_flag_name[] = {\n+\tBLK_MQ_F_NAME(TAG_QUEUE_SHARED),\n+\tBLK_MQ_F_NAME(STACKING),\n+\tBLK_MQ_F_NAME(TAG_HCTX_SHARED),\n+\tBLK_MQ_F_NAME(BLOCKING),\n+\tBLK_MQ_F_NAME(TAG_RR),\n+\tBLK_MQ_F_NAME(NO_SCHED_BY_DEFAULT),\n+};\n+\n+#undef BLK_MQ_F_NAME\n+\n+static int blk_mq_tagset_flags_show(struct seq_file *m, void *v)\n+{\n+\tstruct blk_mq_tag_set *set = m-\u003eprivate;\n+\n+\tBUILD_BUG_ON(ARRAY_SIZE(tagset_flag_name) != ilog2(BLK_MQ_F_MAX));\n+\n+\tdown_read(\u0026set-\u003eupdate_nr_hwq_lock);\n+\n+\tblk_flags_show(m, set-\u003eflags, tagset_flag_name,\n+\t\t ARRAY_SIZE(tagset_flag_name));\n+\tseq_putc(m, '\\n');\n+\n+\tup_read(\u0026set-\u003eupdate_nr_hwq_lock);\n+\n+\treturn 0;\n+}\n+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_flags);\n+\n+#define BLK_MQ_TAGSET_VALUE_SHOW(_name, _type, _value, _format) \\\n+static int blk_mq_tagset_##_name##_show(struct seq_file *m, void *v) \\\n+{ \\\n+\tstruct blk_mq_tag_set *set = m-\u003eprivate; \\\n+\t_type value; \\\n+\\\n+\tdown_read(\u0026set-\u003eupdate_nr_hwq_lock); \\\n+\tvalue = (_value); \\\n+\tup_read(\u0026set-\u003eupdate_nr_hwq_lock); \\\n+\\\n+\tseq_printf(m, _format, value); \\\n+\treturn 0; \\\n+} \\\n+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_##_name)\n+\n+BLK_MQ_TAGSET_VALUE_SHOW(nr_maps, unsigned int, set-\u003enr_maps, \"%u\\n\");\n+BLK_MQ_TAGSET_VALUE_SHOW(nr_hw_queues, unsigned int, set-\u003enr_hw_queues, \"%u\\n\");\n+BLK_MQ_TAGSET_VALUE_SHOW(queue_depth, unsigned int, set-\u003equeue_depth, \"%u\\n\");\n+BLK_MQ_TAGSET_VALUE_SHOW(reserved_tags, unsigned int, set-\u003ereserved_tags, \"%u\\n\");\n+BLK_MQ_TAGSET_VALUE_SHOW(cmd_size, unsigned int, set-\u003ecmd_size, \"%u\\n\");\n+BLK_MQ_TAGSET_VALUE_SHOW(numa_node, int, set-\u003enuma_node, \"%d\\n\");\n+BLK_MQ_TAGSET_VALUE_SHOW(timeout, unsigned int, set-\u003etimeout, \"%u\\n\");\n+\n+#undef BLK_MQ_TAGSET_VALUE_SHOW\n+\n+static int blk_mq_tagset_hctx_tags_shared_show(struct seq_file *m, void *v)\n+{\n+\tstruct blk_mq_tag_set *set = m-\u003eprivate;\n+\tbool shared;\n+\n+\tdown_read(\u0026set-\u003eupdate_nr_hwq_lock);\n+\tshared = blk_mq_is_shared_tags(set-\u003eflags);\n+\tup_read(\u0026set-\u003eupdate_nr_hwq_lock);\n+\n+\tseq_printf(m, \"%d\\n\", shared);\n+\treturn 0;\n+}\n+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_hctx_tags_shared);\n+\n+static int blk_mq_tagset_map_show(struct seq_file *m, void *v)\n+{\n+\tstruct blk_mq_tag_set *set = m-\u003eprivate;\n+\tunsigned long index = debugfs_get_aux_num(m-\u003efile);\n+\tunsigned int map = index / nr_cpu_ids;\n+\tunsigned int cpu = index % nr_cpu_ids;\n+\n+\tdown_read(\u0026set-\u003eupdate_nr_hwq_lock);\n+\n+\tseq_printf(m, \"%u\\n\", set-\u003emap[map].mq_map[cpu]);\n+\n+\tup_read(\u0026set-\u003eupdate_nr_hwq_lock);\n+\treturn 0;\n+}\n+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_map);\n+\n+static void blk_mq_tagset_debugfs_create_maps(struct blk_mq_tag_set *set)\n+{\n+\tstruct dentry *dir, *map_dir;\n+\tunsigned int cpu, i;\n+\tchar name[20];\n+\n+\tdir = debugfs_create_dir(\"map\", set-\u003edebugfs_dir);\n+\tif (IS_ERR_OR_NULL(dir))\n+\t\treturn;\n+\n+\tfor (i = 0; i \u003c set-\u003enr_maps; i++) {\n+\t\tsnprintf(name, sizeof(name), \"%u\", i);\n+\t\tmap_dir = debugfs_create_dir(name, dir);\n+\t\tif (IS_ERR_OR_NULL(map_dir))\n+\t\t\tcontinue;\n+\n+\t\tfor_each_possible_cpu(cpu) {\n+\t\t\t/* Encode the map and CPU indices in the auxiliary data. */\n+\t\t\tunsigned long index = (unsigned long)i * nr_cpu_ids + cpu;\n+\n+\t\t\tsnprintf(name, sizeof(name), \"cpu%u\", cpu);\n+\t\t\tdebugfs_create_file_aux_num(name, 0444, map_dir, set,\n+\t\t\t\t\t\t index, \u0026blk_mq_tagset_map_fops);\n+\t\t}\n+\t}\n+}\n+\n+static ssize_t blk_mq_tagset_tags_read(struct file *file, char __user *user_buf,\n+\t\t\t\t size_t count, loff_t *ppos)\n+{\n+\tstruct dentry *dentry = file-\u003ef_path.dentry;\n+\tunsigned int nr_tags, nr_reserved_tags, active_queues;\n+\tstruct blk_mq_tags *tags;\n+\tchar buf[128];\n+\tint ret, len;\n+\n+\t/*\n+\t * Tag updates remove these files before freeing the tags. Shared tags\n+\t * remain valid until tag set teardown removes the shared_tags file.\n+\t */\n+\tret = debugfs_file_get(dentry);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\ttags = file-\u003eprivate_data;\n+\tif (!tags) {\n+\t\tdebugfs_file_put(dentry);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tnr_tags = tags-\u003enr_tags;\n+\tnr_reserved_tags = tags-\u003enr_reserved_tags;\n+\tactive_queues = READ_ONCE(tags-\u003eactive_queues);\n+\tdebugfs_file_put(dentry);\n+\n+\t/*\n+\t * A fault on the user buffer may need I/O to a frozen queue. Drop the\n+\t * active reference first so file removal does not wait for that I/O.\n+\t */\n+\tlen = scnprintf(buf, sizeof(buf),\n+\t\t\t\".nr_tags=%u\\n.nr_reserved_tags=%u\\n.active_queues=%u\\n\",\n+\t\t\tnr_tags, nr_reserved_tags, active_queues);\n+\treturn simple_read_from_buffer(user_buf, count, ppos, buf, len);\n+}\n+\n+static const struct file_operations blk_mq_tagset_tags_fops = {\n+\t.owner\t\t= THIS_MODULE,\n+\t.open\t\t= simple_open,\n+\t.read\t\t= blk_mq_tagset_tags_read,\n+\t.llseek\t\t= default_llseek,\n+};\n+\n+void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set)\n+{\n+\tif (IS_ERR_OR_NULL(set-\u003edebugfs_dir))\n+\t\treturn;\n+\n+\tdebugfs_lookup_and_remove(\"tags\", set-\u003edebugfs_dir);\n+}\n+\n+void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set)\n+{\n+\tstruct dentry *dir;\n+\tunsigned int i;\n+\tchar name[20];\n+\n+\tif (IS_ERR_OR_NULL(set-\u003edebugfs_dir))\n+\t\treturn;\n+\n+\tdir = debugfs_create_dir(\"tags\", set-\u003edebugfs_dir);\n+\tif (IS_ERR_OR_NULL(dir))\n+\t\treturn;\n+\n+\tfor (i = 0; i \u003c set-\u003enr_hw_queues; i++) {\n+\t\tstruct blk_mq_tags *tags = set-\u003etags[i];\n+\n+\t\tsnprintf(name, sizeof(name), \"%u\", i);\n+\t\tif (tags \u0026\u0026 tags == set-\u003eshared_tags)\n+\t\t\tdebugfs_create_symlink(name, dir, \"../shared_tags\");\n+\t\telse\n+\t\t\tdebugfs_create_file_unsafe(name, 0444, dir, tags,\n+\t\t\t\t\t\t \u0026blk_mq_tagset_tags_fops);\n+\t}\n+}\n+\n+static void blk_mq_tagset_debugfs_create_files(struct blk_mq_tag_set *set)\n+{\n+\tdebugfs_create_file(\"nr_maps\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_nr_maps_fops);\n+\tdebugfs_create_file(\"nr_hw_queues\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_nr_hw_queues_fops);\n+\tdebugfs_create_file(\"queue_depth\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_queue_depth_fops);\n+\tdebugfs_create_file(\"reserved_tags\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_reserved_tags_fops);\n+\tdebugfs_create_file(\"cmd_size\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_cmd_size_fops);\n+\tdebugfs_create_file(\"numa_node\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_numa_node_fops);\n+\tdebugfs_create_file(\"timeout\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_timeout_fops);\n+\tdebugfs_create_file(\"hctx_tags_shared\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_hctx_tags_shared_fops);\n+\tdebugfs_create_file(\"flags\", 0444, set-\u003edebugfs_dir, set,\n+\t\t\t \u0026blk_mq_tagset_flags_fops);\n+\tblk_mq_tagset_debugfs_create_maps(set);\n+\tdebugfs_create_file_unsafe(\"shared_tags\", 0444, set-\u003edebugfs_dir,\n+\t\t\t\t set-\u003eshared_tags, \u0026blk_mq_tagset_tags_fops);\n+\tblk_mq_tagset_debugfs_create_tags(set);\n+}\n+\n+void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set)\n+{\n+\tstruct dentry *dir;\n+\tunsigned int memflags;\n+\tchar name[24];\n+\tint id;\n+\n+\tmemflags = blk_mq_tagset_debugfs_lock();\n+\n+\tif (IS_ERR_OR_NULL(blk_mq_tagset_debugfs_root))\n+\t\tblk_mq_tagset_debugfs_root = debugfs_create_dir(\"tagset\", NULL);\n+\n+\tif (set-\u003edebugfs_dir || IS_ERR_OR_NULL(blk_mq_tagset_debugfs_root))\n+\t\tgoto out_unlock;\n+\n+\tid = ida_alloc(\u0026blk_mq_tagset_debugfs_ida, GFP_KERNEL);\n+\tif (id \u003c 0)\n+\t\tgoto out_unlock;\n+\n+\tsnprintf(name, sizeof(name), \"%d\", id);\n+\tdir = debugfs_create_dir(name, blk_mq_tagset_debugfs_root);\n+\tif (IS_ERR_OR_NULL(dir)) {\n+\t\tida_free(\u0026blk_mq_tagset_debugfs_ida, id);\n+\t\tgoto out_unlock;\n+\t}\n+\n+\tset-\u003edebugfs_id = id;\n+\tset-\u003edebugfs_dir = dir;\n+\tblk_mq_tagset_debugfs_create_files(set);\n+\n+out_unlock:\n+\tblk_mq_tagset_debugfs_unlock(memflags);\n+}\n+\n+void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set)\n+{\n+\tmutex_lock(\u0026blk_mq_tagset_debugfs_mutex);\n+\n+\tdebugfs_remove_recursive(set-\u003edebugfs_dir);\n+\tset-\u003edebugfs_dir = NULL;\n+\n+\tif (set-\u003edebugfs_id \u003e= 0) {\n+\t\tida_free(\u0026blk_mq_tagset_debugfs_ida, set-\u003edebugfs_id);\n+\t\tset-\u003edebugfs_id = -1;\n+\t}\n+\n+\tmutex_unlock(\u0026blk_mq_tagset_debugfs_mutex);\n+}\ndiff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h\nindex 49bb1aaa83dc7..aea278bdc4e78 100644\n--- a/block/blk-mq-debugfs.h\n+++ b/block/blk-mq-debugfs.h\n@@ -7,6 +7,7 @@\n #include \u003clinux/seq_file.h\u003e\n \n struct blk_mq_hw_ctx;\n+struct blk_mq_tag_set;\n \n struct blk_mq_debugfs_attr {\n \tconst char *name;\n@@ -34,6 +35,11 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,\n void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);\n \n void blk_mq_debugfs_register_rq_qos(struct request_queue *q);\n+\n+void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set);\n+void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set);\n+void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set);\n+void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set);\n #else\n static inline void blk_mq_debugfs_register(struct request_queue *q)\n {\n@@ -77,6 +83,22 @@ static inline void blk_mq_debugfs_register_rq_qos(struct request_queue *q)\n {\n }\n \n+static inline void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set)\n+{\n+}\n+\n+static inline void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set)\n+{\n+}\n+\n+static inline void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set)\n+{\n+}\n+\n+static inline void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set)\n+{\n+}\n+\n #endif\n \n #if defined(CONFIG_BLK_DEV_ZONED) \u0026\u0026 defined(CONFIG_BLK_DEBUG_FS)\ndiff --git a/block/blk-mq.c b/block/blk-mq.c\nindex a26a11c73ee3e..f32d2df044dcc 100644\n--- a/block/blk-mq.c\n+++ b/block/blk-mq.c\n@@ -9,6 +9,7 @@\n #include \u003clinux/module.h\u003e\n #include \u003clinux/backing-dev.h\u003e\n #include \u003clinux/bio.h\u003e\n+#include \u003clinux/bitmap.h\u003e\n #include \u003clinux/blkdev.h\u003e\n #include \u003clinux/blk-integrity.h\u003e\n #include \u003clinux/kmemleak.h\u003e\n@@ -4159,9 +4160,74 @@ static void __blk_mq_free_map_and_rqs(struct blk_mq_tag_set *set,\n \tset-\u003etags[hctx_idx] = NULL;\n }\n \n+static void blk_mq_update_mapped_tags_bitmap(struct blk_mq_tag_set *set)\n+{\n+\tunsigned int i, cpu;\n+\n+\tbitmap_zero(set-\u003emapped_tags_bitmap, set-\u003enr_hw_queues);\n+\tif (set-\u003enr_hw_queues == 1) {\n+\t\t__set_bit(0, set-\u003emapped_tags_bitmap);\n+\t\treturn;\n+\t}\n+\n+\tfor (i = 0; i \u003c set-\u003enr_maps; i++) {\n+\t\tstruct blk_mq_queue_map *map = \u0026set-\u003emap[i];\n+\n+\t\tif (!map-\u003enr_queues)\n+\t\t\tcontinue;\n+\t\tfor_each_possible_cpu(cpu)\n+\t\t\t__set_bit(map-\u003emq_map[cpu], set-\u003emapped_tags_bitmap);\n+\t}\n+}\n+\n+static void blk_mq_alloc_mapped_tags(struct blk_mq_tag_set *set)\n+{\n+\tunsigned int cpu, i;\n+\tbool remapped = false;\n+\n+\tlockdep_assert_held_write(\u0026set-\u003eupdate_nr_hwq_lock);\n+\n+\tfor_each_possible_cpu(cpu) {\n+\t\tfor (i = 0; i \u003c set-\u003enr_maps; i++) {\n+\t\t\tstruct blk_mq_queue_map *map = \u0026set-\u003emap[i];\n+\t\t\tunsigned int hctx_idx;\n+\n+\t\t\tif (!map-\u003enr_queues)\n+\t\t\t\tcontinue;\n+\t\t\thctx_idx = map-\u003emq_map[cpu];\n+\t\t\tif (!set-\u003etags[hctx_idx] \u0026\u0026\n+\t\t\t !__blk_mq_alloc_map_and_rqs(set, hctx_idx)) {\n+\t\t\t\t/* Queue 0 always has tags available for fallback. */\n+\t\t\t\tmap-\u003emq_map[cpu] = 0;\n+\t\t\t\tremapped = true;\n+\t\t\t}\n+\t\t}\n+\t}\n+\tif (remapped)\n+\t\tblk_mq_update_mapped_tags_bitmap(set);\n+}\n+\n+static bool blk_mq_tagset_tags_mapped(struct blk_mq_tag_set *set,\n+\t\t\t\t unsigned int hctx_idx)\n+{\n+\treturn test_bit(hctx_idx, set-\u003emapped_tags_bitmap);\n+}\n+\n+/* The queue maps must be stable and the unused tags no longer in use. */\n+static void blk_mq_free_unmapped_tags(struct blk_mq_tag_set *set)\n+{\n+\tunsigned int i;\n+\n+\t/* Keep queue 0 as a fallback if a later tag allocation fails. */\n+\tfor (i = 1; i \u003c set-\u003enr_hw_queues; i++) {\n+\t\tif (set-\u003etags[i] \u0026\u0026 !blk_mq_tagset_tags_mapped(set, i))\n+\t\t\t__blk_mq_free_map_and_rqs(set, i);\n+\t}\n+}\n+\n static void blk_mq_map_swqueue(struct request_queue *q)\n {\n-\tunsigned int j, hctx_idx;\n+\tunsigned int j;\n \tunsigned long i;\n \tstruct blk_mq_hw_ctx *hctx;\n \tstruct blk_mq_ctx *ctx;\n@@ -4173,11 +4239,7 @@ static void blk_mq_map_swqueue(struct request_queue *q)\n \t\thctx-\u003edispatch_from = NULL;\n \t}\n \n-\t/*\n-\t * Map software to hardware queues.\n-\t *\n-\t * If the cpu isn't present, the cpu is mapped to first hctx.\n-\t */\n+\t/* Map software to hardware queues. */\n \tfor_each_possible_cpu(i) {\n \n \t\tctx = per_cpu_ptr(q-\u003equeue_ctx, i);\n@@ -4187,19 +4249,6 @@ static void blk_mq_map_swqueue(struct request_queue *q)\n \t\t\t\t\t\tHCTX_TYPE_DEFAULT, i);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\thctx_idx = set-\u003emap[j].mq_map[i];\n-\t\t\t/* unmapped hw queue can be remapped after CPU topo changed */\n-\t\t\tif (!set-\u003etags[hctx_idx] \u0026\u0026\n-\t\t\t !__blk_mq_alloc_map_and_rqs(set, hctx_idx)) {\n-\t\t\t\t/*\n-\t\t\t\t * If tags initialization fail for some hctx,\n-\t\t\t\t * that hctx won't be brought online. In this\n-\t\t\t\t * case, remap the current ctx to hctx[0] which\n-\t\t\t\t * is guaranteed to always have tags allocated\n-\t\t\t\t */\n-\t\t\t\tset-\u003emap[j].mq_map[i] = 0;\n-\t\t\t}\n-\n \t\t\thctx = blk_mq_map_queue_type(q, j, i);\n \t\t\tctx-\u003ehctxs[j] = hctx;\n \t\t\t/*\n@@ -4230,18 +4279,8 @@ static void blk_mq_map_swqueue(struct request_queue *q)\n \tqueue_for_each_hw_ctx(q, hctx, i) {\n \t\tint cpu;\n \n-\t\t/*\n-\t\t * If no software queues are mapped to this hardware queue,\n-\t\t * disable it and free the request entries.\n-\t\t */\n+\t\t/* Disable hardware queues with no mapped software queues. */\n \t\tif (!hctx-\u003enr_ctx) {\n-\t\t\t/* Never unmap queue 0. We need it as a\n-\t\t\t * fallback in case of a new remap fails\n-\t\t\t * allocation\n-\t\t\t */\n-\t\t\tif (i)\n-\t\t\t\t__blk_mq_free_map_and_rqs(set, i);\n-\n \t\t\thctx-\u003etags = NULL;\n \t\t\tcontinue;\n \t\t}\n@@ -4782,12 +4821,18 @@ static void blk_mq_update_queue_map(struct blk_mq_tag_set *set)\n \t\tBUG_ON(set-\u003enr_maps \u003e 1);\n \t\tblk_mq_map_queues(\u0026set-\u003emap[HCTX_TYPE_DEFAULT]);\n \t}\n+\tblk_mq_update_mapped_tags_bitmap(set);\n }\n \n+/*\n+ * On successful growth, also install a larger mapped_tags_bitmap. The caller\n+ * rebuilds its contents when updating the queue maps under update_nr_hwq_lock.\n+ */\n static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(\n \t\t\t\tstruct blk_mq_tag_set *set,\n \t\t\t\tint new_nr_hw_queues)\n {\n+\tunsigned long *new_mapped_tags_bitmap;\n \tstruct blk_mq_tags **new_tags;\n \tint i;\n \n@@ -4799,6 +4844,13 @@ static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(\n \tif (!new_tags)\n \t\treturn ERR_PTR(-ENOMEM);\n \n+\tnew_mapped_tags_bitmap = bitmap_zalloc_node(new_nr_hw_queues, GFP_KERNEL,\n+\t\t\t\t\t\t set-\u003enuma_node);\n+\tif (!new_mapped_tags_bitmap) {\n+\t\tkfree(new_tags);\n+\t\treturn ERR_PTR(-ENOMEM);\n+\t}\n+\n \tif (set-\u003etags)\n \t\tmemcpy(new_tags, set-\u003etags, set-\u003enr_hw_queues *\n \t\t sizeof(*set-\u003etags));\n@@ -4815,12 +4867,15 @@ static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(\n \t\tcond_resched();\n \t}\n \n+\tbitmap_free(set-\u003emapped_tags_bitmap);\n+\tset-\u003emapped_tags_bitmap = new_mapped_tags_bitmap;\n \treturn new_tags;\n out_unwind:\n \twhile (--i \u003e= set-\u003enr_hw_queues) {\n \t\tif (!blk_mq_is_shared_tags(set-\u003eflags))\n \t\t\tblk_mq_free_map_and_rqs(set, new_tags[i], i);\n \t}\n+\tbitmap_free(new_mapped_tags_bitmap);\n \tkfree(new_tags);\n \treturn ERR_PTR(-ENOMEM);\n }\n@@ -4884,9 +4939,17 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)\n \t\tif (ret)\n \t\t\tgoto out_free_srcu;\n \t}\n+\n+\tset-\u003emapped_tags_bitmap = bitmap_zalloc_node(set-\u003enr_hw_queues, GFP_KERNEL,\n+\t\t\t\t\t\t set-\u003enuma_node);\n+\tif (!set-\u003emapped_tags_bitmap) {\n+\t\tret = -ENOMEM;\n+\t\tgoto out_cleanup_srcu;\n+\t}\n+\n \tret = init_srcu_struct(\u0026set-\u003etags_srcu);\n \tif (ret)\n-\t\tgoto out_cleanup_srcu;\n+\t\tgoto out_free_mapped_tags_bitmap;\n \n \tinit_rwsem(\u0026set-\u003eupdate_nr_hwq_lock);\n \n@@ -4911,9 +4974,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)\n \tret = blk_mq_alloc_set_map_and_rqs(set);\n \tif (ret)\n \t\tgoto out_free_mq_map;\n+\tblk_mq_free_unmapped_tags(set);\n \n \tmutex_init(\u0026set-\u003etag_list_lock);\n \tINIT_LIST_HEAD(\u0026set-\u003etag_list);\n+#ifdef CONFIG_BLK_DEBUG_FS\n+\tset-\u003edebugfs_id = -1;\n+#endif\n+\tblk_mq_tagset_debugfs_register(set);\n \n \treturn 0;\n \n@@ -4926,6 +4994,9 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)\n \tset-\u003etags = NULL;\n out_cleanup_tags_srcu:\n \tcleanup_srcu_struct(\u0026set-\u003etags_srcu);\n+out_free_mapped_tags_bitmap:\n+\tbitmap_free(set-\u003emapped_tags_bitmap);\n+\tset-\u003emapped_tags_bitmap = NULL;\n out_cleanup_srcu:\n \tif (set-\u003eflags \u0026 BLK_MQ_F_BLOCKING)\n \t\tcleanup_srcu_struct(set-\u003esrcu);\n@@ -4956,6 +5027,8 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)\n {\n \tint i, j;\n \n+\tblk_mq_tagset_debugfs_unregister(set);\n+\n \tfor (i = 0; i \u003c set-\u003enr_hw_queues; i++)\n \t\t__blk_mq_free_map_and_rqs(set, i);\n \n@@ -4972,6 +5045,9 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)\n \tkfree(set-\u003etags);\n \tset-\u003etags = NULL;\n \n+\tbitmap_free(set-\u003emapped_tags_bitmap);\n+\tset-\u003emapped_tags_bitmap = NULL;\n+\n \tsrcu_barrier(\u0026set-\u003etags_srcu);\n \tcleanup_srcu_struct(\u0026set-\u003etags_srcu);\n \tif (set-\u003eflags \u0026 BLK_MQ_F_BLOCKING) {\n@@ -5137,6 +5213,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,\n \t\tblk_mq_debugfs_unregister_hctxs(q);\n \t\tblk_mq_sysfs_unregister_hctxs(q);\n \t}\n+\tblk_mq_tagset_debugfs_remove_tags(set);\n \n \t/*\n \t * Switch IO scheduler to 'none', cleaning up the data associated\n@@ -5162,6 +5239,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,\n \n fallback:\n \tblk_mq_update_queue_map(set);\n+\tblk_mq_alloc_mapped_tags(set);\n \tlist_for_each_entry(q, \u0026set-\u003etag_list, tag_set_list) {\n \t\t__blk_mq_realloc_hw_ctxs(set, q);\n \n@@ -5178,6 +5256,8 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,\n \t\t}\n \t\tblk_mq_map_swqueue(q);\n \t}\n+\t/* All queues have stopped using tags excluded by the new maps. */\n+\tblk_mq_free_unmapped_tags(set);\n switch_back:\n \t/* The blk_mq_elv_switch_back unfreezes queue for us. */\n \tlist_for_each_entry(q, \u0026set-\u003etag_list, tag_set_list) {\n@@ -5194,6 +5274,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,\n \t\tblk_mq_remove_hw_queues_cpuhp(q);\n \t\tblk_mq_add_hw_queues_cpuhp(q);\n \t}\n+\tblk_mq_tagset_debugfs_create_tags(set);\n \n out_free_ctx:\n \tblk_mq_free_sched_ctx_batch(\u0026elv_tbl);\ndiff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h\nindex af878597afb8c..a80bc63a6e71c 100644\n--- a/include/linux/blk-mq.h\n+++ b/include/linux/blk-mq.h\n@@ -14,6 +14,7 @@\n struct blk_mq_tags;\n struct blk_flush_queue;\n struct io_comp_batch;\n+struct dentry;\n \n #define BLKDEV_MIN_RQ\t4\n #define BLKDEV_DEFAULT_RQ\t128\n@@ -517,6 +518,10 @@ enum hctx_type {\n *\t\t tag set.\n * @tags:\t Tag sets. One tag set per hardware queue. Has @nr_hw_queues\n *\t\t elements.\n+ * @mapped_tags_bitmap: Bitmap of hardware queue indices referenced by active\n+ *\t\t CPU maps. Rebuilt before publication or with update_nr_hwq_lock\n+ *\t\t held for writing. Tags for index 0 are retained as a fallback\n+ *\t\t even when its bit is clear.\n * @shared_tags:\n *\t\t Shared set of tags. Has @nr_hw_queues elements. If set,\n *\t\t shared by all @tags.\n@@ -530,6 +535,8 @@ enum hctx_type {\n * @update_nr_hwq_lock:\n * \t\t Synchronize updating nr_hw_queues with add/del disk \u0026\n * \t\t switching elevator.\n+ * @debugfs_dir: Debugfs directory for this tag set.\n+ * @debugfs_id: ID used as part of the debugfs directory name.\n */\n struct blk_mq_tag_set {\n \tconst struct blk_mq_ops\t*ops;\n@@ -545,6 +552,7 @@ struct blk_mq_tag_set {\n \tvoid\t\t\t*driver_data;\n \n \tstruct blk_mq_tags\t**tags;\n+\tunsigned long\t\t*mapped_tags_bitmap;\n \n \tstruct blk_mq_tags\t*shared_tags;\n \n@@ -554,6 +562,11 @@ struct blk_mq_tag_set {\n \tstruct srcu_struct\ttags_srcu;\n \n \tstruct rw_semaphore\tupdate_nr_hwq_lock;\n+\n+#ifdef CONFIG_BLK_DEBUG_FS\n+\tstruct dentry\t\t*debugfs_dir;\n+\tint\t\t\tdebugfs_id;\n+#endif\n };\n \n /**\n"
} |
| 2/1 | 2026/10/09 05:05 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": [
"DEBUG_FS",
"BLK_DEBUG_FS"
],
"FocusSymbols": [
"blk_mq_alloc_mapped_tags",
"blk_mq_free_unmapped_tags",
"blk_mq_update_mapped_tags_bitmap",
"blk_mq_update_nr_hw_queues",
"blk_mq_tagset_debugfs_register",
"blk_mq_tagset_debugfs_unregister",
"blk_mq_tagset_tags_read",
"blk_mq_tagset_map_show",
"blk_mq_tagset_flags_show",
"blk_mq_tagset_debugfs_create_tags",
"blk_mq_tagset_debugfs_remove_tags"
],
"Reasoning": "The patch modifies the core blk-mq subsystem by changing tagset management and software-to-hardware queue mapping (adding dynamic allocation/freeing of mapped/unmapped tags based on a newly introduced mapped_tags_bitmap, with defensive lock assertions). In addition, it exposes tagset debugfs attributes and directories with custom file operations and lifetime handling. These code paths are fully reachable in virtualized environments via block devices and debugfs.",
"WorthFuzzing": true
}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 792794fe2785fe34cc6ac6fa547bf2516b3772a3
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Oct 9 05:05:01 2026 +0000
syz-cluster: applied patch under review
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 6754d8f9449c1..78a91a1095bb5 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -7,6 +7,7 @@
#include <linux/blkdev.h>
#include <linux/build_bug.h>
#include <linux/debugfs.h>
+#include <linux/idr.h>
#include "blk.h"
#include "blk-mq.h"
@@ -643,11 +644,19 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent,
void blk_mq_debugfs_register(struct request_queue *q)
{
+ struct blk_mq_tag_set *set = q->tag_set;
struct blk_mq_hw_ctx *hctx;
unsigned long i;
+ char target[32];
debugfs_create_files(q, q->debugfs_dir, q, blk_mq_debugfs_queue_attrs);
+ if (!IS_ERR_OR_NULL(q->debugfs_dir) &&
+ !IS_ERR_OR_NULL(set->debugfs_dir) && set->debugfs_id >= 0) {
+ snprintf(target, sizeof(target), "../../tagset/%d", set->debugfs_id);
+ debugfs_create_symlink("tagset", q->debugfs_dir, target);
+ }
+
queue_for_each_hw_ctx(q, hctx, i) {
if (!hctx->debugfs_dir)
blk_mq_debugfs_register_hctx(q, hctx);
@@ -827,3 +836,292 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx)
debugfs_remove_recursive(hctx->sched_debugfs_dir);
hctx->sched_debugfs_dir = NULL;
}
+
+/* Tag set debugfs --------------------------------------------------------- */
+
+static DEFINE_IDA(blk_mq_tagset_debugfs_ida);
+static DEFINE_MUTEX(blk_mq_tagset_debugfs_mutex);
+static struct dentry *blk_mq_tagset_debugfs_root;
+
+/* Prevent debugfs allocation reclaim from issuing I/O to frozen queues. */
+static unsigned int __must_check blk_mq_tagset_debugfs_lock(void)
+ __acquires(&blk_mq_tagset_debugfs_mutex)
+{
+ unsigned int memflags = memalloc_noio_save();
+
+ mutex_lock(&blk_mq_tagset_debugfs_mutex);
+ return memflags;
+}
+
+static void blk_mq_tagset_debugfs_unlock(unsigned int memflags)
+ __releases(&blk_mq_tagset_debugfs_mutex)
+{
+ mutex_unlock(&blk_mq_tagset_debugfs_mutex);
+ memalloc_noio_restore(memflags);
+}
+
+#define BLK_MQ_F_NAME(name) \
+ [ilog2(BLK_MQ_F_##name)] = #name
+static const char *const tagset_flag_name[] = {
+ BLK_MQ_F_NAME(TAG_QUEUE_SHARED),
+ BLK_MQ_F_NAME(STACKING),
+ BLK_MQ_F_NAME(TAG_HCTX_SHARED),
+ BLK_MQ_F_NAME(BLOCKING),
+ BLK_MQ_F_NAME(TAG_RR),
+ BLK_MQ_F_NAME(NO_SCHED_BY_DEFAULT),
+};
+
+#undef BLK_MQ_F_NAME
+
+static int blk_mq_tagset_flags_show(struct seq_file *m, void *v)
+{
+ struct blk_mq_tag_set *set = m->private;
+
+ BUILD_BUG_ON(ARRAY_SIZE(tagset_flag_name) != ilog2(BLK_MQ_F_MAX));
+
+ down_read(&set->update_nr_hwq_lock);
+
+ blk_flags_show(m, set->flags, tagset_flag_name,
+ ARRAY_SIZE(tagset_flag_name));
+ seq_putc(m, '\n');
+
+ up_read(&set->update_nr_hwq_lock);
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_flags);
+
+#define BLK_MQ_TAGSET_VALUE_SHOW(_name, _type, _value, _format) \
+static int blk_mq_tagset_##_name##_show(struct seq_file *m, void *v) \
+{ \
+ struct blk_mq_tag_set *set = m->private; \
+ _type value; \
+\
+ down_read(&set->update_nr_hwq_lock); \
+ value = (_value); \
+ up_read(&set->update_nr_hwq_lock); \
+\
+ seq_printf(m, _format, value); \
+ return 0; \
+} \
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_##_name)
+
+BLK_MQ_TAGSET_VALUE_SHOW(nr_maps, unsigned int, set->nr_maps, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(nr_hw_queues, unsigned int, set->nr_hw_queues, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(queue_depth, unsigned int, set->queue_depth, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(reserved_tags, unsigned int, set->reserved_tags, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(cmd_size, unsigned int, set->cmd_size, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(numa_node, int, set->numa_node, "%d\n");
+BLK_MQ_TAGSET_VALUE_SHOW(timeout, unsigned int, set->timeout, "%u\n");
+
+#undef BLK_MQ_TAGSET_VALUE_SHOW
+
+static int blk_mq_tagset_hctx_tags_shared_show(struct seq_file *m, void *v)
+{
+ struct blk_mq_tag_set *set = m->private;
+ bool shared;
+
+ down_read(&set->update_nr_hwq_lock);
+ shared = blk_mq_is_shared_tags(set->flags);
+ up_read(&set->update_nr_hwq_lock);
+
+ seq_printf(m, "%d\n", shared);
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_hctx_tags_shared);
+
+static int blk_mq_tagset_map_show(struct seq_file *m, void *v)
+{
+ struct blk_mq_tag_set *set = m->private;
+ unsigned long index = debugfs_get_aux_num(m->file);
+ unsigned int map = index / nr_cpu_ids;
+ unsigned int cpu = index % nr_cpu_ids;
+
+ down_read(&set->update_nr_hwq_lock);
+
+ seq_printf(m, "%u\n", set->map[map].mq_map[cpu]);
+
+ up_read(&set->update_nr_hwq_lock);
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_map);
+
+static void blk_mq_tagset_debugfs_create_maps(struct blk_mq_tag_set *set)
+{
+ struct dentry *dir, *map_dir;
+ unsigned int cpu, i;
+ char name[20];
+
+ dir = debugfs_create_dir("map", set->debugfs_dir);
+ if (IS_ERR_OR_NULL(dir))
+ return;
+
+ for (i = 0; i < set->nr_maps; i++) {
+ snprintf(name, sizeof(name), "%u", i);
+ map_dir = debugfs_create_dir(name, dir);
+ if (IS_ERR_OR_NULL(map_dir))
+ continue;
+
+ for_each_possible_cpu(cpu) {
+ /* Encode the map and CPU indices in the auxiliary data. */
+ unsigned long index = (unsigned long)i * nr_cpu_ids + cpu;
+
+ snprintf(name, sizeof(name), "cpu%u", cpu);
+ debugfs_create_file_aux_num(name, 0444, map_dir, set,
+ index, &blk_mq_tagset_map_fops);
+ }
+ }
+}
+
+static ssize_t blk_mq_tagset_tags_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct dentry *dentry = file->f_path.dentry;
+ unsigned int nr_tags, nr_reserved_tags, active_queues;
+ struct blk_mq_tags *tags;
+ char buf[128];
+ int ret, len;
+
+ /*
+ * Tag updates remove these files before freeing the tags. Shared tags
+ * remain valid until tag set teardown removes the shared_tags file.
+ */
+ ret = debugfs_file_get(dentry);
+ if (ret)
+ return ret;
+
+ tags = file->private_data;
+ if (!tags) {
+ debugfs_file_put(dentry);
+ return -ENODEV;
+ }
+
+ nr_tags = tags->nr_tags;
+ nr_reserved_tags = tags->nr_reserved_tags;
+ active_queues = READ_ONCE(tags->active_queues);
+ debugfs_file_put(dentry);
+
+ /*
+ * A fault on the user buffer may need I/O to a frozen queue. Drop the
+ * active reference first so file removal does not wait for that I/O.
+ */
+ len = scnprintf(buf, sizeof(buf),
+ ".nr_tags=%u\n.nr_reserved_tags=%u\n.active_queues=%u\n",
+ nr_tags, nr_reserved_tags, active_queues);
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static const struct file_operations blk_mq_tagset_tags_fops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = blk_mq_tagset_tags_read,
+ .llseek = default_llseek,
+};
+
+void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set)
+{
+ if (IS_ERR_OR_NULL(set->debugfs_dir))
+ return;
+
+ debugfs_lookup_and_remove("tags", set->debugfs_dir);
+}
+
+void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set)
+{
+ struct dentry *dir;
+ unsigned int i;
+ char name[20];
+
+ if (IS_ERR_OR_NULL(set->debugfs_dir))
+ return;
+
+ dir = debugfs_create_dir("tags", set->debugfs_dir);
+ if (IS_ERR_OR_NULL(dir))
+ return;
+
+ for (i = 0; i < set->nr_hw_queues; i++) {
+ struct blk_mq_tags *tags = set->tags[i];
+
+ snprintf(name, sizeof(name), "%u", i);
+ if (tags && tags == set->shared_tags)
+ debugfs_create_symlink(name, dir, "../shared_tags");
+ else
+ debugfs_create_file_unsafe(name, 0444, dir, tags,
+ &blk_mq_tagset_tags_fops);
+ }
+}
+
+static void blk_mq_tagset_debugfs_create_files(struct blk_mq_tag_set *set)
+{
+ debugfs_create_file("nr_maps", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_nr_maps_fops);
+ debugfs_create_file("nr_hw_queues", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_nr_hw_queues_fops);
+ debugfs_create_file("queue_depth", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_queue_depth_fops);
+ debugfs_create_file("reserved_tags", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_reserved_tags_fops);
+ debugfs_create_file("cmd_size", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_cmd_size_fops);
+ debugfs_create_file("numa_node", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_numa_node_fops);
+ debugfs_create_file("timeout", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_timeout_fops);
+ debugfs_create_file("hctx_tags_shared", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_hctx_tags_shared_fops);
+ debugfs_create_file("flags", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_flags_fops);
+ blk_mq_tagset_debugfs_create_maps(set);
+ debugfs_create_file_unsafe("shared_tags", 0444, set->debugfs_dir,
+ set->shared_tags, &blk_mq_tagset_tags_fops);
+ blk_mq_tagset_debugfs_create_tags(set);
+}
+
+void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set)
+{
+ struct dentry *dir;
+ unsigned int memflags;
+ char name[24];
+ int id;
+
+ memflags = blk_mq_tagset_debugfs_lock();
+
+ if (IS_ERR_OR_NULL(blk_mq_tagset_debugfs_root))
+ blk_mq_tagset_debugfs_root = debugfs_create_dir("tagset", NULL);
+
+ if (set->debugfs_dir || IS_ERR_OR_NULL(blk_mq_tagset_debugfs_root))
+ goto out_unlock;
+
+ id = ida_alloc(&blk_mq_tagset_debugfs_ida, GFP_KERNEL);
+ if (id < 0)
+ goto out_unlock;
+
+ snprintf(name, sizeof(name), "%d", id);
+ dir = debugfs_create_dir(name, blk_mq_tagset_debugfs_root);
+ if (IS_ERR_OR_NULL(dir)) {
+ ida_free(&blk_mq_tagset_debugfs_ida, id);
+ goto out_unlock;
+ }
+
+ set->debugfs_id = id;
+ set->debugfs_dir = dir;
+ blk_mq_tagset_debugfs_create_files(set);
+
+out_unlock:
+ blk_mq_tagset_debugfs_unlock(memflags);
+}
+
+void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set)
+{
+ mutex_lock(&blk_mq_tagset_debugfs_mutex);
+
+ debugfs_remove_recursive(set->debugfs_dir);
+ set->debugfs_dir = NULL;
+
+ if (set->debugfs_id >= 0) {
+ ida_free(&blk_mq_tagset_debugfs_ida, set->debugfs_id);
+ set->debugfs_id = -1;
+ }
+
+ mutex_unlock(&blk_mq_tagset_debugfs_mutex);
+}
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index 49bb1aaa83dc7..aea278bdc4e78 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -7,6 +7,7 @@
#include <linux/seq_file.h>
struct blk_mq_hw_ctx;
+struct blk_mq_tag_set;
struct blk_mq_debugfs_attr {
const char *name;
@@ -34,6 +35,11 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);
void blk_mq_debugfs_register_rq_qos(struct request_queue *q);
+
+void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set);
+void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set);
+void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set);
+void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set);
#else
static inline void blk_mq_debugfs_register(struct request_queue *q)
{
@@ -77,6 +83,22 @@ static inline void blk_mq_debugfs_register_rq_qos(struct request_queue *q)
{
}
+static inline void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set)
+{
+}
+
+static inline void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set)
+{
+}
+
+static inline void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set)
+{
+}
+
+static inline void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set)
+{
+}
+
#endif
#if defined(CONFIG_BLK_DEV_ZONED) && defined(CONFIG_BLK_DEBUG_FS)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index a26a11c73ee3e..f32d2df044dcc 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -9,6 +9,7 @@
#include <linux/module.h>
#include <linux/backing-dev.h>
#include <linux/bio.h>
+#include <linux/bitmap.h>
#include <linux/blkdev.h>
#include <linux/blk-integrity.h>
#include <linux/kmemleak.h>
@@ -4159,9 +4160,74 @@ static void __blk_mq_free_map_and_rqs(struct blk_mq_tag_set *set,
set->tags[hctx_idx] = NULL;
}
+static void blk_mq_update_mapped_tags_bitmap(struct blk_mq_tag_set *set)
+{
+ unsigned int i, cpu;
+
+ bitmap_zero(set->mapped_tags_bitmap, set->nr_hw_queues);
+ if (set->nr_hw_queues == 1) {
+ __set_bit(0, set->mapped_tags_bitmap);
+ return;
+ }
+
+ for (i = 0; i < set->nr_maps; i++) {
+ struct blk_mq_queue_map *map = &set->map[i];
+
+ if (!map->nr_queues)
+ continue;
+ for_each_possible_cpu(cpu)
+ __set_bit(map->mq_map[cpu], set->mapped_tags_bitmap);
+ }
+}
+
+static void blk_mq_alloc_mapped_tags(struct blk_mq_tag_set *set)
+{
+ unsigned int cpu, i;
+ bool remapped = false;
+
+ lockdep_assert_held_write(&set->update_nr_hwq_lock);
+
+ for_each_possible_cpu(cpu) {
+ for (i = 0; i < set->nr_maps; i++) {
+ struct blk_mq_queue_map *map = &set->map[i];
+ unsigned int hctx_idx;
+
+ if (!map->nr_queues)
+ continue;
+ hctx_idx = map->mq_map[cpu];
+ if (!set->tags[hctx_idx] &&
+ !__blk_mq_alloc_map_and_rqs(set, hctx_idx)) {
+ /* Queue 0 always has tags available for fallback. */
+ map->mq_map[cpu] = 0;
+ remapped = true;
+ }
+ }
+ }
+ if (remapped)
+ blk_mq_update_mapped_tags_bitmap(set);
+}
+
+static bool blk_mq_tagset_tags_mapped(struct blk_mq_tag_set *set,
+ unsigned int hctx_idx)
+{
+ return test_bit(hctx_idx, set->mapped_tags_bitmap);
+}
+
+/* The queue maps must be stable and the unused tags no longer in use. */
+static void blk_mq_free_unmapped_tags(struct blk_mq_tag_set *set)
+{
+ unsigned int i;
+
+ /* Keep queue 0 as a fallback if a later tag allocation fails. */
+ for (i = 1; i < set->nr_hw_queues; i++) {
+ if (set->tags[i] && !blk_mq_tagset_tags_mapped(set, i))
+ __blk_mq_free_map_and_rqs(set, i);
+ }
+}
+
static void blk_mq_map_swqueue(struct request_queue *q)
{
- unsigned int j, hctx_idx;
+ unsigned int j;
unsigned long i;
struct blk_mq_hw_ctx *hctx;
struct blk_mq_ctx *ctx;
@@ -4173,11 +4239,7 @@ static void blk_mq_map_swqueue(struct request_queue *q)
hctx->dispatch_from = NULL;
}
- /*
- * Map software to hardware queues.
- *
- * If the cpu isn't present, the cpu is mapped to first hctx.
- */
+ /* Map software to hardware queues. */
for_each_possible_cpu(i) {
ctx = per_cpu_ptr(q->queue_ctx, i);
@@ -4187,19 +4249,6 @@ static void blk_mq_map_swqueue(struct request_queue *q)
HCTX_TYPE_DEFAULT, i);
continue;
}
- hctx_idx = set->map[j].mq_map[i];
- /* unmapped hw queue can be remapped after CPU topo changed */
- if (!set->tags[hctx_idx] &&
- !__blk_mq_alloc_map_and_rqs(set, hctx_idx)) {
- /*
- * If tags initialization fail for some hctx,
- * that hctx won't be brought online. In this
- * case, remap the current ctx to hctx[0] which
- * is guaranteed to always have tags allocated
- */
- set->map[j].mq_map[i] = 0;
- }
-
hctx = blk_mq_map_queue_type(q, j, i);
ctx->hctxs[j] = hctx;
/*
@@ -4230,18 +4279,8 @@ static void blk_mq_map_swqueue(struct request_queue *q)
queue_for_each_hw_ctx(q, hctx, i) {
int cpu;
- /*
- * If no software queues are mapped to this hardware queue,
- * disable it and free the request entries.
- */
+ /* Disable hardware queues with no mapped software queues. */
if (!hctx->nr_ctx) {
- /* Never unmap queue 0. We need it as a
- * fallback in case of a new remap fails
- * allocation
- */
- if (i)
- __blk_mq_free_map_and_rqs(set, i);
-
hctx->tags = NULL;
continue;
}
@@ -4782,12 +4821,18 @@ static void blk_mq_update_queue_map(struct blk_mq_tag_set *set)
BUG_ON(set->nr_maps > 1);
blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
}
+ blk_mq_update_mapped_tags_bitmap(set);
}
+/*
+ * On successful growth, also install a larger mapped_tags_bitmap. The caller
+ * rebuilds its contents when updating the queue maps under update_nr_hwq_lock.
+ */
static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(
struct blk_mq_tag_set *set,
int new_nr_hw_queues)
{
+ unsigned long *new_mapped_tags_bitmap;
struct blk_mq_tags **new_tags;
int i;
@@ -4799,6 +4844,13 @@ static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(
if (!new_tags)
return ERR_PTR(-ENOMEM);
+ new_mapped_tags_bitmap = bitmap_zalloc_node(new_nr_hw_queues, GFP_KERNEL,
+ set->numa_node);
+ if (!new_mapped_tags_bitmap) {
+ kfree(new_tags);
+ return ERR_PTR(-ENOMEM);
+ }
+
if (set->tags)
memcpy(new_tags, set->tags, set->nr_hw_queues *
sizeof(*set->tags));
@@ -4815,12 +4867,15 @@ static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(
cond_resched();
}
+ bitmap_free(set->mapped_tags_bitmap);
+ set->mapped_tags_bitmap = new_mapped_tags_bitmap;
return new_tags;
out_unwind:
while (--i >= set->nr_hw_queues) {
if (!blk_mq_is_shared_tags(set->flags))
blk_mq_free_map_and_rqs(set, new_tags[i], i);
}
+ bitmap_free(new_mapped_tags_bitmap);
kfree(new_tags);
return ERR_PTR(-ENOMEM);
}
@@ -4884,9 +4939,17 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
if (ret)
goto out_free_srcu;
}
+
+ set->mapped_tags_bitmap = bitmap_zalloc_node(set->nr_hw_queues, GFP_KERNEL,
+ set->numa_node);
+ if (!set->mapped_tags_bitmap) {
+ ret = -ENOMEM;
+ goto out_cleanup_srcu;
+ }
+
ret = init_srcu_struct(&set->tags_srcu);
if (ret)
- goto out_cleanup_srcu;
+ goto out_free_mapped_tags_bitmap;
init_rwsem(&set->update_nr_hwq_lock);
@@ -4911,9 +4974,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
ret = blk_mq_alloc_set_map_and_rqs(set);
if (ret)
goto out_free_mq_map;
+ blk_mq_free_unmapped_tags(set);
mutex_init(&set->tag_list_lock);
INIT_LIST_HEAD(&set->tag_list);
+#ifdef CONFIG_BLK_DEBUG_FS
+ set->debugfs_id = -1;
+#endif
+ blk_mq_tagset_debugfs_register(set);
return 0;
@@ -4926,6 +4994,9 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
set->tags = NULL;
out_cleanup_tags_srcu:
cleanup_srcu_struct(&set->tags_srcu);
+out_free_mapped_tags_bitmap:
+ bitmap_free(set->mapped_tags_bitmap);
+ set->mapped_tags_bitmap = NULL;
out_cleanup_srcu:
if (set->flags & BLK_MQ_F_BLOCKING)
cleanup_srcu_struct(set->srcu);
@@ -4956,6 +5027,8 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
{
int i, j;
+ blk_mq_tagset_debugfs_unregister(set);
+
for (i = 0; i < set->nr_hw_queues; i++)
__blk_mq_free_map_and_rqs(set, i);
@@ -4972,6 +5045,9 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
kfree(set->tags);
set->tags = NULL;
+ bitmap_free(set->mapped_tags_bitmap);
+ set->mapped_tags_bitmap = NULL;
+
srcu_barrier(&set->tags_srcu);
cleanup_srcu_struct(&set->tags_srcu);
if (set->flags & BLK_MQ_F_BLOCKING) {
@@ -5137,6 +5213,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
blk_mq_debugfs_unregister_hctxs(q);
blk_mq_sysfs_unregister_hctxs(q);
}
+ blk_mq_tagset_debugfs_remove_tags(set);
/*
* Switch IO scheduler to 'none', cleaning up the data associated
@@ -5162,6 +5239,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
fallback:
blk_mq_update_queue_map(set);
+ blk_mq_alloc_mapped_tags(set);
list_for_each_entry(q, &set->tag_list, tag_set_list) {
__blk_mq_realloc_hw_ctxs(set, q);
@@ -5178,6 +5256,8 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
}
blk_mq_map_swqueue(q);
}
+ /* All queues have stopped using tags excluded by the new maps. */
+ blk_mq_free_unmapped_tags(set);
switch_back:
/* The blk_mq_elv_switch_back unfreezes queue for us. */
list_for_each_entry(q, &set->tag_list, tag_set_list) {
@@ -5194,6 +5274,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
blk_mq_remove_hw_queues_cpuhp(q);
blk_mq_add_hw_queues_cpuhp(q);
}
+ blk_mq_tagset_debugfs_create_tags(set);
out_free_ctx:
blk_mq_free_sched_ctx_batch(&elv_tbl);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index af878597afb8c..a80bc63a6e71c 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -14,6 +14,7 @@
struct blk_mq_tags;
struct blk_flush_queue;
struct io_comp_batch;
+struct dentry;
#define BLKDEV_MIN_RQ 4
#define BLKDEV_DEFAULT_RQ 128
@@ -517,6 +518,10 @@ enum hctx_type {
* tag set.
* @tags: Tag sets. One tag set per hardware queue. Has @nr_hw_queues
* elements.
+ * @mapped_tags_bitmap: Bitmap of hardware queue indices referenced by active
+ * CPU maps. Rebuilt before publication or with update_nr_hwq_lock
+ * held for writing. Tags for index 0 are retained as a fallback
+ * even when its bit is clear.
* @shared_tags:
* Shared set of tags. Has @nr_hw_queues elements. If set,
* shared by all @tags.
@@ -530,6 +535,8 @@ enum hctx_type {
* @update_nr_hwq_lock:
* Synchronize updating nr_hw_queues with add/del disk &
* switching elevator.
+ * @debugfs_dir: Debugfs directory for this tag set.
+ * @debugfs_id: ID used as part of the debugfs directory name.
*/
struct blk_mq_tag_set {
const struct blk_mq_ops *ops;
@@ -545,6 +552,7 @@ struct blk_mq_tag_set {
void *driver_data;
struct blk_mq_tags **tags;
+ unsigned long *mapped_tags_bitmap;
struct blk_mq_tags *shared_tags;
@@ -554,6 +562,11 @@ struct blk_mq_tag_set {
struct srcu_struct tags_srcu;
struct rw_semaphore update_nr_hwq_lock;
+
+#ifdef CONFIG_BLK_DEBUG_FS
+ struct dentry *debugfs_dir;
+ int debugfs_id;
+#endif
};
/**
|
| 3/2 | 2026/10/09 05:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 12089 output: 30 thoughts: 1232 Thoughts: **Patch Analysis: Blk-mq Debugfs Integration** Alright, let's dive into this patch. Target architecture is amd64, which is typical. First, I need to understand what's being changed here. The diff touches `block/blk-mq-debugfs.c`, `block/blk-mq-debugfs.h`, `block/blk-mq.c`, and `include/linux/blk-mq.h`. Looks like we're integrating debugfs functionality for tagset information in the block multi-queue layer. Specifically, in the debugfs files, new functions are being added for registering, unregistering, creating, and removing tagset debugfs entries. Show functions are included to display various tagset-related information. A debugfs symlink is created: "tagset" pointing to `../../tagset/%d`. The core logic modifications are within `block/blk-mq.c`. I see functions like `blk_mq_update_mapped_tags_bitmap`, `blk_mq_alloc_mapped_tags`, `blk_mq_tagset_tags_mapped`, `blk_mq_free_unmapped_tags`, being touched, which are important parts of tag allocation, queue mapping, and bitmap management. `blk_mq_map_swqueue` is modified to remove tag allocation from inside map_swqueue loop and hw queue disable freeing, and changes are made to `blk_mq_update_queue_map`, `blk_mq_prealloc_tag_set_tags`, `blk_mq_alloc_tag_set`, `blk_mq_free_tag_set`, and `__blk_mq_update_nr_hw_queues`. This confirms we're dealing with substantial changes in blk-mq core functionality. This is important since blk-mq is a foundational layer for block devices in the kernel. Now the critical question is, can this be fuzzed? Absolutely! This is directly related to block devices, and there are several ways to trigger this code, including loop devices, virtio-blk, nbd, and, importantly, null_blk. Null_blk, which is commonly fuzzed by syzkaller, allows configuring the number of hardware queues, submit queues, and shared tags via configfs. Standard block devices, creating/deleting loop devices (using `ioctl LOOP_SET_FD`), modifying queue settings, and reading debugfs entries are all potential fuzzing targets. Considering the patch is modifying core block layer code (specifically memory management, queue mapping, and bitmap/lock usage within blk-mq), and the debugfs integration provides a user-accessible interface, the "WorthFuzzing=true" flag applies without a doubt. The reachability criterion is easily met. This patch is definitely worth fuzzing and should be flagged as such. Let me just confirm if `CONFIG_BLK_DEBUG_FS` or other relevant config options are needed here. I'll need to check the Kconfig and/or use grepper for that. |
| 4/2 | 2026/10/09 05:05 | tool | grepper |
0mArgs:{
"Expression": "config BLK_DEBUG_FS",
"PathPrefixes": [
"block/"
]
}Results: {
"Output": "block/Kconfig=164=config BLK_CGROUP_IOPRIO\n--\nblock/Kconfig-172-\nblock/Kconfig:173:config BLK_DEBUG_FS\nblock/Kconfig-174-\tbool \"Block layer debugging information in debugfs\"\n"
} |
| 5/2 | 2026/10/09 05:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14077 output: 32 thoughts: 28 Thoughts: Okay, let's dive into this. Here's how I'd approach that kernel configuration investigation: **Investigating `BLK_DEBUG_FS` Dependencies** Alright, so the task at hand is to understand the dependencies of `BLK_DEBUG_FS`. My usual approach is to go straight to the source – the `Kconfig` file. And given the context, I'm pretty certain that the relevant definition lives within the `block/Kconfig` file. Specifically, I'm going to jump to around line 173. Hopefully, this line will contain the definition itself, or at least a section that defines or influences `BLK_DEBUG_FS`. I'm expecting to find `depends on` clauses that spell out the other configuration options that must be enabled before `BLK_DEBUG_FS` can even be considered. I'll need to parse that carefully. After reading that, I can deduce how it might affect the overall system configuration. |
| 6/2 | 2026/10/09 05:05 | tool | read-file |
0mArgs:{
"File": "block/Kconfig",
"FirstLine": 170,
"LineCount": 20
}Results: {
"Contents": " 170:\t\tscheduler and block devices process requests. Only some I/O schedulers\n 171:\t\tand some block devices support I/O priorities.\n 172:\t\n 173:\tconfig BLK_DEBUG_FS\n 174:\t\tbool \"Block layer debugging information in debugfs\"\n 175:\t\tdefault y\n 176:\t\tdepends on DEBUG_FS\n 177:\t\thelp\n 178:\t\tInclude block layer debugging information in debugfs. This information\n 179:\t\tis mostly useful for kernel developers, but it doesn't incur any cost\n 180:\t\tat runtime.\n 181:\t\n 182:\t\tUnless you are building a kernel for a tiny system, you should\n 183:\t\tsay Y here.\n 184:\t\n 185:\tconfig BLK_SED_OPAL\n 186:\t\tbool \"Logic for interfacing with Opal enabled SEDs\"\n 187:\t\tdepends on KEYS\n 188:\t\tselect PSERIES_PLPKS if PPC_PSERIES\n 189:\t\tselect PSERIES_PLPKS_SED if PPC_PSERIES\n"
} |
| 7/2 | 2026/10/09 05:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14639 output: 30 thoughts: 276 Thoughts: **My Configuration Quandary** Okay, here's the deal. I'm focusing on these kernel configurations and need to be precise. My initial understanding is that `BLK_DEBUG_FS` inherently depends on `DEBUG_FS`, which makes sense. And, obviously, `BLK_MQ` is fundamental to the block layer, so that's always enabled when the block layer is active. But then I start thinking, "What *specifically* do I need enabled in my kernel config?" I immediately zero in on `BLK_DEBUG_FS` and `DEBUG_FS`, those are the obvious ones. I'm wondering about `BLK_DEV_NULL_BLK` - is that essential, or is it just part of the default configuration? Gotta be sure. Right, the instructions are clear: *no assumptions*. I need to thoroughly analyze the Kconfig files, chase down those `#ifdef` guards, and meticulously check those "depends on" lines. Got it. And strip out those pesky 'CONFIG_' prefixes, of course, that's just good practice. Now, from the code, I see that changes in `block/blk-mq.c` are compiled unconditionally since the block layer is standard. But, the debugfs parts in `block/blk-mq-debugfs.c` and those `#ifdef CONFIG_BLK_DEBUG_FS` blocks in `include/linux/blk-mq.h` *specifically* require `BLK_DEBUG_FS` and `DEBUG_FS`. Bingo. Time to double-check how `block/blk-mq-debugfs.c` is actually built, and I'll go straight to `block/Makefile`. |
| 8/2 | 2026/10/09 05:05 | tool | grepper |
0mArgs:{
"Expression": "blk-mq-debugfs",
"PathPrefixes": [
"block/Makefile"
]
}Results: {
"Output": "block/Makefile=34=obj-$(CONFIG_BLK_WBT)\t\t+= blk-wbt.o\nblock/Makefile:35:obj-$(CONFIG_BLK_DEBUG_FS)\t+= blk-mq-debugfs.o\nblock/Makefile-36-obj-$(CONFIG_BLK_SED_OPAL)\t+= sed-opal.o\n"
} |
| 9/2 | 2026/10/09 05:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15393 output: 40 thoughts: 1414 Thoughts: **Focusing on Block Device Debugging with FocusSymbols** Okay, so I'm looking at this patch and how to fuzz it effectively. First, `blk-mq-debugfs.o` is being added, and that's dependent on `BLK_DEBUG_FS` which, in turn, depends on `DEBUG_FS`. So, both `BLK_DEBUG_FS` and `DEBUG_FS` need to be enabled for this to even compile and get us to `block/blk-mq-debugfs.c`. Makes sense. Now, let's think about FocusSymbols. The documentation is clear: we want to avoid the really common stuff – allocators, page fault handlers, core sync primitives. Instead, we want specific entrypoints or functions that implement the *logic* of the new feature or the changes made. I've gone through the code to identify the key functions added or modified. In `blk-mq-debugfs.c`, we have `blk_mq_debugfs_register` (modified), along with a bunch of functions related to creating and displaying debugfs files for tagset information: `blk_mq_tagset_flags_show`, `blk_mq_tagset_hctx_tags_shared_show`, `blk_mq_tagset_map_show`, `blk_mq_tagset_debugfs_create_maps`, `blk_mq_tagset_tags_read`, etc. There are also those macro-generated functions like `blk_mq_tagset_nr_maps_show` and the like. Then, over in `blk-mq.c`, we see functions like `blk_mq_update_mapped_tags_bitmap`, `blk_mq_alloc_mapped_tags`, `blk_mq_free_unmapped_tags`, `blk_mq_map_swqueue`, `blk_mq_update_queue_map`, and a few others dealing with tag set management. Now, I need to check something: are any of those `blk_mq_update_mapped_tags_bitmap`, `blk_mq_alloc_mapped_tags`, or `blk_mq_free_unmapped_tags` static, or are they getting inlined? I can't directly target inline functions with FocusSymbols. Yep, those three are `static`. They are not what I want. However `blk_mq_map_swqueue`, `blk_mq_update_queue_map`, and `__blk_mq_update_nr_hw_queues` are available as separate functions. So, let's narrow down which of these are the *right* symbols to use. I'm focusing on the debugfs registration and unregistration functions, the tag information readers, and the core management functions that are *not* lifecycle related: `blk_mq_tagset_debugfs_register`, `blk_mq_tagset_debugfs_unregister`, `blk_mq_tagset_tags_read`, `blk_mq_tagset_map_show`, `blk_mq_tagset_flags_show`. From `blk-mq.c`, I'm looking at `blk_mq_alloc_mapped_tags`, `blk_mq_free_unmapped_tags`, `blk_mq_update_mapped_tags_bitmap`, `__blk_mq_update_nr_hw_queues`, `blk_mq_map_swqueue`, and `blk_mq_update_queue_map`. These functions seem very specific to the added feature logic. I have to be careful with things like `blk_mq_alloc_tag_set` and `blk_mq_free_tag_set`. While they are not general memory allocators, they are lifecycle functions called by *every* block device driver. That’s probably too ubiquitous for a focus symbol. Okay, I think I have a solid list of functions that make sense for fuzzing with FocusSymbols! |
| 10/2 | 2026/10/09 05:05 | tool | grepper |
0mArgs:{
"Expression": "blk_mq_update_nr_hw_queues",
"PathPrefixes": [
"block/",
"drivers/"
]
}Results: {
"Output": "block/blk-mq-tag.c=502=void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_tag_iter_fn *fn,\n--\nblock/blk-mq-tag.c-507-\t/*\nblock/blk-mq-tag.c:508:\t * __blk_mq_update_nr_hw_queues() updates nr_hw_queues and queue_hw_ctx\nblock/blk-mq-tag.c-509-\t * while the queue is frozen. So we can use q_usage_counter to avoid\n--\nblock/blk-mq.c=5143=static int blk_mq_elv_switch_none(struct request_queue *q,\n--\nblock/blk-mq.c-5182-\nblock/blk-mq.c:5183:static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,\nblock/blk-mq.c-5184-\t\t\t\t\t\t\tint nr_hw_queues)\n--\nblock/blk-mq.c-5288-\nblock/blk-mq.c:5289:void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)\nblock/blk-mq.c-5290-{\n--\nblock/blk-mq.c-5292-\tmutex_lock(\u0026set-\u003etag_list_lock);\nblock/blk-mq.c:5293:\t__blk_mq_update_nr_hw_queues(set, nr_hw_queues);\nblock/blk-mq.c-5294-\tmutex_unlock(\u0026set-\u003etag_list_lock);\n--\nblock/blk-mq.c-5296-}\nblock/blk-mq.c:5297:EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);\nblock/blk-mq.c-5298-\n--\ndrivers/block/nbd.c=1512=static int nbd_start_device(struct nbd_device *nbd)\n--\ndrivers/block/nbd.c-1529-\tmutex_unlock(\u0026nbd-\u003econfig_lock);\ndrivers/block/nbd.c:1530:\tblk_mq_update_nr_hw_queues(\u0026nbd-\u003etag_set, num_connections);\ndrivers/block/nbd.c-1531-\tmutex_lock(\u0026nbd-\u003econfig_lock);\n--\ndrivers/block/nbd.c=2684=static int __init nbd_init(void)\n--\ndrivers/block/nbd.c-2739-\t * Set to the intended connection count so nbd_start_device() can skip\ndrivers/block/nbd.c:2740:\t * the queue-freezing blk_mq_update_nr_hw_queues() call.\ndrivers/block/nbd.c-2741-\t */\n--\ndrivers/block/null_blk/main.c=384=static int nullb_update_nr_hw_queues(struct nullb_device *dev,\n--\ndrivers/block/null_blk/main.c-429-\tnr_hw_queues = submit_queues + poll_queues;\ndrivers/block/null_blk/main.c:430:\tblk_mq_update_nr_hw_queues(set, nr_hw_queues);\ndrivers/block/null_blk/main.c-431-\tret = set-\u003enr_hw_queues == nr_hw_queues ? 0 : -ENOMEM;\n--\ndrivers/block/xen-blkfront.c=2062=static int blkfront_resume(struct xenbus_device *dev)\n--\ndrivers/block/xen-blkfront.c-2119-\tif (!err)\ndrivers/block/xen-blkfront.c:2120:\t\tblk_mq_update_nr_hw_queues(\u0026info-\u003etag_set, info-\u003enr_rings);\ndrivers/block/xen-blkfront.c-2121-\n--\ndrivers/nvme/host/apple.c=1038=static void apple_nvme_reset_work(struct work_struct *work)\n--\ndrivers/nvme/host/apple.c-1206-\tnvme_wait_freeze(\u0026anv-\u003ectrl);\ndrivers/nvme/host/apple.c:1207:\tblk_mq_update_nr_hw_queues(\u0026anv-\u003etagset, 1);\ndrivers/nvme/host/apple.c-1208-\tnvme_unfreeze(\u0026anv-\u003ectrl);\n--\ndrivers/nvme/host/fc.c=2924=nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)\n--\ndrivers/nvme/host/fc.c-2955-\t\t\tprior_ioq_cnt, nr_io_queues);\ndrivers/nvme/host/fc.c:2956:\t\tblk_mq_update_nr_hw_queues(\u0026ctrl-\u003etag_set, nr_io_queues);\ndrivers/nvme/host/fc.c-2957-\t}\n--\ndrivers/nvme/host/pci.c=3184=static bool nvme_pci_update_nr_queues(struct nvme_dev *dev)\n--\ndrivers/nvme/host/pci.c-3201-\ndrivers/nvme/host/pci.c:3202:\tblk_mq_update_nr_hw_queues(\u0026dev-\u003etagset, dev-\u003eonline_queues - 1);\ndrivers/nvme/host/pci.c-3203-\t/* free previously allocated queues that are no longer usable */\n--\ndrivers/nvme/host/rdma.c=881=static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)\n--\ndrivers/nvme/host/rdma.c-930-\t\t}\ndrivers/nvme/host/rdma.c:931:\t\tblk_mq_update_nr_hw_queues(ctrl-\u003ectrl.tagset,\ndrivers/nvme/host/rdma.c-932-\t\t\tctrl-\u003ectrl.queue_count - 1);\n--\ndrivers/nvme/host/tcp.c=2240=static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)\n--\ndrivers/nvme/host/tcp.c-2279-\t\t}\ndrivers/nvme/host/tcp.c:2280:\t\tblk_mq_update_nr_hw_queues(ctrl-\u003etagset,\ndrivers/nvme/host/tcp.c-2281-\t\t\tctrl-\u003equeue_count - 1);\n--\ndrivers/nvme/target/loop.c=440=static void nvme_loop_reset_ctrl_work(struct work_struct *work)\n--\ndrivers/nvme/target/loop.c-470-\ndrivers/nvme/target/loop.c:471:\tblk_mq_update_nr_hw_queues(\u0026ctrl-\u003etag_set,\ndrivers/nvme/target/loop.c-472-\t\t\tctrl-\u003ectrl.queue_count - 1);\n"
} |
| 11/2 | 2026/10/09 05:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19533 output: 18 thoughts: 1035 Thoughts: **Fuzzing Target Assessment: Block Layer Tagset and Debugfs Interactions** Okay, let's break this down systematically. I need to determine if this code is a good candidate for fuzzing. I see `blk_mq_update_nr_hw_queues` is called from various places like `null_blk` and `nbd`, which are known block device configurations. Functions like `blk_mq_alloc_mapped_tags`, `blk_mq_free_unmapped_tags`, and `blk_mq_update_mapped_tags_bitmap` are connected to the tagset allocation and management process. Then there's the debugfs aspect; reading files under `/sys/kernel/debug/tagset/` or `/sys/kernel/debug/block/.../tagset/` triggers functions like `blk_mq_tagset_tags_read`, `blk_mq_tagset_map_show`, and `blk_mq_tagset_flags_show`. The initial assessment, `WorthFuzzing=true`, appears correct. The patch hits core block layer code within `blk-mq` and debugfs interfaces, which means it’s within the realm of potential fuzzing targets. This is especially true because it introduces several elements that can be leveraged by a fuzzer: * It introduces a `mapped_tags_bitmap`, which will involve dynamic allocation and freeing of tags, which is always interesting from a memory management perspective. * The assertions using `lockdep_assert_held_write` are good targets for concurrency-oriented fuzzing because they are concurrency checks. * The new debugfs directories and functions present additional attack surface, especially with unsafe file handlers and locking mechanisms. We have `debugfs_create_file_unsafe`, `debugfs_file_get`, mutexes and `memalloc_noio_save` - these all indicate potential areas for exploitation. * The modification of sw-to-hw queue mapping and the queue update flows are also significant. All of this can be reached easily within common virtualization environments like QEMU and GCE, since it relies on block devices, loop devices, and debugfs interactions, all of which are very easily set up. Now for the required configs, I need to make sure I have the necessary environment. I'll need `BLK_DEBUG_FS` and `DEBUG_FS`. They are required to enable access to the debugfs functionality that this patch introduces. Next, I need to define the `FocusSymbols`. Let's identify the most promising function calls. I'll focus on the functions introduced or modified by this patch that are *not* ubiquitous. I'm focusing on the more specialized functions and not core memory management or syscall dispatchers. I'll use those that expose the new functionality: * `blk_mq_alloc_mapped_tags` * `blk_mq_free_unmapped_tags` * `blk_mq_update_mapped_tags_bitmap` * `blk_mq_update_nr_hw_queues` * `blk_mq_tagset_debugfs_register` * `blk_mq_tagset_debugfs_unregister` * `blk_mq_tagset_tags_read` * `blk_mq_tagset_map_show` * `blk_mq_tagset_flags_show` * `blk_mq_tagset_debugfs_create_tags` * `blk_mq_tagset_debugfs_remove_tags` Let's double-check the function names in the diff, just to be precise. I'll verify the static/non-static status of each to see if that matters for linking and coverage: * `blk_mq_tagset_flags_show` (static) * `blk_mq_tagset_map_show` (static) * `blk_mq_tagset_tags_read` (static) * `blk_mq_tagset_debugfs_register` (non-static) * `blk_mq_tagset_debugfs_unregister` (non-static) * `blk_mq_tagset_debugfs_create_tags` (non-static) * `blk_mq_tagset_debugfs_remove_tags` (non-static) * `blk_mq_update_mapped_tags_bitmap` (static) * `blk_mq_alloc_mapped_tags` (static) * `blk_mq_free_unmapped_tags` (static) * `blk_mq_update_nr_hw_queues` |
| 12/2 | 2026/10/09 05:06 | tool | grepper |
0mArgs:{
"Expression": "config DEBUG_FS"
}Results: {
"Output": "lib/Kconfig.debug=698=config MAGIC_SYSRQ_SERIAL_SEQUENCE\n--\nlib/Kconfig.debug-707-\nlib/Kconfig.debug:708:config DEBUG_FS\nlib/Kconfig.debug-709-\tbool \"Debug Filesystem\"\n--\nlib/Kconfig.debug=720=choice\n--\nlib/Kconfig.debug-729-\nlib/Kconfig.debug:730:config DEBUG_FS_ALLOW_ALL\nlib/Kconfig.debug-731-\tbool \"Access normal\"\n--\nlib/Kconfig.debug-735-\nlib/Kconfig.debug:736:config DEBUG_FS_ALLOW_NONE\nlib/Kconfig.debug-737-\tbool \"No access\"\n"
} |
| 13/2 | 2026/10/09 05:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21813 output: 285 thoughts: 274 Thoughts: **Fuzzing Configuration Review** Okay, so I'm looking over this fuzzing setup. First, I see that `DEBUG_FS` is independent of specific hardware, and `BLK_DEBUG_FS` naturally depends on `DEBUG_FS`. That's good, no unexpected dependencies to worry about. Now, let me check the `set-results` format. The `EnableConfigs` list looks correct: `["DEBUG_FS", "BLK_DEBUG_FS"]`. That's precisely what we need to enable the features under test. And the `FocusSymbols` are all the key functions related to block device tag management. I see: `blk_mq_alloc_mapped_tags`, `blk_mq_free_unmapped_tags`, and all those other `blk_mq_..._debugfs` functions. Perfect. They are all crucial for testing the integrity and behavior of the tag handling logic. The "Reasoning" field will allow us to concisely explain any verdict. And finally, `WorthFuzzing`: true – of course, it is. Yep, everything here looks thoroughly reviewed and sound. I'm satisfied. Let's go ahead and call `set-results`. |
| 14/2 | 2026/10/09 05:06 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"DEBUG_FS",
"BLK_DEBUG_FS"
],
"FocusSymbols": [
"blk_mq_alloc_mapped_tags",
"blk_mq_free_unmapped_tags",
"blk_mq_update_mapped_tags_bitmap",
"blk_mq_update_nr_hw_queues",
"blk_mq_tagset_debugfs_register",
"blk_mq_tagset_debugfs_unregister",
"blk_mq_tagset_tags_read",
"blk_mq_tagset_map_show",
"blk_mq_tagset_flags_show",
"blk_mq_tagset_debugfs_create_tags",
"blk_mq_tagset_debugfs_remove_tags"
],
"Reasoning": "The patch modifies the core blk-mq subsystem by changing tagset management and software-to-hardware queue mapping (adding dynamic allocation/freeing of mapped/unmapped tags based on a newly introduced mapped_tags_bitmap, with defensive lock assertions). In addition, it exposes tagset debugfs attributes and directories with custom file operations and lifetime handling. These code paths are fully reachable in virtualized environments via block devices and debugfs.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"DEBUG_FS",
"BLK_DEBUG_FS"
],
"FocusSymbols": [
"blk_mq_alloc_mapped_tags",
"blk_mq_free_unmapped_tags",
"blk_mq_update_mapped_tags_bitmap",
"blk_mq_update_nr_hw_queues",
"blk_mq_tagset_debugfs_register",
"blk_mq_tagset_debugfs_unregister",
"blk_mq_tagset_tags_read",
"blk_mq_tagset_map_show",
"blk_mq_tagset_flags_show",
"blk_mq_tagset_debugfs_create_tags",
"blk_mq_tagset_debugfs_remove_tags"
],
"Reasoning": "The patch modifies the core blk-mq subsystem by changing tagset management and software-to-hardware queue mapping (adding dynamic allocation/freeing of mapped/unmapped tags based on a newly introduced mapped_tags_bitmap, with defensive lock assertions). In addition, it exposes tagset debugfs attributes and directories with custom file operations and lifetime handling. These code paths are fully reachable in virtualized environments via block devices and debugfs.",
"WorthFuzzing": true
} |
| 15/1 | 2026/10/09 05:06 | action | If |
1mArgs:{
"WorthFuzzing": true
}Results: null |
| 16/2 | 2026/10/09 05:06 | agent | kmsan-evaluator |
1mModel:core Args: null Results: {
"KMSANReasoning": "The patch introduces debugfs entries for blk-mq tag sets and manages active hardware queue mappings using a dynamically allocated bitmap (`mapped_tags_bitmap`).\n\nFrom a KMSAN perspective:\n1. No uninitialized memory or structure padding is leaked to user space: debugfs show/read handlers output formatted ASCII strings using `seq_printf` and `scnprintf` (`blk_mq_tagset_tags_read`, `blk_mq_tagset_map_show`, etc.), followed by `simple_read_from_buffer`.\n2. Stack buffers (`target[32]`, `name[20]`, `name[24]`, `buf[128]`) are safely written via `snprintf`/`scnprintf` prior to being read or passed to debugfs APIs.\n3. Newly added heap objects (`mapped_tags_bitmap`) are allocated with `bitmap_zalloc_node` (ensuring zero-initialization), and new struct fields (`debugfs_dir`, `debugfs_id`) in `struct blk_mq_tag_set` are properly initialized in `blk_mq_alloc_tag_set`.\n4. Control flow and branching rely on well-initialized tag set fields, integers, and zeroed bitmaps.\n\nContrast with KASAN/LOCKDEP:\nAny potential bugs introduced by this patch would involve tag lifetime/use-after-free (e.g. tearing down tags while a debugfs file is being read), NULL pointer dereferences, array bounds, or locking anomalies (`blk_mq_tagset_debugfs_mutex` vs queue locks). These are detected by KASAN and LOCKDEP. A dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
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 792794fe2785fe34cc6ac6fa547bf2516b3772a3
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Oct 9 05:05:01 2026 +0000
syz-cluster: applied patch under review
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 6754d8f9449c1..78a91a1095bb5 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -7,6 +7,7 @@
#include <linux/blkdev.h>
#include <linux/build_bug.h>
#include <linux/debugfs.h>
+#include <linux/idr.h>
#include "blk.h"
#include "blk-mq.h"
@@ -643,11 +644,19 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent,
void blk_mq_debugfs_register(struct request_queue *q)
{
+ struct blk_mq_tag_set *set = q->tag_set;
struct blk_mq_hw_ctx *hctx;
unsigned long i;
+ char target[32];
debugfs_create_files(q, q->debugfs_dir, q, blk_mq_debugfs_queue_attrs);
+ if (!IS_ERR_OR_NULL(q->debugfs_dir) &&
+ !IS_ERR_OR_NULL(set->debugfs_dir) && set->debugfs_id >= 0) {
+ snprintf(target, sizeof(target), "../../tagset/%d", set->debugfs_id);
+ debugfs_create_symlink("tagset", q->debugfs_dir, target);
+ }
+
queue_for_each_hw_ctx(q, hctx, i) {
if (!hctx->debugfs_dir)
blk_mq_debugfs_register_hctx(q, hctx);
@@ -827,3 +836,292 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx)
debugfs_remove_recursive(hctx->sched_debugfs_dir);
hctx->sched_debugfs_dir = NULL;
}
+
+/* Tag set debugfs --------------------------------------------------------- */
+
+static DEFINE_IDA(blk_mq_tagset_debugfs_ida);
+static DEFINE_MUTEX(blk_mq_tagset_debugfs_mutex);
+static struct dentry *blk_mq_tagset_debugfs_root;
+
+/* Prevent debugfs allocation reclaim from issuing I/O to frozen queues. */
+static unsigned int __must_check blk_mq_tagset_debugfs_lock(void)
+ __acquires(&blk_mq_tagset_debugfs_mutex)
+{
+ unsigned int memflags = memalloc_noio_save();
+
+ mutex_lock(&blk_mq_tagset_debugfs_mutex);
+ return memflags;
+}
+
+static void blk_mq_tagset_debugfs_unlock(unsigned int memflags)
+ __releases(&blk_mq_tagset_debugfs_mutex)
+{
+ mutex_unlock(&blk_mq_tagset_debugfs_mutex);
+ memalloc_noio_restore(memflags);
+}
+
+#define BLK_MQ_F_NAME(name) \
+ [ilog2(BLK_MQ_F_##name)] = #name
+static const char *const tagset_flag_name[] = {
+ BLK_MQ_F_NAME(TAG_QUEUE_SHARED),
+ BLK_MQ_F_NAME(STACKING),
+ BLK_MQ_F_NAME(TAG_HCTX_SHARED),
+ BLK_MQ_F_NAME(BLOCKING),
+ BLK_MQ_F_NAME(TAG_RR),
+ BLK_MQ_F_NAME(NO_SCHED_BY_DEFAULT),
+};
+
+#undef BLK_MQ_F_NAME
+
+static int blk_mq_tagset_flags_show(struct seq_file *m, void *v)
+{
+ struct blk_mq_tag_set *set = m->private;
+
+ BUILD_BUG_ON(ARRAY_SIZE(tagset_flag_name) != ilog2(BLK_MQ_F_MAX));
+
+ down_read(&set->update_nr_hwq_lock);
+
+ blk_flags_show(m, set->flags, tagset_flag_name,
+ ARRAY_SIZE(tagset_flag_name));
+ seq_putc(m, '\n');
+
+ up_read(&set->update_nr_hwq_lock);
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_flags);
+
+#define BLK_MQ_TAGSET_VALUE_SHOW(_name, _type, _value, _format) \
+static int blk_mq_tagset_##_name##_show(struct seq_file *m, void *v) \
+{ \
+ struct blk_mq_tag_set *set = m->private; \
+ _type value; \
+\
+ down_read(&set->update_nr_hwq_lock); \
+ value = (_value); \
+ up_read(&set->update_nr_hwq_lock); \
+\
+ seq_printf(m, _format, value); \
+ return 0; \
+} \
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_##_name)
+
+BLK_MQ_TAGSET_VALUE_SHOW(nr_maps, unsigned int, set->nr_maps, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(nr_hw_queues, unsigned int, set->nr_hw_queues, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(queue_depth, unsigned int, set->queue_depth, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(reserved_tags, unsigned int, set->reserved_tags, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(cmd_size, unsigned int, set->cmd_size, "%u\n");
+BLK_MQ_TAGSET_VALUE_SHOW(numa_node, int, set->numa_node, "%d\n");
+BLK_MQ_TAGSET_VALUE_SHOW(timeout, unsigned int, set->timeout, "%u\n");
+
+#undef BLK_MQ_TAGSET_VALUE_SHOW
+
+static int blk_mq_tagset_hctx_tags_shared_show(struct seq_file *m, void *v)
+{
+ struct blk_mq_tag_set *set = m->private;
+ bool shared;
+
+ down_read(&set->update_nr_hwq_lock);
+ shared = blk_mq_is_shared_tags(set->flags);
+ up_read(&set->update_nr_hwq_lock);
+
+ seq_printf(m, "%d\n", shared);
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_hctx_tags_shared);
+
+static int blk_mq_tagset_map_show(struct seq_file *m, void *v)
+{
+ struct blk_mq_tag_set *set = m->private;
+ unsigned long index = debugfs_get_aux_num(m->file);
+ unsigned int map = index / nr_cpu_ids;
+ unsigned int cpu = index % nr_cpu_ids;
+
+ down_read(&set->update_nr_hwq_lock);
+
+ seq_printf(m, "%u\n", set->map[map].mq_map[cpu]);
+
+ up_read(&set->update_nr_hwq_lock);
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(blk_mq_tagset_map);
+
+static void blk_mq_tagset_debugfs_create_maps(struct blk_mq_tag_set *set)
+{
+ struct dentry *dir, *map_dir;
+ unsigned int cpu, i;
+ char name[20];
+
+ dir = debugfs_create_dir("map", set->debugfs_dir);
+ if (IS_ERR_OR_NULL(dir))
+ return;
+
+ for (i = 0; i < set->nr_maps; i++) {
+ snprintf(name, sizeof(name), "%u", i);
+ map_dir = debugfs_create_dir(name, dir);
+ if (IS_ERR_OR_NULL(map_dir))
+ continue;
+
+ for_each_possible_cpu(cpu) {
+ /* Encode the map and CPU indices in the auxiliary data. */
+ unsigned long index = (unsigned long)i * nr_cpu_ids + cpu;
+
+ snprintf(name, sizeof(name), "cpu%u", cpu);
+ debugfs_create_file_aux_num(name, 0444, map_dir, set,
+ index, &blk_mq_tagset_map_fops);
+ }
+ }
+}
+
+static ssize_t blk_mq_tagset_tags_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct dentry *dentry = file->f_path.dentry;
+ unsigned int nr_tags, nr_reserved_tags, active_queues;
+ struct blk_mq_tags *tags;
+ char buf[128];
+ int ret, len;
+
+ /*
+ * Tag updates remove these files before freeing the tags. Shared tags
+ * remain valid until tag set teardown removes the shared_tags file.
+ */
+ ret = debugfs_file_get(dentry);
+ if (ret)
+ return ret;
+
+ tags = file->private_data;
+ if (!tags) {
+ debugfs_file_put(dentry);
+ return -ENODEV;
+ }
+
+ nr_tags = tags->nr_tags;
+ nr_reserved_tags = tags->nr_reserved_tags;
+ active_queues = READ_ONCE(tags->active_queues);
+ debugfs_file_put(dentry);
+
+ /*
+ * A fault on the user buffer may need I/O to a frozen queue. Drop the
+ * active reference first so file removal does not wait for that I/O.
+ */
+ len = scnprintf(buf, sizeof(buf),
+ ".nr_tags=%u\n.nr_reserved_tags=%u\n.active_queues=%u\n",
+ nr_tags, nr_reserved_tags, active_queues);
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static const struct file_operations blk_mq_tagset_tags_fops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = blk_mq_tagset_tags_read,
+ .llseek = default_llseek,
+};
+
+void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set)
+{
+ if (IS_ERR_OR_NULL(set->debugfs_dir))
+ return;
+
+ debugfs_lookup_and_remove("tags", set->debugfs_dir);
+}
+
+void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set)
+{
+ struct dentry *dir;
+ unsigned int i;
+ char name[20];
+
+ if (IS_ERR_OR_NULL(set->debugfs_dir))
+ return;
+
+ dir = debugfs_create_dir("tags", set->debugfs_dir);
+ if (IS_ERR_OR_NULL(dir))
+ return;
+
+ for (i = 0; i < set->nr_hw_queues; i++) {
+ struct blk_mq_tags *tags = set->tags[i];
+
+ snprintf(name, sizeof(name), "%u", i);
+ if (tags && tags == set->shared_tags)
+ debugfs_create_symlink(name, dir, "../shared_tags");
+ else
+ debugfs_create_file_unsafe(name, 0444, dir, tags,
+ &blk_mq_tagset_tags_fops);
+ }
+}
+
+static void blk_mq_tagset_debugfs_create_files(struct blk_mq_tag_set *set)
+{
+ debugfs_create_file("nr_maps", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_nr_maps_fops);
+ debugfs_create_file("nr_hw_queues", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_nr_hw_queues_fops);
+ debugfs_create_file("queue_depth", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_queue_depth_fops);
+ debugfs_create_file("reserved_tags", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_reserved_tags_fops);
+ debugfs_create_file("cmd_size", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_cmd_size_fops);
+ debugfs_create_file("numa_node", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_numa_node_fops);
+ debugfs_create_file("timeout", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_timeout_fops);
+ debugfs_create_file("hctx_tags_shared", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_hctx_tags_shared_fops);
+ debugfs_create_file("flags", 0444, set->debugfs_dir, set,
+ &blk_mq_tagset_flags_fops);
+ blk_mq_tagset_debugfs_create_maps(set);
+ debugfs_create_file_unsafe("shared_tags", 0444, set->debugfs_dir,
+ set->shared_tags, &blk_mq_tagset_tags_fops);
+ blk_mq_tagset_debugfs_create_tags(set);
+}
+
+void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set)
+{
+ struct dentry *dir;
+ unsigned int memflags;
+ char name[24];
+ int id;
+
+ memflags = blk_mq_tagset_debugfs_lock();
+
+ if (IS_ERR_OR_NULL(blk_mq_tagset_debugfs_root))
+ blk_mq_tagset_debugfs_root = debugfs_create_dir("tagset", NULL);
+
+ if (set->debugfs_dir || IS_ERR_OR_NULL(blk_mq_tagset_debugfs_root))
+ goto out_unlock;
+
+ id = ida_alloc(&blk_mq_tagset_debugfs_ida, GFP_KERNEL);
+ if (id < 0)
+ goto out_unlock;
+
+ snprintf(name, sizeof(name), "%d", id);
+ dir = debugfs_create_dir(name, blk_mq_tagset_debugfs_root);
+ if (IS_ERR_OR_NULL(dir)) {
+ ida_free(&blk_mq_tagset_debugfs_ida, id);
+ goto out_unlock;
+ }
+
+ set->debugfs_id = id;
+ set->debugfs_dir = dir;
+ blk_mq_tagset_debugfs_create_files(set);
+
+out_unlock:
+ blk_mq_tagset_debugfs_unlock(memflags);
+}
+
+void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set)
+{
+ mutex_lock(&blk_mq_tagset_debugfs_mutex);
+
+ debugfs_remove_recursive(set->debugfs_dir);
+ set->debugfs_dir = NULL;
+
+ if (set->debugfs_id >= 0) {
+ ida_free(&blk_mq_tagset_debugfs_ida, set->debugfs_id);
+ set->debugfs_id = -1;
+ }
+
+ mutex_unlock(&blk_mq_tagset_debugfs_mutex);
+}
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index 49bb1aaa83dc7..aea278bdc4e78 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -7,6 +7,7 @@
#include <linux/seq_file.h>
struct blk_mq_hw_ctx;
+struct blk_mq_tag_set;
struct blk_mq_debugfs_attr {
const char *name;
@@ -34,6 +35,11 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);
void blk_mq_debugfs_register_rq_qos(struct request_queue *q);
+
+void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set);
+void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set);
+void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set);
+void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set);
#else
static inline void blk_mq_debugfs_register(struct request_queue *q)
{
@@ -77,6 +83,22 @@ static inline void blk_mq_debugfs_register_rq_qos(struct request_queue *q)
{
}
+static inline void blk_mq_tagset_debugfs_register(struct blk_mq_tag_set *set)
+{
+}
+
+static inline void blk_mq_tagset_debugfs_unregister(struct blk_mq_tag_set *set)
+{
+}
+
+static inline void blk_mq_tagset_debugfs_create_tags(struct blk_mq_tag_set *set)
+{
+}
+
+static inline void blk_mq_tagset_debugfs_remove_tags(struct blk_mq_tag_set *set)
+{
+}
+
#endif
#if defined(CONFIG_BLK_DEV_ZONED) && defined(CONFIG_BLK_DEBUG_FS)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index a26a11c73ee3e..f32d2df044dcc 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -9,6 +9,7 @@
#include <linux/module.h>
#include <linux/backing-dev.h>
#include <linux/bio.h>
+#include <linux/bitmap.h>
#include <linux/blkdev.h>
#include <linux/blk-integrity.h>
#include <linux/kmemleak.h>
@@ -4159,9 +4160,74 @@ static void __blk_mq_free_map_and_rqs(struct blk_mq_tag_set *set,
set->tags[hctx_idx] = NULL;
}
+static void blk_mq_update_mapped_tags_bitmap(struct blk_mq_tag_set *set)
+{
+ unsigned int i, cpu;
+
+ bitmap_zero(set->mapped_tags_bitmap, set->nr_hw_queues);
+ if (set->nr_hw_queues == 1) {
+ __set_bit(0, set->mapped_tags_bitmap);
+ return;
+ }
+
+ for (i = 0; i < set->nr_maps; i++) {
+ struct blk_mq_queue_map *map = &set->map[i];
+
+ if (!map->nr_queues)
+ continue;
+ for_each_possible_cpu(cpu)
+ __set_bit(map->mq_map[cpu], set->mapped_tags_bitmap);
+ }
+}
+
+static void blk_mq_alloc_mapped_tags(struct blk_mq_tag_set *set)
+{
+ unsigned int cpu, i;
+ bool remapped = false;
+
+ lockdep_assert_held_write(&set->update_nr_hwq_lock);
+
+ for_each_possible_cpu(cpu) {
+ for (i = 0; i < set->nr_maps; i++) {
+ struct blk_mq_queue_map *map = &set->map[i];
+ unsigned int hctx_idx;
+
+ if (!map->nr_queues)
+ continue;
+ hctx_idx = map->mq_map[cpu];
+ if (!set->tags[hctx_idx] &&
+ !__blk_mq_alloc_map_and_rqs(set, hctx_idx)) {
+ /* Queue 0 always has tags available for fallback. */
+ map->mq_map[cpu] = 0;
+ remapped = true;
+ }
+ }
+ }
+ if (remapped)
+ blk_mq_update_mapped_tags_bitmap(set);
+}
+
+static bool blk_mq_tagset_tags_mapped(struct blk_mq_tag_set *set,
+ unsigned int hctx_idx)
+{
+ return test_bit(hctx_idx, set->mapped_tags_bitmap);
+}
+
+/* The queue maps must be stable and the unused tags no longer in use. */
+static void blk_mq_free_unmapped_tags(struct blk_mq_tag_set *set)
+{
+ unsigned int i;
+
+ /* Keep queue 0 as a fallback if a later tag allocation fails. */
+ for (i = 1; i < set->nr_hw_queues; i++) {
+ if (set->tags[i] && !blk_mq_tagset_tags_mapped(set, i))
+ __blk_mq_free_map_and_rqs(set, i);
+ }
+}
+
static void blk_mq_map_swqueue(struct request_queue *q)
{
- unsigned int j, hctx_idx;
+ unsigned int j;
unsigned long i;
struct blk_mq_hw_ctx *hctx;
struct blk_mq_ctx *ctx;
@@ -4173,11 +4239,7 @@ static void blk_mq_map_swqueue(struct request_queue *q)
hctx->dispatch_from = NULL;
}
- /*
- * Map software to hardware queues.
- *
- * If the cpu isn't present, the cpu is mapped to first hctx.
- */
+ /* Map software to hardware queues. */
for_each_possible_cpu(i) {
ctx = per_cpu_ptr(q->queue_ctx, i);
@@ -4187,19 +4249,6 @@ static void blk_mq_map_swqueue(struct request_queue *q)
HCTX_TYPE_DEFAULT, i);
continue;
}
- hctx_idx = set->map[j].mq_map[i];
- /* unmapped hw queue can be remapped after CPU topo changed */
- if (!set->tags[hctx_idx] &&
- !__blk_mq_alloc_map_and_rqs(set, hctx_idx)) {
- /*
- * If tags initialization fail for some hctx,
- * that hctx won't be brought online. In this
- * case, remap the current ctx to hctx[0] which
- * is guaranteed to always have tags allocated
- */
- set->map[j].mq_map[i] = 0;
- }
-
hctx = blk_mq_map_queue_type(q, j, i);
ctx->hctxs[j] = hctx;
/*
@@ -4230,18 +4279,8 @@ static void blk_mq_map_swqueue(struct request_queue *q)
queue_for_each_hw_ctx(q, hctx, i) {
int cpu;
- /*
- * If no software queues are mapped to this hardware queue,
- * disable it and free the request entries.
- */
+ /* Disable hardware queues with no mapped software queues. */
if (!hctx->nr_ctx) {
- /* Never unmap queue 0. We need it as a
- * fallback in case of a new remap fails
- * allocation
- */
- if (i)
- __blk_mq_free_map_and_rqs(set, i);
-
hctx->tags = NULL;
continue;
}
@@ -4782,12 +4821,18 @@ static void blk_mq_update_queue_map(struct blk_mq_tag_set *set)
BUG_ON(set->nr_maps > 1);
blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
}
+ blk_mq_update_mapped_tags_bitmap(set);
}
+/*
+ * On successful growth, also install a larger mapped_tags_bitmap. The caller
+ * rebuilds its contents when updating the queue maps under update_nr_hwq_lock.
+ */
static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(
struct blk_mq_tag_set *set,
int new_nr_hw_queues)
{
+ unsigned long *new_mapped_tags_bitmap;
struct blk_mq_tags **new_tags;
int i;
@@ -4799,6 +4844,13 @@ static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(
if (!new_tags)
return ERR_PTR(-ENOMEM);
+ new_mapped_tags_bitmap = bitmap_zalloc_node(new_nr_hw_queues, GFP_KERNEL,
+ set->numa_node);
+ if (!new_mapped_tags_bitmap) {
+ kfree(new_tags);
+ return ERR_PTR(-ENOMEM);
+ }
+
if (set->tags)
memcpy(new_tags, set->tags, set->nr_hw_queues *
sizeof(*set->tags));
@@ -4815,12 +4867,15 @@ static struct blk_mq_tags **blk_mq_prealloc_tag_set_tags(
cond_resched();
}
+ bitmap_free(set->mapped_tags_bitmap);
+ set->mapped_tags_bitmap = new_mapped_tags_bitmap;
return new_tags;
out_unwind:
while (--i >= set->nr_hw_queues) {
if (!blk_mq_is_shared_tags(set->flags))
blk_mq_free_map_and_rqs(set, new_tags[i], i);
}
+ bitmap_free(new_mapped_tags_bitmap);
kfree(new_tags);
return ERR_PTR(-ENOMEM);
}
@@ -4884,9 +4939,17 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
if (ret)
goto out_free_srcu;
}
+
+ set->mapped_tags_bitmap = bitmap_zalloc_node(set->nr_hw_queues, GFP_KERNEL,
+ set->numa_node);
+ if (!set->mapped_tags_bitmap) {
+ ret = -ENOMEM;
+ goto out_cleanup_srcu;
+ }
+
ret = init_srcu_struct(&set->tags_srcu);
if (ret)
- goto out_cleanup_srcu;
+ goto out_free_mapped_tags_bitmap;
init_rwsem(&set->update_nr_hwq_lock);
@@ -4911,9 +4974,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
ret = blk_mq_alloc_set_map_and_rqs(set);
if (ret)
goto out_free_mq_map;
+ blk_mq_free_unmapped_tags(set);
mutex_init(&set->tag_list_lock);
INIT_LIST_HEAD(&set->tag_list);
+#ifdef CONFIG_BLK_DEBUG_FS
+ set->debugfs_id = -1;
+#endif
+ blk_mq_tagset_debugfs_register(set);
return 0;
@@ -4926,6 +4994,9 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
set->tags = NULL;
out_cleanup_tags_srcu:
cleanup_srcu_struct(&set->tags_srcu);
+out_free_mapped_tags_bitmap:
+ bitmap_free(set->mapped_tags_bitmap);
+ set->mapped_tags_bitmap = NULL;
out_cleanup_srcu:
if (set->flags & BLK_MQ_F_BLOCKING)
cleanup_srcu_struct(set->srcu);
@@ -4956,6 +5027,8 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
{
int i, j;
+ blk_mq_tagset_debugfs_unregister(set);
+
for (i = 0; i < set->nr_hw_queues; i++)
__blk_mq_free_map_and_rqs(set, i);
@@ -4972,6 +5045,9 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
kfree(set->tags);
set->tags = NULL;
+ bitmap_free(set->mapped_tags_bitmap);
+ set->mapped_tags_bitmap = NULL;
+
srcu_barrier(&set->tags_srcu);
cleanup_srcu_struct(&set->tags_srcu);
if (set->flags & BLK_MQ_F_BLOCKING) {
@@ -5137,6 +5213,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
blk_mq_debugfs_unregister_hctxs(q);
blk_mq_sysfs_unregister_hctxs(q);
}
+ blk_mq_tagset_debugfs_remove_tags(set);
/*
* Switch IO scheduler to 'none', cleaning up the data associated
@@ -5162,6 +5239,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
fallback:
blk_mq_update_queue_map(set);
+ blk_mq_alloc_mapped_tags(set);
list_for_each_entry(q, &set->tag_list, tag_set_list) {
__blk_mq_realloc_hw_ctxs(set, q);
@@ -5178,6 +5256,8 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
}
blk_mq_map_swqueue(q);
}
+ /* All queues have stopped using tags excluded by the new maps. */
+ blk_mq_free_unmapped_tags(set);
switch_back:
/* The blk_mq_elv_switch_back unfreezes queue for us. */
list_for_each_entry(q, &set->tag_list, tag_set_list) {
@@ -5194,6 +5274,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
blk_mq_remove_hw_queues_cpuhp(q);
blk_mq_add_hw_queues_cpuhp(q);
}
+ blk_mq_tagset_debugfs_create_tags(set);
out_free_ctx:
blk_mq_free_sched_ctx_batch(&elv_tbl);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index af878597afb8c..a80bc63a6e71c 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -14,6 +14,7 @@
struct blk_mq_tags;
struct blk_flush_queue;
struct io_comp_batch;
+struct dentry;
#define BLKDEV_MIN_RQ 4
#define BLKDEV_DEFAULT_RQ 128
@@ -517,6 +518,10 @@ enum hctx_type {
* tag set.
* @tags: Tag sets. One tag set per hardware queue. Has @nr_hw_queues
* elements.
+ * @mapped_tags_bitmap: Bitmap of hardware queue indices referenced by active
+ * CPU maps. Rebuilt before publication or with update_nr_hwq_lock
+ * held for writing. Tags for index 0 are retained as a fallback
+ * even when its bit is clear.
* @shared_tags:
* Shared set of tags. Has @nr_hw_queues elements. If set,
* shared by all @tags.
@@ -530,6 +535,8 @@ enum hctx_type {
* @update_nr_hwq_lock:
* Synchronize updating nr_hw_queues with add/del disk &
* switching elevator.
+ * @debugfs_dir: Debugfs directory for this tag set.
+ * @debugfs_id: ID used as part of the debugfs directory name.
*/
struct blk_mq_tag_set {
const struct blk_mq_ops *ops;
@@ -545,6 +552,7 @@ struct blk_mq_tag_set {
void *driver_data;
struct blk_mq_tags **tags;
+ unsigned long *mapped_tags_bitmap;
struct blk_mq_tags *shared_tags;
@@ -554,6 +562,11 @@ struct blk_mq_tag_set {
struct srcu_struct tags_srcu;
struct rw_semaphore update_nr_hwq_lock;
+
+#ifdef CONFIG_BLK_DEBUG_FS
+ struct dentry *debugfs_dir;
+ int debugfs_id;
+#endif
};
/**
|
| 17/3 | 2026/10/09 05:06 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 11301 output: 37 thoughts: 2070 Thoughts: **KMSAN Assessment of Block/MQ Debugfs Patch** Okay, let's break this down. My goal is to determine if this patch necessitates a dedicated KMSAN fuzzing session. The patch adds debugfs entries for `blk_mq_tag_set`. I need to assess if the changes introduce uninitialized memory risks or potential kernel-to-user information leaks that KMSAN would catch *exclusively*. If standard detectors like KASAN or LOCKDEP are sufficient, or if structures are properly initialized, a KMSAN session is overkill and a waste of resources. First, I examined `blk_mq_tagset_tags_read`. It uses `scnprintf` to format data into a local buffer `buf` and then copies this, with `simple_read_from_buffer`, to the user-space buffer. Importantly, `scnprintf` ensures the local buffer is fully initialized by the formatting operations. The `simple_read_from_buffer` function reads up to the formatted length. Therefore, no uninitialized bytes are exposed to user space here. This looks safe. Next, I looked at the `seq_file` show functions (`blk_mq_tagset_flags_show`, etc.). These functions use `seq_printf` or `blk_flags_show` to write formatted data to the sequence file. No direct copying of kernel struct members to user space is taking place. This is also safe. Then, I focused on the bitmap allocations (`bitmap_zalloc_node`). The `bitmap_zalloc_node` function, as the name indicates, allocates and *zeroes* the memory. This means the bitmaps are initialized before use, and no uninitialized memory concerns arise here. Good. I've also checked the buffers used in creating debugfs symlinks and entries (`target` and `name`). The use of `snprintf` ensures these buffers are properly null-terminated and initialized before use. No risks here either. Finally, I reviewed the new fields added to `struct blk_mq_tag_set`: `mapped_tags_bitmap`, `debugfs_dir`, and `debugfs_id`. They are *all* explicitly initialized. `mapped_tags_bitmap` is allocated with `bitmap_zalloc_node`, zeroed on allocation. The `debugfs_id` is set to -1 initially, and `debugfs_dir` is `NULL`. These are all initialized during the lifetime of the structure. I verified this in `blk_mq_alloc_tag_set`. The cleanup also ensures the members are uninitialized. I performed a check with `grepper` on the calls to `blk_mq_alloc_tag_set` and all looked good. **Conclusion:** Based on this analysis, I'm confident that this patch doesn't introduce any KMSAN-specific vulnerabilities. There are no obvious risks of exposing uninitialized kernel memory to user space, or information leaks. KASAN, LOCKDEP, and standard bug detectors are sufficient for this patch. Therefore, **NeedsKMSAN=false**. A dedicated KMSAN fuzzing session is not required. |
| 18/3 | 2026/10/09 05:06 | tool | grepper |
0mArgs:{
"Expression": "blk_mq_alloc_set_map_and_rqs",
"PathPrefixes": [
"block/"
]
}Results: {
"Output": "block/blk-mq.c=4722=static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set)\n--\nblock/blk-mq.c-4758- */\nblock/blk-mq.c:4759:static int blk_mq_alloc_set_map_and_rqs(struct blk_mq_tag_set *set)\nblock/blk-mq.c-4760-{\n--\nblock/blk-mq.c=4889=int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)\n--\nblock/blk-mq.c-4973-\nblock/blk-mq.c:4974:\tret = blk_mq_alloc_set_map_and_rqs(set);\nblock/blk-mq.c-4975-\tif (ret)\n"
} |
| 19/3 | 2026/10/09 05:06 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14304 output: 36 thoughts: 30 Thoughts: Okay, let's dive into this. I need to get a handle on how this system works, so I'm going to jump into the `blk_mq_alloc_set_map_and_rqs` function. I remember seeing that one in `block/blk-mq.c`, so that's where I'll start. It should give me a solid understanding of how they're handling memory allocation, mapping, and the request structures themselves within the blk-mq framework. I need to refresh my understanding of how this particular mechanism fits into the overall scheme. |
| 20/3 | 2026/10/09 05:06 | tool | read-file |
0mArgs:{
"File": "block/blk-mq.c",
"FirstLine": 4759,
"LineCount": 40
}Results: {
"Contents": "4759:\tstatic int blk_mq_alloc_set_map_and_rqs(struct blk_mq_tag_set *set)\n4760:\t{\n4761:\t\tunsigned int depth;\n4762:\t\tint err;\n4763:\t\n4764:\t\tdepth = set-\u003equeue_depth;\n4765:\t\tdo {\n4766:\t\t\terr = __blk_mq_alloc_rq_maps(set);\n4767:\t\t\tif (!err)\n4768:\t\t\t\tbreak;\n4769:\t\n4770:\t\t\tset-\u003equeue_depth \u003e\u003e= 1;\n4771:\t\t\tif (set-\u003equeue_depth \u003c set-\u003ereserved_tags + BLK_MQ_TAG_MIN) {\n4772:\t\t\t\terr = -ENOMEM;\n4773:\t\t\t\tbreak;\n4774:\t\t\t}\n4775:\t\t} while (set-\u003equeue_depth);\n4776:\t\n4777:\t\tif (!set-\u003equeue_depth || err) {\n4778:\t\t\tpr_err(\"blk-mq: failed to allocate request map\\n\");\n4779:\t\t\treturn -ENOMEM;\n4780:\t\t}\n4781:\t\n4782:\t\tif (depth != set-\u003equeue_depth)\n4783:\t\t\tpr_info(\"blk-mq: reduced tag depth (%u -\u003e %u)\\n\",\n4784:\t\t\t\t\t\t\tdepth, set-\u003equeue_depth);\n4785:\t\n4786:\t\treturn 0;\n4787:\t}\n4788:\t\n4789:\tstatic void blk_mq_update_queue_map(struct blk_mq_tag_set *set)\n4790:\t{\n4791:\t\t/*\n4792:\t\t * blk_mq_map_queues() and multiple .map_queues() implementations\n4793:\t\t * expect that set-\u003emap[HCTX_TYPE_DEFAULT].nr_queues is set to the\n4794:\t\t * number of hardware queues.\n4795:\t\t */\n4796:\t\tif (set-\u003enr_maps == 1)\n4797:\t\t\tset-\u003emap[HCTX_TYPE_DEFAULT].nr_queues = set-\u003enr_hw_queues;\n4798:\t\n"
} |
| 21/3 | 2026/10/09 05:06 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15094 output: 36 thoughts: 35 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Diving into Tag Allocation** Alright, let's zero in on `blk_mq_alloc_set_map_and_rqs` within `blk_mq_alloc_tag_set`. I need to refresh my memory on the critical points around that allocation process. It's the lynchpin for how we carve up resources and map requests within the blk-mq framework. I need to understand exactly what happens at this level, because this is where the allocation process starts, which effects the rate the OS can accept new work. Understanding the function itself, and the calls surrounding it, is where the interesting logic happens. What is the lifecycle around what is being allocated here? |
| 22/3 | 2026/10/09 05:06 | tool | read-file |
0mArgs:{
"File": "block/blk-mq.c",
"FirstLine": 4940,
"LineCount": 60
}Results: {
"Contents": "4940:\t\t\t\tgoto out_free_srcu;\n4941:\t\t}\n4942:\t\n4943:\t\tset-\u003emapped_tags_bitmap = bitmap_zalloc_node(set-\u003enr_hw_queues, GFP_KERNEL,\n4944:\t\t\t\t\t\t\t set-\u003enuma_node);\n4945:\t\tif (!set-\u003emapped_tags_bitmap) {\n4946:\t\t\tret = -ENOMEM;\n4947:\t\t\tgoto out_cleanup_srcu;\n4948:\t\t}\n4949:\t\n4950:\t\tret = init_srcu_struct(\u0026set-\u003etags_srcu);\n4951:\t\tif (ret)\n4952:\t\t\tgoto out_free_mapped_tags_bitmap;\n4953:\t\n4954:\t\tinit_rwsem(\u0026set-\u003eupdate_nr_hwq_lock);\n4955:\t\n4956:\t\tret = -ENOMEM;\n4957:\t\tset-\u003etags = kcalloc_node(set-\u003enr_hw_queues,\n4958:\t\t\t\t\t sizeof(struct blk_mq_tags *), GFP_KERNEL,\n4959:\t\t\t\t\t set-\u003enuma_node);\n4960:\t\tif (!set-\u003etags)\n4961:\t\t\tgoto out_cleanup_tags_srcu;\n4962:\t\n4963:\t\tfor (i = 0; i \u003c set-\u003enr_maps; i++) {\n4964:\t\t\tset-\u003emap[i].mq_map = kcalloc_node(nr_cpu_ids,\n4965:\t\t\t\t\t\t\t sizeof(set-\u003emap[i].mq_map[0]),\n4966:\t\t\t\t\t\t\t GFP_KERNEL, set-\u003enuma_node);\n4967:\t\t\tif (!set-\u003emap[i].mq_map)\n4968:\t\t\t\tgoto out_free_mq_map;\n4969:\t\t\tset-\u003emap[i].nr_queues = set-\u003enr_hw_queues;\n4970:\t\t}\n4971:\t\n4972:\t\tblk_mq_update_queue_map(set);\n4973:\t\n4974:\t\tret = blk_mq_alloc_set_map_and_rqs(set);\n4975:\t\tif (ret)\n4976:\t\t\tgoto out_free_mq_map;\n4977:\t\tblk_mq_free_unmapped_tags(set);\n4978:\t\n4979:\t\tmutex_init(\u0026set-\u003etag_list_lock);\n4980:\t\tINIT_LIST_HEAD(\u0026set-\u003etag_list);\n4981:\t#ifdef CONFIG_BLK_DEBUG_FS\n4982:\t\tset-\u003edebugfs_id = -1;\n4983:\t#endif\n4984:\t\tblk_mq_tagset_debugfs_register(set);\n4985:\t\n4986:\t\treturn 0;\n4987:\t\n4988:\tout_free_mq_map:\n4989:\t\tfor (i = 0; i \u003c set-\u003enr_maps; i++) {\n4990:\t\t\tkfree(set-\u003emap[i].mq_map);\n4991:\t\t\tset-\u003emap[i].mq_map = NULL;\n4992:\t\t}\n4993:\t\tkfree(set-\u003etags);\n4994:\t\tset-\u003etags = NULL;\n4995:\tout_cleanup_tags_srcu:\n4996:\t\tcleanup_srcu_struct(\u0026set-\u003etags_srcu);\n4997:\tout_free_mapped_tags_bitmap:\n4998:\t\tbitmap_free(set-\u003emapped_tags_bitmap);\n4999:\t\tset-\u003emapped_tags_bitmap = NULL;\n"
} |
| 23/3 | 2026/10/09 05:06 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16293 output: 389 thoughts: 2608 Thoughts: **Uninitialized Memory Analysis: blk-mq Tag Set Debugfs** Okay, let's break this down. My primary focus is on potential uninitialized memory exposures, especially given the introduction of debugfs interfaces and the manipulation of tag sets. I've walked through the code, focusing on data structures being allocated, initialized, and potentially exposed to userspace via the debugfs interface. First, `blk_mq_alloc_tag_set` calls `blk_mq_update_queue_map`, and that in turn calls `blk_mq_update_mapped_tags_bitmap`. That's where the critical `set->mapped_tags_bitmap` is involved. I see that this bitmap is zeroed from the beginning using `bitmap_zero` or allocated with `bitmap_zalloc_node` when we resize the number of HW queues. The allocation and initialization of tags happens through `blk_mq_alloc_set_map_and_rqs` and potentially with reallocation/mapping through `blk_mq_alloc_mapped_tags`. The critical part here is that if a tag isn't mapped, it should be freed to prevent the possibility of an uninitialized entry being shown in debugfs. The code ensures that with `blk_mq_free_unmapped_tags` and `__blk_mq_free_map_and_rqs`. Now, digging into the debugfs interactions. `blk_mq_tagset_map_show` reads the `mq_map` array, but that array is initialized via `kcalloc_node` which provides zero-initialization. I see that values in `mq_map` are filled by `map_queues` and potentially remapped in the same function. `blk_mq_tagset_tags_read` similarly reads initialized variables like `nr_tags`, `nr_reserved_tags`, and `active_queues`, formatting them into ASCII strings for output. All scalar values read from `set` are initialized when the tag set is created. The memory is written through `simple_read_from_buffer` which is also safe. I've carefully scrutinized the code, and there's no evidence of uninitialized memory being directly copied to userspace via `copy_to_user`, `put_user`, netlink, ioctl, sockets, or BPF buffers. I've also looked for conditional logic that might depend on uninitialized variables or struct fields, but there are none. `set->mapped_tags_bitmap` is handled correctly, initialized at the start, and re-zeroed/populated if hardware queues are changed. No complex data structures are initialized in a way that might leave uninitialized fields accessible in reachable code paths. There are no unsafe bounds checks that could result in uninitialized bytes being read. In `blk_mq_debugfs_register`, the `target` string is a stack buffer initialized through `snprintf`, and it is also null-terminated. Then it is passed to `debugfs_create_symlink`, which calls `kstrdup`. I have considered the potential for concurrency issues in `blk_mq_tagset_tags_read`, but since the check happens inside `debugfs_file_get` and `debugfs_file_put` there is no direct risk. Any lifetime issues with tag sets and the debugfs file entries and locking are handled by KASAN/LOCKDEP. In summary, there are no uninitialized memory risks. All of the allocations and initializations use zero-initialization or assign a value to it before it is read. The new structures and bitmaps are zero-allocated with `bitmap_zalloc_node` or `kcalloc_node`. Any potential bugs introduced by this patch are related to use-after-free, out-of-bounds accesses, or locking, which are all covered by KASAN and LOCKDEP. KMSAN is not needed in this case, as there is no exposure of uninitialized memory. |
| 24/3 | 2026/10/09 05:07 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch introduces debugfs entries for blk-mq tag sets and manages active hardware queue mappings using a dynamically allocated bitmap (`mapped_tags_bitmap`).\n\nFrom a KMSAN perspective:\n1. No uninitialized memory or structure padding is leaked to user space: debugfs show/read handlers output formatted ASCII strings using `seq_printf` and `scnprintf` (`blk_mq_tagset_tags_read`, `blk_mq_tagset_map_show`, etc.), followed by `simple_read_from_buffer`.\n2. Stack buffers (`target[32]`, `name[20]`, `name[24]`, `buf[128]`) are safely written via `snprintf`/`scnprintf` prior to being read or passed to debugfs APIs.\n3. Newly added heap objects (`mapped_tags_bitmap`) are allocated with `bitmap_zalloc_node` (ensuring zero-initialization), and new struct fields (`debugfs_dir`, `debugfs_id`) in `struct blk_mq_tag_set` are properly initialized in `blk_mq_alloc_tag_set`.\n4. Control flow and branching rely on well-initialized tag set fields, integers, and zeroed bitmaps.\n\nContrast with KASAN/LOCKDEP:\nAny potential bugs introduced by this patch would involve tag lifetime/use-after-free (e.g. tearing down tags while a debugfs file is being read), NULL pointer dereferences, array bounds, or locking anomalies (`blk_mq_tagset_debugfs_mutex` vs queue locks). These are detected by KASAN and LOCKDEP. A dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch introduces debugfs entries for blk-mq tag sets and manages active hardware queue mappings using a dynamically allocated bitmap (`mapped_tags_bitmap`).\n\nFrom a KMSAN perspective:\n1. No uninitialized memory or structure padding is leaked to user space: debugfs show/read handlers output formatted ASCII strings using `seq_printf` and `scnprintf` (`blk_mq_tagset_tags_read`, `blk_mq_tagset_map_show`, etc.), followed by `simple_read_from_buffer`.\n2. Stack buffers (`target[32]`, `name[20]`, `name[24]`, `buf[128]`) are safely written via `snprintf`/`scnprintf` prior to being read or passed to debugfs APIs.\n3. Newly added heap objects (`mapped_tags_bitmap`) are allocated with `bitmap_zalloc_node` (ensuring zero-initialization), and new struct fields (`debugfs_dir`, `debugfs_id`) in `struct blk_mq_tag_set` are properly initialized in `blk_mq_alloc_tag_set`.\n4. Control flow and branching rely on well-initialized tag set fields, integers, and zeroed bitmaps.\n\nContrast with KASAN/LOCKDEP:\nAny potential bugs introduced by this patch would involve tag lifetime/use-after-free (e.g. tearing down tags while a debugfs file is being read), NULL pointer dereferences, array bounds, or locking anomalies (`blk_mq_tagset_debugfs_mutex` vs queue locks). These are detected by KASAN and LOCKDEP. A dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|