Skip to content

Commit 7703818

Browse files
kovalev0gregkh
authored andcommitted
jfs: add check read-only before truncation in jfs_truncate_nolock()
[ Upstream commit b5799dd ] Added a check for "read-only" mode in the `jfs_truncate_nolock` function to avoid errors related to writing to a read-only filesystem. Call stack: block_write_begin() { jfs_write_failed() { jfs_truncate() { jfs_truncate_nolock() { txEnd() { ... log = JFS_SBI(tblk->sb)->log; // (log == NULL) If the `isReadOnly(ip)` condition is triggered in `jfs_truncate_nolock`, the function execution will stop, and no further data modification will occur. Instead, the `xtTruncate` function will be called with the "COMMIT_WMAP" flag, preventing modifications in "read-only" mode. Fixes: 1da177e ("Linux-2.6.12-rc2") Reported-by: syzbot+4e89b5368baba8324e07@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=4e89b5368baba8324e07 Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org> Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e593031 commit 7703818

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/jfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
375375

376376
ASSERT(length >= 0);
377377

378-
if (test_cflag(COMMIT_Nolink, ip)) {
378+
if (test_cflag(COMMIT_Nolink, ip) || isReadOnly(ip)) {
379379
xtTruncate(0, ip, length, COMMIT_WMAP);
380380
return;
381381
}

0 commit comments

Comments
 (0)