]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
FS: JFS: Fix null-ptr-deref Read in txBegin
authorImmad Mir <mirimmad17@gmail.com>
Fri, 23 Jun 2023 13:44:01 +0000 (19:14 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Aug 2023 14:35:10 +0000 (16:35 +0200)
[ Upstream commit 47cfdc338d674d38f4b2f22b7612cc6a2763ba27 ]

 Syzkaller reported an issue where txBegin may be called
 on a superblock in a read-only mounted filesystem which leads
 to NULL pointer deref. This could be solved by checking if
 the filesystem is read-only before calling txBegin, and returning
 with appropiate error code.

Reported-By: syzbot+f1faa20eec55e0c8644c@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=be7e52c50c5182cc09a09ea6fc456446b2039de3
Signed-off-by: Immad Mir <mirimmad17@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/jfs/namei.c

index 56c3fcbfe80ed0b69156bcab2f981b4d322b0aba..6726dcddd6f8691d7680bac632e1baf778820052 100644 (file)
@@ -813,6 +813,11 @@ static int jfs_link(struct dentry *old_dentry,
        if (rc)
                goto out;
 
+       if (isReadOnly(ip)) {
+               jfs_error(ip->i_sb, "read-only filesystem\n");
+               return -EROFS;
+       }
+
        tid = txBegin(ip->i_sb, 0);
 
        mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT);