Skip to contentSkip to conversation

INFO: task hung in bdev_freeze

syzbot In review syzbot 4 participants 11 messages Nov 9 – Nov 11

Subsystems (2)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    58c1eb84e977 arm64: sdei: Preserve the interrupted context..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=11932a4e580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a58b6b4d667e7a61
dashboard link: https://syzkaller.appspot.com/bug?extid=d4ecb9a1e5b3dcf8baec
compiler:       Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
userspace arch: arm64
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=111be7a5580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10e99409580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b1ec47537e12/disk-58c1eb84.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/3bca0c2b1169/vmlinux-58c1eb84.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0a7c49594d5a/Image-58c1eb84.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/80e50d025158/mount_0.gz
fsck result: OK (log: https://syzkaller.appspot.com/x/fsck.log?x=17699409580000)

AI-generated root cause summary:
In ext4_force_shutdown(), EXT4_GOING_FLAGS_DEFAULT invokes bdev_freeze(sb->s_bdev) to freeze the underlying block device before setting EXT4_FLAGS_SHUTDOWN, and thaws it immediately afterwards via bdev_thaw(). Because ext4_forced_shutdown() is tested only prior to bdev_freeze() and EXT4_FLAGS_SHUTDOWN is not set until bdev_freeze() returns, concurrent callers of EXT4_IOC_SHUTDOWN all bypass the shutdown check and serialize on bdev->bd_fsfreeze_mutex. Each caller must execute a full freeze_super() cycle involving s_umount exclusion, percpu_rwsem write transitions, and synchronize_rcu() calls, causing waiting tasks to stall in uninterruptible sleep (D state) on bd_fsfreeze_mutex and trigger hung-task timeouts.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=d4ecb9a1e5b3dcf8baec

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]
INFO: task syz.1.3811:25659 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.1.3811      state:D stack:0     pid:25659 tgid:25638 ppid:20649  task_flags:0x400140 flags:0x00800001
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:7531
 __mutex_lock_common kernel/locking/mutex.c:726 [inline]
 __mutex_lock+0x5d8/0x10b8 kernel/locking/mutex.c:821
 mutex_lock_nested+0x24/0x30 kernel/locking/mutex.c:874
 bdev_freeze+0x38/0x2e8 block/bdev.c:304
 ext4_force_shutdown+0x288/0x5ac fs/ext4/ioctl.c:826
 ext4_ioctl_shutdown fs/ext4/ioctl.c:868 [inline]
 __ext4_ioctl fs/ext4/ioctl.c:1888 [inline]
 ext4_ioctl+0x21dc/0x4430 fs/ext4/ioctl.c:1932
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl fs/ioctl.c:583 [inline]
 __arm64_sys_ioctl+0x154/0x1cc fs/ioctl.c:583
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
INFO: task syz.1.3811:25660 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.1.3811      state:D stack:0     pid:25660 tgid:25638 ppid:20649  task_flags:0x400040 flags:0x00800001
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:7531
 rwsem_down_read_slowpath+0x544/0x7f8 kernel/locking/rwsem.c:1114
 __down_read_common kernel/locking/rwsem.c:1291 [inline]
 __down_read kernel/locking/rwsem.c:1304 [inline]
 down_read+0xa0/0x2bc kernel/locking/rwsem.c:1576
 __super_lock fs/super.c:62 [inline]
 super_lock+0x258/0x344 fs/super.c:124
 user_get_super+0xb8/0x1bc fs/super.c:1022
 quotactl_block fs/quota/quota.c:889 [inline]
 __do_sys_quotactl fs/quota/quota.c:955 [inline]
 __se_sys_quotactl fs/quota/quota.c:917 [inline]
 __arm64_sys_quotactl+0x4c8/0x90c fs/quota/quota.c:917
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
INFO: task syz.0.3808:25667 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.0.3808      state:D stack:0     pid:25667 tgid:25642 ppid:21229  task_flags:0x400140 flags:0x00800001
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:7531
 __mutex_lock_common kernel/locking/mutex.c:726 [inline]
 __mutex_lock+0x5d8/0x10b8 kernel/locking/mutex.c:821
 mutex_lock_nested+0x24/0x30 kernel/locking/mutex.c:874
 bdev_freeze+0x38/0x2e8 block/bdev.c:304
 ext4_force_shutdown+0x288/0x5ac fs/ext4/ioctl.c:826
 ext4_ioctl_shutdown fs/ext4/ioctl.c:868 [inline]
 __ext4_ioctl fs/ext4/ioctl.c:1888 [inline]
 ext4_ioctl+0x21dc/0x4430 fs/ext4/ioctl.c:1932
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl fs/ioctl.c:583 [inline]
 __arm64_sys_ioctl+0x154/0x1cc fs/ioctl.c:583
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
INFO: task syz.2.3812:25664 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.2.3812      state:D stack:0     pid:25664 tgid:25645 ppid:21748  task_flags:0x400140 flags:0x00800001
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:7531
 __mutex_lock_common kernel/locking/mutex.c:726 [inline]
 __mutex_lock+0x5d8/0x10b8 kernel/locking/mutex.c:821
 mutex_lock_nested+0x24/0x30 kernel/locking/mutex.c:874
 bdev_freeze+0x38/0x2e8 block/bdev.c:304
 ext4_force_shutdown+0x288/0x5ac fs/ext4/ioctl.c:826
 ext4_ioctl_shutdown fs/ext4/ioctl.c:868 [inline]
 __ext4_ioctl fs/ext4/ioctl.c:1888 [inline]
 ext4_ioctl+0x21dc/0x4430 fs/ext4/ioctl.c:1932
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl fs/ioctl.c:583 [inline]
 __arm64_sys_ioctl+0x154/0x1cc fs/ioctl.c:583
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
INFO: task syz.2.3812:25665 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.2.3812      state:D stack:0     pid:25665 tgid:25645 ppid:21748  task_flags:0x400040 flags:0x00800001
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:7531
 rwsem_down_read_slowpath+0x544/0x7f8 kernel/locking/rwsem.c:1114
 __down_read_common kernel/locking/rwsem.c:1291 [inline]
 __down_read kernel/locking/rwsem.c:1304 [inline]
 down_read+0xa0/0x2bc kernel/locking/rwsem.c:1576
 __super_lock fs/super.c:62 [inline]
 super_lock+0x258/0x344 fs/super.c:124
 user_get_super+0xb8/0x1bc fs/super.c:1022
 quotactl_block fs/quota/quota.c:889 [inline]
 __do_sys_quotactl fs/quota/quota.c:955 [inline]
 __se_sys_quotactl fs/quota/quota.c:917 [inline]
 __arm64_sys_quotactl+0x4c8/0x90c fs/quota/quota.c:917
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606
INFO: task kmmpd-loop1:25649 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kmmpd-loop1     state:D stack:0     pid:25649 tgid:25649 ppid:2      task_flags:0x208040 flags:0x00000010
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 percpu_rwsem_wait+0x2a0/0x2f8 kernel/locking/percpu-rwsem.c:164
 __percpu_down_read+0x84/0xb4 kernel/locking/percpu-rwsem.c:180
 percpu_down_read_internal include/linux/percpu-rwsem.h:67 [inline]
 percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline]
 __sb_start_write include/linux/fs/super.h:19 [inline]
 sb_start_write include/linux/fs/super.h:125 [inline]
 class_super_write_constructor include/linux/fs/super.h:130 [inline]
 write_mmp_block+0x358/0x3e4 fs/ext4/mmp.c:63
 kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
 kthread+0x304/0x3d4 kernel/kthread.c:436
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:854
INFO: task kmmpd-loop2:25651 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kmmpd-loop2     state:D stack:0     pid:25651 tgid:25651 ppid:2      task_flags:0x208040 flags:0x00000010
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 percpu_rwsem_wait+0x2a0/0x2f8 kernel/locking/percpu-rwsem.c:164
 __percpu_down_read+0x84/0xb4 kernel/locking/percpu-rwsem.c:180
 percpu_down_read_internal include/linux/percpu-rwsem.h:67 [inline]
 percpu_down_read_freezable include/linux/percpu-rwsem.h:83 [inline]
 __sb_start_write include/linux/fs/super.h:19 [inline]
 sb_start_write include/linux/fs/super.h:125 [inline]
 class_super_write_constructor include/linux/fs/super.h:130 [inline]
 write_mmp_block+0x358/0x3e4 fs/ext4/mmp.c:63
 kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
 kthread+0x304/0x3d4 kernel/kthread.c:436
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:854
INFO: task syz.3.3813:25671 blocked for more than 144 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.3.3813      state:D stack:0     pid:25671 tgid:25657 ppid:22407  task_flags:0x400140 flags:0x00000001
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5583 [inline]
 __schedule+0x1368/0x2b50 kernel/sched/core.c:7382
 __schedule_loop kernel/sched/core.c:7459 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7474
 schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:7531
 __mutex_lock_common kernel/locking/mutex.c:726 [inline]
 __mutex_lock+0x5d8/0x10b8 kernel/locking/mutex.c:821
 mutex_lock_nested+0x24/0x30 kernel/locking/mutex.c:874
 bdev_freeze+0x38/0x2e8 block/bdev.c:304
 ext4_force_shutdown+0x288/0x5ac fs/ext4/ioctl.c:826
 ext4_ioctl_shutdown fs/ext4/ioctl.c:868 [inline]
 __ext4_ioctl fs/ext4/ioctl.c:1888 [inline]
 ext4_ioctl+0x21dc/0x4430 fs/ext4/ioctl.c:1932
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl fs/ioctl.c:583 [inline]
 __arm64_sys_ioctl+0x154/0x1cc fs/ioctl.c:583
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606

