summaryrefslogtreecommitdiffstats
path: root/fs/squashfs/block.c
diff options
context:
space:
mode:
authorLizhi Xu <lizhi.xu@windriver.com>2023-11-16 04:13:52 +0100
committerAndrew Morton <akpm@linux-foundation.org>2023-12-07 01:12:45 +0100
commiteb66b8abae98f869c224f7c852b685ae02144564 (patch)
tree3c79c688b505832d86db2ec4a078aa209b2a9ace /fs/squashfs/block.c
parentmm/selftests: fix pagemap_ioctl memory map test (diff)
downloadlinux-eb66b8abae98f869c224f7c852b685ae02144564.tar.xz
linux-eb66b8abae98f869c224f7c852b685ae02144564.zip
squashfs: squashfs_read_data need to check if the length is 0
When the length passed in is 0, the pagemap_scan_test_walk() caller should bail. This error causes at least a WARN_ON(). Link: https://lkml.kernel.org/r/20231116031352.40853-1-lizhi.xu@windriver.com Reported-by: syzbot+32d3767580a1ea339a81@syzkaller.appspotmail.com Closes: https://lkml.kernel.org/r/0000000000000526f2060a30a085@google.com Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com> Reviewed-by: Phillip Lougher <phillip@squashfs.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs/squashfs/block.c')
-rw-r--r--fs/squashfs/block.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 581ce9519339..2dc730800f44 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -321,7 +321,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
TRACE("Block @ 0x%llx, %scompressed size %d\n", index - 2,
compressed ? "" : "un", length);
}
- if (length < 0 || length > output->length ||
+ if (length <= 0 || length > output->length ||
(index + length) > msblk->bytes_used) {
res = -EIO;
goto out;