Re: [PATCH v2] btrfs: reject empty non-root tree blocks at read time

From: Qu Wenruo

Date: Thu Apr 09 2026 - 05:39:17 EST




在 2026/4/9 18:39, Qu Wenruo 写道:


在 2026/4/9 17:41, ZhengYuan Huang 写道:

[CAUSE]
The old btrfs_verify_level_key() path rejected tree blocks with
nritems == 0 whenever the parent check provided a first key.
Commit 947a629988f1 ("btrfs: move tree block parentness check into
validate_extent_buffer()") moved the parentness checks into the read-time
validation path, but it dropped that guard. This lets an empty non-root
tree block pass read-time validation even though slot 0 must exist if the
parent provides a first key.

Wait for a second, there is still the nritems == 0 check inside btrfs_verify_level_key().

It looks like there is a missing link.

Is the btrfs_buffer_uptodate() call inside read_block_for_search() not passing the correct check structure?

And if you can provide the fuzzed image for each of your fix/report, it will help a lot.

It will not only provide a reliable way to test, but also allows reviewer to verify if the root cause is correct.


Thanks,
Qu