| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/23 22:31 | flow | patch-triage |
3mArgs:null Results: {
"EnableConfigs": [
"BLOCK"
],
"FocusSymbols": [
"super_lock",
"freeze_super",
"thaw_super",
"iterate_supers_sync",
"user_get_super",
"grab_super",
"fs_bdev_sync",
"fs_bdev_freeze",
"fs_bdev_thaw"
],
"KMSANReasoning": "The patch refactors internal superblock locking and waiting mechanisms in fs/super.c (introducing enum super_lock_flags_t, unifying super_lock/super_wait, and implementing RAII cleanup guards via __DEFINE_UNLOCK_GUARD/scoped_guard/ACQUIRE). It does not introduce or modify any data structures copied to user space, does not allocate uninitialized buffers, and does not alter data buffers or bounds checks. All local variables and guard structures (such as class_super_lock_t) are fully initialized at the point of declaration. The potential bugs in this patch are concurrency- and locking-related (deadlocks, lock ordering, missed unlocks, refcount errors, or error return handling), which are covered by LOCKDEP and KASAN. Therefore, a dedicated KMSAN session is not justified.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies core VFS superblock locking and shutdown waiting logic in fs/super.c. It consolidates multiple locking helpers into a unified super_lock() function with flags, changes its return semantics from bool to int error codes, and introduces RAII-style cleanup guards (scoped_guard, scoped_cond_guard, ACQUIRE). These modifications directly affect reachable code paths exercised by common filesystem syscalls and ioctls, including mount, sync, FIFREEZE/FITHAW ioctls, and block device holder callbacks. Such locking and lifecycle refactorings warrant fuzzing to catch potential lockdep splats, regressions, or synchronization races.",
"WorthFuzzing": true
} |
| 1/1 | 2026/10/23 22:31 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 7d0dafe06bb19feaa70a02f1f486e0c37394c702\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Fri Oct 23 22:31:42 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/fs/super.c b/fs/super.c\nindex 63e85794ea4d5..aff2169ca94d1 100644\n--- a/fs/super.c\n+++ b/fs/super.c\n@@ -55,24 +55,32 @@ static char *sb_writers_name[SB_FREEZE_LEVELS] = {\n \t\"sb_internal\",\n };\n \n-static inline void __super_lock(struct super_block *sb, bool excl)\n+enum super_lock_flags_t {\n+\tSUPER_LOCK_EXCL\t\t= (1U \u003c\u003c 0),\n+\tSUPER_LOCK_KILLABLE\t= (1U \u003c\u003c 1),\n+\tSUPER_LOCK_WAIT_SHUTDOWN = (1U \u003c\u003c 2),\n+};\n+\n+static inline int __super_lock(struct super_block *sb,\n+\t\t\t enum super_lock_flags_t flags)\n {\n-\tif (excl)\n+\tif (flags \u0026 SUPER_LOCK_KILLABLE) {\n+\t\tif (flags \u0026 SUPER_LOCK_EXCL)\n+\t\t\treturn down_write_killable(\u0026sb-\u003es_umount);\n+\t\treturn down_read_killable(\u0026sb-\u003es_umount);\n+\t}\n+\n+\tif (flags \u0026 SUPER_LOCK_EXCL)\n \t\tdown_write(\u0026sb-\u003es_umount);\n \telse\n \t\tdown_read(\u0026sb-\u003es_umount);\n+\treturn 0;\n }\n \n-static inline int __super_lock_killable(struct super_block *sb, bool excl)\n-{\n-\tif (excl)\n-\t\treturn down_write_killable(\u0026sb-\u003es_umount);\n-\treturn down_read_killable(\u0026sb-\u003es_umount);\n-}\n-\n-static inline void super_unlock(struct super_block *sb, bool excl)\n+static inline void super_unlock(struct super_block *sb,\n+\t\t\t\tenum super_lock_flags_t flags)\n {\n-\tif (excl)\n+\tif (flags \u0026 SUPER_LOCK_EXCL)\n \t\tup_write(\u0026sb-\u003es_umount);\n \telse\n \t\tup_read(\u0026sb-\u003es_umount);\n@@ -80,17 +88,17 @@ static inline void super_unlock(struct super_block *sb, bool excl)\n \n static inline void __super_lock_excl(struct super_block *sb)\n {\n-\t__super_lock(sb, true);\n+\t__super_lock(sb, SUPER_LOCK_EXCL);\n }\n \n static inline void super_unlock_excl(struct super_block *sb)\n {\n-\tsuper_unlock(sb, true);\n+\tsuper_unlock(sb, SUPER_LOCK_EXCL);\n }\n \n static inline void super_unlock_shared(struct super_block *sb)\n {\n-\tsuper_unlock(sb, false);\n+\tsuper_unlock(sb, 0);\n }\n \n static bool super_flags(const struct super_block *sb, unsigned int flags)\n@@ -103,12 +111,54 @@ static bool super_flags(const struct super_block *sb, unsigned int flags)\n }\n \n /*\n- * Returns 0 with s_umount held, -ENOENT if the superblock is going away, or,\n- * if @killable, the error from a wait which was cut short.\n+ * Wait for one of @sb_flags to be set on @sb, sleeping in @state. Returns 0\n+ * or -ERESTARTSYS if @state allowed the wait to be cut short.\n */\n-static int super_lock_common(struct super_block *sb, bool excl, bool killable)\n+static int super_wait(struct super_block *sb, unsigned int sb_flags,\n+\t\t unsigned int state)\n {\n-\tint ret = 0;\n+\treturn wait_var_event_state(\u0026sb-\u003es_flags, super_flags(sb, sb_flags),\n+\t\t\t\t state);\n+}\n+\n+/**\n+ * super_lock - wait for superblock to become ready and lock it\n+ * @sb: superblock to wait for\n+ * @flags: SUPER_LOCK_* flags\n+ *\n+ * If the superblock has neither passed through vfs_get_tree() or\n+ * generic_shutdown_super() yet wait for it to happen. Either superblock\n+ * creation will succeed and SB_BORN is set by vfs_get_tree() or we're\n+ * woken and we'll see SB_DYING.\n+ *\n+ * With SUPER_LOCK_EXCL s_umount is taken for writing, otherwise for reading.\n+ *\n+ * A superblock which is being shut down is not waited for unless\n+ * SUPER_LOCK_WAIT_SHUTDOWN is passed. That is for those who have nothing to\n+ * do on a superblock which is going away, but who promise their caller that\n+ * what it had to write has been written, or who must not carry on while the\n+ * filesystem is still being written out. The wait is over once\n+ * generic_shutdown_super() is done with @sb, and -ENOENT is still returned.\n+ *\n+ * With SUPER_LOCK_KILLABLE all the waiting can be cut short by a fatal\n+ * signal. That is only for callers which give up altogether when they are\n+ * killed. If what comes after the wait happens either way, the wait must\n+ * not be cut short.\n+ *\n+ * The caller must have acquired a temporary reference on @sb-\u003es_passive.\n+ *\n+ * Return: 0 if SB_BORN was set and with s_umount held. Without s_umount held,\n+ * -ENOENT if the superblock is being shut down or SB_DYING was set,\n+ * -EINTR or -ERESTARTSYS if the task was killed.\n+ */\n+static __must_check int super_lock(struct super_block *sb,\n+\t\t\t\t enum super_lock_flags_t flags)\n+{\n+\tunsigned int state = TASK_UNINTERRUPTIBLE;\n+\tint ret;\n+\n+\tif (flags \u0026 SUPER_LOCK_KILLABLE)\n+\t\tstate = TASK_KILLABLE;\n \n \tlockdep_assert_not_held(\u0026sb-\u003es_umount);\n \n@@ -119,26 +169,18 @@ static int super_lock_common(struct super_block *sb, bool excl, bool killable)\n \t * and it can be a long one: the filesystem is written out first.\n \t */\n \tif (!atomic_read(\u0026sb-\u003es_active))\n-\t\treturn -ENOENT;\n+\t\tgoto dying;\n \n \t/* wait until the superblock is ready or dying */\n-\tif (killable)\n-\t\tret = wait_var_event_killable(\u0026sb-\u003es_flags,\n-\t\t\t\t\t super_flags(sb, SB_BORN | SB_DYING));\n-\telse\n-\t\twait_var_event(\u0026sb-\u003es_flags,\n-\t\t\t super_flags(sb, SB_BORN | SB_DYING));\n+\tret = super_wait(sb, SB_BORN | SB_DYING, state);\n \tif (ret)\n \t\treturn ret;\n \n \t/* Don't pointlessly acquire s_umount. */\n \tif (super_flags(sb, SB_DYING))\n-\t\treturn -ENOENT;\n+\t\tgoto dying;\n \n-\tif (killable)\n-\t\tret = __super_lock_killable(sb, excl);\n-\telse\n-\t\t__super_lock(sb, excl);\n+\tret = __super_lock(sb, flags);\n \tif (ret)\n \t\treturn ret;\n \n@@ -148,101 +190,45 @@ static int super_lock_common(struct super_block *sb, bool excl, bool killable)\n \t * grab a reference to this. Tell them so.\n \t */\n \tif (sb-\u003es_flags \u0026 SB_DYING) {\n-\t\tsuper_unlock(sb, excl);\n-\t\treturn -ENOENT;\n+\t\tsuper_unlock(sb, flags);\n+\t\tgoto dying;\n \t}\n \n \tWARN_ON_ONCE(!(sb-\u003es_flags \u0026 SB_BORN));\n \treturn 0;\n-}\n \n-/**\n- * super_lock - wait for superblock to become ready and lock it\n- * @sb: superblock to wait for\n- * @excl: whether exclusive access is required\n- *\n- * If the superblock has neither passed through vfs_get_tree() or\n- * generic_shutdown_super() yet wait for it to happen. Either superblock\n- * creation will succeed and SB_BORN is set by vfs_get_tree() or we're\n- * woken and we'll see SB_DYING.\n- *\n- * A superblock which is being shut down is not waited for, see\n- * super_wait_shutdown() and super_wait_shutdown_killable() for that.\n- *\n- * The caller must have acquired a temporary reference on @sb-\u003es_passive.\n- *\n- * Return: The function returns true if SB_BORN was set and with\n- * s_umount held. The function returns false if the superblock\n- * is being shut down or SB_DYING was set and without s_umount\n- * held.\n- */\n-static __must_check bool super_lock(struct super_block *sb, bool excl)\n-{\n-\treturn !super_lock_common(sb, excl, false);\n-}\n-\n-/**\n- * super_lock_killable - killable super_lock()\n- * @sb: superblock to wait for\n- * @excl: whether exclusive access is required\n- *\n- * Only for callers which give up altogether when they are killed.\n- *\n- * The caller must have acquired a temporary reference on @sb-\u003es_passive.\n- *\n- * Return: 0 if SB_BORN was set and with s_umount held. Without s_umount held,\n- * -ENOENT if the superblock is being shut down or SB_DYING was set,\n- * -EINTR or -ERESTARTSYS if the task was killed.\n- */\n-static __must_check int super_lock_killable(struct super_block *sb, bool excl)\n-{\n-\treturn super_lock_common(sb, excl, true);\n+dying:\n+\tif (flags \u0026 SUPER_LOCK_WAIT_SHUTDOWN) {\n+\t\tret = super_wait(sb, SB_DYING, state);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\treturn -ENOENT;\n }\n \n-/**\n- * super_wait_shutdown_killable - wait for a superblock being shut down\n- * @sb: superblock super_lock() failed on\n- *\n- * For those who have nothing to do on a superblock which is going away, but\n- * who promise their caller that what it had to write has been written.\n- *\n- * Only for callers which give up altogether when they are killed. If what\n- * comes after the wait happens either way, the wait must not be cut short.\n- *\n- * The caller must have acquired a temporary reference on @sb-\u003es_passive.\n- *\n- * Return: 0 once generic_shutdown_super() is done with @sb, -ERESTARTSYS if\n- * the task was killed first.\n- */\n-static int super_wait_shutdown_killable(struct super_block *sb)\n+static inline void super_unlock_guard(struct super_block *sb,\n+\t\t\t\t enum super_lock_flags_t flags)\n {\n-\treturn wait_var_event_killable(\u0026sb-\u003es_flags, super_flags(sb, SB_DYING));\n+\tif (!IS_ERR_OR_NULL(sb))\n+\t\tsuper_unlock(sb, flags);\n }\n \n-/**\n- * super_wait_shutdown - wait for a superblock being shut down\n- * @sb: superblock super_lock() failed on\n- *\n- * For callers of which the rest happens whether they are killed or not, and\n- * must not happen while the filesystem is still being written out.\n- *\n- * The caller must have acquired a temporary reference on @sb-\u003es_passive.\n- */\n-static void super_wait_shutdown(struct super_block *sb)\n-{\n-\twait_var_event(\u0026sb-\u003es_flags, super_flags(sb, SB_DYING));\n-}\n+/* Unlocks with the flags it locked with. */\n+__DEFINE_CLASS_IS_CONDITIONAL(super_lock, true);\n+__DEFINE_UNLOCK_GUARD(super_lock, struct super_block,\n+\t\t super_unlock_guard(_T-\u003elock, _T-\u003eflags),\n+\t\t enum super_lock_flags_t flags);\n \n-/* wait and try to acquire read-side of @sb-\u003es_umount */\n-static inline bool super_lock_shared(struct super_block *sb)\n+static inline class_super_lock_t\n+class_super_lock_constructor(struct super_block *sb, enum super_lock_flags_t flags)\n {\n-\treturn super_lock(sb, false);\n-}\n+\tclass_super_lock_t _t = { .lock = sb, .flags = flags };\n+\tint ret;\n \n-/* wait and try to acquire write-side of @sb-\u003es_umount */\n-static inline bool super_lock_excl(struct super_block *sb)\n-{\n-\treturn super_lock(sb, true);\n+\tret = super_lock(sb, flags);\n+\tif (ret)\n+\t\t_t.lock = ERR_PTR(ret);\n+\treturn _t;\n }\n \n /* wake waiters */\n@@ -606,9 +592,7 @@ static struct super_block *super_dev_next(struct super_dev *cursor,\n \t\t\t\treturn sb;\n \t\t\t}\n \t\t}\n-\t\tret = wait_var_event_state(\u0026sb-\u003es_flags,\n-\t\t\t\t\t super_flags(sb, SB_BORN | SB_DYING),\n-\t\t\t\t\t state);\n+\t\tret = super_wait(sb, SB_BORN | SB_DYING, state);\n \t\tput_super(sb);\n \t\tif (ret) {\n \t\t\tsuper_dev_walk_end(cursor);\n@@ -721,7 +705,7 @@ static int grab_super(struct super_block *sb)\n \n \trefcount_inc(\u0026sb-\u003es_passive);\n \tspin_unlock(\u0026sb_lock);\n-\tret = super_lock_killable(sb, true);\n+\tret = super_lock(sb, SUPER_LOCK_EXCL | SUPER_LOCK_KILLABLE);\n \tif (!ret) {\n \t\tif (atomic_inc_not_zero(\u0026sb-\u003es_active)) {\n \t\t\tput_super(sb);\n@@ -731,8 +715,7 @@ static int grab_super(struct super_block *sb)\n \t\tret = -ENOENT;\n \t}\n \tif (ret == -ENOENT)\n-\t\tret = wait_var_event_killable(\u0026sb-\u003es_flags,\n-\t\t\t\t\t super_flags(sb, SB_DEAD));\n+\t\tret = super_wait(sb, SB_DEAD, TASK_KILLABLE);\n \tput_super(sb);\n \treturn ret ? ret : -EAGAIN;\n }\n@@ -1052,9 +1035,13 @@ static inline struct super_block *next_super(struct super_block *sb,\n static int __iterate_supers(void (*f)(struct super_block *, void *), void *arg,\n \t\t\t enum super_iter_flags_t flags)\n {\n+\tenum super_lock_flags_t lock_flags = 0;\n \tstruct super_block *sb, *p = NULL;\n \tint ret = 0;\n \n+\tif (flags \u0026 SUPER_ITER_WAIT_SHUTDOWN)\n+\t\tlock_flags |= SUPER_LOCK_KILLABLE | SUPER_LOCK_WAIT_SHUTDOWN;\n+\n \tspin_lock(\u0026sb_lock);\n \n \tfor (sb = first_super(flags);\n@@ -1074,11 +1061,14 @@ static int __iterate_supers(void (*f)(struct super_block *, void *), void *arg,\n \n \t\tif (flags \u0026 SUPER_ITER_UNLOCKED) {\n \t\t\tf(sb, arg);\n-\t\t} else if (super_lock_shared(sb)) {\n-\t\t\tf(sb, arg);\n-\t\t\tsuper_unlock_shared(sb);\n-\t\t} else if (flags \u0026 SUPER_ITER_WAIT_SHUTDOWN) {\n-\t\t\tret = super_wait_shutdown_killable(sb);\n+\t\t} else {\n+\t\t\tACQUIRE(super_lock, lock)(sb, lock_flags);\n+\n+\t\t\tret = ACQUIRE_ERR(super_lock, \u0026lock);\n+\t\t\tif (!ret)\n+\t\t\t\tf(sb, arg);\n+\t\t\telse if (ret == -ENOENT)\n+\t\t\t\tret = 0;\n \t\t}\n \n \t\tif (p)\n@@ -1126,8 +1116,8 @@ void iterate_supers_born(void (*f)(struct super_block *, void *), void *arg)\n * A superblock which is still being set up isn't passed to @f either, and\n * isn't waited for. Nobody can have written to it yet.\n *\n- * Return: 0 if all the superblocks were seen, -ERESTARTSYS if the task was\n- * killed while it waited for one.\n+ * Return: 0 if all the superblocks were seen, -EINTR or -ERESTARTSYS if the\n+ * task was killed while it waited for one.\n */\n int iterate_supers_sync(void (*f)(struct super_block *, void *), void *arg)\n {\n@@ -1151,8 +1141,6 @@ void iterate_supers_type(struct file_system_type *type,\n \n \tspin_lock(\u0026sb_lock);\n \thlist_for_each_entry(sb, \u0026type-\u003efs_supers, s_instances) {\n-\t\tbool locked;\n-\n \t\tif (super_flags(sb, SB_DYING))\n \t\t\tcontinue;\n \n@@ -1161,11 +1149,8 @@ void iterate_supers_type(struct file_system_type *type,\n \n \t\tspin_unlock(\u0026sb_lock);\n \n-\t\tlocked = super_lock_shared(sb);\n-\t\tif (locked) {\n+\t\tscoped_guard(super_lock, sb, 0)\n \t\t\tf(sb, arg);\n-\t\t\tsuper_unlock_shared(sb);\n-\t\t}\n \n \t\tif (p)\n \t\t\tput_super(p);\n@@ -1187,7 +1172,8 @@ struct super_block *user_get_super(dev_t dev, bool excl)\n \tfor_each_dev_super_killable(sb, \u0026cursor) {\n \t\tint ret;\n \n-\t\tret = super_lock_killable(sb, excl);\n+\t\tret = super_lock(sb, (excl ? SUPER_LOCK_EXCL : 0) |\n+\t\t\t\t SUPER_LOCK_KILLABLE);\n \t\tif (ret == -ENOENT)\n \t\t\tcontinue;\n \t\tsuper_dev_walk_end(\u0026cursor);\n@@ -1310,21 +1296,19 @@ static void do_emergency_remount_callback(struct super_block *sb, void *unused)\n {\n \tstruct fs_context *fc = NULL;\n \n-\tif (!super_lock_excl(sb)) {\n-\t\t/* the unmount writes the filesystem out, wait for that */\n-\t\tsuper_wait_shutdown(sb);\n-\t\treturn;\n-\t}\n-\n-\t/* Make sure no reference put under s_umount is the last one. */\n-\tatomic_inc(\u0026sb-\u003es_active);\n-\tif (sb-\u003es_bdev \u0026\u0026 !sb_rdonly(sb)) {\n-\t\tfc = fs_context_for_reconfigure(sb-\u003es_root,\n-\t\t\t\t\tSB_RDONLY | SB_FORCE, SB_RDONLY);\n-\t\tif (!IS_ERR(fc) \u0026\u0026 parse_monolithic_mount_data(fc, NULL) == 0)\n-\t\t\t(void)reconfigure_super(fc);\n+\t/* the unmount writes the filesystem out, wait for that */\n+\tscoped_cond_guard(super_lock, return, sb,\n+\t\t\t SUPER_LOCK_EXCL | SUPER_LOCK_WAIT_SHUTDOWN) {\n+\t\t/* Make sure no reference put under s_umount is the last one. */\n+\t\tatomic_inc(\u0026sb-\u003es_active);\n+\t\tif (sb-\u003es_bdev \u0026\u0026 !sb_rdonly(sb)) {\n+\t\t\tfc = fs_context_for_reconfigure(sb-\u003es_root,\n+\t\t\t\t\t\tSB_RDONLY | SB_FORCE, SB_RDONLY);\n+\t\t\tif (!IS_ERR(fc) \u0026\u0026\n+\t\t\t parse_monolithic_mount_data(fc, NULL) == 0)\n+\t\t\t\t(void)reconfigure_super(fc);\n+\t\t}\n \t}\n-\tsuper_unlock_excl(sb);\n \n \t/*\n \t * Our active reference may be the last one by now, so only drop it\n@@ -1354,20 +1338,17 @@ void emergency_remount(void)\n \t}\n }\n \n-static inline bool get_active_super(struct super_block *sb)\n+static inline bool get_active_super(struct super_block *sb,\n+\t\t\t\t enum super_lock_flags_t flags)\n {\n-\tbool active = false;\n-\n-\tif (super_lock_excl(sb)) {\n-\t\tactive = atomic_inc_not_zero(\u0026sb-\u003es_active);\n-\t\tsuper_unlock_excl(sb);\n-\t}\n-\treturn active;\n+\tscoped_guard(super_lock, sb, SUPER_LOCK_EXCL | flags)\n+\t\treturn atomic_inc_not_zero(\u0026sb-\u003es_active);\n+\treturn false;\n }\n \n static void do_thaw_all_callback(struct super_block *sb, void *unused)\n {\n-\tif (!get_active_super(sb))\n+\tif (!get_active_super(sb, 0))\n \t\treturn;\n \n \t/* fs_bdev_thaw() acquires s_umount so it must not be held here */\n@@ -1375,7 +1356,7 @@ static void do_thaw_all_callback(struct super_block *sb, void *unused)\n \t\twhile (sb-\u003es_bdev \u0026\u0026 !bdev_thaw(sb-\u003es_bdev))\n \t\t\tpr_warn(\"Emergency Thaw on %pg\\n\", sb-\u003es_bdev);\n \n-\tif (super_lock_excl(sb))\n+\tif (!super_lock(sb, SUPER_LOCK_EXCL))\n \t\tthaw_super_locked(sb, FREEZE_HOLDER_USERSPACE, NULL);\n \tdeactivate_super(sb);\n }\n@@ -1413,11 +1394,9 @@ static void filesystems_freeze_callback(struct super_block *sb, void *freeze_all\n \tif (!freeze_all_ptr \u0026\u0026 !(sb-\u003es_type-\u003efs_flags \u0026 FS_POWER_FREEZE))\n \t\treturn;\n \n-\tif (!get_active_super(sb)) {\n-\t\t/* an unmount from a workqueue isn't stopped by the freezer */\n-\t\tsuper_wait_shutdown(sb);\n+\t/* an unmount from a workqueue isn't stopped by the freezer */\n+\tif (!get_active_super(sb, SUPER_LOCK_WAIT_SHUTDOWN))\n \t\treturn;\n-\t}\n \n \tif (sb-\u003es_op-\u003efreeze_super)\n \t\tsb-\u003es_op-\u003efreeze_super(sb, FREEZE_EXCL | FREEZE_HOLDER_KERNEL,\n@@ -1444,7 +1423,7 @@ static void filesystems_thaw_callback(struct super_block *sb, void *unused)\n \tif (!sb-\u003es_op-\u003efreeze_fs \u0026\u0026 !sb-\u003es_op-\u003efreeze_super)\n \t\treturn;\n \n-\tif (!get_active_super(sb))\n+\tif (!get_active_super(sb, 0))\n \t\treturn;\n \n \tif (sb-\u003es_op-\u003ethaw_super)\n@@ -1664,7 +1643,7 @@ static int fs_super_thaw(struct super_block *sb)\n \t}\n \n \t/* The caller holds an active reference. */\n-\tif (WARN_ON_ONCE(!super_lock_excl(sb)))\n+\tif (WARN_ON_ONCE(super_lock(sb, SUPER_LOCK_EXCL)))\n \t\treturn 0;\n \n \t/* FITHAW or an emergency thaw may have dropped the freeze already. */\n@@ -1685,12 +1664,11 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)\n \tmutex_unlock(\u0026bdev-\u003ebd_holder_lock);\n \n \tfor_each_dev_super(sb, \u0026cursor) {\n-\t\tif (!super_lock_shared(sb)) {\n-\t\t\t/* don't take the device away from under an unmount */\n-\t\t\tif (!surprise)\n-\t\t\t\tsuper_wait_shutdown(sb);\n+\t\t/* don't take the device away from under an unmount */\n+\t\tACQUIRE(super_lock, lock)(sb, surprise ? 0 :\n+\t\t\t\t\t SUPER_LOCK_WAIT_SHUTDOWN);\n+\t\tif (ACQUIRE_ERR(super_lock, \u0026lock))\n \t\t\tcontinue;\n-\t\t}\n \t\tif (sb-\u003es_root \u0026\u0026 (sb-\u003es_flags \u0026 SB_ACTIVE)) {\n \t\t\tif (!sb-\u003es_op-\u003eremove_bdev ||\n \t\t\t sb-\u003es_op-\u003eremove_bdev(sb, bdev)) {\n@@ -1702,7 +1680,6 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)\n \t\t\t\t\tsb-\u003es_op-\u003eshutdown(sb);\n \t\t\t}\n \t\t}\n-\t\tsuper_unlock_shared(sb);\n \t}\n }\n \n@@ -1714,22 +1691,19 @@ static void fs_bdev_sync(struct block_device *bdev)\n \tmutex_unlock(\u0026bdev-\u003ebd_holder_lock);\n \n \tfor_each_dev_super_killable(sb, \u0026cursor) {\n-\t\tint ret;\n+\t\tACQUIRE(super_lock, lock)(sb, SUPER_LOCK_KILLABLE |\n+\t\t\t\t\t SUPER_LOCK_WAIT_SHUTDOWN);\n+\t\tint ret = ACQUIRE_ERR(super_lock, \u0026lock);\n \n-\t\tret = super_lock_killable(sb, false);\n-\t\tif (!ret) {\n-\t\t\tif (sb-\u003es_root \u0026\u0026 (sb-\u003es_flags \u0026 SB_ACTIVE))\n-\t\t\t\tsync_filesystem(sb);\n-\t\t\tsuper_unlock_shared(sb);\n-\t\t\tcontinue;\n-\t\t}\n \t\tif (ret == -ENOENT)\n-\t\t\tret = super_wait_shutdown_killable(sb);\n+\t\t\tcontinue;\n \t\tif (ret) {\n \t\t\tsuper_dev_walk_end(\u0026cursor);\n \t\t\tput_super(sb);\n \t\t\treturn;\n \t\t}\n+\t\tif (sb-\u003es_root \u0026\u0026 (sb-\u003es_flags \u0026 SB_ACTIVE))\n+\t\t\tsync_filesystem(sb);\n \t}\n }\n \n@@ -1758,11 +1732,9 @@ static int fs_bdev_freeze(struct block_device *bdev)\n \tmutex_unlock(\u0026bdev-\u003ebd_holder_lock);\n \n \tfor_each_dev_super(sb, \u0026cursor) {\n-\t\tif (!get_active_super(sb)) {\n-\t\t\t/* an unmount writes to the device until it is done */\n-\t\t\tsuper_wait_shutdown(sb);\n+\t\t/* an unmount writes to the device until it is done */\n+\t\tif (!get_active_super(sb, SUPER_LOCK_WAIT_SHUTDOWN))\n \t\t\tcontinue;\n-\t\t}\n \t\terr = fs_super_freeze(sb);\n \t\tif (err \u0026\u0026 !error)\n \t\t\terror = err;\n@@ -1816,7 +1788,7 @@ static int fs_bdev_thaw(struct block_device *bdev)\n \tmutex_unlock(\u0026bdev-\u003ebd_holder_lock);\n \n \tfor_each_dev_super(sb, \u0026cursor) {\n-\t\tif (!get_active_super(sb))\n+\t\tif (!get_active_super(sb, 0))\n \t\t\tcontinue;\n \t\terr = fs_super_thaw(sb);\n \t\tif (err \u0026\u0026 !error)\n@@ -2513,7 +2485,7 @@ int freeze_super(struct super_block *sb, enum freeze_holder who, const void *fre\n {\n \tint ret;\n \n-\tif (!super_lock_excl(sb)) {\n+\tif (super_lock(sb, SUPER_LOCK_EXCL)) {\n \t\tWARN_ONCE(1, \"Dying superblock while freezing!\");\n \t\treturn -EINVAL;\n \t}\n@@ -2680,7 +2652,7 @@ static int thaw_super_locked(struct super_block *sb, enum freeze_holder who,\n int thaw_super(struct super_block *sb, enum freeze_holder who,\n \t const void *freeze_owner)\n {\n-\tif (!super_lock_excl(sb)) {\n+\tif (super_lock(sb, SUPER_LOCK_EXCL)) {\n \t\tWARN_ONCE(1, \"Dying superblock while thawing!\");\n \t\treturn -EINVAL;\n \t}\n"
} |
| 2/1 | 2026/10/23 22:31 | agent | patch-evaluator |
2mModel:core Args: null Results: {
"EnableConfigs": [
"BLOCK"
],
"FocusSymbols": [
"super_lock",
"freeze_super",
"thaw_super",
"iterate_supers_sync",
"user_get_super",
"grab_super",
"fs_bdev_sync",
"fs_bdev_freeze",
"fs_bdev_thaw"
],
"Reasoning": "The patch modifies core VFS superblock locking and shutdown waiting logic in fs/super.c. It consolidates multiple locking helpers into a unified super_lock() function with flags, changes its return semantics from bool to int error codes, and introduces RAII-style cleanup guards (scoped_guard, scoped_cond_guard, ACQUIRE). These modifications directly affect reachable code paths exercised by common filesystem syscalls and ioctls, including mount, sync, FIFREEZE/FITHAW ioctls, and block device holder callbacks. Such locking and lifecycle refactorings warrant fuzzing to catch potential lockdep splats, regressions, or synchronization races.",
"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 7d0dafe06bb19feaa70a02f1f486e0c37394c702
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Oct 23 22:31:42 2026 +0000
syz-cluster: applied patch under review
diff --git a/fs/super.c b/fs/super.c
index 63e85794ea4d5..aff2169ca94d1 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -55,24 +55,32 @@ static char *sb_writers_name[SB_FREEZE_LEVELS] = {
"sb_internal",
};
-static inline void __super_lock(struct super_block *sb, bool excl)
+enum super_lock_flags_t {
+ SUPER_LOCK_EXCL = (1U << 0),
+ SUPER_LOCK_KILLABLE = (1U << 1),
+ SUPER_LOCK_WAIT_SHUTDOWN = (1U << 2),
+};
+
+static inline int __super_lock(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- if (excl)
+ if (flags & SUPER_LOCK_KILLABLE) {
+ if (flags & SUPER_LOCK_EXCL)
+ return down_write_killable(&sb->s_umount);
+ return down_read_killable(&sb->s_umount);
+ }
+
+ if (flags & SUPER_LOCK_EXCL)
down_write(&sb->s_umount);
else
down_read(&sb->s_umount);
+ return 0;
}
-static inline int __super_lock_killable(struct super_block *sb, bool excl)
-{
- if (excl)
- return down_write_killable(&sb->s_umount);
- return down_read_killable(&sb->s_umount);
-}
-
-static inline void super_unlock(struct super_block *sb, bool excl)
+static inline void super_unlock(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- if (excl)
+ if (flags & SUPER_LOCK_EXCL)
up_write(&sb->s_umount);
else
up_read(&sb->s_umount);
@@ -80,17 +88,17 @@ static inline void super_unlock(struct super_block *sb, bool excl)
static inline void __super_lock_excl(struct super_block *sb)
{
- __super_lock(sb, true);
+ __super_lock(sb, SUPER_LOCK_EXCL);
}
static inline void super_unlock_excl(struct super_block *sb)
{
- super_unlock(sb, true);
+ super_unlock(sb, SUPER_LOCK_EXCL);
}
static inline void super_unlock_shared(struct super_block *sb)
{
- super_unlock(sb, false);
+ super_unlock(sb, 0);
}
static bool super_flags(const struct super_block *sb, unsigned int flags)
@@ -103,12 +111,54 @@ static bool super_flags(const struct super_block *sb, unsigned int flags)
}
/*
- * Returns 0 with s_umount held, -ENOENT if the superblock is going away, or,
- * if @killable, the error from a wait which was cut short.
+ * Wait for one of @sb_flags to be set on @sb, sleeping in @state. Returns 0
+ * or -ERESTARTSYS if @state allowed the wait to be cut short.
*/
-static int super_lock_common(struct super_block *sb, bool excl, bool killable)
+static int super_wait(struct super_block *sb, unsigned int sb_flags,
+ unsigned int state)
{
- int ret = 0;
+ return wait_var_event_state(&sb->s_flags, super_flags(sb, sb_flags),
+ state);
+}
+
+/**
+ * super_lock - wait for superblock to become ready and lock it
+ * @sb: superblock to wait for
+ * @flags: SUPER_LOCK_* flags
+ *
+ * If the superblock has neither passed through vfs_get_tree() or
+ * generic_shutdown_super() yet wait for it to happen. Either superblock
+ * creation will succeed and SB_BORN is set by vfs_get_tree() or we're
+ * woken and we'll see SB_DYING.
+ *
+ * With SUPER_LOCK_EXCL s_umount is taken for writing, otherwise for reading.
+ *
+ * A superblock which is being shut down is not waited for unless
+ * SUPER_LOCK_WAIT_SHUTDOWN is passed. That is for those who have nothing to
+ * do on a superblock which is going away, but who promise their caller that
+ * what it had to write has been written, or who must not carry on while the
+ * filesystem is still being written out. The wait is over once
+ * generic_shutdown_super() is done with @sb, and -ENOENT is still returned.
+ *
+ * With SUPER_LOCK_KILLABLE all the waiting can be cut short by a fatal
+ * signal. That is only for callers which give up altogether when they are
+ * killed. If what comes after the wait happens either way, the wait must
+ * not be cut short.
+ *
+ * The caller must have acquired a temporary reference on @sb->s_passive.
+ *
+ * Return: 0 if SB_BORN was set and with s_umount held. Without s_umount held,
+ * -ENOENT if the superblock is being shut down or SB_DYING was set,
+ * -EINTR or -ERESTARTSYS if the task was killed.
+ */
+static __must_check int super_lock(struct super_block *sb,
+ enum super_lock_flags_t flags)
+{
+ unsigned int state = TASK_UNINTERRUPTIBLE;
+ int ret;
+
+ if (flags & SUPER_LOCK_KILLABLE)
+ state = TASK_KILLABLE;
lockdep_assert_not_held(&sb->s_umount);
@@ -119,26 +169,18 @@ static int super_lock_common(struct super_block *sb, bool excl, bool killable)
* and it can be a long one: the filesystem is written out first.
*/
if (!atomic_read(&sb->s_active))
- return -ENOENT;
+ goto dying;
/* wait until the superblock is ready or dying */
- if (killable)
- ret = wait_var_event_killable(&sb->s_flags,
- super_flags(sb, SB_BORN | SB_DYING));
- else
- wait_var_event(&sb->s_flags,
- super_flags(sb, SB_BORN | SB_DYING));
+ ret = super_wait(sb, SB_BORN | SB_DYING, state);
if (ret)
return ret;
/* Don't pointlessly acquire s_umount. */
if (super_flags(sb, SB_DYING))
- return -ENOENT;
+ goto dying;
- if (killable)
- ret = __super_lock_killable(sb, excl);
- else
- __super_lock(sb, excl);
+ ret = __super_lock(sb, flags);
if (ret)
return ret;
@@ -148,101 +190,45 @@ static int super_lock_common(struct super_block *sb, bool excl, bool killable)
* grab a reference to this. Tell them so.
*/
if (sb->s_flags & SB_DYING) {
- super_unlock(sb, excl);
- return -ENOENT;
+ super_unlock(sb, flags);
+ goto dying;
}
WARN_ON_ONCE(!(sb->s_flags & SB_BORN));
return 0;
-}
-/**
- * super_lock - wait for superblock to become ready and lock it
- * @sb: superblock to wait for
- * @excl: whether exclusive access is required
- *
- * If the superblock has neither passed through vfs_get_tree() or
- * generic_shutdown_super() yet wait for it to happen. Either superblock
- * creation will succeed and SB_BORN is set by vfs_get_tree() or we're
- * woken and we'll see SB_DYING.
- *
- * A superblock which is being shut down is not waited for, see
- * super_wait_shutdown() and super_wait_shutdown_killable() for that.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- *
- * Return: The function returns true if SB_BORN was set and with
- * s_umount held. The function returns false if the superblock
- * is being shut down or SB_DYING was set and without s_umount
- * held.
- */
-static __must_check bool super_lock(struct super_block *sb, bool excl)
-{
- return !super_lock_common(sb, excl, false);
-}
-
-/**
- * super_lock_killable - killable super_lock()
- * @sb: superblock to wait for
- * @excl: whether exclusive access is required
- *
- * Only for callers which give up altogether when they are killed.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- *
- * Return: 0 if SB_BORN was set and with s_umount held. Without s_umount held,
- * -ENOENT if the superblock is being shut down or SB_DYING was set,
- * -EINTR or -ERESTARTSYS if the task was killed.
- */
-static __must_check int super_lock_killable(struct super_block *sb, bool excl)
-{
- return super_lock_common(sb, excl, true);
+dying:
+ if (flags & SUPER_LOCK_WAIT_SHUTDOWN) {
+ ret = super_wait(sb, SB_DYING, state);
+ if (ret)
+ return ret;
+ }
+ return -ENOENT;
}
-/**
- * super_wait_shutdown_killable - wait for a superblock being shut down
- * @sb: superblock super_lock() failed on
- *
- * For those who have nothing to do on a superblock which is going away, but
- * who promise their caller that what it had to write has been written.
- *
- * Only for callers which give up altogether when they are killed. If what
- * comes after the wait happens either way, the wait must not be cut short.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- *
- * Return: 0 once generic_shutdown_super() is done with @sb, -ERESTARTSYS if
- * the task was killed first.
- */
-static int super_wait_shutdown_killable(struct super_block *sb)
+static inline void super_unlock_guard(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- return wait_var_event_killable(&sb->s_flags, super_flags(sb, SB_DYING));
+ if (!IS_ERR_OR_NULL(sb))
+ super_unlock(sb, flags);
}
-/**
- * super_wait_shutdown - wait for a superblock being shut down
- * @sb: superblock super_lock() failed on
- *
- * For callers of which the rest happens whether they are killed or not, and
- * must not happen while the filesystem is still being written out.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- */
-static void super_wait_shutdown(struct super_block *sb)
-{
- wait_var_event(&sb->s_flags, super_flags(sb, SB_DYING));
-}
+/* Unlocks with the flags it locked with. */
+__DEFINE_CLASS_IS_CONDITIONAL(super_lock, true);
+__DEFINE_UNLOCK_GUARD(super_lock, struct super_block,
+ super_unlock_guard(_T->lock, _T->flags),
+ enum super_lock_flags_t flags);
-/* wait and try to acquire read-side of @sb->s_umount */
-static inline bool super_lock_shared(struct super_block *sb)
+static inline class_super_lock_t
+class_super_lock_constructor(struct super_block *sb, enum super_lock_flags_t flags)
{
- return super_lock(sb, false);
-}
+ class_super_lock_t _t = { .lock = sb, .flags = flags };
+ int ret;
-/* wait and try to acquire write-side of @sb->s_umount */
-static inline bool super_lock_excl(struct super_block *sb)
-{
- return super_lock(sb, true);
+ ret = super_lock(sb, flags);
+ if (ret)
+ _t.lock = ERR_PTR(ret);
+ return _t;
}
/* wake waiters */
@@ -606,9 +592,7 @@ static struct super_block *super_dev_next(struct super_dev *cursor,
return sb;
}
}
- ret = wait_var_event_state(&sb->s_flags,
- super_flags(sb, SB_BORN | SB_DYING),
- state);
+ ret = super_wait(sb, SB_BORN | SB_DYING, state);
put_super(sb);
if (ret) {
super_dev_walk_end(cursor);
@@ -721,7 +705,7 @@ static int grab_super(struct super_block *sb)
refcount_inc(&sb->s_passive);
spin_unlock(&sb_lock);
- ret = super_lock_killable(sb, true);
+ ret = super_lock(sb, SUPER_LOCK_EXCL | SUPER_LOCK_KILLABLE);
if (!ret) {
if (atomic_inc_not_zero(&sb->s_active)) {
put_super(sb);
@@ -731,8 +715,7 @@ static int grab_super(struct super_block *sb)
ret = -ENOENT;
}
if (ret == -ENOENT)
- ret = wait_var_event_killable(&sb->s_flags,
- super_flags(sb, SB_DEAD));
+ ret = super_wait(sb, SB_DEAD, TASK_KILLABLE);
put_super(sb);
return ret ? ret : -EAGAIN;
}
@@ -1052,9 +1035,13 @@ static inline struct super_block *next_super(struct super_block *sb,
static int __iterate_supers(void (*f)(struct super_block *, void *), void *arg,
enum super_iter_flags_t flags)
{
+ enum super_lock_flags_t lock_flags = 0;
struct super_block *sb, *p = NULL;
int ret = 0;
+ if (flags & SUPER_ITER_WAIT_SHUTDOWN)
+ lock_flags |= SUPER_LOCK_KILLABLE | SUPER_LOCK_WAIT_SHUTDOWN;
+
spin_lock(&sb_lock);
for (sb = first_super(flags);
@@ -1074,11 +1061,14 @@ static int __iterate_supers(void (*f)(struct super_block *, void *), void *arg,
if (flags & SUPER_ITER_UNLOCKED) {
f(sb, arg);
- } else if (super_lock_shared(sb)) {
- f(sb, arg);
- super_unlock_shared(sb);
- } else if (flags & SUPER_ITER_WAIT_SHUTDOWN) {
- ret = super_wait_shutdown_killable(sb);
+ } else {
+ ACQUIRE(super_lock, lock)(sb, lock_flags);
+
+ ret = ACQUIRE_ERR(super_lock, &lock);
+ if (!ret)
+ f(sb, arg);
+ else if (ret == -ENOENT)
+ ret = 0;
}
if (p)
@@ -1126,8 +1116,8 @@ void iterate_supers_born(void (*f)(struct super_block *, void *), void *arg)
* A superblock which is still being set up isn't passed to @f either, and
* isn't waited for. Nobody can have written to it yet.
*
- * Return: 0 if all the superblocks were seen, -ERESTARTSYS if the task was
- * killed while it waited for one.
+ * Return: 0 if all the superblocks were seen, -EINTR or -ERESTARTSYS if the
+ * task was killed while it waited for one.
*/
int iterate_supers_sync(void (*f)(struct super_block *, void *), void *arg)
{
@@ -1151,8 +1141,6 @@ void iterate_supers_type(struct file_system_type *type,
spin_lock(&sb_lock);
hlist_for_each_entry(sb, &type->fs_supers, s_instances) {
- bool locked;
-
if (super_flags(sb, SB_DYING))
continue;
@@ -1161,11 +1149,8 @@ void iterate_supers_type(struct file_system_type *type,
spin_unlock(&sb_lock);
- locked = super_lock_shared(sb);
- if (locked) {
+ scoped_guard(super_lock, sb, 0)
f(sb, arg);
- super_unlock_shared(sb);
- }
if (p)
put_super(p);
@@ -1187,7 +1172,8 @@ struct super_block *user_get_super(dev_t dev, bool excl)
for_each_dev_super_killable(sb, &cursor) {
int ret;
- ret = super_lock_killable(sb, excl);
+ ret = super_lock(sb, (excl ? SUPER_LOCK_EXCL : 0) |
+ SUPER_LOCK_KILLABLE);
if (ret == -ENOENT)
continue;
super_dev_walk_end(&cursor);
@@ -1310,21 +1296,19 @@ static void do_emergency_remount_callback(struct super_block *sb, void *unused)
{
struct fs_context *fc = NULL;
- if (!super_lock_excl(sb)) {
- /* the unmount writes the filesystem out, wait for that */
- super_wait_shutdown(sb);
- return;
- }
-
- /* Make sure no reference put under s_umount is the last one. */
- atomic_inc(&sb->s_active);
- if (sb->s_bdev && !sb_rdonly(sb)) {
- fc = fs_context_for_reconfigure(sb->s_root,
- SB_RDONLY | SB_FORCE, SB_RDONLY);
- if (!IS_ERR(fc) && parse_monolithic_mount_data(fc, NULL) == 0)
- (void)reconfigure_super(fc);
+ /* the unmount writes the filesystem out, wait for that */
+ scoped_cond_guard(super_lock, return, sb,
+ SUPER_LOCK_EXCL | SUPER_LOCK_WAIT_SHUTDOWN) {
+ /* Make sure no reference put under s_umount is the last one. */
+ atomic_inc(&sb->s_active);
+ if (sb->s_bdev && !sb_rdonly(sb)) {
+ fc = fs_context_for_reconfigure(sb->s_root,
+ SB_RDONLY | SB_FORCE, SB_RDONLY);
+ if (!IS_ERR(fc) &&
+ parse_monolithic_mount_data(fc, NULL) == 0)
+ (void)reconfigure_super(fc);
+ }
}
- super_unlock_excl(sb);
/*
* Our active reference may be the last one by now, so only drop it
@@ -1354,20 +1338,17 @@ void emergency_remount(void)
}
}
-static inline bool get_active_super(struct super_block *sb)
+static inline bool get_active_super(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- bool active = false;
-
- if (super_lock_excl(sb)) {
- active = atomic_inc_not_zero(&sb->s_active);
- super_unlock_excl(sb);
- }
- return active;
+ scoped_guard(super_lock, sb, SUPER_LOCK_EXCL | flags)
+ return atomic_inc_not_zero(&sb->s_active);
+ return false;
}
static void do_thaw_all_callback(struct super_block *sb, void *unused)
{
- if (!get_active_super(sb))
+ if (!get_active_super(sb, 0))
return;
/* fs_bdev_thaw() acquires s_umount so it must not be held here */
@@ -1375,7 +1356,7 @@ static void do_thaw_all_callback(struct super_block *sb, void *unused)
while (sb->s_bdev && !bdev_thaw(sb->s_bdev))
pr_warn("Emergency Thaw on %pg\n", sb->s_bdev);
- if (super_lock_excl(sb))
+ if (!super_lock(sb, SUPER_LOCK_EXCL))
thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE, NULL);
deactivate_super(sb);
}
@@ -1413,11 +1394,9 @@ static void filesystems_freeze_callback(struct super_block *sb, void *freeze_all
if (!freeze_all_ptr && !(sb->s_type->fs_flags & FS_POWER_FREEZE))
return;
- if (!get_active_super(sb)) {
- /* an unmount from a workqueue isn't stopped by the freezer */
- super_wait_shutdown(sb);
+ /* an unmount from a workqueue isn't stopped by the freezer */
+ if (!get_active_super(sb, SUPER_LOCK_WAIT_SHUTDOWN))
return;
- }
if (sb->s_op->freeze_super)
sb->s_op->freeze_super(sb, FREEZE_EXCL | FREEZE_HOLDER_KERNEL,
@@ -1444,7 +1423,7 @@ static void filesystems_thaw_callback(struct super_block *sb, void *unused)
if (!sb->s_op->freeze_fs && !sb->s_op->freeze_super)
return;
- if (!get_active_super(sb))
+ if (!get_active_super(sb, 0))
return;
if (sb->s_op->thaw_super)
@@ -1664,7 +1643,7 @@ static int fs_super_thaw(struct super_block *sb)
}
/* The caller holds an active reference. */
- if (WARN_ON_ONCE(!super_lock_excl(sb)))
+ if (WARN_ON_ONCE(super_lock(sb, SUPER_LOCK_EXCL)))
return 0;
/* FITHAW or an emergency thaw may have dropped the freeze already. */
@@ -1685,12 +1664,11 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super(sb, &cursor) {
- if (!super_lock_shared(sb)) {
- /* don't take the device away from under an unmount */
- if (!surprise)
- super_wait_shutdown(sb);
+ /* don't take the device away from under an unmount */
+ ACQUIRE(super_lock, lock)(sb, surprise ? 0 :
+ SUPER_LOCK_WAIT_SHUTDOWN);
+ if (ACQUIRE_ERR(super_lock, &lock))
continue;
- }
if (sb->s_root && (sb->s_flags & SB_ACTIVE)) {
if (!sb->s_op->remove_bdev ||
sb->s_op->remove_bdev(sb, bdev)) {
@@ -1702,7 +1680,6 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)
sb->s_op->shutdown(sb);
}
}
- super_unlock_shared(sb);
}
}
@@ -1714,22 +1691,19 @@ static void fs_bdev_sync(struct block_device *bdev)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super_killable(sb, &cursor) {
- int ret;
+ ACQUIRE(super_lock, lock)(sb, SUPER_LOCK_KILLABLE |
+ SUPER_LOCK_WAIT_SHUTDOWN);
+ int ret = ACQUIRE_ERR(super_lock, &lock);
- ret = super_lock_killable(sb, false);
- if (!ret) {
- if (sb->s_root && (sb->s_flags & SB_ACTIVE))
- sync_filesystem(sb);
- super_unlock_shared(sb);
- continue;
- }
if (ret == -ENOENT)
- ret = super_wait_shutdown_killable(sb);
+ continue;
if (ret) {
super_dev_walk_end(&cursor);
put_super(sb);
return;
}
+ if (sb->s_root && (sb->s_flags & SB_ACTIVE))
+ sync_filesystem(sb);
}
}
@@ -1758,11 +1732,9 @@ static int fs_bdev_freeze(struct block_device *bdev)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super(sb, &cursor) {
- if (!get_active_super(sb)) {
- /* an unmount writes to the device until it is done */
- super_wait_shutdown(sb);
+ /* an unmount writes to the device until it is done */
+ if (!get_active_super(sb, SUPER_LOCK_WAIT_SHUTDOWN))
continue;
- }
err = fs_super_freeze(sb);
if (err && !error)
error = err;
@@ -1816,7 +1788,7 @@ static int fs_bdev_thaw(struct block_device *bdev)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super(sb, &cursor) {
- if (!get_active_super(sb))
+ if (!get_active_super(sb, 0))
continue;
err = fs_super_thaw(sb);
if (err && !error)
@@ -2513,7 +2485,7 @@ int freeze_super(struct super_block *sb, enum freeze_holder who, const void *fre
{
int ret;
- if (!super_lock_excl(sb)) {
+ if (super_lock(sb, SUPER_LOCK_EXCL)) {
WARN_ONCE(1, "Dying superblock while freezing!");
return -EINVAL;
}
@@ -2680,7 +2652,7 @@ static int thaw_super_locked(struct super_block *sb, enum freeze_holder who,
int thaw_super(struct super_block *sb, enum freeze_holder who,
const void *freeze_owner)
{
- if (!super_lock_excl(sb)) {
+ if (super_lock(sb, SUPER_LOCK_EXCL)) {
WARN_ONCE(1, "Dying superblock while thawing!");
return -EINVAL;
}
|
| 3/2 | 2026/10/23 22:31 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 10144 output: 33 thoughts: 1494 Thoughts: **WorthFuzzing Analysis of Kernel Patch in fs/super.c** Okay, so I need to evaluate this patch series that touches `fs/super.c`. First, I want to understand what's been changed. Reading the diff, it looks like there's a new `enum super_lock_flags_t` and a refactoring of the `__super_lock`, `super_unlock`, and related functions. There's also some cleanup with guards introduced, like `__DEFINE_CLASS_IS_CONDITIONAL`, and `scoped_guard`, etc. It looks like quite a few calls in functions like `grab_super`, `iterate_supers_type`, `user_get_super`, and a slew of other superblock-related functions are being changed. Given the nature of the changes, I need to check the Git log to understand the full scope, but I have to use `grepper`, `codesearch-dir-index`, `read-file` and `set-results` since I don't have direct access to `git log`. Crucially, I need to refer back to the core triage philosophy. The main point is reachability – can the changed code *actually* execute in a standard virtualized environment? And, I need to be careful about refactoring; they can introduce subtle semantic shifts. So I need to go through the guidelines again to see if this constitutes refactoring or a logic modification, and if it's in a core subsystem. `fs/super.c` is definitely core VFS code. It’s all about superblock locking, lifecycle management, freezing, thawing, mounting, unmounting, iterating supers, syncing, and bdev operations. That's a huge deal. That's reachable from syscalls like `mount`, `umount2`, `sync`, ioctls like `FIFREEZE`, and `FITHAW`, so it's most certainly reachable and worth fuzzing. Therefore, WorthFuzzing is almost certainly TRUE! These are core VFS superblock locking changes, cleanup guards, and refactoring. Now, the important part: defining `FocusSymbols`. I need to identify which functions were altered or introduced in `fs/super.c`. Let's create a list: - `super_wait` (static) - `super_lock` (static) - `super_unlock` (static inline) - `super_unlock_guard` (static inline) - `class_super_lock_constructor` (static inline) - `super_dev_next` (static) - `grab_super` (static) - `__iterate_supers` (static) - `iterate_supers_sync` (global) - `iterate_supers_type` (global) - `user_get_super` (global) - `do_emergency_remount_callback` (static) - `get_active_super` (static inline) - `do_thaw_all_callback` (static) - `filesystems_freeze_callback` (static) - `filesystems_thaw_callback` (static) - `fs_super_thaw` (static) - `fs_bdev_mark_dead` (static) - `fs_bdev_sync` (static) - `fs_bdev_freeze` (static) - `fs_bdev_thaw` (static) - `freeze_super` (global) - `thaw_super` (global) Okay, now let's think about `FocusSymbols`. I *must* avoid generic, ubiquitous functions. I need to list functions that specifically implement the logic being added or altered, or direct API entrypoints. Also, static inline functions are compiled away, so I need to find the callers of the inline ones. I'm going to carefully inspect the code in `fs/super.c` using `read-file` and `grepper` to see which are static, which are inline, and where the non-static callers reside. Specifically, I'll focus on the area around the lock changes (lines 55-250) and then the freezing/thawing areas (lines 1050-1850). This will help me select the appropriate `FocusSymbols`. |
| 4/2 | 2026/10/23 22:32 | tool | read-file |
0mArgs:{
"File": "fs/super.c",
"FirstLine": 140,
"LineCount": 80
}Results: {
"Contents": " 140:\t * filesystem is still being written out. The wait is over once\n 141:\t * generic_shutdown_super() is done with @sb, and -ENOENT is still returned.\n 142:\t *\n 143:\t * With SUPER_LOCK_KILLABLE all the waiting can be cut short by a fatal\n 144:\t * signal. That is only for callers which give up altogether when they are\n 145:\t * killed. If what comes after the wait happens either way, the wait must\n 146:\t * not be cut short.\n 147:\t *\n 148:\t * The caller must have acquired a temporary reference on @sb-\u003es_passive.\n 149:\t *\n 150:\t * Return: 0 if SB_BORN was set and with s_umount held. Without s_umount held,\n 151:\t * -ENOENT if the superblock is being shut down or SB_DYING was set,\n 152:\t * -EINTR or -ERESTARTSYS if the task was killed.\n 153:\t */\n 154:\tstatic __must_check int super_lock(struct super_block *sb,\n 155:\t\t\t\t\t enum super_lock_flags_t flags)\n 156:\t{\n 157:\t\tunsigned int state = TASK_UNINTERRUPTIBLE;\n 158:\t\tint ret;\n 159:\t\n 160:\t\tif (flags \u0026 SUPER_LOCK_KILLABLE)\n 161:\t\t\tstate = TASK_KILLABLE;\n 162:\t\n 163:\t\tlockdep_assert_not_held(\u0026sb-\u003es_umount);\n 164:\t\n 165:\t\t/*\n 166:\t\t * The last active reference is dropped with s_umount held, which\n 167:\t\t * stays held until SB_DYING is set, and there is no getting a new\n 168:\t\t * one. All there is to find at the end of that wait is SB_DYING,\n 169:\t\t * and it can be a long one: the filesystem is written out first.\n 170:\t\t */\n 171:\t\tif (!atomic_read(\u0026sb-\u003es_active))\n 172:\t\t\tgoto dying;\n 173:\t\n 174:\t\t/* wait until the superblock is ready or dying */\n 175:\t\tret = super_wait(sb, SB_BORN | SB_DYING, state);\n 176:\t\tif (ret)\n 177:\t\t\treturn ret;\n 178:\t\n 179:\t\t/* Don't pointlessly acquire s_umount. */\n 180:\t\tif (super_flags(sb, SB_DYING))\n 181:\t\t\tgoto dying;\n 182:\t\n 183:\t\tret = __super_lock(sb, flags);\n 184:\t\tif (ret)\n 185:\t\t\treturn ret;\n 186:\t\n 187:\t\t/*\n 188:\t\t * Has gone through generic_shutdown_super() in the meantime.\n 189:\t\t * @sb-\u003es_root is NULL and @sb-\u003es_active is 0. No one needs to\n 190:\t\t * grab a reference to this. Tell them so.\n 191:\t\t */\n 192:\t\tif (sb-\u003es_flags \u0026 SB_DYING) {\n 193:\t\t\tsuper_unlock(sb, flags);\n 194:\t\t\tgoto dying;\n 195:\t\t}\n 196:\t\n 197:\t\tWARN_ON_ONCE(!(sb-\u003es_flags \u0026 SB_BORN));\n 198:\t\treturn 0;\n 199:\t\n 200:\tdying:\n 201:\t\tif (flags \u0026 SUPER_LOCK_WAIT_SHUTDOWN) {\n 202:\t\t\tret = super_wait(sb, SB_DYING, state);\n 203:\t\t\tif (ret)\n 204:\t\t\t\treturn ret;\n 205:\t\t}\n 206:\t\treturn -ENOENT;\n 207:\t}\n 208:\t\n 209:\tstatic inline void super_unlock_guard(struct super_block *sb,\n 210:\t\t\t\t\t enum super_lock_flags_t flags)\n 211:\t{\n 212:\t\tif (!IS_ERR_OR_NULL(sb))\n 213:\t\t\tsuper_unlock(sb, flags);\n 214:\t}\n 215:\t\n 216:\t/* Unlocks with the flags it locked with. */\n 217:\t__DEFINE_CLASS_IS_CONDITIONAL(super_lock, true);\n 218:\t__DEFINE_UNLOCK_GUARD(super_lock, struct super_block,\n 219:\t\t\t super_unlock_guard(_T-\u003elock, _T-\u003eflags),\n"
} |
| 5/2 | 2026/10/23 22:32 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13855 output: 57 thoughts: 194 Thoughts: **Analyzing Superblock Locking and Related Functions** Okay, let's dive into this `super_lock` situation. My first thought is to understand its call sites and any associated modifications. Looking at `fs/super.c`, the fact that `super_lock` is declared as `static` and non-`inline` immediately piques my interest. It's marked as `static __must_check int super_lock(...)`. In a typical kernel build, this implies it's probably *not* inlined by default, unless we're dealing with Link Time Optimization (LTO) or whole-program optimization. Given it's called so frequently within `fs/super.c` – I'm guessing at least 5-10 times based on experience – the compiler is very unlikely to inline it without those more aggressive optimizations. That's good to keep in mind, and informs my understanding of any changes. Now, I need to expand the scope and look beyond just `super_lock`. I see `user_get_super` as a potentially related function, especially because it's not `static`. That suggests it's either exported or declared in `fs.h`, and therefore could interact with `super_lock`. Let's also bring `freeze_super`, `thaw_super`, `iterate_supers_sync`, and `iterate_supers_type` into the picture. These all have "super" in their name, so are likely related. It's time to fire up `grep` and search for these functions across the `fs/` directory to get a complete picture of their usage and interactions. |
| 6/2 | 2026/10/23 22:32 | tool | grepper |
0mArgs:{
"Expression": "(user_get_super|freeze_super|thaw_super|iterate_supers_sync|iterate_supers_type)\\(",
"PathPrefixes": [
"fs/",
"include/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 250 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (17 files in total):\nfs/btrfs/ioctl.c:2\nfs/ext4/super.c:1\nfs/f2fs/gc.c:3\nfs/f2fs/super.c:1\nfs/gfs2/super.c:5\nfs/gfs2/sys.c:2\nfs/internal.h:2\nfs/ioctl.c:4\nfs/quota/quota.c:1\nfs/smb/client/misc.c:2\nfs/statfs.c:1\nfs/super.c:16\nfs/sync.c:7\nfs/xfs/scrub/fscounters.c:2\nfs/xfs/xfs_notify_failure.c:3\ninclude/linux/fs.h:1\ninclude/linux/fs/super.h:2\n\nfs/btrfs/ioctl.c=5151=static int btrfs_ioctl_shutdown(struct btrfs_fs_info *fs_info, unsigned long arg)\n--\nfs/btrfs/ioctl.c-5170-\tcase BTRFS_SHUTDOWN_FLAGS_DEFAULT:\nfs/btrfs/ioctl.c:5171:\t\tret = freeze_super(fs_info-\u003esb, FREEZE_HOLDER_KERNEL, NULL);\nfs/btrfs/ioctl.c-5172-\t\tif (ret)\n--\nfs/btrfs/ioctl.c-5174-\t\tbtrfs_force_shutdown(fs_info);\nfs/btrfs/ioctl.c:5175:\t\tret = thaw_super(fs_info-\u003esb, FREEZE_HOLDER_KERNEL, NULL);\nfs/btrfs/ioctl.c-5176-\t\tif (ret)\n--\nfs/ext4/super.c=696=static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,\n--\nfs/ext4/super.c-744-\t * semaphore and setting it without proper remount procedure is\nfs/ext4/super.c:745:\t * confusing code such as freeze_super() leading to deadlocks\nfs/ext4/super.c-746-\t * and other problems.\n--\nfs/f2fs/gc.c=2352=int f2fs_resize_fs(struct file *filp, __u64 block_count)\n--\nfs/f2fs/gc.c-2430-\nfs/f2fs/gc.c:2431:\terr = freeze_super(sbi-\u003esb, FREEZE_HOLDER_KERNEL, NULL);\nfs/f2fs/gc.c-2432-\tif (err)\n--\nfs/f2fs/gc.c-2435-\tif (f2fs_readonly(sbi-\u003esb)) {\nfs/f2fs/gc.c:2436:\t\terr = thaw_super(sbi-\u003esb, FREEZE_HOLDER_KERNEL, NULL);\nfs/f2fs/gc.c-2437-\t\tif (err)\n--\nfs/f2fs/gc.c-2495-\tf2fs_up_write_trace(\u0026sbi-\u003egc_lock, \u0026glc);\nfs/f2fs/gc.c:2496:\tthaw_super(sbi-\u003esb, FREEZE_HOLDER_KERNEL, NULL);\nfs/f2fs/gc.c-2497-\treturn err;\n--\nfs/f2fs/super.c=4758=static void f2fs_handle_critical_error(struct f2fs_sb_info *sbi,\n--\nfs/f2fs/super.c-4811-\t * via remount procedure, otherwise, it will confuse code like\nfs/f2fs/super.c:4812:\t * freeze_super() which will lead to deadlocks and other problems.\nfs/f2fs/super.c-4813-\t */\n--\nfs/gfs2/super.c=671=static int gfs2_do_thaw(struct gfs2_sbd *sdp, enum freeze_holder who, const void *freeze_owner)\n--\nfs/gfs2/super.c-678-\t\tgoto fail;\nfs/gfs2/super.c:679:\terror = thaw_super(sb, who, freeze_owner);\nfs/gfs2/super.c-680-\tif (!error)\n--\nfs/gfs2/super.c=689=void gfs2_freeze_func(struct work_struct *work)\n--\nfs/gfs2/super.c-699-\nfs/gfs2/super.c:700:\terror = freeze_super(sb, FREEZE_HOLDER_USERSPACE, NULL);\nfs/gfs2/super.c-701-\tif (error)\n--\nfs/gfs2/super.c-729-\nfs/gfs2/super.c:730:static int gfs2_freeze_super(struct super_block *sb, enum freeze_holder who,\nfs/gfs2/super.c-731-\t\t\t const void *freeze_owner)\n--\nfs/gfs2/super.c-743-\tfor (;;) {\nfs/gfs2/super.c:744:\t\terror = freeze_super(sb, who, freeze_owner);\nfs/gfs2/super.c-745-\t\tif (error) {\n--\nfs/gfs2/super.c=778=static int gfs2_freeze_fs(struct super_block *sb)\n--\nfs/gfs2/super.c-798-\nfs/gfs2/super.c:799:static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who,\nfs/gfs2/super.c-800-\t\t\t const void *freeze_owner)\n--\nfs/gfs2/sys.c=154=static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\n--\nfs/gfs2/sys.c-166-\tcase 0:\nfs/gfs2/sys.c:167:\t\terror = thaw_super(sdp-\u003esd_vfs, FREEZE_HOLDER_USERSPACE, NULL);\nfs/gfs2/sys.c-168-\t\tbreak;\nfs/gfs2/sys.c-169-\tcase 1:\nfs/gfs2/sys.c:170:\t\terror = freeze_super(sdp-\u003esd_vfs, FREEZE_HOLDER_USERSPACE, NULL);\nfs/gfs2/sys.c-171-\t\tbreak;\n--\nfs/internal.h=137=extern bool super_trylock_shared(struct super_block *sb);\nfs/internal.h:138:struct super_block *user_get_super(dev_t, bool excl);\nfs/internal.h-139-void put_super(struct super_block *sb);\nfs/internal.h=140=void iterate_supers_born(void (*f)(struct super_block *, void *), void *arg);\nfs/internal.h:141:int iterate_supers_sync(void (*f)(struct super_block *, void *), void *arg);\nfs/internal.h-142-extern bool mount_capable(struct fs_context *);\n--\nfs/ioctl.c=385=static int ioctl_fsfreeze(struct file *filp)\n--\nfs/ioctl.c-397-\tif (sb-\u003es_op-\u003efreeze_super)\nfs/ioctl.c:398:\t\treturn sb-\u003es_op-\u003efreeze_super(sb, FREEZE_HOLDER_USERSPACE, NULL);\nfs/ioctl.c:399:\treturn freeze_super(sb, FREEZE_HOLDER_USERSPACE, NULL);\nfs/ioctl.c-400-}\n--\nfs/ioctl.c=402=static int ioctl_fsthaw(struct file *filp)\n--\nfs/ioctl.c-410-\tif (sb-\u003es_op-\u003ethaw_super)\nfs/ioctl.c:411:\t\treturn sb-\u003es_op-\u003ethaw_super(sb, FREEZE_HOLDER_USERSPACE, NULL);\nfs/ioctl.c:412:\treturn thaw_super(sb, FREEZE_HOLDER_USERSPACE, NULL);\nfs/ioctl.c-413-}\n--\nfs/quota/quota.c=866=static struct super_block *quotactl_block(const char __user *special, int cmd)\n--\nfs/quota/quota.c-888-retry:\nfs/quota/quota.c:889:\tsb = user_get_super(dev, excl);\nfs/quota/quota.c-890-\tif (!sb)\n--\nfs/smb/client/misc.c=884=static void tcon_super_cb(struct super_block *sb, void *arg)\n--\nfs/smb/client/misc.c-902-\t\t/*\nfs/smb/client/misc.c:903:\t\t * Take the active reference while iterate_supers_type() still\nfs/smb/client/misc.c-904-\t\t * holds s_umount shared.\n--\nfs/smb/client/misc.c=912=static struct super_block *__cifs_get_super(void (*f)(struct super_block *, void *),\n--\nfs/smb/client/misc.c-923-\tfor (; *fs_type; fs_type++) {\nfs/smb/client/misc.c:924:\t\titerate_supers_type(*fs_type, f, \u0026sd);\nfs/smb/client/misc.c-925-\t\tif (sd.sb)\n--\nfs/statfs.c=235=static int vfs_ustat(dev_t dev, struct kstatfs *sbuf)\nfs/statfs.c-236-{\nfs/statfs.c:237:\tstruct super_block *s = user_get_super(dev, false);\nfs/statfs.c-238-\tint err;\n--\nfs/super.c=1102=void iterate_supers_born(void (*f)(struct super_block *, void *), void *arg)\n--\nfs/super.c-1121- */\nfs/super.c:1122:int iterate_supers_sync(void (*f)(struct super_block *, void *), void *arg)\nfs/super.c-1123-{\n--\nfs/super.c-1136- */\nfs/super.c:1137:void iterate_supers_type(struct file_system_type *type,\nfs/super.c-1138-\tvoid (*f)(struct super_block *, void *), void *arg)\n--\nfs/super.c=1165=EXPORT_SYMBOL(iterate_supers_type);\nfs/super.c-1166-\nfs/super.c:1167:struct super_block *user_get_super(dev_t dev, bool excl)\nfs/super.c-1168-{\n--\nfs/super.c=1389=static void filesystems_freeze_callback(struct super_block *sb, void *freeze_all_ptr)\n--\nfs/super.c-1401-\tif (sb-\u003es_op-\u003efreeze_super)\nfs/super.c:1402:\t\tsb-\u003es_op-\u003efreeze_super(sb, FREEZE_EXCL | FREEZE_HOLDER_KERNEL,\nfs/super.c-1403-\t\t\t\t filesystems_freeze_ptr);\nfs/super.c-1404-\telse\nfs/super.c:1405:\t\tfreeze_super(sb, FREEZE_EXCL | FREEZE_HOLDER_KERNEL,\nfs/super.c-1406-\t\t\t filesystems_freeze_ptr);\n--\nfs/super.c=1421=static void filesystems_thaw_callback(struct super_block *sb, void *unused)\n--\nfs/super.c-1429-\tif (sb-\u003es_op-\u003ethaw_super)\nfs/super.c:1430:\t\tsb-\u003es_op-\u003ethaw_super(sb, FREEZE_EXCL | FREEZE_HOLDER_KERNEL,\nfs/super.c-1431-\t\t\t\t filesystems_freeze_ptr);\nfs/super.c-1432-\telse\nfs/super.c:1433:\t\tthaw_super(sb, FREEZE_EXCL | FREEZE_HOLDER_KERNEL,\nfs/super.c-1434-\t\t\t filesystems_freeze_ptr);\n--\nfs/super.c=1624=static int fs_super_freeze(struct super_block *sb)\n--\nfs/super.c-1626-\tif (sb-\u003es_op-\u003efreeze_super)\nfs/super.c:1627:\t\treturn sb-\u003es_op-\u003efreeze_super(sb,\nfs/super.c-1628-\t\t\t\tFREEZE_MAY_NEST | FREEZE_HOLDER_USERSPACE, NULL);\nfs/super.c:1629:\treturn freeze_super(sb, FREEZE_MAY_NEST | FREEZE_HOLDER_USERSPACE, NULL);\nfs/super.c-1630-}\n--\nfs/super.c=1632=static int fs_super_thaw(struct super_block *sb)\n--\nfs/super.c-1636-\tif (sb-\u003es_op-\u003ethaw_super) {\nfs/super.c:1637:\t\terror = sb-\u003es_op-\u003ethaw_super(sb,\nfs/super.c-1638-\t\t\t\tFREEZE_MAY_NEST | FREEZE_HOLDER_USERSPACE, NULL);\n--\nfs/super.c=1723=static int fs_bdev_freeze(struct block_device *bdev)\n--\nfs/super.c-1747-\t * of them failed to freeze and swallow the error: rolling the rest back\nfs/super.c:1748:\t * via thaw_super() can fail too, so neither is a clear win. A single\nfs/super.c-1749-\t * filesystem (count == 1) still reports its error.\n--\nfs/super.c=2254=static void sb_wait_write(struct super_block *sb, int level)\n--\nfs/super.c-2260- * We are going to return to userspace and forget about these locks, the\nfs/super.c:2261: * ownership goes to the caller of thaw_super() which does unlock().\nfs/super.c-2262- */\n--\nfs/super.c=2377=static inline bool may_unfreeze(struct super_block *sb, enum freeze_holder who,\n--\nfs/super.c-2483- */\nfs/super.c:2484:int freeze_super(struct super_block *sb, enum freeze_holder who, const void *freeze_owner)\nfs/super.c-2485-{\n--\nfs/super.c-2562-\t * For debugging purposes so that fs can warn if it sees write activity\nfs/super.c:2563:\t * when frozen is set to SB_FREEZE_COMPLETE, and for thaw_super().\nfs/super.c-2564-\t */\n--\nfs/super.c=2581=static int thaw_super_locked(struct super_block *sb, enum freeze_holder who,\n--\nfs/super.c-2639- *\nfs/super.c:2640: * Unlocks the filesystem and marks it writeable again after freeze_super()\nfs/super.c-2641- * if there are no remaining freezes on the filesystem.\n--\nfs/super.c-2651- */\nfs/super.c:2652:int thaw_super(struct super_block *sb, enum freeze_holder who,\nfs/super.c-2653-\t const void *freeze_owner)\n--\nfs/sync.c=97=void ksys_sync(void)\n--\nfs/sync.c-101-\twakeup_flusher_threads(WB_REASON_SYNC);\nfs/sync.c:102:\tif (iterate_supers_sync(sync_inodes_one_sb, NULL) ||\nfs/sync.c:103:\t iterate_supers_sync(sync_fs_one_sb, \u0026nowait) ||\nfs/sync.c:104:\t iterate_supers_sync(sync_fs_one_sb, \u0026wait))\n\n"
} |
| 7/2 | 2026/10/23 22:32 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18658 output: 27 thoughts: 144 Thoughts: Okay, let's see, I'm tracing the callers of `super_lock` and related superblock functions. This is interesting. **Tracing Superblock Locking in the Kernel** Alright, I see that `iterate_supers_sync` is directly linked to `ksys_sync`, which of course maps to the `sync(2)` syscall. Makes sense – syncing the filesystem needs to interact with the superblocks. Now, `freeze_super` and `thaw_super` get called from `ioctl_fsfreeze` and `ioctl_fsthaw`, which in turn are called by the `ioctl` commands `FIFREEZE` and `FITHAW`. That's the freezing and thawing mechanism, which, of course, needs to touch the superblock. Then there's `user_get_super`, which is being called by `quotactl` and `ustat`. So quota and filesystem statistics are clearly interacting with the superblock, again, makes total sense. And at the center of all this is `super_lock` itself – the fundamental function implementing superblock locking that seems to be orchestrating access to the superblock. Now, let me see, what else calls `super_lock` or any of the other functions I've been tracing? Let's check `grab_super` because that's another important function related to the superblock. |
| 8/2 | 2026/10/23 22:32 | tool | grepper |
0mArgs:{
"Expression": "grab_super\\(",
"PathPrefixes": [
"fs/"
]
}Results: {
"Output": "fs/super.c=687=EXPORT_SYMBOL(deactivate_super);\n--\nfs/super.c-701- */\nfs/super.c:702:static int grab_super(struct super_block *sb)\nfs/super.c-703-{\n--\nfs/super.c=911=struct super_block *sget_fc(struct fs_context *fc,\n--\nfs/super.c-988-\t}\nfs/super.c:989:\terr = grab_super(old);\nfs/super.c-990-\tif (err == -EAGAIN)\n"
} |
| 9/2 | 2026/10/23 22:32 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19279 output: 34 thoughts: 4477 Thoughts: **Analyzing Superblock Locking Changes** Okay, here's what I've pieced together from this patch. It looks like we've got a significant overhaul of the superblock locking mechanisms, and the implications are broad, impacting how we handle device state changes, filesystem mounting, and unmounting, and syncing. It appears that the original code utilized a simple boolean return for the lock function which had the issues associated with it. First, the core change is the introduction of `enum super_lock_flags_t` to manage lock behavior. This offers more fine-grained control with flags like `SUPER_LOCK_EXCL`, `SUPER_LOCK_KILLABLE`, and `SUPER_LOCK_WAIT_SHUTDOWN`. The original `__super_lock` is now inline, and the new `super_lock` function takes these flags, handles waiting for superblock readiness, and integrates the shutdown wait logic directly. It appears there was code duplication between callers who wanted to wait for shutdown and those who did not. All of that is handled with this enum and the use of conditional checks. The lock structure now includes a `lock` member which is a `struct semaphore`. This replaces the previous bool which lead to a loss of functionality. The old system had a dedicated `super_lock_common` that was used to handle the different cases. This has been replaced with the new enum flags. Now, instead of callers manually calling `super_wait_shutdown_killable()`, `super_lock` uses the `SUPER_LOCK_WAIT_SHUTDOWN` flag to call `super_wait(sb, SB_DYING, state)` directly. This cleans up the code, but there are potentially more state changes to be handled. The `__DEFINE_UNLOCK_GUARD` and `__DEFINE_CLASS_IS_CONDITIONAL` macros are interesting. They provide a mechanism for automatically unlocking the superblock when a scoped object goes out of scope, improving code safety. These appear to have been added to improve code safety in regards to unlock operations. The `__iterate_supers` function, which iterates over superblocks, now leverages this guarded locking. It uses `ACQUIRE` and `ACQUIRE_ERR` which are macros. The interesting bit is how the loop handles `-ENOENT` return values. A non-zero `ret` from `super_lock` now breaks out of the loop and handles the error and cases as intended. `fs_bdev_mark_dead`, `fs_bdev_sync`, `freeze_super`, `thaw_super`, and `do_emergency_remount_callback` are all updated to leverage the new lock functionality and error handling. `fs_bdev_sync` uses the killable lock and shutdown wait. `freeze_super` and `thaw_super` now directly return error codes from `super_lock`. In `do_emergency_remount_callback`, `scoped_cond_guard` is used, which ensures the active reference to the superblock is properly handled alongside the locking. It seems the code has been refactored in order to handle the different cases and also to ensure the code is safer. Overall, it seems the changes are aimed at making the locking more robust and easier to use. By incorporating the shutdown wait logic and providing more explicit error handling, we should see fewer issues with race conditions and deadlocks. The guarded unlocking with `scoped_cond_guard` and the improved `ACQUIRE` macros are definitely steps in the right direction. It looks like the original implementation had issues that the refactor has addressed. |
| 10/2 | 2026/10/23 22:32 | tool | read-file |
0mArgs:{
"File": "fs/super.c",
"FirstLine": 1290,
"LineCount": 40
}Results: {
"Contents": "1290:\tcancel_readonly:\n1291:\t\tsb_end_ro_state_change(sb);\n1292:\t\treturn retval;\n1293:\t}\n1294:\t\n1295:\tstatic void do_emergency_remount_callback(struct super_block *sb, void *unused)\n1296:\t{\n1297:\t\tstruct fs_context *fc = NULL;\n1298:\t\n1299:\t\t/* the unmount writes the filesystem out, wait for that */\n1300:\t\tscoped_cond_guard(super_lock, return, sb,\n1301:\t\t\t\t SUPER_LOCK_EXCL | SUPER_LOCK_WAIT_SHUTDOWN) {\n1302:\t\t\t/* Make sure no reference put under s_umount is the last one. */\n1303:\t\t\tatomic_inc(\u0026sb-\u003es_active);\n1304:\t\t\tif (sb-\u003es_bdev \u0026\u0026 !sb_rdonly(sb)) {\n1305:\t\t\t\tfc = fs_context_for_reconfigure(sb-\u003es_root,\n1306:\t\t\t\t\t\t\tSB_RDONLY | SB_FORCE, SB_RDONLY);\n1307:\t\t\t\tif (!IS_ERR(fc) \u0026\u0026\n1308:\t\t\t\t parse_monolithic_mount_data(fc, NULL) == 0)\n1309:\t\t\t\t\t(void)reconfigure_super(fc);\n1310:\t\t\t}\n1311:\t\t}\n1312:\t\n1313:\t\t/*\n1314:\t\t * Our active reference may be the last one by now, so only drop it\n1315:\t\t * after s_umount has been released.\n1316:\t\t */\n1317:\t\tif (!IS_ERR_OR_NULL(fc))\n1318:\t\t\tput_fs_context(fc);\n1319:\t\tdeactivate_super(sb);\n1320:\t}\n1321:\t\n1322:\tstatic void do_emergency_remount(struct work_struct *work)\n1323:\t{\n1324:\t\t__iterate_supers(do_emergency_remount_callback, NULL,\n1325:\t\t\t\t SUPER_ITER_UNLOCKED | SUPER_ITER_REVERSE);\n1326:\t\tkfree(work);\n1327:\t\tprintk(\"Emergency Remount complete\\n\");\n1328:\t}\n1329:\t\n"
} |
| 11/2 | 2026/10/23 22:32 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25168 output: 32 thoughts: 470 Thoughts: **Analyzing `fs_bdev_sync` and Superblock Locking** Okay, let's dive into this `fs_bdev_sync` function. My initial impression is...hold on, there's been a change! Let me make sure I understand the modifications, and where we're at now. So, the code iterates through superblocks using `for_each_dev_super_killable(sb, &cursor)`. The key difference I'm seeing is the direct call to `ACQUIRE(super_lock, lock)`. Previously, we had explicit calls to `super_lock_killable`, `super_unlock_shared` and a call to `super_wait_shutdown_killable`. This change is trying to simplify the locking structure. Hmm, I see an `ACQUIRE_ERR` call. This indicates there's error checking related to the locking mechanism right after the attempt to acquire. If we encounter `-ENOENT`, we just `continue` to the next superblock – that makes sense, as the superblock probably no longer exists. If a general error occurs, we clean up and return. Now, if the lock acquisition is successful, *then* the filesystem sync is performed via `sync_filesystem(sb)`. The bit that's getting my attention, however, is where the lock is *released*. It seems implicit! I need to confirm this. Ah, it's released at the end of the `for` loop scope. That's a subtle but important point that's good to keep in mind, and verify if everything is cleaned up if we encounter an error. But now I'm curious about the specific operation performed by `for_each_dev_super_killable`. I'll need to check the definition of that macro or function to fully understand the superblock iteration process and how this locking interacts with it. |
| 12/2 | 2026/10/23 22:32 | tool | grepper |
0mArgs:{
"Expression": "#define for_each_dev_super",
"PathPrefixes": [
"fs/"
]
}Results: {
"Output": "fs/super.c=562=static struct super_block *super_dev_next(struct super_dev *cursor,\n--\nfs/super.c-607-\nfs/super.c:608:#define for_each_dev_super(sb, cursor) \\\nfs/super.c-609-\t__for_each_dev_super(sb, cursor, TASK_UNINTERRUPTIBLE)\n--\nfs/super.c-611-/* Stop the walk on a fatal signal. */\nfs/super.c:612:#define for_each_dev_super_killable(sb, cursor) \\\nfs/super.c-613-\t__for_each_dev_super(sb, cursor, TASK_KILLABLE)\n"
} |
| 13/2 | 2026/10/23 22:32 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26258 output: 33 thoughts: 21 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Diving into `fs/super.c`** Okay, time to get my hands dirty. I'm going to zero in on lines 600 through 640 of `fs/super.c`. That's where I *expect* to find the core of whatever mechanism is responsible for \[*user would fill in based on their knowledge of the context; e.g., superblock initialization, mount option parsing, filesystem type detection, etc.*]. My gut tells me that specific section likely handles the \[*specific functionality*], but the exact implementation details, especially corner cases, are what I'm interested in drilling into. I’ll be looking for any hints about potential race conditions or locking issues at this stage. I'll need to pay close attention to the data structures being used here and how they interact with other parts of the super block lifecycle. I'm also keeping an eye out for any calls to potentially problematic functions, like those related to memory allocation, or interaction with underlying storage devices. I'm expecting to see calls related to \[*specific kernel API calls or structures*], and I'm keen to see if any of my earlier assumptions are correct based on the code's behavior. |
| 14/2 | 2026/10/23 22:33 | tool | read-file |
0mArgs:{
"File": "fs/super.c",
"FirstLine": 600,
"LineCount": 40
}Results: {
"Contents": " 600:\t\t\t}\n 601:\t\t}\n 602:\t}\n 603:\t\n 604:\t#define __for_each_dev_super(sb, cursor, state)\t\t\t\\\n 605:\t\tfor (sb = super_dev_next(cursor, NULL, state); sb;\t\t\\\n 606:\t\t sb = super_dev_next(cursor, sb, state))\n 607:\t\n 608:\t#define for_each_dev_super(sb, cursor) \\\n 609:\t\t__for_each_dev_super(sb, cursor, TASK_UNINTERRUPTIBLE)\n 610:\t\n 611:\t/* Stop the walk on a fatal signal. */\n 612:\t#define for_each_dev_super_killable(sb, cursor) \\\n 613:\t\t__for_each_dev_super(sb, cursor, TASK_KILLABLE)\n 614:\t\n 615:\tstatic void kill_super_notify(struct super_block *sb)\n 616:\t{\n 617:\t\tlockdep_assert_not_held(\u0026sb-\u003es_umount);\n 618:\t\n 619:\t\t/* already notified earlier */\n 620:\t\tif (sb-\u003es_flags \u0026 SB_DEAD)\n 621:\t\t\treturn;\n 622:\t\n 623:\t\t/* Drop sget_fc()'s claim on s_dev. */\n 624:\t\tsuper_dev_put(\u0026sb-\u003es_super_dev);\n 625:\t\n 626:\t\t/*\n 627:\t\t * Let concurrent mounts know that this thing is really dead.\n 628:\t\t * sget_fc() skips SB_DEAD superblocks and calls test() under\n 629:\t\t * sb_lock, so set it under sb_lock: once we return no test()\n 630:\t\t * runs on this superblock anymore and none will start. Everyone\n 631:\t\t * else already saw SB_DYING and either discarded the superblock\n 632:\t\t * or waits for SB_DEAD.\n 633:\t\t */\n 634:\t\tspin_lock(\u0026sb_lock);\n 635:\t\tsuper_wake(sb, SB_DEAD);\n 636:\t\tspin_unlock(\u0026sb_lock);\n 637:\t}\n 638:\t\n 639:\t/**\n"
} |
| 15/2 | 2026/10/23 22:33 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27207 output: 34 thoughts: 1333 Thoughts: **Analyzing the Superblock Locking and `fs_bdev_sync`** Okay, let's break this down. I'm looking at `super_dev_next` and specifically the locking within `for_each_dev_super_killable`. The previous version used a more explicit locking scheme with `super_lock_killable` and `super_unlock_shared`, but this new code utilizes `ACQUIRE(super_lock, lock)`. The intent is to acquire a killable lock, potentially waiting for shutdown. The cleanup function on `lock` looks like `super_unlock_guard`. My primary concern is the interaction between error handling, the lock, and `sync_filesystem`. If `ret` is an error, the code path immediately bails out after the `lock` cleanup. However, if the error is `-ENOENT`, the code *continues* to the next iteration. Crucially, even with `-ENOENT`, the destructor for `lock` still runs, and the lock is *not* acquired. The crucial change, it seems, is `sync_filesystem(sb)` now executes *within* the scope of the `super_lock`. In the old code, `super_lock_killable` was used, `sync_filesystem` was called, and *then* the lock was released. So now it is within. The critical piece here is what happens when the superblock is dying and `super_lock` enters the `dying` block, where it waits for `SB_DYING`. During this wait, it can return `-ENOENT`. The new code handles this `-ENOENT` return by *continuing* to the next iteration of the loop, which means the lock is never acquired! If interrupted during `super_wait`, it could return `-ERESTARTSYS` or similar, which would cause an early exit from the loop (which is correct), but `-ENOENT` is handled in a completely different way, by continuing to the next iteration! The crucial question is, if `ret` is 0, the code proceeds to `sync_filesystem(sb)`, which is now *inside* the locked region and then the lock is released at the block exit. So `sync_filesystem(sb)` is now holding the read lock on `s_umount`. This also means that `-ENOENT` is an edge case to be carefully considered. It's used in the code where the lock is *not* acquired, but it proceeds on to `sync_filesystem`. The new code *correctly* calls `sync_filesystem` under the read lock if `ret == 0` (no error). So I need to check what calls `fs_bdev_sync` itself. That is the next step here. |
| 16/2 | 2026/10/23 22:33 | tool | grepper |
0mArgs:{
"Expression": "fs_bdev_sync",
"PathPrefixes": [
"fs/",
"block/"
]
}Results: {
"Output": "fs/super.c=1659=static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)\n--\nfs/super.c-1685-\nfs/super.c:1686:static void fs_bdev_sync(struct block_device *bdev)\nfs/super.c-1687-{\n--\nfs/super.c=1806=static const struct blk_holder_ops fs_holder_ops = {\nfs/super.c-1807-\t.mark_dead\t\t= fs_bdev_mark_dead,\nfs/super.c:1808:\t.sync\t\t\t= fs_bdev_sync,\nfs/super.c-1809-\t.freeze\t\t\t= fs_bdev_freeze,\n"
} |
| 17/2 | 2026/10/23 22:33 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29365 output: 26 thoughts: 2925 Thoughts: **Analysis of Block Device Holder Callbacks and Superblock Locking Refactoring** Alright, let's break this down. My understanding of the system is that `fs_holder_ops` are the key callbacks for block devices: they signal critical events like sync, freeze, thaw, and device death. This patch, based on the `git log -1` and the diff, is touching the superblock locking, which is a core part of the VFS, specifically in `fs/super.c`. The changes are significant; it's a deep dive into how superblocks are locked, unlocked, and handled during shutdown scenarios. The refactoring consolidates multiple lock functions (`super_lock_killable`, `super_wait_shutdown`, etc.) into a single, flag-driven `super_lock` function. It then introduces RAII-style guards for superblock locking, which means using `scoped_guard`, `scoped_cond_guard`, and `ACQUIRE`, something that could easily introduce a new issue. Plus, the patch also modifies error handling with return value changes for `super_lock` and adds new assertions. My assessment of the patch, based on this, is that it directly touches reachable executable code in a core subsystem. The modifications in `fs/super.c` (VFS, synchronization/locking) are key. The refactoring includes: restructuring data structures, introducing helper abstractions, and altering algorithm flows. Critically, there are new assertions, specifically related to the superblock's state (`SB_BORN`, `s_umount`). Because this is critical code, and because of the nature of the changes, this patch *must* be fuzzed. `WorthFuzzing = true`. Now, let's identify the *right* focus symbols. We need to focus on functions that directly implement the logic being altered, or are the entrypoints to specific features. The modified code touches `fs/super.c`. Here's my focus: * `super_lock`: This is the *central* function being refactored. I need to make sure this symbol is accessible and not inlined (confirmed: it is a static function, not static inline, and can be easily targeted). I'll also want to look at callers of `super_lock`. * `freeze_super`: I want to focus on this, and `thaw_super`. These functions are directly related to filesystem freezing and thawing, triggered by `FIFREEZE/FITHAW` ioctls and emergency thaw. * `user_get_super`: This is called when using quotactl or ustat with a dev_t, which are interesting system calls to focus on. * `iterate_supers_sync`: This function is called on the system call `sync`, which is interesting to focus on. * `grab_super`: Relevant when mounting a filesystem that may already exist and matching superblocks. * `fs_bdev_sync`: Block device holder callback for sync. * `fs_bdev_freeze`: Block device holder callback for freeze. * `fs_bdev_thaw`: Block device holder callback for thaw. These symbols are not ubiquitous; they're very specific to filesystem operations, which is exactly what we want. They offer clear entry points for testing the changes. The goal is to focus on specific entry points, and changed functions, to maximize our fuzzing efficiency! |
| 18/2 | 2026/10/23 22:33 | tool | grepper |
0mArgs:{
"Expression": "super\\.o",
"PathPrefixes": [
"fs/"
]
}Results: {
"Output": "fs/9p/Makefile=2=obj-$(CONFIG_9P_FS) := 9p.o\n--\nfs/9p/Makefile-4-9p-objs := \\\nfs/9p/Makefile:5:\tvfs_super.o \\\nfs/9p/Makefile-6-\tvfs_inode.o \\\n--\nfs/Makefile-9-\nfs/Makefile:10:obj-y :=\topen.o read_write.o file_table.o super.o \\\nfs/Makefile-11-\t\tchar_dev.o stat.o exec.o pipe.o namei.o fcntl.o \\\n--\nfs/adfs/Makefile=6=obj-$(CONFIG_ADFS_FS) += adfs.o\nfs/adfs/Makefile-7-\nfs/adfs/Makefile:8:adfs-objs := dir.o dir_f.o dir_fplus.o file.o inode.o map.o super.o\n--\nfs/affs/Makefile=8=obj-$(CONFIG_AFFS_FS) += affs.o\nfs/affs/Makefile-9-\nfs/affs/Makefile:10:affs-objs := super.o namei.o inode.o file.o dir.o amigaffs.o bitmap.o symlink.o\n--\nfs/afs/Makefile=6=kafs-y := \\\n--\nfs/afs/Makefile-31-\tserver_list.o \\\nfs/afs/Makefile:32:\tsuper.o \\\nfs/afs/Makefile-33-\tsymlink.o \\\n--\nfs/befs/Makefile=7=ccflags-$(CONFIG_BEFS_DEBUG) += -DDEBUG\nfs/befs/Makefile:8:befs-objs := datastream.o btree.o super.o inode.o debug.o io.o linuxvfs.o\n--\nfs/btrfs/Makefile=22=obj-$(CONFIG_BTRFS_FS) := btrfs.o\nfs/btrfs/Makefile-23-\nfs/btrfs/Makefile:24:btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \\\nfs/btrfs/Makefile-25-\t file-item.o inode-item.o disk-io.o \\\n--\nfs/ceph/Makefile=6=obj-$(CONFIG_CEPH_FS) += ceph.o\nfs/ceph/Makefile-7-\nfs/ceph/Makefile:8:ceph-y := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \\\nfs/ceph/Makefile-9-\texport.o caps.o snap.o xattr.o quota.o io.o \\\n--\nfs/ecryptfs/Makefile=6=obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o\nfs/ecryptfs/Makefile-7-\nfs/ecryptfs/Makefile:8:ecryptfs-y := dentry.o file.o inode.o main.o super.o mmap.o read_write.o \\\nfs/ecryptfs/Makefile-9-\t crypto.o keystore.o kthread.o debug.o\n--\nfs/efivarfs/Makefile=6=obj-$(CONFIG_EFIVAR_FS)\t\t+= efivarfs.o\nfs/efivarfs/Makefile-7-\nfs/efivarfs/Makefile:8:efivarfs-objs\t\t\t:= inode.o file.o super.o vars.o\n--\nfs/erofs/Makefile=3=obj-$(CONFIG_EROFS_FS) += erofs.o\nfs/erofs/Makefile:4:erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o\nfs/erofs/Makefile-5-erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o\n--\nfs/exfat/Makefile=5=obj-$(CONFIG_EXFAT_FS) += exfat.o\nfs/exfat/Makefile-6-\nfs/exfat/Makefile:7:exfat-y\t:= inode.o namei.o dir.o super.o fatent.o cache.o nls.o misc.o \\\nfs/exfat/Makefile-8-\t file.o balloc.o iomap.o\n--\nfs/ext2/Makefile=10=ext2-y := balloc.o dir.o file.o ialloc.o inode.o \\\nfs/ext2/Makefile:11:\t ioctl.o namei.o super.o symlink.o trace.o\nfs/ext2/Makefile-12-\n--\nfs/ext4/Makefile=8=ext4-y\t:= balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \\\n--\nfs/ext4/Makefile-11-\t\tmmp.o move_extent.o namei.o page-io.o readpage.o resize.o \\\nfs/ext4/Makefile:12:\t\tsuper.o symlink.o sysfs.o xattr.o xattr_hurd.o xattr_trusted.o \\\nfs/ext4/Makefile-13-\t\txattr_user.o fast_commit.o orphan.o\n--\nfs/f2fs/Makefile=2=obj-$(CONFIG_F2FS_FS) += f2fs.o\nfs/f2fs/Makefile-3-\nfs/f2fs/Makefile:4:f2fs-y\t\t:= dir.o file.o inode.o namei.o hash.o super.o inline.o\nfs/f2fs/Makefile-5-f2fs-y\t\t+= checkpoint.o gc.o data.o node.o segment.o recovery.o\n--\nfs/gfs2/Makefile=4=gfs2-y := acl.o bmap.o dir.o xattr.o glock.o \\\n--\nfs/gfs2/Makefile-7-\tops_fstype.o inode.o quota.o \\\nfs/gfs2/Makefile:8:\trecovery.o rgrp.o super.o sys.o trans.o util.o\nfs/gfs2/Makefile-9-\n--\nfs/hfs/Makefile=8=hfs-objs := bitmap.o bfind.o bnode.o brec.o btree.o \\\nfs/hfs/Makefile-9-\t catalog.o dir.o extent.o inode.o attr.o mdb.o \\\nfs/hfs/Makefile:10: part_tbl.o string.o super.o sysdep.o trans.o\nfs/hfs/Makefile-11-\n--\nfs/hfsplus/Makefile=6=obj-$(CONFIG_HFSPLUS_FS) += hfsplus.o\nfs/hfsplus/Makefile-7-\nfs/hfsplus/Makefile:8:hfsplus-objs := super.o options.o inode.o ioctl.o extents.o catalog.o dir.o btree.o \\\nfs/hfsplus/Makefile-9-\t\tbnode.o brec.o bfind.o tables.o unicode.o wrapper.o bitmap.o part_tbl.o \\\n--\nfs/hpfs/Makefile=8=hpfs-objs := alloc.o anode.o buffer.o dentry.o dir.o dnode.o ea.o file.o \\\nfs/hpfs/Makefile:9:\t inode.o map.o name.o namei.o super.o\n--\nfs/jffs2/Makefile=11=jffs2-y\t+= symlink.o build.o erase.o background.o fs.o writev.o\nfs/jffs2/Makefile:12:jffs2-y\t+= super.o debug.o\nfs/jffs2/Makefile-13-\n--\nfs/jfs/Makefile=6=obj-$(CONFIG_JFS_FS) += jfs.o\nfs/jfs/Makefile-7-\nfs/jfs/Makefile:8:jfs-y := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \\\nfs/jfs/Makefile-9-\t jfs_xtree.o jfs_imap.o jfs_debug.o jfs_dmap.o \\\n--\nfs/nfs/Makefile=8=CFLAGS_nfstrace.o += -I$(src)\nfs/nfs/Makefile:9:nfs-y \t\t\t:= client.o dir.o file.o getroot.o inode.o super.o \\\nfs/nfs/Makefile-10-\t\t\t io.o direct.o pagelist.o read.o symlink.o unlink.o \\\n--\nfs/nfs/Makefile=18=obj-$(CONFIG_NFS_V2) += nfsv2.o\nfs/nfs/Makefile:19:nfsv2-y := nfs2super.o proc.o nfs2xdr.o\nfs/nfs/Makefile-20-\nfs/nfs/Makefile=21=obj-$(CONFIG_NFS_V3) += nfsv3.o\nfs/nfs/Makefile:22:nfsv3-y := nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o\nfs/nfs/Makefile-23-nfsv3-$(CONFIG_NFS_V3_ACL) += nfs3acl.o\n--\nfs/nfs/Makefile=26=CFLAGS_nfs4trace.o += -I$(src)\nfs/nfs/Makefile:27:nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \\\nfs/nfs/Makefile-28-\t delegation.o nfs4idmap.o callback.o callback_xdr.o callback_proc.o \\\n--\nfs/nilfs2/Makefile=2=obj-$(CONFIG_NILFS2_FS) += nilfs2.o\nfs/nilfs2/Makefile:3:nilfs2-y := inode.o file.o dir.o super.o namei.o page.o mdt.o \\\nfs/nilfs2/Makefile-4-\tbtnode.o bmap.o btree.o direct.o dat.o recovery.o \\\n--\nfs/ntfs/Makefile=5=ntfs-y := aops.o attrib.o collate.o dir.o file.o index.o inode.o \\\nfs/ntfs/Makefile:6:\t mft.o mst.o namei.o runlist.o super.o unistr.o attrlist.o ea.o \\\nfs/ntfs/Makefile-7-\t upcase.o bitmap.o lcnalloc.o logfile.o reparse.o compress.o \\\n--\nfs/ntfs3/Makefile=33=ntfs3-y :=\tattrib.o \\\n--\nfs/ntfs3/Makefile-47-\t\trun.o \\\nfs/ntfs3/Makefile:48:\t\tsuper.o \\\nfs/ntfs3/Makefile-49-\t\tupcase.o \\\n--\nfs/ocfs2/Makefile=11=ocfs2-objs := \\\n--\nfs/ocfs2/Makefile-35-\tsuballoc.o \t\t\\\nfs/ocfs2/Makefile:36:\tsuper.o \t\t\\\nfs/ocfs2/Makefile-37-\tsymlink.o \t\t\\\n--\nfs/orangefs/Makefile=8=orangefs-objs := acl.o file.o orangefs-cache.o orangefs-utils.o xattr.o \\\nfs/orangefs/Makefile:9:\t\t dcache.o inode.o orangefs-sysfs.o orangefs-mod.o super.o \\\nfs/orangefs/Makefile-10-\t\t devorangefs-req.o namei.o symlink.o dir.o orangefs-bufmap.o \\\n--\nfs/overlayfs/Makefile=6=obj-$(CONFIG_OVERLAY_FS) += overlay.o\nfs/overlayfs/Makefile-7-\nfs/overlayfs/Makefile:8:overlay-objs := super.o namei.o util.o inode.o file.o dir.o readdir.o \\\nfs/overlayfs/Makefile-9-\t\tcopy_up.o export.o params.o xattrs.o\n--\nfs/romfs/Makefile=6=obj-$(CONFIG_ROMFS_FS) += romfs.o\nfs/romfs/Makefile-7-\nfs/romfs/Makefile:8:romfs-y := storage.o super.o\nfs/romfs/Makefile-9-\n--\nfs/squashfs/Makefile=7=squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o\nfs/squashfs/Makefile:8:squashfs-y += namei.o super.o symlink.o decompressor.o page_actor.o\nfs/squashfs/Makefile-9-squashfs-$(CONFIG_SQUASHFS_FILE_CACHE) += file_cache.o\n--\nfs/ubifs/Makefile=2=obj-$(CONFIG_UBIFS_FS) += ubifs.o\nfs/ubifs/Makefile-3-\nfs/ubifs/Makefile:4:ubifs-y += shrinker.o journal.o file.o dir.o super.o sb.o io.o\nfs/ubifs/Makefile-5-ubifs-y += tnc.o master.o scan.o replay.o log.o commit.o gc.o orphan.o\n--\nfs/udf/Makefile=8=udf-objs := balloc.o dir.o file.o ialloc.o inode.o lowlevel.o namei.o \\\nfs/udf/Makefile:9:\t\tpartition.o super.o truncate.o symlink.o \\\nfs/udf/Makefile-10-\t\tdirectory.o misc.o udftime.o unicode.o\n--\nfs/ufs/Makefile=8=ufs-objs := balloc.o cylinder.o dir.o file.o ialloc.o inode.o \\\nfs/ufs/Makefile:9:\t namei.o super.o util.o\nfs/ufs/Makefile-10-ccflags-$(CONFIG_UFS_DEBUG) += -DDEBUG\n--\nfs/vboxsf/Makefile=3=obj-$(CONFIG_VBOXSF_FS) += vboxsf.o\nfs/vboxsf/Makefile-4-\nfs/vboxsf/Makefile:5:vboxsf-y := dir.o file.o utils.o vboxsf_wrappers.o super.o\n--\nfs/xfs/Makefile=71=xfs-y\t\t\t\t+= xfs_aops.o \\\n--\nfs/xfs/Makefile-105-\t\t\t\t xfs_stats.o \\\nfs/xfs/Makefile:106:\t\t\t\t xfs_super.o \\\nfs/xfs/Makefile-107-\t\t\t\t xfs_symlink.o \\\n--\nfs/xfs/Makefile=203=xfs-$(CONFIG_XFS_RT)\t\t+= $(addprefix scrub/, \\\nfs/xfs/Makefile:204:\t\t\t\t rgsuper.o \\\nfs/xfs/Makefile-205-\t\t\t\t rtbitmap.o \\\n--\nfs/zonefs/Makefile=4=obj-$(CONFIG_ZONEFS_FS) += zonefs.o\nfs/zonefs/Makefile-5-\nfs/zonefs/Makefile:6:zonefs-y\t:= super.o file.o sysfs.o\n"
} |
| 19/2 | 2026/10/23 22:33 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36837 output: 29 thoughts: 449 Thoughts: **Analyzing the Filesystem Superblock Locking Patch** Okay, so I'm looking at this `fs/Makefile` and it's clear `fs/super.c` is compiled into the core kernel because it's in `obj-y`. My immediate concern, as always, is whether any changes introduced by this patch are conditional. Are there any `#ifdef` blocks around the modifications in `fs/super.c`? That's the crucial question. I need to make sure the added locking primitives are always present. I'll check the diff and the file itself for any conditional compilation. Looks like the patch introduces a bunch of new functions and variables: `enum super_lock_flags_t`, `__super_lock`, `super_unlock`, and all these related locking functions, alongside callbacks and device-related functions like `fs_bdev_mark_dead`, `fs_bdev_sync`, and so on. Alright, a quick scan of the diff confirms that none of these new functions and variables are wrapped in any `#ifdef` directives. That's a good sign, because it means they're always compiled in. However, that does NOT guarantee that the changes do not rely on conditional compilation. The only condition I need to check now is, is code related to block devices, like `fs_bdev_*` which are used a lot in this patch, `#ifdef CONFIG_BLOCK` in `fs/super.c`? |
| 20/2 | 2026/10/23 22:33 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_BLOCK",
"PathPrefixes": [
"fs/super.c"
]
}Results: {
"Output": "fs/super.c=1195=int reconfigure_super(struct fs_context *fc)\n--\nfs/super.c-1220-\tif (fc-\u003esb_flags_mask \u0026 SB_RDONLY) {\nfs/super.c:1221:#ifdef CONFIG_BLOCK\nfs/super.c-1222-\t\tif (!(fc-\u003esb_flags \u0026 SB_RDONLY) \u0026\u0026 sb-\u003es_bdev \u0026\u0026\n--\nfs/super.c=1349=static void do_thaw_all_callback(struct super_block *sb, void *unused)\n--\nfs/super.c-1354-\t/* fs_bdev_thaw() acquires s_umount so it must not be held here */\nfs/super.c:1355:\tif (IS_ENABLED(CONFIG_BLOCK))\nfs/super.c-1356-\t\twhile (sb-\u003es_bdev \u0026\u0026 !bdev_thaw(sb-\u003es_bdev))\n--\nfs/super.c=1621=EXPORT_SYMBOL(sget_dev);\nfs/super.c-1622-\nfs/super.c:1623:#ifdef CONFIG_BLOCK\nfs/super.c-1624-static int fs_super_freeze(struct super_block *sb)\n"
} |
| 21/2 | 2026/10/23 22:33 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37951 output: 34 thoughts: 49 Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person: **Investigating a Kernel Block Configuration Dependency** Alright, my internal radar just pinged. Line 1623 in `fs/super.c` has a `#ifdef CONFIG_BLOCK` directive. Always a good starting point when I see something like that. My immediate thought is, "Let's dig in and see what conditional logic is gated by that preprocessor symbol." Given my familiarity with the codebase, my assumption is this will either be code that directly interacts with block devices, or code that is indirectly enabled to support a block configuration. I'll need to assess the scope of the code block. I'll mentally evaluate if it is defining or using a data structure. Is it registering a filesystem type? Does it affect how the super block is handled? I'll be looking for subtle dependencies, as well as obvious ones. I'll analyze the code both within the `#ifdef` block and, just as importantly, the surrounding code to understand the context and implications of `CONFIG_BLOCK` being defined (or not). The goal is to fully understand its impact on the filesystem initialization, and possible functionality, and make an assessment about the code's design. |
| 22/2 | 2026/10/23 22:34 | tool | read-file |
0mArgs:{
"File": "fs/super.c",
"FirstLine": 1620,
"LineCount": 40
}Results: {
"Contents": "1620:\t}\n1621:\tEXPORT_SYMBOL(sget_dev);\n1622:\t\n1623:\t#ifdef CONFIG_BLOCK\n1624:\tstatic int fs_super_freeze(struct super_block *sb)\n1625:\t{\n1626:\t\tif (sb-\u003es_op-\u003efreeze_super)\n1627:\t\t\treturn sb-\u003es_op-\u003efreeze_super(sb,\n1628:\t\t\t\t\tFREEZE_MAY_NEST | FREEZE_HOLDER_USERSPACE, NULL);\n1629:\t\treturn freeze_super(sb, FREEZE_MAY_NEST | FREEZE_HOLDER_USERSPACE, NULL);\n1630:\t}\n1631:\t\n1632:\tstatic int fs_super_thaw(struct super_block *sb)\n1633:\t{\n1634:\t\tint error;\n1635:\t\n1636:\t\tif (sb-\u003es_op-\u003ethaw_super) {\n1637:\t\t\terror = sb-\u003es_op-\u003ethaw_super(sb,\n1638:\t\t\t\t\tFREEZE_MAY_NEST | FREEZE_HOLDER_USERSPACE, NULL);\n1639:\t\t\t/* -EINVAL means the freeze is gone already. */\n1640:\t\t\tif (error == -EINVAL)\n1641:\t\t\t\treturn 0;\n1642:\t\t\treturn error;\n1643:\t\t}\n1644:\t\n1645:\t\t/* The caller holds an active reference. */\n1646:\t\tif (WARN_ON_ONCE(super_lock(sb, SUPER_LOCK_EXCL)))\n1647:\t\t\treturn 0;\n1648:\t\n1649:\t\t/* FITHAW or an emergency thaw may have dropped the freeze already. */\n1650:\t\tif (sb-\u003es_writers.frozen != SB_FREEZE_COMPLETE ||\n1651:\t\t !sb-\u003es_writers.freeze_ucount) {\n1652:\t\t\tsuper_unlock_excl(sb);\n1653:\t\t\treturn 0;\n1654:\t\t}\n1655:\t\treturn thaw_super_locked(sb, FREEZE_MAY_NEST | FREEZE_HOLDER_USERSPACE,\n1656:\t\t\t\t\t NULL);\n1657:\t}\n1658:\t\n1659:\tstatic void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)\n"
} |
| 23/2 | 2026/10/23 22:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38934 output: 34 thoughts: 82 Thoughts: Here's my take on the situation: **Investigating Block Device Configuration Dependencies** Okay, so I'm digging into this code and I see these functions – `fs_super_thaw`, `fs_bdev_mark_dead`, `fs_bdev_sync`, `fs_bdev_freeze`, `fs_bdev_thaw` – and they're all nested within an `#ifdef CONFIG_BLOCK` conditional. Right, of course, these are block device related operations, so it makes perfect sense. My immediate question, though, is where does this preprocessor directive actually *end*? We have to know the scope of this to understand what other code these functions depend on. I'll need to figure out where the `#endif` is. I'm guessing it's not too long, let me check around line 1810-1830 and see if I can spot it. |
| 24/2 | 2026/10/23 22:34 | tool | read-file |
0mArgs:{
"File": "fs/super.c",
"FirstLine": 1805,
"LineCount": 25
}Results: {
"Contents": "1805:\t\n1806:\tstatic const struct blk_holder_ops fs_holder_ops = {\n1807:\t\t.mark_dead\t\t= fs_bdev_mark_dead,\n1808:\t\t.sync\t\t\t= fs_bdev_sync,\n1809:\t\t.freeze\t\t\t= fs_bdev_freeze,\n1810:\t\t.thaw\t\t\t= fs_bdev_thaw,\n1811:\t};\n1812:\t\n1813:\tstatic struct super_dev *super_dev_find(dev_t dev, const struct super_block *sb)\n1814:\t{\n1815:\t\tstruct super_dev *sd;\n1816:\t\n1817:\t\tlockdep_assert_held(\u0026super_dev_lock);\n1818:\t\n1819:\t\thash_for_each_possible(super_dev_hash, sd, sd_hash, dev) {\n1820:\t\t\tif (sd-\u003esd_dev == dev \u0026\u0026 sd-\u003esd_sb == sb)\n1821:\t\t\t\treturn sd;\n1822:\t\t}\n1823:\t\treturn NULL;\n1824:\t}\n1825:\t\n1826:\t/*\n1827:\t * Filesystem metadata is shared across users and should be accounted to the\n1828:\t * root cgroup. Charging it to individual cgroups can trigger foreign writeback\n1829:\t * of the bdev inode's entire owner wb, including unrelated file data. For\n"
} |
| 25/2 | 2026/10/23 22:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39647 output: 32 thoughts: 26 Thoughts: Here's a summary of my thought process: **Debugging a `#ifdef` Block in the Kernel** Okay, so I'm trying to figure out where this `#ifdef CONFIG_BLOCK` block ends within the `fs/super.c` file. I need to understand the scope of that conditional compilation. My initial thought is the most direct approach: let's use `grep` to quickly locate the corresponding `#endif` statement. That's usually the most reliable way to visually identify the closing bracket of a conditional directive in C code, especially in a file as large as `fs/super.c`. Grabbing the relevant information directly and efficiently is key, given that I'm already familiar with this codebase. |
| 26/2 | 2026/10/23 22:34 | tool | grepper |
0mError:no matches Args: {
"Expression": "#endif.*CONFIG_BLOCK",
"PathPrefixes": [
"fs/super.c"
]
}Results: {
"error": "no matches"
} |
| 27/2 | 2026/10/23 22:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39869 output: 29 thoughts: 21 Thoughts: Here's my summary, as if I were thinking it: **Digging into the Preprocessor Maze** Okay, time to get my hands dirty. I need to track down where this particular `#endif` is lurking, and based on the context, my gut tells me it's likely somewhere in the thick of things, maybe near some conditional compilation. Let's start with a focused `grep`. The suspect area seems to be around lines 1800 to 2000. Hopefully, that targeted search will narrow things down pretty quickly. I'm expecting to find a conditional block that's either badly nested or has an unexpected side effect and this is my best lead. Time to see what that `grep` uncovers. |
| 28/2 | 2026/10/23 22:34 | tool | grepper |
0mArgs:{
"Expression": "^#endif",
"PathPrefixes": [
"fs/super.c"
]
}Results: {
"Output": "fs/super.c=1195=int reconfigure_super(struct fs_context *fc)\n--\nfs/super.c-1224-\t\t\treturn -EACCES;\nfs/super.c:1225:#endif\nfs/super.c-1226-\t\tremount_rw = !(fc-\u003esb_flags \u0026 SB_RDONLY) \u0026\u0026 sb_rdonly(sb);\n--\nfs/super.c=2138=EXPORT_SYMBOL(kill_block_super);\nfs/super.c:2139:#endif\nfs/super.c-2140-\n"
} |
| 29/2 | 2026/10/23 22:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40234 output: 28 thoughts: 111 Thoughts: **Analyzing Kernel Configuration Options** Alright, perfect! I've confirmed it: lines 1623 through 2139 are *definitely* nested within `#ifdef CONFIG_BLOCK`! And we all know `CONFIG_BLOCK` is practically ubiquitous – it's enabled across almost every standard configuration, particularly for anything related to fuzzing filesystems and block devices. That means `BLOCK` should absolutely be added to `EnableConfigs`. This is a solid find. Now, I need to make sure I haven't missed anything. Are there any *other* relevant configuration options lurking around? Time to dig a bit deeper. Let's start by checking `fs/Kconfig` and `fs/super.c`. These are the typical places to find filesystem-related configuration details. I'll do a quick scan of `fs/super.c`, searching for any instances of `CONFIG_`. That should expose any other potentially interesting options. Let's see what turns up. |
| 30/2 | 2026/10/23 22:34 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_",
"PathPrefixes": [
"fs/super.c"
]
}Results: {
"Output": "fs/super.c=1195=int reconfigure_super(struct fs_context *fc)\n--\nfs/super.c-1220-\tif (fc-\u003esb_flags_mask \u0026 SB_RDONLY) {\nfs/super.c:1221:#ifdef CONFIG_BLOCK\nfs/super.c-1222-\t\tif (!(fc-\u003esb_flags \u0026 SB_RDONLY) \u0026\u0026 sb-\u003es_bdev \u0026\u0026\n--\nfs/super.c=1349=static void do_thaw_all_callback(struct super_block *sb, void *unused)\n--\nfs/super.c-1354-\t/* fs_bdev_thaw() acquires s_umount so it must not be held here */\nfs/super.c:1355:\tif (IS_ENABLED(CONFIG_BLOCK))\nfs/super.c-1356-\t\twhile (sb-\u003es_bdev \u0026\u0026 !bdev_thaw(sb-\u003es_bdev))\n--\nfs/super.c=1621=EXPORT_SYMBOL(sget_dev);\nfs/super.c-1622-\nfs/super.c:1623:#ifdef CONFIG_BLOCK\nfs/super.c-1624-static int fs_super_freeze(struct super_block *sb)\n--\nfs/super.c=1813=static struct super_dev *super_dev_find(dev_t dev, const struct super_block *sb)\n--\nfs/super.c-1835- * Raw buffered I/O also uses kernel-file accounting while a filesystem uses\nfs/super.c:1836: * the device. This is independent of CONFIG_BLK_DEV_WRITE_MOUNTED: writes to\nfs/super.c-1837- * a mounted device are dangerous administrative operations, and charging\n"
} |
| 31/2 | 2026/10/23 22:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41035 output: 236 thoughts: 1350 Thoughts: **Focusing on Superblock Locking: A Fuzzing Strategy** Okay, so I'm looking at `fs/super.c`. `CONFIG_BLOCK` is the only guard in that file, and the rest is always compiled into `vmlinux`. My goal is to identify specific, non-ubiquitous kernel functions to target for fuzzing, given the recent patch. Let's review the focus symbols once more. We've got: `super_lock`, `freeze_super`, `thaw_super`, `iterate_supers_sync`, `user_get_super`, `grab_super`, `fs_bdev_freeze`, `fs_bdev_thaw`, `fs_bdev_sync`, `fs_bdev_mark_dead`, `do_emergency_remount_callback`, and `do_thaw_all_callback`. These functions all relate to the core changes in the patch: superblock locking and wait management. Now, which of these are the best fuzz targets? I'll check `super_lock` first. Is it static and exported as a symbol? In kernel builds, if a static function is called in multiple places (and isn't inlined) it's likely to have a symbol in `vmlinux`. `super_lock` is definitely called by several other functions: `class_super_lock_constructor`, `grab_super`, `user_get_super`, `do_thaw_all_callback`, `fs_super_thaw`, `freeze_super`, and `thaw_super`. It's pretty substantial, maybe around 50 lines. So, it's very likely a symbol and therefore a good target. `freeze_super` and `thaw_super` are also exported, global functions, and `user_get_super` and `iterate_supers_sync` are non-static. `grab_super` is static and the others, `fs_bdev_freeze`, `fs_bdev_thaw` and `fs_bdev_sync` are static callbacks in `fs_holder_ops`. So, the key functions to watch are now: `super_lock`, `freeze_super`, `thaw_super`, `iterate_supers_sync`, `user_get_super`, `grab_super`, and `fs_bdev_sync`, `fs_bdev_freeze`, and `fs_bdev_thaw`. Are any of these ubiquitous? No. `super_lock` is only used during mounting, freezing, thawing, syncing, quotactl, and bdev holder operations, not every syscall. `freeze_super` and `thaw_super` are only called during freezing and thawing. `iterate_supers_sync` is just during sync. `user_get_super` for quotactl and ustat. `grab_super` during mounting, `fs_bdev_sync`, `fs_bdev_freeze`, and `fs_bdev_thaw` on bdev events. They're all very specific. None are generic functions like `kmalloc`, `kfree`, `mutex_lock`, or `schedule`. The patch unifies locking and wait helpers into `super_lock()`. It uses RAII/guard classes and updates call sites in standard VFS operations: freeze/thaw, mount/sget_fc, sync, block device ops. This code is definitely reachable through syscalls like `mount`, `umount`, `sync`, and `ioctl(FIFREEZE/FITHAW)`. Refactoring locking and wait behavior is risky. It's likely to introduce regressions, deadlocks, and lockdep violations. Therefore, this is a clear candidate for fuzzing (`WorthFuzzing = true`). We'll need the `BLOCK` config since a portion of `fs/super.c` is guarded by it. Everything seems correct and directly supported by the sources and triage rules. It's time to call `set-results`. |
| 32/2 | 2026/10/23 22:34 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"BLOCK"
],
"FocusSymbols": [
"super_lock",
"freeze_super",
"thaw_super",
"iterate_supers_sync",
"user_get_super",
"grab_super",
"fs_bdev_sync",
"fs_bdev_freeze",
"fs_bdev_thaw"
],
"Reasoning": "The patch modifies core VFS superblock locking and shutdown waiting logic in fs/super.c. It consolidates multiple locking helpers into a unified super_lock() function with flags, changes its return semantics from bool to int error codes, and introduces RAII-style cleanup guards (scoped_guard, scoped_cond_guard, ACQUIRE). These modifications directly affect reachable code paths exercised by common filesystem syscalls and ioctls, including mount, sync, FIFREEZE/FITHAW ioctls, and block device holder callbacks. Such locking and lifecycle refactorings warrant fuzzing to catch potential lockdep splats, regressions, or synchronization races.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"BLOCK"
],
"FocusSymbols": [
"super_lock",
"freeze_super",
"thaw_super",
"iterate_supers_sync",
"user_get_super",
"grab_super",
"fs_bdev_sync",
"fs_bdev_freeze",
"fs_bdev_thaw"
],
"Reasoning": "The patch modifies core VFS superblock locking and shutdown waiting logic in fs/super.c. It consolidates multiple locking helpers into a unified super_lock() function with flags, changes its return semantics from bool to int error codes, and introduces RAII-style cleanup guards (scoped_guard, scoped_cond_guard, ACQUIRE). These modifications directly affect reachable code paths exercised by common filesystem syscalls and ioctls, including mount, sync, FIFREEZE/FITHAW ioctls, and block device holder callbacks. Such locking and lifecycle refactorings warrant fuzzing to catch potential lockdep splats, regressions, or synchronization races.",
"WorthFuzzing": true
} |
| 33/1 | 2026/10/23 22:34 | action | If |
0mArgs:{
"WorthFuzzing": true
}Results: null |
| 34/2 | 2026/10/23 22:34 | agent | kmsan-evaluator |
0mModel:core Args: null Results: {
"KMSANReasoning": "The patch refactors internal superblock locking and waiting mechanisms in fs/super.c (introducing enum super_lock_flags_t, unifying super_lock/super_wait, and implementing RAII cleanup guards via __DEFINE_UNLOCK_GUARD/scoped_guard/ACQUIRE). It does not introduce or modify any data structures copied to user space, does not allocate uninitialized buffers, and does not alter data buffers or bounds checks. All local variables and guard structures (such as class_super_lock_t) are fully initialized at the point of declaration. The potential bugs in this patch are concurrency- and locking-related (deadlocks, lock ordering, missed unlocks, refcount errors, or error return handling), which are covered by LOCKDEP and KASAN. Therefore, a dedicated KMSAN session is not justified.",
"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 7d0dafe06bb19feaa70a02f1f486e0c37394c702
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Oct 23 22:31:42 2026 +0000
syz-cluster: applied patch under review
diff --git a/fs/super.c b/fs/super.c
index 63e85794ea4d5..aff2169ca94d1 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -55,24 +55,32 @@ static char *sb_writers_name[SB_FREEZE_LEVELS] = {
"sb_internal",
};
-static inline void __super_lock(struct super_block *sb, bool excl)
+enum super_lock_flags_t {
+ SUPER_LOCK_EXCL = (1U << 0),
+ SUPER_LOCK_KILLABLE = (1U << 1),
+ SUPER_LOCK_WAIT_SHUTDOWN = (1U << 2),
+};
+
+static inline int __super_lock(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- if (excl)
+ if (flags & SUPER_LOCK_KILLABLE) {
+ if (flags & SUPER_LOCK_EXCL)
+ return down_write_killable(&sb->s_umount);
+ return down_read_killable(&sb->s_umount);
+ }
+
+ if (flags & SUPER_LOCK_EXCL)
down_write(&sb->s_umount);
else
down_read(&sb->s_umount);
+ return 0;
}
-static inline int __super_lock_killable(struct super_block *sb, bool excl)
-{
- if (excl)
- return down_write_killable(&sb->s_umount);
- return down_read_killable(&sb->s_umount);
-}
-
-static inline void super_unlock(struct super_block *sb, bool excl)
+static inline void super_unlock(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- if (excl)
+ if (flags & SUPER_LOCK_EXCL)
up_write(&sb->s_umount);
else
up_read(&sb->s_umount);
@@ -80,17 +88,17 @@ static inline void super_unlock(struct super_block *sb, bool excl)
static inline void __super_lock_excl(struct super_block *sb)
{
- __super_lock(sb, true);
+ __super_lock(sb, SUPER_LOCK_EXCL);
}
static inline void super_unlock_excl(struct super_block *sb)
{
- super_unlock(sb, true);
+ super_unlock(sb, SUPER_LOCK_EXCL);
}
static inline void super_unlock_shared(struct super_block *sb)
{
- super_unlock(sb, false);
+ super_unlock(sb, 0);
}
static bool super_flags(const struct super_block *sb, unsigned int flags)
@@ -103,12 +111,54 @@ static bool super_flags(const struct super_block *sb, unsigned int flags)
}
/*
- * Returns 0 with s_umount held, -ENOENT if the superblock is going away, or,
- * if @killable, the error from a wait which was cut short.
+ * Wait for one of @sb_flags to be set on @sb, sleeping in @state. Returns 0
+ * or -ERESTARTSYS if @state allowed the wait to be cut short.
*/
-static int super_lock_common(struct super_block *sb, bool excl, bool killable)
+static int super_wait(struct super_block *sb, unsigned int sb_flags,
+ unsigned int state)
{
- int ret = 0;
+ return wait_var_event_state(&sb->s_flags, super_flags(sb, sb_flags),
+ state);
+}
+
+/**
+ * super_lock - wait for superblock to become ready and lock it
+ * @sb: superblock to wait for
+ * @flags: SUPER_LOCK_* flags
+ *
+ * If the superblock has neither passed through vfs_get_tree() or
+ * generic_shutdown_super() yet wait for it to happen. Either superblock
+ * creation will succeed and SB_BORN is set by vfs_get_tree() or we're
+ * woken and we'll see SB_DYING.
+ *
+ * With SUPER_LOCK_EXCL s_umount is taken for writing, otherwise for reading.
+ *
+ * A superblock which is being shut down is not waited for unless
+ * SUPER_LOCK_WAIT_SHUTDOWN is passed. That is for those who have nothing to
+ * do on a superblock which is going away, but who promise their caller that
+ * what it had to write has been written, or who must not carry on while the
+ * filesystem is still being written out. The wait is over once
+ * generic_shutdown_super() is done with @sb, and -ENOENT is still returned.
+ *
+ * With SUPER_LOCK_KILLABLE all the waiting can be cut short by a fatal
+ * signal. That is only for callers which give up altogether when they are
+ * killed. If what comes after the wait happens either way, the wait must
+ * not be cut short.
+ *
+ * The caller must have acquired a temporary reference on @sb->s_passive.
+ *
+ * Return: 0 if SB_BORN was set and with s_umount held. Without s_umount held,
+ * -ENOENT if the superblock is being shut down or SB_DYING was set,
+ * -EINTR or -ERESTARTSYS if the task was killed.
+ */
+static __must_check int super_lock(struct super_block *sb,
+ enum super_lock_flags_t flags)
+{
+ unsigned int state = TASK_UNINTERRUPTIBLE;
+ int ret;
+
+ if (flags & SUPER_LOCK_KILLABLE)
+ state = TASK_KILLABLE;
lockdep_assert_not_held(&sb->s_umount);
@@ -119,26 +169,18 @@ static int super_lock_common(struct super_block *sb, bool excl, bool killable)
* and it can be a long one: the filesystem is written out first.
*/
if (!atomic_read(&sb->s_active))
- return -ENOENT;
+ goto dying;
/* wait until the superblock is ready or dying */
- if (killable)
- ret = wait_var_event_killable(&sb->s_flags,
- super_flags(sb, SB_BORN | SB_DYING));
- else
- wait_var_event(&sb->s_flags,
- super_flags(sb, SB_BORN | SB_DYING));
+ ret = super_wait(sb, SB_BORN | SB_DYING, state);
if (ret)
return ret;
/* Don't pointlessly acquire s_umount. */
if (super_flags(sb, SB_DYING))
- return -ENOENT;
+ goto dying;
- if (killable)
- ret = __super_lock_killable(sb, excl);
- else
- __super_lock(sb, excl);
+ ret = __super_lock(sb, flags);
if (ret)
return ret;
@@ -148,101 +190,45 @@ static int super_lock_common(struct super_block *sb, bool excl, bool killable)
* grab a reference to this. Tell them so.
*/
if (sb->s_flags & SB_DYING) {
- super_unlock(sb, excl);
- return -ENOENT;
+ super_unlock(sb, flags);
+ goto dying;
}
WARN_ON_ONCE(!(sb->s_flags & SB_BORN));
return 0;
-}
-/**
- * super_lock - wait for superblock to become ready and lock it
- * @sb: superblock to wait for
- * @excl: whether exclusive access is required
- *
- * If the superblock has neither passed through vfs_get_tree() or
- * generic_shutdown_super() yet wait for it to happen. Either superblock
- * creation will succeed and SB_BORN is set by vfs_get_tree() or we're
- * woken and we'll see SB_DYING.
- *
- * A superblock which is being shut down is not waited for, see
- * super_wait_shutdown() and super_wait_shutdown_killable() for that.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- *
- * Return: The function returns true if SB_BORN was set and with
- * s_umount held. The function returns false if the superblock
- * is being shut down or SB_DYING was set and without s_umount
- * held.
- */
-static __must_check bool super_lock(struct super_block *sb, bool excl)
-{
- return !super_lock_common(sb, excl, false);
-}
-
-/**
- * super_lock_killable - killable super_lock()
- * @sb: superblock to wait for
- * @excl: whether exclusive access is required
- *
- * Only for callers which give up altogether when they are killed.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- *
- * Return: 0 if SB_BORN was set and with s_umount held. Without s_umount held,
- * -ENOENT if the superblock is being shut down or SB_DYING was set,
- * -EINTR or -ERESTARTSYS if the task was killed.
- */
-static __must_check int super_lock_killable(struct super_block *sb, bool excl)
-{
- return super_lock_common(sb, excl, true);
+dying:
+ if (flags & SUPER_LOCK_WAIT_SHUTDOWN) {
+ ret = super_wait(sb, SB_DYING, state);
+ if (ret)
+ return ret;
+ }
+ return -ENOENT;
}
-/**
- * super_wait_shutdown_killable - wait for a superblock being shut down
- * @sb: superblock super_lock() failed on
- *
- * For those who have nothing to do on a superblock which is going away, but
- * who promise their caller that what it had to write has been written.
- *
- * Only for callers which give up altogether when they are killed. If what
- * comes after the wait happens either way, the wait must not be cut short.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- *
- * Return: 0 once generic_shutdown_super() is done with @sb, -ERESTARTSYS if
- * the task was killed first.
- */
-static int super_wait_shutdown_killable(struct super_block *sb)
+static inline void super_unlock_guard(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- return wait_var_event_killable(&sb->s_flags, super_flags(sb, SB_DYING));
+ if (!IS_ERR_OR_NULL(sb))
+ super_unlock(sb, flags);
}
-/**
- * super_wait_shutdown - wait for a superblock being shut down
- * @sb: superblock super_lock() failed on
- *
- * For callers of which the rest happens whether they are killed or not, and
- * must not happen while the filesystem is still being written out.
- *
- * The caller must have acquired a temporary reference on @sb->s_passive.
- */
-static void super_wait_shutdown(struct super_block *sb)
-{
- wait_var_event(&sb->s_flags, super_flags(sb, SB_DYING));
-}
+/* Unlocks with the flags it locked with. */
+__DEFINE_CLASS_IS_CONDITIONAL(super_lock, true);
+__DEFINE_UNLOCK_GUARD(super_lock, struct super_block,
+ super_unlock_guard(_T->lock, _T->flags),
+ enum super_lock_flags_t flags);
-/* wait and try to acquire read-side of @sb->s_umount */
-static inline bool super_lock_shared(struct super_block *sb)
+static inline class_super_lock_t
+class_super_lock_constructor(struct super_block *sb, enum super_lock_flags_t flags)
{
- return super_lock(sb, false);
-}
+ class_super_lock_t _t = { .lock = sb, .flags = flags };
+ int ret;
-/* wait and try to acquire write-side of @sb->s_umount */
-static inline bool super_lock_excl(struct super_block *sb)
-{
- return super_lock(sb, true);
+ ret = super_lock(sb, flags);
+ if (ret)
+ _t.lock = ERR_PTR(ret);
+ return _t;
}
/* wake waiters */
@@ -606,9 +592,7 @@ static struct super_block *super_dev_next(struct super_dev *cursor,
return sb;
}
}
- ret = wait_var_event_state(&sb->s_flags,
- super_flags(sb, SB_BORN | SB_DYING),
- state);
+ ret = super_wait(sb, SB_BORN | SB_DYING, state);
put_super(sb);
if (ret) {
super_dev_walk_end(cursor);
@@ -721,7 +705,7 @@ static int grab_super(struct super_block *sb)
refcount_inc(&sb->s_passive);
spin_unlock(&sb_lock);
- ret = super_lock_killable(sb, true);
+ ret = super_lock(sb, SUPER_LOCK_EXCL | SUPER_LOCK_KILLABLE);
if (!ret) {
if (atomic_inc_not_zero(&sb->s_active)) {
put_super(sb);
@@ -731,8 +715,7 @@ static int grab_super(struct super_block *sb)
ret = -ENOENT;
}
if (ret == -ENOENT)
- ret = wait_var_event_killable(&sb->s_flags,
- super_flags(sb, SB_DEAD));
+ ret = super_wait(sb, SB_DEAD, TASK_KILLABLE);
put_super(sb);
return ret ? ret : -EAGAIN;
}
@@ -1052,9 +1035,13 @@ static inline struct super_block *next_super(struct super_block *sb,
static int __iterate_supers(void (*f)(struct super_block *, void *), void *arg,
enum super_iter_flags_t flags)
{
+ enum super_lock_flags_t lock_flags = 0;
struct super_block *sb, *p = NULL;
int ret = 0;
+ if (flags & SUPER_ITER_WAIT_SHUTDOWN)
+ lock_flags |= SUPER_LOCK_KILLABLE | SUPER_LOCK_WAIT_SHUTDOWN;
+
spin_lock(&sb_lock);
for (sb = first_super(flags);
@@ -1074,11 +1061,14 @@ static int __iterate_supers(void (*f)(struct super_block *, void *), void *arg,
if (flags & SUPER_ITER_UNLOCKED) {
f(sb, arg);
- } else if (super_lock_shared(sb)) {
- f(sb, arg);
- super_unlock_shared(sb);
- } else if (flags & SUPER_ITER_WAIT_SHUTDOWN) {
- ret = super_wait_shutdown_killable(sb);
+ } else {
+ ACQUIRE(super_lock, lock)(sb, lock_flags);
+
+ ret = ACQUIRE_ERR(super_lock, &lock);
+ if (!ret)
+ f(sb, arg);
+ else if (ret == -ENOENT)
+ ret = 0;
}
if (p)
@@ -1126,8 +1116,8 @@ void iterate_supers_born(void (*f)(struct super_block *, void *), void *arg)
* A superblock which is still being set up isn't passed to @f either, and
* isn't waited for. Nobody can have written to it yet.
*
- * Return: 0 if all the superblocks were seen, -ERESTARTSYS if the task was
- * killed while it waited for one.
+ * Return: 0 if all the superblocks were seen, -EINTR or -ERESTARTSYS if the
+ * task was killed while it waited for one.
*/
int iterate_supers_sync(void (*f)(struct super_block *, void *), void *arg)
{
@@ -1151,8 +1141,6 @@ void iterate_supers_type(struct file_system_type *type,
spin_lock(&sb_lock);
hlist_for_each_entry(sb, &type->fs_supers, s_instances) {
- bool locked;
-
if (super_flags(sb, SB_DYING))
continue;
@@ -1161,11 +1149,8 @@ void iterate_supers_type(struct file_system_type *type,
spin_unlock(&sb_lock);
- locked = super_lock_shared(sb);
- if (locked) {
+ scoped_guard(super_lock, sb, 0)
f(sb, arg);
- super_unlock_shared(sb);
- }
if (p)
put_super(p);
@@ -1187,7 +1172,8 @@ struct super_block *user_get_super(dev_t dev, bool excl)
for_each_dev_super_killable(sb, &cursor) {
int ret;
- ret = super_lock_killable(sb, excl);
+ ret = super_lock(sb, (excl ? SUPER_LOCK_EXCL : 0) |
+ SUPER_LOCK_KILLABLE);
if (ret == -ENOENT)
continue;
super_dev_walk_end(&cursor);
@@ -1310,21 +1296,19 @@ static void do_emergency_remount_callback(struct super_block *sb, void *unused)
{
struct fs_context *fc = NULL;
- if (!super_lock_excl(sb)) {
- /* the unmount writes the filesystem out, wait for that */
- super_wait_shutdown(sb);
- return;
- }
-
- /* Make sure no reference put under s_umount is the last one. */
- atomic_inc(&sb->s_active);
- if (sb->s_bdev && !sb_rdonly(sb)) {
- fc = fs_context_for_reconfigure(sb->s_root,
- SB_RDONLY | SB_FORCE, SB_RDONLY);
- if (!IS_ERR(fc) && parse_monolithic_mount_data(fc, NULL) == 0)
- (void)reconfigure_super(fc);
+ /* the unmount writes the filesystem out, wait for that */
+ scoped_cond_guard(super_lock, return, sb,
+ SUPER_LOCK_EXCL | SUPER_LOCK_WAIT_SHUTDOWN) {
+ /* Make sure no reference put under s_umount is the last one. */
+ atomic_inc(&sb->s_active);
+ if (sb->s_bdev && !sb_rdonly(sb)) {
+ fc = fs_context_for_reconfigure(sb->s_root,
+ SB_RDONLY | SB_FORCE, SB_RDONLY);
+ if (!IS_ERR(fc) &&
+ parse_monolithic_mount_data(fc, NULL) == 0)
+ (void)reconfigure_super(fc);
+ }
}
- super_unlock_excl(sb);
/*
* Our active reference may be the last one by now, so only drop it
@@ -1354,20 +1338,17 @@ void emergency_remount(void)
}
}
-static inline bool get_active_super(struct super_block *sb)
+static inline bool get_active_super(struct super_block *sb,
+ enum super_lock_flags_t flags)
{
- bool active = false;
-
- if (super_lock_excl(sb)) {
- active = atomic_inc_not_zero(&sb->s_active);
- super_unlock_excl(sb);
- }
- return active;
+ scoped_guard(super_lock, sb, SUPER_LOCK_EXCL | flags)
+ return atomic_inc_not_zero(&sb->s_active);
+ return false;
}
static void do_thaw_all_callback(struct super_block *sb, void *unused)
{
- if (!get_active_super(sb))
+ if (!get_active_super(sb, 0))
return;
/* fs_bdev_thaw() acquires s_umount so it must not be held here */
@@ -1375,7 +1356,7 @@ static void do_thaw_all_callback(struct super_block *sb, void *unused)
while (sb->s_bdev && !bdev_thaw(sb->s_bdev))
pr_warn("Emergency Thaw on %pg\n", sb->s_bdev);
- if (super_lock_excl(sb))
+ if (!super_lock(sb, SUPER_LOCK_EXCL))
thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE, NULL);
deactivate_super(sb);
}
@@ -1413,11 +1394,9 @@ static void filesystems_freeze_callback(struct super_block *sb, void *freeze_all
if (!freeze_all_ptr && !(sb->s_type->fs_flags & FS_POWER_FREEZE))
return;
- if (!get_active_super(sb)) {
- /* an unmount from a workqueue isn't stopped by the freezer */
- super_wait_shutdown(sb);
+ /* an unmount from a workqueue isn't stopped by the freezer */
+ if (!get_active_super(sb, SUPER_LOCK_WAIT_SHUTDOWN))
return;
- }
if (sb->s_op->freeze_super)
sb->s_op->freeze_super(sb, FREEZE_EXCL | FREEZE_HOLDER_KERNEL,
@@ -1444,7 +1423,7 @@ static void filesystems_thaw_callback(struct super_block *sb, void *unused)
if (!sb->s_op->freeze_fs && !sb->s_op->freeze_super)
return;
- if (!get_active_super(sb))
+ if (!get_active_super(sb, 0))
return;
if (sb->s_op->thaw_super)
@@ -1664,7 +1643,7 @@ static int fs_super_thaw(struct super_block *sb)
}
/* The caller holds an active reference. */
- if (WARN_ON_ONCE(!super_lock_excl(sb)))
+ if (WARN_ON_ONCE(super_lock(sb, SUPER_LOCK_EXCL)))
return 0;
/* FITHAW or an emergency thaw may have dropped the freeze already. */
@@ -1685,12 +1664,11 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super(sb, &cursor) {
- if (!super_lock_shared(sb)) {
- /* don't take the device away from under an unmount */
- if (!surprise)
- super_wait_shutdown(sb);
+ /* don't take the device away from under an unmount */
+ ACQUIRE(super_lock, lock)(sb, surprise ? 0 :
+ SUPER_LOCK_WAIT_SHUTDOWN);
+ if (ACQUIRE_ERR(super_lock, &lock))
continue;
- }
if (sb->s_root && (sb->s_flags & SB_ACTIVE)) {
if (!sb->s_op->remove_bdev ||
sb->s_op->remove_bdev(sb, bdev)) {
@@ -1702,7 +1680,6 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)
sb->s_op->shutdown(sb);
}
}
- super_unlock_shared(sb);
}
}
@@ -1714,22 +1691,19 @@ static void fs_bdev_sync(struct block_device *bdev)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super_killable(sb, &cursor) {
- int ret;
+ ACQUIRE(super_lock, lock)(sb, SUPER_LOCK_KILLABLE |
+ SUPER_LOCK_WAIT_SHUTDOWN);
+ int ret = ACQUIRE_ERR(super_lock, &lock);
- ret = super_lock_killable(sb, false);
- if (!ret) {
- if (sb->s_root && (sb->s_flags & SB_ACTIVE))
- sync_filesystem(sb);
- super_unlock_shared(sb);
- continue;
- }
if (ret == -ENOENT)
- ret = super_wait_shutdown_killable(sb);
+ continue;
if (ret) {
super_dev_walk_end(&cursor);
put_super(sb);
return;
}
+ if (sb->s_root && (sb->s_flags & SB_ACTIVE))
+ sync_filesystem(sb);
}
}
@@ -1758,11 +1732,9 @@ static int fs_bdev_freeze(struct block_device *bdev)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super(sb, &cursor) {
- if (!get_active_super(sb)) {
- /* an unmount writes to the device until it is done */
- super_wait_shutdown(sb);
+ /* an unmount writes to the device until it is done */
+ if (!get_active_super(sb, SUPER_LOCK_WAIT_SHUTDOWN))
continue;
- }
err = fs_super_freeze(sb);
if (err && !error)
error = err;
@@ -1816,7 +1788,7 @@ static int fs_bdev_thaw(struct block_device *bdev)
mutex_unlock(&bdev->bd_holder_lock);
for_each_dev_super(sb, &cursor) {
- if (!get_active_super(sb))
+ if (!get_active_super(sb, 0))
continue;
err = fs_super_thaw(sb);
if (err && !error)
@@ -2513,7 +2485,7 @@ int freeze_super(struct super_block *sb, enum freeze_holder who, const void *fre
{
int ret;
- if (!super_lock_excl(sb)) {
+ if (super_lock(sb, SUPER_LOCK_EXCL)) {
WARN_ONCE(1, "Dying superblock while freezing!");
return -EINVAL;
}
@@ -2680,7 +2652,7 @@ static int thaw_super_locked(struct super_block *sb, enum freeze_holder who,
int thaw_super(struct super_block *sb, enum freeze_holder who,
const void *freeze_owner)
{
- if (!super_lock_excl(sb)) {
+ if (super_lock(sb, SUPER_LOCK_EXCL)) {
WARN_ONCE(1, "Dying superblock while thawing!");
return -EINVAL;
}
|
| 35/3 | 2026/10/23 22:34 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 9356 output: 195 thoughts: 1742 Thoughts: **KMSAN Needs Assessment: Superblock Locking Refactor** Okay, let's break this down. The question is: do these filesystem superblock locking changes warrant a dedicated KMSAN fuzzing session, or is KASAN sufficient? My gut feeling is KASAN should be enough, but let's be thorough. First, I'm diving into the diff itself. It's touching `fs/super.c`, which is all about superblock management. The core of the change seems to be a refactoring of `super_lock` and its related locking helpers, introducing an `enum super_lock_flags_t`, merging different locking variants into a unified `super_lock` function, and using cleanup guard macros like `scoped_guard` and `ACQUIRE` for more robust lock management. It’s a clean-up and consolidation, which is generally a good thing. They’re replacing manual lock/unlock sequences with guards or the new interface. Now, my radar for KMSAN is going off... I need to look for uninitialized memory usage that could leak information. My checklist: 1. **User-Space Exposure:** Are there any kernel structures being modified or introduced that get sent to user space? That would include anything like `copy_to_user`, `put_user`, netlink attributes, ioctl output arguments, socket options, or BPF buffers. No, that's a negative. Nothing here looks like it touches the userland in that manner. 2. **Conditional Logic & Uninitialized Variables:** Are there new areas of conditional logic or branching that might depend on uninitialized variables or struct fields? I need to check. Let's see... the `class_super_lock_t` struct initialization looks standard: `.lock = sb, .flags = flags`. I need to verify that local variables within the relevant functions like `super_lock`, `__iterate_supers`, and `fs_bdev_sync` are initialized before use. The constructor for the guard looks fine: it explicitly initializes all fields of the local variable `_t`. In `__iterate_supers`, `lock_flags` is initialized to 0, and `ret` is also initialized. In `fs_bdev_sync` `ret` is assigned from `ACQUIRE_ERR`. So, no immediate red flags on this front. 3. **Complex Data Structure Initialization:** Any new allocations or modifications of complex data structures where uninitialized fields could be read later in reachable code paths? No, this patch isn't introducing any new memory allocations. It's just refactoring existing locking mechanisms. 4. **Bounds Checking and Buffer Manipulation:** How about any changes to bounds checks, lengths, or logic that might allow surrounding code to access uninitialized bytes of existing buffers? Nope. I'm not seeing any buffer manipulations or data parsing here. So, what are the potential risks here? This patch is all about synchronization and locking. The biggest risks are locking bugs, deadlocks, lockdep warnings, and logic errors in return values. The change in return value, returning a negative error rather than a boolean true/false from the `super_lock` function, needs careful attention. And, there are warnings using `WARN_ON_ONCE` and `WARN_ONCE` surrounding calls to `super_lock`. I am thinking about those. But these kinds of issues are exactly what KASAN and LOCKDEP are designed to catch! **Key Takeaway: KASAN and LOCKDEP are fully suited.** The bugs that could crop up here: deadlocks, lock inversion, use-after-free issues, refcount issues on `struct super_block`, NULL dereferences, and error pointer dereferences are things caught by KASAN and LOCKDEP. They detect potential problems from the locking semantics that is being changed here. None of these are memory bugs or info leaks to userspace! KMSAN is specifically for detecting uninitialized memory reads and information leaks. There is no usage of uninitialized memory here and no user-space interaction. Let's double-check by verifying the `__DEFINE_UNLOCK_GUARD` and `ACQUIRE` usages since these are standard constructs. So I verify where `__DEFINE_UNLOCK_GUARD` and its related `class_super_lock_constructor` are defined. The struct `class_##name##_t` which holds `type *lock` and any additional args (`enum super_lock_flags_t flags`) are explicitly initialized. There is zero uninitialized memory usage. So, in conclusion: * The patch refactors superblock locking using cleanup helpers. * No new memory allocations or user-space interaction. * All variables and helper structures are fully initialized. * The risks are locking-related, which KASAN and LOCKDEP cover. * No uninitialized memory |
| 36/3 | 2026/10/23 22:34 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch refactors internal superblock locking and waiting mechanisms in fs/super.c (introducing enum super_lock_flags_t, unifying super_lock/super_wait, and implementing RAII cleanup guards via __DEFINE_UNLOCK_GUARD/scoped_guard/ACQUIRE). It does not introduce or modify any data structures copied to user space, does not allocate uninitialized buffers, and does not alter data buffers or bounds checks. All local variables and guard structures (such as class_super_lock_t) are fully initialized at the point of declaration. The potential bugs in this patch are concurrency- and locking-related (deadlocks, lock ordering, missed unlocks, refcount errors, or error return handling), which are covered by LOCKDEP and KASAN. Therefore, a dedicated KMSAN session is not justified.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch refactors internal superblock locking and waiting mechanisms in fs/super.c (introducing enum super_lock_flags_t, unifying super_lock/super_wait, and implementing RAII cleanup guards via __DEFINE_UNLOCK_GUARD/scoped_guard/ACQUIRE). It does not introduce or modify any data structures copied to user space, does not allocate uninitialized buffers, and does not alter data buffers or bounds checks. All local variables and guard structures (such as class_super_lock_t) are fully initialized at the point of declaration. The potential bugs in this patch are concurrency- and locking-related (deadlocks, lock ordering, missed unlocks, refcount errors, or error return handling), which are covered by LOCKDEP and KASAN. Therefore, a dedicated KMSAN session is not justified.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|