diff --git a/fs/squashfs/symlink.c b/fs/squashfs/symlink.c index 6ef735bd841a..7cffc1059c42 100644 --- a/fs/squashfs/symlink.c +++ b/fs/squashfs/symlink.c @@ -49,6 +49,11 @@ static int squashfs_symlink_read_folio(struct file *file, struct folio *folio) /* * Skip index bytes into symlink metadata. */ + if (length < 0) { + error = -EINVAL; + goto out; + } + if (index) { bytes = squashfs_read_metadata(sb, NULL, &block, &offset, index);