| 0/0 |
2026/05/25 05:12 |
flow |
assessment-security |
1h01m
Results: map[DenialOfService:false Explanation:**Root Cause Analysis**
The bug report indicates a `WARN_ON_ONCE(!buffer_uptodate(bh))` being triggered
in `mark_buffer_dirty()`. The call trace shows this happens in the UDF
filesystem when allocating a new block (`udf_bitmap_new_block`).
This warning is triggered due to the following sequence of events:
1. The UDF filesystem reads a bitmap block from the disk. The read succeeds, and
the buffer head (`bh`) is marked as uptodate and cached in memory.
2. The filesystem modifies the bitmap block and marks it dirty. The block layer
attempts to write the buffer to the disk asynchronously.
3. An I/O error occurs during the writeback. In the syzkaller report, this is
caused by the underlying loop device changing its capacity (`loop0: detected
capacity change from 0 to 256`), which makes subsequent writes fail.
4. When an asynchronous write fails, the block layer's completion handler
(`end_buffer_async_write()`) clears the `uptodate` flag of the buffer head to
indicate the I/O failure.
5. Later, the filesystem attempts to allocate another block, modifies the same
cached bitmap buffer, and calls `mark_buffer_dirty(bh)`.
6. `mark_buffer_dirty()` checks if the buffer is uptodate. Since the flag was
cleared by the previous failed write, it triggers the `WARN_ON_ONCE`.
**Security Impact**
* **Exploitable:** No. The memory content of the buffer (`bh->b_data`) remains
perfectly valid and contains the filesystem's modifications. There is no memory
corruption, use-after-free, or out-of-bounds access. The warning is merely a
sanity check that complains about dirtying a buffer that previously failed to
write.
* **Denial of Service:** No. The bug only triggers a non-fatal `WARN_ON_ONCE`.
It does not halt the kernel, cause deadlocks, or leak resources. In production
kernels (where `panic_on_warn` is disabled), this will only result in a single
warning in the kernel log.
* **Unprivileged / User Namespace:** No. Triggering this requires mounting a UDF
filesystem. The UDF filesystem does not have the `FS_USERNS_MOUNT` flag, meaning
it cannot be mounted by unprivileged users, even within a user namespace.
* **Peripheral Trigger:** Yes. This can be triggered by a user plugging in a USB
drive formatted with UDF, waiting for it to be auto-mounted by the desktop
environment, initiating a write operation, and physically yanking the USB drive
out before the write completes. The sudden removal of the device will cause I/O
errors, clearing the `uptodate` flag and triggering the warning on subsequent
allocation attempts.
* **Malicious Filesystem Trigger:** No. A malicious filesystem image alone
cannot trigger this. The block must be successfully read first, and then a write
must fail. This strictly requires a failing block device or a device that is
removed/resized at runtime.
**Conclusion**
This is a harmless warning caused by a known interaction between the block
layer's error handling and `mark_buffer_dirty()`. It has no security
implications and cannot be exploited for privilege escalation or denial of
service. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/25 05:12 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/05/25 05:12 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/e1285811811587373a91c9ab00de3dabe338ef7e]
|
| 3/1 |
2026/05/25 05:14 |
action |
kernel-builder |
32m
Results: map[KernelObj:/app/workdir/cache/build/d8fe47c092a4c4125f4531fde5c94d3a388e39dd]
|
| 4/1 |
2026/05/25 05:46 |
action |
codesearch-prepare |
24m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/25 06:10 |
agent |
expert |
3m
Model:
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false 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 greeping
".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 or elevated privileges.
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 completly 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 tranfers, that's 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 exploitabability depends on how exactly the uninit value
is used in the code, and what it affects.
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 Confidetial 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:
loop0: detected capacity change from 0 to 256
udf: Unknown parameter 'iochb�^Ү��'
loop0: detected capacity change from 0 to 1024
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
UDF-fs: warning (device loop0): udf_update_inode: IO error syncing udf inode [00000347]
------------[ cut here ]------------
!buffer_uptodate(bh)
WARNING: fs/buffer.c:1087 at mark_buffer_dirty+0x299/0x410 fs/buffer.c:1087, CPU#0: syz.0.0/5323
Modules linked in:
CPU: 0 UID: 0 PID: 5323 Comm: syz.0.0 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:mark_buffer_dirty+0x299/0x410 fs/buffer.c:1087
Code: 4c 89 f7 e8 b9 5c da ff 49 8b 3e be 40 00 00 00 5b 41 5c 41 5e 41 5f 5d e9 b4 63 fb ff e8 ef 90 6d ff eb 8c e8 e8 90 6d ff 90 <0f> 0b 90 e9 a5 fd ff ff e8 da 90 6d ff 90 0f 0b 90 e9 cf fd ff ff
RSP: 0018:ffffc9000e0aed90 EFLAGS: 00010283
RAX: ffffffff82584058 RBX: ffff88801ccbc2b8 RCX: 0000000000100000
RDX: ffffc9000ec22000 RSI: 000000000000ff56 RDI: 000000000000ff57
RBP: ffffc9000e0af001 R08: ffff88801ccbc2bf R09: 1ffff11003997857
R10: dffffc0000000000 R11: ffffed1003997858 R12: ffff888032e14000
R13: 0000000000000082 R14: 0000000000000142 R15: ffffc9000e0af320
FS: 00007f4edf7166c0(0000) GS:ffff88808c881000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4edf6b2fe8 CR3: 000000000bbc5000 CR4: 0000000000352ef0
Call Trace:
<TASK>
udf_bitmap_new_block fs/udf/balloc.c:347 [inline]
udf_new_block+0x183b/0x1c70 fs/udf/balloc.c:721
inode_getblk fs/udf/inode.c:900 [inline]
udf_map_block+0x1340/0x42d0 fs/udf/inode.c:453
__udf_get_block+0x52/0x250 fs/udf/inode.c:467
__block_write_begin_int+0x6c6/0x1910 fs/buffer.c:2042
block_write_begin+0x8d/0x120 fs/buffer.c:2153
udf_write_begin+0x118/0x270 fs/udf/inode.c:261
generic_perform_write+0x2e2/0x8f0 mm/filemap.c:4325
__generic_file_write_iter+0x1ae/0x230 mm/filemap.c:4439
udf_file_write_iter+0x2ca/0x6b0 fs/udf/file.c:112
iter_file_splice_write+0x9a1/0x10f0 fs/splice.c:736
do_splice_from fs/splice.c:936 [inline]
direct_splice_actor+0x101/0x160 fs/splice.c:1159
splice_direct_to_actor+0x53a/0xc70 fs/splice.c:1103
do_splice_direct_actor fs/splice.c:1202 [inline]
do_splice_direct+0x195/0x290 fs/splice.c:1228
do_sendfile+0x535/0x7d0 fs/read_write.c:1372
__do_sys_sendfile64 fs/read_write.c:1433 [inline]
__se_sys_sendfile64+0x144/0x1a0 fs/read_write.c:1419
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4ede79cdd9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4edf715fe8 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 00007f4edea15fa0 RCX: 00007f4ede79cdd9
RDX: 0000000000000000 RSI: 0000000000000005 RDI: 0000000000000005
RBP: 00007f4ede832d69 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000800000009 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f4edea16038 R14: 00007f4edea15fa0 R15: 00007ffe4b0c6f38
</TASK>
Reply: **Root Cause Analysis**
The bug report indicates a `WARN_ON_ONCE(!buffer_uptodate(bh))` being triggered in `mark_buffer_dirty()`. The call trace shows this happens in the UDF filesystem when allocating a new block (`udf_bitmap_new_block`).
This warning is triggered due to the following sequence of events:
1. The UDF filesystem reads a bitmap block from the disk. The read succeeds, and the buffer head (`bh`) is marked as uptodate and cached in memory.
2. The filesystem modifies the bitmap block and marks it dirty. The block layer attempts to write the buffer to the disk asynchronously.
3. An I/O error occurs during the writeback. In the syzkaller report, this is caused by the underlying loop device changing its capacity (`loop0: detected capacity change from 0 to 256`), which makes subsequent writes fail.
4. When an asynchronous write fails, the block layer's completion handler (`end_buffer_async_write()`) clears the `uptodate` flag of the buffer head to indicate the I/O failure.
5. Later, the filesystem attempts to allocate another block, modifies the same cached bitmap buffer, and calls `mark_buffer_dirty(bh)`.
6. `mark_buffer_dirty()` checks if the buffer is uptodate. Since the flag was cleared by the previous failed write, it triggers the `WARN_ON_ONCE`.
**Security Impact**
* **Exploitable:** No. The memory content of the buffer (`bh->b_data`) remains perfectly valid and contains the filesystem's modifications. There is no memory corruption, use-after-free, or out-of-bounds access. The warning is merely a sanity check that complains about dirtying a buffer that previously failed to write.
* **Denial of Service:** No. The bug only triggers a non-fatal `WARN_ON_ONCE`. It does not halt the kernel, cause deadlocks, or leak resources. In production kernels (where `panic_on_warn` is disabled), this will only result in a single warning in the kernel log.
* **Unprivileged / User Namespace:** No. Triggering this requires mounting a UDF filesystem. The UDF filesystem does not have the `FS_USERNS_MOUNT` flag, meaning it cannot be mounted by unprivileged users, even within a user namespace.
* **Peripheral Trigger:** Yes. This can be triggered by a user plugging in a USB drive formatted with UDF, waiting for it to be auto-mounted by the desktop environment, initiating a write operation, and physically yanking the USB drive out before the write completes. The sudden removal of the device will cause I/O errors, clearing the `uptodate` flag and triggering the warning on subsequent allocation attempts.
* **Malicious Filesystem Trigger:** No. A malicious filesystem image alone cannot trigger this. The block must be successfully read first, and then a write must fail. This strictly requires a failing block device or a device that is removed/resized at runtime.
**Conclusion**
This is a harmless warning caused by a known interaction between the block layer's error handling and `mark_buffer_dirty()`. It has no security implications and cannot be exploited for privilege escalation or denial of service.
|
| 6/2 |
2026/05/25 06:10 |
llm |
expert |
0m
Model:
Tokens:
input: 7513
output: 20
thoughts: 634
Thoughts: **Analyzing a UDF Filesystem Bug**
Okay, here's what I'm seeing. We've got a syzkaller bug report, and it looks like it's triggering a warning in the UDF filesystem code. Specifically, the warning is related to `mark_buffer_dirty` in `fs/buffer.c`. The critical condition is `!buffer_uptodate(bh)`.
The trace tells me this happens during a write operation: we go from `udf_file_write_iter` down to `generic_perform_write`, through the buffer layer with `block_write_begin`, which calls `__block_write_begin_int`. That in turn calls `udf_map_block`, which calls `udf_new_block`. And in that block allocation, a call to `udf_bitmap_new_block` that does something wrong.
My initial thought is to examine the code around line 1087 in `fs/buffer.c`, where the warning is generated. I need to understand why the buffer isn't uptodate when it's being marked dirty. This suggests a potential issue with the buffer handling, possibly related to caching, synchronization, or a race condition within the UDF write path. Perhaps the block allocation in `udf_bitmap_new_block` isn't properly initializing the buffer, or there's a missing synchronization step when working with the UDF bitmap. We also have to consider the fact this comes from a capacity change that is detected. That needs to be understood. The "Unknown parameter" warning is also intriguing. I'll need to dig into `udf_bitmap_new_block`, `udf_map_block` and `__block_write_begin_int` to figure out what's going on.
|
| 7/2 |
2026/05/25 06:10 |
tool |
grepper |
0m
Args: map[Expression:!buffer_uptodate]
Results: map[Output:
Full output is too long, showing 500 out of 589 lines.
Use more precise expression if possible.
[fs/adfs/dir.c=186=static int adfs_dir_sync(struct adfs_dir *dir)
--
fs/adfs/dir.c-193- sync_dirty_buffer(bh);
fs/adfs/dir.c:194: if (buffer_req(bh) && !buffer_uptodate(bh))
fs/adfs/dir.c-195- err = -EIO;
--
fs/bfs/inode.c=132=static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
--
fs/bfs/inode.c-169- sync_dirty_buffer(bh);
fs/bfs/inode.c:170: if (buffer_req(bh) && !buffer_uptodate(bh))
fs/bfs/inode.c-171- err = -EIO;
--
fs/buffer.c=256=static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
--
fs/buffer.c-284- do {
fs/buffer.c:285: if (!buffer_uptodate(tmp))
fs/buffer.c-286- folio_uptodate = 0;
--
fs/buffer.c=550=int mmb_sync(struct mapping_metadata_bhs *mmb)
--
fs/buffer.c-613- wait_on_buffer(bh);
fs/buffer.c:614: if (!buffer_uptodate(bh))
fs/buffer.c-615- err = -EIO;
--
fs/buffer.c=1085=void mark_buffer_dirty(struct buffer_head *bh)
fs/buffer.c-1086-{
fs/buffer.c:1087: WARN_ON_ONCE(!buffer_uptodate(bh));
fs/buffer.c-1088-
--
fs/buffer.c=1399=struct buffer_head *__bread_gfp(struct block_device *bdev, sector_t block,
--
fs/buffer.c-1413-
fs/buffer.c:1414: if (likely(bh) && !buffer_uptodate(bh))
fs/buffer.c-1415- bh = __bread_slow(bh);
--
fs/buffer.c=1940=iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh,
--
fs/buffer.c-1962- */
fs/buffer.c:1963: if (!buffer_uptodate(bh) ||
fs/buffer.c-1964- (offset >= i_size_read(inode)))
--
fs/buffer.c-1967- case IOMAP_DELALLOC:
fs/buffer.c:1968: if (!buffer_uptodate(bh) ||
fs/buffer.c-1969- (offset >= i_size_read(inode)))
--
fs/buffer.c=2007=int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
--
fs/buffer.c-2031- if (folio_test_uptodate(folio)) {
fs/buffer.c:2032: if (!buffer_uptodate(bh))
fs/buffer.c-2033- set_buffer_uptodate(bh);
--
fs/buffer.c-2063- if (folio_test_uptodate(folio)) {
fs/buffer.c:2064: if (!buffer_uptodate(bh))
fs/buffer.c-2065- set_buffer_uptodate(bh);
--
fs/buffer.c-2067- }
fs/buffer.c:2068: if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
fs/buffer.c-2069- !buffer_unwritten(bh) &&
--
fs/buffer.c-2079- wait_on_buffer(*--wait_bh);
fs/buffer.c:2080: if (!buffer_uptodate(*wait_bh))
fs/buffer.c-2081- err = -EIO;
--
fs/buffer.c=2095=void block_commit_write(struct folio *folio, size_t from, size_t to)
--
fs/buffer.c-2110- if (block_end <= from || block_start >= to) {
fs/buffer.c:2111: if (!buffer_uptodate(bh))
fs/buffer.c-2112- partial = true;
--
fs/buffer.c=2243=bool block_is_partially_uptodate(struct folio *folio, size_t from, size_t count)
--
fs/buffer.c-2263- if (block_end > from && block_start < to) {
fs/buffer.c:2264: if (!buffer_uptodate(bh)) {
fs/buffer.c-2265- ret = false;
--
fs/buffer.c=2551=int block_truncate_page(struct address_space *mapping,
--
fs/buffer.c-2603-
fs/buffer.c:2604: if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh)) {
fs/buffer.c-2605- err = bh_read(bh, 0);
--
fs/buffer.c=2764=int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags)
--
fs/buffer.c-2781- wait_on_buffer(bh);
fs/buffer.c:2782: if (!buffer_uptodate(bh))
fs/buffer.c-2783- return -EIO;
--
fs/buffer.c=2986=int bh_uptodate_or_lock(struct buffer_head *bh)
fs/buffer.c-2987-{
fs/buffer.c:2988: if (!buffer_uptodate(bh)) {
fs/buffer.c-2989- lock_buffer(bh);
fs/buffer.c:2990: if (!buffer_uptodate(bh))
fs/buffer.c-2991- return 0;
--
fs/buffer.c=3006=int __bh_read(struct buffer_head *bh, blk_opf_t op_flags, bool wait)
--
fs/buffer.c-3016- wait_on_buffer(bh);
fs/buffer.c:3017: if (!buffer_uptodate(bh))
fs/buffer.c-3018- ret = -EIO;
--
fs/exfat/fatent.c=46=static int __exfat_ent_get(struct super_block *sb, unsigned int loc,
--
fs/exfat/fatent.c-55-
fs/exfat/fatent.c:56: if (!bh || bh->b_blocknr != sec || !buffer_uptodate(bh)) {
fs/exfat/fatent.c-57- brelse(bh);
--
fs/exfat/fatent.c=73=static int __exfat_ent_set(struct super_block *sb, unsigned int loc,
--
fs/exfat/fatent.c-83-
fs/exfat/fatent.c:84: if (!bh || bh->b_blocknr != sec || !buffer_uptodate(bh)) {
fs/exfat/fatent.c-85- if (bh)
--
fs/exfat/misc.c=177=int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync)
--
fs/exfat/misc.c-189- wait_on_buffer(bhs[i]);
fs/exfat/misc.c:190: if (!err && !buffer_uptodate(bhs[i]))
fs/exfat/misc.c-191- err = -EIO;
--
fs/ext2/inode.c=1524=static int __ext2_write_inode(struct inode *inode, int do_sync)
--
fs/ext2/inode.c-1616- sync_dirty_buffer(bh);
fs/ext2/inode.c:1617: if (buffer_req(bh) && !buffer_uptodate(bh)) {
fs/ext2/inode.c-1618- printk ("IO error syncing ext2 inode [%s:%08lx]\n",
--
fs/ext2/xattr.c=706=ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
--
fs/ext2/xattr.c-771- error = -EIO;
fs/ext2/xattr.c:772: if (buffer_req(new_bh) && !buffer_uptodate(new_bh))
fs/ext2/xattr.c-773- goto cleanup;
--
fs/ext4/balloc.c=567=int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group,
--
fs/ext4/balloc.c-580- wait_on_buffer(bh);
fs/ext4/balloc.c:581: if (!buffer_uptodate(bh)) {
fs/ext4/balloc.c-582- ext4_error_err(sb, EIO, "Cannot read block bitmap - "
--
fs/ext4/ext4_jbd2.c=353=int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
--
fs/ext4/ext4_jbd2.c-398- sync_dirty_buffer(bh);
fs/ext4/ext4_jbd2.c:399: if (buffer_req(bh) && !buffer_uptodate(bh)) {
fs/ext4/ext4_jbd2.c-400- ext4_error_inode_err(inode, where, line,
--
fs/ext4/ialloc.c=123=ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
--
fs/ext4/ialloc.c-198- ext4_simulate_fail(sb, EXT4_SIM_IBITMAP_EIO));
fs/ext4/ialloc.c:199: if (!buffer_uptodate(bh)) {
fs/ext4/ialloc.c-200- put_bh(bh);
--
fs/ext4/ialloc.c=675=static int recently_deleted(struct super_block *sb, ext4_group_t group, int ino)
--
fs/ext4/ialloc.c-696- (ino / inodes_per_block));
fs/ext4/ialloc.c:697: if (!bh || !buffer_uptodate(bh))
fs/ext4/ialloc.c-698- /*
--
fs/ext4/inode.c=977=struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
--
fs/ext4/inode.c-1031- }
fs/ext4/inode.c:1032: if (!buffer_uptodate(bh)) {
fs/ext4/inode.c-1033- memset(bh->b_data, 0, inode->i_sb->s_blocksize);
--
fs/ext4/inode.c=1070=int ext4_bread_batch(struct inode *inode, ext4_lblk_t block, int bh_count,
--
fs/ext4/inode.c-1096- for (i = 0; i < bh_count; i++) {
fs/ext4/inode.c:1097: if (bhs[i] && !buffer_uptodate(bhs[i])) {
fs/ext4/inode.c-1098- err = -EIO;
--
fs/ext4/inode.c=1112=int ext4_walk_page_buffers(handle_t *handle, struct inode *inode,
--
fs/ext4/inode.c-1131- if (block_end <= from || block_start >= to) {
fs/ext4/inode.c:1132: if (partial && !buffer_uptodate(bh))
fs/ext4/inode.c-1133- *partial = 1;
--
fs/ext4/inode.c=1170=int ext4_block_write_begin(handle_t *handle, struct folio *folio,
--
fs/ext4/inode.c-1243- }
fs/ext4/inode.c:1244: if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
fs/ext4/inode.c-1245- !buffer_unwritten(bh) &&
--
fs/ext4/inode.c-1255- wait_on_buffer(wait[i]);
fs/ext4/inode.c:1256: if (!buffer_uptodate(wait[i]))
fs/ext4/inode.c-1257- err = -EIO;
--
fs/ext4/inode.c=4030=static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)
--
fs/ext4/inode.c-4078-
fs/ext4/inode.c:4079: if (!buffer_uptodate(bh)) {
fs/ext4/inode.c-4080- err = ext4_read_bh_lock(bh, 0, true);
--
fs/ext4/inode.c=4853=static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino,
--
fs/ext4/inode.c-4923- */
fs/ext4/inode.c:4924: if (!buffer_uptodate(bitmap_bh)) {
fs/ext4/inode.c-4925- brelse(bitmap_bh);
--
fs/ext4/inode.c-4985- wait_on_buffer(bh);
fs/ext4/inode.c:4986: if (!buffer_uptodate(bh)) {
fs/ext4/inode.c-4987- if (ret_block)
--
fs/ext4/inode.c=5760=int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
--
fs/ext4/inode.c-5799- sync_dirty_buffer(iloc.bh);
fs/ext4/inode.c:5800: if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
fs/ext4/inode.c-5801- ext4_error_inode_block(inode, iloc.bh->b_blocknr, EIO,
--
fs/ext4/ioctl.c=59=int ext4_update_primary_sb(struct super_block *sb, handle_t *handle,
--
fs/ext4/ioctl.c-81-
fs/ext4/ioctl.c:82: if (buffer_write_io_error(bh) || !buffer_uptodate(bh)) {
fs/ext4/ioctl.c-83- ext4_msg(sbi->s_sb, KERN_ERR, "previous I/O error to "
--
fs/ext4/mballoc.c=2855=ext4_group_t ext4_mb_prefetch(struct super_block *sb, ext4_group_t group,
--
fs/ext4/mballoc.c-2879- if (!IS_ERR_OR_NULL(bh)) {
fs/ext4/mballoc.c:2880: if (!buffer_uptodate(bh) && cnt)
fs/ext4/mballoc.c-2881- (*cnt)++;
--
fs/ext4/mmp.c=42=static int write_mmp_block_thawed(struct super_block *sb,
--
fs/ext4/mmp.c-52- wait_on_buffer(bh);
fs/ext4/mmp.c:53: if (unlikely(!buffer_uptodate(bh)))
fs/ext4/mmp.c-54- return -EIO;
--
fs/ext4/move_extent.c=117=static int mext_folio_mkuptodate(struct folio *folio, size_t from, size_t to)
--
fs/ext4/move_extent.c-143- if (block_end <= from || block_start >= to) {
fs/ext4/move_extent.c:144: if (!buffer_uptodate(bh))
fs/ext4/move_extent.c-145- partial = true;
--
fs/ext4/namei.c=1517=static struct buffer_head *__ext4_find_entry(struct inode *dir,
--
fs/ext4/namei.c-1611- wait_on_buffer(bh);
fs/ext4/namei.c:1612: if (!buffer_uptodate(bh)) {
fs/ext4/namei.c-1613- EXT4_ERROR_INODE_ERR(dir, EIO,
--
fs/ext4/super.c=751=static void update_super_work(struct work_struct *work)
--
fs/ext4/super.c-782- ext4_update_super(sbi->s_sb);
fs/ext4/super.c:783: if (buffer_write_io_error(sbh) || !buffer_uptodate(sbh)) {
fs/ext4/super.c-784- ext4_msg(sbi->s_sb, KERN_ERR, "previous I/O error to "
--
fs/ext4/super.c=6289=static int ext4_commit_super(struct super_block *sb)
--
fs/ext4/super.c-6304-
fs/ext4/super.c:6305: if (buffer_write_io_error(sbh) || !buffer_uptodate(sbh)) {
fs/ext4/super.c-6306- /*
--
fs/fat/dir.c=51=static inline void fat_dir_readahead(struct inode *dir, sector_t iblock,
--
fs/fat/dir.c-66- bh = sb_find_get_block(sb, phys);
fs/fat/dir.c:67: if (bh == NULL || !buffer_uptodate(bh)) {
fs/fat/dir.c-68- for (sec = 0; sec < sbi->sec_per_clus; sec++)
--
fs/fat/misc.c=349=int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
--
fs/fat/misc.c-357- wait_on_buffer(bhs[i]);
fs/fat/misc.c:358: if (!err && !buffer_uptodate(bhs[i]))
fs/fat/misc.c-359- err = -EIO;
--
fs/gfs2/bmap.c=294=static void gfs2_metapath_ra(struct gfs2_glock *gl, __be64 *start, __be64 *end)
--
fs/gfs2/bmap.c-305- if (trylock_buffer(rabh)) {
fs/gfs2/bmap.c:306: if (!buffer_uptodate(rabh)) {
fs/gfs2/bmap.c-307- rabh->b_end_io = end_buffer_read_sync;
--
fs/gfs2/log.c=300=static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
--
fs/gfs2/log.c-323- }
fs/gfs2/log.c:324: if (!buffer_uptodate(bh) &&
fs/gfs2/log.c-325- !cmpxchg(&sdp->sd_log_error, 0, -EIO))
--
fs/gfs2/lops.c=42=void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
--
fs/gfs2/lops.c-50- gfs2_assert_withdraw(sdp, 0);
fs/gfs2/lops.c:51: if (!buffer_uptodate(bh))
fs/gfs2/lops.c-52- gfs2_io_error_bh(sdp, bh);
--
fs/gfs2/lops.c=102=static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
--
fs/gfs2/lops.c-106-
fs/gfs2/lops.c:107: BUG_ON(!buffer_uptodate(bh));
fs/gfs2/lops.c-108- BUG_ON(!buffer_pinned(bh));
--
fs/gfs2/meta_io.c=259=int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
--
fs/gfs2/meta_io.c-301- wait_on_buffer(bh);
fs/gfs2/meta_io.c:302: if (unlikely(!buffer_uptodate(bh))) {
fs/gfs2/meta_io.c-303- struct gfs2_trans *tr = current->journal_info;
--
fs/gfs2/meta_io.c=322=int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)
--
fs/gfs2/meta_io.c-328-
fs/gfs2/meta_io.c:329: if (!buffer_uptodate(bh)) {
fs/gfs2/meta_io.c-330- struct gfs2_trans *tr = current->journal_info;
--
fs/gfs2/rgrp.c=1147=static u32 count_unlinked(struct gfs2_rgrpd *rgd)
--
fs/gfs2/rgrp.c-1156- buffer = bi->bi_bh->b_data + bi->bi_offset;
fs/gfs2/rgrp.c:1157: WARN_ON(!buffer_uptodate(bi->bi_bh));
fs/gfs2/rgrp.c-1158- while (goal < bi->bi_blocks) {
--
fs/gfs2/rgrp.c=1738=static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext,
--
fs/gfs2/rgrp.c-1765- buffer = bh->b_data + bi->bi_offset;
fs/gfs2/rgrp.c:1766: WARN_ON(!buffer_uptodate(bh));
fs/gfs2/rgrp.c-1767- if (state != GFS2_BLKST_UNLINKED && bi->bi_clone)
--
fs/hpfs/buffer.c=93=void *hpfs_get_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp)
--
fs/hpfs/buffer.c-102- if ((*bhp = bh = sb_getblk(s, hpfs_search_hotfix_map(s, secno))) != NULL) {
fs/hpfs/buffer.c:103: if (!buffer_uptodate(bh)) wait_on_buffer(bh);
fs/hpfs/buffer.c-104- set_buffer_uptodate(bh);
--
fs/isofs/compress.c=40=static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
--
fs/isofs/compress.c-98- wait_on_buffer(bhs[0]);
fs/isofs/compress.c:99: if (!buffer_uptodate(bhs[0])) {
fs/isofs/compress.c-100- *errp = -EIO;
--
fs/isofs/compress.c-132- wait_on_buffer(bhs[curbh]);
fs/isofs/compress.c:133: if (!buffer_uptodate(bhs[curbh])) {
fs/isofs/compress.c-134- *errp = -EIO;
--
fs/jbd2/commit.c=165=static int journal_wait_on_commit_record(journal_t *journal,
--
fs/jbd2/commit.c-172-
fs/jbd2/commit.c:173: if (unlikely(!buffer_uptodate(bh)))
fs/jbd2/commit.c-174- ret = -EIO;
--
fs/jbd2/commit.c=377=void jbd2_journal_commit_transaction(journal_t *journal)
--
fs/jbd2/commit.c-839-
fs/jbd2/commit.c:840: if (unlikely(!buffer_uptodate(bh)))
fs/jbd2/commit.c-841- err = -EIO;
--
fs/jbd2/commit.c-882-
fs/jbd2/commit.c:883: if (unlikely(!buffer_uptodate(bh)))
fs/jbd2/commit.c-884- err = -EIO;
--
fs/jbd2/journal.c=868=int jbd2_fc_wait_bufs(journal_t *journal, int num_blks)
--
fs/jbd2/journal.c-885- */
fs/jbd2/journal.c:886: if (unlikely(!buffer_uptodate(bh))) {
fs/jbd2/journal.c-887- journal->j_fc_off = i + 1;
--
fs/jbd2/recovery.c=68=static void do_readahead(journal_t *journal, unsigned int start)
--
fs/jbd2/recovery.c-98-
fs/jbd2/recovery.c:99: if (!buffer_uptodate(bh) && !buffer_locked(bh)) {
fs/jbd2/recovery.c-100- bufs[nbufs++] = bh;
--
fs/jbd2/recovery.c=125=static int jread(struct buffer_head **bhp, journal_t *journal,
--
fs/jbd2/recovery.c-150-
fs/jbd2/recovery.c:151: if (!buffer_uptodate(bh)) {
fs/jbd2/recovery.c-152- /*
--
fs/jbd2/recovery.c-163-
fs/jbd2/recovery.c:164: if (!buffer_uptodate(bh)) {
fs/jbd2/recovery.c-165- printk(KERN_ERR "JBD2: Failed to read block at offset %u\n",
--
fs/minix/inode.c=685=static int minix_write_inode(struct inode *inode, struct writeback_control *wbc)
--
fs/minix/inode.c-697- sync_dirty_buffer(bh);
fs/minix/inode.c:698: if (buffer_req(bh) && !buffer_uptodate(bh)) {
fs/minix/inode.c-699- printk("IO error syncing minix inode [%s:%08llx]\n",
--
fs/mpage.c=453=static int mpage_write_folio(struct writeback_control *wbc, struct folio *folio,
--
fs/mpage.c-497-
fs/mpage.c:498: if (!buffer_dirty(bh) || !buffer_uptodate(bh))
fs/mpage.c-499- goto confused;
--
fs/nilfs2/btree.c=471=static int __nilfs_btree_get_block(const struct nilfs_bmap *btree, __u64 ptr,
--
fs/nilfs2/btree.c-521- out_no_wait:
fs/nilfs2/btree.c:522: if (!buffer_uptodate(bh)) {
fs/nilfs2/btree.c-523- nilfs_err(btree->b_inode->i_sb,
--
fs/nilfs2/dat.c=398=int nilfs_dat_translate(struct inode *dat, __u64 vblocknr, sector_t *blocknrp)
--
fs/nilfs2/dat.c-412- if (bh) {
fs/nilfs2/dat.c:413: WARN_ON(!buffer_uptodate(bh));
fs/nilfs2/dat.c-414- brelse(entry_bh);
--
fs/nilfs2/gcinode.c=133=int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *bh)
--
fs/nilfs2/gcinode.c-135- wait_on_buffer(bh);
fs/nilfs2/gcinode.c:136: if (!buffer_uptodate(bh)) {
fs/nilfs2/gcinode.c-137- struct inode *inode = bh->b_folio->mapping->host;
--
fs/nilfs2/inode.c=960=int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh)
--
fs/nilfs2/inode.c-966- spin_lock(&nilfs->ns_inode_lock);
fs/nilfs2/inode.c:967: if (ii->i_bh == NULL || unlikely(!buffer_uptodate(ii->i_bh))) {
fs/nilfs2/inode.c-968- spin_unlock(&nilfs->ns_inode_lock);
--
fs/nilfs2/inode.c-975- ii->i_bh = *pbh;
fs/nilfs2/inode.c:976: else if (unlikely(!buffer_uptodate(ii->i_bh))) {
fs/nilfs2/inode.c-977- __brelse(ii->i_bh);
--
fs/nilfs2/mdt.c=170=static int nilfs_mdt_read_block(struct inode *inode, unsigned long block,
--
fs/nilfs2/mdt.c-203- err = -EIO;
fs/nilfs2/mdt.c:204: if (!buffer_uptodate(first_bh)) {
fs/nilfs2/mdt.c-205- nilfs_err(inode->i_sb,
--
fs/nilfs2/mdt.c=568=int nilfs_mdt_freeze_buffer(struct inode *inode, struct buffer_head *bh)
--
fs/nilfs2/mdt.c-586-
fs/nilfs2/mdt.c:587: if (!buffer_uptodate(bh_frozen))
fs/nilfs2/mdt.c-588- nilfs_copy_buffer(bh_frozen, bh);
--
fs/nilfs2/segbuf.c=95=int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *segbuf)
--
fs/nilfs2/segbuf.c-104- lock_buffer(bh);
fs/nilfs2/segbuf.c:105: if (!buffer_uptodate(bh)) {
fs/nilfs2/segbuf.c-106- memset(bh->b_data, 0, bh->b_size);
--
fs/ntfs3/fsntfs.c=1333=int ntfs_get_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo,
--
fs/ntfs3/fsntfs.c-1384- lock_buffer(bh);
fs/ntfs3/fsntfs.c:1385: if (!buffer_uptodate(bh)) {
fs/ntfs3/fsntfs.c-1386- memset(bh->b_data, 0, blocksize);
--
fs/ocfs2/alloc.c=877=static int ocfs2_validate_extent_block(struct super_block *sb,
--
fs/ocfs2/alloc.c-885-
fs/ocfs2/alloc.c:886: BUG_ON(!buffer_uptodate(bh));
fs/ocfs2/alloc.c-887-
--
fs/ocfs2/aops.c=42=static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
--
fs/ocfs2/aops.c-80- * need be, copy it over from the buffer cache. */
fs/ocfs2/aops.c:81: if (!buffer_uptodate(bh_result) && ocfs2_inode_is_new(inode)) {
fs/ocfs2/aops.c-82- u64 blkno = le64_to_cpu(fe->id2.i_list.l_recs[0].e_blkno) +
--
fs/ocfs2/aops.c=396=int walk_page_buffers( handle_t *handle,
--
fs/ocfs2/aops.c-416- if (block_end <= from || block_start >= to) {
fs/ocfs2/aops.c:417: if (partial && !buffer_uptodate(bh))
fs/ocfs2/aops.c-418- *partial = 1;
--
fs/ocfs2/aops.c=575=int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno,
--
fs/ocfs2/aops.c-617- set_buffer_uptodate(bh);
fs/ocfs2/aops.c:618: } else if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
fs/ocfs2/aops.c-619- !buffer_new(bh) &&
--
fs/ocfs2/aops.c-633- wait_on_buffer(*--wait_bh);
fs/ocfs2/aops.c:634: if (!buffer_uptodate(*wait_bh))
fs/ocfs2/aops.c-635- ret = -EIO;
--
fs/ocfs2/buffer_head_io.c=89=int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
--
fs/ocfs2/buffer_head_io.c-176-
fs/ocfs2/buffer_head_io.c:177: if (!buffer_uptodate(bh)) {
fs/ocfs2/buffer_head_io.c-178- /* Status won't be cleared from here on out,
--
fs/ocfs2/buffer_head_io.c=193=int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
--
fs/ocfs2/buffer_head_io.c-363-
fs/ocfs2/buffer_head_io.c:364: if (!buffer_uptodate(bh)) {
fs/ocfs2/buffer_head_io.c-365- /* Status won't be cleared from here on out,
--
fs/ocfs2/buffer_head_io.c=428=int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
--
fs/ocfs2/buffer_head_io.c-455-
fs/ocfs2/buffer_head_io.c:456: if (!buffer_uptodate(bh)) {
fs/ocfs2/buffer_head_io.c-457- ret = -EIO;
--
fs/ocfs2/dir.c=437=static int ocfs2_validate_dir_block(struct super_block *sb,
--
fs/ocfs2/dir.c-450-
fs/ocfs2/dir.c:451: BUG_ON(!buffer_uptodate(bh));
fs/ocfs2/dir.c-452-
--
fs/ocfs2/dir.c=581=static int ocfs2_validate_dx_root(struct super_block *sb,
--
fs/ocfs2/dir.c-586-
fs/ocfs2/dir.c:587: BUG_ON(!buffer_uptodate(bh));
fs/ocfs2/dir.c-588-
--
fs/ocfs2/dir.c=650=static int ocfs2_validate_dx_leaf(struct super_block *sb,
--
fs/ocfs2/dir.c-655-
fs/ocfs2/dir.c:656: BUG_ON(!buffer_uptodate(bh));
fs/ocfs2/dir.c-657-
--
fs/ocfs2/inode.c=1423=int ocfs2_validate_inode_block(struct super_block *sb,
--
fs/ocfs2/inode.c-1430-
fs/ocfs2/inode.c:1431: BUG_ON(!buffer_uptodate(bh));
fs/ocfs2/inode.c-1432-
--
fs/ocfs2/inode.c=1568=static int ocfs2_filecheck_validate_inode_block(struct super_block *sb,
--
fs/ocfs2/inode.c-1576-
fs/ocfs2/inode.c:1577: BUG_ON(!buffer_uptodate(bh));
fs/ocfs2/inode.c-1578-
--
]
]
|
| 8/2 |
2026/05/25 06:11 |
llm |
expert |
0m
Model:
Tokens:
input: 18564
output: 46
thoughts: 405
Thoughts: **Analyzing a `WARN_ON_ONCE` in the UDF Filesystem**
Okay, so I've got a `WARN_ON_ONCE` triggering at `fs/buffer.c:1087`, specifically in `mark_buffer_dirty`. It looks like it's complaining because `buffer_uptodate(bh)` is false when it shouldn't be. This suggests that a buffer is being marked dirty before it has valid data, which is definitely a no-no.
The stack trace gives me the critical path: The issue appears to originate within the UDF filesystem, specifically in block allocation. Let's trace it backwards... It's triggered within `udf_bitmap_new_block` called from `udf_new_block` and then, crucially, via `udf_map_block` and ultimately, during a write operation. It starts with a call to `udf_file_write_iter` which eventually lands in `block_write_begin`, which triggers the warning. This all seems to happen when trying to write data.
I should start by examining `fs/udf/balloc.c:347`. The function `udf_bitmap_new_block` is where this whole allocation process appears to begin. I need to understand why a buffer is being marked dirty when it's not uptodate, and the allocation logic seems to be a good place to start my investigation. Perhaps there's an issue with how new blocks are being initialized or flagged? Maybe we're setting the dirty bit too early. I'll focus on how `udf_bitmap_new_block` and `udf_new_block` interact with the buffer, focusing on how `buffer_uptodate` is managed within these functions.
|
| 9/2 |
2026/05/25 06:11 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/udf/balloc.c IncludeLines:true Name:udf_bitmap_new_block]
Results: map[SourceCode: 222: static udf_pblk_t udf_bitmap_new_block(struct super_block *sb,
223: struct udf_bitmap *bitmap, uint16_t partition,
224: uint32_t goal, int *err)
225: {
226: struct udf_sb_info *sbi = UDF_SB(sb);
227: int newbit, bit = 0;
228: udf_pblk_t block;
229: int block_group, group_start;
230: int end_goal, nr_groups, bitmap_nr, i;
231: struct buffer_head *bh = NULL;
232: char *ptr;
233: udf_pblk_t newblock = 0;
234:
235: *err = -ENOSPC;
236: mutex_lock(&sbi->s_alloc_mutex);
237:
238: repeat:
239: if (goal >= sbi->s_partmaps[partition].s_partition_len)
240: goal = 0;
241:
242: nr_groups = bitmap->s_nr_groups;
243: block = goal + (sizeof(struct spaceBitmapDesc) << 3);
244: block_group = block >> (sb->s_blocksize_bits + 3);
245: group_start = block_group ? 0 : sizeof(struct spaceBitmapDesc);
246:
247: bitmap_nr = load_block_bitmap(sb, bitmap, block_group);
248: if (bitmap_nr < 0)
249: goto error_return;
250: bh = bitmap->s_block_bitmap[bitmap_nr];
251: ptr = memscan((char *)bh->b_data + group_start, 0xFF,
252: sb->s_blocksize - group_start);
253:
254: if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
255: bit = block % (sb->s_blocksize << 3);
256: if (udf_test_bit(bit, bh->b_data))
257: goto got_block;
258:
259: end_goal = (bit + 63) & ~63;
260: bit = udf_find_next_one_bit(bh->b_data, end_goal, bit);
261: if (bit < end_goal)
262: goto got_block;
263:
264: ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF,
265: sb->s_blocksize - ((bit + 7) >> 3));
266: newbit = (ptr - ((char *)bh->b_data)) << 3;
267: if (newbit < sb->s_blocksize << 3) {
268: bit = newbit;
269: goto search_back;
270: }
271:
272: newbit = udf_find_next_one_bit(bh->b_data,
273: sb->s_blocksize << 3, bit);
274: if (newbit < sb->s_blocksize << 3) {
275: bit = newbit;
276: goto got_block;
277: }
278: }
279:
280: for (i = 0; i < (nr_groups * 2); i++) {
281: block_group++;
282: if (block_group >= nr_groups)
283: block_group = 0;
284: group_start = block_group ? 0 : sizeof(struct spaceBitmapDesc);
285:
286: bitmap_nr = load_block_bitmap(sb, bitmap, block_group);
287: if (bitmap_nr < 0)
288: goto error_return;
289: bh = bitmap->s_block_bitmap[bitmap_nr];
290: if (i < nr_groups) {
291: ptr = memscan((char *)bh->b_data + group_start, 0xFF,
292: sb->s_blocksize - group_start);
293: if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
294: bit = (ptr - ((char *)bh->b_data)) << 3;
295: break;
296: }
297: } else {
298: bit = udf_find_next_one_bit(bh->b_data,
299: sb->s_blocksize << 3,
300: group_start << 3);
301: if (bit < sb->s_blocksize << 3)
302: break;
303: }
304: }
305: if (i >= (nr_groups * 2)) {
306: mutex_unlock(&sbi->s_alloc_mutex);
307: return newblock;
308: }
309: if (bit < sb->s_blocksize << 3)
310: goto search_back;
311: else
312: bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3,
313: group_start << 3);
314: if (bit >= sb->s_blocksize << 3) {
315: mutex_unlock(&sbi->s_alloc_mutex);
316: return 0;
317: }
318:
319: search_back:
320: i = 0;
321: while (i < 7 && bit > (group_start << 3) &&
322: udf_test_bit(bit - 1, bh->b_data)) {
323: ++i;
324: --bit;
325: }
326:
327: got_block:
328: newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) -
329: (sizeof(struct spaceBitmapDesc) << 3);
330:
331: if (newblock >= sbi->s_partmaps[partition].s_partition_len) {
332: /*
333: * Ran off the end of the bitmap, and bits following are
334: * non-compliant (not all zero)
335: */
336: udf_err(sb, "bitmap for partition %d corrupted (block %u marked"
337: " as free, partition length is %u)\n", partition,
338: newblock, sbi->s_partmaps[partition].s_partition_len);
339: goto error_return;
340: }
341:
342: if (!udf_clear_bit(bit, bh->b_data)) {
343: udf_debug("bit already cleared for block %d\n", bit);
344: goto repeat;
345: }
346:
347: mark_buffer_dirty(bh);
348:
349: udf_add_free_space(sb, partition, -1);
350: mutex_unlock(&sbi->s_alloc_mutex);
351: *err = 0;
352: return newblock;
353:
354: error_return:
355: *err = -EIO;
356: mutex_unlock(&sbi->s_alloc_mutex);
357: return 0;
358: }
SourceFile:fs/udf/balloc.c]
|
| 10/2 |
2026/05/25 06:11 |
llm |
expert |
0m
Model:
Tokens:
input: 21651
output: 43
thoughts: 77
Thoughts: **Analyzing the Potential Issue in UDF File System Bitmap Management**
Okay, so I've got this warning popping up, and it's pointing me right at `mark_buffer_dirty(bh)` within the `udf_bitmap_new_block` function. That's immediately interesting, so I need to understand the context. The crucial part seems to be how `bh` is obtained. It looks like `bh` is coming from `load_block_bitmap(sb, bitmap, block_group)`, specifically from this line: `bh = bitmap->s_block_bitmap[bitmap_nr];`. Right, so this `load_block_bitmap` is likely the key to tracing the problem. I'll need to dig into `load_block_bitmap` to see how it's managing and loading these bitmap buffers and understand where things might be going wrong to trigger this `mark_buffer_dirty` call at the wrong time or with an invalid buffer. Let's see what that function is up to.
|
| 11/2 |
2026/05/25 06:11 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/udf/balloc.c IncludeLines:true Name:load_block_bitmap]
Results: map[SourceCode: 77: static int load_block_bitmap(struct super_block *sb,
78: struct udf_bitmap *bitmap,
79: unsigned int block_group)
80: {
81: int retval = 0;
82: int nr_groups = bitmap->s_nr_groups;
83:
84: if (block_group >= nr_groups) {
85: udf_debug("block_group (%u) > nr_groups (%d)\n",
86: block_group, nr_groups);
87: }
88:
89: if (bitmap->s_block_bitmap[block_group]) {
90: /*
91: * The bitmap failed verification in the past. No point in
92: * trying again.
93: */
94: if (IS_ERR(bitmap->s_block_bitmap[block_group]))
95: return PTR_ERR(bitmap->s_block_bitmap[block_group]);
96: return block_group;
97: }
98:
99: retval = read_block_bitmap(sb, bitmap, block_group, block_group);
100: if (retval < 0)
101: return retval;
102:
103: return block_group;
104: }
SourceFile:fs/udf/balloc.c]
|
| 12/2 |
2026/05/25 06:11 |
llm |
expert |
0m
Model:
Tokens:
input: 22393
output: 43
thoughts: 11
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing the `read_block_bitmap` Function**
Alright, time to dive in. My first thought is to zero in on that `read_block_bitmap` function. I need to refresh my understanding of how it's implemented. I'm assuming it's part of the block device driver/filesystem layer we're dealing with here, likely responsible for managing the allocation and deallocation of data blocks on the storage medium. I want to quickly evaluate:
* **How it interacts with the underlying storage:** Is it making direct hardware calls, or working through some intermediate abstraction layer? I need to understand how it's physically reading the data to understand where it might fail, and to find what's wrong.
* **The bitmap format:** What's the bit-per-block ratio? Is it a simple linear bitmap, or something more sophisticated like a block group bitmap? Any quirks with endianness or data structure packing would be good to quickly understand.
* **Error handling and recovery:** Does it have robust error checking? What happens if it encounters a bad sector or read error? Is there any redundancy? Does it retry reads, or log an error and give up?
* **Caching:** Is there any caching or prefetching involved? That could introduce interesting failure modes if the cache gets corrupted or invalid.
* **Concurrency:** Is this function thread-safe? Does it handle locking correctly if multiple threads are reading/writing bitmaps concurrently? This is something I'll need to know about to avoid data corruption.
* **Assumptions and Edge Cases:** Do any assumptions have been made on the sizes or blocks? If these are not handled correctly there could be issues.
I'll be looking for potential bottlenecks, points of failure, and any opportunities for optimization. This will be the key to understanding how our data is being stored. I'm hoping I can find the answer quickly and fix this.
|
| 13/2 |
2026/05/25 06:11 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/udf/balloc.c IncludeLines:true Name:read_block_bitmap]
Results: map[SourceCode: 31: static int read_block_bitmap(struct super_block *sb,
32: struct udf_bitmap *bitmap, unsigned int block,
33: unsigned long bitmap_nr)
34: {
35: struct buffer_head *bh = NULL;
36: int i;
37: int max_bits, off, count;
38: struct kernel_lb_addr loc;
39:
40: loc.logicalBlockNum = bitmap->s_extPosition;
41: loc.partitionReferenceNum = UDF_SB(sb)->s_partition;
42:
43: bh = sb_bread(sb, udf_get_lb_pblock(sb, &loc, block));
44: bitmap->s_block_bitmap[bitmap_nr] = bh;
45: if (!bh)
46: return -EIO;
47:
48: /* Check consistency of Space Bitmap buffer. */
49: max_bits = sb->s_blocksize * 8;
50: if (!bitmap_nr) {
51: off = sizeof(struct spaceBitmapDesc) << 3;
52: count = min(max_bits - off, bitmap->s_nr_groups);
53: } else {
54: /*
55: * Rough check if bitmap number is too big to have any bitmap
56: * blocks reserved.
57: */
58: if (bitmap_nr >
59: (bitmap->s_nr_groups >> (sb->s_blocksize_bits + 3)) + 2)
60: return 0;
61: off = 0;
62: count = bitmap->s_nr_groups - bitmap_nr * max_bits +
63: (sizeof(struct spaceBitmapDesc) << 3);
64: count = min(count, max_bits);
65: }
66:
67: for (i = 0; i < count; i++)
68: if (udf_test_bit(i + off, bh->b_data)) {
69: bitmap->s_block_bitmap[bitmap_nr] =
70: ERR_PTR(-EFSCORRUPTED);
71: brelse(bh);
72: return -EFSCORRUPTED;
73: }
74: return 0;
75: }
SourceFile:fs/udf/balloc.c]
|
| 14/2 |
2026/05/25 06:11 |
llm |
expert |
0m
Model:
Tokens:
input: 23564
output: 41
thoughts: 354
Thoughts: **Debugging a Possible UDF Filesystem Issue**
Okay, let me break this down. I'm looking at this `read_block_bitmap` function and I see it uses `sb_bread`, which is supposed to synchronously read a block and return an up-to-date buffer head. Crucially, if `sb_bread` succeeds, that buffer *should* be uptodate. But then, I see that `udf_bitmap_new_block` modifies the buffer and calls `mark_buffer_dirty(bh)`. I'm trying to figure out how `!buffer_uptodate(bh)` could possibly be true at this point. That makes no sense, I wouldn't expect this, given my experience.
Then I recalled that the buffer could be invalidated if there was an I/O error. Then I see the bug report, which points at a capacity change on `loop0` device, which seems related, given it reports a change from 0 to 256 then 1024, and then there's this `udf_update_inode` printing an "IO error". Ah, so it looks like `udf_update_inode` prints the I/O error message. Then I also recall that an I/O error might clear the 'uptodate' flag. That makes sense. This means that a write might fail. When a buffer write fails, the flag could get cleared by `end_buffer_write_sync` or `end_buffer_async_write`. I need to confirm this now. Let me check `end_buffer_async_write`.
|
| 15/2 |
2026/05/25 06:11 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/buffer.c IncludeLines:true Name:end_buffer_async_write]
Results: map[SourceCode: 379: /*
380: * Completion handler for block_write_full_folio() - folios which are unlocked
381: * during I/O, and which have the writeback flag cleared upon I/O completion.
382: */
383: static void end_buffer_async_write(struct buffer_head *bh, int uptodate)
384: {
385: unsigned long flags;
386: struct buffer_head *first;
387: struct buffer_head *tmp;
388: struct folio *folio;
389:
390: BUG_ON(!buffer_async_write(bh));
391:
392: folio = bh->b_folio;
393: if (uptodate) {
394: set_buffer_uptodate(bh);
395: } else {
396: buffer_io_error(bh, ", lost async page write");
397: mark_buffer_write_io_error(bh);
398: clear_buffer_uptodate(bh);
399: }
400:
401: first = folio_buffers(folio);
402: spin_lock_irqsave(&first->b_uptodate_lock, flags);
403:
404: clear_buffer_async_write(bh);
405: unlock_buffer(bh);
406: tmp = bh->b_this_page;
407: while (tmp != bh) {
408: if (buffer_async_write(tmp)) {
409: BUG_ON(!buffer_locked(tmp));
410: goto still_busy;
411: }
412: tmp = tmp->b_this_page;
413: }
414: spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
415: folio_end_writeback(folio);
416: return;
417:
418: still_busy:
419: spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
420: }
SourceFile:fs/buffer.c]
|
| 16/2 |
2026/05/25 06:11 |
llm |
expert |
0m
Model:
Tokens:
input: 24943
output: 39
thoughts: 757
Thoughts: **Analyzing a Potential UDF Filesystem Issue**
Okay, so here's what I'm thinking... the code triggers a warning due to a buffer not being marked as `uptodate` even though it's modified. Specifically, `clear_buffer_uptodate(bh)` is called when an I/O error occurs, which makes sense. If there's a writeback I/O error, the buffer loses its `uptodate` flag. Then, later, if the filesystem tries to modify this same buffer again and calls `mark_buffer_dirty(bh)`, boom, we get `WARN_ON_ONCE(!buffer_uptodate(bh))`.
I see that `udf_bitmap_new_block` modifies a block bitmap buffer (`bh->b_data`) and then immediately calls `mark_buffer_dirty(bh)`. The problem is that it *doesn't* explicitly check if the buffer is still `uptodate` *before* the modification! The buffer `bh` is cached in `bitmap->s_block_bitmap[bitmap_nr]`. When first read, the buffer was `uptodate`. Then it was written back, but the write failed – losing the `uptodate` flag. So then `udf_bitmap_new_block` gets called again, reuses the cached `bh`, modifies it, and calls `mark_buffer_dirty`, which triggers the warning.
The warning itself isn't a kernel panic; it's just a `WARN_ON_ONCE`. So, is this actually exploitable? There's no obvious memory corruption at first glance. The buffer is still valid, `bh->b_data` is still good memory. It's just that the `uptodate` flag is false because of the I/O error. Modifying it and marking it dirty again will simply attempt another writeback. This looks like a harmless warning. Maybe a denial-of-service, if the warning gets treated as a panic, but that's not the default.
But, if the buffer is *not* `uptodate`, its contents may not reflect what's on disk. However, it's a bitmap block, so the read, modify, and failed write cycle means the modified contents are *only* in memory. But does the memory content get corrupted by the failed write? No. It *should* still contain what the filesystem wrote to it.
So, okay, it still looks like just a warning.
Let me explore any other consequences. Could the buffer get freed and then reallocated? Nope, `bh` is pinned by the filesystem because it's in `bitmap->s_block_bitmap[bitmap_nr]`. Remember `read_block_bitmap` uses `sb_bread(...)` which returns a buffer with elevated refcount. The filesystem keeps this `bh` in the bitmap until unmount. So, no free.
So, the issue is that `end_buffer_async_write` clears the `uptodate` flag on I/O errors. And then `mark_buffer_dirty` gives us a warning if the flag is clear. I think I will check `fs/buffer.c` for `mark_buffer_dirty`.
|
| 17/2 |
2026/05/25 06:11 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/buffer.c IncludeLines:true Name:mark_buffer_dirty]
Results: map[SourceCode:1073: /**
1074: * mark_buffer_dirty - mark a buffer_head as needing writeout
1075: * @bh: the buffer_head to mark dirty
1076: *
1077: * mark_buffer_dirty() will set the dirty bit against the buffer, then set
1078: * its backing page dirty, then tag the page as dirty in the page cache
1079: * and then attach the address_space's inode to its superblock's dirty
1080: * inode list.
1081: *
1082: * mark_buffer_dirty() is atomic. It takes bh->b_folio->mapping->i_private_lock,
1083: * i_pages lock and mapping->host->i_lock.
1084: */
1085: void mark_buffer_dirty(struct buffer_head *bh)
1086: {
1087: WARN_ON_ONCE(!buffer_uptodate(bh));
1088:
1089: trace_block_dirty_buffer(bh);
1090:
1091: /*
1092: * Very *carefully* optimize the it-is-already-dirty case.
1093: *
1094: * Don't let the final "is it dirty" escape to before we
1095: * perhaps modified the buffer.
1096: */
1097: if (buffer_dirty(bh)) {
1098: smp_mb();
1099: if (buffer_dirty(bh))
1100: return;
1101: }
1102:
1103: if (!test_set_buffer_dirty(bh)) {
1104: struct folio *folio = bh->b_folio;
1105: struct address_space *mapping = NULL;
1106:
1107: if (!folio_test_set_dirty(folio)) {
1108: mapping = folio->mapping;
1109: if (mapping)
1110: __folio_mark_dirty(folio, mapping, 0);
1111: }
1112: if (mapping)
1113: __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
1114: }
1115: }
SourceFile:fs/buffer.c]
|
| 18/2 |
2026/05/25 06:11 |
llm |
expert |
0m
Model:
Tokens:
input: 27090
output: 28
thoughts: 1345
Thoughts: **Analysis of the UDF Filesystem `WARN_ON_ONCE`**
Okay, so the warning is just a `WARN_ON_ONCE`, not a critical error, which is good. The immediate concern is whether it can lead to memory corruption or a system crash. It looks like it won't. If the buffer isn't uptodate, `mark_buffer_dirty` still flags it as dirty, and sets the page dirty which results in a subsequent write attempt. If the I/O error is transient, things might work on the subsequent write. If it's persistent, it just fails again.
Now, if a buffer isn't uptodate, does this imply the page itself isn't uptodate? `end_buffer_async_write` *does* clear the uptodate flag on the buffer in case of a write error! This looks familiar. After a write failure, `clear_buffer_uptodate(bh)` is indeed called. I should also check if any other functions clear the buffer uptodate, I see that read errors in `end_buffer_async_read` can clear it. But here it's a write error.
The bug report mentions a capacity change on the `loop0` device, and the "udf_update_inode: IO error syncing udf inode" message. Right, a capacity change, or backing file truncation, is almost certainly the root cause of the I/O errors, as writes now fail. When `udf_bitmap_new_block` is called, it modifies a cached bitmap block and calls `mark_buffer_dirty(bh)`. Since the previous write of this bitmap block failed, its uptodate flag would have been cleared. That's what's triggering the warning.
Is this exploitable? Not directly. It's just a warning. Can it be triggered by an unprivileged user? If they can mount a UDF filesystem, which *might* be possible via user namespaces and loop devices, or yank out a USB drive while writing to it, yes. Can an unprivileged user even change the capacity of a loop device? Yes, if they have access to the loop device and the backing file, they can truncate the backing file and trigger I/O errors.
This isn't just a UDF-specific issue; any filesystem that caches buffer heads and calls `mark_buffer_dirty` without checking `buffer_uptodate` or `buffer_write_io_error` could hit this. Ext4, for instance, might do this when modifying bitmap blocks, though JBD2 might handle things differently. In UDF, it directly calls `mark_buffer_dirty(bh)`.
Let's look at the security implications. It's not exploitable. No DoS unless `panic_on_warn` is set, but that's unlikely. Syzkaller might flag it as a bug. In production, it's just a warning. Access from unprivileged processes is possible if they can mount UDF or cause I/O errors with loop devices or USB drives. A malicious filesystem isn't even necessary; just a UDF filesystem on a failing device. The peripheral trigger is also there (unplugging a USB drive).
Let's check if the contents of a buffer are invalid. If the buffer was read successfully, it *was* uptodate. Then, it was modified, marked dirty, and writeback started. A failed write calls `clear_buffer_uptodate(bh)`. The data in `bh->b_data` is still the *intended* data, not garbage. From the filesystem's perspective, the memory content is still valid. So, when the filesystem modifies it again and calls `mark_buffer_dirty`, it's safe to try writing again. This warning in `mark_buffer_dirty` was put in place to catch cases where a buffer is marked dirty *before* it was read from disk. But in this case, a write error lost the uptodate flag. This is a known issue regarding `mark_buffer_dirty` and write errors. There are discussions on LKML about this. "fs: buffer: WARNING in mark_buffer_dirty" triggered by failing block devices!
Now, let me see if there's a fix for this in the kernel tree...
|
| 19/2 |
2026/05/25 06:12 |
tool |
git-log |
0m
Args: map[MessageRegexps:[mark_buffer_dirty uptodate]]
Results: map[Output:ca76bb226bf4 nilfs2: do not force clear folio if buffer is referenced
2f3d93e210b9 ext4: fix race in buffer_head read fault injection
2026559a6c4c nilfs2: fix null-ptr-deref in block_dirty_buffer tracepoint
cb3de5fc876e ext4: fix a potential assertion failure due to improperly dirtied buffer
cdaac8e7e5a0 nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse
28a65b49eb53 nilfs2: do not write dirty data after degenerating to read-only
558d6450c775 ext4: fix WARN_ON_ONCE(!buffer_uptodate) after an error writing the superblock
e86807862e68 ext4: avoid kernel warning when writing the superblock to a dead device
853a0c25baf9 udf: Mark LVID buffer as uptodate before marking it dirty
2074abfeb8ea ext2: clear uptodate flag on super block I/O error
]
|
| 20/2 |
2026/05/25 06:12 |
llm |
expert |
0m
Model:
Tokens:
input: 29669
output: 27
thoughts: 43
Thoughts: Okay, let's dive into commit `558d6450c775 ext4: fix WARN_ON_ONCE(!buffer_uptodate) after an error writing the superblock`. I need to understand what's going on here, especially since it concerns a core filesystem component and a pretty nasty bug - a `WARN_ON_ONCE`. That tells me something is seriously awry. The `ext4` filesystem is critical, and any corruption to the superblock could spell disaster for data integrity. The fact it's related to an error during *writing* the superblock immediately flags potential disk I/O issues or underlying driver problems as likely contributors. I'll need to see the exact context of the `WARN_ON_ONCE` call to understand the error condition and the specific code path that is failing. I need to figure out what `buffer_uptodate` represents in this context. Is it a flag indicating a successful write, or some form of synchronization state? The "fix" is the critical piece now. Does the fix address the underlying issue, or just mask it? Is it a true resolution or a workaround? I need to analyze the code change to ascertain whether it addresses the root cause of the problem. Was it a race condition, a memory issue, or a subtle logic error? I'll probably be able to tell by looking at which buffers and locks are involved. I want to see how this fix interacts with error handling mechanisms. Are they improved, or just bypassed in specific circumstances? Also, any side effects? Any performance hits? Let's get to the code!
|
| 21/2 |
2026/05/25 06:12 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 558d6450c7755aa005d89021204b6cdcae5e848f
Author: Ye Bin <yebin10@huawei.com>
Date: Tue Jun 15 17:05:37 2021 +0800
ext4: fix WARN_ON_ONCE(!buffer_uptodate) after an error writing the superblock
If a writeback of the superblock fails with an I/O error, the buffer
is marked not uptodate. However, this can cause a WARN_ON to trigger
when we attempt to write superblock a second time. (Which might
succeed this time, for cerrtain types of block devices such as iSCSI
devices over a flaky network.)
Try to detect this case in flush_stashed_error_work(), and also change
__ext4_handle_dirty_metadata() so we always set the uptodate flag, not
just in the nojournal case.
Before this commit, this problem can be repliciated via:
1. dmsetup create dust1 --table '0 2097152 dust /dev/sdc 0 4096'
2. mount /dev/mapper/dust1 /home/test
3. dmsetup message dust1 0 addbadblock 0 10
4. cd /home/test
5. echo "XXXXXXX" > t
After a few seconds, we got following warning:
[ 80.654487] end_buffer_async_write: bh=0xffff88842f18bdd0
[ 80.656134] Buffer I/O error on dev dm-0, logical block 0, lost async page write
[ 85.774450] EXT4-fs error (device dm-0): ext4_check_bdev_write_error:193: comm kworker/u16:8: Error while async write back metadata
[ 91.415513] mark_buffer_dirty: bh=0xffff88842f18bdd0
[ 91.417038] ------------[ cut here ]------------
[ 91.418450] WARNING: CPU: 1 PID: 1944 at fs/buffer.c:1092 mark_buffer_dirty.cold+0x1c/0x5e
[ 91.440322] Call Trace:
[ 91.440652] __jbd2_journal_temp_unlink_buffer+0x135/0x220
[ 91.441354] __jbd2_journal_unfile_buffer+0x24/0x90
[ 91.441981] __jbd2_journal_refile_buffer+0x134/0x1d0
[ 91.442628] jbd2_journal_commit_transaction+0x249a/0x3240
[ 91.443336] ? put_prev_entity+0x2a/0x200
[ 91.443856] ? kjournald2+0x12e/0x510
[ 91.444324] kjournald2+0x12e/0x510
[ 91.444773] ? woken_wake_function+0x30/0x30
[ 91.445326] kthread+0x150/0x1b0
[ 91.445739] ? commit_timeout+0x20/0x20
[ 91.446258] ? kthread_flush_worker+0xb0/0xb0
[ 91.446818] ret_from_fork+0x1f/0x30
[ 91.447293] ---[ end trace 66f0b6bf3d1abade ]---
Signed-off-by: Ye Bin <yebin10@huawei.com>
Link: https://lore.kernel.org/r/20210615090537.3423231-1-yebin10@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index be799040a415..b96ecba91899 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -327,6 +327,7 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
set_buffer_meta(bh);
set_buffer_prio(bh);
+ set_buffer_uptodate(bh);
if (ext4_handle_valid(handle)) {
err = jbd2_journal_dirty_metadata(handle, bh);
/* Errors can only happen due to aborted journal or a nasty bug */
@@ -355,7 +356,6 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
err);
}
} else {
- set_buffer_uptodate(bh);
if (inode)
mark_buffer_dirty_inode(bh, inode);
else
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 20344633bdd9..cdbe71d935e8 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -705,15 +705,23 @@ static void flush_stashed_error_work(struct work_struct *work)
* ext4 error handling code during handling of previous errors.
*/
if (!sb_rdonly(sbi->s_sb) && journal) {
+ struct buffer_head *sbh = sbi->s_sbh;
handle = jbd2_journal_start(journal, 1);
if (IS_ERR(handle))
goto write_directly;
- if (jbd2_journal_get_write_access(handle, sbi->s_sbh)) {
+ if (jbd2_journal_get_write_access(handle, sbh)) {
jbd2_journal_stop(handle);
goto write_directly;
}
ext4_update_super(sbi->s_sb);
- if (jbd2_journal_dirty_metadata(handle, sbi->s_sbh)) {
+ if (buffer_write_io_error(sbh) || !buffer_uptodate(sbh)) {
+ ext4_msg(sbi->s_sb, KERN_ERR, "previous I/O error to "
+ "superblock detected");
+ clear_buffer_write_io_error(sbh);
+ set_buffer_uptodate(sbh);
+ }
+
+ if (jbd2_journal_dirty_metadata(handle, sbh)) {
jbd2_journal_stop(handle);
goto write_directly;
}
]
|
| 22/2 |
2026/05/25 06:12 |
llm |
expert |
0m
Model:
Tokens:
input: 32031
output: 21
thoughts: 1249
Thoughts: **Harmless Warning in UDF Filesystem - A Deep Dive**
Okay, so I'm looking at this UDF issue and it seems pretty straightforward at first glance. It looks like a classic scenario where `ext4` has a fix for something that UDF missed. Specifically, it involves the order of operations concerning the `buffer_uptodate` flag and marking a buffer dirty. Ext4 explicitly calls `set_buffer_uptodate(bh)` *before* `mark_buffer_dirty(bh)`. UDF doesn't.
My initial thought was, "Security implications?". The commit message mentions a warning (`WARN_ON_ONCE(!buffer_uptodate(bh))`) but downplays it. It indicates that write errors can clear the `uptodate` flag, and marking it dirty afterward triggers the warning. This seems like a known issue, and not an exploitable vulnerability. It's just a warning. And, unless `panic_on_warn` is set (which is unlikely), it's not a denial of service either.
Let's dig deeper. The question is, can this lead to other issues? Could the buffer actually be outdated because it was never read? I checked the code path in `udf_bitmap_new_block`. The buffer (`bh`) comes from `load_block_bitmap`, which relies on `read_block_bitmap`, which uses `sb_bread`. If `sb_bread` fails, it returns `NULL`, and `read_block_bitmap` returns `-EIO`. So, the buffer *is* read at least once. The only way it is not `uptodate` is if there's a write failure. The memory content is valid.
I then looked for other instances where `buffer_uptodate` is cleared. There is an `end_buffer_async_read` function that can clear it if a read fails. However, `sb_bread` waits for the read to complete and checks `buffer_uptodate`; if it's not uptodate it returns `NULL`. Thus, the buffer (`bh`) is definitely `uptodate` when `sb_bread` returns.
So, it really does seem to be just a harmless warning.
Here's a breakdown of the security impact based on what I've found:
* **Exploitable:** No.
* **Denial of Service:** No (only a warning).
* **Accessible from unprivileged processes:** Yes, but only if they can mount UDF or trigger I/O errors.
* **Accessible from user namespaces:** Yes, if they can mount UDF.
* **VM Guest/Host Trigger:** No, not specific to virtual machines.
* **Ethernet Network Trigger:** No.
* **Other Remote Trigger:** No.
* **Peripheral Trigger:** Yes, like unplugging a USB drive.
* **Malicious Filesystem Trigger:** Yes, a malformed filesystem *could* trigger I/O errors by referencing invalid block numbers.
Wait, there's more in the bug report. There's a capacity change on `loop0` which caused an I/O error. This got me thinking. A malicious file system can probably trigger this *without* a failing device. If a UDF file system specifies a bitmap block beyond the device's end, `sb_bread` fails. Then `read_block_bitmap` will return `-EIO` and `load_block_bitmap` returns `-EIO`. `udf_bitmap_new_block` will recognize `bitmap_nr < 0` and go to `error_return`. So it won't reach `mark_buffer_dirty(bh)`. So, for `mark_buffer_dirty(bh)` to be reached, `sb_bread` *must* have succeeded, meaning the block *was* within the device's capacity *initially*.
Thus, it is likely that the device capacity got reduced after `sb_bread`, or the device was removed, or it's a loop device and the backing file was truncated.
Is it possible to make the issue happen without the device capacity changing?
* If the filesystem is mounted read-write, and the block device is read-only? No, `sb_bread` would succeed, but the write would fail. But you can't mount read-write on a read-only device.
* What if the block device has bad blocks? Yes, the write will fail.
* What if the filesystem is on a loop device and the backing file runs out of space? Yes, this would cause a write to fail.
So, an unprivileged user *could* trigger this by making a loop device, mounting it, and then causing writes to fail (e
|
| 23/2 |
2026/05/25 06:13 |
tool |
grepper |
0m
Args: map[Expression:FS_USERNS_MOUNT]
Results: map[Output:drivers/android/binder/rust_binderfs.c=753=static struct file_system_type binder_fs_type = {
--
drivers/android/binder/rust_binderfs.c-757- .kill_sb = binderfs_kill_super,
drivers/android/binder/rust_binderfs.c:758: .fs_flags = FS_USERNS_MOUNT,
drivers/android/binder/rust_binderfs.c-759-};
--
drivers/android/binderfs.c=749=static struct file_system_type binder_fs_type = {
--
drivers/android/binderfs.c-753- .kill_sb = binderfs_kill_super,
drivers/android/binderfs.c:754: .fs_flags = FS_USERNS_MOUNT,
drivers/android/binderfs.c-755-};
--
fs/binfmt_misc.c=1021=static struct file_system_type bm_fs_type = {
--
fs/binfmt_misc.c-1024- .init_fs_context = bm_init_fs_context,
fs/binfmt_misc.c:1025: .fs_flags = FS_USERNS_MOUNT,
fs/binfmt_misc.c-1026- .kill_sb = kill_anon_super,
--
fs/devpts/inode.c=453=static struct file_system_type devpts_fs_type = {
--
fs/devpts/inode.c-457- .kill_sb = devpts_kill_sb,
fs/devpts/inode.c:458: .fs_flags = FS_USERNS_MOUNT,
fs/devpts/inode.c-459-};
--
fs/fuse/inode.c=2157=static struct file_system_type fuse_fs_type = {
--
fs/fuse/inode.c-2159- .name = "fuse",
fs/fuse/inode.c:2160: .fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT | FS_ALLOW_IDMAP,
fs/fuse/inode.c-2161- .init_fs_context = fuse_init_fs_context,
--
fs/overlayfs/params.c=782=static const struct fs_context_operations ovl_context_ops = {
--
fs/overlayfs/params.c-791- * This is called during fsopen() and will record the user namespace of
fs/overlayfs/params.c:792: * the caller in fc->user_ns since we've raised FS_USERNS_MOUNT. We'll
fs/overlayfs/params.c-793- * need it when we actually create the superblock to verify that the
--
fs/overlayfs/super.c=1571=struct file_system_type ovl_fs_type = {
--
fs/overlayfs/super.c-1575- .parameters = ovl_parameter_spec,
fs/overlayfs/super.c:1576: .fs_flags = FS_USERNS_MOUNT,
fs/overlayfs/super.c-1577- .kill_sb = kill_anon_super,
--
fs/proc/root.c=357=static struct file_system_type proc_fs_type = {
--
fs/proc/root.c-361- .kill_sb = proc_kill_sb,
fs/proc/root.c:362: .fs_flags = FS_USERNS_MOUNT | FS_DISALLOW_NOTIFY_PERM,
fs/proc/root.c-363-};
--
fs/ramfs/inode.c=317=static struct file_system_type ramfs_fs_type = {
--
fs/ramfs/inode.c-321- .kill_sb = ramfs_kill_sb,
fs/ramfs/inode.c:322: .fs_flags = FS_USERNS_MOUNT,
fs/ramfs/inode.c-323-};
--
fs/super.c=694=bool mount_capable(struct fs_context *fc)
fs/super.c-695-{
fs/super.c:696: if (!(fc->fs_type->fs_flags & FS_USERNS_MOUNT))
fs/super.c-697- return capable(CAP_SYS_ADMIN);
--
fs/super.c=734=struct super_block *sget_fc(struct fs_context *fc,
--
fs/super.c-743- /*
fs/super.c:744: * Never allow s_user_ns != &init_user_ns when FS_USERNS_MOUNT is
fs/super.c-745- * not set, as the filesystem is likely unprepared to handle it.
--
fs/super.c-748- */
fs/super.c:749: if (user_ns != &init_user_ns && !(fc->fs_type->fs_flags & FS_USERNS_MOUNT)) {
fs/super.c-750- errorfc(fc, "VFS: Mounting from non-initial user namespace is not allowed");
--
fs/sysfs/mount.c=92=static struct file_system_type sysfs_fs_type = {
--
fs/sysfs/mount.c-95- .kill_sb = sysfs_kill_sb,
fs/sysfs/mount.c:96: .fs_flags = FS_USERNS_MOUNT,
fs/sysfs/mount.c-97-};
--
include/linux/fs.h=2272=struct file_system_type {
--
include/linux/fs.h-2277-#define FS_HAS_SUBTYPE 4
include/linux/fs.h:2278:#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */
include/linux/fs.h-2279-#define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events */
--
ipc/mqueue.c=1613=static struct file_system_type mqueue_fs_type = {
--
ipc/mqueue.c-1616- .kill_sb = kill_anon_super,
ipc/mqueue.c:1617: .fs_flags = FS_USERNS_MOUNT,
ipc/mqueue.c-1618-};
--
kernel/bpf/inode.c=1074=static struct file_system_type bpf_fs_type = {
--
kernel/bpf/inode.c-1079- .kill_sb = bpf_kill_super,
kernel/bpf/inode.c:1080: .fs_flags = FS_USERNS_MOUNT,
kernel/bpf/inode.c-1081-};
--
kernel/cgroup/cgroup.c=2354=struct file_system_type cgroup_fs_type = {
--
kernel/cgroup/cgroup.c-2358- .kill_sb = cgroup_kill_sb,
kernel/cgroup/cgroup.c:2359: .fs_flags = FS_USERNS_MOUNT,
kernel/cgroup/cgroup.c-2360-};
--
kernel/cgroup/cgroup.c=2362=static struct file_system_type cgroup2_fs_type = {
--
kernel/cgroup/cgroup.c-2366- .kill_sb = cgroup_kill_sb,
kernel/cgroup/cgroup.c:2367: .fs_flags = FS_USERNS_MOUNT,
kernel/cgroup/cgroup.c-2368-};
--
kernel/cgroup/cgroup.c=2435=static struct file_system_type cpuset_fs_type = {
--
kernel/cgroup/cgroup.c-2438- .parameters = cpuset_fs_parameters,
kernel/cgroup/cgroup.c:2439: .fs_flags = FS_USERNS_MOUNT,
kernel/cgroup/cgroup.c-2440-};
--
mm/shmem.c=5349=static struct file_system_type shmem_fs_type = {
--
mm/shmem.c-5356- .kill_sb = kill_anon_super,
mm/shmem.c:5357: .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME,
mm/shmem.c-5358-};
--
mm/shmem.c=5758=static struct file_system_type shmem_fs_type = {
--
mm/shmem.c-5762- .kill_sb = ramfs_kill_sb,
mm/shmem.c:5763: .fs_flags = FS_USERNS_MOUNT,
mm/shmem.c-5764-};
]
|
| 24/2 |
2026/05/25 06:13 |
llm |
expert |
0m
Model:
Tokens:
input: 36643
output: 41
thoughts: 879
Thoughts: **Analyzing the UDF Filesystem Vulnerability**
Okay, so I'm looking at this UDF filesystem issue and how it might be exploited. My initial thought is that since UDF doesn't have `FS_USERNS_MOUNT`, an unprivileged user can't mount a UDF filesystem, even in a user namespace. That seems like a good starting point, meaning they can't directly trigger the bug. Unless they could somehow cause a mounted UDF filesystem to write to a failing device...but they can't mount it, so that's a dead end.
Could root mount it, and then an unprivileged user cause the problem? If root mounts a UDF filesystem on a loop device, and then an unprivileged user can truncate the backing file, leading to a loop device failure, that might work. However, unprivileged users typically can't make a loop device fail, unless they have direct access to and can truncate the backing file. If root mounts from a file owned by an unprivileged user, the user *could* truncate the file, but root shouldn't be doing that. So again, that path is unlikely for exploitation from unprivileged processes or user namespaces.
Then it hits me: Peripheral Trigger! If a user plugs in a USB drive with a UDF filesystem, the desktop environment (running as root or using udisks) might auto-mount it. Now we're talking! The user can write to the filesystem and then yank the USB drive out. This will definitely cause I/O errors. The filesystem might then try to write again, perhaps if there are queued writes, or if the drive is pulled out mid-write, and another write occurs before unmount. Wait, but if the USB drive is yanked, the block device is removed... can the filesystem still try to write? Yes, because the filesystem is still mounted until unmounted.
If a process then writes to a file on the UDF filesystem, it allocates blocks, modifying the bitmap, which calls `mark_buffer_dirty(bh)`. Since the device is gone, previous writes likely failed, clearing the `uptodate` flag. Bingo! That warning *can* be triggered by yanking a USB drive.
But is this a security issue? It's just a warning, which isn't a system crash. So it's not a Denial of Service, and definitely not exploitable for malicious activity. I need to be certain there's no other path for exploitation.
Let's double-check how `mark_buffer_dirty` and buffer handling work. If `buffer_uptodate(bh)` is false, `mark_buffer_dirty` warns and sets the buffer dirty. The writeback thread will then try to write, fail again because the device is gone. No memory corruption. The buffer isn't freed while in `bitmap->s_block_bitmap`, it's only freed on unmount. No use-after-free either.
Alright, another path to consider: what if `load_block_bitmap` returns a buffer that was never read successfully? If `read_block_bitmap` fails, it returns a negative error code. So `load_block_bitmap` also returns `< 0`. But `udf_bitmap_new_block` handles the error and doesn't use the `bh` (buffer header). So that's safe.
What if `read_block_bitmap` succeeds, but the buffer isn't uptodate? `sb_bread` returns `NULL` (or some other error) if the buffer isn't uptodate. I should double check `sb_bread` to be sure. That would have to be an error to be safe.
|
| 25/2 |
2026/05/25 06:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/linux/buffer_head.h IncludeLines:true Name:sb_bread]
Results: map[SourceCode: 343: static inline struct buffer_head *
344: sb_bread(struct super_block *sb, sector_t block)
345: {
346: return __bread_gfp(sb->s_bdev, block, sb->s_blocksize, __GFP_MOVABLE);
347: }
SourceFile:include/linux/buffer_head.h]
|
| 26/2 |
2026/05/25 06:13 |
llm |
expert |
0m
Model:
Tokens:
input: 38470
output: 39
thoughts: 11
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Initial Checkpoint: Examining `__bread_gfp`**
Alright, let's dive in. My initial thought is focused on examining `__bread_gfp`. Given my experience, I'm already anticipating what that name likely represents. I immediately assume it's related to GFP (Green Fluorescent Protein) and possibly a method or function related to the handling of it, bread likely being related to its expression product. With the double underscore, I'd bet it's an internal or private function. I'll need to remember to look for other related items. Perhaps the associated public API? I will likely start by checking its implementation.
|
| 27/2 |
2026/05/25 06:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/buffer.c IncludeLines:true Name:__bread_gfp]
Results: map[SourceCode:1377: /**
1378: * __bread_gfp() - Read a block.
1379: * @bdev: The block device to read from.
1380: * @block: Block number in units of block size.
1381: * @size: The block size of this device in bytes.
1382: * @gfp: Not page allocation flags; see below.
1383: *
1384: * You are not expected to call this function. You should use one of
1385: * sb_bread(), sb_bread_unmovable() or __bread().
1386: *
1387: * Read a specified block, and return the buffer head that refers to it.
1388: * If @gfp is 0, the memory will be allocated using the block device's
1389: * default GFP flags. If @gfp is __GFP_MOVABLE, the memory may be
1390: * allocated from a movable area. Do not pass in a complete set of
1391: * GFP flags.
1392: *
1393: * The returned buffer head has its refcount increased. The caller should
1394: * call brelse() when it has finished with the buffer.
1395: *
1396: * Context: May sleep waiting for I/O.
1397: * Return: NULL if the block was unreadable.
1398: */
1399: struct buffer_head *__bread_gfp(struct block_device *bdev, sector_t block,
1400: unsigned size, gfp_t gfp)
1401: {
1402: struct buffer_head *bh;
1403:
1404: gfp |= mapping_gfp_constraint(bdev->bd_mapping, ~__GFP_FS);
1405:
1406: /*
1407: * Prefer looping in the allocator rather than here, at least that
1408: * code knows what it's doing.
1409: */
1410: gfp |= __GFP_NOFAIL;
1411:
1412: bh = bdev_getblk(bdev, block, size, gfp);
1413:
1414: if (likely(bh) && !buffer_uptodate(bh))
1415: bh = __bread_slow(bh);
1416: return bh;
1417: }
SourceFile:fs/buffer.c]
|
| 28/2 |
2026/05/25 06:13 |
llm |
expert |
0m
Model:
Tokens:
input: 39371
output: 38
thoughts: 10
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Initial Check: Bread Speed**
Alright, the directive is straightforward. Let's delve right into the function `__bread_slow`. Given my experience, I'm already mentally running through potential areas of concern based on that naming convention. "Slow" usually implies some form of optimization opportunity. I'm expecting this function to be involved in a time-sensitive process, likely related to data processing, calculation, or network communication. It's a flag that immediately triggers my mental checklist: I'll be looking for algorithmic inefficiencies, unnecessary I/O operations, potential bottlenecks from thread synchronization, or inefficient data structures used in the context of `__bread`.
I need to quickly assess what `__bread_slow` actually *does*. Is this a critical path operation? Does it impact other areas of the system if slow? I'll probably start by looking at its call graph and dependent components. My primary concerns are that it might be creating latency in the larger process, which I need to optimize, or perhaps be creating bottlenecks. My first step is to quickly analyze the source code for what it does!
|
| 29/2 |
2026/05/25 06:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/buffer.c IncludeLines:true Name:__bread_slow]
Results: map[SourceCode:1160: static struct buffer_head *__bread_slow(struct buffer_head *bh)
1161: {
1162: lock_buffer(bh);
1163: if (buffer_uptodate(bh)) {
1164: unlock_buffer(bh);
1165: return bh;
1166: } else {
1167: get_bh(bh);
1168: bh->b_end_io = end_buffer_read_sync;
1169: submit_bh(REQ_OP_READ, bh);
1170: wait_on_buffer(bh);
1171: if (buffer_uptodate(bh))
1172: return bh;
1173: }
1174: brelse(bh);
1175: return NULL;
1176: }
SourceFile:fs/buffer.c]
|
| 30/2 |
2026/05/25 06:13 |
llm |
expert |
0m
Model:
Tokens:
input: 39934
output: 21
thoughts: 122
Thoughts: **Analyzing Buffer Validity in the Kernel**
Okay, so looking at this `__bread_slow` function, it's clear that it returns `NULL` immediately if the buffer isn't up-to-date after the read. That means `sb_bread` *always* returns a buffer that's current, or it returns `NULL`. This implies that `bh` is, without a doubt, up-to-date when it's first read. That part is straightforward.
Now, the only possible scenario for `bh` *not* being up-to-date later would be if a write happened and *that* write failed, which makes perfect sense. This just reinforces what I initially thought.
However, I need to be absolutely certain I haven't missed a corner case. Now I'm going to methodically track down all the code locations that can potentially clear `buffer_uptodate`, just to confirm there are no surprises. Gotta be thorough.
|
| 31/2 |
2026/05/25 06:13 |
tool |
grepper |
0m
Args: map[Expression:clear_buffer_uptodate]
Results: map[Output:fs/buffer.c=143=static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate)
--
fs/buffer.c-148- /* This happens, due to failed read-ahead attempts. */
fs/buffer.c:149: clear_buffer_uptodate(bh);
fs/buffer.c-150- }
--
fs/buffer.c=165=void end_buffer_write_sync(struct buffer_head *bh, int uptodate)
--
fs/buffer.c-171- mark_buffer_write_io_error(bh);
fs/buffer.c:172: clear_buffer_uptodate(bh);
fs/buffer.c-173- }
--
fs/buffer.c=256=static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
--
fs/buffer.c-269- } else {
fs/buffer.c:270: clear_buffer_uptodate(bh);
fs/buffer.c-271- buffer_io_error(bh, ", async page read");
--
fs/buffer.c=383=static void end_buffer_async_write(struct buffer_head *bh, int uptodate)
--
fs/buffer.c-397- mark_buffer_write_io_error(bh);
fs/buffer.c:398: clear_buffer_uptodate(bh);
fs/buffer.c-399- }
--
fs/buffer.c=2277=EXPORT_SYMBOL(block_is_partially_uptodate);
--
fs/buffer.c-2282- * Reads the folio asynchronously --- the unlock_buffer() and
fs/buffer.c:2283: * set/clear_buffer_uptodate() functions propagate buffer state into the
fs/buffer.c-2284- * folio once IO has completed.
--
fs/ext4/fast_commit.c=187=static void ext4_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
--
fs/ext4/fast_commit.c-196- __func__, bh->b_blocknr);
fs/ext4/fast_commit.c:197: clear_buffer_uptodate(bh);
fs/ext4/fast_commit.c-198- }
--
fs/ext4/inode.c=1170=int ext4_block_write_begin(handle_t *handle, struct folio *folio,
--
fs/ext4/inode.c-1271- if (err2) {
fs/ext4/inode.c:1272: clear_buffer_uptodate(wait[i]);
fs/ext4/inode.c-1273- err = err2;
--
fs/ext4/inode.c=4030=static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)
--
fs/ext4/inode.c-4089- if (err) {
fs/ext4/inode.c:4090: clear_buffer_uptodate(bh);
fs/ext4/inode.c-4091- goto unlock;
--
fs/ext4/mmp.c=72=static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
--
fs/ext4/mmp.c-78- if (*bh)
fs/ext4/mmp.c:79: clear_buffer_uptodate(*bh);
fs/ext4/mmp.c-80-
--
fs/ext4/super.c=163=static inline void __ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
--
fs/ext4/super.c-166- if (simu_fail) {
fs/ext4/super.c:167: clear_buffer_uptodate(bh);
fs/ext4/super.c-168- unlock_buffer(bh);
--
fs/gfs2/log.c=1021=void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
--
fs/gfs2/log.c-1057- clear_buffer_dirty(bh);
fs/gfs2/log.c:1058: clear_buffer_uptodate(bh);
fs/gfs2/log.c-1059-}
--
fs/jbd2/commit.c=32=static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
--
fs/jbd2/commit.c-39- else
fs/jbd2/commit.c:40: clear_buffer_uptodate(bh);
fs/jbd2/commit.c-41- if (orig_bh) {
--
fs/nilfs2/btree.c=471=static int __nilfs_btree_get_block(const struct nilfs_bmap *btree, __u64 ptr,
--
fs/nilfs2/btree.c-531- if (nilfs_btree_broken_node_block(bh)) {
fs/nilfs2/btree.c:532: clear_buffer_uptodate(bh);
fs/nilfs2/btree.c-533- brelse(bh);
--
fs/nilfs2/gcinode.c=133=int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *bh)
--
fs/nilfs2/gcinode.c-148- if (buffer_nilfs_node(bh) && nilfs_btree_broken_node_block(bh)) {
fs/nilfs2/gcinode.c:149: clear_buffer_uptodate(bh);
fs/nilfs2/gcinode.c-150- return -EIO;
--
fs/nilfs2/segment.c=1816=static void nilfs_abort_logs(struct list_head *logs, int err)
--
fs/nilfs2/segment.c-1827- b_assoc_buffers) {
fs/nilfs2/segment.c:1828: clear_buffer_uptodate(bh);
fs/nilfs2/segment.c-1829- if (bh->b_folio != bd_folio) {
--
fs/nilfs2/segment.c-1838- if (bh == segbuf->sb_super_root) {
fs/nilfs2/segment.c:1839: clear_buffer_uptodate(bh);
fs/nilfs2/segment.c-1840- if (bh->b_folio != bd_folio) {
--
fs/ocfs2/aops.c=129=int ocfs2_get_block(struct inode *inode, sector_t iblock,
--
fs/ocfs2/aops.c-174- clear_buffer_dirty(bh_result);
fs/ocfs2/aops.c:175: clear_buffer_uptodate(bh_result);
fs/ocfs2/aops.c-176- goto bail;
--
fs/ocfs2/buffer_head_io.c=89=int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
--
fs/ocfs2/buffer_head_io.c-167- } else if (bh && buffer_uptodate(bh)) {
fs/ocfs2/buffer_head_io.c:168: clear_buffer_uptodate(bh);
fs/ocfs2/buffer_head_io.c-169- }
--
fs/ocfs2/buffer_head_io.c=193=int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
--
fs/ocfs2/buffer_head_io.c-353- } else if (bh && buffer_uptodate(bh)) {
fs/ocfs2/buffer_head_io.c:354: clear_buffer_uptodate(bh);
fs/ocfs2/buffer_head_io.c-355- }
--
fs/ocfs2/super.c=1694=static int ocfs2_get_sector(struct super_block *sb,
--
fs/ocfs2/super.c-1710- if (!buffer_dirty(*bh))
fs/ocfs2/super.c:1711: clear_buffer_uptodate(*bh);
fs/ocfs2/super.c-1712- unlock_buffer(*bh);
--
include/linux/buffer_head.h=140=static __always_inline void set_buffer_uptodate(struct buffer_head *bh)
--
include/linux/buffer_head.h-160-
include/linux/buffer_head.h:161:static __always_inline void clear_buffer_uptodate(struct buffer_head *bh)
include/linux/buffer_head.h-162-{
]
|
| 32/2 |
2026/05/25 06:13 |
llm |
expert |
0m
Model:
Tokens:
input: 42634
output: 66
thoughts: 964
Thoughts: **Analysis of the Buffer Dirty Flag Warning**
Okay, so I've been looking into this `buffer_uptodate` issue, and it all boils down to how we handle writes and errors. I confirmed that both `end_buffer_async_write` and `end_buffer_write_sync` correctly clear the `buffer_uptodate` flag when a write fails. This is precisely what I anticipated. The warning message surfaces because the buffer was written, the write unfortunately failed, and then the system attempts to mark it dirty again. This is a recognized issue and, thankfully, just a warning. There's no inherent security risk here.
Here’s the breakdown: The core problem is a `WARN_ON_ONCE(!buffer_uptodate(bh))` within the `mark_buffer_dirty()` function. This occurs when a buffer is marked dirty, but its `uptodate` flag is unexpectedly clear. The block layer is the culprit, clearing this flag if an asynchronous write fails, such as via `end_buffer_async_write()`.
In this specific scenario, a `loop0` block device's capacity was changed, causing I/O errors. The UDF filesystem had a cached bitmap block, which was initially read successfully and therefore marked `uptodate`. The filesystem modified and attempted to write the bitmap. The write failed due to the capacity change, so the block layer correctly cleared the `uptodate` flag. Later, the filesystem, operating on the same cached bitmap block, modified it again, calling `mark_buffer_dirty(bh)`. Because the `uptodate` flag had been cleared due to the prior write failure, the warning is triggered.
The important point is that the memory content of the buffer *remains* valid, containing the filesystem's modifications. There's no memory corruption, use-after-free, or out-of-bounds access. The warning doesn't halt the system unless `panic_on_warn` is set, which isn't the standard.
Therefore, this bug is not exploitable and doesn't cause a denial of service.
The conditions needed to trigger this vulnerability are a bit involved:
* It can be triggered by an unprivileged user only if they could mount a UDF filesystem and induce I/O errors on the underlying device (e.g., by truncating the backing file of a loop device). However, unprivileged users can't mount UDF filesystems, because it doesn't support `FS_USERNS_MOUNT`.
* A malicious filesystem image is also a potential source if the image specifies block numbers beyond the end of the device, but in such cases, `sb_bread` would fail, and it would not reach `mark_buffer_dirty`. It requires that the device actually fail or change capacity *after* the block is read.
* The most plausible trigger seems to be through a peripheral device, such as a USB drive, if the user unplugs the drive while the filesystem is writing.
I've been double checking this, and a malicious filesystem alone *cannot* trigger this without device failure or removal. If a malicious filesystem has a file sharing blocks with the bitmap and the user writes to the file, and the write fails for some reason? No, writes to the block device fail if the block is out of bounds, but `sb_bread` would also fail if it's out of bounds. What if the block is within bounds, but the write fails due to some quota or something? Block device writes don't fail due to quota. What if the malicious filesystem has a corrupted bitmap that causes the filesystem to write to a block that is read-only? Block devices are either entirely read-only or read-write. If it's read-only, `mark_buffer_dirty` won't even try to write, or the write will fail, but you can't mount a read-only device read-write. The `uptodate` flag is only cleared on I/O error.
So, I'm setting the results to:
* Exploitable: False
* DenialOfService: False
* Unprivileged: False
* UserNamespace: False
* VMGuestTrigger: False
* VMHostTrigger: False
* NetworkTrigger: False
* RemoteTrigger: False
* PeripheralTrigger: True
* FilesystemTrigger: False
|
| 33/2 |
2026/05/25 06:13 |
tool |
set-results |
0m
Args: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 34/2 |
2026/05/25 06:13 |
llm |
expert |
0m
Model:
Tokens:
input: 44669
output: 705
thoughts: 243
Thoughts: **My Analysis of the `WARN_ON_ONCE` in `mark_buffer_dirty()`**
Okay, the results are in. Time to synthesize this into a clear and concise response. I've got a handle on the core issue: the `WARN_ON_ONCE(!buffer_uptodate(bh))` in `mark_buffer_dirty()` is being triggered. Specifically, a write error clears the `uptodate` flag of a buffer head. Later, when the filesystem, UDF in this case, modifies that *same* buffer and then tries to mark it as dirty again, the warning pops up. This is, as I suspected, due to a known, if somewhat unfortunate, behavior within the block layer and how `mark_buffer_dirty()` functions.
I can immediately see this isn't a critical vulnerability. The good news is that there's no evidence of memory corruption or any immediate security implications. It's really more of a potential data integrity concern and a nuisance warning, than something that could lead to an exploit or privilege escalation. This is a crucial distinction to make. This also isn't a denial of service attack vector.
The trigger conditions are reasonably well-defined: something that causes an I/O error on a UDF-mounted device, like the classic example of abruptly unplugging a USB drive while data is being written to it. This suggests that other similar scenarios, such as capacity changes on loop devices or other sudden changes to block devices could have similar problems. The saving grace is that unprivileged users can't mount UDF filesystems directly, so we're not dealing with an easy-to-exploit local privilege escalation. This limits the threat model considerably.
In conclusion, I'll structure the response by clarifying the root cause, dismissing security implications, and explaining the potential triggers. It's a bug, sure, but it's not the end of the world.
|
| 35/1 |
2026/05/25 06:14 |
action |
format-explanation |
0m
Results: map[Explanation:**Root Cause Analysis**
The bug report indicates a `WARN_ON_ONCE(!buffer_uptodate(bh))` being triggered
in `mark_buffer_dirty()`. The call trace shows this happens in the UDF
filesystem when allocating a new block (`udf_bitmap_new_block`).
This warning is triggered due to the following sequence of events:
1. The UDF filesystem reads a bitmap block from the disk. The read succeeds, and
the buffer head (`bh`) is marked as uptodate and cached in memory.
2. The filesystem modifies the bitmap block and marks it dirty. The block layer
attempts to write the buffer to the disk asynchronously.
3. An I/O error occurs during the writeback. In the syzkaller report, this is
caused by the underlying loop device changing its capacity (`loop0: detected
capacity change from 0 to 256`), which makes subsequent writes fail.
4. When an asynchronous write fails, the block layer's completion handler
(`end_buffer_async_write()`) clears the `uptodate` flag of the buffer head to
indicate the I/O failure.
5. Later, the filesystem attempts to allocate another block, modifies the same
cached bitmap buffer, and calls `mark_buffer_dirty(bh)`.
6. `mark_buffer_dirty()` checks if the buffer is uptodate. Since the flag was
cleared by the previous failed write, it triggers the `WARN_ON_ONCE`.
**Security Impact**
* **Exploitable:** No. The memory content of the buffer (`bh->b_data`) remains
perfectly valid and contains the filesystem's modifications. There is no memory
corruption, use-after-free, or out-of-bounds access. The warning is merely a
sanity check that complains about dirtying a buffer that previously failed to
write.
* **Denial of Service:** No. The bug only triggers a non-fatal `WARN_ON_ONCE`.
It does not halt the kernel, cause deadlocks, or leak resources. In production
kernels (where `panic_on_warn` is disabled), this will only result in a single
warning in the kernel log.
* **Unprivileged / User Namespace:** No. Triggering this requires mounting a UDF
filesystem. The UDF filesystem does not have the `FS_USERNS_MOUNT` flag, meaning
it cannot be mounted by unprivileged users, even within a user namespace.
* **Peripheral Trigger:** Yes. This can be triggered by a user plugging in a USB
drive formatted with UDF, waiting for it to be auto-mounted by the desktop
environment, initiating a write operation, and physically yanking the USB drive
out before the write completes. The sudden removal of the device will cause I/O
errors, clearing the `uptodate` flag and triggering the warning on subsequent
allocation attempts.
* **Malicious Filesystem Trigger:** No. A malicious filesystem image alone
cannot trigger this. The block must be successfully read first, and then a write
must fail. This strictly requires a failing block device or a device that is
removed/resized at runtime.
**Conclusion**
This is a harmless warning caused by a known interaction between the block
layer's error handling and `mark_buffer_dirty()`. It has no security
implications and cannot be exploited for privilege escalation or denial of
service.]
|