* [syzbot] [nilfs?] kernel BUG in __block_write_begin_int (3)
@ 2024-10-16 9:59 syzbot
2024-10-17 16:02 ` [syzbot] " syzbot
2024-10-17 19:33 ` [PATCH] nilfs2: fix kernel bug due to missing clearing of checked flag Ryusuke Konishi
0 siblings, 2 replies; 3+ messages in thread
From: syzbot @ 2024-10-16 9:59 UTC (permalink / raw)
To: konishi.ryusuke, linux-kernel, linux-nilfs, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 2f87d0916ce0 Merge tag 'trace-ringbuffer-v6.12-rc3' of git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1425d887980000
kernel config: https://syzkaller.appspot.com/x/.config?x=cfbd94c114a3d407
dashboard link: https://syzkaller.appspot.com/bug?extid=d6ca2daf692c7a82f959
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=13a2245f980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13295030580000
Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-2f87d091.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2704ba6867a8/vmlinux-2f87d091.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9f7121fd532b/bzImage-2f87d091.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/b4825b2e2eaa/mount_0.gz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+d6ca2daf692c7a82f959@syzkaller.appspotmail.com
NILFS (loop0): mounting fs with errors
------------[ cut here ]------------
kernel BUG at fs/buffer.c:2099!
Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5098 Comm: syz-executor902 Not tainted 6.12.0-rc3-syzkaller-00044-g2f87d0916ce0 #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:__block_write_begin_int+0x19a7/0x1a70 fs/buffer.c:2099
Code: 31 ff e8 cc 58 71 ff 48 89 d8 48 25 ff 0f 00 00 74 27 e8 dc 53 71 ff e9 c6 e7 ff ff e8 d2 53 71 ff 90 0f 0b e8 ca 53 71 ff 90 <0f> 0b e8 c2 53 71 ff 90 0f 0b e8 6a b2 a2 09 48 8b 5c 24 08 48 89
RSP: 0018:ffffc9000179f9e0 EFLAGS: 00010293
RAX: ffffffff82239386 RBX: 0000000000007372 RCX: ffff8880008ec880
RDX: 0000000000000000 RSI: 0000000000001000 RDI: 0000000000007372
RBP: ffffc9000179fb50 R08: ffffffff82237bb3 R09: 1ffffd400021e7b8
R10: dffffc0000000000 R11: fffff9400021e7b9 R12: 04fff5000000462d
R13: 0000000000000000 R14: 0000000000001000 R15: 0000000000007372
FS: 000055558bc8f380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005597207fdc30 CR3: 00000000404c2000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
nilfs_prepare_chunk fs/nilfs2/dir.c:86 [inline]
nilfs_add_link+0x66e/0xb50 fs/nilfs2/dir.c:486
nilfs_mkdir+0x1f9/0x340 fs/nilfs2/namei.c:233
vfs_mkdir+0x2f9/0x4f0 fs/namei.c:4257
do_mkdirat+0x264/0x3a0 fs/namei.c:4280
__do_sys_mkdir fs/namei.c:4300 [inline]
__se_sys_mkdir fs/namei.c:4298 [inline]
__x64_sys_mkdir+0x6c/0x80 fs/namei.c:4298
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:0x7f6018852427
Code: 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 53 00 00 00 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:00007ffdfca7e2b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000053
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f6018852427
RDX: 0000000000000004 RSI: 00000000000001ff RDI: 0000000020000780
RBP: 0000000020000780 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffdfca7e350 R14: 0000000000000000 R15: 0000000000000000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__block_write_begin_int+0x19a7/0x1a70 fs/buffer.c:2099
Code: 31 ff e8 cc 58 71 ff 48 89 d8 48 25 ff 0f 00 00 74 27 e8 dc 53 71 ff e9 c6 e7 ff ff e8 d2 53 71 ff 90 0f 0b e8 ca 53 71 ff 90 <0f> 0b e8 c2 53 71 ff 90 0f 0b e8 6a b2 a2 09 48 8b 5c 24 08 48 89
RSP: 0018:ffffc9000179f9e0 EFLAGS: 00010293
RAX: ffffffff82239386 RBX: 0000000000007372 RCX: ffff8880008ec880
RDX: 0000000000000000 RSI: 0000000000001000 RDI: 0000000000007372
RBP: ffffc9000179fb50 R08: ffffffff82237bb3 R09: 1ffffd400021e7b8
R10: dffffc0000000000 R11: fffff9400021e7b9 R12: 04fff5000000462d
R13: 0000000000000000 R14: 0000000000001000 R15: 0000000000007372
FS: 000055558bc8f380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005597207fdc30 CR3: 00000000404c2000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
---
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: kernel BUG in __block_write_begin_int (3)
2024-10-16 9:59 [syzbot] [nilfs?] kernel BUG in __block_write_begin_int (3) syzbot
@ 2024-10-17 16:02 ` syzbot
2024-10-17 19:33 ` [PATCH] nilfs2: fix kernel bug due to missing clearing of checked flag Ryusuke Konishi
1 sibling, 0 replies; 3+ messages in thread
From: syzbot @ 2024-10-17 16:02 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: kernel BUG in __block_write_begin_int (3)
Author: dmantipov@yandex.ru
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git c964ced7726294d40913f2127c3f185a92cb4a41
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index fe5b1a30c509..57108bd90e8b 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -483,6 +483,13 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
got_it:
from = offset_in_folio(folio, de);
to = from + rec_len;
+ if (unlikely(to > folio_size(folio))) {
+ nilfs_error(dir->i_sb, "bad entry in directory #%lu:"
+ " from=%zu to=%zu size=%zu", dir->i_ino,
+ from, to, folio_size(folio));
+ err = -EINVAL;
+ goto out_unlock;
+ }
err = nilfs_prepare_chunk(folio, from, to);
if (err)
goto out_unlock;
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] nilfs2: fix kernel bug due to missing clearing of checked flag
2024-10-16 9:59 [syzbot] [nilfs?] kernel BUG in __block_write_begin_int (3) syzbot
2024-10-17 16:02 ` [syzbot] " syzbot
@ 2024-10-17 19:33 ` Ryusuke Konishi
1 sibling, 0 replies; 3+ messages in thread
From: Ryusuke Konishi @ 2024-10-17 19:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, linux-kernel, syzbot, syzkaller-bugs
Syzbot reported that in directory operations after nilfs2 detects
filesystem corruption and degrades to read-only,
__block_write_begin_int(), which is called to prepare block writes,
may fail the BUG_ON check for accesses exceeding the folio/page size,
triggering a kernel bug.
This was found to be because the "checked" flag of a page/folio was
not cleared when it was discarded by nilfs2's own routine, which
causes the sanity check of directory entries to be skipped when the
directory page/folio is reloaded. So, fix that.
This was necessary when the use of nilfs2's own page discard routine
was applied to more than just metadata files.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+d6ca2daf692c7a82f959@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d6ca2daf692c7a82f959
Fixes: 8c26c4e2694a ("nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption")
Cc: stable@vger.kernel.org
---
Hi Andrew, please apply this as a bug fix.
This fixes another kernel bug recently reported by syzbot.
Thanks,
Ryusuke Konishi
fs/nilfs2/page.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 5436eb0424bd..10def4b55995 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -401,6 +401,7 @@ void nilfs_clear_folio_dirty(struct folio *folio)
folio_clear_uptodate(folio);
folio_clear_mappedtodisk(folio);
+ folio_clear_checked(folio);
head = folio_buffers(folio);
if (head) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-17 19:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-16 9:59 [syzbot] [nilfs?] kernel BUG in __block_write_begin_int (3) syzbot
2024-10-17 16:02 ` [syzbot] " syzbot
2024-10-17 19:33 ` [PATCH] nilfs2: fix kernel bug due to missing clearing of checked flag Ryusuke Konishi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox