reiserfs: continue checking leaf items after directories
PATCH 1/1 reiserfs: continue checking leaf items after directories
is_leaf() validates each item header in a leaf before the leaf is trusted by search_by_key(). The directory-item case currently returns the result of has_valid_deh_location() directly from inside that loop. If the first directory item is valid, the whole leaf is accepted and any later item headers are never checked.
A crafted leaf can put a valid directory item before a malformed later stat-data, direct, indirect, or directory item. search_by_key() can then select the unchecked item and consumers use ih_item_body() on attacker controlled ih_location/ih_item_len values.
Keep the directory-entry validation, but only fail the leaf when that validation fails. If it succeeds, continue the item-header loop so the remaining headers are checked.
--- fs/reiserfs/stree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/reiserfs/stree.c +2 -1
@@ -479,7 +479,8 @@ static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) ih);return 0 ; } -return has_valid_deh_location (bh, ih); +if (!has_valid_deh_location (bh, ih)) +return 0 ; } prev_location =ih_location (ih); }
Signature · 1 line
2.43.0