mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-12 04:47:56 +00:00
btrfs-progs: check/lowmem: Add checks for compressed extent without csum
There is one report of compressed extent happens in btrfs, but has no csum and then leads to possible decompress error screwing up kernel memory. Although it's a kernel bug, and won't cause problem until compressed data get corrupted, let's catch such problem in advance. This patch will catch any unexpected compressed extent with: 1) missing csum 2) nodatasum flag set in the inode item This is for lowmem mode. Reported-by: James Harvey <jamespharvey20@gmail.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
50b9312f3a
commit
cc7a35f642
@ -2082,6 +2082,25 @@ static int check_file_extent(struct btrfs_root *root, struct btrfs_path *path,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Extra check for compressed extents:
|
||||
* Btrfs doesn't allow NODATASUM and compressed extent co-exist, thus
|
||||
* all compressed extents should have a checksum.
|
||||
*/
|
||||
if (compressed && csum_found < search_len) {
|
||||
error(
|
||||
"root %llu EXTENT_DATA[%llu %llu] compressed extent must have csum, but only %llu bytes have, expect %llu",
|
||||
root->objectid, fkey.objectid, fkey.offset, csum_found,
|
||||
search_len);
|
||||
err |= CSUM_ITEM_MISSING;
|
||||
}
|
||||
if (compressed && nodatasum) {
|
||||
error(
|
||||
"root %llu EXTENT_DATA[%llu %llu] is compressed, but inode flag doesn't allow it",
|
||||
root->objectid, fkey.objectid, fkey.offset);
|
||||
err |= FILE_EXTENT_ERROR;
|
||||
}
|
||||
|
||||
/* Check EXTENT_DATA hole */
|
||||
if (!no_holes && *end != fkey.offset) {
|
||||
if (repair)
|
||||
|
Loading…
Reference in New Issue
Block a user