summaryrefslogtreecommitdiff
path: root/fs/jfs
diff options
context:
space:
mode:
authorImmad Mir <mirimmad17@gmail.com>2023-06-23 16:44:01 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-26 16:26:44 +0300
commit2a3f20efe6c901d4c0871cfd1d8c65e2ade71fc1 (patch)
treee25ed6e688addb4a3c221de7f54be0680809e00c /fs/jfs
parente778c8b0a9b6c5a0206c3b86e19defee9d9a7581 (diff)
downloadlinux-2a3f20efe6c901d4c0871cfd1d8c65e2ade71fc1.tar.xz
FS: JFS: Fix null-ptr-deref Read in txBegin
[ 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>
Diffstat (limited to 'fs/jfs')
-rw-r--r--fs/jfs/namei.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 7a55d14cc1af..f155ad6650bd 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -798,6 +798,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);