Skip to content

Commit a3bd7d6

Browse files
roxanan1996PlaidCat
authored andcommitted
squashfs: fix memory leak in squashfs_fill_super
jira VULN-79855 cve-bf CVE-2025-38415 commit-author Phillip Lougher <phillip@squashfs.org.uk> commit b64700d upstream-diff | Replaced errorf with ERROR due to missing 5a2be12 ("vfs: Convert squashfs to use the new mount API") and c6b8226 ("vfs: Introduce logging functions") its deps. If sb_min_blocksize returns 0, squashfs_fill_super exits without freeing allocated memory (sb->s_fs_info). Fix this by moving the call to sb_min_blocksize to before memory is allocated. Link: https://lkml.kernel.org/r/20250811223740.110392-1-phillip@squashfs.org.uk Fixes: 734aa85 ("Squashfs: check return result of sb_min_blocksize") Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk> Reported-by: Scott GUO <scottzhguo@tencent.com> Closes: https://lore.kernel.org/all/20250811061921.3807353-1-scott_gzh@163.com Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit b64700d) Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
1 parent 92f9e66 commit a3bd7d6

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

fs/squashfs/super.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,23 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
8484
unsigned short flags;
8585
unsigned int fragments;
8686
u64 lookup_table_start, xattr_id_table_start, next_table;
87-
int err;
87+
int err, devblksize = sb_min_blocksize(sb, SQUASHFS_DEVBLK_SIZE);
8888

8989
TRACE("Entered squashfs_fill_superblock\n");
9090

91+
if (!devblksize) {
92+
ERROR("squashfs: unable to set blocksize\n");
93+
return -EINVAL;
94+
}
95+
9196
sb->s_fs_info = kzalloc(sizeof(*msblk), GFP_KERNEL);
9297
if (sb->s_fs_info == NULL) {
9398
ERROR("Failed to allocate squashfs_sb_info\n");
9499
return -ENOMEM;
95100
}
96101
msblk = sb->s_fs_info;
97102

98-
msblk->devblksize = sb_min_blocksize(sb, SQUASHFS_DEVBLK_SIZE);
99-
if (!msblk->devblksize) {
100-
ERROR("squashfs: unable to set blocksize\n");
101-
return -EINVAL;
102-
}
103-
103+
msblk->devblksize = devblksize;
104104
msblk->devblksize_log2 = ffz(~msblk->devblksize);
105105

106106
mutex_init(&msblk->read_data_mutex);

0 commit comments

Comments
 (0)