This is a note to let you know that I've just added the patch titled squashfs: fix buffer release race condition in readahead code to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: squashfs-fix-buffer-release-race-condition-in-readahead-code.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From e11c4e088be4c39d17f304fcf331670891905f42 Mon Sep 17 00:00:00 2001 From: Phillip Lougher <phillip@xxxxxxxxxxxxxxx> Date: Thu, 20 Oct 2022 23:36:16 +0100 Subject: squashfs: fix buffer release race condition in readahead code From: Phillip Lougher <phillip@xxxxxxxxxxxxxxx> commit e11c4e088be4c39d17f304fcf331670891905f42 upstream. Fix a buffer release race condition, where the error value was used after release. Link: https://lkml.kernel.org/r/20221020223616.7571-4-phillip@xxxxxxxxxxxxxxx Fixes: b09a7a036d20 ("squashfs: support reading fragments in readahead call") Signed-off-by: Phillip Lougher <phillip@xxxxxxxxxxxxxxx> Tested-by: Bagas Sanjaya <bagasdotme@xxxxxxxxx> Reported-by: Marc Miltenberger <marcmiltenberger@xxxxxxxxx> Cc: Dimitri John Ledkov <dimitri.ledkov@xxxxxxxxxxxxx> Cc: Hsin-Yi Wang <hsinyi@xxxxxxxxxxxx> Cc: Mirsad Goran Todorovac <mirsad.todorovac@xxxxxxxxxxxx> Cc: Slade Watkins <srw@xxxxxxxxxxxxxxxx> Cc: Thorsten Leemhuis <regressions@xxxxxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/squashfs/file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index f0afd4d6fd30..8ba8c4c50770 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -506,8 +506,9 @@ static int squashfs_readahead_fragment(struct page **page, squashfs_i(inode)->fragment_size); struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; unsigned int n, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1; + int error = buffer->error; - if (buffer->error) + if (error) goto out; expected += squashfs_i(inode)->fragment_offset; @@ -529,7 +530,7 @@ static int squashfs_readahead_fragment(struct page **page, out: squashfs_cache_put(buffer); - return buffer->error; + return error; } static void squashfs_readahead(struct readahead_control *ractl) -- 2.38.1 Patches currently in stable-queue which might be from phillip@xxxxxxxxxxxxxxx are queue-6.0/squashfs-fix-extending-readahead-beyond-end-of-file.patch queue-6.0/squashfs-fix-read-regression-introduced-in-readahead-code.patch queue-6.0/squashfs-fix-buffer-release-race-condition-in-readahead-code.patch