[PATCH 0/4] ocfs2: consolidate extent list validation into block read callbacks

Joseph Qi posted 4 patches 2 months, 1 week ago
fs/ocfs2/alloc.c | 35 +++++++++++++++++++++-------------
fs/ocfs2/dir.c   | 49 +++++++++++++++++++++++++++---------------------
2 files changed, 50 insertions(+), 34 deletions(-)
[PATCH 0/4] ocfs2: consolidate extent list validation into block read callbacks
Posted by Joseph Qi 2 months, 1 week ago
ocfs2 validates extent list fields (l_count, l_next_free_rec) at various
points during extent tree traversal. This is fragile because each caller
must remember to check for corrupted on-disk data before using it.

This series moves those checks into the block read validation callbacks
(ocfs2_validate_dx_root and ocfs2_validate_extent_block), so corrupted
fields are caught early at block read time. Redundant post-read checks
are then removed.

Patch 1-2 handle the dx_root extent list:
  - Move l_count and l_next_free_rec validation into
    ocfs2_validate_dx_root(), skipping inline dx roots.
  - Remove the now-redundant l_next_free_rec == 0 check in
    ocfs2_dx_dir_lookup_rec() and rework the error message to avoid a
    potential NULL pointer dereference of rec.

Patch 3-4 handle extent blocks:
  - Add l_count and l_next_free_rec validation to
    ocfs2_validate_extent_block().
  - Remove the duplicate l_next_free_rec > l_count check in
    __ocfs2_find_path().

Joseph Qi (4):
  ocfs2: validate dx_root extent list fields during block read
  ocfs2: remove empty extent list check in ocfs2_dx_dir_lookup_rec()
  ocfs2: validate extent block list fields during block read
  ocfs2: remove redundant l_next_free_rec check in __ocfs2_find_path()

 fs/ocfs2/alloc.c | 35 +++++++++++++++++++++-------------
 fs/ocfs2/dir.c   | 49 +++++++++++++++++++++++++++---------------------
 2 files changed, 50 insertions(+), 34 deletions(-)

-- 
2.39.3
Re: [PATCH 0/4] ocfs2: consolidate extent list validation into block read callbacks
Posted by Andrew Morton 2 months, 1 week ago
On Fri,  3 Apr 2026 17:07:59 +0800 Joseph Qi <joseph.qi@linux.alibaba.com> wrote:

> ocfs2 validates extent list fields (l_count, l_next_free_rec) at various
> points during extent tree traversal. This is fragile because each caller
> must remember to check for corrupted on-disk data before using it.
> 
> This series moves those checks into the block read validation callbacks
> (ocfs2_validate_dx_root and ocfs2_validate_extent_block), so corrupted
> fields are caught early at block read time. Redundant post-read checks
> are then removed.

AI review asked a few questions - mainly suggesting additional changes.
https://sashiko.dev/#/patchset/20260403090803.3860971-1-joseph.qi@linux.alibaba.com
Re: [PATCH 0/4] ocfs2: consolidate extent list validation into block read callbacks
Posted by Joseph Qi 2 months, 1 week ago

On 4/4/26 3:27 AM, Andrew Morton wrote:
> On Fri,  3 Apr 2026 17:07:59 +0800 Joseph Qi <joseph.qi@linux.alibaba.com> wrote:
> 
>> ocfs2 validates extent list fields (l_count, l_next_free_rec) at various
>> points during extent tree traversal. This is fragile because each caller
>> must remember to check for corrupted on-disk data before using it.
>>
>> This series moves those checks into the block read validation callbacks
>> (ocfs2_validate_dx_root and ocfs2_validate_extent_block), so corrupted
>> fields are caught early at block read time. Redundant post-read checks
>> are then removed.
> 
> AI review asked a few questions - mainly suggesting additional changes.
> https://sashiko.dev/#/patchset/20260403090803.3860971-1-joseph.qi@linux.alibaba.com

Yes, not regressions, actually some improvements.

Thanks,
Joseph