INFO: trying to register non-static key in gfs2_release_folio

Status: moderation: reported on 2026/11/29 22:47
Subsystems: gfs2
Labels: prio:high
[Documentation on labels]
Reported-by: syzbot+fe881ed116d2e8a0eb72@syzkaller.appspotmail.com
First crash: 1h57m, last: 1h57m
✨ AI cause bisection: introduced by (AI job) :
commit b886e0e5de6e7b15ddb302d824ba6a6bb3622c5b
Author: Andreas Gruenbacher <agruenba@redhat.com>
Date: Thu Nov 12 18:58:36 2026 +0000

  gfs2: keep glocks alive while they have active buffers

✨ AI-generated root cause summary:

In gfs2_fill_super() (fs/gfs2/ops_fstype.c), the mount-failure error path frees the superblock private structure via free_sbd(sdp) without waiting for glock disposal (gfs2_wait_glocks(sdp)), flushing deferred delete work (gfs2_flush_delete_work(sdp)), or calling rcu_barrier(), and calls gfs2_lm_unmount(sdp) before destroying sdp->sd_glock_wq. Consequently, GLOF_ASPACE glocks (struct gfs2_glock_aspace, whose embedded mapping uses gfs2_meta_aops) can outlive free_sbd(sdp) with cached metadata folios still on the LRU and a dangling gla->glock.gl_name.ln_sbd pointer. When memory reclaim later invokes shrink_folio_list() -> filemap_release_folio() -> gfs2_release_folio(), gfs2_mapping2sbd(folio->mapping) returns the freed and reallocated sdp pointer, and spin_lock(&sdp->sd_log_lock) operates on arbitrary reallocated heap memory, triggering the Lockdep non-static key error and the UBSAN out-of-bounds tail-CPU index in decode_tail().

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit e5aad2bdbbee:

Root Cause Analysis

The crash occurs because gfs2_fill_super() (fs/gfs2/ops_fstype.c) can free struct gfs2_sbd *sdp via free_sbd(sdp) while struct gfs2_glock_aspace (gla) objectsβ€”along with cached metadata folios in gla->mappingβ€”remain alive, leaving a dangling gla->glock.gl_name.ln_sbd pointer that is later dereferenced during folio reclaim in gfs2_release_folio().

1. Crash Mechanism in gfs2_release_folio()

During memory reclaim (mem_cgroup_resize_max() -> shrink_folio_list() -> filemap_release_folio()), gfs2_release_folio() (fs/gfs2/aops.c:649-671) obtains sdp via gfs2_mapping2sbd(folio->mapping) (fs/gfs2/meta_io.h:40-49) and acquires spin_lock(&sdp->sd_log_lock):

static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping)
{
	struct inode *inode = mapping->host;
	if (mapping->a_ops == &gfs2_meta_aops) {
		struct gfs2_glock_aspace *gla =
			container_of(mapping, struct gfs2_glock_aspace, mapping);
		return glock_sbd(&gla->glock);
	} else
		return inode->i_sb->s_fs_info;
}
  • Only gfs2_meta_aops, gfs2_rgrp_aops, and gfs2_jdata_aops use gfs2_release_folio().
  • For gfs2_rgrp_aops and gfs2_jdata_aops, gfs2_mapping2sbd() reads inode->i_sb->s_fs_info, which free_sbd() (fs/gfs2/ops_fstype.c:66-73) explicitly clears to NULL before calling kfree(sdp).
  • For gfs2_meta_aops, folio->mapping is gla->mapping embedded in a struct gfs2_glock_aspace (GLOF_ASPACE, used by gfs2_inode_glops), and glock_sbd(&gla->glock) returns gla->glock.gl_name.ln_sbd.
  • Because gla is still allocated (KASAN does not report a UAF on folio->mapping) while sdp points to a freed and reallocated kmalloc-8k object, &sdp->sd_log_lock resolves to arbitrary reallocated heap memory:
    1. register_lock_class() -> assign_lock_key() sees lock->key == NULL and !static_obj(lock), emitting INFO: trying to register non-static key and calling debug_locks_off().
    2. With debug_locks disabled, debug_spin_lock_before() skips SPINLOCK_MAGIC validation, allowing queued_spin_lock_slowpath() -> __pv_queued_spin_lock_slowpath() -> decode_tail() (kernel/locking/qspinlock.h:68) to decode a corrupted tail CPU index (2460 on an 8-CPU system), triggering the UBSAN array-index-out-of-bounds splat.

2. Incomplete Teardown in gfs2_fill_super()

The only place where gla->mapping is truncated and emptied is __gfs2_glock_put() (fs/gfs2/glock.c:230-234), which calls truncate_inode_pages_final(mapping) when the glock's reference count reaches zero.

