[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CY5PR12MB6455B012A589AE5A29C52146C623A@CY5PR12MB6455.namprd12.prod.outlook.com>
Date: Fri, 23 Jun 2023 19:14:01 +0530
From: mirimmad@...look.com
To: unlisted-recipients:; (no To-header on input)
Cc: Immad Mir <mirimmad17@...il.com>,
syzbot+f1faa20eec55e0c8644c@...kaller.appspotmail.com,
Dave Kleikamp <shaggy@...nel.org>,
jfs-discussion@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [PATCH] FS: JFS: Fix null-ptr-deref Read in txBegin
From: Immad Mir <mirimmad17@...il.com>
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@...kaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=be7e52c50c5182cc09a09ea6fc456446b2039de3
Signed-off-by: Immad Mir <mirimmad17@...il.com>
---
fs/jfs/namei.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index b29d68b5e..12e95431c 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -798,8 +798,13 @@ static int jfs_link(struct dentry *old_dentry,
rc = dquot_initialize(dir);
if (rc)
goto out;
-
- tid = txBegin(ip->i_sb, 0);
+ if (!isReadOnly(ip)) {
+ tid = txBegin(ip->i_sb, 0);
+ } else {
+ jfs_error(ip->i_sb, "read-only filesystem\n");
+ rc = -EROFS;
+ goto out;
+ }
mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT);
mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD);
--
2.40.0
Powered by blists - more mailing lists