| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/07/08 16:50 | flow | patch-triage |
0mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [
"ext4_alloc_file_blocks",
"ext4_zero_range",
"ext4_load_tail_bh",
"ext4_block_zero_eof",
"ext4_zero_partial_blocks"
],
"Reasoning": "The patch modifies the ext4 filesystem's block allocation and zeroing logic, specifically handling partial block zeroing and unwritten extents during fallocate operations (like zero range and punch hole). These are functional changes to core filesystem logic that can be reached via system calls (e.g., fallocate, truncate) and should be fuzzed.",
"WorthFuzzing": true
} |
| 1/1 | 2026/07/08 16:50 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 2f6180f427ae88d859c01cbb10f911dfa570eb9c\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Wed Jul 8 16:50:01 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h\nindex 94283a991e5c4f..b2e55876d0e352 100644\n--- a/fs/ext4/ext4.h\n+++ b/fs/ext4/ext4.h\n@@ -3099,8 +3099,11 @@ extern int ext4_chunk_trans_extent(struct inode *inode, int nrblocks);\n extern int ext4_meta_trans_blocks(struct inode *inode, int lblocks,\n \t\t\t\t int pextents);\n extern int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end);\n+\n+#define EXT4_PARTIAL_ZERO_START\t0x1\n+#define EXT4_PARTIAL_ZERO_END\t0x2\n extern int ext4_zero_partial_blocks(struct inode *inode, loff_t lstart,\n-\t\t\t\t loff_t length, bool *did_zero);\n+\t\t\t\t loff_t length, unsigned int *partial_zeroed);\n extern vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf);\n extern qsize_t *ext4_get_reserved_space(struct inode *inode);\n extern int ext4_get_projid(struct inode *inode, kprojid_t *projid);\ndiff --git a/fs/ext4/extents.c b/fs/ext4/extents.c\nindex 125f628e738ab1..9a1b06c8dd9797 100644\n--- a/fs/ext4/extents.c\n+++ b/fs/ext4/extents.c\n@@ -4585,6 +4585,7 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,\n \tloff_t epos = 0, old_size = i_size_read(inode);\n \tunsigned int blkbits = inode-\u003ei_blkbits;\n \tbool alloc_zero = false;\n+\tbool orphan = false;\n \n \tBUG_ON(!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS));\n \tmap.m_lblk = offset \u003e\u003e blkbits;\n@@ -4659,12 +4660,35 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,\n \n \t\tif (alloc_zero \u0026\u0026\n \t\t (map.m_flags \u0026 (EXT4_MAP_MAPPED | EXT4_MAP_UNWRITTEN))) {\n+\t\t\tWARN_ON_ONCE(map.m_lblk + map.m_len \u003e\n+\t\t\t\tEXT4_B_TO_LBLK(inode, new_size ?: old_size));\n+\n \t\t\tret = ext4_issue_zeroout(inode, map.m_lblk, map.m_pblk,\n \t\t\t\t\t\t map.m_len);\n-\t\t\tif (likely(!ret))\n-\t\t\t\tret = ext4_convert_unwritten_extents(NULL,\n+\t\t\tif (unlikely(ret))\n+\t\t\t\tbreak;\n+\n+\t\t\thandle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,\n+\t\t\t\t\t\t credits);\n+\t\t\tif (IS_ERR(handle)) {\n+\t\t\t\tret = PTR_ERR(handle);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tif (new_size) {\n+\t\t\t\tret = ext4_orphan_add(handle, inode);\n+\t\t\t\torphan = true;\n+\t\t\t\tif (ret) {\n+\t\t\t\t\text4_journal_stop(handle);\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tret = ext4_convert_unwritten_extents(handle,\n \t\t\t\t\tinode, (loff_t)map.m_lblk \u003c\u003c blkbits,\n \t\t\t\t\t(loff_t)map.m_len \u003c\u003c blkbits);\n+\t\t\tret2 = ext4_journal_stop(handle);\n+\t\t\tret = ret ? ret : ret2;\n \t\t\tif (ret)\n \t\t\t\tbreak;\n \t\t}\n@@ -4678,7 +4702,7 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,\n \t\tgoto retry;\n \n \tif (!epos || !new_size)\n-\t\treturn ret;\n+\t\tgoto out;\n \n \t/*\n \t * Allocate blocks, update the file size to match the size of the\n@@ -4687,12 +4711,16 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,\n \tif (epos \u003e new_size)\n \t\tepos = new_size;\n \n-\thandle = ext4_journal_start(inode, EXT4_HT_MISC, 1);\n-\tif (IS_ERR(handle))\n-\t\treturn ret ? ret : PTR_ERR(handle);\n+\thandle = ext4_journal_start(inode, EXT4_HT_MISC, 2);\n+\tif (IS_ERR(handle)) {\n+\t\tret = ret ? ret : PTR_ERR(handle);\n+\t\tgoto out;\n+\t}\n \n \text4_update_inode_size(inode, epos);\n \tret2 = ext4_mark_inode_dirty(handle, inode);\n+\tif (orphan \u0026\u0026 inode-\u003ei_nlink)\n+\t\text4_orphan_del(handle, inode);\n \text4_update_inode_fsync_trans(handle, inode, 1);\n \tret3 = ext4_journal_stop(handle);\n \tret2 = ret3 ? ret3 : ret2;\n@@ -4701,6 +4729,11 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,\n \t\tpagecache_isize_extended(inode, old_size, epos);\n \n \treturn ret ? ret : ret2;\n+\n+out:\n+\tif (orphan \u0026\u0026 inode-\u003ei_nlink)\n+\t\text4_orphan_del(NULL, inode);\n+\treturn ret;\n }\n \n static int ext4_collapse_range(struct file *file, loff_t offset, loff_t len);\n@@ -4715,7 +4748,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,\n \tloff_t align_start, align_end, new_size = 0;\n \tloff_t end = offset + len;\n \tunsigned int blocksize = i_blocksize(inode);\n-\tbool partial_zeroed = false;\n+\tunsigned int partial_zeroed = 0;\n \tint ret, flags;\n \n \ttrace_ext4_zero_range(inode, offset, len, mode);\n@@ -4734,10 +4767,16 @@ static long ext4_zero_range(struct file *file, loff_t offset,\n \t}\n \n \tflags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;\n-\t/* Preallocate the range including the unaligned edges */\n+\t/*\n+\t * Preallocate the range including the unaligned edges, and zero\n+\t * out partial blocks if they already contain data.\n+\t */\n \tif (!IS_ALIGNED(offset | end, blocksize)) {\n \t\tret = ext4_alloc_file_blocks(file, offset, len, new_size,\n \t\t\t\t\t flags);\n+\t\tif (!ret)\n+\t\t\tret = ext4_zero_partial_blocks(inode, offset, len,\n+\t\t\t\t\t\t \u0026partial_zeroed);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n@@ -4754,6 +4793,21 @@ static long ext4_zero_range(struct file *file, loff_t offset,\n \t/* Zero range excluding the unaligned edges */\n \talign_start = round_up(offset, blocksize);\n \talign_end = round_down(end, blocksize);\n+\n+\t/*\n+\t * In WRITE_ZEROES mode, edges that were not partial-zeroed (clean\n+\t * unwritten or hole) must be allocated and zeroed as whole blocks.\n+\t * Expand the aligned range outward to cover them.\n+\t */\n+\tif (mode \u0026 FALLOC_FL_WRITE_ZEROES) {\n+\t\tif (!IS_ALIGNED(offset, blocksize) \u0026\u0026\n+\t\t !(partial_zeroed \u0026 EXT4_PARTIAL_ZERO_START))\n+\t\t\talign_start = round_down(offset, blocksize);\n+\t\tif (!IS_ALIGNED(end, blocksize) \u0026\u0026\n+\t\t !(partial_zeroed \u0026 EXT4_PARTIAL_ZERO_END))\n+\t\t\talign_end = round_up(end, blocksize);\n+\t}\n+\n \tif (align_end \u003e align_start) {\n \t\tif (mode \u0026 FALLOC_FL_WRITE_ZEROES)\n \t\t\tflags = EXT4_GET_BLOCKS_CREATE_ZERO | EXT4_EX_NOCACHE;\n@@ -4770,11 +4824,15 @@ static long ext4_zero_range(struct file *file, loff_t offset,\n \tif (IS_ALIGNED(offset | end, blocksize))\n \t\treturn ret;\n \n-\t/* Zero out partial block at the edges of the range */\n-\tret = ext4_zero_partial_blocks(inode, offset, len, \u0026partial_zeroed);\n-\tif (ret)\n-\t\treturn ret;\n-\tif (((file-\u003ef_flags \u0026 O_SYNC) || IS_SYNC(inode)) \u0026\u0026 partial_zeroed) {\n+\t/*\n+\t * In FALLOC_FL_WRITE_ZEROES mode, edges that have been partially\n+\t * zeroed must be written back to ensure the entire zeroed range\n+\t * is converted to the written state. In SYNC mode, writeback is\n+\t * also required to persist the zeroed data to disk.\n+\t */\n+\tif (partial_zeroed \u0026\u0026\n+\t ((mode \u0026 FALLOC_FL_WRITE_ZEROES) ||\n+\t (file-\u003ef_flags \u0026 O_SYNC) || IS_SYNC(inode))) {\n \t\tret = filemap_write_and_wait_range(inode-\u003ei_mapping, offset,\n \t\t\t\t\t\t end - 1);\n \t\tif (ret)\ndiff --git a/fs/ext4/inode.c b/fs/ext4/inode.c\nindex c2c2d6ac7f3d13..c0c921400aa4f3 100644\n--- a/fs/ext4/inode.c\n+++ b/fs/ext4/inode.c\n@@ -4026,6 +4026,10 @@ void ext4_set_aops(struct inode *inode)\n * because it might have data in pagecache (eg, if called from ext4_zero_range,\n * ext4_punch_hole, etc) which needs to be properly zeroed out. Otherwise a\n * racing writeback can come later and flush the stale pagecache to disk.\n+ *\n+ * Return the loaded bh if it actually needs zeroing - in written, dirty\n+ * unwritten, or delalloc state. Return NULL if it's clean (i.e., a hole or\n+ * a clean unwritten block).\n */\n static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)\n {\n@@ -4037,7 +4041,7 @@ static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)\n \tint err = 0;\n \n \tfolio = __filemap_get_folio(mapping, from \u003e\u003e PAGE_SHIFT,\n-\t\t\t\t FGP_LOCK | FGP_ACCESSED | FGP_CREAT,\n+\t\t\t\t FGP_WRITEBEGIN | FGP_ACCESSED,\n \t\t\t\t mapping_gfp_constraint(mapping, ~__GFP_FS));\n \tif (IS_ERR(folio))\n \t\treturn ERR_CAST(folio);\n@@ -4064,8 +4068,15 @@ static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)\n \t}\n \tif (!buffer_mapped(bh)) {\n \t\tBUFFER_TRACE(bh, \"unmapped\");\n-\t\text4_get_block(inode, iblock, bh, 0);\n-\t\t/* unmapped? It's a hole - nothing to do */\n+\t\terr = ext4_get_block(inode, iblock, bh, 0);\n+\t\tif (err \u003c 0)\n+\t\t\tgoto unlock;\n+\t\t/*\n+\t\t * It's a hole or a clean unwritten block - nothing to do.\n+\t\t * Note that a lookup-only get_block (without\n+\t\t * EXT4_GET_BLOCKS_CREATE) never sets BH_Mapped for clean\n+\t\t * unwritten extents.\n+\t\t */\n \t\tif (!buffer_mapped(bh)) {\n \t\t\tBUFFER_TRACE(bh, \"still unmapped\");\n \t\t\tgoto unlock;\n@@ -4218,6 +4229,9 @@ int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end)\n \toffset = from \u0026 (blocksize - 1);\n \tif (!offset || from \u003e= end)\n \t\treturn 0;\n+\t/* Inline data has no tail block to zero. */\n+\tif (ext4_has_inline_data(inode))\n+\t\treturn 0;\n \t/* If we are processing an encrypted inode during orphan list handling */\n \tif (IS_ENCRYPTED(inode) \u0026\u0026 !fscrypt_has_encryption_key(inode))\n \t\treturn 0;\n@@ -4252,13 +4266,26 @@ int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end)\n \treturn 0;\n }\n \n+/*\n+ * Zero out the unaligned head and tail of the [lstart, lstart+length)\n+ * range.\n+ *\n+ * On return, @partial_zeroed records which edges actually got\n+ * partial-zeroed. Set EXT4_PARTIAL_ZERO_START/EXT4_PARTIAL_ZERO_END if\n+ * the head/tail block got actually partially zeroed (in written, dirty\n+ * unwritten or delalloc state). Cleared if the head/tail block is a\n+ * hole or a clean unwritten block, in which case there is nothing that\n+ * needs zeroing. When the head and tail land in the same block, both\n+ * bits are set together on a successful zeroing.\n+ */\n int ext4_zero_partial_blocks(struct inode *inode, loff_t lstart, loff_t length,\n-\t\t\t bool *did_zero)\n+\t\t\t unsigned int *partial_zeroed)\n {\n \tstruct super_block *sb = inode-\u003ei_sb;\n \tunsigned partial_start, partial_end;\n \text4_fsblk_t start, end;\n \tloff_t byte_end = (lstart + length - 1);\n+\tbool did_zero = false;\n \tint err = 0;\n \n \tpartial_start = lstart \u0026 (sb-\u003es_blocksize - 1);\n@@ -4270,21 +4297,32 @@ int ext4_zero_partial_blocks(struct inode *inode, loff_t lstart, loff_t length,\n \t/* Handle partial zero within the single block */\n \tif (start == end \u0026\u0026\n \t (partial_start || (partial_end != sb-\u003es_blocksize - 1))) {\n-\t\terr = ext4_block_zero_range(inode, lstart, length, did_zero,\n+\t\terr = ext4_block_zero_range(inode, lstart, length, \u0026did_zero,\n \t\t\t\t\t NULL);\n+\t\tif (did_zero)\n+\t\t\t*partial_zeroed |= (EXT4_PARTIAL_ZERO_START |\n+\t\t\t\t\t EXT4_PARTIAL_ZERO_END);\n \t\treturn err;\n \t}\n \t/* Handle partial zero out on the start of the range */\n \tif (partial_start) {\n \t\terr = ext4_block_zero_range(inode, lstart, sb-\u003es_blocksize,\n-\t\t\t\t\t did_zero, NULL);\n+\t\t\t\t\t \u0026did_zero, NULL);\n \t\tif (err)\n \t\t\treturn err;\n+\t\tif (did_zero)\n+\t\t\t*partial_zeroed |= EXT4_PARTIAL_ZERO_START;\n \t}\n \t/* Handle partial zero out on the end of the range */\n-\tif (partial_end != sb-\u003es_blocksize - 1)\n+\tif (partial_end != sb-\u003es_blocksize - 1) {\n+\t\tdid_zero = false;\n \t\terr = ext4_block_zero_range(inode, byte_end - partial_end,\n-\t\t\t\t\t partial_end + 1, did_zero, NULL);\n+\t\t\t\t\t partial_end + 1, \u0026did_zero, NULL);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t\tif (did_zero)\n+\t\t\t*partial_zeroed |= EXT4_PARTIAL_ZERO_END;\n+\t}\n \treturn err;\n }\n \n@@ -4433,7 +4471,7 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)\n \tloff_t end = offset + length;\n \thandle_t *handle;\n \tunsigned int credits;\n-\tbool partial_zeroed = false;\n+\tunsigned int partial_zeroed = 0;\n \tint ret;\n \n \ttrace_ext4_punch_hole(inode, offset, length, 0);\n"
} |
| 2/1 | 2026/07/08 16:50 | agent | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [
"ext4_alloc_file_blocks",
"ext4_zero_range",
"ext4_load_tail_bh",
"ext4_block_zero_eof",
"ext4_zero_partial_blocks"
],
"Reasoning": "The patch modifies the ext4 filesystem's block allocation and zeroing logic, specifically handling partial block zeroing and unwritten extents during fallocate operations (like zero range and punch hole). These are functional changes to core filesystem logic that can be reached via system calls (e.g., fallocate, truncate) and should be fuzzed.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Do not list too generic configs (we already have them enabled). Only list those that specifically cover the modified code. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). 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: For your convenience, here is the diff of the changes:
commit 2f6180f427ae88d859c01cbb10f911dfa570eb9c
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Jul 8 16:50:01 2026 +0000
syz-cluster: applied patch under review
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 94283a991e5c4f..b2e55876d0e352 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3099,8 +3099,11 @@ extern int ext4_chunk_trans_extent(struct inode *inode, int nrblocks);
extern int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
int pextents);
extern int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end);
+
+#define EXT4_PARTIAL_ZERO_START 0x1
+#define EXT4_PARTIAL_ZERO_END 0x2
extern int ext4_zero_partial_blocks(struct inode *inode, loff_t lstart,
- loff_t length, bool *did_zero);
+ loff_t length, unsigned int *partial_zeroed);
extern vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf);
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
extern int ext4_get_projid(struct inode *inode, kprojid_t *projid);
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 125f628e738ab1..9a1b06c8dd9797 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4585,6 +4585,7 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,
loff_t epos = 0, old_size = i_size_read(inode);
unsigned int blkbits = inode->i_blkbits;
bool alloc_zero = false;
+ bool orphan = false;
BUG_ON(!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS));
map.m_lblk = offset >> blkbits;
@@ -4659,12 +4660,35 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,
if (alloc_zero &&
(map.m_flags & (EXT4_MAP_MAPPED | EXT4_MAP_UNWRITTEN))) {
+ WARN_ON_ONCE(map.m_lblk + map.m_len >
+ EXT4_B_TO_LBLK(inode, new_size ?: old_size));
+
ret = ext4_issue_zeroout(inode, map.m_lblk, map.m_pblk,
map.m_len);
- if (likely(!ret))
- ret = ext4_convert_unwritten_extents(NULL,
+ if (unlikely(ret))
+ break;
+
+ handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
+ credits);
+ if (IS_ERR(handle)) {
+ ret = PTR_ERR(handle);
+ break;
+ }
+
+ if (new_size) {
+ ret = ext4_orphan_add(handle, inode);
+ orphan = true;
+ if (ret) {
+ ext4_journal_stop(handle);
+ break;
+ }
+ }
+
+ ret = ext4_convert_unwritten_extents(handle,
inode, (loff_t)map.m_lblk << blkbits,
(loff_t)map.m_len << blkbits);
+ ret2 = ext4_journal_stop(handle);
+ ret = ret ? ret : ret2;
if (ret)
break;
}
@@ -4678,7 +4702,7 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,
goto retry;
if (!epos || !new_size)
- return ret;
+ goto out;
/*
* Allocate blocks, update the file size to match the size of the
@@ -4687,12 +4711,16 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,
if (epos > new_size)
epos = new_size;
- handle = ext4_journal_start(inode, EXT4_HT_MISC, 1);
- if (IS_ERR(handle))
- return ret ? ret : PTR_ERR(handle);
+ handle = ext4_journal_start(inode, EXT4_HT_MISC, 2);
+ if (IS_ERR(handle)) {
+ ret = ret ? ret : PTR_ERR(handle);
+ goto out;
+ }
ext4_update_inode_size(inode, epos);
ret2 = ext4_mark_inode_dirty(handle, inode);
+ if (orphan && inode->i_nlink)
+ ext4_orphan_del(handle, inode);
ext4_update_inode_fsync_trans(handle, inode, 1);
ret3 = ext4_journal_stop(handle);
ret2 = ret3 ? ret3 : ret2;
@@ -4701,6 +4729,11 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,
pagecache_isize_extended(inode, old_size, epos);
return ret ? ret : ret2;
+
+out:
+ if (orphan && inode->i_nlink)
+ ext4_orphan_del(NULL, inode);
+ return ret;
}
static int ext4_collapse_range(struct file *file, loff_t offset, loff_t len);
@@ -4715,7 +4748,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
loff_t align_start, align_end, new_size = 0;
loff_t end = offset + len;
unsigned int blocksize = i_blocksize(inode);
- bool partial_zeroed = false;
+ unsigned int partial_zeroed = 0;
int ret, flags;
trace_ext4_zero_range(inode, offset, len, mode);
@@ -4734,10 +4767,16 @@ static long ext4_zero_range(struct file *file, loff_t offset,
}
flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;
- /* Preallocate the range including the unaligned edges */
+ /*
+ * Preallocate the range including the unaligned edges, and zero
+ * out partial blocks if they already contain data.
+ */
if (!IS_ALIGNED(offset | end, blocksize)) {
ret = ext4_alloc_file_blocks(file, offset, len, new_size,
flags);
+ if (!ret)
+ ret = ext4_zero_partial_blocks(inode, offset, len,
+ &partial_zeroed);
if (ret)
return ret;
}
@@ -4754,6 +4793,21 @@ static long ext4_zero_range(struct file *file, loff_t offset,
/* Zero range excluding the unaligned edges */
align_start = round_up(offset, blocksize);
align_end = round_down(end, blocksize);
+
+ /*
+ * In WRITE_ZEROES mode, edges that were not partial-zeroed (clean
+ * unwritten or hole) must be allocated and zeroed as whole blocks.
+ * Expand the aligned range outward to cover them.
+ */
+ if (mode & FALLOC_FL_WRITE_ZEROES) {
+ if (!IS_ALIGNED(offset, blocksize) &&
+ !(partial_zeroed & EXT4_PARTIAL_ZERO_START))
+ align_start = round_down(offset, blocksize);
+ if (!IS_ALIGNED(end, blocksize) &&
+ !(partial_zeroed & EXT4_PARTIAL_ZERO_END))
+ align_end = round_up(end, blocksize);
+ }
+
if (align_end > align_start) {
if (mode & FALLOC_FL_WRITE_ZEROES)
flags = EXT4_GET_BLOCKS_CREATE_ZERO | EXT4_EX_NOCACHE;
@@ -4770,11 +4824,15 @@ static long ext4_zero_range(struct file *file, loff_t offset,
if (IS_ALIGNED(offset | end, blocksize))
return ret;
- /* Zero out partial block at the edges of the range */
- ret = ext4_zero_partial_blocks(inode, offset, len, &partial_zeroed);
- if (ret)
- return ret;
- if (((file->f_flags & O_SYNC) || IS_SYNC(inode)) && partial_zeroed) {
+ /*
+ * In FALLOC_FL_WRITE_ZEROES mode, edges that have been partially
+ * zeroed must be written back to ensure the entire zeroed range
+ * is converted to the written state. In SYNC mode, writeback is
+ * also required to persist the zeroed data to disk.
+ */
+ if (partial_zeroed &&
+ ((mode & FALLOC_FL_WRITE_ZEROES) ||
+ (file->f_flags & O_SYNC) || IS_SYNC(inode))) {
ret = filemap_write_and_wait_range(inode->i_mapping, offset,
end - 1);
if (ret)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c2c2d6ac7f3d13..c0c921400aa4f3 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4026,6 +4026,10 @@ void ext4_set_aops(struct inode *inode)
* because it might have data in pagecache (eg, if called from ext4_zero_range,
* ext4_punch_hole, etc) which needs to be properly zeroed out. Otherwise a
* racing writeback can come later and flush the stale pagecache to disk.
+ *
+ * Return the loaded bh if it actually needs zeroing - in written, dirty
+ * unwritten, or delalloc state. Return NULL if it's clean (i.e., a hole or
+ * a clean unwritten block).
*/
static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)
{
@@ -4037,7 +4041,7 @@ static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)
int err = 0;
folio = __filemap_get_folio(mapping, from >> PAGE_SHIFT,
- FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
+ FGP_WRITEBEGIN | FGP_ACCESSED,
mapping_gfp_constraint(mapping, ~__GFP_FS));
if (IS_ERR(folio))
return ERR_CAST(folio);
@@ -4064,8 +4068,15 @@ static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from)
}
if (!buffer_mapped(bh)) {
BUFFER_TRACE(bh, "unmapped");
- ext4_get_block(inode, iblock, bh, 0);
- /* unmapped? It's a hole - nothing to do */
+ err = ext4_get_block(inode, iblock, bh, 0);
+ if (err < 0)
+ goto unlock;
+ /*
+ * It's a hole or a clean unwritten block - nothing to do.
+ * Note that a lookup-only get_block (without
+ * EXT4_GET_BLOCKS_CREATE) never sets BH_Mapped for clean
+ * unwritten extents.
+ */
if (!buffer_mapped(bh)) {
BUFFER_TRACE(bh, "still unmapped");
goto unlock;
@@ -4218,6 +4229,9 @@ int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end)
offset = from & (blocksize - 1);
if (!offset || from >= end)
return 0;
+ /* Inline data has no tail block to zero. */
+ if (ext4_has_inline_data(inode))
+ return 0;
/* If we are processing an encrypted inode during orphan list handling */
if (IS_ENCRYPTED(inode) && !fscrypt_has_encryption_key(inode))
return 0;
@@ -4252,13 +4266,26 @@ int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end)
return 0;
}
+/*
+ * Zero out the unaligned head and tail of the [lstart, lstart+length)
+ * range.
+ *
+ * On return, @partial_zeroed records which edges actually got
+ * partial-zeroed. Set EXT4_PARTIAL_ZERO_START/EXT4_PARTIAL_ZERO_END if
+ * the head/tail block got actually partially zeroed (in written, dirty
+ * unwritten or delalloc state). Cleared if the head/tail block is a
+ * hole or a clean unwritten block, in which case there is nothing that
+ * needs zeroing. When the head and tail land in the same block, both
+ * bits are set together on a successful zeroing.
+ */
int ext4_zero_partial_blocks(struct inode *inode, loff_t lstart, loff_t length,
- bool *did_zero)
+ unsigned int *partial_zeroed)
{
struct super_block *sb = inode->i_sb;
unsigned partial_start, partial_end;
ext4_fsblk_t start, end;
loff_t byte_end = (lstart + length - 1);
+ bool did_zero = false;
int err = 0;
partial_start = lstart & (sb->s_blocksize - 1);
@@ -4270,21 +4297,32 @@ int ext4_zero_partial_blocks(struct inode *inode, loff_t lstart, loff_t length,
/* Handle partial zero within the single block */
if (start == end &&
(partial_start || (partial_end != sb->s_blocksize - 1))) {
- err = ext4_block_zero_range(inode, lstart, length, did_zero,
+ err = ext4_block_zero_range(inode, lstart, length, &did_zero,
NULL);
+ if (did_zero)
+ *partial_zeroed |= (EXT4_PARTIAL_ZERO_START |
+ EXT4_PARTIAL_ZERO_END);
return err;
}
/* Handle partial zero out on the start of the range */
if (partial_start) {
err = ext4_block_zero_range(inode, lstart, sb->s_blocksize,
- did_zero, NULL);
+ &did_zero, NULL);
if (err)
return err;
+ if (did_zero)
+ *partial_zeroed |= EXT4_PARTIAL_ZERO_START;
}
/* Handle partial zero out on the end of the range */
- if (partial_end != sb->s_blocksize - 1)
+ if (partial_end != sb->s_blocksize - 1) {
+ did_zero = false;
err = ext4_block_zero_range(inode, byte_end - partial_end,
- partial_end + 1, did_zero, NULL);
+ partial_end + 1, &did_zero, NULL);
+ if (err)
+ return err;
+ if (did_zero)
+ *partial_zeroed |= EXT4_PARTIAL_ZERO_END;
+ }
return err;
}
@@ -4433,7 +4471,7 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
loff_t end = offset + length;
handle_t *handle;
unsigned int credits;
- bool partial_zeroed = false;
+ unsigned int partial_zeroed = 0;
int ret;
trace_ext4_punch_hole(inode, offset, length, 0);
|
| 3/2 | 2026/07/08 16:50 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 6060 output: 31 thoughts: 563 Thoughts: **Analyzing the Ext4 Filesystem Patch for Fuzzing Opportunities** Okay, so I've got a patch here for the ext4 filesystem, and my initial thought is that this is a pretty significant functional change. It looks like it's touching core logic, so fuzzing is definitely on the radar. I see modifications to `fs/ext4/extents.c` and `fs/ext4/inode.c`, with `ext4_zero_partial_blocks` being the main function of interest initially, especially with the introduction of these new `EXT4_PARTIAL_ZERO_START` and `EXT4_PARTIAL_ZERO_END` flags. Diving deeper, it's modified quite a few functions that could be prime targets: `ext4_alloc_file_blocks`, which now has to handle orphans and zeroing; `ext4_zero_range` which has been updated to consider `FALLOC_FL_WRITE_ZEROES` and partial zeroing; and `ext4_load_tail_bh`, and `ext4_block_zero_eof`. Then there's the variable change in `ext4_punch_hole`, I should consider that function too. Now, the real question is, are these functions hot-path functions, or are they more obscure? `ext4_alloc_file_blocks` and `ext4_zero_range` are both static, located in `fs/ext4/extents.c`. `ext4_load_tail_bh`, `ext4_block_zero_eof`, `ext4_zero_partial_blocks`, and `ext4_punch_hole` are in `fs/ext4/inode.c`, so I'll need to research them individually. I need to make sure I'm not missing any config options that I need to be aware of. I know `CONFIG_EXT4_FS` is required, but that's a given. I'll need to check the surrounding code for any other `CONFIG_` flags that might be relevant. I'll fire up the grepper to scan `fs/ext4/extents.c` and `fs/ext4/inode.c` for any potential dependencies around these specific functions. |
| 4/2 | 2026/07/08 16:50 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_",
"PathPrefix": "fs/ext4/extents.c"
}Results: {
"Output": "fs/ext4/extents.c=6285=int ext4_ext_clear_bb(struct inode *inode)\n--\nfs/ext4/extents.c-6336-\nfs/ext4/extents.c:6337:#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)\nfs/ext4/extents.c-6338-int ext4_ext_space_root_idx_test(struct inode *inode, int check)\n"
} |
| 5/2 | 2026/07/08 16:50 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 7265 output: 30 thoughts: 17 Thoughts: Here's my thought process, as it stands: **Digging Deeper into the Ext4 Inode Handling** Okay, so we're dealing with a file system-related issue, and I'm pretty sure I've got a handle on the general area. But, I need to be *thorough*. To confirm my suspicions about how inodes might be involved, I'm going to take a closer look at the `fs/ext4/inode.c` file within the kernel source. It's the logical place to start – inode management is core to the Ext4 file system, and this file is where that logic is likely housed. I need to refresh my memory on the inode structure, the allocation/deallocation process, and any error handling related to it. Seeing it in code will either confirm my initial assessment or provide crucial new insights. It's time to dive into that file and see what secrets it holds. |
| 6/2 | 2026/07/08 16:50 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_",
"PathPrefix": "fs/ext4/inode.c"
}Results: {
"Output": "fs/ext4/inode.c=169=void ext4_evict_inode(struct inode *inode)\n--\nfs/ext4/inode.c-336-\nfs/ext4/inode.c:337:#ifdef CONFIG_QUOTA\nfs/ext4/inode.c-338-qsize_t *ext4_get_reserved_space(struct inode *inode)\n--\nfs/ext4/inode.c=412=int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk,\n--\nfs/ext4/inode.c-436- */\nfs/ext4/inode.c:437:#ifdef CONFIG_EXT4_DEBUG\nfs/ext4/inode.c-438-void ext4_check_map_extents_env(struct inode *inode)\n--\nfs/ext4/inode.c=5259=struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,\n--\nfs/ext4/inode.c-5432-\tei-\u003ei_disksize = inode-\u003ei_size;\nfs/ext4/inode.c:5433:#ifdef CONFIG_QUOTA\nfs/ext4/inode.c-5434-\tei-\u003ei_reserved_quota = 0;\n"
} |
| 7/2 | 2026/07/08 16:50 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 7851 output: 33 thoughts: 355 Thoughts: **Analyzing EXT4 Block Allocation and Zeroing Functions** Okay, so I'm looking into these EXT4 functions, and it seems the only config I really need to be concerned with right now is `EXT4_FS`. Straightforward. Now, let's break down the functions that are going to be most relevant here. I've got a list forming in my mind: * `ext4_alloc_file_blocks` * `ext4_zero_range` * `ext4_load_tail_bh` * `ext4_block_zero_eof` * `ext4_zero_partial_blocks` Right, let's trace the calls, and understand their place in the operation chain. `ext4_alloc_file_blocks` is critical because it's called by `ext4_zero_range` and `ext4_collapse_range`, and probably a few other key functions. Aha, and `ext4_zero_range` is called by `ext4_fallocate`, which is where things start to get interesting. `ext4_punch_hole` is also called by `ext4_fallocate`. This is all fallocate related, not the hot path read/write operations, so that's good to keep in mind. Then `ext4_load_tail_bh` is called from `ext4_block_zero_range`. `ext4_block_zero_eof` is triggered by `ext4_setattr` and `ext4_page_mkwrite`. And finally, `ext4_zero_partial_blocks` gets called from `ext4_zero_range` and `ext4_punch_hole`. So, bottom line, the functions to really focus on are: * `ext4_alloc_file_blocks` * `ext4_zero_range` * `ext4_load_tail_bh` * `ext4_block_zero_eof` * `ext4_zero_partial_blocks` Now, before I go deeper, I should probably double check whether `ext4_alloc_file_blocks` is static, because that makes a big difference in how I'd approach its analysis. |
| 8/2 | 2026/07/08 16:50 | tool | grepper |
0mArgs:{
"Expression": "ext4_alloc_file_blocks",
"PathPrefix": "fs/ext4/"
}Results: {
"Output": "fs/ext4/extents.c=4543=int ext4_ext_truncate(handle_t *handle, struct inode *inode)\n--\nfs/ext4/extents.c-4573-\nfs/ext4/extents.c:4574:static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,\nfs/ext4/extents.c-4575-\t\t\t\t loff_t new_size, int flags)\n--\nfs/ext4/extents.c=4743=static long ext4_zero_range(struct file *file, loff_t offset,\n--\nfs/ext4/extents.c-4774-\tif (!IS_ALIGNED(offset | end, blocksize)) {\nfs/ext4/extents.c:4775:\t\tret = ext4_alloc_file_blocks(file, offset, len, new_size,\nfs/ext4/extents.c-4776-\t\t\t\t\t flags);\n--\nfs/ext4/extents.c-4816-\t\t\t\t EXT4_EX_NOCACHE);\nfs/ext4/extents.c:4817:\t\tret = ext4_alloc_file_blocks(file, align_start,\nfs/ext4/extents.c-4818-\t\t\t\t\t align_end - align_start, new_size,\n--\nfs/ext4/extents.c=4864=static long ext4_do_fallocate(struct file *file, loff_t offset,\n--\nfs/ext4/extents.c-4888-\nfs/ext4/extents.c:4889:\tret = ext4_alloc_file_blocks(file, offset, len, new_size,\nfs/ext4/extents.c-4890-\t\t\t\t EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT);\n"
} |
| 9/2 | 2026/07/08 16:50 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 9216 output: 154 thoughts: 452 Thoughts: **My Analysis of the Ext4 Filesystem Patch for Fuzzing** Okay, so I've got this patch for the ext4 filesystem, and my task is to figure out the best way to fuzz it. Let's break this down. First, I need to list the key symbols. Alright, `ext4_alloc_file_blocks`, `ext4_zero_range`, and `ext4_load_tail_bh` are all static within the ext4 code, while `ext4_block_zero_eof` and `ext4_zero_partial_blocks` are exported, which is good to know. I'll definitely want to include all of these in my `FocusSymbols` list – I need to ensure the fuzzer targets these functions. Now, about configurations. The patch seems to be fundamentally altering the block allocation and zeroing routines, especially concerning partial block handling and unwritten extents, which are at the heart of how `fallocate` operations like zero range and punch hole work. These functions are exposed via system calls, so fuzzing them is definitely a good idea. However, the prompt advised not to list generic configs. `EXT4_FS` is always enabled, and is generic. I think I'll leave the `EnableConfigs` empty for this one. A quick sanity check on `ext4_zero_partial_blocks` and `ext4_block_zero_eof` to ensure they aren't in a hot path. They're called from `fallocate`, `truncate`, and `page_mkwrite`. While `page_mkwrite` can be called frequently, it's not as common as read/write operations. However, these calls are specific to the modified logic, so it is still a good idea to focus on them. Therefore, my final `FocusSymbols` list is: * `ext4_alloc_file_blocks` * `ext4_zero_range` * `ext4_load_tail_bh` * `ext4_block_zero_eof` * `ext4_zero_partial_blocks` I'm ready to move forward. |
| 10/2 | 2026/07/08 16:50 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [
"ext4_alloc_file_blocks",
"ext4_zero_range",
"ext4_load_tail_bh",
"ext4_block_zero_eof",
"ext4_zero_partial_blocks"
],
"Reasoning": "The patch modifies the ext4 filesystem's block allocation and zeroing logic, specifically handling partial block zeroing and unwritten extents during fallocate operations (like zero range and punch hole). These are functional changes to core filesystem logic that can be reached via system calls (e.g., fallocate, truncate) and should be fuzzed.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": null,
"FocusSymbols": [
"ext4_alloc_file_blocks",
"ext4_zero_range",
"ext4_load_tail_bh",
"ext4_block_zero_eof",
"ext4_zero_partial_blocks"
],
"Reasoning": "The patch modifies the ext4 filesystem's block allocation and zeroing logic, specifically handling partial block zeroing and unwritten extents during fallocate operations (like zero range and punch hole). These are functional changes to core filesystem logic that can be reached via system calls (e.g., fallocate, truncate) and should be fuzzed.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|