Showing all locks held in the system:
locks held by kworker/u8:0/12: 2, on CPU#1:
 #0: ffff0000c004c148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c004c148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff80008fa47c20 ((work_completion)(&sub_info->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff80008fa47c20 ((work_completion)(&sub_info->work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
locks held by khungtaskd/31: 1, last CPU#1:
 #0: ffff800089aa56a0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
 #0: ffff800089aa56a0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #0: ffff800089aa56a0 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x4c/0x188 kernel/locking/lockdep.c:6871
locks held by kworker/u8:2/40: 3, last CPU#1:
 #0: ffff0000c004b948 ((wq_completion)events_power_efficient){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c004b948 ((wq_completion)events_power_efficient){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff800090f97c20 ((work_completion)(&(&par->cursor_work)->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff800090f97c20 ((work_completion)(&(&par->cursor_work)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff800089a9ada0 (console_lock){+.+.}-{0:0}, at: fb_flashcursor+0x28/0x398 drivers/video/fbdev/core/fbcon.c:403
locks held by kworker/u8:3/42: 3, on CPU#0:
 #0: ffff0000c004c148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c004c148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff800090fb7c20 ((linkwatch_work).work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff800090fb7c20 ((linkwatch_work).work){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x20/0x2c net/core/rtnetlink.c:80
locks held by kworker/u8:4/63: 3, on CPU#0:
 #0: ffff0000c3d1e148 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c3d1e148 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff800092147c20 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff800092147c20 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x20/0x2c net/core/rtnetlink.c:80
locks held by kworker/u8:12/3416: 2, on CPU#0:
 #0: ffff0000c004c148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c004c148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff80009c0f7c20 ((work_completion)(&sub_info->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff80009c0f7c20 ((work_completion)(&sub_info->work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
locks held by getty/4496: 2, on CPU#0:
 #0: ffff0000cd6e50a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x3c/0x4c drivers/tty/tty_ldsem.c:340
 #1: ffff8000932bb2e8 (&ldata->atomic_read_lock){+.+.}-{4:4}, at: n_tty_read+0x350/0xffc drivers/tty/n_tty.c:2211
locks held by kworker/1:2/4689: 3, on CPU#1:
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff80009a037c20 (deferred_process_work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff80009a037c20 (deferred_process_work){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x20/0x2c net/core/rtnetlink.c:80
locks held by kworker/1:3/4758: 3, last CPU#1:
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff800099ee7c20 ((work_completion)(&data->fib_event_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff800099ee7c20 ((work_completion)(&data->fib_event_work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff0000cde94258 (&data->fib_lock){+.+.}-{4:4}, at: nsim_fib_event_work+0x198/0x320 drivers/net/netdevsim/fib.c:1490
locks held by kworker/1:4/4869: 3, on CPU#1:
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff8000966c7c20 ((work_completion)(&data->fib_event_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff8000966c7c20 ((work_completion)(&data->fib_event_work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff0000c8af0258 (&data->fib_lock){+.+.}-{4:4}, at: nsim_fib_event_work+0x198/0x320 drivers/net/netdevsim/fib.c:1490
locks held by kworker/1:5/5032: 4, on CPU#1:
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff80009b147c20 ((work_completion)(&helper->damage_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff80009b147c20 ((work_completion)(&helper->damage_work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff0000c6fc6270 (&helper->lock){+.+.}-{4:4}, at: drm_fb_helper_fb_dirty drivers/gpu/drm/clients/drm_fbdev_helper.c:295 [inline]
 #2: ffff0000c6fc6270 (&helper->lock){+.+.}-{4:4}, at: drm_fb_helper_damage_work+0x120/0xbc0 drivers/gpu/drm/clients/drm_fbdev_helper.c:336
 #3: ffff0000c6f80128 (&dev->master_mutex){+.+.}-{4:4}, at: drm_master_internal_acquire+0x24/0x78 drivers/gpu/drm/drm_auth.c:435
locks held by syz.1.3811/25641: 5, last CPU#1:
 #0: ffff0000c14946a0 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #1: ffff0000c9688478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #1: ffff0000c9688478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
 #2: ffff0000c9688100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock fs/super.c:60 [inline]
 #2: ffff0000c9688100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock_excl fs/super.c:75 [inline]
 #2: ffff0000c9688100 (&type->s_umount_key#32){++++}-{4:4}, at: freeze_super+0x4a0/0xf6c fs/super.c:2242
 #3: ffff0000c9688570 (sb_pagefaults){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #3: ffff0000c9688570 (sb_pagefaults){++++}-{0:0}, at: freeze_super+0x4b8/0xf6c fs/super.c:2246
 #4: ffff0000c9688668 (sb_internal){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #4: ffff0000c9688668 (sb_internal){++++}-{0:0}, at: freeze_super+0x780/0xf6c fs/super.c:2260
locks held by syz.1.3811/25659: 1, on CPU#1:
 #0: ffff0000c14946a0 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
locks held by syz.1.3811/25660: 1, on CPU#1:
 #0: ffff0000c9688100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock fs/super.c:62 [inline]
 #0: ffff0000c9688100 (&type->s_umount_key#32){++++}-{4:4}, at: super_lock+0x258/0x344 fs/super.c:124
locks held by syz.0.3808/25644: 2, last CPU#1:
 #0: ffff0000c1495220 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #1: ffff0000f0a58478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #1: ffff0000f0a58478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
locks held by syz.0.3808/25667: 1, on CPU#1:
 #0: ffff0000c1495220 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
locks held by syz.0.3808/25668: 1, last CPU#1:
 #0: ffff0000f0a58100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock fs/super.c:62 [inline]
 #0: ffff0000f0a58100 (&type->s_umount_key#32){++++}-{4:4}, at: super_lock+0x258/0x344 fs/super.c:124
locks held by syz.2.3812/25646: 4, last CPU#0:
 #0: ffff0000c1493b20 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #1: ffff0000ea2de478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #1: ffff0000ea2de478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
 #2: ffff0000ea2de100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock fs/super.c:60 [inline]
 #2: ffff0000ea2de100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock_excl fs/super.c:75 [inline]
 #2: ffff0000ea2de100 (&type->s_umount_key#32){++++}-{4:4}, at: freeze_super+0x4a0/0xf6c fs/super.c:2242
 #3: ffff0000ea2de570 (sb_pagefaults){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #3: ffff0000ea2de570 (sb_pagefaults){++++}-{0:0}, at: freeze_super+0x4b8/0xf6c fs/super.c:2246
locks held by syz.2.3812/25664: 1, on CPU#0:
 #0: ffff0000c1493b20 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
locks held by syz.2.3812/25665: 1, on CPU#0:
 #0: ffff0000ea2de100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock fs/super.c:62 [inline]
 #0: ffff0000ea2de100 (&type->s_umount_key#32){++++}-{4:4}, at: super_lock+0x258/0x344 fs/super.c:124
locks held by kmmpd-loop1/25649: 1, on CPU#1:
 #0: ffff0000c9688478 (sb_writers#3){++++}-{0:0}, at: kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
locks held by kmmpd-loop2/25651: 1, on CPU#1:
 #0: ffff0000ea2de478 (sb_writers#3){++++}-{0:0}, at: kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
locks held by syz.3.3813/25658: 2, last CPU#0:
 #0: ffff0000c1492fa0 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #1: ffff0000eab62478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #1: ffff0000eab62478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
locks held by syz.3.3813/25671: 1, on CPU#0:
 #0: ffff0000c1492fa0 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
locks held by syz.3.3813/25672: 1, last CPU#0:
 #0: ffff0000eab62478 (sb_writers#3){++++}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
 #0: ffff0000eab62478 (sb_writers#3){++++}-{0:0}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #0: ffff0000eab62478 (sb_writers#3){++++}-{0:0}, at: rcuwait_wake_up+0x38/0x25c kernel/exit.c:322
locks held by syz.4.3814/25662: 2, last CPU#0:
 #0: ffff0000c1492420 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #1: ffff0000da54c478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #1: ffff0000da54c478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
locks held by syz-executor/25983: 1, on CPU#1:
 #0: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x20/0x2c net/core/rtnetlink.c:80
locks held by syz-executor/26125: 7, on CPU#0:
 #0: ffff0000d11a0478 (sb_writers#6){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2762 [inline]
 #0: ffff0000d11a0478 (sb_writers#6){.+.+}-{0:0}, at: vfs_write+0x248/0xa0c fs/read_write.c:683
 #1: ffff0000c9acb880 (&of->mutex){+.+.}-{4:4}, at: kernfs_fop_write_iter+0x1b0/0x3b8 fs/kernfs/file.c:336
 #2: ffff0000ca4c5008 (kn->active#55){.+.+}-{0:0}, at: kernfs_get_active_of fs/kernfs/file.c:73 [inline]
 #2: ffff0000ca4c5008 (kn->active#55){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x1f0/0x3b8 fs/kernfs/file.c:337
 #3: ffff80008a3ad460 (nsim_bus_dev_list_lock){+.+.}-{4:4}, at: del_device_store+0xd8/0x2d4 drivers/net/netdevsim/bus.c:233
 #4: ffff0000da8f3128 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1109 [inline]
 #4: ffff0000da8f3128 (&dev->mutex){....}-{4:4}, at: __device_driver_lock+0x94/0xcc drivers/base/dd.c:1046
 #5: ffff0000da8f2258 (&devlink->lock_key#14){+.+.}-{4:4}, at: devl_lock+0x24/0x34 net/devlink/core.c:314
 #6: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x20/0x2c net/core/rtnetlink.c:80
locks held by syz-executor/26181: 3, on CPU#0:
 #0: ffff8000898bbaf8 (&ops->srcu#2){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:213 [inline]
 #0: ffff8000898bbaf8 (&ops->srcu#2){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:320 [inline]
 #0: ffff8000898bbaf8 (&ops->srcu#2){.+.+}-{0:0}, at: rtnl_link_ops_get+0x17c/0x26c net/core/rtnetlink.c:602
 #1: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock net/core/rtnetlink.c:80 [inline]
 #1: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_nets_lock+0x38/0x10c net/core/rtnetlink.c:366
 #2: ffff80008994a5a0 (wq_pool_mutex){+.+.}-{4:4}, at: __alloc_workqueue+0xa84/0x121c kernel/workqueue.c:6201
locks held by syz-executor/26191: 1, on CPU#0:
 #0: ffff80008abcf5a0 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock+0x20/0x2c net/core/rtnetlink.c:80

=============================================

---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

#1 lore raw

PATCH 1/1 ext4: make concurrent DEFAULT shutdown waits killable

From: Qing Zhang <[email protected]>

Concurrent DEFAULT shutdown callers can all pass the shutdown flag check before the first caller finishes bdev_freeze(). They then wait uninterruptibly on bd_fsfreeze_mutex and may perform redundant freeze/thaw operations, triggering hung-task reports if the initial freeze takes long enough.

Serialize DEFAULT shutdown attempts with a per-superblock mutex acquired killably. Re-check the shutdown flag after acquiring it to skip the freeze after a successful attempt, or retry if the previous attempt failed.

Leave LOGFLUSH and NOLOGFLUSH unchanged. The ->shutdown callback uses NOLOGFLUSH with s_umount held, so it must not acquire a mutex held across a freeze. This does not shorten the initial freeze or prevent hung-task reports for the active freezer and other freeze-blocked tasks.

Fixes 783d94854499 ("ext4: add EXT4_IOC_GOINGDOWN ioctl")
Reported-by [email protected]

---

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

 fs/ext4/ext4.h  |  1 +
 fs/ext4/ioctl.c | 14 +++++++++++++-
 fs/ext4/super.c |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)
fs/ext4/ext4.h +1 -0
index f38fec3167fb..c4e44e3d58cc 100644
@@ -1647,6 +1647,7 @@ struct ext4_sb_info {
 	/* Journaling */
 	struct journal_s *s_journal;
 	unsigned long s_ext4_flags;		/* Ext4 superblock flags */
+	struct mutex s_shutdown_lock;	/* Serializes DEFAULT shutdown requests */
 	struct mutex s_orphan_lock;	/* Protects on disk list changes */
 	struct list_head s_orphan;	/* List of orphaned inodes in on disk
 					   list */
fs/ext4/ioctl.c +13 -1
index e8e579498c99..3019b16320a0 100644
@@ -818,16 +818,28 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags)
 	if (ext4_forced_shutdown(sb))
 		return 0;
 
+	if (flags == EXT4_GOING_FLAGS_DEFAULT) {
+		if (mutex_lock_killable(&sbi->s_shutdown_lock))
+			return -EINTR;
+		if (ext4_forced_shutdown(sb)) {
+			mutex_unlock(&sbi->s_shutdown_lock);
+			return 0;
+		}
+	}
+
 	ext4_msg(sb, KERN_ALERT, "shut down requested (%d)", flags);
 	trace_ext4_shutdown(sb, flags);
 
 	switch (flags) {
 	case EXT4_GOING_FLAGS_DEFAULT:
 		ret = bdev_freeze(sb->s_bdev);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&sbi->s_shutdown_lock);
 			return ret;
+		}
 		set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
 		bdev_thaw(sb->s_bdev);
+		mutex_unlock(&sbi->s_shutdown_lock);
 		break;
 	case EXT4_GOING_FLAGS_LOGFLUSH:
 		/*
fs/ext4/super.c +1 -0
index 9cae52471dee..a1d4fc5c0a68 100644
@@ -5547,6 +5547,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 
 	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
 	mutex_init(&sbi->s_orphan_lock);
+	mutex_init(&sbi->s_shutdown_lock);
 
 	spin_lock_init(&sbi->s_bdev_wb_lock);
 
Signature · 1 line
2.43.7
#2 lore raw

Re: [PATCH] ext4: make concurrent DEFAULT shutdown waits killable

Sashiko has reviewed this patch and found no issues.
Quoted 19 lines

From: Qing Zhang <[email protected]>

Concurrent DEFAULT shutdown callers can all pass the shutdown flag check before the first caller finishes bdev_freeze(). They then wait uninterruptibly on bd_fsfreeze_mutex and may perform redundant freeze/thaw operations, triggering hung-task reports if the initial freeze takes long enough.

Serialize DEFAULT shutdown attempts with a per-superblock mutex acquired killably. Re-check the shutdown flag after acquiring it to skip the freeze after a successful attempt, or retry if the previous attempt failed.

Leave LOGFLUSH and NOLOGFLUSH unchanged. The ->shutdown callback uses NOLOGFLUSH with s_umount held, so it must not acquire a mutex held across a freeze. This does not shorten the initial freeze or prevent hung-task reports for the active freezer and other freeze-blocked tasks.

Quoted 4 lines
Fixes 783d94854499 ("ext4: add EXT4_IOC_GOINGDOWN ioctl")
Reported-by [email protected]

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer
#3 lore raw

Re: [PATCH] ext4: make concurrent DEFAULT shutdown waits killable

In reply to [email protected]
Quoted 19 lines · On Tue 10-11-26 21:21:18, [email protected] wrote:

From: Qing Zhang <[email protected]>

Concurrent DEFAULT shutdown callers can all pass the shutdown flag check before the first caller finishes bdev_freeze(). They then wait uninterruptibly on bd_fsfreeze_mutex and may perform redundant freeze/thaw operations, triggering hung-task reports if the initial freeze takes long enough.

Serialize DEFAULT shutdown attempts with a per-superblock mutex acquired killably. Re-check the shutdown flag after acquiring it to skip the freeze after a successful attempt, or retry if the previous attempt failed.

Leave LOGFLUSH and NOLOGFLUSH unchanged. The ->shutdown callback uses NOLOGFLUSH with s_umount held, so it must not acquire a mutex held across a freeze. This does not shorten the initial freeze or prevent hung-task reports for the active freezer and other freeze-blocked tasks.

Quoted 4 lines
Fixes 783d94854499 ("ext4: add EXT4_IOC_GOINGDOWN ioctl")
Reported-by [email protected]

Err, no. This is really syzkaller self-inflicted damage we aren't going to work around. If anything you could make the wait on bd_fsfreeze_mutex in bdev_freeze() killable. That will actually be a sensible change and should address syzbot warning as well.

Honza

Quoted 69 lines

---

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

 fs/ext4/ext4.h  |  1 +
 fs/ext4/ioctl.c | 14 +++++++++++++-
 fs/ext4/super.c |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)
fs/ext4/ext4.h +1 -0
index f38fec3167fb..c4e44e3d58cc 100644
@@ -1647,6 +1647,7 @@ struct ext4_sb_info {
 	/* Journaling */
 	struct journal_s *s_journal;
 	unsigned long s_ext4_flags;		/* Ext4 superblock flags */
+	struct mutex s_shutdown_lock;	/* Serializes DEFAULT shutdown requests */
 	struct mutex s_orphan_lock;	/* Protects on disk list changes */
 	struct list_head s_orphan;	/* List of orphaned inodes in on disk
 					   list */
fs/ext4/ioctl.c +13 -1
index e8e579498c99..3019b16320a0 100644
@@ -818,16 +818,28 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags)
 	if (ext4_forced_shutdown(sb))
 		return 0;
 
+	if (flags == EXT4_GOING_FLAGS_DEFAULT) {
+		if (mutex_lock_killable(&sbi->s_shutdown_lock))
+			return -EINTR;
+		if (ext4_forced_shutdown(sb)) {
+			mutex_unlock(&sbi->s_shutdown_lock);
+			return 0;
+		}
+	}
+
 	ext4_msg(sb, KERN_ALERT, "shut down requested (%d)", flags);
 	trace_ext4_shutdown(sb, flags);
 
 	switch (flags) {
 	case EXT4_GOING_FLAGS_DEFAULT:
 		ret = bdev_freeze(sb->s_bdev);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&sbi->s_shutdown_lock);
 			return ret;
+		}
 		set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
 		bdev_thaw(sb->s_bdev);
+		mutex_unlock(&sbi->s_shutdown_lock);
 		break;
 	case EXT4_GOING_FLAGS_LOGFLUSH:
 		/*
fs/ext4/super.c +1 -0
index 9cae52471dee..a1d4fc5c0a68 100644
@@ -5547,6 +5547,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 
 	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
 	mutex_init(&sbi->s_orphan_lock);
+	mutex_init(&sbi->s_shutdown_lock);
 
 	spin_lock_init(&sbi->s_bdev_wb_lock);
 
Signature · 1 line
2.43.7
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#4 lore raw

Re: [PATCH] ext4: make concurrent DEFAULT shutdown waits killable

Quoted 4 lines · Jan Kara

Err, no. This is really syzkaller self-inflicted damage we aren't going to work around. If anything you could make the wait on bd_fsfreeze_mutex in bdev_freeze() killable. That will actually be a sensible change and should address syzbot warning as well.

Thanks, that's indeed simpler. All current callers of bdev_freeze() (the generic FIFREEZE ioctl, ext4, ntfs, ntfs3, xfs) already propagate the error, so only the wait itself needs to change:

---

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

 block/bdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/bdev.c +3 -1
index f20f91b3176e..e57be2320423 100644
@@ -301,7 +301,9 @@ int bdev_freeze(struct block_device *bdev)
 {
 	int error = 0;
 
-	mutex_lock(&bdev->bd_fsfreeze_mutex);
+	error = mutex_lock_killable(&bdev->bd_fsfreeze_mutex);
+	if (error)
+		return error;
 
 	/* A device being removed from its filesystem refuses freezes. */
 	if (!atomic_inc_unless_negative(&bdev->bd_fsfreeze_count)) {
Signature · 1 line
2.43.7
#5 lore raw

Re: [PATCH] ext4: make concurrent DEFAULT shutdown waits killable

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] block: missing Signed-off-by trailer and real author name in commit - [Medium] block: commit message…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] block: missing Signed-off-by trailer and real author name in commit
- [Medium] block: commit message is a raw ext4 email reply with wrong bdev_freeze() info
--

commit b7fc68757e7a71c50d74a009f283890518f74c9a
Author: [email protected] <[email protected]>

Quoted 11 lines

ext4: make concurrent DEFAULT shutdown waits killable

Quoted 4 lines · Jan Kara

Err, no. This is really syzkaller self-inflicted damage we aren't going to work around. If anything you could make the wait on bd_fsfreeze_mutex in bdev_freeze() killable. That will actually be a sensible change and should address syzbot warning as well.

Thanks, that's indeed simpler. All current callers of bdev_freeze() (the generic FIFREEZE ioctl, ext4, ntfs, ntfs3, xfs) already propagate the error, so only the wait itself needs to change:

[Severity: High]
This commit is missing a Signed-off-by: trailer, and the Author header uses an email address instead of the author's real name.

[Severity: Medium]
Does the commit title and message match the change being made?

The patch modifies bdev_freeze() in block/bdev.c rather than ext4, and the changelog is formatted as an email reply rather than a standalone commit description. In addition, ioctl_fsfreeze() calls freeze_super() rather than bdev_freeze(), other callers exist (lock_fs(), exfat_force_shutdown(), and f2fs_do_shutdown()), and xfs_fs_goingdown() ignores non-zero returns from bdev_freeze() and returns 0 without calling xfs_force_shutdown().

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author syzbot
#6 lore raw
In reply to [email protected]
syzbot tried to test the proposed patch but the build/boot failed:

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to checkout kernel repo git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master: failed to run ["git" "-c" "core.hooksPath=/dev/null" "fetch" "--force" "f569e972c8e9057ee9c286220c83a480ebf30cc5" "master"]: exit status 128

Tested on:

commit:         [unknown 
git tree:       upstream
kernel config:  https://syzkaller.appspot.com/x/.config?x=a58b6b4d667e7a61
dashboard link: https://syzkaller.appspot.com/bug?extid=d4ecb9a1e5b3dcf8baec
compiler:       
userspace arch: arm64
patch:          https://syzkaller.appspot.com/x/patch.diff?x=17f58b69580000
author syzbot
#7 lore raw
In reply to [email protected]
syzbot has tested the proposed patch but the reproducer is still triggering an issue:

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:

INFO: task hung in user_get_super

INFO: task syz.4.3007:21757 blocked for more than 143 seconds.
      Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.4.3007      state:D stack:0     pid:21757 tgid:21733 ppid:5332   task_flags:0x400040 flags:0x00800001
Call trace:
 __switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:792 (T)
 context_switch kernel/sched/core.c:5584 [inline]
 __schedule+0x13a0/0x2bd4 kernel/sched/core.c:7389
 __schedule_loop kernel/sched/core.c:7466 [inline]
 schedule+0x13c/0x20c kernel/sched/core.c:7481
 schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:7538
 rwsem_down_read_slowpath+0x544/0x7f8 kernel/locking/rwsem.c:1114
 __down_read_common kernel/locking/rwsem.c:1291 [inline]
 __down_read kernel/locking/rwsem.c:1304 [inline]
 down_read+0xa0/0x2bc kernel/locking/rwsem.c:1576
 __super_lock fs/super.c:62 [inline]
 super_lock+0x258/0x344 fs/super.c:124
 user_get_super+0xb8/0x1bc fs/super.c:1022
 quotactl_block fs/quota/quota.c:889 [inline]
 __do_sys_quotactl fs/quota/quota.c:955 [inline]
 __se_sys_quotactl fs/quota/quota.c:917 [inline]
 __arm64_sys_quotactl+0x4c8/0x90c fs/quota/quota.c:917
 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797
 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816
 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606

Showing all locks held in the system:
locks held by khungtaskd/32: 1, on CPU#0:
 #0: ffff800089ab5660 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
 #0: ffff800089ab5660 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #0: ffff800089ab5660 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x4c/0x188 kernel/locking/lockdep.c:6871
locks held by kworker/u9:0/50: 3, last CPU#0:
 #0: ffff0000ca34d948 ((wq_completion)hci9){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000ca34d948 ((wq_completion)hci9){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff800092057c20 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff800092057c20 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff0000f0c1cea0 (&hdev->req_lock){+.+.}-{4:4}, at: hci_cmd_sync_work+0x1b0/0x380 net/bluetooth/hci_sync.c:337
locks held by getty/4498: 2, last CPU#1:
 #0: ffff0000ca5e80a0 (&tty->ldisc_sem){++++}-{0:0}, at: ldsem_down_read+0x3c/0x4c drivers/tty/tty_ldsem.c:340
 #1: ffff8000932de2e8 (&ldata->atomic_read_lock){+.+.}-{4:4}, at: n_tty_read+0x350/0xffc drivers/tty/n_tty.c:2211
locks held by kworker/1:5/5820: 3, on CPU#1:
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c002ad48 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff800093847c20 ((work_completion)(&data->fib_event_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff800093847c20 ((work_completion)(&data->fib_event_work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff0000ccb4d258 (&data->fib_lock){+.+.}-{4:4}, at: nsim_fib_event_work+0x198/0x320 drivers/net/netdevsim/fib.c:1490
locks held by syz.2.3009/21731: 3, on CPU#1:
 #0: ffff0000c6600470 (&sbi->s_shutdown_lock){+.+.}-{4:4}, at: ext4_force_shutdown+0x17c/0x658 fs/ext4/ioctl.c:822
 #1: ffff0000c148f4a0 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #2: ffff0000d39a0478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #2: ffff0000d39a0478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
locks held by syz.2.3009/21762: 1, on CPU#1:
 #0: ffff0000c6600470 (&sbi->s_shutdown_lock){+.+.}-{4:4}, at: ext4_force_shutdown+0x17c/0x658 fs/ext4/ioctl.c:822
locks held by syz.2.3009/21763: 1, on CPU#1:
 #0: ffff0000d39a0100 (&type->s_umount_key#32){++++}-{4:4}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
 #0: ffff0000d39a0100 (&type->s_umount_key#32){++++}-{4:4}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #0: ffff0000d39a0100 (&type->s_umount_key#32){++++}-{4:4}, at: rcuwait_wake_up+0x38/0x25c kernel/exit.c:322
locks held by syz.4.3007/21734: 5, on CPU#1:
 #0: ffff0000d6314470 (&sbi->s_shutdown_lock){+.+.}-{4:4}, at: ext4_force_shutdown+0x17c/0x658 fs/ext4/ioctl.c:822
 #1: ffff0000c148dda0 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #2: ffff0000d1490478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #2: ffff0000d1490478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
 #3: ffff0000d1490100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock fs/super.c:60 [inline]
 #3: ffff0000d1490100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock_excl fs/super.c:75 [inline]
 #3: ffff0000d1490100 (&type->s_umount_key#32){++++}-{4:4}, at: freeze_super+0x4a0/0xf6c fs/super.c:2242
 #4: ffff0000d1490570 (sb_pagefaults){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #4: ffff0000d1490570 (sb_pagefaults){++++}-{0:0}, at: freeze_super+0x4b8/0xf6c fs/super.c:2246
locks held by syz.4.3007/21756: 1, on CPU#1:
 #0: ffff0000d6314470 (&sbi->s_shutdown_lock){+.+.}-{4:4}, at: ext4_force_shutdown+0x17c/0x658 fs/ext4/ioctl.c:822
locks held by syz.4.3007/21757: 1, last CPU#1:
 #0: ffff0000d1490100 (&type->s_umount_key#32){++++}-{4:4}, at: __super_lock fs/super.c:62 [inline]
 #0: ffff0000d1490100 (&type->s_umount_key#32){++++}-{4:4}, at: super_lock+0x258/0x344 fs/super.c:124
locks held by syz.1.3010/21737: 3, on CPU#1:
 #0: ffff0000ef804470 (&sbi->s_shutdown_lock){+.+.}-{4:4}, at: ext4_force_shutdown+0x17c/0x658 fs/ext4/ioctl.c:822
 #1: ffff0000c154dda0 (&bdev->bd_fsfreeze_mutex){+.+.}-{4:4}, at: bdev_freeze+0x38/0x2e8 block/bdev.c:304
 #2: ffff0000eee66478 (sb_writers#3){++++}-{0:0}, at: sb_wait_write fs/super.c:1977 [inline]
 #2: ffff0000eee66478 (sb_writers#3){++++}-{0:0}, at: freeze_super+0x498/0xf6c fs/super.c:2241
locks held by syz.1.3010/21767: 1, on CPU#0:
 #0: ffff0000ef804470 (&sbi->s_shutdown_lock){+.+.}-{4:4}, at: ext4_force_shutdown+0x17c/0x658 fs/ext4/ioctl.c:822
locks held by syz.1.3010/21768: 1, on CPU#0:
 #0: ffff0000eee66478 (sb_writers#3){++++}-{0:0}, at: __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
 #0: ffff0000eee66478 (sb_writers#3){++++}-{0:0}, at: invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
locks held by kmmpd-loop4/21743: 1, last CPU#1:
 #0: ffff0000d1490478 (sb_writers#3){++++}-{0:0}, at: kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
locks held by kmmpd-loop3/21772: 1, last CPU#1:
 #0: ffff0000eedc6478 (sb_writers#3){++++}-{0:0}, at: kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
locks held by kmmpd-loop0/21796: 1, last CPU#1:
 #0: ffff0000eb87c478 (sb_writers#3){++++}-{0:0}, at: kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
locks held by kworker/u9:4/21931: 3, last CPU#0:
 #0: ffff0000c98bf148 ((wq_completion)hci8){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #0: ffff0000c98bf148 ((wq_completion)hci8){+.+.}-{0:0}, at: process_scheduled_works+0x8c8/0x1250 kernel/workqueue.c:3578
 #1: ffff800098197c20 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3470 [inline]
 #1: ffff800098197c20 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: process_scheduled_works+0x8d0/0x1250 kernel/workqueue.c:3578
 #2: ffff0000ec4b0ea0 (&hdev->req_lock){+.+.}-{4:4}, at: hci_cmd_sync_work+0x1b0/0x380 net/bluetooth/hci_sync.c:337
locks held by kmmpd-loop9/22058: 1, last CPU#1:
 #0: ffff0000c3d98478 (sb_writers#3){++++}-{0:0}, at: kmmpd+0x2fc/0x938 fs/ext4/mmp.c:173
locks held by syz-executor/22236: 6, last CPU#1:
 #0: ffff0000d0912478 (sb_writers#6){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2765 [inline]
 #0: ffff0000d0912478 (sb_writers#6){.+.+}-{0:0}, at: vfs_write+0x248/0xa0c fs/read_write.c:663
 #1: ffff0000f6abf480 (&of->mutex){+.+.}-{4:4}, at: kernfs_fop_write_iter+0x1b0/0x3b8 fs/kernfs/file.c:336
 #2: ffff0000ca778e18 (kn->active#55){.+.+}-{0:0}, at: kernfs_get_active_of fs/kernfs/file.c:73 [inline]
 #2: ffff0000ca778e18 (kn->active#55){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x1f0/0x3b8 fs/kernfs/file.c:337
 #3: ffff80008a3bd8a0 (nsim_bus_dev_list_lock){+.+.}-{4:4}, at: del_device_store+0xd8/0x2d4 drivers/net/netdevsim/bus.c:233
 #4: ffff0000cfcc6128 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1109 [inline]
 #4: ffff0000cfcc6128 (&dev->mutex){....}-{4:4}, at: __device_driver_lock+0x94/0xcc drivers/base/dd.c:1046
 #5: ffff0000cfcc5258 (&devlink->lock_key#13){+.+.}-{4:4}, at: devl_lock+0x24/0x34 net/devlink/core.c:314
locks held by syz-executor/22244: 4, last CPU#1:
 #0: ffff0000d0912478 (sb_writers#6){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2765 [inline]
 #0: ffff0000d0912478 (sb_writers#6){.+.+}-{0:0}, at: vfs_write+0x248/0xa0c fs/read_write.c:663
 #1: ffff0000ec554080 (&of->mutex){+.+.}-{4:4}, at: kernfs_fop_write_iter+0x1b0/0x3b8 fs/kernfs/file.c:336
 #2: ffff0000ca778e18 (kn->active#55){.+.+}-{0:0}, at: kernfs_get_active_of fs/kernfs/file.c:73 [inline]
 #2: ffff0000ca778e18 (kn->active#55){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x1f0/0x3b8 fs/kernfs/file.c:337
 #3: ffff80008a3bd8a0 (nsim_bus_dev_list_lock){+.+.}-{4:4}, at: del_device_store+0xd8/0x2d4 drivers/net/netdevsim/bus.c:233

=============================================

Tested on:

commit:         067c5c24 Merge tag 'page_alloc-for-7.4-rc2' of git://g..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=110505a1580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c06331d9bb9c8204
dashboard link: https://syzkaller.appspot.com/bug?extid=d4ecb9a1e5b3dcf8baec
compiler:       Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
userspace arch: arm64
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1314b1a1580000
#8 lore raw

PATCH v2 1/1 block: make bdev_freeze() mutex waits killable

In reply to [email protected]

From: Qing Zhang <[email protected]>

Concurrent bdev_freeze() callers may wait a long time on bd_fsfreeze_mutex while another caller freezes and syncs the filesystem. Use mutex_lock_killable() to allow fatal signals to interrupt this wait.

An interrupted wait returns -EINTR before bd_fsfreeze_count is incremented, so no freeze reference needs to be dropped. This does not make the filesystem freeze operation itself killable.

---
Changes since v1:
- per Jan's suggestion, move the killable wait from a new ext4 per-superblock mutex into bdev_freeze() itself.

block/bdev.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
block/bdev.c +3 -1
index f20f91b3176e..e57be2320423 100644
@@ -301,7 +301,9 @@ int bdev_freeze(struct block_device *bdev)
 {
 	int error = 0;
 
-	mutex_lock(&bdev->bd_fsfreeze_mutex);
+	error = mutex_lock_killable(&bdev->bd_fsfreeze_mutex);
+	if (error)
+		return error;
 
 	/* A device being removed from its filesystem refuses freezes. */
 	if (!atomic_inc_unless_negative(&bdev->bd_fsfreeze_count)) {
Signature · 1 line
2.43.7
#9 lore raw

Re: [PATCH v2] block: make bdev_freeze() mutex waits killable

Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

From: Qing Zhang <[email protected]>

Concurrent bdev_freeze() callers may wait a long time on bd_fsfreeze_mutex while another caller freezes and syncs the filesystem. Use mutex_lock_killable() to allow fatal signals to interrupt this wait.

Quoted 8 lines

An interrupted wait returns -EINTR before bd_fsfreeze_count is incremented, so no freeze reference needs to be dropped. This does not make the filesystem freeze operation itself killable.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer Reviewed-by on v2 1/1
#10 lore raw

Re: [PATCH v2] block: make bdev_freeze() mutex waits killable

In reply to [email protected]
Quoted 6 lines · On Wed 11-11-26 20:35:29, [email protected] wrote:

From: Qing Zhang <[email protected]>

Concurrent bdev_freeze() callers may wait a long time on bd_fsfreeze_mutex while another caller freezes and syncs the filesystem. Use mutex_lock_killable() to allow fatal signals to interrupt this wait.

Quoted 8 lines

An interrupted wait returns -EINTR before bd_fsfreeze_count is incremented, so no freeze reference needs to be dropped. This does not make the filesystem freeze operation itself killable.

Looks good to me. Feel free to add:

Honza

Quoted 26 lines

---
Changes since v1:
- per Jan's suggestion, move the killable wait from a new ext4 per-superblock mutex into bdev_freeze() itself.

block/bdev.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
block/bdev.c +3 -1
index f20f91b3176e..e57be2320423 100644
@@ -301,7 +301,9 @@ int bdev_freeze(struct block_device *bdev)
 {
 	int error = 0;
 
-	mutex_lock(&bdev->bd_fsfreeze_mutex);
+	error = mutex_lock_killable(&bdev->bd_fsfreeze_mutex);
+	if (error)
+		return error;
 
 	/* A device being removed from its filesystem refuses freezes. */
 	if (!atomic_inc_unless_negative(&bdev->bd_fsfreeze_count)) {
Signature · 1 line
2.43.7
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR