public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3)
@ 2025-01-14  7:40 syzbot
  2025-01-14 10:34 ` Ryusuke Konishi
  2025-01-14 11:28 ` Ryusuke Konishi
  0 siblings, 2 replies; 5+ messages in thread
From: syzbot @ 2025-01-14  7:40 UTC (permalink / raw)
  To: konishi.ryusuke, linux-kernel, linux-nilfs, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    643e2e259c2b Merge tag 'for-6.13-rc6-tag' of git://git.ker..
git tree:       upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1719a218580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7ac4cd61d548c1ef
dashboard link: https://syzkaller.appspot.com/bug?extid=158be45e4d99232e1900
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=132021df980000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1530cf0f980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/76410f8b1345/disk-643e2e25.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1ee033602aec/vmlinux-643e2e25.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b8062c57eaa0/bzImage-643e2e25.xz
mounted in repro #1: https://storage.googleapis.com/syzbot-assets/ca71c75d50c5/mount_0.gz
mounted in repro #2: https://storage.googleapis.com/syzbot-assets/f6a710039269/mount_4.gz

Bisection is inconclusive: the issue happens on the oldest tested release.

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=140b4cb0580000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=160b4cb0580000
console output: https://syzkaller.appspot.com/x/log.txt?x=120b4cb0580000

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

------------[ cut here ]------------
WARNING: CPU: 0 PID: 6214 at fs/nilfs2/btree.c:2301 nilfs_btree_assign+0xabb/0xd20 fs/nilfs2/btree.c:2301
Modules linked in:
CPU: 0 UID: 0 PID: 6214 Comm: segctord Not tainted 6.13.0-rc6-syzkaller-00059-g643e2e259c2b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:nilfs_btree_assign+0xabb/0xd20 fs/nilfs2/btree.c:2301
Code: 00 00 44 89 f0 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc e8 e2 52 24 fe 4c 8b 7c 24 38 eb a2 e8 d6 52 24 fe 90 <0f> 0b 90 41 be fe ff ff ff eb 91 44 89 f1 80 e1 07 80 c1 03 38 c1
RSP: 0018:ffffc90004bcf600 EFLAGS: 00010293
RAX: ffffffff837b20fa RBX: ffff8880758fa658 RCX: ffff888027200000
RDX: 0000000000000000 RSI: 00000000fffffffe RDI: 00000000fffffffe
RBP: ffffc90004bcf730 R08: ffffffff837b1a3b R09: 0000000000000000
R10: ffffc90004bcf560 R11: fffff52000979eaf R12: dffffc0000000000
R13: ffff8880330ca580 R14: 00000000fffffffe R15: 1ffff92000979ed0
FS:  0000000000000000(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020094000 CR3: 0000000030296000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 nilfs_bmap_assign+0x8f/0x160 fs/nilfs2/bmap.c:390
 nilfs_segctor_update_payload_blocknr fs/nilfs2/segment.c:1633 [inline]
 nilfs_segctor_assign fs/nilfs2/segment.c:1667 [inline]
 nilfs_segctor_do_construct+0x35c5/0x6ea0 fs/nilfs2/segment.c:2126
 nilfs_segctor_construct+0x181/0x6b0 fs/nilfs2/segment.c:2479
 nilfs_segctor_thread_construct fs/nilfs2/segment.c:2587 [inline]
 nilfs_segctor_thread+0x69e/0xe80 fs/nilfs2/segment.c:2701
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>


---
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.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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] 5+ messages in thread

* Re: [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3)
  2025-01-14  7:40 [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3) syzbot
