[PATCH] jfs: prevent null log deference from superblock during read only mode
From: rafad900
Date: Fri Mar 27 2026 - 21:58:45 EST
Its not possible to use jfs_create() while the file system is in read
only mode. However, there is not a way for jfs_create() to handle this case
when txBegin fails. So jfs_create() continues to with the changes to the
filesystem and tries to txCommit() them, but when trying to write the changes
to the ->log of the superblock, we reach an error telling us that system
cannot write and enters panic.
Signed-off-by: rafad900 <19312533+rafad900@xxxxxxxxxxxxxxxxxxxxxxxx>
---
fs/jfs/namei.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 60c4a0e0fca5..25b303276b82 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -97,6 +97,10 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
}
tid = txBegin(dip->i_sb, 0);
+ if (tid == 0) {
+ jfs_err("jfs_create: unable to create tblk due to read only filesystem");
+ return -EROFS;
+ }
mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT);
mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD);
--
2.43.0
--xH6SlSvmVBm4Uk5B--