[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221020223616.7571-4-phillip@squashfs.org.uk>
Date: Thu, 20 Oct 2022 23:36:16 +0100
From: Phillip Lougher <phillip@...ashfs.org.uk>
To: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
Cc: hsinyi@...omium.org, regressions@...mhuis.info,
regressions@...ts.linux.dev, dimitri.ledkov@...onical.com,
michael.vogt@...onical.com, phillip.lougher@...il.com,
ogra@...ntu.com, olivier.tilloy@...onical.com,
Phillip Lougher <phillip@...ashfs.org.uk>,
stable@...r.kernel.org
Subject: [PATCH 3/3] squashfs: fix buffer release race condition in readahead code
Fix a buffer release race condition, where the error value was
used after release.
Fixes: b09a7a036d20 ("squashfs: support reading fragments in readahead call")
Cc: <stable@...r.kernel.org>
Signed-off-by: Phillip Lougher <phillip@...ashfs.org.uk>
---
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.35.1
Powered by blists - more mailing lists