Skip to content

Commit b5799dd

Browse files
kovalev0kleikamp
authored andcommitted
jfs: add check read-only before truncation in jfs_truncate_nolock()
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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: [email protected] Link: https://syzkaller.appspot.com/bug?extid=4e89b5368baba8324e07 Signed-off-by: Vasiliy Kovalev <[email protected]> Signed-off-by: Dave Kleikamp <[email protected]>
1 parent 0176e69 commit b5799dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/jfs/inode.c

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

370370
ASSERT(length >= 0);
371371

372-
if (test_cflag(COMMIT_Nolink, ip)) {
372+
if (test_cflag(COMMIT_Nolink, ip) || isReadOnly(ip)) {
373373
xtTruncate(0, ip, length, COMMIT_WMAP);
374374
return;
375375
}

0 commit comments

Comments
 (0)