During a normal unmount (gfs2_kill_sb() in fs/gfs2/ops_fstype.c:1770-1798 and gfs2_put_super() in fs/gfs2/super.c:592-663), GFS2 properly drains all workqueues and glocks before freeing sdp:

  1. gfs2_evict_inodes(sb)
  2. gfs2_flush_delete_work(sdp) followed by destroy_workqueue(sdp->sd_delete_wq)
  3. gfs2_wait_glocks(sdp) (fs/gfs2/glock.c:2018-2040), which waits until atomic_read(&sdp->sd_glock_disposal) == 0, then calls gfs2_lm_unmount(sdp), gfs2_free_dead_glocks(sdp), and destroy_workqueue(sdp->sd_glock_wq)
  4. rcu_barrier() and free_sbd(sdp)

In contrast, when gfs2_fill_super() (fs/gfs2/ops_fstype.c:1287-1318) fails after init_sb() / init_inodes() / init_per_node() have created gfs2_inode_glops (GLOF_ASPACE) glocks and read metadata folios into their gla->mapping:

  • Dropping the metadata inodes (iput() -> gfs2_evict_inode() -> gfs2_glock_put_eventually()) and holders (gfs2_glock_dq_uninit()) does not synchronously call __gfs2_glock_put() when gl->gl_state != LM_ST_UNLOCKED; instead, gfs2_glock_put() queues gl->gl_work onto sdp->sd_glock_wq (and gfs2_evict_inode() may also queue gl->gl_delete onto sdp->sd_delete_wq with a 1–10s delay via gfs2_queue_verify_delete()).
  • gfs2_fill_super()'s error path (fail_lm: through fail_free:):
    • Calls gfs2_lm_unmount(sdp) before destroy_workqueue(sdp->sd_glock_wq) (under lock_dlm, gdlm_unmount() releases the lockspace so in-flight async gdlm_lock()/gdlm_put_lock() operations never receive AST completions to drop gl->gl_lockref.count).
    • Destroys sdp->sd_delete_wq and sdp->sd_glock_wq without gfs2_flush_delete_work(sdp) or gfs2_wait_glocks(sdp). As documented in destroy_workqueue() (kernel/workqueue.c:6416-6421), destroy_workqueue() does not wait for or cancel timer-pending delayed_work (such as gl->gl_work scheduled with gl->gl_hold_time in glock_work_func() / __gfs2_glock_dq(), or gl->gl_delete scheduled with delay > 0).
    • Never calls gfs2_free_dead_glocks(sdp) or rcu_barrier() before free_sbd(sdp).

As a result, free_sbd(sdp) frees sdp while gfs2_glock_aspace objects are still alive with cached folios in gla->mapping on the memcg LRU and a dangling gl_name.ln_sbd pointer, causing subsequent folio reclaim in gfs2_release_folio() to dereference freed/reallocated sdp.

(Note: init_sb() at fs/gfs2/ops_fstype.c:503-505 also calls dput(sdp->sd_root_dir) on failure without clearing sdp->sd_root_dir = NULL, which leads to a double dput() at fail_sb:.)

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
be745086 bisect-cause IsRelease: ❌ ❓ INFO: trying to register non-static key in gfs2_release_folio 2026/11/29 21:56 2026/11/29 21:56 2026/11/29 22:56 e1f06033
bc44044f assessment-security DenialOfService: βœ… Exploitable: βœ… FilesystemTrigger: βœ… FuzzingArtifact: ❌ MemoryCorruption: βœ… NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ INFO: trying to register non-static key in gfs2_release_folio 2026/11/29 21:56 2026/11/29 21:56 2026/11/29 22:46 e1f06033

Sample crash report:
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 0 UID: 0 PID: 28098 Comm: syz.6.4686 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 assign_lock_key+0x133/0x150 kernel/locking/lockdep.c:1028
 register_lock_class+0xcc/0x2e0 kernel/locking/lockdep.c:1343
 __lock_acquire+0x10c/0x2de0 kernel/locking/lockdep.c:5162
 lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
 __raw_spin_lock include/linux/spinlock_api_smp.h:190 [inline]
 _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:173
 spin_lock include/linux/spinlock.h:347 [inline]
 gfs2_release_folio+0x10c/0x570 fs/gfs2/aops.c:671
 shrink_folio_list+0x2361/0x5110 mm/vmscan.c:1456
 evict_folios mm/vmscan.c:5024 [inline]
 evict_folio_lists+0x2bf4/0x3e80 mm/vmscan.c:5199
 try_to_shrink_lruvec+0x186e/0x2ac0 mm/vmscan.c:5254
 lru_gen_shrink_lruvec mm/vmscan.c:5423 [inline]
 shrink_lruvec mm/vmscan.c:6201 [inline]
 shrink_node_memcgs mm/vmscan.c:6450 [inline]
 shrink_node+0xe26/0x6ae0 mm/vmscan.c:6494
 shrink_zones mm/vmscan.c:6712 [inline]
 do_try_to_free_pages+0x50e/0x1880 mm/vmscan.c:6774
 try_to_free_mem_cgroup_pages+0x2f2/0x7f0 mm/vmscan.c:7057
 mem_cgroup_resize_max+0x23c/0x510 mm/memcontrol-v1.c:1466
 mem_cgroup_write+0x1a6/0x230 mm/memcontrol-v1.c:-1
 cgroup_file_write+0x331/0x8f0 kernel/cgroup/cgroup.c:4427
 kernfs_fop_write_iter+0x3a4/0x540 fs/kernfs/file.c:345
 new_sync_write fs/read_write.c:580 [inline]
 vfs_write+0x612/0xba0 fs/read_write.c:672
 ksys_write+0x150/0x270 fs/read_write.c:724
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x00007fb0c67a9b59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb0c7739028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fb0c6a35fa0 RCX: 00007fb0c67a9b59
RDX: 0000000000000020 RSI: 0000200000000480 RDI: 0000000000000004
RBP: 00007fb0c683a18b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fb0c6a36038 R14: 00007fb0c6a35fa0 R15: 00007ffcead31648
 </TASK>
------------[ cut here ]------------
UBSAN: array-index-out-of-bounds in kernel/locking/qspinlock.h:68:9
index 2460 is out of range for type 'unsigned long[8]'
CPU: 0 UID: 0 PID: 28098 Comm: syz.6.4686 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 ubsan_epilogue+0xa/0x30 lib/ubsan.c:233
 __ubsan_handle_out_of_bounds+0xe8/0xf0 lib/ubsan.c:455
 decode_tail kernel/locking/qspinlock.h:68 [inline]
 __pv_queued_spin_lock_slowpath+0xaf3/0xbc0 kernel/locking/qspinlock.c:307
 pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt-spinlock.h:37 [inline]
 queued_spin_lock_slowpath arch/x86/include/asm/paravirt-spinlock.h:71 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:115 [inline]
 do_raw_spin_lock+0x26c/0x2f0 kernel/locking/spinlock_debug.c:116
 spin_lock include/linux/spinlock.h:347 [inline]
 gfs2_release_folio+0x10c/0x570 fs/gfs2/aops.c:671
 shrink_folio_list+0x2361/0x5110 mm/vmscan.c:1456
 evict_folios mm/vmscan.c:5024 [inline]
 evict_folio_lists+0x2bf4/0x3e80 mm/vmscan.c:5199
 try_to_shrink_lruvec+0x186e/0x2ac0 mm/vmscan.c:5254
 lru_gen_shrink_lruvec mm/vmscan.c:5423 [inline]
 shrink_lruvec mm/vmscan.c:6201 [inline]
 shrink_node_memcgs mm/vmscan.c:6450 [inline]
 shrink_node+0xe26/0x6ae0 mm/vmscan.c:6494
 shrink_zones mm/vmscan.c:6712 [inline]
 do_try_to_free_pages+0x50e/0x1880 mm/vmscan.c:6774
 try_to_free_mem_cgroup_pages+0x2f2/0x7f0 mm/vmscan.c:7057
 mem_cgroup_resize_max+0x23c/0x510 mm/memcontrol-v1.c:1466
 mem_cgroup_write+0x1a6/0x230 mm/memcontrol-v1.c:-1
 cgroup_file_write+0x331/0x8f0 kernel/cgroup/cgroup.c:4427
 kernfs_fop_write_iter+0x3a4/0x540 fs/kernfs/file.c:345
 new_sync_write fs/read_write.c:580 [inline]
 vfs_write+0x612/0xba0 fs/read_write.c:672
 ksys_write+0x150/0x270 fs/read_write.c:724
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x00007fb0c67a9b59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb0c7739028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fb0c6a35fa0 RCX: 00007fb0c67a9b59
RDX: 0000000000000020 RSI: 0000200000000480 RDI: 0000000000000004
RBP: 00007fb0c683a18b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fb0c6a36038 R14: 00007fb0c6a35fa0 R15: 00007ffcead31648
 </TASK>
---[ end trace ]---

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/29 21:56 linux-next e5aad2bdbbee e1f06033 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root INFO: trying to register non-static key in gfs2_release_folio
* Struck through repros no longer work on HEAD.