Skip to content

Commit 0176e69

Browse files
kovalev0kleikamp
authored andcommitted
jfs: add check read-only before txBeginAnon() call
Added a read-only check before calling `txBeginAnon` in `extAlloc` and `extRecord`. This prevents modification attempts on a read-only mounted filesystem, avoiding potential errors or crashes. Call trace: txBeginAnon+0xac/0x154 extAlloc+0xe8/0xdec fs/jfs/jfs_extent.c:78 jfs_get_block+0x340/0xb98 fs/jfs/inode.c:248 __block_write_begin_int+0x580/0x166c fs/buffer.c:2128 __block_write_begin fs/buffer.c:2177 [inline] block_write_begin+0x98/0x11c fs/buffer.c:2236 jfs_write_begin+0x44/0x88 fs/jfs/inode.c:299 Fixes: 1da177e ("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 8c3f9a7 commit 0176e69

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fs/jfs/jfs_extent.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr)
7474
int rc;
7575
int xflag;
7676

77+
if (isReadOnly(ip)) {
78+
jfs_error(ip->i_sb, "read-only filesystem\n");
79+
return -EIO;
80+
}
81+
7782
/* This blocks if we are low on resources */
7883
txBeginAnon(ip->i_sb);
7984

@@ -253,6 +258,11 @@ int extRecord(struct inode *ip, xad_t * xp)
253258
{
254259
int rc;
255260

261+
if (isReadOnly(ip)) {
262+
jfs_error(ip->i_sb, "read-only filesystem\n");
263+
return -EIO;
264+
}
265+
256266
txBeginAnon(ip->i_sb);
257267

258268
mutex_lock(&JFS_IP(ip)->commit_mutex);

0 commit comments

Comments
 (0)