general protection fault in nilfs_clear_dirty_page
Subsystems (3)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 6d36c728bc2e Merge tag 'net-6.1-rc2' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1526d2e2880000 kernel config: https://syzkaller.appspot.com/x/.config?x=afc317c0f52ce670 dashboard link: https://syzkaller.appspot.com/bug?extid=53369d11851d8f26735c compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a2030ff47985/disk-6d36c728.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/82a6ec6fd4db/vmlinux-6d36c728.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
NILFS (loop4): discard dirty block: blocknr=0, size=1024 NILFS (loop4): discard dirty block: blocknr=0, size=1024 NILFS (loop4): discard dirty block: blocknr=0, size=1024 NILFS (loop4): discard dirty block: blocknr=0, size=1024
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 1 PID: 5633 Comm: kworker/u4:11 Not tainted 6.1.0-rc1-syzkaller-00093-g6d36c728bc2e #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022 Workqueue: writeback wb_workfn (flush-7:4) RIP: 0010:nilfs_clear_dirty_page+0x9a/0x1080 fs/nilfs2/page.c:387 Code: 31 e8 9a b3 3c fe 49 8d 5f 18 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 e0 9c 90 fe 48 8b 1b 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 c7 9c 90 fe 4c 8b 2b 49 8d 5d 28 RSP: 0018:ffffc900053e7020 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff888026a08000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffea00020d3440 RBP: ffffc900053e70f0 R08: ffffffff834ae92a R09: fffff9400041a689 R10: fffff9400041a689 R11: 1ffffd400041a688 R12: 000000000000000e R13: 0000000000000000 R14: dffffc0000000000 R15: ffffea00020d3440 FS: 0000000000000000(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f592433f000 CR3: 0000000033285000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> nilfs_clear_dirty_pages+0x1d9/0x380 fs/nilfs2/page.c:372 nilfs_writepages+0x117/0x150 fs/nilfs2/inode.c:165 do_writepages+0x3c3/0x680 mm/page-writeback.c:2469 __writeback_single_inode+0xd1/0x670 fs/fs-writeback.c:1587 writeback_sb_inodes+0xb3b/0x18f0 fs/fs-writeback.c:1870 __writeback_inodes_wb+0x125/0x420 fs/fs-writeback.c:1941 wb_writeback+0x440/0x7b0 fs/fs-writeback.c:2046 wb_check_start_all fs/fs-writeback.c:2168 [inline] wb_do_writeback fs/fs-writeback.c:2194 [inline] wb_workfn+0x827/0xef0 fs/fs-writeback.c:2227 process_one_work+0x877/0xdb0 kernel/workqueue.c:2289 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436 kthread+0x266/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:nilfs_clear_dirty_page+0x9a/0x1080 fs/nilfs2/page.c:387 Code: 31 e8 9a b3 3c fe 49 8d 5f 18 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 e0 9c 90 fe 48 8b 1b 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 c7 9c 90 fe 4c 8b 2b 49 8d 5d 28 RSP: 0018:ffffc900053e7020 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff888026a08000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffea00020d3440 RBP: ffffc900053e70f0 R08: ffffffff834ae92a R09: fffff9400041a689 R10: fffff9400041a689 R11: 1ffffd400041a688 R12: 000000000000000e R13: 0000000000000000 R14: dffffc0000000000 R15: ffffea00020d3440 FS: 0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000c000074368 CR3: 000000007ef36000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 ---------------- Code disassembly (best guess), 1 bytes skipped: 0: e8 9a b3 3c fe callq 0xfe3cb39f 5: 49 8d 5f 18 lea 0x18(%r15),%rbx 9: 48 89 d8 mov %rbx,%rax c: 48 c1 e8 03 shr $0x3,%rax 10: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1) 15: 74 08 je 0x1f 17: 48 89 df mov %rbx,%rdi 1a: e8 e0 9c 90 fe callq 0xfe909cff 1f: 48 8b 1b mov (%rbx),%rbx 22: 48 89 d8 mov %rbx,%rax 25: 48 c1 e8 03 shr $0x3,%rax * 29: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1) <-- trapping instruction 2e: 74 08 je 0x38 30: 48 89 df mov %rbx,%rdi 33: e8 c7 9c 90 fe callq 0xfe909cff 38: 4c 8b 2b mov (%rbx),%r13 3b: 49 8d 5d 28 lea 0x28(%r13),%rbx
---
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-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot
syzbotsyzbot has found a reproducer for the following issue on:
syzbot has found a reproducer for the following issue on:
HEAD commit: 022ce8862dff Merge tag 'i2c-for-6.4-rc6' of git://git.kern.. git tree: upstream console+strace: https://syzkaller.appspot.com/x/log.txt?x=118151dd280000 kernel config: https://syzkaller.appspot.com/x/.config?x=7474de833c217bf4 dashboard link: https://syzkaller.appspot.com/bug?extid=53369d11851d8f26735c compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13e9d48b280000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12d7fa63280000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/cb6ca005422c/disk-022ce886.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/172bf908a89e/vmlinux-022ce886.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4a00b7ed8430/bzImage-022ce886.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/edff56b4a75d/mount_0.gz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 0 PID: 5040 Comm: syz-executor116 Not tainted 6.4.0-rc5-syzkaller-00305-g022ce8862dff #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023 RIP: 0010:nilfs_clear_dirty_page+0xa9/0x1130 fs/nilfs2/page.c:388 Code: 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 1b 38 97 fe 48 8b 1b 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 48 89 df e8 f9 37 97 fe 4c 8b 2b 49 8d 5d 28 48 RSP: 0018:ffffc90003d2f2e0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: dffffc0000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffea0001cb1900 RBP: ffffc90003d2f3b0 R08: ffffffff834bef29 R09: fffff94000396321 R10: 0000000000000000 R11: dffffc0000000001 R12: ffffea0001cb1900 R13: 0000000000000000 R14: dffffc0000000000 R15: dffffc0000000000 FS: 00007f996874e700(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055fe30356e00 CR3: 000000002995d000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> nilfs_clear_dirty_pages+0x1e0/0x370 fs/nilfs2/page.c:373 nilfs_writepages+0x11c/0x160 fs/nilfs2/inode.c:165 do_writepages+0x3a6/0x670 mm/page-writeback.c:2551 filemap_fdatawrite_wbc+0x125/0x180 mm/filemap.c:390 __filemap_fdatawrite_range mm/filemap.c:423 [inline] filemap_write_and_wait_range+0x1d4/0x2c0 mm/filemap.c:678 generic_file_read_iter+0x19e/0x540 mm/filemap.c:2805 call_read_iter include/linux/fs.h:1862 [inline] generic_file_splice_read+0x240/0x640 fs/splice.c:419 do_splice_to fs/splice.c:902 [inline] splice_direct_to_actor+0x40c/0xbd0 fs/splice.c:973 do_splice_direct+0x283/0x3d0 fs/splice.c:1082 do_sendfile+0x620/0xff0 fs/read_write.c:1254 __do_sys_sendfile64 fs/read_write.c:1322 [inline] __se_sys_sendfile64+0x17c/0x1e0 fs/read_write.c:1308 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f9970ac36f9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 71 15 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:00007f996874e2f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000028 RAX: ffffffffffffffda RBX: 00007f9970b497b0 RCX: 00007f9970ac36f9 RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000007 RBP: 00007f9970b15b1c R08: 0000000000000000 R09: 0000000000000000 R10: 0001000000201005 R11: 0000000000000246 R12: 00007f9970b150c0 R13: 00000000200026c0 R14: 0032656c69662f2e R15: 00007f9970b497b8 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:nilfs_clear_dirty_page+0xa9/0x1130 fs/nilfs2/page.c:388 Code: 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 1b 38 97 fe 48 8b 1b 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 48 89 df e8 f9 37 97 fe 4c 8b 2b 49 8d 5d 28 48 RSP: 0018:ffffc90003d2f2e0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: dffffc0000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffea0001cb1900 RBP: ffffc90003d2f3b0 R08: ffffffff834bef29 R09: fffff94000396321 R10: 0000000000000000 R11: dffffc0000000001 R12: ffffea0001cb1900 R13: 0000000000000000 R14: dffffc0000000000 R15: dffffc0000000000 FS: 00007f996874e700(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f9970b1500a CR3: 000000002995d000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 ---------------- Code disassembly (best guess): 0: 48 89 d8 mov %rbx,%rax 3: 48 c1 e8 03 shr $0x3,%rax 7: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1) c: 74 08 je 0x16 e: 48 89 df mov %rbx,%rdi 11: e8 1b 38 97 fe callq 0xfe973831 16: 48 8b 1b mov (%rbx),%rbx 19: 48 89 d8 mov %rbx,%rax 1c: 48 c1 e8 03 shr $0x3,%rax 20: 48 b9 00 00 00 00 00 movabs $0xdffffc0000000000,%rcx 27: fc ff df * 2a: 80 3c 08 00 cmpb $0x0,(%rax,%rcx,1) <-- trapping instruction 2e: 74 08 je 0x38 30: 48 89 df mov %rbx,%rdi 33: e8 f9 37 97 fe callq 0xfe973831 38: 4c 8b 2b mov (%rbx),%r13 3b: 49 8d 5d 28 lea 0x28(%r13),%rbx 3f: 48 rex.W
---
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.
syzbot
syzbotsyzbot has bisected this issue to:
syzbot has bisected this issue to:
commit 4a445b7b6178d88956192c0202463063f52e8667
Author: Qu Wenruo <[email protected]> Date: Sat Aug 13 08:06:53 2022 +0000
btrfs: don't merge pages into bio if their page offset is not contiguous
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17778475280000 start commit: 022ce8862dff Merge tag 'i2c-for-6.4-rc6' of git://git.kern.. git tree: upstream final oops: https://syzkaller.appspot.com/x/report.txt?x=14f78475280000 console output: https://syzkaller.appspot.com/x/log.txt?x=10f78475280000 kernel config: https://syzkaller.appspot.com/x/.config?x=7474de833c217bf4 dashboard link: https://syzkaller.appspot.com/bug?extid=53369d11851d8f26735c syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13e9d48b280000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12d7fa63280000
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Quoted 7 lines · syzbot
syzbot has bisected this issue to:
commit
4a445b7b6178d88956192c0202463063f52e8667Author: Qu Wenruo <wqu-IBi9RG/[email protected]> Date: Sat Aug 13 08:06:53 2022 +0000btrfs: don't merge pages into bio if their page offset is not contiguous
I can't see how that btrfs commit would affect nilfs2..
Ryusuke Konishi
maintainerQuoted 11 lines · On Mon, Jun 12, 2023 at 12:30 PM Christoph Hellwig wrote:
Quoted 7 lines · syzbot
syzbot has bisected this issue to:
commit
4a445b7b6178d88956192c0202463063f52e8667Author: Qu Wenruo <wqu-IBi9RG/[email protected]> Date: Sat Aug 13 08:06:53 2022 +0000btrfs: don't merge pages into bio if their page offset is not contiguous
I can't see how that btrfs commit would affect nilfs2..
Yeah, I think this bisection result is wrong.
I have already posted a bug-fix patch titled "nilfs2: prevent general protection fault in nilfs_clear_dirty_page()"
for this issue.
Thanks,
Ryusuke Konishi
Ryusuke Konishi
maintainerPATCH 1/1 nilfs2: prevent general protection fault in nilfs_clear_dirty_page()
In reply to syzbotIn a syzbot stress test that deliberately causes file system errors on nilfs2 with a corrupted disk image, it has been reported that nilfs_clear_dirty_page() called from nilfs_clear_dirty_pages() can cause a general protection fault.
In nilfs_clear_dirty_pages(), when looking up dirty pages from the page cache and calling nilfs_clear_dirty_page() for each dirty page/folio retrieved, the back reference from the argument page to "mapping" may have been changed to NULL (and possibly others). It is necessary to check this after locking the page/folio.
So, fix this issue by not calling nilfs_clear_dirty_page() on a page/folio after locking it in nilfs_clear_dirty_pages() if the back reference "mapping" from the page/folio is different from the "mapping" that held the page/folio just before.
--- fs/nilfs2/page.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/nilfs2/page.c +9 -1
@@ -370,7 +370,15 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent)struct folio *folio = fbatch.folios[i];folio_lock (folio); -nilfs_clear_dirty_page (&folio->page, silent); + +/* +* This folio may have been removed from the address +* space by truncation or invalidation when the lock +* was acquired. Skip processing in that case. +*/ +if (likely (folio->mapping == mapping)) +nilfs_clear_dirty_page (&folio->page, silent); +folio_unlock (folio); }folio_batch_release (&fbatch);
Signature · 1 line
2.34.1