2024-06-06 10:01:53

by Ubisectech Sirius

[permalink] [raw]
Subject: kernel BUG in __folio_start_writeback

Hello.
We are Ubisectech Sirius Team, the vulnerability lab of China ValiantSec. Recently, our team has discovered a issue in Linux kernel 6.8. Attached to the email were a PoC file of the issue.

Stack dump:
__vm_munmap+0x13d/0x390 mm/mmap.c:2990
__do_sys_munmap mm/mmap.c:3007 [inline]
__se_sys_munmap mm/mmap.c:3004 [inline]
__x64_sys_munmap+0x62/0x90 mm/mmap.c:3004
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6f/0x77
------------[ cut here ]------------
kernel BUG at mm/page-writeback.c:2991!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
CPU: 1 PID: 12198 Comm: segctord Not tainted 6.8.0 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:__folio_start_writeback+0x6f3/0xad0 mm/page-writeback.c:2991
Code: e8 a2 28 ce ff 48 89 ef e8 aa ed 1d 00 49 89 c7 e9 67 fd ff ff e8 8d 28 ce ff 48 c7 c6 e0 91 d7 8a 48 89 ef e8 7e 7c 0d 00 90 <0f> 0b e8 76 28 ce ff e8 c1 eb d9 08 e9 4b fb ff ff e8 67 28 ce ff
RSP: 0018:ffffc900020ffa00 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff88804246c1f8 RCX: ffffc900020ff860
RDX: ffff888018964980 RSI: ffffffff81bc8432 RDI: 0000000000000000
RBP: ffffea00018b57c0 R08: 0000000000000001 R09: fffffbfff1eb0742
R10: ffffffff8f583a17 R11: 0000000000000001 R12: 1ffff9200041ff45
R13: 0000000000000000 R14: 0000000000000001 R15: ffffea00018b57c0
FS: 0000000000000000(0000) GS:ffff88807ec00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f9cb42f0088 CR3: 00000000454c0000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
<TASK>
nilfs_segctor_prepare_write fs/nilfs2/segment.c:1697 [inline]
nilfs_segctor_do_construct+0x1c10/0x78a0 fs/nilfs2/segment.c:2113
nilfs_segctor_construct+0x8c7/0xb10 fs/nilfs2/segment.c:2418
nilfs_segctor_thread_construct fs/nilfs2/segment.c:2526 [inline]
nilfs_segctor_thread+0x3cc/0xf30 fs/nilfs2/segment.c:2610
kthread+0x2cc/0x3b0 kernel/kthread.c:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:243
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__folio_start_writeback+0x6f3/0xad0 mm/page-writeback.c:2991
Code: e8 a2 28 ce ff 48 89 ef e8 aa ed 1d 00 49 89 c7 e9 67 fd ff ff e8 8d 28 ce ff 48 c7 c6 e0 91 d7 8a 48 89 ef e8 7e 7c 0d 00 90 <0f> 0b e8 76 28 ce ff e8 c1 eb d9 08 e9 4b fb ff ff e8 67 28 ce ff
RSP: 0018:ffffc900020ffa00 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff88804246c1f8 RCX: ffffc900020ff860
RDX: ffff888018964980 RSI: ffffffff81bc8432 RDI: 0000000000000000
RBP: ffffea00018b57c0 R08: 0000000000000001 R09: fffffbfff1eb0742
R10: ffffffff8f583a17 R11: 0000000000000001 R12: 1ffff9200041ff45
R13: 0000000000000000 R14: 0000000000000001 R15: ffffea00018b57c0
FS: 0000000000000000(0000) GS:ffff88802c600000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbc5505bb58 CR3: 0000000046b08000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
root@test-h2-pc:~/1900/workdir/new_zero_day_crashes/2e10a9506d3be94cd15ce8fedcc9d7eef99ed7a0# cat report0
do_new_mount fs/namespace.c:3352 [inline]
path_mount+0x6b3/0x1eb0 fs/namespace.c:3679
do_mount fs/namespace.c:3692 [inline]
__do_sys_mount fs/namespace.c:3898 [inline]
__se_sys_mount fs/namespace.c:3875 [inline]
__x64_sys_mount+0x287/0x310 fs/namespace.c:3875
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6f/0x77
------------[ cut here ]------------
kernel BUG at mm/page-writeback.c:2991!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
CPU: 0 PID: 10193 Comm: segctord Not tainted 6.8.0 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:__folio_start_writeback+0x6f3/0xad0 mm/page-writeback.c:2991
Code: e8 a2 28 ce ff 48 89 ef e8 aa ed 1d 00 49 89 c7 e9 67 fd ff ff e8 8d 28 ce ff 48 c7 c6 e0 91 d7 8a 48 89 ef e8 7e 7c 0d 00 90 <0f> 0b e8 76 28 ce ff e8 c1 eb d9 08 e9 4b fb ff ff e8 67 28 ce ff
RSP: 0018:ffffc90001d57a00 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff888016c47b78 RCX: ffffc90001d57860
RDX: ffff888017d0a4c0 RSI: ffffffff81bc8432 RDI: 0000000000000000
RBP: ffffea0001a26ac0 R08: 0000000000000001 R09: fffffbfff1eb0742
R10: ffffffff8f583a17 R11: 0000000000000001 R12: 1ffff920003aaf45
R13: 0000000000000000 R14: 0000000000000001 R15: ffffea0001a26ac0
FS: 0000000000000000(0000) GS:ffff88802c600000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2de42000 CR3: 000000004d124000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
<TASK>
nilfs_segctor_prepare_write fs/nilfs2/segment.c:1710 [inline]
nilfs_segctor_do_construct+0x45e2/0x78a0 fs/nilfs2/segment.c:2113
nilfs_segctor_construct+0x8c7/0xb10 fs/nilfs2/segment.c:2418
nilfs_segctor_thread_construct fs/nilfs2/segment.c:2526 [inline]
nilfs_segctor_thread+0x3cc/0xf30 fs/nilfs2/segment.c:2610
kthread+0x2cc/0x3b0 kernel/kthread.c:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:243
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__folio_start_writeback+0x6f3/0xad0 mm/page-writeback.c:2991
Code: e8 a2 28 ce ff 48 89 ef e8 aa ed 1d 00 49 89 c7 e9 67 fd ff ff e8 8d 28 ce ff 48 c7 c6 e0 91 d7 8a 48 89 ef e8 7e 7c 0d 00 90 <0f> 0b e8 76 28 ce ff e8 c1 eb d9 08 e9 4b fb ff ff e8 67 28 ce ff
RSP: 0018:ffffc90001d57a00 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff888016c47b78 RCX: ffffc90001d57860
RDX: ffff888017d0a4c0 RSI: ffffffff81bc8432 RDI: 0000000000000000
RBP: ffffea0001a26ac0 R08: 0000000000000001 R09: fffffbfff1eb0742
R10: ffffffff8f583a17 R11: 0000000000000001 R12: 1ffff920003aaf45
R13: 0000000000000000 R14: 0000000000000001 R15: ffffea0001a26ac0
FS: 0000000000000000(0000) GS:ffff88807ec00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4cbd43efa0 CR3: 0000000042ee2000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554

