Skip to content

Commit 2afdbd7

Browse files
committed
btrfs-progs: check/original: detect invalid file extent items for
symbolic links [BUG] There is a recent bug that btrfs/012 fails and kernel rejects to read a symbolic link which is backed by a regular extent. Furthremore in that case, "btrfs check" doesn't detect such problem at all. [CAUSE] For symbolic links, we only allow inline file extents, and this means we should only have a symbolic link target which is smaller than 4K. But btrfs check doesn't handle symbolic link inodes any differently, thus it doesn't check if the file extents are inlined or not, nor reporting this problem as an error. [FIX] When processing data extents, if we find the owning inode is a symbolic link, and the file extent is regular/preallocated, mark the inode with I_ERR_FILE_EXTENT_TOO_LARGE error. Signed-off-by: Qu Wenruo <[email protected]>
1 parent 184eddc commit 2afdbd7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

check/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,13 @@ static int process_file_extent(struct btrfs_root *root,
17451745
rec->errors |= I_ERR_BAD_FILE_EXTENT;
17461746
if (disk_bytenr > 0)
17471747
rec->found_size += num_bytes;
1748+
/*
1749+
* Symbolic links should only have inlined extents.
1750+
* A regular extent means it's already too large to
1751+
* be inlined.
1752+
*/
1753+
if (S_ISLNK(rec->imode))
1754+
rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE;
17481755
} else {
17491756
rec->errors |= I_ERR_BAD_FILE_EXTENT;
17501757
}

0 commit comments

Comments
 (0)