| 0/0 |
2026/09/07 00:00 |
flow |
assessment-security |
29m
Results: map[DenialOfService:true Explanation:**Bug Analysis:**
The bug is a slab-use-after-free in `gfs2_remove_from_ail()` when accessing
`bd->bd_ail_gl_list`.
**Root Cause:**
When a GFS2 filesystem encounters an inconsistency or an I/O error, it enters a
"withdrawn" state to protect data integrity. During this state, if an inode is
evicted (e.g., during a failed mount or memory pressure), `gfs2_evict_inode()`
skips flushing the Active Item List (AIL) because the filesystem is withdrawn
and cannot write out dirty pages. It then proceeds to drop the reference to the
inode's glock (`ip->i_gl`).
If the glock's reference count drops to zero, `__gfs2_glock_put()` frees the
glock. However, because the AIL was not flushed, there are still `gfs2_bufdata`
objects (`bd`) linked to the glock's `gl_ail_list`.
Later, the withdraw worker (`gfs2_withdraw_func()`) calls `gfs2_ail_drain()` to
clean up the remaining transactions. This function iterates over the AIL and
calls `gfs2_remove_from_ail()`, which attempts to unlink the `bd` from
`gl_ail_list` using `list_del_init()`. Since the glock has already been freed,
this results in a use-after-free list operation.
**Exploitability:**
The bug is exploitable. The freed glock belongs to the `gfs2_glock(aspace)`
dedicated slab cache. An attacker can spray the heap to reallocate the freed
glock. When `list_del_init()` is called on the corrupted list, it performs
`next->prev = prev` and `prev->next = next`. By carefully controlling the
reallocation and the state of the list, an attacker can use this list unlinking
primitive to corrupt kernel memory, overwrite pointers, or leak heap addresses
(defeating KASLR).
**Trigger Vectors:**
- **Malicious Filesystem & Peripheral Trigger:** The most viable way to trigger
this bug is by mounting a maliciously crafted GFS2 filesystem image (e.g., from
a USB drive). The crafted image can be designed to dirty buffers during journal
recovery and then intentionally trigger an inconsistency that causes the
filesystem to withdraw during the mount process, leading directly to the bug.
- **Unprivileged Access:** GFS2 does not support `FS_USERNS_MOUNT`, meaning it
cannot be mounted inside unprivileged user namespaces. Mounting it requires
`CAP_SYS_ADMIN` in the initial namespace. Therefore, it is not reachable by
unprivileged local processes unless a vulnerable image is auto-mounted by the
desktop environment. Exploitable:true FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/07 00:00 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/09/07 00:00 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/ca3278c94e9ac92afd13f908cd83ea4671d0e93d]
|
| 3/1 |
2026/09/07 00:00 |
action |
kernel-builder |
14m
Results: map[KernelObj:/app/workdir/cache/build/e8c9398b937a4245a86d17d804eb773ff89a8575]
|
| 4/1 |
2026/09/07 00:15 |
action |
codesearch-prepare |
9m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/07 00:24 |
agent |
expert |
5m
Model:
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
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:
The kernel bug report is:
==================================================================
BUG: KASAN: slab-use-after-free in __list_del_entry_valid_or_report+0x1b1/0x1d0 lib/list_debug.c:62
Read of size 8 at addr ffff88807e0c64c0 by task kworker/1:1/44
CPU: 1 UID: 0 PID: 44 Comm: kworker/1:1 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/16/2026
Workqueue: events gfs2_withdraw_func
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1c0 mm/kasan/report.c:595
__list_del_entry_valid_or_report+0x1b1/0x1d0 lib/list_debug.c:62
__list_del_entry_valid include/linux/list.h:140 [inline]
__list_del_entry include/linux/list.h:261 [inline]
list_del_init include/linux/list.h:333 [inline]
gfs2_remove_from_ail+0x138/0x340 fs/gfs2/log.c:79
gfs2_ail_empty_tr fs/gfs2/log.c:287 [inline]
gfs2_ail_drain+0x39c/0x6b0 fs/gfs2/log.c:954
do_withdraw+0xeb/0x300 fs/gfs2/util.c:126
gfs2_withdraw_func+0x349/0x3d0 fs/gfs2/util.c:236
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Allocated by task 6846:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4683 [inline]
slab_alloc_node mm/slub.c:4996 [inline]
kmem_cache_alloc_noprof+0x269/0x6a0 mm/slub.c:5010
gfs2_glock_get+0x1e5/0x1260 fs/gfs2/glock.c:1074
gfs2_inode_lookup+0x2e0/0x920 fs/gfs2/inode.c:149
gfs2_lookup_root+0x57/0xe0 fs/gfs2/ops_fstype.c:428
init_sb+0xa17/0xfd0 fs/gfs2/ops_fstype.c:497
gfs2_fill_super+0x1acb/0x2d00 fs/gfs2/ops_fstype.c:1219
get_tree_bdev_flags+0x38c/0x620 fs/super.c:1887
gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1333
vfs_get_tree+0x92/0x320 fs/super.c:1947
fc_mount fs/namespace.c:1198 [inline]
do_new_mount_fc fs/namespace.c:3772 [inline]
do_new_mount fs/namespace.c:3848 [inline]
path_mount+0x7d0/0x24c0 fs/namespace.c:4168
do_mount fs/namespace.c:4181 [inline]
__do_sys_mount fs/namespace.c:4397 [inline]
__se_sys_mount fs/namespace.c:4374 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:4374
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 35:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2748 [inline]
slab_free mm/slub.c:6499 [inline]
kmem_cache_free+0x127/0x6c0 mm/slub.c:6626
gfs2_glock_dealloc+0xd0/0x160 fs/gfs2/glock.c:134
rcu_do_batch kernel/rcu/tree.c:2650 [inline]
rcu_core+0x5f0/0x1260 kernel/rcu/tree.c:2919
handle_softirqs+0x1e6/0x9d0 kernel/softirq.c:645
__do_softirq kernel/softirq.c:679 [inline]
invoke_softirq kernel/softirq.c:519 [inline]
__irq_exit_rcu+0x194/0x210 kernel/softirq.c:767
irq_exit_rcu+0x9/0x30 kernel/softirq.c:784
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
sysvec_apic_timer_interrupt+0xa3/0xc0 arch/x86/kernel/apic/apic.c:1062
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
Last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
__call_rcu_common.constprop.0+0xa5/0x9b0 kernel/rcu/tree.c:3181
gfs2_glock_free+0x35/0xa0 fs/gfs2/glock.c:150
glock_work_func+0x437/0x4d0 fs/gfs2/glock.c:1003
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
Second to last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
insert_work+0x36/0x230 kernel/workqueue.c:2272
__queue_work+0xa60/0x1370 kernel/workqueue.c:2448
__queue_delayed_work+0x357/0x450 kernel/workqueue.c:2617
queue_delayed_work_on+0x180/0x1e0 kernel/workqueue.c:2669
queue_delayed_work include/linux/workqueue.h:715 [inline]
gfs2_glock_queue_work+0x75/0x120 fs/gfs2/glock.c:198
do_xmote+0x453/0x680 fs/gfs2/glock.c:718
run_queue+0x555/0x6a0 fs/gfs2/glock.c:757
glock_work_func+0x35b/0x4d0 fs/gfs2/glock.c:987
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
The buggy address belongs to the object at ffff88807e0c63a8
which belongs to the cache gfs2_glock(aspace) of size 1176
The buggy address is located 280 bytes inside of
freed 1176-byte region [ffff88807e0c63a8, ffff88807e0c6840)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88807e0c68c0 pfn:0x7e0c4
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff888140aa83c0 ffff888020363948 ffffea0000d04110
raw: ffff88807e0c68c0 00000002000c000a 00000000f5000000 0000000000000000
head: 00fff00000000240 ffff888140aa83c0 ffff888020363948 ffffea0000d04110
head: ffff88807e0c68c0 00000002000c000a 00000000f5000000 0000000000000000
head: 00fff00000000002 ffffffffffffff01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000004
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6300, tgid 6299 (syz.1.95), ts 127307470235
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1871
prep_new_page mm/page_alloc.c:1879 [inline]
get_page_from_freelist+0x110d/0x35d0 mm/page_alloc.c:3943
__alloc_frozen_pages_noprof+0x2eb/0x3300 mm/page_alloc.c:5436
alloc_slab_page mm/slub.c:3347 [inline]
allocate_slab mm/slub.c:3462 [inline]
new_slab+0xa9/0x6e0 mm/slub.c:3513
refill_objects+0xe3/0x410 mm/slub.c:7410
refill_sheaf mm/slub.c:2885 [inline]
__pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4774
alloc_from_pcs mm/slub.c:4850 [inline]
slab_alloc_node mm/slub.c:4984 [inline]
kmem_cache_alloc_noprof+0x4c4/0x6a0 mm/slub.c:5010
gfs2_glock_get+0x1e5/0x1260 fs/gfs2/glock.c:1074
gfs2_inode_lookup+0x2e0/0x920 fs/gfs2/inode.c:149
gfs2_dir_search+0x22a/0x2e0 fs/gfs2/dir.c:1663
gfs2_lookupi+0x4b7/0x6a0 fs/gfs2/inode.c:354
gfs2_lookup_meta+0xae/0x190 fs/gfs2/inode.c:294
init_statfs fs/gfs2/ops_fstype.c:616 [inline]
init_journal fs/gfs2/ops_fstype.c:781 [inline]
init_inodes+0xd86/0x2790 fs/gfs2/ops_fstype.c:846
gfs2_fill_super+0x1d54/0x2d00 fs/gfs2/ops_fstype.c:1252
get_tree_bdev_flags+0x38c/0x620 fs/super.c:1887
gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1333
page last free pid 5621 tgid 5621 ts 114446076348 stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
__free_pages_prepare mm/page_alloc.c:1418 [inline]
__free_frozen_pages+0x79f/0x10f0 mm/page_alloc.c:2962
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x47/0xf0 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x1a0/0x1f0 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4683 [inline]
slab_alloc_node mm/slub.c:4996 [inline]
kmem_cache_alloc_noprof+0x269/0x6a0 mm/slub.c:5010
anon_vma_chain_alloc mm/rmap.c:142 [inline]
__anon_vma_prepare+0xae/0x5e0 mm/rmap.c:194
__vmf_anon_prepare+0x11f/0x250 mm/memory.c:3961
vmf_anon_prepare mm/internal.h:569 [inline]
do_anonymous_page+0x47d/0x2050 mm/memory.c:5478
do_pte_missing mm/memory.c:4698 [inline]
handle_pte_fault mm/memory.c:6558 [inline]
__handle_mm_fault+0x1ff3/0x2f60 mm/memory.c:6707
handle_mm_fault+0x363/0xa20 mm/memory.c:6876
do_user_addr_fault+0x745/0x12f0 arch/x86/mm/fault.c:1394
handle_page_fault arch/x86/mm/fault.c:1483 [inline]
exc_page_fault+0x6f/0xd0 arch/x86/mm/fault.c:1536
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
Memory state around the buggy address:
ffff88807e0c6380: fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb
ffff88807e0c6400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807e0c6480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807e0c6500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807e0c6580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
==================================================================
BUG: KASAN: slab-use-after-free in __list_del_entry_valid_or_report+0x1a4/0x1d0 lib/list_debug.c:65
Read of size 8 at addr ffff88807e0c64c8 by task kworker/1:1/44
CPU: 1 UID: 0 PID: 44 Comm: kworker/1:1 Tainted: G B syzkaller #0 PREEMPT(full)
Tainted: [B]=BAD_PAGE
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/16/2026
Workqueue: events gfs2_withdraw_func
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1c0 mm/kasan/report.c:595
__list_del_entry_valid_or_report+0x1a4/0x1d0 lib/list_debug.c:65
__list_del_entry_valid include/linux/list.h:140 [inline]
__list_del_entry include/linux/list.h:261 [inline]
list_del_init include/linux/list.h:333 [inline]
gfs2_remove_from_ail+0x138/0x340 fs/gfs2/log.c:79
gfs2_ail_empty_tr fs/gfs2/log.c:287 [inline]
gfs2_ail_drain+0x39c/0x6b0 fs/gfs2/log.c:954
do_withdraw+0xeb/0x300 fs/gfs2/util.c:126
gfs2_withdraw_func+0x349/0x3d0 fs/gfs2/util.c:236
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Allocated by task 6846:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4683 [inline]
slab_alloc_node mm/slub.c:4996 [inline]
kmem_cache_alloc_noprof+0x269/0x6a0 mm/slub.c:5010
gfs2_glock_get+0x1e5/0x1260 fs/gfs2/glock.c:1074
gfs2_inode_lookup+0x2e0/0x920 fs/gfs2/inode.c:149
gfs2_lookup_root+0x57/0xe0 fs/gfs2/ops_fstype.c:428
init_sb+0xa17/0xfd0 fs/gfs2/ops_fstype.c:497
gfs2_fill_super+0x1acb/0x2d00 fs/gfs2/ops_fstype.c:1219
get_tree_bdev_flags+0x38c/0x620 fs/super.c:1887
gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1333
vfs_get_tree+0x92/0x320 fs/super.c:1947
fc_mount fs/namespace.c:1198 [inline]
do_new_mount_fc fs/namespace.c:3772 [inline]
do_new_mount fs/namespace.c:3848 [inline]
path_mount+0x7d0/0x24c0 fs/namespace.c:4168
do_mount fs/namespace.c:4181 [inline]
__do_sys_mount fs/namespace.c:4397 [inline]
__se_sys_mount fs/namespace.c:4374 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:4374
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 35:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2748 [inline]
slab_free mm/slub.c:6499 [inline]
kmem_cache_free+0x127/0x6c0 mm/slub.c:6626
gfs2_glock_dealloc+0xd0/0x160 fs/gfs2/glock.c:134
rcu_do_batch kernel/rcu/tree.c:2650 [inline]
rcu_core+0x5f0/0x1260 kernel/rcu/tree.c:2919
handle_softirqs+0x1e6/0x9d0 kernel/softirq.c:645
__do_softirq kernel/softirq.c:679 [inline]
invoke_softirq kernel/softirq.c:519 [inline]
__irq_exit_rcu+0x194/0x210 kernel/softirq.c:767
irq_exit_rcu+0x9/0x30 kernel/softirq.c:784
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
sysvec_apic_timer_interrupt+0xa3/0xc0 arch/x86/kernel/apic/apic.c:1062
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
Last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
__call_rcu_common.constprop.0+0xa5/0x9b0 kernel/rcu/tree.c:3181
gfs2_glock_free+0x35/0xa0 fs/gfs2/glock.c:150
glock_work_func+0x437/0x4d0 fs/gfs2/glock.c:1003
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
Second to last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
insert_work+0x36/0x230 kernel/workqueue.c:2272
__queue_work+0xa60/0x1370 kernel/workqueue.c:2448
__queue_delayed_work+0x357/0x450 kernel/workqueue.c:2617
queue_delayed_work_on+0x180/0x1e0 kernel/workqueue.c:2669
queue_delayed_work include/linux/workqueue.h:715 [inline]
gfs2_glock_queue_work+0x75/0x120 fs/gfs2/glock.c:198
do_xmote+0x453/0x680 fs/gfs2/glock.c:718
run_queue+0x555/0x6a0 fs/gfs2/glock.c:757
glock_work_func+0x35b/0x4d0 fs/gfs2/glock.c:987
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
The buggy address belongs to the object at ffff88807e0c63a8
which belongs to the cache gfs2_glock(aspace) of size 1176
The buggy address is located 288 bytes inside of
freed 1176-byte region [ffff88807e0c63a8, ffff88807e0c6840)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88807e0c68c0 pfn:0x7e0c4
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff888140aa83c0 ffff888020363948 ffffea0000d04110
raw: ffff88807e0c68c0 00000002000c000a 00000000f5000000 0000000000000000
head: 00fff00000000240 ffff888140aa83c0 ffff888020363948 ffffea0000d04110
head: ffff88807e0c68c0 00000002000c000a 00000000f5000000 0000000000000000
head: 00fff00000000002 ffffffffffffff01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000004
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6300, tgid 6299 (syz.1.95), ts 127307470235
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1871
prep_new_page mm/page_alloc.c:1879 [inline]
get_page_from_freelist+0x110d/0x35d0 mm/page_alloc.c:3943
__alloc_frozen_pages_noprof+0x2eb/0x3300 mm/page_alloc.c:5436
alloc_slab_page mm/slub.c:3347 [inline]
allocate_slab mm/slub.c:3462 [inline]
new_slab+0xa9/0x6e0 mm/slub.c:3513
refill_objects+0xe3/0x410 mm/slub.c:7410
refill_sheaf mm/slub.c:2885 [inline]
__pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4774
alloc_from_pcs mm/slub.c:4850 [inline]
slab_alloc_node mm/slub.c:4984 [inline]
kmem_cache_alloc_noprof+0x4c4/0x6a0 mm/slub.c:5010
gfs2_glock_get+0x1e5/0x1260 fs/gfs2/glock.c:1074
gfs2_inode_lookup+0x2e0/0x920 fs/gfs2/inode.c:149
gfs2_dir_search+0x22a/0x2e0 fs/gfs2/dir.c:1663
gfs2_lookupi+0x4b7/0x6a0 fs/gfs2/inode.c:354
gfs2_lookup_meta+0xae/0x190 fs/gfs2/inode.c:294
init_statfs fs/gfs2/ops_fstype.c:616 [inline]
init_journal fs/gfs2/ops_fstype.c:781 [inline]
init_inodes+0xd86/0x2790 fs/gfs2/ops_fstype.c:846
gfs2_fill_super+0x1d54/0x2d00 fs/gfs2/ops_fstype.c:1252
get_tree_bdev_flags+0x38c/0x620 fs/super.c:1887
gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1333
page last free pid 5621 tgid 5621 ts 114446076348 stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
__free_pages_prepare mm/page_alloc.c:1418 [inline]
__free_frozen_pages+0x79f/0x10f0 mm/page_alloc.c:2962
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x47/0xf0 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x1a0/0x1f0 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4683 [inline]
slab_alloc_node mm/slub.c:4996 [inline]
kmem_cache_alloc_noprof+0x269/0x6a0 mm/slub.c:5010
anon_vma_chain_alloc mm/rmap.c:142 [inline]
__anon_vma_prepare+0xae/0x5e0 mm/rmap.c:194
__vmf_anon_prepare+0x11f/0x250 mm/memory.c:3961
vmf_anon_prepare mm/internal.h:569 [inline]
do_anonymous_page+0x47d/0x2050 mm/memory.c:5478
do_pte_missing mm/memory.c:4698 [inline]
handle_pte_fault mm/memory.c:6558 [inline]
__handle_mm_fault+0x1ff3/0x2f60 mm/memory.c:6707
handle_mm_fault+0x363/0xa20 mm/memory.c:6876
do_user_addr_fault+0x745/0x12f0 arch/x86/mm/fault.c:1394
handle_page_fault arch/x86/mm/fault.c:1483 [inline]
exc_page_fault+0x6f/0xd0 arch/x86/mm/fault.c:1536
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
Memory state around the buggy address:
ffff88807e0c6380: fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb
ffff88807e0c6400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807e0c6480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807e0c6500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807e0c6580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
==================================================================
BUG: KASAN: slab-use-after-free in __list_del include/linux/list.h:241 [inline]
BUG: KASAN: slab-use-after-free in __list_del_entry include/linux/list.h:264 [inline]
BUG: KASAN: slab-use-after-free in __list_del_entry include/linux/list.h:259 [inline]
BUG: KASAN: slab-use-after-free in list_del_init include/linux/list.h:333 [inline]
BUG: KASAN: slab-use-after-free in gfs2_remove_from_ail+0x323/0x340 fs/gfs2/log.c:79
Write of size 8 at addr ffff88807e0c64c8 by task kworker/1:1/44
CPU: 1 UID: 0 PID: 44 Comm: kworker/1:1 Tainted: G B syzkaller #0 PREEMPT(full)
Tainted: [B]=BAD_PAGE
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/16/2026
Workqueue: events gfs2_withdraw_func
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1c0 mm/kasan/report.c:595
__list_del include/linux/list.h:241 [inline]
__list_del_entry include/linux/list.h:264 [inline]
__list_del_entry include/linux/list.h:259 [inline]
list_del_init include/linux/list.h:333 [inline]
gfs2_remove_from_ail+0x323/0x340 fs/gfs2/log.c:79
gfs2_ail_empty_tr fs/gfs2/log.c:287 [inline]
gfs2_ail_drain+0x39c/0x6b0 fs/gfs2/log.c:954
do_withdraw+0xeb/0x300 fs/gfs2/util.c:126
gfs2_withdraw_func+0x349/0x3d0 fs/gfs2/util.c:236
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Allocated by task 6846:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4683 [inline]
slab_alloc_node mm/slub.c:4996 [inline]
kmem_cache_alloc_noprof+0x269/0x6a0 mm/slub.c:5010
gfs2_glock_get+0x1e5/0x1260 fs/gfs2/glock.c:1074
gfs2_inode_lookup+0x2e0/0x920 fs/gfs2/inode.c:149
gfs2_lookup_root+0x57/0xe0 fs/gfs2/ops_fstype.c:428
init_sb+0xa17/0xfd0 fs/gfs2/ops_fstype.c:497
gfs2_fill_super+0x1acb/0x2d00 fs/gfs2/ops_fstype.c:1219
get_tree_bdev_flags+0x38c/0x620 fs/super.c:1887
gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1333
vfs_get_tree+0x92/0x320 fs/super.c:1947
fc_mount fs/namespace.c:1198 [inline]
do_new_mount_fc fs/namespace.c:3772 [inline]
do_new_mount fs/namespace.c:3848 [inline]
path_mount+0x7d0/0x24c0 fs/namespace.c:4168
do_mount fs/namespace.c:4181 [inline]
__do_sys_mount fs/namespace.c:4397 [inline]
__se_sys_mount fs/namespace.c:4374 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:4374
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 35:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2748 [inline]
slab_free mm/slub.c:6499 [inline]
kmem_cache_free+0x127/0x6c0 mm/slub.c:6626
gfs2_glock_dealloc+0xd0/0x160 fs/gfs2/glock.c:134
rcu_do_batch kernel/rcu/tree.c:2650 [inline]
rcu_core+0x5f0/0x1260 kernel/rcu/tree.c:2919
handle_softirqs+0x1e6/0x9d0 kernel/softirq.c:645
__do_softirq kernel/softirq.c:679 [inline]
invoke_softirq kernel/softirq.c:519 [inline]
__irq_exit_rcu+0x194/0x210 kernel/softirq.c:767
irq_exit_rcu+0x9/0x30 kernel/softirq.c:784
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
sysvec_apic_timer_interrupt+0xa3/0xc0 arch/x86/kernel/apic/apic.c:1062
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
Last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
__call_rcu_common.constprop.0+0xa5/0x9b0 kernel/rcu/tree.c:3181
gfs2_glock_free+0x35/0xa0 fs/gfs2/glock.c:150
glock_work_func+0x437/0x4d0 fs/gfs2/glock.c:1003
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
Second to last potentially related work creation:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
insert_work+0x36/0x230 kernel/workqueue.c:2272
__queue_work+0xa60/0x1370 kernel/workqueue.c:2448
__queue_delayed_work+0x357/0x450 kernel/workqueue.c:2617
queue_delayed_work_on+0x180/0x1e0 kernel/workqueue.c:2669
queue_delayed_work include/linux/workqueue.h:715 [inline]
gfs2_glock_queue_work+0x75/0x120 fs/gfs2/glock.c:198
do_xmote+0x453/0x680 fs/gfs2/glock.c:718
run_queue+0x555/0x6a0 fs/gfs2/glock.c:757
glock_work_func+0x35b/0x4d0 fs/gfs2/glock.c:987
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
process_scheduled_works kernel/workqueue.c:3479 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
The buggy address belongs to the object at ffff88807e0c63a8
which belongs to the cache gfs2_glock(aspace) of size 1176
The buggy address is located 288 bytes inside of
freed 1176-byte region [ffff88807e0c63a8, ffff88807e0c6840)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88807e0c68c0 pfn:0x7e0c4
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff888140aa83c0 ffff888020363948 ffffea0000d04110
raw: ffff88807e0c68c0 00000002000c000a 00000000f5000000 0000000000000000
head: 00fff00000000240 ffff888140aa83c0 ffff888020363948 ffffea0000d04110
head: ffff88807e0c68c0 00000002000c000a 00000000f5000000 0000000000000000
head: 00fff00000000002 ffffffffffffff01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000004
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6300, tgid 6299 (syz.1.95), ts 127307470235
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1871
prep_new_page mm/page_alloc.c:1879 [inline]
get_page_from_freelist+0x110d/0x35d0 mm/page_alloc.c:3943
__alloc_frozen_pages_noprof+0x2eb/0x3300 mm/page_alloc.c:5436
alloc_slab_page mm/slub.c:3347 [inline]
allocate_slab mm/slub.c:3462 [inline]
new_slab+0xa9/0x6e0 mm/slub.c:3513
refill_objects+0xe3/0x410 mm/slub.c:7410
refill_sheaf mm/slub.c:2885 [inline]
__pcs_replace_empty_main+0x35e/0x650 mm/slub.c:4774
alloc_from_pcs mm/slub.c:4850 [inline]
slab_alloc_node mm/slub.c:4984 [inline]
kmem_cache_alloc_noprof+0x4c4/0x6a0 mm/slub.c:5010
gfs2_glock_get+0x1e5/0x1260 fs/gfs2/glock.c:1074
gfs2_inode_lookup+0x2e0/0x920 fs/gfs2/inode.c:149
gfs2_dir_search+0x22a/0x2e0 fs/gfs2/dir.c:1663
gfs2_lookupi+0x4b7/0x6a0 fs/gfs2/inode.c:354
gfs2_lookup_meta+0xae/0x190 fs/gfs2/inode.c:294
init_statfs fs/gfs2/ops_fstype.c:616 [inline]
init_journal fs/gfs2/ops_fstype.c:781 [inline]
init_inodes+0xd86/0x2790 fs/gfs2/ops_fstype.c:846
gfs2_fill_super+0x1d54/0x2d00 fs/gfs2/ops_fstype.c:1252
get_tree_bdev_flags+0x38c/0x620 fs/super.c:1887
gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1333
page last free pid 5621 tgid 5621 ts 114446076348 stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
__free_pages_prepare mm/page_alloc.c:1418 [inline]
__free_frozen_pages+0x79f/0x10f0 mm/page_alloc.c:2962
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x47/0xf0 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x1a0/0x1f0 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4683 [inline]
slab_alloc_node mm/slub.c:4996 [inline]
kmem_cache_alloc_noprof+0x269/0x6a0 mm/slub.c:5010
anon_vma_chain_alloc mm/rmap.c:142 [inline]
__anon_vma_prepare+0xae/0x5e0 mm/rmap.c:194
__vmf_anon_prepare+0x11f/0x250 mm/memory.c:3961
vmf_anon_prepare mm/internal.h:569 [inline]
do_anonymous_page+0x47d/0x2050 mm/memory.c:5478
do_pte_missing mm/memory.c:4698 [inline]
handle_pte_fault mm/memory.c:6558 [inline]
__handle_mm_fault+0x1ff3/0x2f60 mm/memory.c:6707
handle_mm_fault+0x363/0xa20 mm/memory.c:6876
do_user_addr_fault+0x745/0x12f0 arch/x86/mm/fault.c:1394
handle_page_fault arch/x86/mm/fault.c:1483 [inline]
exc_page_fault+0x6f/0xd0 arch/x86/mm/fault.c:1536
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
Memory state around the buggy address:
ffff88807e0c6380: fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb
ffff88807e0c6400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807e0c6480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807e0c6500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807e0c6580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Reply: **Bug Analysis:**
The bug is a slab-use-after-free in `gfs2_remove_from_ail()` when accessing `bd->bd_ail_gl_list`.
**Root Cause:**
When a GFS2 filesystem encounters an inconsistency or an I/O error, it enters a "withdrawn" state to protect data integrity. During this state, if an inode is evicted (e.g., during a failed mount or memory pressure), `gfs2_evict_inode()` skips flushing the Active Item List (AIL) because the filesystem is withdrawn and cannot write out dirty pages. It then proceeds to drop the reference to the inode's glock (`ip->i_gl`).
If the glock's reference count drops to zero, `__gfs2_glock_put()` frees the glock. However, because the AIL was not flushed, there are still `gfs2_bufdata` objects (`bd`) linked to the glock's `gl_ail_list`.
Later, the withdraw worker (`gfs2_withdraw_func()`) calls `gfs2_ail_drain()` to clean up the remaining transactions. This function iterates over the AIL and calls `gfs2_remove_from_ail()`, which attempts to unlink the `bd` from `gl_ail_list` using `list_del_init()`. Since the glock has already been freed, this results in a use-after-free list operation.
**Exploitability:**
The bug is exploitable. The freed glock belongs to the `gfs2_glock(aspace)` dedicated slab cache. An attacker can spray the heap to reallocate the freed glock. When `list_del_init()` is called on the corrupted list, it performs `next->prev = prev` and `prev->next = next`. By carefully controlling the reallocation and the state of the list, an attacker can use this list unlinking primitive to corrupt kernel memory, overwrite pointers, or leak heap addresses (defeating KASLR).
**Trigger Vectors:**
- **Malicious Filesystem & Peripheral Trigger:** The most viable way to trigger this bug is by mounting a maliciously crafted GFS2 filesystem image (e.g., from a USB drive). The crafted image can be designed to dirty buffers during journal recovery and then intentionally trigger an inconsistency that causes the filesystem to withdraw during the mount process, leading directly to the bug.
- **Unprivileged Access:** GFS2 does not support `FS_USERNS_MOUNT`, meaning it cannot be mounted inside unprivileged user namespaces. Mounting it requires `CAP_SYS_ADMIN` in the initial namespace. Therefore, it is not reachable by unprivileged local processes unless a vulnerable image is auto-mounted by the desktop environment.
|
| 6/2 |
2026/09/07 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 21350
output: 42
thoughts: 390
Thoughts: **KASAN Slab-Use-After-Free Deep Dive**
Okay, so I've got a KASAN slab-use-after-free report. Specifically, it's hitting in `__list_del_entry_valid_or_report`, and the call chain leads us through `gfs2_remove_from_ail`. That's interesting, and it looks like it's coming from GFS2, as expected.
I know that the offending object is allocated within `gfs2_glock_get`, and, as I'd anticipate with glocks, it's being freed in `gfs2_glock_dealloc`. The cache associated with this object appears to be `gfs2_glock(aspace)`. Seems like a standard glock life cycle, then.
Let's dissect the stack trace. I see `gfs2_remove_from_ail` as the entry point, called directly. The trace goes through `gfs2_ail_empty_tr`, which is inlined, then `gfs2_ail_drain`. From there, we are in `do_withdraw` and `gfs2_withdraw_func`. The final call is in `process_one_work`, likely triggered by a workqueue. This points to an AIL drain that is part of a withdraw operation.
Now, to confirm the deallocation path, I see `gfs2_glock_dealloc` at the end of the stack, and it looks like RCU is involved, as I can see `rcu_do_batch` in the chain.
Time to dive into the code. I'll need to use `codesearch-definition-source` to jump to the definitions of both `gfs2_remove_from_ail` and `gfs2_glock_dealloc` to understand the exact mechanics of these functions. I'll want to focus on how they interact with the glock and AIL, looking for the mismatch that KASAN is reporting.
|
| 7/2 |
2026/09/07 00:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/log.c Name:gfs2_remove_from_ail]
Results: map[SourceCode: 75: static void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
76: {
77: bd->bd_tr = NULL;
78: list_del_init(&bd->bd_ail_st_list);
79: list_del_init(&bd->bd_ail_gl_list);
80: atomic_dec(&bd->bd_gl->gl_ail_count);
81: brelse(bd->bd_bh);
82: }
SourceFile:fs/gfs2/log.c]
|
| 8/2 |
2026/09/07 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 22388
output: 47
thoughts: 79
Thoughts: Here's my summary, as though I'm thinking through this myself:
**Debugging a UAF in gfs2**
Okay, so I'm chasing down this Use-After-Free (UAF) error. The first clue is that the UAF is happening on `bd->bd_ail_gl_list`. Right away, that points me towards something related to the AIL, which isn't *that* surprising, but I need to narrow it down. The bugged address seems to belong to the `gfs2_glock(aspace)` cache. Hmm, that's interesting; I'm pretty familiar with the gfs2 glock structure. Let's see if this can be related to a double free, or a use after deallocation.
Now I need to find the specific offset; ah, it's 280 bytes inside a freed 1176-byte region. That helps quite a bit. Now the question becomes, what data is at that offset within the `struct gfs2_glock`? That's the key. I need to refresh my mental layout of that structure to figure out what could potentially be getting accessed at that specific offset after the glock has been freed. Let's take a look at the `struct gfs2_glock` layout... Time to dig through the code.
|
| 9/2 |
2026/09/07 00:24 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:fs/gfs2/glock.c FieldOffset:280 Name:gfs2_glock]
Results: map[Fields:[map[Name:gl_dead OffsetBits:2112 SizeBits:128] map[Name:gl_ail_list OffsetBits:2240 SizeBits:128]]]
|
| 10/2 |
2026/09/07 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 22866
output: 43
thoughts: 113
Thoughts: **Analyzing the Global AIL List**
Okay, so offset 280 translates to 2240 bits – that's the `gl_ail_list` within the `gfs2_buffer_head`. Right, so `list_del_init(&bd->bd_ail_gl_list)` is removing the current buffer head (`bd`) from the global AIL list – the `gl_ail_list`. Now, the tricky part... it looks like the `gfs2_glock` object associated with that buffer head has already been freed, but the buffer head (`bd`) is *still* linked to the now-freed glock via that `bd_ail_gl_list` link. This is a potential memory issue, and could lead to issues later. We need to check the function that deallocates gfs2 glocks - `gfs2_glock_dealloc` – to confirm how the list entry is unlinked. Let's dig into that function and see what's happening.
|
| 11/2 |
2026/09/07 00:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:gfs2_glock_dealloc]
Results: map[SourceCode: 126: static void gfs2_glock_dealloc(struct rcu_head *rcu)
127: {
128: struct gfs2_glock *gl = container_of(rcu, struct gfs2_glock, gl_rcu);
129:
130: kfree(gl->gl_lksb.sb_lvbptr);
131: if (gl->gl_ops->go_flags & GLOF_ASPACE) {
132: struct gfs2_glock_aspace *gla =
133: container_of(gl, struct gfs2_glock_aspace, glock);
134: kmem_cache_free(gfs2_glock_aspace_cachep, gla);
135: } else
136: kmem_cache_free(gfs2_glock_cachep, gl);
137: }
SourceFile:fs/gfs2/glock.c]
|
| 12/2 |
2026/09/07 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 23527
output: 42
thoughts: 35
Thoughts: Okay, here's my interpretation of those thoughts, summarized from a first-person expert perspective:
**Investigating a Glock Release in GFS2**
Alright, the objective is clear: I need to understand how a Glock is being freed, specifically through an RCU mechanism. First, I need to pinpoint the exact location in the code where this happens. My immediate next step is to trace the execution path. I'll need to locate all instances where `gfs2_glock_free` is called, because that's the function responsible for freeing the glock, and all calls to `call_rcu`, which is how the RCU mechanism is invoked. It's a classic code diving exercise, but the RCU aspect suggests there's some deferred work involved – likely synchronization cleanup that needs to happen safely after a critical section. I expect to find these calls scattered across the GFS2 code, depending on the lock's state and where the Glock is in its lifecycle, so I'll need to trace through the code. I anticipate potentially finding this in several places, depending on the lock's state. I'll be looking for clues about the concurrency context: Is the RCU callback for freeing called from the context of an i/o path, a metadata update path, or a user-initiated lock release? This information is critical for determining the implications. The specifics of the callback will be the important piece of the puzzle.
|
| 13/2 |
2026/09/07 00:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:gfs2_glock_free]
Results: map[SourceCode: 147: void gfs2_glock_free(struct gfs2_glock *gl) {
148: struct gfs2_sbd *sdp = glock_sbd(gl);
149:
150: __gfs2_glock_free(gl);
151: if (atomic_dec_and_test(&sdp->sd_glock_disposal))
152: wake_up(&sdp->sd_kill_wait);
153: }
SourceFile:fs/gfs2/glock.c]
|
| 14/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 24074
output: 43
thoughts: 16
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Diving into `__gfs2_glock_free`**
Alright, let's zero in on `__gfs2_glock_free`. That's where the rubber meets the road when we're talking about releasing those global locks in GFS2. I need to refresh my memory on the critical path here. What are the key considerations? Is it just about decrementing the reference count and conditionally freeing the memory? Are there more complex scenarios to consider, like races with other threads that might be holding the lock or waiting on it? I need to quickly run through the likely code paths in my head. Are there spinlocks involved, and if so, how are they handled in relation to the main lock? Specifically, I am interested in how the lock is being freed after the last user drops their ref, as well as checking the various states the glock can be in. Any potential for deadlocks or livelocks here? Gotta keep an eye out for those, especially in a distributed filesystem. Where are the likely points of contention or potential memory leaks. I better make sure I know how we handle asynchronous un-locks in there as well. Time to get my eyes on the actual implementation, and dig in.
|
| 15/2 |
2026/09/07 00:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:__gfs2_glock_free]
Results: map[SourceCode: 139: static void __gfs2_glock_free(struct gfs2_glock *gl)
140: {
141: rhashtable_remove_fast(&gl_hash_table, &gl->gl_node, ht_parms);
142: smp_mb();
143: wake_up_glock(gl);
144: call_rcu(&gl->gl_rcu, gfs2_glock_dealloc);
145: }
SourceFile:fs/gfs2/glock.c]
|
| 16/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 24581
output: 40
thoughts: 162
Thoughts: **Investigating Glock Deallocation Anomalies**
Okay, so I've got a Glock that's been freed, but somehow its associated `gl_ail_list` still has entries. That's a serious inconsistency. My immediate thought is, if a Glock is truly freed, its `gl_ail_count` should be zero, and the list itself should be empty. Something's gone sideways here. Time to dig in.
The first step is to trace the execution path of the freeing process. Let's see where `gfs2_glock_free` is actually being called. The trace gives me the breakdown: it's called directly at `gfs2_glock_free+0x35` in `fs/gfs2/glock.c` and also within `glock_work_func`. Seems I need to focus on `glock_work_func` as it likely holds some logic that interacts with `gl_ail_list`. Let's scrutinize that function and see what's going on there.
|
| 17/2 |
2026/09/07 00:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:glock_work_func]
Results: map[SourceCode: 956: static void glock_work_func(struct work_struct *work)
957: {
958: struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_work.work);
959: unsigned int drop_refs;
960: unsigned long delay;
961:
962: spin_lock(&gl->gl_lockref.lock);
963: again:
964: drop_refs = 1;
965: if (test_bit(GLF_HAVE_REPLY, &gl->gl_flags)) {
966: clear_bit(GLF_HAVE_REPLY, &gl->gl_flags);
967: finish_xmote(gl, gl->gl_reply);
968: drop_refs++;
969: }
970: delay = 0;
971: if (test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
972: gl->gl_state != LM_ST_UNLOCKED &&
973: gl->gl_demote_state != LM_ST_EXCLUSIVE) {
974: if (glock_type(gl) == LM_TYPE_INODE) {
975: unsigned long holdtime, now = jiffies;
976:
977: holdtime = gl->gl_tchange + gl->gl_hold_time;
978: if (time_before(now, holdtime))
979: delay = holdtime - now;
980: }
981:
982: if (!delay) {
983: clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags);
984: gfs2_set_demote(GLF_DEMOTE, gl);
985: }
986: }
987: run_queue(gl, 0);
988: if (delay) {
989: /* Keep one glock reference for the work we requeue. */
990: drop_refs--;
991: gfs2_glock_queue_work(gl, delay);
992: }
993:
994: /* Drop the remaining glock references manually. */
995: GLOCK_BUG_ON(gl, gl->gl_lockref.count < drop_refs);
996: gl->gl_lockref.count -= drop_refs;
997: if (!gl->gl_lockref.count) {
998: if (gl->gl_state != LM_ST_UNLOCKED) {
999: gl->gl_lockref.count++;
1000: request_demote(gl, LM_ST_UNLOCKED, 0, false);
1001: goto again;
1002: }
1003: __gfs2_glock_put(gl);
1004: return;
1005: }
1006: spin_unlock(&gl->gl_lockref.lock);
1007: }
SourceFile:fs/gfs2/glock.c]
|
| 18/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 25900
output: 43
thoughts: 48
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**Deconstructing the Glock Release**
Alright, so `__gfs2_glock_put(gl)` is triggered when the reference count on a `glock` (`gl`) drops to zero. That's the key trigger, the signal that the system is ready to let go of this lock. Now, I need to understand what actually happens *within* `__gfs2_glock_put`. What are the cleanup steps? Are there any crucial data structures being released, or state transitions? I need to drill down into the implementation of that function to grasp the full implications of this release. What's the context? What locks are held when it's called? What's the impact on the overall file system consistency? Time to dig into the code.
|
| 19/2 |
2026/09/07 00:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:__gfs2_glock_put]
Results: map[SourceCode: 210: static void __gfs2_glock_put(struct gfs2_glock *gl)
211: {
212: struct gfs2_sbd *sdp = glock_sbd(gl);
213: struct address_space *mapping = gfs2_glock2aspace(gl);
214:
215: lockref_mark_dead(&gl->gl_lockref);
216: spin_unlock(&gl->gl_lockref.lock);
217: GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders));
218: if (mapping) {
219: truncate_inode_pages_final(mapping);
220: if (!gfs2_withdrawn(sdp))
221: GLOCK_BUG_ON(gl, !mapping_empty(mapping));
222: }
223: trace_gfs2_glock_put(gl);
224: sdp->sd_lockstruct.ls_ops->lm_put_lock(gl);
225: }
SourceFile:fs/gfs2/glock.c]
|
| 20/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 26504
output: 55
thoughts: 76
Thoughts: Okay, let me think this through.
**Analyzing the `__gfs2_glock_put` Function**
Right, so `__gfs2_glock_put` calls `lm_put_lock(gl)`. The key here is what `lm_put_lock` *does*. It's almost certainly going to be related to freeing the glock, right? Probably something like `gfs2_glock_free`, or at least a function that eventually calls it. I should probably double-check that assumption though. Time to hunt down references to `gfs2_glock_free` to see where it gets called and verify my suspicion.
|
| 21/2 |
2026/09/07 00:25 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/gfs2/glock.c IncludeSnippetLines:0 Name:gfs2_glock_free SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gdlm_ast SourceFile:fs/gfs2/lock_dlm.c SourceLine:140] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gdlm_put_lock SourceFile:fs/gfs2/lock_dlm.c SourceLine:332] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gdlm_put_lock SourceFile:fs/gfs2/lock_dlm.c SourceLine:370] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:nolock_ops SourceFile:fs/gfs2/ops_fstype.c SourceLine:949]] TruncatedOutput:false]
|
| 22/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 27024
output: 40
thoughts: 142
Thoughts: **My Analysis of the GFS2 Locking Mechanism**
Okay, so I'm looking at this `nolock_ops` structure, and it's got `gfs2_glock_free` assigned to `lm_put_lock`. Right, so that means `gfs2_glock_free` is the function that's going to get called when the reference count, `gl_lockref.count`, on a glock hits zero. That makes sense, cleanup time. But hang on... if the reference count is zero, that implies no one is *currently* referencing the glock. No active users.
Now I'm remembering that `gfs2_remove_from_ail` is called during the process of a `gfs2_ail_drain`, which itself is invoked from `do_withdraw`. I know those drain and withdraw operations can be complex and involved. So there's definitely a point where a glock can be in a state of cleanup due to being removed from the AIL (Active Intent List) that might not be at the same point in time as the removal of active users. Hmmm... let's shift gears and examine `gfs2_remove_from_ail` and `gfs2_ail_drain` closely, to see the exact relationship between removing the glock from the AIL and the actual reference count. I need to understand if there are any race conditions or logic errors here. The interaction of the AIL and the glock reference counting is the crucial piece here.
|
| 23/2 |
2026/09/07 00:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/log.c Name:gfs2_ail_drain]
Results: map[SourceCode: 927: /**
928: * gfs2_ail_drain - drain the ail lists after a withdraw
929: * @sdp: Pointer to GFS2 superblock
930: */
931: void gfs2_ail_drain(struct gfs2_sbd *sdp)
932: {
933: struct gfs2_trans *tr;
934:
935: spin_lock(&sdp->sd_ail_lock);
936: /*
937: * For transactions on the sd_ail1_list we need to drain both the
938: * ail1 and ail2 lists. That's because function gfs2_ail1_start_one
939: * (temporarily) moves items from its tr_ail1 list to tr_ail2 list
940: * before revokes are sent for that block. Items on the sd_ail2_list
941: * should have already gotten beyond that point, so no need.
942: */
943: while (!list_empty(&sdp->sd_ail1_list)) {
944: tr = list_first_entry(&sdp->sd_ail1_list, struct gfs2_trans,
945: tr_list);
946: gfs2_ail_empty_tr(sdp, tr, &tr->tr_ail1_list);
947: gfs2_ail_empty_tr(sdp, tr, &tr->tr_ail2_list);
948: list_del(&tr->tr_list);
949: gfs2_trans_free(sdp, tr);
950: }
951: while (!list_empty(&sdp->sd_ail2_list)) {
952: tr = list_first_entry(&sdp->sd_ail2_list, struct gfs2_trans,
953: tr_list);
954: gfs2_ail_empty_tr(sdp, tr, &tr->tr_ail2_list);
955: list_del(&tr->tr_list);
956: gfs2_trans_free(sdp, tr);
957: }
958: gfs2_drain_revokes(sdp);
959: spin_unlock(&sdp->sd_ail_lock);
960: }
SourceFile:fs/gfs2/log.c]
|
| 24/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 28210
output: 42
thoughts: 23
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Analyzing the AIL Removal Logic in GFS2**
Okay, so I'm looking at `gfs2_ail_empty_tr` here. My immediate thought is, "Ah, right, this is the function responsible for clearing the AIL (Active Intent List) within a transaction." Makes sense. A transaction completes, so we need to flush out what was pending.
The key line that jumps out is the call to `gfs2_remove_from_ail`. That's the core of the cleanup. I know that function. It's the workhorse that handles the actual removal of AIL entries. The question now becomes: *How* is `gfs2_remove_from_ail` being used within the `gfs2_ail_empty_tr` context? Are we removing individual AIL entries? All of them at once? Are there any subtleties regarding the order of removal, particularly in relation to dependencies between AIL entries?
My mind is immediately trying to trace the data structures involved: the transaction itself, the AIL, how the entries are linked, and what locks are being held at this point. I need to be sure the removal process is atomic and doesn't introduce any race conditions. Is this function called under a transaction lock? Are we dealing with any memory barriers here? These are the usual suspects I'd be looking for in any AIL manipulation.
Specifically, I'm thinking about the implications for crash recovery. If a crash happens mid-transaction, before the AIL is completely cleared, what happens? How robust is the recovery process? It's all about ensuring data consistency, and this `gfs2_remove_from_ail` call is a critical piece of the puzzle. I need to dig into the details to fully grasp its impact.
|
| 25/2 |
2026/09/07 00:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/log.c Name:gfs2_ail_empty_tr]
Results: map[SourceCode: 278: static void gfs2_ail_empty_tr(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
279: struct list_head *head)
280: {
281: struct gfs2_bufdata *bd;
282:
283: while (!list_empty(head)) {
284: bd = list_first_entry(head, struct gfs2_bufdata,
285: bd_ail_st_list);
286: gfs2_assert(sdp, bd->bd_tr == tr);
287: gfs2_remove_from_ail(bd);
288: }
289: }
SourceFile:fs/gfs2/log.c]
|
| 26/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 28912
output: 49
thoughts: 104
Thoughts: **GFS2 Allocation Item Removal and Glock Management**
Okay, so I'm looking at this `gfs2_remove_from_ail` function, and it's taking a `bd` (buffer descriptor) and removing it from both `bd_ail_st_list` and `bd_ail_gl_list`. The alarm bells are going off, though, because it seems like the `bd->bd_gl`, the associated glock, has *already* been freed! That's a huge problem. We shouldn't be messing with `bd`s linked to a freed glock.
The critical question here is: how are these glocks getting freed when there are still `bd`s referencing them on their `gl_ail_list`? This indicates a serious flaw in the reference counting or the glock lifecycle itself. I need to trace back how `bd_gl` is being assigned in the first place, and then dive deep into the reference count management for these glocks. Something is fundamentally off in the synchronization. This needs immediate investigation.
|
| 27/2 |
2026/09/07 00:25 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:fs/gfs2/log.c IncludeSnippetLines:0 Name:bd_gl SourceTreePrefix:]
Results: map[References:<nil> TruncatedOutput:false]
|
| 28/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 29311
output: 44
thoughts: 20
Thoughts: Okay, here's my summary, presented as a first-person account, focusing on the core understanding:
**Decoding the `gfs2_bufdata` Structure**
Right, let me see... I'm looking at `gfs2_bufdata`, and I'm zeroing in on this field, `bd_gl`. Okay, so `bd_gl` is a field *within* the `gfs2_bufdata` structure. That tells me a key piece of information. Since I'm familiar with the GFS2 architecture, this hints that this structure, the `gfs2_bufdata`, is intimately connected to managing buffer data in the context of global locking. The `gl` abbreviation suggests this will be a global lock. I'll need to drill down further to see how it's used, but my initial impression is that `bd_gl` likely holds a reference, key, or pointer related to a global lock that's guarding access or ensuring consistency related to the buffer data. This is right in line with how I'd expect GFS2 to work. My next step will be to confirm this is what it is and what its purpose is.
|
| 29/2 |
2026/09/07 00:25 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:fs/gfs2/log.c FieldOffset:<nil> Name:gfs2_bufdata]
Results: map[Fields:[map[Name:bd_bh OffsetBits:0 SizeBits:64] map[Name:bd_gl OffsetBits:64 SizeBits:64] map[Name:bd_blkno OffsetBits:128 SizeBits:64] map[Name:bd_list OffsetBits:192 SizeBits:128] map[Name:bd_tr OffsetBits:320 SizeBits:64] map[Name:bd_ail_st_list OffsetBits:384 SizeBits:128] map[Name:bd_ail_gl_list OffsetBits:512 SizeBits:128]]]
|
| 30/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 29791
output: 30
thoughts: 13
Thoughts: Here's my take on those thoughts:
**Tracing the Source of `bd_gl`**
Okay, so I need to figure out where the variable `bd_gl` is being assigned. This is a pretty common first step when debugging or understanding the flow of a system. I need to understand its value or why it has that specific value. I need to track it down. Maybe I'm troubleshooting a problem, or perhaps I'm trying to refactor some code and want to be sure I don't break anything. Either way, finding the declaration or assignment is the starting point. Let's dig in and figure out where this thing originates.
|
| 31/2 |
2026/09/07 00:25 |
tool |
grepper |
0m
Args: map[Expression:bd_gl = PathPrefix:fs/gfs2/]
Results: map[Output:fs/gfs2/trans.c=168=static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl,
--
fs/gfs2/trans.c-174- bd->bd_bh = bh;
fs/gfs2/trans.c:175: bd->bd_gl = gl;
fs/gfs2/trans.c-176- INIT_LIST_HEAD(&bd->bd_list);
--
fs/gfs2/trans.c=196=void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
--
fs/gfs2/trans.c-221- }
fs/gfs2/trans.c:222: gfs2_assert(sdp, bd->bd_gl == gl);
fs/gfs2/trans.c-223- set_bit(TR_TOUCHED, &tr->tr_flags);
--
fs/gfs2/trans.c=257=void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
--
fs/gfs2/trans.c-285- }
fs/gfs2/trans.c:286: gfs2_assert(sdp, bd->bd_gl == gl);
fs/gfs2/trans.c-287- set_bit(TR_TOUCHED, &tr->tr_flags);
]
|
| 32/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 30363
output: 41
thoughts: 29
Thoughts: Okay, here's my interpretation of those thoughts, presented as a first-person expert summary:
**Grasping the Glock Reference in GFS2 Allocations**
Alright, let's break this down. I'm focusing on `bd_gl`, specifically its setting within the `gfs2_alloc_bufdata` function. The key question I'm immediately posing is, "Does this allocation of `bd_gl` take a reference on the glock?" Understanding the lifecycle of that `glock` is absolutely crucial for ensuring data consistency and preventing race conditions in GFS2.
If a reference *is* taken, then we need to trace exactly how the reference is held. Is it held across the allocation of the `bufdata`? Is the `glock` acquired during the allocation? Is it released when `bufdata` are freed? What are the implications if the allocation is interrupted or fails? Knowing *precisely* the scope and duration of this "reference" is fundamental to preventing potential problems. I need to dig into the surrounding code and determine the specific mechanisms in place. The glock lifecycle is the critical piece here, and if `bd_gl` references it, I have to ensure the proper locking and unlocking behavior is followed by whatever process uses it.
|
| 33/2 |
2026/09/07 00:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/trans.c Name:gfs2_alloc_bufdata]
Results: map[SourceCode: 168: static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl,
169: struct buffer_head *bh)
170: {
171: struct gfs2_bufdata *bd;
172:
173: bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL);
174: bd->bd_bh = bh;
175: bd->bd_gl = gl;
176: INIT_LIST_HEAD(&bd->bd_list);
177: INIT_LIST_HEAD(&bd->bd_ail_st_list);
178: INIT_LIST_HEAD(&bd->bd_ail_gl_list);
179: return bd;
180: }
SourceFile:fs/gfs2/trans.c]
|
| 34/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 30967
output: 37
thoughts: 61
Thoughts: **Analyzing the Object Lifecycle**
Okay, so initially I was thinking, "Does this `gl` object need some explicit referencing?" But, no, it doesn't look like it directly does. But hold on... if `bd` is *actually* attached to `gl_ail_list`, shouldn't that automatically mean the `gl` object itself is kept alive through that connection? That's what I'm expecting. Let me trace back and see *exactly* where `bd` is being added to `gl_ail_list`. It's all about how that dependency is managed, and I need to verify that link.
|
| 35/2 |
2026/09/07 00:25 |
tool |
grepper |
0m
Args: map[Expression:list_add.*bd_ail_gl_list PathPrefix:fs/gfs2/]
Results: map[Output:fs/gfs2/lops.c=102=static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
--
fs/gfs2/lops.c-122- struct gfs2_glock *gl = bd->bd_gl;
fs/gfs2/lops.c:123: list_add(&bd->bd_ail_gl_list, &gl->gl_ail_list);
fs/gfs2/lops.c-124- atomic_inc(&gl->gl_ail_count);
]
|
| 36/2 |
2026/09/07 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 31358
output: 40
thoughts: 12
Thoughts: Okay, let's dive into this. Here's my take on `gfs2_unpin`:
**Unpinning in GFS2: My Mental Workflow**
Alright, so the task at hand is `gfs2_unpin`. This function, at its core, must be about removing a pin, or more accurately, releasing a resource that was previously pinned. In the context of GFS2, a clustered file system, "pinning" likely means preventing some operation, perhaps eviction from cache, flushing to disk, or maybe even preventing metadata from being moved. The goal of `gfs2_unpin`, then, has to be the exact opposite. I need to figure out what that "pin" represents, which operation it's blocking, and how to effectively *unblock* it.
My immediate thought process goes through the different levels within GFS2. What object is it pinned to? Is it a buffer, an inode, an extent, or something else entirely? What context is the function operating in? Is it being called in response to some I/O operation, or part of a regular background task? I need to understand the dependencies and interactions.
Now, I'm thinking about the potential consequences of this unpin. If I release something without ensuring consistency, could I introduce data corruption, inconsistencies across the cluster, or even deadlocks? I need to know the locking strategy within the function. Does it acquire any locks before doing anything or are there any race conditions? This is where my experience with distributed file systems comes into play. I need to be thinking about concurrent access and ensuring everything is properly synchronized.
Finally, I'll need to look at the surrounding code to determine how this function is integrated. What are the calling contexts? What pre-conditions are expected, and what post-conditions should be guaranteed? Error handling is critical, too. What happens if something goes wrong during the unpin process? Does it return an error, and, if so, how is the error handled higher up in the stack? Are there any invariants or data structures that are relying on this "pin" being maintained, and how will their state be ensured if the pin is released unexpectedly? I'll probably start reading the source with these questions in mind.
|
| 37/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/lops.c Name:gfs2_unpin]
Results: map[SourceCode: 102: static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
103: struct gfs2_trans *tr)
104: {
105: struct gfs2_bufdata *bd = bh->b_private;
106:
107: BUG_ON(!buffer_uptodate(bh));
108: BUG_ON(!buffer_pinned(bh));
109:
110: lock_buffer(bh);
111: mark_buffer_dirty(bh);
112: clear_buffer_pinned(bh);
113:
114: if (buffer_is_rgrp(bd))
115: maybe_release_space(bd);
116:
117: spin_lock(&sdp->sd_ail_lock);
118: if (bd->bd_tr) {
119: list_del(&bd->bd_ail_st_list);
120: brelse(bh);
121: } else {
122: struct gfs2_glock *gl = bd->bd_gl;
123: list_add(&bd->bd_ail_gl_list, &gl->gl_ail_list);
124: atomic_inc(&gl->gl_ail_count);
125: }
126: bd->bd_tr = tr;
127: list_add(&bd->bd_ail_st_list, &tr->tr_ail1_list);
128: spin_unlock(&sdp->sd_ail_lock);
129:
130: clear_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
131: trace_gfs2_pin(bd, 0);
132: unlock_buffer(bh);
133: atomic_dec(&sdp->sd_log_pinned);
134: }
SourceFile:fs/gfs2/lops.c]
|
| 38/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 32459
output: 43
thoughts: 103
Thoughts: **My Analysis of `gfs2_unpin` and Glock Management**
Okay, so `gfs2_unpin` is adding this `bd` structure to the `gl_ail_list` and bumping up the `gl_ail_count`. Seems straightforward enough, right? But something feels off. It doesn't appear to be taking a reference on the glock itself, which is a potential red flag.
My immediate concern is: if `gl_ail_count` is incremented, *does* that actually prevent the glock from getting freed? That's the critical question here. I need to know if the count is considered when the system is deciding if the glock can be deallocated.
The next step is clear. I need to dig into `__gfs2_glock_put` to see how it handles freeing the glock, and crucially, how `gl_ail_count` factors into that process. Let's see if this count is actually used for protection.
|
| 39/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:__gfs2_glock_put]
Results: map[SourceCode: 210: static void __gfs2_glock_put(struct gfs2_glock *gl)
211: {
212: struct gfs2_sbd *sdp = glock_sbd(gl);
213: struct address_space *mapping = gfs2_glock2aspace(gl);
214:
215: lockref_mark_dead(&gl->gl_lockref);
216: spin_unlock(&gl->gl_lockref.lock);
217: GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders));
218: if (mapping) {
219: truncate_inode_pages_final(mapping);
220: if (!gfs2_withdrawn(sdp))
221: GLOCK_BUG_ON(gl, !mapping_empty(mapping));
222: }
223: trace_gfs2_glock_put(gl);
224: sdp->sd_lockstruct.ls_ops->lm_put_lock(gl);
225: }
SourceFile:fs/gfs2/glock.c]
|
| 40/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 33150
output: 43
thoughts: 51
Thoughts: Okay, here's my interpretation of those thoughts, summarized from my perspective as an expert in the field:
**Debugging Glitch: `gl_ail_count` Oversight**
Hmm, this code snippet seems to have a problem. I'm immediately noticing a potential issue: it's not explicitly checking the `gl_ail_count` field. That feels...off. We're dealing with glocks here, and overlooking this counter could lead to serious problems with lock management and potentially, data corruption if we're not careful.
Wait a second, wasn't `gl_ail_count` handled in `gfs2_glock_free`? Let's confirm that. To make sure, let me go straight to the source, and check the implementation of `__gfs2_glock_free` to verify precisely what's going on with `gl_ail_count` there. It's time to dig into the details and make sure there isn't an unintentional oversight or unexpected behavior.
|
| 41/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:__gfs2_glock_free]
Results: map[SourceCode: 139: static void __gfs2_glock_free(struct gfs2_glock *gl)
140: {
141: rhashtable_remove_fast(&gl_hash_table, &gl->gl_node, ht_parms);
142: smp_mb();
143: wake_up_glock(gl);
144: call_rcu(&gl->gl_rcu, gfs2_glock_dealloc);
145: }
SourceFile:fs/gfs2/glock.c]
|
| 42/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 33628
output: 42
thoughts: 79
Thoughts: Okay, let me think this through.
**Analyzing Glock Reference Counting in GFS2**
Hmm, no, I haven't explicitly checked that. But, hold on a second... the `gfs2_glock_put` function gets called precisely when the `gl_lockref.count` field within the glock structure hits zero. That's the crucial trigger. Now, the key question is: who, or what, is *holding* these references to the glock? I need to understand the lifecycle. Specifically, if that counter is accurate when it hits zero.
Ah, I remember, whenever a transaction modifies a buffer, doesn't it have to take a reference on the glock associated with that buffer? That would make sense, ensuring the lock is held as long as the data is being touched. Alright, I need to confirm that transaction. That should explain the locking scheme.
Okay, let's trace through the `gfs2_trans_add_data` function and see how it works. That should give me the answer.
|
| 43/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/trans.c Name:gfs2_trans_add_data]
Results: map[SourceCode: 182: /**
183: * gfs2_trans_add_data - Add a databuf to the transaction.
184: * @gl: The inode glock associated with the buffer
185: * @bh: The buffer to add
186: *
187: * This is used in journaled data mode.
188: * We need to journal the data block in the same way as metadata in
189: * the functions above. The difference is that here we have a tag
190: * which is two __be64's being the block number (as per meta data)
191: * and a flag which says whether the data block needs escaping or
192: * not. This means we need a new log entry for each 251 or so data
193: * blocks, which isn't an enormous overhead but twice as much as
194: * for normal metadata blocks.
195: */
196: void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
197: {
198: struct gfs2_trans *tr = current->journal_info;
199: struct gfs2_sbd *sdp = glock_sbd(gl);
200: struct gfs2_bufdata *bd;
201:
202: lock_buffer(bh);
203: if (buffer_pinned(bh)) {
204: set_bit(TR_TOUCHED, &tr->tr_flags);
205: goto out;
206: }
207: spin_lock(&sdp->sd_log_lock);
208: bd = bh->b_private;
209: if (bd == NULL) {
210: spin_unlock(&sdp->sd_log_lock);
211: unlock_buffer(bh);
212: bd = gfs2_alloc_bufdata(gl, bh);
213: lock_buffer(bh);
214: spin_lock(&sdp->sd_log_lock);
215: if (bh->b_private) {
216: kmem_cache_free(gfs2_bufdata_cachep, bd);
217: bd = bh->b_private;
218: } else {
219: bh->b_private = bd;
220: }
221: }
222: gfs2_assert(sdp, bd->bd_gl == gl);
223: set_bit(TR_TOUCHED, &tr->tr_flags);
224: if (list_empty(&bd->bd_list)) {
225: set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
226: set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
227: gfs2_pin(sdp, bd->bd_bh);
228: tr->tr_num_databuf_new++;
229: list_add_tail(&bd->bd_list, &tr->tr_databuf);
230: }
231: spin_unlock(&sdp->sd_log_lock);
232: out:
233: unlock_buffer(bh);
234: }
SourceFile:fs/gfs2/trans.c]
|
| 44/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 34927
output: 41
thoughts: 99
Thoughts: **Glock Reference in the GFS2 File System**
Okay, so I'm thinking about how the Glock is referenced in GFS2, specifically when dealing with dirty buffers and inodes. I can see that there isn't a direct reference on the glock. However, if a block device (`bd`) is tied to a buffer and that buffer is flagged as dirty, then the inode associated with that buffer *must* also be dirty, right? And, if the inode is dirty, then it stands to reason the inode itself would have some sort of reference to the Glock? Yep, confirmed - `ip->i_gl` is the pointer.
But, a new thought, what happens if that inode gets evicted from the in-core inode cache? When an inode is evicted, it has to write any dirty pages back to disk, right? I'm betting that's where the Glock comes into play again, ensuring consistent access during the writeback. Alright, I'll take a look at the `gfs2_evict_inode` function and confirm that process.
|
| 45/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/super.c Name:gfs2_evict_inode]
Results: map[SourceCode:1445: static void gfs2_evict_inode(struct inode *inode)
1446: {
1447: struct super_block *sb = inode->i_sb;
1448: struct gfs2_sbd *sdp = sb->s_fs_info;
1449: struct gfs2_inode *ip = GFS2_I(inode);
1450: struct gfs2_holder gh;
1451: enum evict_behavior behavior;
1452: int ret;
1453:
1454: gfs2_holder_mark_uninitialized(&gh);
1455: if (sb_rdonly(sb) || !ip->i_no_addr || !ip->i_gl)
1456: goto out;
1457:
1458: /*
1459: * In case of an incomplete mount, gfs2_evict_inode() may be called for
1460: * system files without having an active journal to write to. In that
1461: * case, skip the filesystem evict.
1462: */
1463: if (!sdp->sd_jdesc)
1464: goto out;
1465:
1466: behavior = evict_should_delete(inode, &gh);
1467: if (behavior == EVICT_SHOULD_DEFER_DELETE &&
1468: !test_bit(SDF_KILL, &sdp->sd_flags)) {
1469: struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl;
1470:
1471: if (io_gl) {
1472: gfs2_glock_hold(io_gl);
1473: if (!gfs2_queue_verify_delete(io_gl, true))
1474: gfs2_glock_put(io_gl);
1475: goto out;
1476: }
1477: behavior = EVICT_SHOULD_SKIP_DELETE;
1478: }
1479: if (behavior == EVICT_SHOULD_DELETE)
1480: ret = evict_unlinked_inode(inode, &gh);
1481: else
1482: ret = evict_linked_inode(inode, &gh);
1483:
1484: if (gfs2_rs_active(&ip->i_res))
1485: gfs2_rs_deltree(&ip->i_res);
1486:
1487: if (ret && !gfs2_withdrawn(sdp) && ret != -EROFS)
1488: fs_warn(sdp, "gfs2_evict_inode: %d\n", ret);
1489: out:
1490: if (gfs2_holder_initialized(&gh))
1491: gfs2_glock_dq_uninit(&gh);
1492: gfs2_truncate_inode_pages_final(inode);
1493: if (ip->i_qadata)
1494: gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1495: gfs2_rs_deltree(&ip->i_res);
1496: gfs2_ordered_del_inode(ip);
1497: clear_inode(inode);
1498: gfs2_dir_hash_inval(ip);
1499: if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
1500: struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1501:
1502: glock_clear_object(gl, ip);
1503: gfs2_glock_hold(gl);
1504: ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1505: gfs2_glock_dq_uninit(&ip->i_iopen_gh);
1506: gfs2_glock_put_eventually(gl);
1507: }
1508: if (ip->i_gl) {
1509: glock_clear_object(ip->i_gl, ip);
1510: wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
1511: gfs2_glock_put_eventually(ip->i_gl);
1512: rcu_assign_pointer(ip->i_gl, NULL);
1513: }
1514: }
SourceFile:fs/gfs2/super.c]
|
| 46/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 36597
output: 36
thoughts: 332
Thoughts: **Analyzing Potential Data Loss During Filesystem Withdrawal**
Okay, so I'm digging into this crash, and it seems related to inode eviction and a filesystem being withdrawn. My initial thought is that when an inode gets evicted, `gfs2_glock_put_eventually(ip->i_gl)` is called, which makes sense. Normally, that process would include truncating the inode's pages to clear them. But what happens if the filesystem is in a withdrawn state *during* that eviction?
Looking at `gfs2_evict_inode`, I see a crucial check:
```c
if (ret && !gfs2_withdrawn(sdp) && ret != -EROFS)
fs_warn(sdp, "gfs2_evict_inode: %d\n", ret);
```
This suggests that if the filesystem is withdrawn (`gfs2_withdrawn(sdp)` returns true), `gfs2_evict_inode` *might* skip writing out dirty pages. That's immediately concerning because we could be losing data.
Then there's the stack trace of the crash itself:
```
gfs2_remove_from_ail+0x138/0x340 fs/gfs2/log.c:79
gfs2_ail_empty_tr fs/gfs2/log.c:287 [inline]
gfs2_ail_drain+0x39c/0x6b0 fs/gfs2/log.c:954
do_withdraw+0xeb/0x300 fs/gfs2/util.c:126
gfs2_withdraw_func+0x349/0x3d0 fs/gfs2/util.c:236
```
That's the key! `gfs2_withdraw_func` is clearly active. So, the crash is definitely happening during filesystem withdrawal. I need to understand what `do_withdraw` is actually doing in this context, and then figure out why the eviction process isn't writing the dirty pages to disk. This feels like a race condition between withdrawal and eviction, potentially causing data loss. The focus now is `do_withdraw`.
|
| 47/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/util.c Name:do_withdraw]
Results: map[SourceCode: 118: static void do_withdraw(struct gfs2_sbd *sdp)
119: {
120: down_write(&sdp->sd_log_flush_lock);
121: if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
122: up_write(&sdp->sd_log_flush_lock);
123: return;
124: }
125: clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
126: gfs2_ail_drain(sdp); /* frees all transactions */
127: up_write(&sdp->sd_log_flush_lock);
128:
129: wake_up(&sdp->sd_logd_waitq);
130: wake_up(&sdp->sd_quota_wait);
131:
132: wait_event_timeout(sdp->sd_log_waitq,
133: gfs2_log_is_empty(sdp),
134: HZ * 5);
135:
136: sdp->sd_vfs->s_flags |= SB_RDONLY;
137:
138: /*
139: * Dequeue any pending non-system glock holders that can no
140: * longer be granted because the file system is withdrawn.
141: */
142: gfs2_withdraw_glocks(sdp);
143: }
SourceFile:fs/gfs2/util.c]
|
| 48/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 37921
output: 43
thoughts: 482
Thoughts: **Analyzing GFS2 Glock Deallocation During Filesystem Withdrawal**
Okay, so `do_withdraw` is running, meaning the filesystem is going offline. The code calls `gfs2_ail_drain(sdp)`, and my immediate question is: what happens to the glocks? My assumption is that `gfs2_withdraw_glocks(sdp)` handles freeing them, but looking closer, that's called *after* the AIL drain. This raises a red flag, meaning some glocks might be freed *before* the explicit withdrawal process begins.
I need to understand the mechanism here. Let's trace a glock deallocation using the stack trace provided. I see `gfs2_glock_dealloc` at the core, called from `rcu_do_batch`, suggesting an RCU-related freeing process. The glock was queued for freeing by `gfs2_glock_free` and subsequently via `glock_work_func`. Ah, `glock_work_func` is the key. It looks like it dropped the final reference to the glock, leading to its deallocation. The `gl->gl_lockref.count` reaching zero seems to be the trigger.
But this seems problematic. We know `gl_ail_list` is associated with buffered data, meaning there can be `bd`s (buffer descriptors) associated with this glock and queued for writeback. Shouldn't the presence of those buffered data pins the glock? I need to clarify how AIL pinning interacts with the reference count. Let's see how this works in `gfs2_unpin`: it adds the `bd` to `gl->gl_ail_list` and then increments `gl->gl_ail_count`. Critically, it does *not* increment `gl_lockref.count`. This is a crucial distinction.
Now I see the problem. If `gl_ail_count` is non-zero, it means there's AIL work queued on this glock, but the glock is *still* eligible for deallocation because its reference count isn't being explicitly held by the AIL! This is a serious concurrency issue during filesystem withdrawal. I need to investigate `__gfs2_glock_put` now to fully understand the deallocation path and confirm my suspicion. This could explain a subtle data corruption bug.
|
| 49/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:__gfs2_glock_put]
Results: map[SourceCode: 210: static void __gfs2_glock_put(struct gfs2_glock *gl)
211: {
212: struct gfs2_sbd *sdp = glock_sbd(gl);
213: struct address_space *mapping = gfs2_glock2aspace(gl);
214:
215: lockref_mark_dead(&gl->gl_lockref);
216: spin_unlock(&gl->gl_lockref.lock);
217: GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders));
218: if (mapping) {
219: truncate_inode_pages_final(mapping);
220: if (!gfs2_withdrawn(sdp))
221: GLOCK_BUG_ON(gl, !mapping_empty(mapping));
222: }
223: trace_gfs2_glock_put(gl);
224: sdp->sd_lockstruct.ls_ops->lm_put_lock(gl);
225: }
SourceFile:fs/gfs2/glock.c]
|
| 50/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 39285
output: 41
thoughts: 151
Thoughts: **My Concerns Regarding `gl_ail_count` and Glock Lifespan**
Okay, so I'm looking at this code and something is immediately grabbing my attention. It seems like it's *not* explicitly checking `gl_ail_count`. Now, my expertise tells me this is a potential problem. If this count isn't being used as a reference counter, how is the Glock—the global lock—surviving when there are still entries on the `gl_ail_list`? That's the crux of my worry.
Typically, and this is what I'd expect, the inode holds a reference to the Glock through `ip->i_gl`. And the VFS cache, of course, is what keeps the inode alive. When the system is working as intended, when an inode is evicted, it's supposed to write out its dirty pages. Now, importantly, these pages, once written, should be removed from the AIL—the active inode list. So, everything should be tidy in the normal case.
But... here's where my worry deepens. If the filesystem is somehow withdrawn, `gfs2_evict_inode` *might* skip writing out these pages! That could leave the Glock hanging in an unstable state. This needs a closer look, so I'm going to revisit `gfs2_evict_inode` to confirm my suspicion and understand the implications of this possible oversight.
|
| 51/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/super.c Name:gfs2_evict_inode]
Results: map[SourceCode:1445: static void gfs2_evict_inode(struct inode *inode)
1446: {
1447: struct super_block *sb = inode->i_sb;
1448: struct gfs2_sbd *sdp = sb->s_fs_info;
1449: struct gfs2_inode *ip = GFS2_I(inode);
1450: struct gfs2_holder gh;
1451: enum evict_behavior behavior;
1452: int ret;
1453:
1454: gfs2_holder_mark_uninitialized(&gh);
1455: if (sb_rdonly(sb) || !ip->i_no_addr || !ip->i_gl)
1456: goto out;
1457:
1458: /*
1459: * In case of an incomplete mount, gfs2_evict_inode() may be called for
1460: * system files without having an active journal to write to. In that
1461: * case, skip the filesystem evict.
1462: */
1463: if (!sdp->sd_jdesc)
1464: goto out;
1465:
1466: behavior = evict_should_delete(inode, &gh);
1467: if (behavior == EVICT_SHOULD_DEFER_DELETE &&
1468: !test_bit(SDF_KILL, &sdp->sd_flags)) {
1469: struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl;
1470:
1471: if (io_gl) {
1472: gfs2_glock_hold(io_gl);
1473: if (!gfs2_queue_verify_delete(io_gl, true))
1474: gfs2_glock_put(io_gl);
1475: goto out;
1476: }
1477: behavior = EVICT_SHOULD_SKIP_DELETE;
1478: }
1479: if (behavior == EVICT_SHOULD_DELETE)
1480: ret = evict_unlinked_inode(inode, &gh);
1481: else
1482: ret = evict_linked_inode(inode, &gh);
1483:
1484: if (gfs2_rs_active(&ip->i_res))
1485: gfs2_rs_deltree(&ip->i_res);
1486:
1487: if (ret && !gfs2_withdrawn(sdp) && ret != -EROFS)
1488: fs_warn(sdp, "gfs2_evict_inode: %d\n", ret);
1489: out:
1490: if (gfs2_holder_initialized(&gh))
1491: gfs2_glock_dq_uninit(&gh);
1492: gfs2_truncate_inode_pages_final(inode);
1493: if (ip->i_qadata)
1494: gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1495: gfs2_rs_deltree(&ip->i_res);
1496: gfs2_ordered_del_inode(ip);
1497: clear_inode(inode);
1498: gfs2_dir_hash_inval(ip);
1499: if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
1500: struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1501:
1502: glock_clear_object(gl, ip);
1503: gfs2_glock_hold(gl);
1504: ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1505: gfs2_glock_dq_uninit(&ip->i_iopen_gh);
1506: gfs2_glock_put_eventually(gl);
1507: }
1508: if (ip->i_gl) {
1509: glock_clear_object(ip->i_gl, ip);
1510: wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
1511: gfs2_glock_put_eventually(ip->i_gl);
1512: rcu_assign_pointer(ip->i_gl, NULL);
1513: }
1514: }
SourceFile:fs/gfs2/super.c]
|
| 52/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 41084
output: 39
thoughts: 86
Thoughts: **Analyzing Potential GFS2 Inode Eviction Issues**
Okay, so I'm thinking about this GFS2 code and specifically the inode eviction process. If `gfs2_withdrawn(sdp)` is true – which indicates some sort of resource withdrawal condition within the shared disk partition (SDP) – then `evict_linked_inode` or `evict_unlinked_inode` *might* misbehave. The functions might return an error, or perhaps, skip writing out the necessary pages. This sounds like it could cause some serious data inconsistencies if it isn't handled correctly.
Wait a second… I need to consider `evict_linked_inode` more closely. I remember that function calls `gfs2_glock_nq_init`, and that's concerning. That glock initialization function could *definitely* fail if the system is in a withdrawn state. I need to specifically focus on `evict_linked_inode` since this glock issue is clearly relevant and could be the primary source of problems if `gfs2_withdrawn` is true. Let me take a look at the `evict_linked_inode` source.
|
| 53/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/super.c Name:evict_linked_inode]
Results: map[SourceCode:1384: /*
1385: * evict_linked_inode - evict an inode whose dinode has not been unlinked
1386: * @inode: The inode to evict
1387: * @gh: The glock holder structure
1388: */
1389: static int evict_linked_inode(struct inode *inode, struct gfs2_holder *gh)
1390: {
1391: struct super_block *sb = inode->i_sb;
1392: struct gfs2_sbd *sdp = sb->s_fs_info;
1393: struct gfs2_inode *ip = GFS2_I(inode);
1394: struct gfs2_glock *gl = ip->i_gl;
1395: struct address_space *metamapping = gfs2_glock2aspace(gl);
1396: int ret;
1397:
1398: if (!(test_bit(GLF_DIRTY, &gl->gl_flags) || inode->i_flags & I_DIRTY))
1399: goto clean;
1400:
1401: /* The inode glock must be held exclusively and be instantiated. */
1402: if (!gfs2_holder_initialized(gh))
1403: ret = gfs2_glock_nq_init(gl, LM_ST_EXCLUSIVE, 0, gh);
1404: else
1405: ret = gfs2_instantiate(gh);
1406: if (ret)
1407: return ret;
1408:
1409: gfs2_log_flush(sdp, gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
1410: GFS2_LFC_EVICT_INODE);
1411: if (test_bit(GLF_DIRTY, &gl->gl_flags)) {
1412: filemap_fdatawrite(metamapping);
1413: filemap_fdatawait(metamapping);
1414: }
1415: write_inode_now(inode, 1);
1416: gfs2_ail_flush(gl, 0);
1417:
1418: clean:
1419: ret = gfs2_truncate_inode_pages(inode);
1420: truncate_inode_pages(metamapping, 0);
1421: return ret;
1422: }
SourceFile:fs/gfs2/super.c]
|
| 54/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 42160
output: 43
thoughts: 473
Thoughts: **Analyzing the GFS2 Inode Eviction Path**
Okay, so I'm digging into this GFS2 inode eviction code. The first thing that jumps out is the potential for an early return from `evict_linked_inode` if `gfs2_glock_nq_init` fails. That failure, probably due to a withdraw scenario, causes `evict_linked_inode` to return `ret` immediately. This is where things get interesting because it looks like `gfs2_truncate_inode_pages` and `truncate_inode_pages(metamapping, 0)` *aren't* called in that error path. Hold on… that's a key observation!
If `ret` is returned, then `gfs2_evict_inode` is still going to run, and I need to track what happens next. The `out:` label is the crucial section. It handles cleaning up the glock holder if initialized, calls `gfs2_truncate_inode_pages_final(inode)`, checks `qa_ref`, removes the resource, deletes the inode from the ordered list, clears the inode, invalidates the directory hash, and handles clearing the `i_iopen_gh` and `i_gl` glocks.
Crucially, I noticed that `truncate_inode_pages(metamapping, 0)` is *not* explicitly called when `evict_linked_inode` fails. But, and this is the important part, `metamapping` is the address space associated with the glock, specifically `gfs2_glock2aspace(gl)`. I know that `gfs2_glock_put` *does* call `truncate_inode_pages_final(mapping)`. That's where I need to look closer. I'm going to jump into the `__gfs2_glock_put` function to see what it's doing with that `mapping` argument and make sure this path is properly handled. This is where I'll find my answer. I need to understand whether this is a legitimate optimization, or potentially a subtle bug.
|
| 55/2 |
2026/09/07 00:26 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:fs/gfs2/glock.c Name:__gfs2_glock_put]
|
| 56/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 43268
output: 31
thoughts: 332
Thoughts: **My Line of Reasoning for `__gfs2_glock_put`**
Okay, so I'm looking at `__gfs2_glock_put`. Right off the bat, I see the call to `truncate_inode_pages_final(mapping)`. That's interesting, because I know what that function does: it cleans up the `metamapping` associated with the glock. Essentially, it's the process of freeing the pages.
Now, a page being freed, that directly implies that any buffers associated with that page also need to be freed. It's a fundamental principle of memory management in this context. It then follows that `gfs2_releasepage` or something similar, is likely being called. I need to make sure I understand the complete lifecycle here. This is where I'll look to understand if `gfs2_release_folio` is involved too.
|
| 57/2 |
2026/09/07 00:26 |
tool |
grepper |
0m
Args: map[Expression:release_folio.*= PathPrefix:fs/gfs2/]
Results: map[Output:fs/gfs2/aops.c=711=static const struct address_space_operations gfs2_aops = {
--
fs/gfs2/aops.c-715- .dirty_folio = iomap_dirty_folio,
fs/gfs2/aops.c:716: .release_folio = iomap_release_folio,
fs/gfs2/aops.c-717- .invalidate_folio = iomap_invalidate_folio,
--
fs/gfs2/aops.c=724=static const struct address_space_operations gfs2_jdata_aops = {
--
fs/gfs2/aops.c-731- .invalidate_folio = gfs2_invalidate_folio,
fs/gfs2/aops.c:732: .release_folio = gfs2_release_folio,
fs/gfs2/aops.c-733- .is_partially_uptodate = block_is_partially_uptodate,
--
fs/gfs2/meta_io.c=102=const struct address_space_operations gfs2_meta_aops = {
--
fs/gfs2/meta_io.c-105- .writepages = gfs2_aspace_writepages,
fs/gfs2/meta_io.c:106: .release_folio = gfs2_release_folio,
fs/gfs2/meta_io.c-107- .migrate_folio = buffer_migrate_folio_norefs,
--
fs/gfs2/meta_io.c=110=const struct address_space_operations gfs2_rgrp_aops = {
--
fs/gfs2/meta_io.c-113- .writepages = gfs2_aspace_writepages,
fs/gfs2/meta_io.c:114: .release_folio = gfs2_release_folio,
fs/gfs2/meta_io.c-115- .migrate_folio = buffer_migrate_folio_norefs,
]
|
| 58/2 |
2026/09/07 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 44365
output: 41
thoughts: 14
Thoughts: Okay, let's dive into this. Here's how I'd approach summarizing the "thoughts" you've presented, as if they were my own internal thought process, tailored for a fellow expert:
**Investigating `gfs2_release_folio`**
Alright, so the task at hand is to analyze `gfs2_release_folio`. Given my experience with the GFS2 file system internals, I know this is a critical function, likely dealing with releasing a folio (likely a page cache abstraction in this context). The name itself screams "cleanup" and "resource management," which are bread and butter in file system development. My immediate questions are:
* What are the preconditions for calling this? What states is the folio expected to be in?
* What is the specific locking involved? Are we talking about page locks, inode locks, or something else entirely? Concurrent access can get hairy real quick.
* What resources are *actually* being released? Is it just the folio itself, or are associated metadata structures and buffers being cleaned up too?
* Are there any subtle interactions with other functions, especially writeback or journaling operations, that I need to be aware of? Deadlocks are always a risk in these situations.
* What about error handling? Is it robust? Does it properly handle the case where, for instance, a writeback operation fails during a release? Are there subtle memory leaks or corruption vulnerabilities?
I'll need to look very closely at the code itself, not just the function signature, and think about the wider context it operates within. Specifically, I'll pay close attention to the following:
* The code immediately surrounding the function call, which should provide hints about the folio's lifecycle.
* Any calls to other GFS2 functions within `gfs2_release_folio`, which might reveal dependencies or related operations.
* Any error paths. Robust error handling is crucial.
* Any interactions with locking mechanisms.
* Any memory management aspects.
Essentially, I'll need to dissect its role in the greater scheme of things: understanding how the function integrates into GFS2's page cache management and block allocation. Then I can make sound judgement on its quality.
|
| 59/2 |
2026/09/07 00:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/aops.c Name:gfs2_release_folio]
Results: map[SourceCode: 648: bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask)
649: {
650: struct address_space *mapping = folio->mapping;
651: struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping);
652: struct buffer_head *bh, *head;
653: struct gfs2_bufdata *bd;
654:
655: head = folio_buffers(folio);
656: if (!head)
657: return false;
658:
659: /*
660: * mm accommodates an old ext3 case where clean folios might
661: * not have had the dirty bit cleared. Thus, it can send actual
662: * dirty folios to ->release_folio() via shrink_active_list().
663: *
664: * As a workaround, we skip folios that contain dirty buffers
665: * below. Once ->release_folio isn't called on dirty folios
666: * anymore, we can warn on dirty buffers like we used to here
667: * again.
668: */
669:
670: spin_lock(&sdp->sd_log_lock);
671: bh = head;
672: do {
673: if (atomic_read(&bh->b_count))
674: goto cannot_release;
675: bd = bh->b_private;
676: if (bd && bd->bd_tr)
677: goto cannot_release;
678: if (buffer_dirty(bh) || WARN_ON(buffer_pinned(bh)))
679: goto cannot_release;
680: bh = bh->b_this_page;
681: } while (bh != head);
682:
683: bh = head;
684: do {
685: bd = bh->b_private;
686: if (bd) {
687: gfs2_assert_warn(sdp, bd->bd_bh == bh);
688: bd->bd_bh = NULL;
689: bh->b_private = NULL;
690: /*
691: * The bd may still be queued as a revoke, in which
692: * case we must not dequeue nor free it.
693: */
694: if (!bd->bd_blkno && !list_empty(&bd->bd_list))
695: list_del_init(&bd->bd_list);
696: if (list_empty(&bd->bd_list))
697: kmem_cache_free(gfs2_bufdata_cachep, bd);
698: }
699:
700: bh = bh->b_this_page;
701: } while (bh != head);
702: spin_unlock(&sdp->sd_log_lock);
703:
704: return try_to_free_buffers(folio);
705:
706: cannot_release:
707: spin_unlock(&sdp->sd_log_lock);
708: return false;
709: }
SourceFile:fs/gfs2/aops.c]
|
| 60/2 |
2026/09/07 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 45854
output: 53
thoughts: 1606
Thoughts: **The Problem: A Use-After-Free in GFS2's AIL Handling During Withdrawals**
Okay, here's what I've figured out: I've identified a use-after-free issue in GFS2, and here's the sequence of events. First, `gfs2_release_folio` checks if a buffer (`bd`) is in the AIL (Active Inode List) using `bd->bd_tr`. If it *is* in the AIL, it returns false, meaning it cannot be immediately freed. This makes sense: you can't free a buffer that's part of an active transaction. But here's where it gets interesting: the `truncate_inode_pages_final` function *doesn't* care if `gfs2_release_folio` fails, which initially seemed odd.
The process goes like this: `truncate_inode_pages_final` is called, which then calls `truncate_inode_pages`, which then calls `truncate_inode_folio`. `truncate_inode_folio` calls `filemap_remove_folio` which removes it from the page cache. Fine, the folio is removed. However, the buffers still hold a reference to the folio. Specifically, `alloc_page_buffers` takes a reference on the folio, so it's not actually freed until the buffers themselves are released.
The folios are removed from the page cache, meaning that `mapping_empty(mapping)` becomes true. This leads to the glock being freed. However, crucially, the `bd` (buffer descriptor) is *still* on the glock's AIL list (`gl->gl_ail_list`)! This is because `gfs2_release_folio` failed to free the buffer. The glock is freed while the buffer descriptor is still on the glock's AIL list.
Later on, `gfs2_ail_drain` is called, likely during a filesystem withdrawal. This function iterates through the AIL, finds the transaction, and calls `gfs2_ail_empty_tr`. `gfs2_ail_empty_tr` iterates through the transaction's AIL list (which contains the buffer descriptor, `bd`) and calls `gfs2_remove_from_ail(bd)`. The problem here is that `gfs2_remove_from_ail` accesses the `bd->bd_ail_gl_list` which now points to freed memory due to the `list_del_init` operation attempting to modify the glock's freed `gl_ail_list`. This is a clear use-after-free.
Here's the sequence again for clarity:
1. Buffer modified -> `bd` created, `bd->bd_gl` points to a glock.
2. Buffer unpinned (using `gfs2_unpin`) -> `bd` is added to AIL lists, `bd->bd_tr` is set.
3. Inode evicted.
4. Filesystem withdrawn (`gfs2_withdrawn(sdp)` is true).
5. `evict_linked_inode` (or similar) returns an error.
6. `gfs2_evict_inode` skips writing pages and AIL flush.
7. `gfs2_evict_inode` calls `gfs2_glock_put_eventually(ip->i_gl)`.
8. The glock's reference count drops to 0. `__gfs2_glock_put` is called.
9. `__gfs2_glock_put` calls `truncate_inode_pages_final(mapping)`.
10. `truncate_inode_pages_final` removes the folio from the mapping (page cache).
11. `__gfs2_glock_put` checks `!mapping_empty(mapping)`. The `GLOCK_BUG_ON` check is skipped due to the withdrawal.
12. `__gfs2_glock_put` calls `lm_put_lock(gl)`, which then calls `gfs2_glock_free`.
13. The glock is freed via RCU.
14. Meanwhile, `bd` is still on AIL lists.
15. The withdraw process continues. `do_withdraw` calls `gfs2_ail_drain(sdp)`.
16. `gfs2_ail_drain` finds transaction, calls `gfs2_remove_from_ail(bd)`.
17. `gfs2_remove_from_ail` accesses `bd->bd_ail_gl_list` to remove it from the list.
18. `
|
| 61/2 |
2026/09/07 00:27 |
tool |
git-log |
0m
Args: map[CodeRegexp:if \(!gfs2_withdrawn\(sdp\)\) Count:10 PathPrefix:fs/gfs2/glock.c]
Results: map[Output:0e10da69d167 gfs2: Clean up properly during a withdraw
af572efef10a Revert "gfs2: Allow some glocks to be used during withdraw"
1b7d498dcab4 gfs2: Rename gfs2_{withdrawing_or_ => }withdrawn
4d927b03a688 gfs2: Rename gfs2_withdrawn to gfs2_withdrawing_or_withdrawn
015af1af4400 gfs2: Mark withdraws as unlikely
ee1e2c773e4f gfs2: call truncate_inode_pages_final for address space glocks
]
|
| 62/2 |
2026/09/07 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 48714
output: 26
thoughts: 18
Thoughts: Okay, here's my interpretation of what's going through my mind when I see that prompt, tailored as if I'm an expert:
**Analyzing Commit `0e10da69d167`**
Alright, a commit hash, `0e10da69d167`. Right off the bat, I'm already mentally cross-referencing this against my mental database of recent work. Is it something I've seen before? Does the leading part of the hash, *0e10da*, ring any bells? I quickly try to remember if I was the one who did it, or who touched that area recently. I’m thinking about what project or repository this probably belongs to based on the current context.
Now, I'm expecting a full picture here. I need to know *why* I'm being asked to consider this specific commit. Is it part of a troubleshooting exercise? A code review request? Or are we trying to understand a specific regression? What am I trying to *do* with this commit? I need more context to give a truly relevant thought summary. Is this coming from a security audit perspective? A performance investigation? An upgrade planning discussion? All of these things matter.
The first thing I'm going to do if I have access, is to use my preferred Git tool to inspect the diff. I'm looking for the *type* of changes: are we talking about bug fixes, new features, refactoring, or documentation? Then, I'll pay close attention to the specific lines changed. I'll mentally map those changes to the relevant parts of the codebase, evaluating the potential impacts on the current system, and future developments. Is this a local change, or is it upstream and more important?
I'm trying to reconstruct the developer's thought process. What problem were they trying to solve with this change? Are there potential performance bottlenecks or subtle bugs that could arise? Does this commit introduce any breaking changes or require any careful migration steps? I'll also be mentally verifying that all related unit tests are included, and what testing was involved.
Ultimately, I’m building a mental model of this commit's place within the larger system. I’m evaluating its impact on stability, performance, maintainability, and security. I'll need more info, but I'm ready to dive into the specifics now.
|
| 63/2 |
2026/09/07 00:27 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 0e10da69d1671109b2ae5ed3eed6aa44b5ee64bc
Author: Andreas Gruenbacher <agruenba@redhat.com>
Date: Tue Aug 5 00:07:02 2025 +0200
gfs2: Clean up properly during a withdraw
During a withdraw, we don't want to write out any more data than we have
to, so in do_xmote(), skip the ->go_sync() glock operation. We still
want to keep calling ->go_inval() to discard any cached data or
metadata, whether clean or dirty.
We do still allow glocks to transition into state LM_ST_UNLOCKED. This
has the desired side effect of calling ->go_inval() and invalidating the
glock caches.
Function gfs2_withdraw_glocks() is already used for dequeuing any
left-over waiters. We still want that to happen, but additionally, we
want all glocks to be unlocked.
Finally, we change function do_promote() to refuse any further
promotions.
This commit cleans up the leftovers of commit 86934198eefa ("gfs2: Clear
flags when withdraw prevents xmote").
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index ac9e10a41f00..267b442b4c09 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -458,8 +458,14 @@ int gfs2_instantiate(struct gfs2_holder *gh)
static void do_promote(struct gfs2_glock *gl)
{
+ struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
struct gfs2_holder *gh, *current_gh;
+ if (gfs2_withdrawn(sdp)) {
+ do_error(gl, LM_OUT_ERROR);
+ return;
+ }
+
current_gh = find_first_holder(gl);
list_for_each_entry(gh, &gl->gl_holders, gh_list) {
if (test_bit(HIF_HOLDER, &gh->gh_iflags))
@@ -565,7 +571,6 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)
state_change(gl, state);
}
-
/* Demote to UN request arrived during demote to SH or DF */
if (test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags) &&
gl->gl_state != LM_ST_UNLOCKED &&
@@ -654,28 +659,36 @@ __acquires(&gl->gl_lockref.lock)
struct lm_lockstruct *ls = &sdp->sd_lockstruct;
int ret;
- if (target != LM_ST_UNLOCKED && gfs2_withdrawn(sdp))
- goto skip_inval;
+ /*
+ * When a filesystem is withdrawing, the remaining cluster nodes will
+ * take care of recovering the withdrawing node's journal. We only
+ * need to make sure that once we trigger remote recovery, we won't
+ * write to the shared block device anymore. This means that here,
+ *
+ * - no new writes to the filesystem must be triggered (->go_sync()).
+ *
+ * - any cached data should be discarded by calling ->go_inval(), dirty
+ * or not and journaled or unjournaled.
+ *
+ * - no more dlm locking operations should be issued (->lm_lock()).
+ */
GLOCK_BUG_ON(gl, gl->gl_state == target);
GLOCK_BUG_ON(gl, gl->gl_state == gl->gl_target);
+
if (!glops->go_inval || !glops->go_sync)
goto skip_inval;
spin_unlock(&gl->gl_lockref.lock);
- ret = glops->go_sync(gl);
- /* If we had a problem syncing (due to io errors or whatever,
- * we should not invalidate the metadata or tell dlm to
- * release the glock to other nodes.
- */
- if (ret) {
- if (cmpxchg(&sdp->sd_log_error, 0, ret)) {
- fs_err(sdp, "Error %d syncing glock\n", ret);
- gfs2_dump_glock(NULL, gl, true);
- gfs2_withdraw(sdp);
+ if (!gfs2_withdrawn(sdp)) {
+ ret = glops->go_sync(gl);
+ if (ret) {
+ if (cmpxchg(&sdp->sd_log_error, 0, ret)) {
+ fs_err(sdp, "Error %d syncing glock\n", ret);
+ gfs2_dump_glock(NULL, gl, true);
+ gfs2_withdraw(sdp);
+ }
}
- spin_lock(&gl->gl_lockref.lock);
- goto skip_inval;
}
if (target == LM_ST_UNLOCKED || target == LM_ST_DEFERRED)
@@ -683,25 +696,10 @@ __acquires(&gl->gl_lockref.lock)
spin_lock(&gl->gl_lockref.lock);
skip_inval:
- if (gfs2_withdrawn(sdp) && target != LM_ST_UNLOCKED) {
- request_demote(gl, LM_ST_UNLOCKED, 0, false);
- /*
- * Ordinarily, we would call dlm and its callback would call
- * finish_xmote, which would call state_change() to the new state.
- * Since we withdrew, we won't call dlm, so call state_change
- * manually, but to the UNLOCKED state we desire.
- */
- state_change(gl, LM_ST_UNLOCKED);
- /*
- * We skip telling dlm to do the locking, so we won't get a
- * reply that would otherwise clear GLF_LOCK. So we clear it here.
- */
- if (!test_bit(GLF_CANCELING, &gl->gl_flags))
- clear_bit(GLF_LOCK, &gl->gl_flags);
- clear_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
- gl->gl_lockref.count++;
- gfs2_glock_queue_work(gl, GL_GLOCK_DFT_HOLD);
- return;
+ if (gfs2_withdrawn(sdp)) {
+ if (target != LM_ST_UNLOCKED)
+ target = LM_OUT_ERROR;
+ goto out;
}
if (ls->ls_ops->lm_lock) {
@@ -717,12 +715,15 @@ __acquires(&gl->gl_lockref.lock)
}
clear_bit(GLF_PENDING_REPLY, &gl->gl_flags);
- if (ret == -ENODEV && gl->gl_target == LM_ST_UNLOCKED &&
- target == LM_ST_UNLOCKED) {
+ if (ret == -ENODEV) {
/*
* The lockspace has been released and the lock has
* been unlocked implicitly.
*/
+ if (target != LM_ST_UNLOCKED) {
+ target = LM_OUT_ERROR;
+ goto out;
+ }
} else {
fs_err(sdp, "lm_lock ret %d\n", ret);
GLOCK_BUG_ON(gl, !gfs2_withdrawn(sdp));
@@ -730,6 +731,7 @@ __acquires(&gl->gl_lockref.lock)
}
}
+out:
/* Complete the operation now. */
finish_xmote(gl, target);
gl->gl_lockref.count++;
@@ -2081,8 +2083,17 @@ static void dump_glock_func(struct gfs2_glock *gl)
static void withdraw_glock(struct gfs2_glock *gl)
{
spin_lock(&gl->gl_lockref.lock);
- if (!__lockref_is_dead(&gl->gl_lockref))
+ if (!__lockref_is_dead(&gl->gl_lockref)) {
+ /*
+ * We don't want to write back any more dirty data. Unlock the
+ * remaining inode and resource group glocks; this will cause
+ * their ->go_inval() hooks to toss out all the remaining
+ * cached data, dirty or not.
+ */
+ if (gl->gl_ops->go_inval && gl->gl_state != LM_ST_UNLOCKED)
+ request_demote(gl, LM_ST_UNLOCKED, 0, false);
do_error(gl, LM_OUT_ERROR); /* remove pending waiters */
+ }
spin_unlock(&gl->gl_lockref.lock);
}
]
|
| 64/2 |
2026/09/07 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 51731
output: 40
thoughts: 135
Thoughts: **Analyzing the `0e10da69d167` Commit and Its Implications**
Okay, so this commit, `0e10da69d167`, is focused on optimizing a withdrawal process. The core idea is to reduce unnecessary I/O during a withdrawal, specifically within `do_xmote()`. The stated goal is to avoid the `->go_sync()` glock operation, but still ensure `->go_inval()` is called. That's a key distinction. We're keeping the invalidation step.
My initial thought is, if we're calling `go_inval`, then cached data *will* be discarded. That's the expected behavior. `go_inval` is, essentially, an eviction signal for the cache. For inode glocks specifically, this `go_inval` is handled by `inode_go_inval`. Now I need to refresh my memory on the workings of `inode_go_inval`. Let's dig into that function. The real detail lies there.
|
| 65/2 |
2026/09/07 00:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glops.c Name:inode_go_inval]
Results: map[SourceCode: 358: static void inode_go_inval(struct gfs2_glock *gl, int flags)
359: {
360: struct gfs2_inode *ip = gfs2_glock2inode(gl);
361:
362: gfs2_assert_withdraw(glock_sbd(gl), !atomic_read(&gl->gl_ail_count));
363:
364: if (flags & DIO_METADATA) {
365: struct address_space *mapping = gfs2_glock2aspace(gl);
366: truncate_inode_pages(mapping, 0);
367: if (ip) {
368: set_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags);
369: forget_all_cached_acls(&ip->i_inode);
370: security_inode_invalidate_secctx(&ip->i_inode);
371: gfs2_dir_hash_inval(ip);
372: }
373: }
374:
375: if (ip == GFS2_I(glock_sbd(gl)->sd_rindex)) {
376: gfs2_log_flush(glock_sbd(gl), NULL,
377: GFS2_LOG_HEAD_FLUSH_NORMAL |
378: GFS2_LFC_INODE_GO_INVAL);
379: glock_sbd(gl)->sd_rindex_uptodate = 0;
380: }
381: if (ip && S_ISREG(ip->i_inode.i_mode))
382: truncate_inode_pages(ip->i_inode.i_mapping, 0);
383:
384: gfs2_clear_glop_pending(ip);
385: }
SourceFile:fs/gfs2/glops.c]
|
| 66/2 |
2026/09/07 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 52687
output: 26
thoughts: 279
Thoughts: **My Analysis of the `inode_go_inval` Workflow**
Okay, so I'm looking at `inode_go_inval` and that `gfs2_assert_withdraw` call with the `glock`'s `gl_ail_count`... Right, if `gl_ail_count` isn't zero, it will withdraw the filesystem! But, and this is important, if the filesystem *is* already withdrawn, the `gfs2_assert_withdraw` just skips it. So, we're good and `inode_go_inval` keeps running.
Next up, it calls `truncate_inode_pages(mapping, 0)`. That's the folio removal part. But here's the kicker: if a folio has buffers and `bd->bd_tr` isn't `NULL`, then `gfs2_release_folio` *fails*. This means the buffers *aren't* freed. The folio is yanked out of the mapping, but it hangs around. Okay, got it.
Now, `__gfs2_glock_put` gets called, and that calls `truncate_inode_pages_final(mapping)`. Since `truncate_inode_pages` already removed the folios from the mapping, `mapping_empty(mapping)` comes back as true.
This brings up a question, I have to ask myself, if the mapping is empty at that point, then why did the developers add that `if (!gfs2_withdrawn(sdp))` check to `__gfs2_glock_put`? I need to check the commit log. Let's see... commit `ee1e2c773e4f`. Let me go check it.
|
| 67/2 |
2026/09/07 00:27 |
tool |
git-show |
0m
Args:
Results: map[Output:commit ee1e2c773e4f4ce2213f9d77cc703b669ca6fa3f
Author: Bob Peterson <rpeterso@redhat.com>
Date: Wed Sep 16 11:06:23 2020 -0500
gfs2: call truncate_inode_pages_final for address space glocks
Before this patch, we were not calling truncate_inode_pages_final for the
address space for glocks, which left the possibility of a leak. We now
take care of the problem instead of complaining, and we do it during
glock tear-down..
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 15c5c26f6ae7..19d4db4c44e7 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -270,7 +270,12 @@ static void __gfs2_glock_put(struct gfs2_glock *gl)
gfs2_glock_remove_from_lru(gl);
spin_unlock(&gl->gl_lockref.lock);
GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders));
- GLOCK_BUG_ON(gl, mapping && mapping->nrpages && !gfs2_withdrawn(sdp));
+ if (mapping) {
+ truncate_inode_pages_final(mapping);
+ if (!gfs2_withdrawn(sdp))
+ GLOCK_BUG_ON(gl, mapping->nrpages ||
+ mapping->nrexceptional);
+ }
trace_gfs2_glock_put(gl);
sdp->sd_lockstruct.ls_ops->lm_put_lock(gl);
}
]
|
| 68/2 |
2026/09/07 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 53913
output: 36
thoughts: 245
Thoughts: **My Analysis of a Potential Bug Fix**
Okay, so before this recent commit, the code checked for this condition: `GLOCK_BUG_ON(gl, mapping && mapping->nrpages && !gfs2_withdrawn(sdp));`. I immediately recognize that this was *already* ignoring `mapping->nrpages` if the superblock was in a withdrawn state. The reasoning is sound – if the system's withdrawn, we might not be able to flush the pages, which is why they'd stick around in the mapping.
But that makes me think, if pages *do* remain in the mapping due to a withdrawn state, wouldn't `truncate_inode_pages_final` throw a fit? I recall that function having this check:
```c
if (mapping->nrpages || mapping->nrexceptional) {
/*
* As this is probably a bug, print a warning.
*/
pr_err("BUG: %s: %lu pages or %lu exceptional entries still in mapping %p\n",
__func__, mapping->nrpages, mapping->nrexceptional, mapping);
}
```
However, I need to pause and remind myself that `truncate_inode_pages_final` doesn't actually remove folios. It *only* prints a warning if it detects folios still present. It's more of a diagnostic than a corrective action, and that's crucial. I need to go back and verify exactly what `truncate_inode_pages_final` is *really* doing.
|
| 69/2 |
2026/09/07 00:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:mm/truncate.c Name:truncate_inode_pages_final]
Results: map[SourceCode: 489: /**
490: * truncate_inode_pages_final - truncate *all* pages before inode dies
491: * @mapping: mapping to truncate
492: *
493: * Called under (and serialized by) inode->i_rwsem.
494: *
495: * Filesystems have to use this in the .evict_inode path to inform the
496: * VM that this is the final truncate and the inode is going away.
497: */
498: void truncate_inode_pages_final(struct address_space *mapping)
499: {
500: /*
501: * Page reclaim can not participate in regular inode lifetime
502: * management (can't call iput()) and thus can race with the
503: * inode teardown. Tell it when the address space is exiting,
504: * so that it does not install eviction information after the
505: * final truncate has begun.
506: */
507: mapping_set_exiting(mapping);
508:
509: if (!mapping_empty(mapping)) {
510: /*
511: * As truncation uses a lockless tree lookup, cycle
512: * the tree lock to make sure any ongoing tree
513: * modification that does not see AS_EXITING is
514: * completed before starting the final truncate.
515: */
516: xa_lock_irq(&mapping->i_pages);
517: xa_unlock_irq(&mapping->i_pages);
518: }
519:
520: truncate_inode_pages(mapping, 0);
521: }
SourceFile:mm/truncate.c]
|
| 70/2 |
2026/09/07 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 55042
output: 34
thoughts: 86
Thoughts: **Analyzing the Truncation Process**
Okay, so I'm tracing through this inode truncation procedure, and it looks like it *does* call `truncate_inode_pages(mapping, 0)`. That makes sense; it's the expected function to start the cleanup. Right, so it *should* remove the file's folios from the mapping. But here's a potential issue: what if `gfs2_release_folio` fails during that process? Will `truncate_inode_pages` correctly handle that? It seems like `truncate_inode_pages` will *still* remove the folio from the mapping, regardless. I need to confirm this. Ah, but `truncate_inode_pages` actually calls `truncate_inode_folio`, so I should inspect that function for more detail. Let me pull that up and see how it works.
|
| 71/2 |
2026/09/07 00:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:mm/truncate.c Name:truncate_inode_folio]
Results: map[SourceCode: 170: int truncate_inode_folio(struct address_space *mapping, struct folio *folio)
171: {
172: if (folio->mapping != mapping)
173: return -EIO;
174:
175: truncate_cleanup_folio(folio);
176: filemap_remove_folio(folio);
177: return 0;
178: }
SourceFile:mm/truncate.c]
|
| 72/2 |
2026/09/07 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 55491
output: 39
thoughts: 1239
Thoughts: **Analyzing a Potential Use-After-Free Vulnerability in GFS2**
Okay, so I'm following this logic, and it looks like `truncate_inode_pages_final` is removing the folio from the mapping, which is good. That means `mapping_empty(mapping)` should be true afterwards. Then, the `GLOCK_BUG_ON` check is bypassed. But if `gfs2_release_folio` fails, the folio and its buffers, *with* `bd` attached, are just left dangling, unmapped. And crucially, `bd->bd_gl` still points to the glock.
Now here's where it gets interesting: the glock is being freed via `__gfs2_glock_put`, and that's because `gl_lockref.count` reaches zero. And that zero count is happening because `gfs2_evict_inode` is calling `gfs2_glock_put_eventually(ip->i_gl)`. The key here is that `gfs2_evict_inode` is *not* waiting for the AIL to drain completely. Normally, `evict_linked_inode` calls `gfs2_ail_flush`, but that's skipped if the filesystem is withdrawing.
So, *the glock is being released while there are still items on its AIL list*! And that makes the glock available for freeing.
Alright, is this exploitable? Looking deeper, this appears to be a classic use-after-free on `gl_ail_list` when `gfs2_remove_from_ail` is called. That routine modifies `bd->bd_ail_gl_list.prev->next` and `bd->bd_ail_gl_list.next->prev`. If the `bd` is the only item on the `gl_ail_list`, then those `prev` and `next` pointers point back to the glock's AIL list itself, `gl->gl_ail_list`. But that glock has *already* been freed! So, now we have a write to freed memory. It's writing the address of `bd->bd_ail_gl_list` to where the glock's `gl_ail_list` used to be.
Can an attacker control this? The glock comes from the `gfs2_glock` cache, with a size of 1176. A heap spray might reallocate the memory. If the attacker reallocates the glock memory to something controlled, the pointer to `bd->bd_ail_gl_list` gets written into the attacker-controlled object at offset 280 (because of the 2240 bit value). That's a potential kernel pointer leak or a corruption vector.
The big hurdle is the need for the filesystem to be in a withdrawing state. Can an unprivileged user force that? A withdrawal usually means an inconsistency or an I/O error. If the user provides a *malicious* GFS2 image (perhaps on a USB drive), that could easily trigger a withdraw during the mount process by providing bad metadata.
The bug report shows this happening during the mount: `gfs2_fill_super`, `get_tree_bdev_flags`, and down the line to the `path_mount` functions. So, the glock is being allocated during the mount process, and then released somehow in a flawed way *during mount*. I need to look at the stack trace to determine how the glock is deallocated to understand this process more. It appears the glock is allocated in `gfs2_inode_lookup` during `init_sb`, then something fails, and it withdraws the mount. The `init_sb` routine is where the key information should be.
|
| 73/2 |
2026/09/07 00:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c Name:init_sb]
Results: map[SourceCode: 443: static int init_sb(struct gfs2_sbd *sdp, int silent)
444: {
445: struct super_block *sb = sdp->sd_vfs;
446: struct gfs2_holder sb_gh;
447: u64 no_addr;
448: int ret;
449:
450: ret = gfs2_glock_nq_num(sdp, GFS2_SB_LOCK, &gfs2_meta_glops,
451: LM_ST_SHARED, 0, &sb_gh);
452: if (ret) {
453: fs_err(sdp, "can't acquire superblock glock: %d\n", ret);
454: return ret;
455: }
456:
457: ret = gfs2_read_sb(sdp, silent);
458: if (ret) {
459: fs_err(sdp, "can't read superblock: %d\n", ret);
460: goto out;
461: }
462:
463: switch(sdp->sd_sb.sb_fs_format) {
464: case GFS2_FS_FORMAT_MAX:
465: sb->s_xattr = gfs2_xattr_handlers_max;
466: break;
467:
468: case GFS2_FS_FORMAT_MIN:
469: sb->s_xattr = gfs2_xattr_handlers_min;
470: break;
471:
472: default:
473: BUG();
474: }
475:
476: /* Set up the buffer cache and SB for real */
477: if (sdp->sd_sb.sb_bsize < bdev_logical_block_size(sb->s_bdev)) {
478: ret = -EINVAL;
479: fs_err(sdp, "FS block size (%u) is too small for device "
480: "block size (%u)\n",
481: sdp->sd_sb.sb_bsize, bdev_logical_block_size(sb->s_bdev));
482: goto out;
483: }
484: if (sdp->sd_sb.sb_bsize > PAGE_SIZE) {
485: ret = -EINVAL;
486: fs_err(sdp, "FS block size (%u) is too big for machine "
487: "page size (%u)\n",
488: sdp->sd_sb.sb_bsize, (unsigned int)PAGE_SIZE);
489: goto out;
490: }
491: ret = -EINVAL;
492: if (!sb_set_blocksize(sb, sdp->sd_sb.sb_bsize))
493: goto out;
494:
495: /* Get the root inode */
496: no_addr = sdp->sd_sb.sb_root_dir.no_addr;
497: ret = gfs2_lookup_root(sb, &sdp->sd_root_dir, no_addr, "root");
498: if (ret)
499: goto out;
500:
501: /* Get the master inode */
502: no_addr = sdp->sd_sb.sb_master_dir.no_addr;
503: ret = gfs2_lookup_root(sb, &sdp->sd_master_dir, no_addr, "master");
504: if (ret) {
505: dput(sdp->sd_root_dir);
506: goto out;
507: }
508: sb->s_root = dget(sdp->sd_args.ar_meta ? sdp->sd_master_dir : sdp->sd_root_dir);
509: out:
510: gfs2_glock_dq_uninit(&sb_gh);
511: return ret;
512: }
SourceFile:fs/gfs2/ops_fstype.c]
|
| 74/2 |
2026/09/07 00:28 |
llm |
expert |
0m
Model:
Tokens:
input: 58796
output: 43
thoughts: 143
Thoughts: **Root Inode Eviction Conundrum**
Okay, so I'm tracing this `gfs2_lookup_root` function, and something's bugging me. If it fails for the master inode, it calls `dput` on `sdp->sd_root_dir`. That much is straightforward. And the `dput` will evict the root inode. But then I'm thinking, if the root inode is evicted, it has to release its glock, right? That's standard inode lifecycle stuff.
But here's the kicker: how *did* the root inode get dirty buffers in the first place? I mean, `gfs2_lookup_root` might read some metadata during its execution. But reading doesn't make something dirty... I'm missing something. Okay, perhaps it *does* add it to the AIL, so technically its not "dirty" but it needs to be processed.
So, how *else* could it be dirty? Did something else make the root inode dirty? Was the filesystem maybe in the middle of journal recovery, where operations make the inode dirty? I need to check `gfs2_fill_super`. It must be setting up or altering the root inode. I need to refresh my memory on that, because this feels like a critical piece of the puzzle I'm overlooking. Gotta understand the root inode's initial state.
|
| 75/2 |
2026/09/07 00:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c Name:gfs2_fill_super]
Results: map[SourceCode:1107: /**
1108: * gfs2_fill_super - Read in superblock
1109: * @sb: The VFS superblock
1110: * @fc: Mount options and flags
1111: *
1112: * Returns: -errno
1113: */
1114: static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
1115: {
1116: struct gfs2_args *args = fc->fs_private;
1117: int silent = fc->sb_flags & SB_SILENT;
1118: struct gfs2_sbd *sdp;
1119: struct gfs2_holder mount_gh;
1120: struct address_space *mapping;
1121: int error;
1122:
1123: sdp = init_sbd(sb);
1124: if (!sdp) {
1125: pr_warn("can't alloc struct gfs2_sbd\n");
1126: return -ENOMEM;
1127: }
1128: sdp->sd_args = *args;
1129:
1130: if (sdp->sd_args.ar_spectator) {
1131: sb->s_flags |= SB_RDONLY;
1132: set_bit(SDF_RORECOVERY, &sdp->sd_flags);
1133: }
1134: if (sdp->sd_args.ar_posix_acl)
1135: sb->s_flags |= SB_POSIXACL;
1136: if (sdp->sd_args.ar_nobarrier)
1137: set_bit(SDF_NOBARRIERS, &sdp->sd_flags);
1138:
1139: sb->s_flags |= SB_NOSEC;
1140: sb->s_magic = GFS2_MAGIC;
1141: sb->s_op = &gfs2_super_ops;
1142:
1143: set_default_d_op(sb, &gfs2_dops);
1144: sb->s_export_op = &gfs2_export_ops;
1145: sb->s_qcop = &gfs2_quotactl_ops;
1146: sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
1147: sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
1148: sb->s_time_gran = 1;
1149: sb->s_maxbytes = MAX_LFS_FILESIZE;
1150:
1151: /* Set up the buffer cache and fill in some fake block size values
1152: to allow us to read-in the on-disk superblock. */
1153: sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, SECTOR_SIZE);
1154: error = -EINVAL;
1155: if (!sdp->sd_sb.sb_bsize)
1156: goto fail_free;
1157: sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
1158: sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - SECTOR_SHIFT;
1159: sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
1160:
1161: sdp->sd_tune.gt_logd_secs = sdp->sd_args.ar_commit;
1162: sdp->sd_tune.gt_quota_quantum = sdp->sd_args.ar_quota_quantum;
1163: if (sdp->sd_args.ar_statfs_quantum) {
1164: sdp->sd_tune.gt_statfs_slow = 0;
1165: sdp->sd_tune.gt_statfs_quantum = sdp->sd_args.ar_statfs_quantum;
1166: } else {
1167: sdp->sd_tune.gt_statfs_slow = 1;
1168: sdp->sd_tune.gt_statfs_quantum = 30;
1169: }
1170:
1171: /* Set up an address space for metadata writes */
1172: sdp->sd_inode = new_inode(sb);
1173: error = -ENOMEM;
1174: if (!sdp->sd_inode)
1175: goto fail_free;
1176: sdp->sd_inode->i_ino = GFS2_BAD_INO;
1177: sdp->sd_inode->i_size = OFFSET_MAX;
1178:
1179: mapping = gfs2_aspace(sdp);
1180: mapping->a_ops = &gfs2_rgrp_aops;
1181: gfs2_setup_inode(sdp->sd_inode);
1182:
1183: error = init_names(sdp, silent);
1184: if (error)
1185: goto fail_iput;
1186:
1187: snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s", sdp->sd_table_name);
1188:
1189: error = -ENOMEM;
1190: sdp->sd_glock_wq = alloc_workqueue("gfs2-glock/%s",
1191: WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_FREEZABLE | WQ_PERCPU,
1192: 0,
1193: sdp->sd_fsname);
1194: if (!sdp->sd_glock_wq)
1195: goto fail_iput;
1196:
1197: sdp->sd_delete_wq = alloc_workqueue("gfs2-delete/%s",
1198: WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_PERCPU, 0,
1199: sdp->sd_fsname);
1200: if (!sdp->sd_delete_wq)
1201: goto fail_glock_wq;
1202:
1203: error = gfs2_sys_fs_add(sdp);
1204: if (error)
1205: goto fail_delete_wq;
1206:
1207: gfs2_create_debugfs_file(sdp);
1208:
1209: error = gfs2_lm_mount(sdp, silent);
1210: if (error)
1211: goto fail_debug;
1212:
1213: INIT_WORK(&sdp->sd_withdraw_work, gfs2_withdraw_func);
1214:
1215: error = init_locking(sdp, &mount_gh, DO);
1216: if (error)
1217: goto fail_lm;
1218:
1219: error = init_sb(sdp, silent);
1220: if (error)
1221: goto fail_locking;
1222:
1223: /* Turn rgrplvb on by default if fs format is recent enough */
1224: if (!sdp->sd_args.ar_got_rgrplvb && sdp->sd_sb.sb_fs_format > 1801)
1225: sdp->sd_args.ar_rgrplvb = 1;
1226:
1227: error = wait_on_journal(sdp);
1228: if (error)
1229: goto fail_sb;
1230:
1231: /*
1232: * If user space has failed to join the cluster or some similar
1233: * failure has occurred, then the journal id will contain a
1234: * negative (error) number. This will then be returned to the
1235: * caller (of the mount syscall). We do this even for spectator
1236: * mounts (which just write a jid of 0 to indicate "ok" even though
1237: * the jid is unused in the spectator case)
1238: */
1239: if (sdp->sd_lockstruct.ls_jid < 0) {
1240: error = sdp->sd_lockstruct.ls_jid;
1241: sdp->sd_lockstruct.ls_jid = 0;
1242: goto fail_sb;
1243: }
1244:
1245: if (sdp->sd_args.ar_spectator)
1246: snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.s",
1247: sdp->sd_table_name);
1248: else
1249: snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.%u",
1250: sdp->sd_table_name, sdp->sd_lockstruct.ls_jid);
1251:
1252: error = init_inodes(sdp, DO);
1253: if (error)
1254: goto fail_sb;
1255:
1256: error = init_per_node(sdp, DO);
1257: if (error)
1258: goto fail_inodes;
1259:
1260: error = gfs2_statfs_init(sdp);
1261: if (error) {
1262: fs_err(sdp, "can't initialize statfs subsystem: %d\n", error);
1263: goto fail_per_node;
1264: }
1265:
1266: if (!sb_rdonly(sb)) {
1267: error = init_threads(sdp);
1268: if (error)
1269: goto fail_per_node;
1270: }
1271:
1272: error = gfs2_freeze_lock_shared(sdp);
1273: if (error)
1274: goto fail_per_node;
1275:
1276: if (!sb_rdonly(sb))
1277: error = gfs2_make_fs_rw(sdp);
1278:
1279: if (error) {
1280: gfs2_freeze_unlock(sdp);
1281: fs_err(sdp, "can't make FS RW: %d\n", error);
1282: goto fail_per_node;
1283: }
1284: gfs2_glock_dq_uninit(&mount_gh);
1285: gfs2_online_uevent(sdp);
1286: return 0;
1287:
1288: fail_per_node:
1289: init_per_node(sdp, UNDO);
1290: gfs2_destroy_threads(sdp);
1291: fail_inodes:
1292: init_inodes(sdp, UNDO);
1293: fail_sb:
1294: if (sdp->sd_root_dir)
1295: dput(sdp->sd_root_dir);
1296: if (sdp->sd_master_dir)
1297: dput(sdp->sd_master_dir);
1298: if (sb->s_root)
1299: dput(sb->s_root);
1300: sb->s_root = NULL;
1301: fail_locking:
1302: init_locking(sdp, &mount_gh, UNDO);
1303: fail_lm:
1304: complete_all(&sdp->sd_journal_ready);
1305: gfs2_lm_unmount(sdp);
1306: fail_debug:
1307: gfs2_delete_debugfs_file(sdp);
1308: gfs2_sys_fs_del(sdp);
1309: fail_delete_wq:
1310: destroy_workqueue(sdp->sd_delete_wq);
1311: fail_glock_wq:
1312: if (sdp->sd_glock_wq)
1313: destroy_workqueue(sdp->sd_glock_wq);
1314: fail_iput:
1315: iput(sdp->sd_inode);
1316: fail_free:
1317: free_sbd(sdp);
1318: return error;
1319: }
SourceFile:fs/gfs2/ops_fstype.c]
|
| 76/2 |
2026/09/07 00:28 |
llm |
expert |
0m
Model:
Tokens:
input: 62877
output: 33
thoughts: 1532
Thoughts: **Exploitation of a GFS2 Filesystem Bug During Mount**
Okay, so here's what I've figured out. We've got a use-after-free vulnerability in the GFS2 filesystem during mount. It hinges on the journal recovery process and filesystem withdrawal. Let's break it down:
The `gfs2_fill_super` function initiates the mount process. It calls `init_inodes` which, in turn, calls `init_journal` and then `gfs2_recover_journal`. Now, if `gfs2_recover_journal` hits an error, or detects something wrong with the image, it can trigger a filesystem withdrawal. This is key.
If the filesystem is withdrawn during the mount, `init_inodes` returns an error. This causes `gfs2_fill_super` to release the root directory inode with `dput`. The mount fails. During the mount failure, any dirty buffers written during journal recovery will be skipped during `gfs2_evict_inode` as the filesystem has been withdrawn. This frees glocks that were used during the recovery and then the mount attempt.
The withdrawal process involves a function `gfs2_withdraw_func` that is called via a kernel work queue. It’s important because it runs after the inodes have been evicted and the glocks freed. `gfs2_withdraw_func` eventually calls `gfs2_ail_drain`, and *that's* where the problem lies. `gfs2_ail_drain` accesses a freed glock via `bd->bd_ail_gl_list`. This is a classic use-after-free.
So the attack scenario is clear. It involves a malicious GFS2 image that, during mount, triggers a journal recovery process that fails. During the journal recovery the kernel dirties some buffers. The failure causes a withdrawal and cleanup process which puts and frees glocks. The `gfs2_withdraw_func` drains the AIL *after* the glock is freed and attempts to access it. The filesystem will be withdrawn by an invalid block number or some similar error.
Is this exploitable? Absolutely. This is a slab use-after-free. The attacker can carefully craft the filesystem image to cause a journal recovery error during the mount. Since this is a slab allocation, they can control the contents of a reallocated object, potentially through heap spraying from another thread or even another process.
The attacker might be able to corrupt the `list_head` pointers which might lead to arbitrary memory write. However, it looks like `bd` is still valid and on the AIL. This means the `list_del_init` only writes `&gl->gl_ail_list` into `gl->gl_ail_list`. This isn't as bad as arbitrary write, but it's still significant. If the glock is reallocated, a pointer to itself (offset by a certain amount) will be written into the reallocated object.
Now, if there are multiple `bd` objects on the list, the corruption is much more interesting. The bug could write the address of another `bd` into the attacker's controlled glock object. `bd` is a `gfs2_bufdata` object, which means the attacker can leak kernel addresses.
This is all made worse because GFS2 likely doesn't have `FS_USERNS_MOUNT`, so we require root privs to trigger. However, assuming we have root in the initial namespace, we can create the exploit: craft a malicious GFS2 image, trigger journal recovery failure, and trigger the use-after-free to leak kernel addresses. It's a solid kernel information leak and potentially a full kernel exploit if other vulnerabilities are found to chain.
|
| 77/2 |
2026/09/07 00:28 |
tool |
grepper |
0m
Error:
Args: map[Expression:FS_USERNS_MOUNT PathPrefix:fs/gfs2/]
Results:
|
| 78/2 |
2026/09/07 00:28 |
llm |
expert |
0m
Model:
Tokens:
input: 65261
output: 44
thoughts: 1884
Thoughts: **Vulnerability Analysis: GFS2 Filesystem Error Handling**
Okay, let's break this down. My initial assessment is that this GFS2 vulnerability isn't trivial. I can't just casually exploit this with a standard user account. It's a use-after-free issue, a critical problem, and it'll lead to a system crash—a classic denial of service. The core lies in `gfs2_remove_from_ail` accessing a freed glock. The root cause is a race condition when a filesystem withdraws. Specifically, the glock for an inode is freed prematurely due to a combination of `gfs2_evict_inode` putting the glock *before* the AIL is fully drained during a filesystem withdraw.
First, I realize this can't be triggered directly in a user namespace. The filesystem lacks the `FS_USERNS_MOUNT` flag and requires `CAP_SYS_ADMIN`, effectively blocking unprivileged processes from directly mounting it. So, a direct mounting attack is out.
However, a "malicious filesystem trigger" is possible. *If* I can get a malicious GFS2 filesystem image somehow mounted, *that's* where the unprivileged user can gain access, because a malicious file can trigger metadata inconsistencies, thus a withdraw. The crash is triggered by subsequent inode eviction, because dirty buffers are still on the AIL but the glock is freed prematurely. Desktop environments, via udisks2 or similar, *might* auto-mount a malicious USB drive containing such a filesystem. That's a huge vector. This also means this could be triggered with a peripheral, which includes a malicious USB drive, a clear attack vector.
Digging deeper, it's not *just* a malicious filesystem. Even a normal GFS2 filesystem with an I/O error (e.g., a disk failing) can trigger the same problem: it withdraws, and then an unprivileged user can trigger this. The problem isn't just malicious data; it's a fundamental error handling flaw. The unprivileged user might not be able to *cause* an I/O error, but, if it happens, the race is still present.
So, let's review:
* Exploitable: Yes, definite use-after-free.
* DoS: Absolutely, system crash.
* Unprivileged access: Indirect. Requires a pre-existing mounted malicious filesystem or I/O error to trigger.
* User Namespace: No.
* Peripheral Trigger: Yes (malicious USB).
* Malicious Filesystem Trigger: Yes.
Now I really need to confirm that `gfs2_glock_put` *actually* frees the glock. Yes, it does via `__gfs2_glock_free` with a call to `kmem_cache_free`. Okay, the glock *is* freed, as expected.
But what about the AIL count? The critical part of this is that the glock is freed while the AIL isn't empty! Normally, `gfs2_ail_flush` handles the write-out and drain before the glock is released. But *if* the filesystem is withdrawn (due to an I/O error or whatever), then `gfs2_ail_flush` *isn't* called! `gfs2_evict_inode` bypasses `gfs2_ail_flush` and puts the glock, leaving `gl_ail_count` > 0. This bypass in `gfs2_evict_inode` is because a glock cannot be initialized if the filesystem is withdrawing.
**That's it! That's the core of the problem: a withdrawn filesystem skips the necessary AIL flush, and an unprivileged user, by triggering the evict of a dirty inode, can trigger the use-after-free.**
|
| 79/2 |
2026/09/07 00:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:gfs2_glock_nq_init]
Results: map[SourceCode: 245: static inline int gfs2_glock_nq_init(struct gfs2_glock *gl,
246: unsigned int state, u16 flags,
247: struct gfs2_holder *gh)
248: {
249: int error;
250:
251: __gfs2_holder_init(gl, state, flags, gh, _RET_IP_);
252:
253: error = gfs2_glock_nq(gh);
254: if (error)
255: gfs2_holder_uninit(gh);
256:
257: return error;
258: }
SourceFile:fs/gfs2/glock.h]
|
| 80/2 |
2026/09/07 00:28 |
llm |
expert |
0m
Model:
Tokens:
input: 68252
output: 42
thoughts: 11
Thoughts: Okay, here's my summary, taking on the persona you've described:
**Understanding the `gfs2_glock_nq` Function Call**
Alright, let's break this down. `gfs2_glock_nq`… immediately, I'm thinking, "Global Lock, No-Wait." It's a fundamental operation in GFS2, a distributed filesystem. My brain immediately jumps to the locking hierarchy and the implications for concurrency control. This isn't just about grabbing a lock; it's about *trying* to grab it, and crucially, doing so *non-blockingly*.
The 'NQ' suffix is key. That means if the lock is immediately available, fantastic, we proceed. But if another process holds it, we *don't* wait. We'll be notified of this by an immediate return. It's about ensuring minimal contention impact, which is especially critical in distributed, high-performance environments. It implies a design that needs to be incredibly sensitive to potential lock acquisition failures. The code using this function *must* be prepared to handle these failures gracefully. I need to understand the scenarios and the logic in place to handle a denied lock request. This is critical for data integrity and performance.
I'm instantly visualizing the state transitions. The various lock states, the queue management, the potential for deadlocks (even though it's no-wait, timing is key). I'm also considering the implications on other glock operations like `gfs2_glock_put` and how they're connected to this `nq` call. This call is a core primitive, so I need to go through it carefully. I'm wondering how it is being used in specific situations, what is the exact usage context of this `nq` in the implementation. This operation would be critical for things like metadata updates, data blocks, file creation and removal – all of those could be impacted by an incomplete lock acquisition due to the `nq` feature.
My thoughts are automatically going toward potential problems:
* **Lock starvation:** is there any logic that needs to be revisited to prevent starvation?
* **Race conditions:** How well is the non-blocking nature handled? Are there potential races where we get the lock status but then another thread changes it?
* **Error Handling:** What's the error handling like when `gfs2_glock_nq` fails? Does the system retry? How does that impact the overall filesystem performance and responsiveness? What are the implications of the error code that it returns?
Ultimately, with this function, understanding the *why* is just as important as the *how*. I need to drill down into the context, examine the surrounding code, and see how this non-blocking approach contributes to GFS2's overall design and performance goals.
|
| 81/2 |
2026/09/07 00:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:gfs2_glock_nq]
Results: map[SourceCode:1466: int gfs2_glock_nq(struct gfs2_holder *gh)
1467: {
1468: struct gfs2_glock *gl = gh->gh_gl;
1469: struct gfs2_sbd *sdp = glock_sbd(gl);
1470: int error;
1471:
1472: if (gfs2_withdrawn(sdp))
1473: return -EIO;
1474:
1475: if (gh->gh_flags & GL_NOBLOCK) {
1476: struct gfs2_holder *current_gh;
1477:
1478: error = -ECHILD;
1479: spin_lock(&gl->gl_lockref.lock);
1480: if (find_last_waiter(gl))
1481: goto unlock;
1482: current_gh = find_first_holder(gl);
1483: if (!may_grant(gl, current_gh, gh))
1484: goto unlock;
1485: set_bit(HIF_HOLDER, &gh->gh_iflags);
1486: list_add_tail(&gh->gh_list, &gl->gl_holders);
1487: trace_gfs2_promote(gh);
1488: error = 0;
1489: unlock:
1490: spin_unlock(&gl->gl_lockref.lock);
1491: return error;
1492: }
1493:
1494: gh->gh_error = 0;
1495: spin_lock(&gl->gl_lockref.lock);
1496: add_to_queue(gh);
1497: if (unlikely((LM_FLAG_RECOVER & gh->gh_flags) &&
1498: test_and_clear_bit(GLF_HAVE_FROZEN_REPLY, &gl->gl_flags))) {
1499: set_bit(GLF_HAVE_REPLY, &gl->gl_flags);
1500: gl->gl_lockref.count++;
1501: gfs2_glock_queue_work(gl, 0);
1502: }
1503: run_queue(gl, 1);
1504: spin_unlock(&gl->gl_lockref.lock);
1505:
1506: error = 0;
1507: if (!(gh->gh_flags & GL_ASYNC))
1508: error = gfs2_glock_wait(gh);
1509:
1510: return error;
1511: }
SourceFile:fs/gfs2/glock.c]
|
| 82/2 |
2026/09/07 00:28 |
llm |
expert |
0m
Model:
Tokens:
input: 69669
output: 42
thoughts: 227
Thoughts: **Analyzing the Error Flow in GFS2 Inode Eviction**
Okay, so I've pinned down the core of this bug. It seems that if `gfs2_glock_nq` returns `-EIO` because `gfs2_withdrawn(sdp)` is true, that's what propagates up through `evict_linked_inode` and ultimately ends up with `gfs2_evict_inode` skipping the AIL flush and just putting the glock. That confirms the primary pathway for the issue, I can reproduce that easily enough.
Now, I'm thinking about other possible triggers. What other circumstances could cause `gfs2_glock_nq` to fail? Could it be something besides the withdrawn state? My immediate thought is `gh->gh_flags & GL_NOBLOCK`, that would return `-ECHILD`. However, `evict_linked_inode` doesn't even use `GL_NOBLOCK`, so that's a dead end.
What about `gfs2_glock_wait`? Could it be that that's failing and returning an error that's somehow propagating back? `gfs2_glock_wait` *can* return an error if it's interrupted, but it's usually using `TASK_UNINTERRUPTIBLE`, so that should be rare. I'll need to go and really dig in to the code for `gfs2_glock_wait` to be sure. Time to go looking at that code...
|
| 83/2 |
2026/09/07 00:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:gfs2_glock_wait]
Results: map[SourceCode:1239: int gfs2_glock_wait(struct gfs2_holder *gh)
1240: {
1241: unsigned long start_time = jiffies;
1242:
1243: might_sleep();
1244: wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE);
1245: gfs2_glock_update_hold_time(gh->gh_gl, start_time);
1246: return gfs2_glock_holder_ready(gh);
1247: }
SourceFile:fs/gfs2/glock.c]
|
| 84/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 70456
output: 37
thoughts: 346
Thoughts: **My Analysis of this Potential Vulnerability**
Okay, so I've been digging into this and it looks like `TASK_UNINTERRUPTIBLE` is the state we're dealing with here. The critical path for `gfs2_glock_nq` returning an error hinges on either `gfs2_withdrawn(sdp)` being true, or `gfs2_glock_holder_ready` returning an error. `gfs2_glock_holder_ready`'s return value is ultimately determined by `gh->gh_error`. And, crucially, `gh->gh_error` can be set to `-EIO` by `do_error` when the filesystem is withdrawn.
So, it all circles back to the filesystem being withdrawn, which can happen due to I/O errors or a malicious filesystem image. This is a classic "Malicious Filesystem Trigger" scenario and also a "Peripheral Trigger," in the sense that a bad filesystem image is an external thing.
This vulnerability is *definitely* exploitable, and it results in a Denial of Service, which is a significant problem. The good news is that it's not directly accessible from unprivileged processes. Mounting a filesystem requires root, and the typical way to trigger withdraw requires I/O errors, which unprivileged users can't cause. Also, GFS2 doesn't work in user namespaces, so we're safe there. It's also not a VM guest, VM host, Ethernet network, or any other remote trigger – at least, not at first glance.
But wait a minute… GFS2 *is* a cluster filesystem, right? It uses DLM, which *does* work over the network. If a remote node sends a malicious DLM message, could that cause a withdraw? Yes, it’s entirely possible. An invalid DLM message could potentially force a local node to withdraw the filesystem to protect data integrity. We need to double-check if DLM errors can trigger this GFS2 withdraw condition. This is something I'm going to follow up on. I’ll need to understand if DLM messages can set the stage for this vulnerability.
|
| 85/2 |
2026/09/07 00:29 |
tool |
grepper |
0m
Args: map[Expression:gfs2_withdraw PathPrefix:fs/gfs2/lock_dlm.c]
Results: map[Output:fs/gfs2/lock_dlm.c=1156=static void gdlm_recover_prep(void *arg)
--
fs/gfs2/lock_dlm.c-1160-
fs/gfs2/lock_dlm.c:1161: if (gfs2_withdrawn(sdp)) {
fs/gfs2/lock_dlm.c-1162- fs_err(sdp, "recover_prep ignored due to withdraw.\n");
--
fs/gfs2/lock_dlm.c=1181=static void gdlm_recover_slot(void *arg, struct dlm_slot *slot)
--
fs/gfs2/lock_dlm.c-1186-
fs/gfs2/lock_dlm.c:1187: if (gfs2_withdrawn(sdp)) {
fs/gfs2/lock_dlm.c-1188- fs_err(sdp, "recover_slot jid %d ignored due to withdraw.\n",
--
fs/gfs2/lock_dlm.c=1210=static void gdlm_recover_done(void *arg, struct dlm_slot *slots, int num_slots,
--
fs/gfs2/lock_dlm.c-1215-
fs/gfs2/lock_dlm.c:1216: if (gfs2_withdrawn(sdp)) {
fs/gfs2/lock_dlm.c-1217- fs_err(sdp, "recover_done ignored due to withdraw.\n");
--
fs/gfs2/lock_dlm.c=1242=static void gdlm_recovery_result(struct gfs2_sbd *sdp, unsigned int jid,
--
fs/gfs2/lock_dlm.c-1246-
fs/gfs2/lock_dlm.c:1247: if (gfs2_withdrawn(sdp)) {
fs/gfs2/lock_dlm.c-1248- fs_err(sdp, "recovery_result jid %d ignored due to withdraw.\n",
]
|
| 86/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 71856
output: 32
thoughts: 26
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Investigating Potential Withdraw Logic in `lock_dlm.c`**
Okay, so I'm looking at `lock_dlm.c`, specifically around the withdraw handling. The code seems to be explicitly checking for withdraw events, which is good. But the real question is, does the module actually *call* `gfs2_withdraw` within this context? That's what I need to confirm. I know how critical withdraw logic is in GFS2, especially during a cluster event or node failure. I need to trace this call chain to make sure it's wired up correctly and that we're properly initiating the necessary recovery mechanisms when we detect a withdraw condition within the distributed lock manager. The presence of the check is a starting point, but without a clear path to `gfs2_withdraw`, it's just a diagnostic marker, not a functional component. I need to verify the implementation path here.
|
| 87/2 |
2026/09/07 00:29 |
tool |
grepper |
0m
Args: map[Expression:gfs2_withdraw\( PathPrefix:fs/gfs2/]
Results: map[Output:fs/gfs2/glock.c=632=__acquires(&gl->gl_lockref.lock)
--
fs/gfs2/glock.c-665- gfs2_dump_glock(NULL, gl, true);
fs/gfs2/glock.c:666: gfs2_withdraw(sdp);
fs/gfs2/glock.c-667- }
--
fs/gfs2/glops.c=33=static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh)
--
fs/gfs2/glops.c-45- gfs2_lm(sdp, "AIL error\n");
fs/gfs2/glops.c:46: gfs2_withdraw(sdp);
fs/gfs2/glops.c-47-}
--
fs/gfs2/log.c=196=void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
--
fs/gfs2/log.c-229- gfs2_lm(sdp, "gfs2_ail1_start_one returned: %d\n", ret);
fs/gfs2/log.c:230: gfs2_withdraw(sdp);
fs/gfs2/log.c-231- }
--
fs/gfs2/lops.c=200=static void gfs2_end_log_write(struct bio *bio)
--
fs/gfs2/lops.c-211- err, sdp->sd_jdesc->jd_jid);
fs/gfs2/lops.c:212: gfs2_withdraw(sdp);
fs/gfs2/lops.c-213- }
--
fs/gfs2/sys.c=190=static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
--
fs/gfs2/sys.c-204- gfs2_lm(sdp, "withdrawing from cluster at user's request\n");
fs/gfs2/sys.c:205: gfs2_withdraw(sdp);
fs/gfs2/sys.c-206-
--
fs/gfs2/trans.c=257=void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
--
fs/gfs2/trans.c-305- fs_info(sdp, "GFS2:adding buf while frozen\n");
fs/gfs2/trans.c:306: gfs2_withdraw(sdp);
fs/gfs2/trans.c-307- goto out_unlock;
--
fs/gfs2/util.c=204=void gfs2_withdraw_func(struct work_struct *work)
--
fs/gfs2/util.c-241-
fs/gfs2/util.c:242:void gfs2_withdraw(struct gfs2_sbd *sdp)
fs/gfs2/util.c-243-{
--
fs/gfs2/util.c=269=void gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
--
fs/gfs2/util.c-279-
fs/gfs2/util.c:280: gfs2_withdraw(sdp);
fs/gfs2/util.c-281- dump_stack();
--
fs/gfs2/util.c=319=void gfs2_consist_i(struct gfs2_sbd *sdp, const char *function,
--
fs/gfs2/util.c-325- function, file, line);
fs/gfs2/util.c:326: gfs2_withdraw(sdp);
fs/gfs2/util.c-327-}
--
fs/gfs2/util.c=333=void gfs2_consist_inode_i(struct gfs2_inode *ip,
--
fs/gfs2/util.c-345- gfs2_dump_glock(NULL, ip->i_gl, 1);
fs/gfs2/util.c:346: gfs2_withdraw(sdp);
fs/gfs2/util.c-347-}
--
fs/gfs2/util.c=353=void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd,
--
fs/gfs2/util.c-367- gfs2_dump_glock(NULL, rgd->rd_gl, 1);
fs/gfs2/util.c:368: gfs2_withdraw(sdp);
fs/gfs2/util.c-369-}
--
fs/gfs2/util.c=375=void gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
--
fs/gfs2/util.c-384- function, file, line);
fs/gfs2/util.c:385: gfs2_withdraw(sdp);
fs/gfs2/util.c-386-}
--
fs/gfs2/util.c=392=void gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
--
fs/gfs2/util.c-401- function, file, line);
fs/gfs2/util.c:402: gfs2_withdraw(sdp);
fs/gfs2/util.c-403-}
--
fs/gfs2/util.c=411=void gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
--
fs/gfs2/util.c-417- function, file, line);
fs/gfs2/util.c:418: gfs2_withdraw(sdp);
fs/gfs2/util.c-419-}
--
fs/gfs2/util.c=425=void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
--
fs/gfs2/util.c-434- (unsigned long long)bh->b_blocknr, function, file, line);
fs/gfs2/util.c:435: gfs2_withdraw(sdp);
fs/gfs2/util.c-436-}
--
fs/gfs2/util.h=196=void gfs2_withdraw_func(struct work_struct *work);
fs/gfs2/util.h:197:void gfs2_withdraw(struct gfs2_sbd *sdp);
fs/gfs2/util.h-198-
]
|
| 88/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 73952
output: 46
thoughts: 1647
Thoughts: **Exploiting the GFS2 Withdraw Vulnerability**
Okay, so `withdraw_store` in `fs/gfs2/sys.c` lets root trigger a cluster withdraw, but it requires `CAP_SYS_ADMIN`, so an unprivileged user's out. They're stuck with triggering it through malicious filesystem images via `gfs2_consist_i`, `gfs2_meta_check_ii`, etc. This means it's a Malicious Filesystem Trigger vulnerability.
No luck with VM guests or hosts in confidential computing, since GFS2 isn't a paravirtualized device.
So far, it looks like it's exploitable, a Denial of Service, *not* accessible to unprivileged processes or user namespaces, and no VM or network triggers. The two remaining are the Peripheral Trigger and the Malicious Filesystem Trigger.
Can I cause an I/O error by filling the disk? No, `-ENOSPC` doesn't trigger the withdraw, neither do quota errors (`-EDQUOT`). And mounting a malicious image using a loop device requires root too. However, a USB drive might get auto-mounted by the desktop environment, and that covers the Malicious Filesystem Trigger and the Peripheral Trigger.
Let's review the exploitability. It's a slab-use-after-free on `gfs2_glock(aspace)` cache with an object size of 1176 and the bug at offset 280 (for `gl_ail_list`). The UAF read/write is in `list_del_init(&bd->bd_ail_gl_list)`. `bd` is a `gfs2_bufdata` object, and `bd->bd_ail_gl_list` is a `list_head`.
The critical part: when the list is of a single `bd`, `list_del_init` ends up writing the address of the reallocated object itself + 280 to offsets 280 and 288 of that reallocated object. Essentially, the attacker can overwrite 16 bytes at offset 280 of the reallocated object with its own address + 280. If the reallocated object has a pointer at those offsets, it gets overwritten with its own address!
If I can control the allocation, I can choose an object with interesting fields at offset 280, e.g., a function pointer. I could then put a fake function pointer there if I can also control the contents of the object. No, the shellcode would not work since it is in the heap and is NX.
However, if it has a data pointer at offset 280, it will point to `gl + 280`. Since I control the contents, I control the data read, which is a very powerful primitive! Furthermore, if there are multiple `bd`s on the list, a heap pointer to `gfs2_bufdata` might get written to the reallocated object. If I can leak this, it defeats KASLR and leaks heap addresses. Definitely exploitable.
Now, is `gfs2_glock(aspace)` a dedicated cache or a merged one? It's a dedicated cache, but are caches merged? With `SLAB_MERGE_DEFAULT` enabled, similar caches get merged. I need to check how `gfs2_glock_aspace_cachep` is created to know for sure.
|
| 89/2 |
2026/09/07 00:29 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:fs/gfs2/main.c Name:gfs2_init_glock_aspace_cache]
Results: map[SourceCode: SourceFile:]
|
| 90/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 76408
output: 39
thoughts: 19
Thoughts: Here's my thought process, as if I were analyzing that:
**Investigating GFS2's Glock Aspace Cache**
Okay, so I'm diving into the GFS2 code today, and my first instinct is to zero in on the `gfs2_glock_aspace_cachep` variable. That name immediately screams "cache" and "address space," which tells me it's likely a critical piece of the GFS2 locking mechanism, probably related to caching file data that the locking system protects. I need to understand how this cache works, how it's used, and what its performance characteristics are. Grepping for that variable is a good starting point. That search will point me to the places in the code where this specific structure or function is referenced. That initial grep will hopefully reveal the definition of the structure, or the function that utilizes that data structure, which would give me a starting point to continue my analysis. After I find the definition, I'll use that information to find where that variable is used, and build my understanding of the system, piece by piece.
|
| 91/2 |
2026/09/07 00:29 |
tool |
grepper |
0m
Args: map[Expression:gfs2_glock_aspace_cachep = PathPrefix:fs/gfs2/]
Results: map[Output:fs/gfs2/main.c=74=static int __init init_gfs2_fs(void)
--
fs/gfs2/main.c-101-
fs/gfs2/main.c:102: gfs2_glock_aspace_cachep = kmem_cache_create("gfs2_glock(aspace)",
fs/gfs2/main.c-103- sizeof(struct gfs2_glock_aspace),
]
|
| 92/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 76829
output: 40
thoughts: 16
Thoughts: Okay, let's dive into this. I need to get a clear picture of how `kmem_cache_create` is being used. I need the *complete* call. I need to see all the arguments, their types, and their values. That's the only way I can properly understand the intent of the cache creation, potential performance implications, and if there are any obvious red flags in the setup. I'm going to extract the full `kmem_cache_create` call and meticulously dissect it. It all hinges on seeing the full context.
|
| 93/2 |
2026/09/07 00:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/main.c Name:init_gfs2_fs]
Results: map[SourceCode: 74: static int __init init_gfs2_fs(void)
75: {
76: int error;
77:
78: gfs2_str2qstr(&gfs2_qdot, ".");
79: gfs2_str2qstr(&gfs2_qdotdot, "..");
80: gfs2_quota_hash_init();
81:
82: error = gfs2_sys_init();
83: if (error)
84: return error;
85:
86: error = list_lru_init(&gfs2_qd_lru);
87: if (error)
88: goto fail_lru;
89:
90: error = gfs2_glock_init();
91: if (error)
92: goto fail_glock;
93:
94: error = -ENOMEM;
95: gfs2_glock_cachep = kmem_cache_create("gfs2_glock",
96: sizeof(struct gfs2_glock),
97: 0, SLAB_RECLAIM_ACCOUNT,
98: gfs2_init_glock_once);
99: if (!gfs2_glock_cachep)
100: goto fail_cachep1;
101:
102: gfs2_glock_aspace_cachep = kmem_cache_create("gfs2_glock(aspace)",
103: sizeof(struct gfs2_glock_aspace),
104: 0, 0, gfs2_init_gl_aspace_once);
105:
106: if (!gfs2_glock_aspace_cachep)
107: goto fail_cachep2;
108:
109: gfs2_inode_cachep = kmem_cache_create("gfs2_inode",
110: sizeof(struct gfs2_inode),
111: 0, SLAB_RECLAIM_ACCOUNT|
112: SLAB_ACCOUNT,
113: gfs2_init_inode_once);
114: if (!gfs2_inode_cachep)
115: goto fail_cachep3;
116:
117: gfs2_bufdata_cachep = kmem_cache_create("gfs2_bufdata",
118: sizeof(struct gfs2_bufdata),
119: 0, 0, NULL);
120: if (!gfs2_bufdata_cachep)
121: goto fail_cachep4;
122:
123: gfs2_rgrpd_cachep = kmem_cache_create("gfs2_rgrpd",
124: sizeof(struct gfs2_rgrpd),
125: 0, 0, NULL);
126: if (!gfs2_rgrpd_cachep)
127: goto fail_cachep5;
128:
129: gfs2_quotad_cachep = kmem_cache_create("gfs2_quotad",
130: sizeof(struct gfs2_quota_data),
131: 0, SLAB_RECLAIM_ACCOUNT, NULL);
132: if (!gfs2_quotad_cachep)
133: goto fail_cachep6;
134:
135: gfs2_qadata_cachep = kmem_cache_create("gfs2_qadata",
136: sizeof(struct gfs2_qadata),
137: 0, 0, NULL);
138: if (!gfs2_qadata_cachep)
139: goto fail_cachep7;
140:
141: gfs2_trans_cachep = kmem_cache_create("gfs2_trans",
142: sizeof(struct gfs2_trans),
143: 0, 0, NULL);
144: if (!gfs2_trans_cachep)
145: goto fail_cachep8;
146:
147: error = gfs2_qd_shrinker_init();
148: if (error)
149: goto fail_shrinker;
150:
151: error = -ENOMEM;
152: gfs2_recovery_wq = alloc_workqueue("gfs2_recovery",
153: WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_PERCPU,
154: 0);
155: if (!gfs2_recovery_wq)
156: goto fail_wq1;
157:
158: gfs2_control_wq = alloc_workqueue("gfs2_control",
159: WQ_UNBOUND | WQ_FREEZABLE, 0);
160: if (!gfs2_control_wq)
161: goto fail_wq2;
162:
163: gfs2_freeze_wq = alloc_workqueue("gfs2_freeze", WQ_PERCPU, 0);
164:
165: if (!gfs2_freeze_wq)
166: goto fail_wq3;
167:
168: gfs2_page_pool = mempool_create_page_pool(64, 0);
169: if (!gfs2_page_pool)
170: goto fail_mempool;
171:
172: gfs2_register_debugfs();
173: error = register_filesystem(&gfs2_fs_type);
174: if (error)
175: goto fail_fs1;
176:
177: error = register_filesystem(&gfs2meta_fs_type);
178: if (error)
179: goto fail_fs2;
180:
181:
182: pr_info("GFS2 installed\n");
183:
184: return 0;
185:
186: fail_fs2:
187: unregister_filesystem(&gfs2_fs_type);
188: fail_fs1:
189: mempool_destroy(gfs2_page_pool);
190: fail_mempool:
191: destroy_workqueue(gfs2_freeze_wq);
192: fail_wq3:
193: destroy_workqueue(gfs2_control_wq);
194: fail_wq2:
195: destroy_workqueue(gfs2_recovery_wq);
196: fail_wq1:
197: gfs2_qd_shrinker_exit();
198: fail_shrinker:
199: kmem_cache_destroy(gfs2_trans_cachep);
200: fail_cachep8:
201: kmem_cache_destroy(gfs2_qadata_cachep);
202: fail_cachep7:
203: kmem_cache_destroy(gfs2_quotad_cachep);
204: fail_cachep6:
205: kmem_cache_destroy(gfs2_rgrpd_cachep);
206: fail_cachep5:
207: kmem_cache_destroy(gfs2_bufdata_cachep);
208: fail_cachep4:
209: kmem_cache_destroy(gfs2_inode_cachep);
210: fail_cachep3:
211: kmem_cache_destroy(gfs2_glock_aspace_cachep);
212: fail_cachep2:
213: kmem_cache_destroy(gfs2_glock_cachep);
214: fail_cachep1:
215: gfs2_glock_exit();
216: fail_glock:
217: list_lru_destroy(&gfs2_qd_lru);
218: fail_lru:
219: gfs2_sys_uninit();
220: return error;
221: }
SourceFile:fs/gfs2/main.c]
|
| 94/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 79379
output: 43
thoughts: 289
Thoughts: **Analyzing the gfs2_glock_aspace Cache**
Okay, so I see that `gfs2_glock_aspace_cachep` is created using `kmem_cache_create` with the constructor `gfs2_init_gl_aspace_once`. That's important. I know from experience that caches created with constructors like this are *not* merged with other caches. The slab allocator ensures that the objects returned from this cache have been initialized correctly by that constructor. So, this `gfs2_glock(aspace)` is a dedicated cache, definitely *not* getting mixed up with something generic like `kmalloc-1024` or `kmalloc-2048`.
This has immediate security implications. If there's a vulnerability that allows for object reuse, an attacker can *only* reallocate a freed object with another `gfs2_glock_aspace` object. That's actually a significant restriction! This means they don't have completely arbitrary control over the reallocated memory. They can't just inject any data they want.
Wait a second, that's a key observation. If they're limited to reallocating with *another* `gfs2_glock_aspace` object, they're constrained by the structure of that object. Their "control" would be limited to manipulating the fields within that new `gfs2_glock_aspace` instance. Okay, that changes the threat model somewhat. I need to understand the layout of the `gfs2_glock_aspace` structure. I need to look at its fields to understand what kind of data they *could* influence during a re-allocation attack. Time to check the layout.
|
| 95/2 |
2026/09/07 00:29 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:fs/gfs2/incore.h Name:gfs2_glock_aspace]
Results: map[Fields:[map[Name:glock OffsetBits:0 SizeBits:5376] map[Name:mapping OffsetBits:5376 SizeBits:4032]]]
|
| 96/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 80141
output: 45
thoughts: 114
Thoughts: **My Analysis of gfs2_glock_aspace**
Okay, so I'm looking at `gfs2_glock_aspace` and immediately see it's a composite structure. It houses a `gfs2_glock` and an `address_space`. That's standard practice, efficient. Now, the key here is the offset of `gl_ail_list`. It's 280 bytes into the `gfs2_glock` struct, which puts it at bit 2240, well within the `gfs2_glock` structure. That’s where things get interesting. The core concept here is that if a reallocation happens, this object gets recreated as a `gfs2_glock_aspace`. The constructor, `gfs2_init_gl_aspace_once`, takes care of the initialization. The implications of this are the key to understanding the potential vulnerabilities here. I need to dig deeper into how these reallocations are triggered and what the initial state of the memory is when the `gfs2_glock_aspace` is first created. This has the potential to lead to interesting use-after-free and/or memory corruption scenarios.
|
| 97/2 |
2026/09/07 00:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/main.c Name:gfs2_init_gl_aspace_once]
Results: map[SourceCode: 60: static void gfs2_init_gl_aspace_once(void *foo)
61: {
62: struct gfs2_glock_aspace *gla = foo;
63:
64: gfs2_init_glock_once(&gla->glock);
65: address_space_init_once(&gla->mapping);
66: }
SourceFile:fs/gfs2/main.c]
|
| 98/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 80704
output: 42
thoughts: 37
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm already deep in the weeds with GFS2 locking:
**Understanding the Allocation and Initialization of GFS2 Glocks**
Alright, so the object is being reallocated. That tells me the core issue is the new allocation; *when* that happens, `gfs2_glock_get` is going to be the one responsible for the initialization of all the fields associated with that glock. I need to refresh my memory on what that initialization entails and what impact that has on glock's initial state. Time to dive into the code for `gfs2_glock_get` and see exactly what's happening.
|
| 99/2 |
2026/09/07 00:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/glock.c Name:gfs2_glock_get]
Results: map[SourceCode:1056: int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
1057: const struct gfs2_glock_operations *glops, int create,
1058: struct gfs2_glock **glp)
1059: {
1060: struct lm_lockname name = { .ln_number = number,
1061: .ln_type = glops->go_type,
1062: .ln_sbd = sdp };
1063: struct gfs2_glock *gl, *tmp;
1064: struct address_space *mapping;
1065:
1066: gl = find_insert_glock(&name, NULL);
1067: if (gl)
1068: goto found;
1069: if (!create)
1070: return -ENOENT;
1071:
1072: if (glops->go_flags & GLOF_ASPACE) {
1073: struct gfs2_glock_aspace *gla =
1074: kmem_cache_alloc(gfs2_glock_aspace_cachep, GFP_NOFS);
1075: if (!gla)
1076: return -ENOMEM;
1077: gl = &gla->glock;
1078: } else {
1079: gl = kmem_cache_alloc(gfs2_glock_cachep, GFP_NOFS);
1080: if (!gl)
1081: return -ENOMEM;
1082: }
1083: memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
1084: gl->gl_ops = glops;
1085:
1086: if (glops->go_flags & GLOF_LVB) {
1087: gl->gl_lksb.sb_lvbptr = kzalloc(GDLM_LVB_SIZE, GFP_NOFS);
1088: if (!gl->gl_lksb.sb_lvbptr) {
1089: gfs2_glock_dealloc(&gl->gl_rcu);
1090: return -ENOMEM;
1091: }
1092: }
1093:
1094: atomic_inc(&sdp->sd_glock_disposal);
1095: gl->gl_node.next = NULL;
1096: gl->gl_flags = BIT(GLF_INITIAL);
1097: if (glops->go_instantiate)
1098: gl->gl_flags |= BIT(GLF_INSTANTIATE_NEEDED);
1099: gl->gl_name = name;
1100: lockref_init(&gl->gl_lockref);
1101: lockdep_set_subclass(&gl->gl_lockref.lock, glops->go_subclass);
1102: gl->gl_state = LM_ST_UNLOCKED;
1103: gl->gl_target = LM_ST_UNLOCKED;
1104: gl->gl_demote_state = LM_ST_EXCLUSIVE;
1105: gl->gl_dstamp = 0;
1106: preempt_disable();
1107: /* We use the global stats to estimate the initial per-glock stats */
1108: gl->gl_stats = this_cpu_ptr(sdp->sd_lkstats)->lkstats[glops->go_type];
1109: preempt_enable();
1110: gl->gl_stats.stats[GFS2_LKS_DCOUNT] = 0;
1111: gl->gl_stats.stats[GFS2_LKS_QCOUNT] = 0;
1112: gl->gl_tchange = jiffies;
1113: gl->gl_object = NULL;
1114: gl->gl_hold_time = GL_GLOCK_DFT_HOLD;
1115: INIT_DELAYED_WORK(&gl->gl_work, glock_work_func);
1116: if (glock_type(gl) == LM_TYPE_IOPEN)
1117: INIT_DELAYED_WORK(&gl->gl_delete, delete_work_func);
1118:
1119: mapping = gfs2_glock2aspace(gl);
1120: if (mapping) {
1121: gfp_t gfp_mask;
1122:
1123: mapping->a_ops = &gfs2_meta_aops;
1124: mapping->host = sdp->sd_inode;
1125: mapping->flags = 0;
1126: gfp_mask = mapping_gfp_mask(sdp->sd_inode->i_mapping);
1127: mapping_set_gfp_mask(mapping, gfp_mask);
1128: mapping->writeback_index = 0;
1129: }
1130:
1131: tmp = find_insert_glock(&name, gl);
1132: if (tmp) {
1133: gfs2_glock_dealloc(&gl->gl_rcu);
1134: if (atomic_dec_and_test(&sdp->sd_glock_disposal))
1135: wake_up(&sdp->sd_kill_wait);
1136:
1137: if (IS_ERR(tmp))
1138: return PTR_ERR(tmp);
1139: gl = tmp;
1140: }
1141:
1142: found:
1143: *glp = gl;
1144: return 0;
1145: }
SourceFile:fs/gfs2/glock.c]
|
| 100/2 |
2026/09/07 00:29 |
llm |
expert |
0m
Model:
Tokens:
input: 82542
output: 43
thoughts: 67
Thoughts: Here's my analysis of the provided snippet, as if it were my thought process:
**Diving into gfs2_glock_get and Initialization**
Okay, so I'm looking at `gfs2_glock_get`, and the first thing that jumps out at me is that it *doesn't* appear to initialize `gl_ail_list`. That's unusual, and something I need to keep in mind. I know that `gl_ail_list` is a critical part of the glock's structure. Where and when is it actually getting set up?
Aha! Now I remember. It's the `gfs2_init_glock_once` constructor where that happens. I recall seeing that initialization during my past reviews. Let me just take a quick look back at `gfs2_init_glock_once` to make sure my understanding is correct and fully refresh my memory of the exact initialization process there. I want to confirm how `gl_ail_list` is set up *exactly* because it plays a role later on.
|
| 101/2 |
2026/09/07 00:30 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/main.c Name:gfs2_init_glock_once]
Results: map[SourceCode: 50: static void gfs2_init_glock_once(void *foo)
51: {
52: struct gfs2_glock *gl = foo;
53:
54: INIT_LIST_HEAD(&gl->gl_holders);
55: INIT_LIST_HEAD(&gl->gl_ail_list);
56: atomic_set(&gl->gl_ail_count, 0);
57: atomic_set(&gl->gl_revokes, 0);
58: }
SourceFile:fs/gfs2/main.c]
|
| 102/2 |
2026/09/07 00:30 |
llm |
expert |
0m
Model:
Tokens:
input: 83056
output: 66
thoughts: 418
Thoughts: **Exploitation of gl_ail_list Corruption**
Okay, here's how this is playing out in my mind. The constructor's initialization of `gl_ail_list` to point to itself seems key, but then it's not re-initialized during freeing or reallocation. That means `gl_ail_list`'s value sticks around after the object is freed, and `gfs2_glock_get` doesn't overwrite it during a subsequent allocation.
At first, I thought this might limit the attacker, as they wouldn't be able to directly control what `gl_ail_list` points to after reallocation. But then it hit me: if the attacker reallocates the glock, and then it's *used* as a normal glock, the old `gl_ail_list` value is still there! This is where things get interesting.
If the original `bd` (block device?) is still linked to that lingering `gl_ail_list`, and the *new* glock starts adding its own `bd`s to that same list, we have a clear path to corruption. When `gfs2_remove_from_ail` is called on the *old* `bd`, it's going to modify the list of the *new* glock. That's a classic scenario for list corruption, and that's the exploitable primitive.
It means the attacker can potentially link their own, controlled objects into the list, or induce arbitrary writes when elements are added or removed. It doesn't matter that they can't directly write to `gl_ail_list` during reallocation. The corruption itself is the exploit.
So, in summary, even with the initial limitations, this is definitely exploitable. Denial of Service is a possibility, and based on the context, there are triggers that could be exploited. Let me set the assessment.
|
| 103/2 |
2026/09/07 00:30 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:true FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 104/2 |
2026/09/07 00:30 |
llm |
expert |
0m
Model:
Tokens:
input: 84005
output: 595
thoughts: 346
Thoughts: **My Final Reasoning on the Vulnerability**
Okay, here's the breakdown, in plain terms, and why I believe this is a critical issue. The crux of it lies in a classic use-after-free scenario. The results are in, and here's my final reasoning.
The problem centers around `gfs2_remove_from_ail` and the `gl_ail_list` within it. It's a use-after-free bug, plain and simple. What happens is this: when a GFS2 filesystem is withdrawn—let's say due to an I/O error or, more concerningly, a maliciously crafted image—`gfs2_evict_inode` cuts some corners. Specifically, it skips the crucial steps of writing out dirty pages and flushing the AIL with `gfs2_ail_flush`. Then, it relinquishes its hold on the inode's glock.
Now, here's where things go sideways: If the reference count on that glock hits zero, it's freed. The system thinks, "Okay, nobody's using this glock anymore, it's safe to release it." However, this is a dangerous assumption because there are still `gfs2_bufdata` objects lurking around, linked to the glock's `gl_ail_list`.
Later, when the withdrawal process attempts to fully drain the AIL via `gfs2_ail_drain`, it tries to remove those orphaned `gfs2_bufdata` objects from the glock's `gl_ail_list`. But that list...it's now on a glock that's been freed. And that's the use-after-free: accessing memory after it's been released.
The really nasty part is the exploitation. An attacker can leverage this list corruption. Since the glock comes from a dedicated `gfs2_glock(aspace)` slab cache, they could manipulate the list pointers if they are able to reallocate the freed glock. This opens the door to arbitrary memory read/write or, at the very least, leaking kernel heap addresses.
The trigger for this is a crafted GFS2 filesystem image. This makes it a Malicious Filesystem Trigger and a Peripheral Trigger. The attacker only needs to have the crafted image mounted – auto-mounting a USB drive, for instance, could do it.
However, the good news is that this is not accessible to unprivileged users in a standard environment, as mounting GFS2 requires `CAP_SYS_ADMIN` in the initial user namespace. Although not trivial, this is still a serious vulnerability.
|
| 105/1 |
2026/09/07 00:30 |
action |
format-explanation |
0m
Results: map[Explanation:**Bug Analysis:**
The bug is a slab-use-after-free in `gfs2_remove_from_ail()` when accessing
`bd->bd_ail_gl_list`.
**Root Cause:**
When a GFS2 filesystem encounters an inconsistency or an I/O error, it enters a
"withdrawn" state to protect data integrity. During this state, if an inode is
evicted (e.g., during a failed mount or memory pressure), `gfs2_evict_inode()`
skips flushing the Active Item List (AIL) because the filesystem is withdrawn
and cannot write out dirty pages. It then proceeds to drop the reference to the
inode's glock (`ip->i_gl`).
If the glock's reference count drops to zero, `__gfs2_glock_put()` frees the
glock. However, because the AIL was not flushed, there are still `gfs2_bufdata`
objects (`bd`) linked to the glock's `gl_ail_list`.
Later, the withdraw worker (`gfs2_withdraw_func()`) calls `gfs2_ail_drain()` to
clean up the remaining transactions. This function iterates over the AIL and
calls `gfs2_remove_from_ail()`, which attempts to unlink the `bd` from
`gl_ail_list` using `list_del_init()`. Since the glock has already been freed,
this results in a use-after-free list operation.
**Exploitability:**
The bug is exploitable. The freed glock belongs to the `gfs2_glock(aspace)`
dedicated slab cache. An attacker can spray the heap to reallocate the freed
glock. When `list_del_init()` is called on the corrupted list, it performs
`next->prev = prev` and `prev->next = next`. By carefully controlling the
reallocation and the state of the list, an attacker can use this list unlinking
primitive to corrupt kernel memory, overwrite pointers, or leak heap addresses
(defeating KASLR).
**Trigger Vectors:**
- **Malicious Filesystem & Peripheral Trigger:** The most viable way to trigger
this bug is by mounting a maliciously crafted GFS2 filesystem image (e.g., from
a USB drive). The crafted image can be designed to dirty buffers during journal
recovery and then intentionally trigger an inconsistency that causes the
filesystem to withdraw during the mount process, leading directly to the bug.
- **Unprivileged Access:** GFS2 does not support `FS_USERNS_MOUNT`, meaning it
cannot be mounted inside unprivileged user namespaces. Mounting it requires
`CAP_SYS_ADMIN` in the initial namespace. Therefore, it is not reachable by
unprivileged local processes unless a vulnerable image is auto-mounted by the
desktop environment.]
|