Thank you for taking the time to read this email and we look forward to working with you further.





Attachments:
poc.c (154.50 kB)

2024-06-06 11:09:39

by Ryusuke Konishi

[permalink] [raw]
Subject: Re: kernel BUG in __folio_start_writeback

On Thu, Jun 6, 2024 at 7:01 PM Ubisectech Sirius wrote:
>
> Hello.
> We are Ubisectech Sirius Team, the vulnerability lab of China ValiantSec. Recently, our team has discovered a issue in Linux kernel 6.8. Attached to the email were a PoC file of the issue.
>
> Stack dump:
> __vm_munmap+0x13d/0x390 mm/mmap.c:2990
> __do_sys_munmap mm/mmap.c:3007 [inline]
> __se_sys_munmap mm/mmap.c:3004 [inline]
> __x64_sys_munmap+0x62/0x90 mm/mmap.c:3004
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x6f/0x77
> ------------[ cut here ]------------
> kernel BUG at mm/page-writeback.c:2991!
> invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
> CPU: 1 PID: 12198 Comm: segctord Not tainted 6.8.0 #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
> RIP: 0010:__folio_start_writeback+0x6f3/0xad0 mm/page-writeback.c:2991
> Code: e8 a2 28 ce ff 48 89 ef e8 aa ed 1d 00 49 89 c7 e9 67 fd ff ff e8 8d 28 ce ff 48 c7 c6 e0 91 d7 8a 48 89 ef e8 7e 7c 0d 00 90 <0f> 0b e8 76 28 ce ff e8 c1 eb d9 08 e9 4b fb ff ff e8 67 28 ce ff
> RSP: 0018:ffffc900020ffa00 EFLAGS: 00010293
> RAX: 0000000000000000 RBX: ffff88804246c1f8 RCX: ffffc900020ff860
> RDX: ffff888018964980 RSI: ffffffff81bc8432 RDI: 0000000000000000
> RBP: ffffea00018b57c0 R08: 0000000000000001 R09: fffffbfff1eb0742
> R10: ffffffff8f583a17 R11: 0000000000000001 R12: 1ffff9200041ff45
> R13: 0000000000000000 R14: 0000000000000001 R15: ffffea00018b57c0
> FS: 0000000000000000(0000) GS:ffff88807ec00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f9cb42f0088 CR3: 00000000454c0000 CR4: 0000000000750ef0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> PKRU: 55555554
> Call Trace:
> <TASK>
> nilfs_segctor_prepare_write fs/nilfs2/segment.c:1697 [inline]
> nilfs_segctor_do_construct+0x1c10/0x78a0 fs/nilfs2/segment.c:2113
> nilfs_segctor_construct+0x8c7/0xb10 fs/nilfs2/segment.c:2418
> nilfs_segctor_thread_construct fs/nilfs2/segment.c:2526 [inline]
> nilfs_segctor_thread+0x3cc/0xf30 fs/nilfs2/segment.c:2610
> kthread+0x2cc/0x3b0 kernel/kthread.c:388
> ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:243
> </TASK>
...
>
> Thank you for taking the time to read this email and we look forward to working with you further.

I believe this issue will be fixed by the following bug fix, which is
currently in the mm tree and will be merged into the mainline soon:

https://lkml.kernel.org/r/[email protected]

After the merge, it will also be sent to the stable trees.

Please wait a little while until then.

Thanks,
Ryusuke Konishi