All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [jfs?] general protection fault in jfs_error (2)
@ 2024-11-16  4:03 syzbot
  2024-11-18 10:06 ` [syzbot] Re: general protection fault in jfs_error() syzbot
  2024-11-19  6:24 ` syzbot
  0 siblings, 2 replies; 3+ messages in thread
From: syzbot @ 2024-11-16  4:03 UTC (permalink / raw)
  To: jfs-discussion, linux-kernel, shaggy, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    2d5404caa8c7 Linux 6.12-rc7
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1772fe30580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2aeec8c0b2e420c
dashboard link: https://syzkaller.appspot.com/bug?extid=5f0d7af0e45fae10edd1
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=17b2f4e8580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=119f7ea7980000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-2d5404ca.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c68277f7b0f1/vmlinux-2d5404ca.xz
kernel image: https://storage.googleapis.com/syzbot-assets/161b075483b1/bzImage-2d5404ca.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/6b6a26f0435b/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+5f0d7af0e45fae10edd1@syzkaller.appspotmail.com

ERROR: (device loop0): remounting filesystem as read-only
ERROR: (device loop0): dbFindCtl: Corrupt dmapctl page
jfs_create: dtInsert returned -EIO
ERROR: (device (efault)): jfs_create: 
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000a: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000050-0x0000000000000057]
CPU: 0 UID: 0 PID: 5313 Comm: syz-executor116 Not tainted 6.12.0-rc7-syzkaller #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:sb_rdonly include/linux/fs.h:2292 [inline]
RIP: 0010:jfs_handle_error fs/jfs/super.c:66 [inline]
RIP: 0010:jfs_error+0x159/0x2e0 fs/jfs/super.c:98
Code: 08 48 c7 c7 40 e9 42 8c 48 89 74 24 08 4c 89 f9 e8 4c 22 9c 08 4d 8d 65 50 4d 89 e7 49 c1 ef 03 48 b8 00 00 00 00 00 fc ff df <41> 80 3c 07 00 74 08 4c 89 e7 e8 48 5e d6 fe 49 8b 1c 24 48 89 de
RSP: 0018:ffffc9000ce4fa20 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: 1c32466592978100
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc9000ce4fb30 R08: ffffffff8174a13c R09: 1ffff11003f8519a
R10: dffffc0000000000 R11: ffffed1003f8519b R12: 0000000000000050
R13: 0000000000000000 R14: 1ffff920019c9f4c R15: 000000000000000a
FS:  0000555595511380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055fdcfd20000 CR3: 0000000043170000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 jfs_create+0x81d/0xbb0 fs/jfs/namei.c:140
 vfs_create+0x23c/0x3d0 fs/namei.c:3294
 do_mknodat+0x447/0x5b0 fs/namei.c:4185
 __do_sys_mknod fs/namei.c:4218 [inline]
 __se_sys_mknod fs/namei.c:4216 [inline]
 __x64_sys_mknod+0x8c/0xa0 fs/namei.c:4216
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f17ac91d9f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff56943258 EFLAGS: 00000246 ORIG_RAX: 0000000000000085
RAX: ffffffffffffffda RBX: 00007fff56943428 RCX: 00007f17ac91d9f9
RDX: 0000000000000701 RSI: 0000000000000000 RDI: 0000000020000000
RBP: 00007f17ac996610 R08: 0000000020000000 R09: 00007fff56943428
R10: 00007fff56943120 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fff56943418 R14: 0000000000000001 R15: 0000000000000001
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:sb_rdonly include/linux/fs.h:2292 [inline]
RIP: 0010:jfs_handle_error fs/jfs/super.c:66 [inline]
RIP: 0010:jfs_error+0x159/0x2e0 fs/jfs/super.c:98
Code: 08 48 c7 c7 40 e9 42 8c 48 89 74 24 08 4c 89 f9 e8 4c 22 9c 08 4d 8d 65 50 4d 89 e7 49 c1 ef 03 48 b8 00 00 00 00 00 fc ff df <41> 80 3c 07 00 74 08 4c 89 e7 e8 48 5e d6 fe 49 8b 1c 24 48 89 de
RSP: 0018:ffffc9000ce4fa20 EFLAGS: 00010206
RAX: dffffc0000000000 RBX: dffffc0000000000 RCX: 1c32466592978100
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc9000ce4fb30 R08: ffffffff8174a13c R09: 1ffff11003f8519a
R10: dffffc0000000000 R11: ffffed1003f8519b R12: 0000000000000050
R13: 0000000000000000 R14: 1ffff920019c9f4c R15: 000000000000000a
FS:  0000555595511380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055fdcfd20000 CR3: 0000000043170000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	08 48 c7             	or     %cl,-0x39(%rax)
   3:	c7 40 e9 42 8c 48 89 	movl   $0x89488c42,-0x17(%rax)
   a:	74 24                	je     0x30
   c:	08 4c 89 f9          	or     %cl,-0x7(%rcx,%rcx,4)
  10:	e8 4c 22 9c 08       	call   0x89c2261
  15:	4d 8d 65 50          	lea    0x50(%r13),%r12
  19:	4d 89 e7             	mov    %r12,%r15
  1c:	49 c1 ef 03          	shr    $0x3,%r15
  20:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  27:	fc ff df
* 2a:	41 80 3c 07 00       	cmpb   $0x0,(%r15,%rax,1) <-- trapping instruction
  2f:	74 08                	je     0x39
  31:	4c 89 e7             	mov    %r12,%rdi
  34:	e8 48 5e d6 fe       	call   0xfed65e81
  39:	49 8b 1c 24          	mov    (%r12),%rbx
  3d:	48 89 de             	mov    %rbx,%rsi


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [syzbot] Re: general protection fault in jfs_error()
  2024-11-16  4:03 [syzbot] [jfs?] general protection fault in jfs_error (2) syzbot
@ 2024-11-18 10:06 ` syzbot
  2024-11-19  6:24 ` syzbot
  1 sibling, 0 replies; 3+ messages in thread
From: syzbot @ 2024-11-18 10:06 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

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 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);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [syzbot] Re: general protection fault in jfs_error()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: syzbot @ 2024-11-19  6:24 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

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);
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-19  6:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.