@ 2025-01-14 10:34 ` Ryusuke Konishi
  2025-01-14 10:51   ` syzbot
  2025-01-14 11:28 ` Ryusuke Konishi
  1 sibling, 1 reply; 5+ messages in thread
From: Ryusuke Konishi @ 2025-01-14 10:34 UTC (permalink / raw)
  To: syzbot+158be45e4d99232e1900; +Cc: linux-kernel, syzkaller-bugs

Isolate whether the ongoing patch protecting the referenced buffer
head affects reproducibility of the issue.

#syz test

diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 9de2a494a069..899686d2e5f7 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -392,6 +392,11 @@ void nilfs_clear_dirty_pages(struct address_space *mapping)
 /**
  * nilfs_clear_folio_dirty - discard dirty folio
  * @folio: dirty folio that will be discarded
+ *
+ * nilfs_clear_folio_dirty() clears working states including dirty state for
+ * the folio and its buffers.  If the folio has buffers, clear only if it is
+ * confirmed that none of the buffer heads are busy (none have valid
+ * references and none are locked).
  */
 void nilfs_clear_folio_dirty(struct folio *folio)
 {
@@ -399,10 +404,6 @@ void nilfs_clear_folio_dirty(struct folio *folio)
 
 	BUG_ON(!folio_test_locked(folio));
 
-	folio_clear_uptodate(folio);
-	folio_clear_mappedtodisk(folio);
-	folio_clear_checked(folio);
-
 	head = folio_buffers(folio);
 	if (head) {
 		const unsigned long clear_bits =
@@ -410,6 +411,25 @@ void nilfs_clear_folio_dirty(struct folio *folio)
 			 BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) |
 			 BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected) |
 			 BIT(BH_Delay));
+		bool busy, invalidated = false;
+
+recheck_buffers:
+		busy = false;
+		bh = head;
+		do {
+			if (atomic_read(&bh->b_count) | buffer_locked(bh)) {
+				busy = true;
+				break;
+			}
+		} while (bh = bh->b_this_page, bh != head);
+
+		if (busy) {
+			if (invalidated)
+				return;
+			invalidate_bh_lrus();
+			invalidated = true;
+			goto recheck_buffers;
+		}
 
 		bh = head;
 		do {
@@ -419,6 +439,9 @@ void nilfs_clear_folio_dirty(struct folio *folio)
 		} while (bh = bh->b_this_page, bh != head);
 	}
 
+	folio_clear_uptodate(folio);
+	folio_clear_mappedtodisk(folio);
+	folio_clear_checked(folio);
 	__nilfs_clear_folio_dirty(folio);
 }
 
-- 
2.43.0


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

* Re: [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3)
  2025-01-14 10:34 ` Ryusuke Konishi
