====================================================== WARNING: possible circular locking dependency detected 6.1.97-syzkaller #0 Not tainted ------------------------------------------------------ syz.4.681/6966 is trying to acquire lock: ffff0000f2914ae0 (&sdp->sd_quota_mutex){+.+.}-{3:3}, at: do_qc+0xbc/0x664 fs/gfs2/quota.c:682 but task is already holding lock: ffff0000eedd34f0 (&ip->i_rw_mutex){++++}-{3:3}, at: __gfs2_iomap_alloc+0x210/0x17a0 fs/gfs2/bmap.c:679 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&ip->i_rw_mutex){++++}-{3:3}: down_read+0x64/0x308 kernel/locking/rwsem.c:1520 __gfs2_iomap_get+0x138/0x1058 fs/gfs2/bmap.c:856 gfs2_iomap_get+0xd8/0x154 fs/gfs2/bmap.c:1396 bh_get+0x208/0x6ac fs/gfs2/quota.c:385 qdsb_get+0x1e0/0x398 fs/gfs2/quota.c:522 gfs2_quota_hold+0x16c/0x558 fs/gfs2/quota.c:608 gfs2_quota_lock+0xbc/0x404 fs/gfs2/quota.c:1076 gfs2_quota_lock_check fs/gfs2/quota.h:50 [inline] alloc_dinode+0x180/0x478 fs/gfs2/inode.c:393 gfs2_create_inode+0xc58/0x1548 fs/gfs2/inode.c:711 gfs2_atomic_open+0xd8/0x1c4 fs/gfs2/inode.c:1292 atomic_open fs/namei.c:3347 [inline] lookup_open fs/namei.c:3455 [inline] open_last_lookups fs/namei.c:3552 [inline] path_openat+0xbf8/0x2548 fs/namei.c:3782 do_filp_open+0x1bc/0x3cc fs/namei.c:3812 do_sys_openat2+0x128/0x3d8 fs/open.c:1318 do_sys_open fs/open.c:1334 [inline] __do_sys_openat fs/open.c:1350 [inline] __se_sys_openat fs/open.c:1345 [inline] __arm64_sys_openat+0x1f0/0x240 fs/open.c:1345 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 -> #0 (&sdp->sd_quota_mutex){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:3090 [inline] check_prevs_add kernel/locking/lockdep.c:3209 [inline] validate_chain kernel/locking/lockdep.c:3825 [inline] __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799 do_qc+0xbc/0x664 fs/gfs2/quota.c:682 gfs2_quota_change+0x238/0x718 fs/gfs2/quota.c:1295 gfs2_alloc_blocks+0x174c/0x207c fs/gfs2/rgrp.c:2494 __gfs2_iomap_alloc+0x3b8/0x17a0 fs/gfs2/bmap.c:705 gfs2_iomap_alloc+0x138/0x1d0 fs/gfs2/bmap.c:1409 gfs2_allocate_page_backing+0x10c/0x204 fs/gfs2/file.c:394 gfs2_page_mkwrite+0x12c4/0x179c fs/gfs2/file.c:524 do_page_mkwrite+0x144/0x37c mm/memory.c:2992 do_shared_fault mm/memory.c:4677 [inline] do_fault mm/memory.c:4745 [inline] handle_pte_fault mm/memory.c:5013 [inline] __handle_mm_fault mm/memory.c:5155 [inline] handle_mm_fault+0x1898/0x3ef0 mm/memory.c:5276 __do_page_fault arch/arm64/mm/fault.c:499 [inline] do_page_fault+0x330/0x890 arch/arm64/mm/fault.c:583 do_translation_fault+0x94/0xc8 arch/arm64/mm/fault.c:667 do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:803 el1_abort+0x3c/0x5c arch/arm64/kernel/entry-common.c:367 el1h_64_sync_handler+0x60/0xac arch/arm64/kernel/entry-common.c:427 el1h_64_sync+0x64/0x68 arch/arm64/kernel/entry.S:580 __arch_copy_to_user+0xcc/0x234 arch/arm64/lib/copy_template.S:115 copy_to_sockptr include/linux/sockptr.h:69 [inline] sock_getbindtodevice+0x1f4/0x400 net/core/sock.c:744 sk_getsockopt+0x8b4/0x23ec net/core/sock.c:1839 sock_getsockopt+0x64/0x78 net/core/sock.c:1973 __sys_getsockopt+0x18c/0x484 net/socket.c:2323 __do_sys_getsockopt net/socket.c:2342 [inline] __se_sys_getsockopt net/socket.c:2339 [inline] __arm64_sys_getsockopt+0xb8/0xd4 net/socket.c:2339 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&ip->i_rw_mutex); lock(&sdp->sd_quota_mutex); lock(&ip->i_rw_mutex); lock(&sdp->sd_quota_mutex); *** DEADLOCK *** 5 locks held by syz.4.681/6966: #0: ffff0000d9ab2b48 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline] #0: ffff0000d9ab2b48 (&mm->mmap_lock){++++}-{3:3}, at: get_mmap_lock_carefully mm/memory.c:5304 [inline] #0: ffff0000d9ab2b48 (&mm->mmap_lock){++++}-{3:3}, at: lock_mm_and_find_vma+0x38/0x2e8 mm/memory.c:5366 #1: ffff0000f12ee558 (sb_pagefaults#3){.+.+}-{0:0}, at: do_page_mkwrite+0x144/0x37c mm/memory.c:2992 #2: ffff0000f12ee650 (sb_internal#5){.+.+}-{0:0}, at: gfs2_trans_begin+0xa8/0x11c fs/gfs2/trans.c:118 #3: ffff0000f2915058 (&sdp->sd_log_flush_lock){.+.+}-{3:3}, at: __gfs2_trans_begin+0x524/0x91c fs/gfs2/trans.c:87 #4: ffff0000eedd34f0 (&ip->i_rw_mutex){++++}-{3:3}, at: __gfs2_iomap_alloc+0x210/0x17a0 fs/gfs2/bmap.c:679 stack backtrace: CPU: 1 PID: 6966 Comm: syz.4.681 Not tainted 6.1.97-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Call trace: dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106 dump_stack+0x1c/0x5c lib/dump_stack.c:113 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2048 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2170 check_prev_add kernel/locking/lockdep.c:3090 [inline] check_prevs_add kernel/locking/lockdep.c:3209 [inline] validate_chain kernel/locking/lockdep.c:3825 [inline] __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662 __mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603 __mutex_lock kernel/locking/mutex.c:747 [inline] mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799 do_qc+0xbc/0x664 fs/gfs2/quota.c:682 gfs2_quota_change+0x238/0x718 fs/gfs2/quota.c:1295 gfs2_alloc_blocks+0x174c/0x207c fs/gfs2/rgrp.c:2494 __gfs2_iomap_alloc+0x3b8/0x17a0 fs/gfs2/bmap.c:705 gfs2_iomap_alloc+0x138/0x1d0 fs/gfs2/bmap.c:1409 gfs2_allocate_page_backing+0x10c/0x204 fs/gfs2/file.c:394 gfs2_page_mkwrite+0x12c4/0x179c fs/gfs2/file.c:524 do_page_mkwrite+0x144/0x37c mm/memory.c:2992 do_shared_fault mm/memory.c:4677 [inline] do_fault mm/memory.c:4745 [inline] handle_pte_fault mm/memory.c:5013 [inline] __handle_mm_fault mm/memory.c:5155 [inline] handle_mm_fault+0x1898/0x3ef0 mm/memory.c:5276 __do_page_fault arch/arm64/mm/fault.c:499 [inline] do_page_fault+0x330/0x890 arch/arm64/mm/fault.c:583 do_translation_fault+0x94/0xc8 arch/arm64/mm/fault.c:667 do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:803 el1_abort+0x3c/0x5c arch/arm64/kernel/entry-common.c:367 el1h_64_sync_handler+0x60/0xac arch/arm64/kernel/entry-common.c:427 el1h_64_sync+0x64/0x68 arch/arm64/kernel/entry.S:580 __arch_copy_to_user+0xcc/0x234 arch/arm64/lib/copy_template.S:115 copy_to_sockptr include/linux/sockptr.h:69 [inline] sock_getbindtodevice+0x1f4/0x400 net/core/sock.c:744 sk_getsockopt+0x8b4/0x23ec net/core/sock.c:1839 sock_getsockopt+0x64/0x78 net/core/sock.c:1973 __sys_getsockopt+0x18c/0x484 net/socket.c:2323 __do_sys_getsockopt net/socket.c:2342 [inline] __se_sys_getsockopt net/socket.c:2339 [inline] __arm64_sys_getsockopt+0xb8/0xd4 net/socket.c:2339 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585