Skip to content

Commit 9f1c14c

Browse files
plougherakpm00
authored andcommitted
Squashfs: reject negative file sizes in squashfs_read_inode()
Syskaller reports a "WARNING in ovl_copy_up_file" in overlayfs. This warning is ultimately caused because the underlying Squashfs file system returns a file with a negative file size. This commit checks for a negative file size and returns EINVAL. [[email protected]: only need to check 64 bit quantity] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 6545b24 ("Squashfs: inode operations") Signed-off-by: Phillip Lougher <[email protected]> Reported-by: [email protected] Closes: https://lore.kernel.org/all/[email protected]/ Cc: Amir Goldstein <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 94b3f02 commit 9f1c14c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/squashfs/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ int squashfs_read_inode(struct inode *inode, long long ino)
197197
goto failed_read;
198198

199199
inode->i_size = le64_to_cpu(sqsh_ino->file_size);
200+
if (inode->i_size < 0) {
201+
err = -EINVAL;
202+
goto failed_read;
203+
}
200204
frag = le32_to_cpu(sqsh_ino->fragment);
201205
if (frag != SQUASHFS_INVALID_FRAG) {
202206
/*

0 commit comments

Comments
 (0)