From: syzbot <syzbot+5f0d7af0e45fae10edd1@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] Re: general protection fault in jfs_error()
Date: Mon, 18 Nov 2024 22:24:37 -0800 [thread overview]
Message-ID: <673c2f25.050a0220.87769.0068.GAE@google.com> (raw)
In-Reply-To: <67381991.050a0220.57553.0045.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: Re: general protection fault in jfs_error()
Author: dmantipov@yandex.ru
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 158f238aa69d91ad74e535c73f552bd4b025109c
diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index 98f9a432c336..c0a51defc5b7 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -303,12 +303,6 @@ static int chkSuper(struct super_block *sb)
/*
* validate superblock
*/
- /* validate fs signature */
- if (strncmp(j_sb->s_magic, JFS_MAGIC, 4) ||
- le32_to_cpu(j_sb->s_version) > JFS_VERSION) {
- rc = -EINVAL;
- goto out;
- }
bsize = le32_to_cpu(j_sb->s_bsize);
if (bsize != PSIZE) {
@@ -449,6 +443,18 @@ int updateSuper(struct super_block *sb, uint state)
return 0;
}
+static int validateSuper(struct buffer_head *bh)
+{
+ struct jfs_superblock *j_sb;
+
+ if (!bh)
+ return -EIO;
+
+ j_sb = (struct jfs_superblock *)bh->b_data;
+
+ return (strncmp(j_sb->s_magic, JFS_MAGIC, 4) == 0 &&
+ le32_to_cpu(j_sb->s_version) <= JFS_VERSION) ? 0 : -EINVAL;
+}
/*
* readSuper()
@@ -457,17 +463,17 @@ int updateSuper(struct super_block *sb, uint state)
*/
int readSuper(struct super_block *sb, struct buffer_head **bpp)
{
- /* read in primary superblock */
+ /* read in and validate primary superblock */
*bpp = sb_bread(sb, SUPER1_OFF >> sb->s_blocksize_bits);
- if (*bpp)
+ if (!validateSuper(*bpp))
return 0;
- /* read in secondary/replicated superblock */
+ /* read in and validate secondary/replicated superblock */
*bpp = sb_bread(sb, SUPER2_OFF >> sb->s_blocksize_bits);
- if (*bpp)
+ if (!validateSuper(*bpp))
return 0;
- return -EIO;
+ return -EINVAL;
}
diff --git a/fs/jfs/jfs_umount.c b/fs/jfs/jfs_umount.c
index 8ec43f53f686..5f01f767bc0a 100644
--- a/fs/jfs/jfs_umount.c
+++ b/fs/jfs/jfs_umount.c
@@ -104,14 +104,15 @@ int jfs_umount(struct super_block *sb)
* list (to signify skip logredo()).
*/
if (log) { /* log = NULL if read-only mount */
- updateSuper(sb, FM_CLEAN);
-
- /*
- * close log:
- *
- * remove file system from log active file system list.
- */
- rc = lmLogClose(sb);
+ rc = updateSuper(sb, FM_CLEAN);
+ if (!rc) {
+ /*
+ * close log:
+ *
+ * remove file system from log active file system list.
+ */
+ rc = lmLogClose(sb);
+ }
}
jfs_info("UnMount JFS Complete: rc = %d", rc);
return rc;
@@ -122,6 +123,7 @@ int jfs_umount_rw(struct super_block *sb)
{
struct jfs_sb_info *sbi = JFS_SBI(sb);
struct jfs_log *log = sbi->log;
+ int rc;
if (!log)
return 0;
@@ -147,7 +149,7 @@ int jfs_umount_rw(struct super_block *sb)
*/
filemap_write_and_wait(sbi->direct_inode->i_mapping);
- updateSuper(sb, FM_CLEAN);
+ rc = updateSuper(sb, FM_CLEAN);
- return lmLogClose(sb);
+ return rc ? rc : lmLogClose(sb);
}
prev parent reply other threads:[~2024-11-19 6:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-16 4:03 [syzbot] [jfs?] general protection fault in jfs_error (2) syzbot
2024-11-18 10:06 ` [syzbot] Re: general protection fault in jfs_error() syzbot
2024-11-19 6:24 ` syzbot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=673c2f25.050a0220.87769.0068.GAE@google.com \
--to=syzbot+5f0d7af0e45fae10edd1@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.