Re: [syzbot] Re: general protection fault in jfs_error()
From: syzbot
Date: Mon Nov 18 2024 - 05:06:57 EST
For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.
***
Subject: Re: general protection fault in jfs_error()
Author: dmantipov@xxxxxxxxx
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git adc218676eef25575469234709c2d87185ca223a
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index d68a4e6ac345..d2eff3375aad 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -96,24 +96,29 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
}
tid = txBegin(dip->i_sb, 0);
+ /* Do not go further if jfs_handle_error() marks us read-only. */
+ if (unlikely(dip->i_sb->s_flags & SB_RDONLY)) {
+ rc = -EROFS;
+ goto out3;
+ }
mutex_lock_nested(&JFS_IP(dip)->commit_mutex, COMMIT_MUTEX_PARENT);
mutex_lock_nested(&JFS_IP(ip)->commit_mutex, COMMIT_MUTEX_CHILD);
rc = jfs_init_acl(tid, ip, dip);
if (rc)
- goto out3;
+ goto out4;
rc = jfs_init_security(tid, ip, dip, &dentry->d_name);
if (rc) {
txAbort(tid, 0);
- goto out3;
+ goto out4;
}
if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) {
jfs_err("jfs_create: dtSearch returned %d", rc);
txAbort(tid, 0);
- goto out3;
+ goto out4;
}
tblk = tid_to_tblock(tid);
@@ -140,7 +145,7 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
txAbort(tid, 1); /* Marks Filesystem dirty */
} else
txAbort(tid, 0); /* Filesystem full */
- goto out3;
+ goto out4;
}
ip->i_op = &jfs_file_inode_operations;
@@ -155,10 +160,12 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
rc = txCommit(tid, 2, &iplist[0], 0);
- out3:
+ out4:
txEnd(tid);
mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
+
+ out3:
if (rc) {
free_ea_wmap(ip);
clear_nlink(ip);