@ 2025-01-14 10:51   ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2025-01-14 10:51 UTC (permalink / raw)
  To: konishi.ryusuke, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in nilfs_btree_assign

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6898 at fs/nilfs2/btree.c:2301 nilfs_btree_assign+0xabb/0xd20 fs/nilfs2/btree.c:2301
Modules linked in:
CPU: 1 UID: 0 PID: 6898 Comm: segctord Not tainted 6.13.0-rc7-syzkaller-gc45323b7560e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:nilfs_btree_assign+0xabb/0xd20 fs/nilfs2/btree.c:2301
Code: 00 00 44 89 f0 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc e8 a2 53 24 fe 4c 8b 7c 24 38 eb a2 e8 96 53 24 fe 90 <0f> 0b 90 41 be fe ff ff ff eb 91 44 89 f1 80 e1 07 80 c1 03 38 c1
RSP: 0018:ffffc90003137600 EFLAGS: 00010293
RAX: ffffffff837b1e8a RBX: ffff8880714f3fd8 RCX: ffff88802e24da00
RDX: 0000000000000000 RSI: 00000000fffffffe RDI: 00000000fffffffe
RBP: ffffc90003137730 R08: ffffffff837b17cb R09: 0000000000000000
R10: ffffc90003137560 R11: fffff52000626eaf R12: dffffc0000000000
R13: ffff88802a22ad00 R14: 00000000fffffffe R15: 1ffff92000626ed0
FS:  0000000000000000(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb73deff000 CR3: 000000000e736000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 nilfs_bmap_assign+0x8f/0x160 fs/nilfs2/bmap.c:390
 nilfs_segctor_update_payload_blocknr fs/nilfs2/segment.c:1633 [inline]
 nilfs_segctor_assign fs/nilfs2/segment.c:1667 [inline]
 nilfs_segctor_do_construct+0x35c5/0x6ea0 fs/nilfs2/segment.c:2126
 nilfs_segctor_construct+0x181/0x6b0 fs/nilfs2/segment.c:2479
 nilfs_segctor_thread_construct fs/nilfs2/segment.c:2587 [inline]
 nilfs_segctor_thread+0x69e/0xe80 fs/nilfs2/segment.c:2701
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>


Tested on:

commit:         c45323b7 Merge tag 'mm-hotfixes-stable-2025-01-13-00-0..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17252a18580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c676c8e1379fdfaa
dashboard link: https://syzkaller.appspot.com/bug?extid=158be45e4d99232e1900
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=160401f8580000


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

* Re: [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3)
  2025-01-14  7:40 [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3) syzbot
  2025-01-14 10:34 ` Ryusuke Konishi
@ 2025-01-14 11:28 ` Ryusuke Konishi
  2025-01-14 12:28   ` syzbot
  1 sibling, 1 reply; 5+ messages in thread
From: Ryusuke Konishi @ 2025-01-14 11:28 UTC (permalink / raw)
  To: syzbot+158be45e4d99232e1900; +Cc: linux-kernel, syzkaller-bugs

Isolation test 2: the reproducers output a lot of
nilfs_btree_propagate messages, but the metadata corruption is not
escalated to the bmap layer, so test the effectiveness of that fix.

#syz test

diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index ef5061bb56da..8a280379e813 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -2103,11 +2103,14 @@ static int nilfs_btree_propagate(struct nilfs_bmap *btree,
 
 	ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1, 0);
 	if (ret < 0) {
-		if (unlikely(ret == -ENOENT))
+		if (unlikely(ret == -ENOENT)) {
 			nilfs_crit(btree->b_inode->i_sb,
 				   "writing node/leaf block does not appear in b-tree (ino=%lu) at key=%llu, level=%d",
 				   btree->b_inode->i_ino,
 				   (unsigned long long)key, level);
+			/* Notify bmap layer of metadata corruption */
+			ret = -EINVAL;
+		}
 		goto out;
 	}
 
-- 
2.43.0


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

* Re: [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3)
  2025-01-14 11:28 ` Ryusuke Konishi
@ 2025-01-14 12:28   ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2025-01-14 12:28 UTC (permalink / raw)
  To: konishi.ryusuke, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in nilfs_btree_assign

------------[ cut here ]------------
WARNING: CPU: 1 PID: 6911 at fs/nilfs2/btree.c:2304 nilfs_btree_assign+0xabb/0xd20 fs/nilfs2/btree.c:2304
Modules linked in:
CPU: 1 UID: 0 PID: 6911 Comm: segctord Not tainted 6.13.0-rc7-syzkaller-gc45323b7560e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
RIP: 0010:nilfs_btree_assign+0xabb/0xd20 fs/nilfs2/btree.c:2304
Code: 00 00 44 89 f0 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc e8 42 55 24 fe 4c 8b 7c 24 38 eb a2 e8 36 55 24 fe 90 <0f> 0b 90 41 be fe ff ff ff eb 91 44 89 f1 80 e1 07 80 c1 03 38 c1
RSP: 0018:ffffc90002f77600 EFLAGS: 00010293
RAX: ffffffff837b1cea RBX: ffff88805bfe0678 RCX: ffff888033a75a00
RDX: 0000000000000000 RSI: 00000000fffffffe RDI: 00000000fffffffe
RBP: ffffc90002f77730 R08: ffffffff837b162b R09: 0000000000000000
R10: ffffc90002f77560 R11: fffff520005eeeaf R12: dffffc0000000000
R13: ffff88806d9e2d00 R14: 00000000fffffffe R15: 1ffff920005eeed0
FS:  0000000000000000(0000) GS:ffff8880b8700000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020012000 CR3: 000000002eeca000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 nilfs_bmap_assign+0x8f/0x160 fs/nilfs2/bmap.c:390
 nilfs_segctor_update_payload_blocknr fs/nilfs2/segment.c:1633 [inline]
 nilfs_segctor_assign fs/nilfs2/segment.c:1667 [inline]
 nilfs_segctor_do_construct+0x35c5/0x6ea0 fs/nilfs2/segment.c:2126
 nilfs_segctor_construct+0x181/0x6b0 fs/nilfs2/segment.c:2479
 nilfs_segctor_thread_construct fs/nilfs2/segment.c:2587 [inline]
 nilfs_segctor_thread+0x69e/0xe80 fs/nilfs2/segment.c:2701
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>


Tested on:

commit:         c45323b7 Merge tag 'mm-hotfixes-stable-2025-01-13-00-0..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14477664580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c676c8e1379fdfaa
dashboard link: https://syzkaller.appspot.com/bug?extid=158be45e4d99232e1900
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=140c01f8580000


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

end of thread, other threads:[~2025-01-14 12:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14  7:40 [syzbot] [nilfs?] WARNING in nilfs_btree_assign (3) syzbot
2025-01-14 10:34 ` Ryusuke Konishi
2025-01-14 10:51   ` syzbot
2025-01-14 11:28 ` Ryusuke Konishi
2025-01-14 12:28   ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox