]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
jfs: add check read-only before txBeginAnon() call
authorVasiliy Kovalev <kovalev@altlinux.org>
Tue, 24 Dec 2024 14:49:13 +0000 (17:49 +0300)
committerDave Kleikamp <dave.kleikamp@oracle.com>
Wed, 19 Feb 2025 21:28:49 +0000 (15:28 -0600)
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: 1da177e4c3f4 ("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>
fs/jfs/jfs_extent.c

index 63d21822d309be4f06acbb52af28b9cdfef4d173..46529bcc8297ea3507a983376b033cfbe1de1e49 100644 (file)
@@ -74,6 +74,11 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr)
        int rc;
        int xflag;
 
+       if (isReadOnly(ip)) {
+               jfs_error(ip->i_sb, "read-only filesystem\n");
+               return -EIO;
+       }
+
        /* This blocks if we are low on resources */
        txBeginAnon(ip->i_sb);
 
@@ -253,6 +258,11 @@ int extRecord(struct inode *ip, xad_t * xp)
 {
        int rc;
 
+       if (isReadOnly(ip)) {
+               jfs_error(ip->i_sb, "read-only filesystem\n");
+               return -EIO;
+       }
+
        txBeginAnon(ip->i_sb);
 
        mutex_lock(&JFS_IP(ip)->commit_mutex);