Re: [syzbot] general protection fault in do_mpage_readpage

From: syzbot
Date: Tue Jun 21 2022 - 17:19:20 EST


syzbot has found a reproducer for the following issue on:

HEAD commit: 34d1d36073ea Add linux-next specific files for 20220621
git tree: linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=11eeec3ff00000
kernel config: https://syzkaller.appspot.com/x/.config?x=b24b62d1c051cfc8
dashboard link: https://syzkaller.appspot.com/bug?extid=dbbd022e608bb122cf4e
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1216c174080000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14362fd8080000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+dbbd022e608bb122cf4e@xxxxxxxxxxxxxxxxxxxxxxxxx

loop0: detected capacity change from 0 to 8191
ntfs3: loop0: Mark volume as dirty due to NTFS errors
general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 0 PID: 3604 Comm: syz-executor200 Not tainted 5.19.0-rc3-next-20220621-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:map_buffer_to_folio fs/mpage.c:107 [inline]
RIP: 0010:do_mpage_readpage+0xfe8/0x19f0 fs/mpage.c:228
Code: 85 ed 0f 84 98 01 00 00 49 be 00 00 00 00 00 fc ff df 4c 89 ed 45 31 e4 eb 2c e8 73 8f 93 ff 48 8d 7d 08 48 89 f8 48 c1 e8 03 <42> 80 3c 30 00 0f 85 53 08 00 00 48 8b 6d 08 41 83 c4 01 49 39 ed
RSP: 0018:ffffc90002f9f7c0 EFLAGS: 00010202
RAX: 0000000000000001 RBX: 0000000000000002 RCX: 0000000000000000
RDX: ffff8880206957c0 RSI: ffffffff81e72ddd RDI: 0000000000000008
RBP: 0000000000000000 R08: 0000000000000004 R09: 0000000000000002
R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000
R13: 0000000000000000 R14: dffffc0000000000 R15: ffffc90002f9f960
FS: 000055555626d300(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000005d84c8 CR3: 000000007e93c000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
mpage_read_folio+0xa5/0x140 fs/mpage.c:378
ntfs_read_folio+0x148/0x1e0 fs/ntfs3/inode.c:706
filemap_read_folio+0x3c/0x1d0 mm/filemap.c:2396
do_read_cache_folio+0x251/0x5b0 mm/filemap.c:3521
do_read_cache_page mm/filemap.c:3563 [inline]
read_cache_page+0x59/0x2a0 mm/filemap.c:3572
read_mapping_page include/linux/pagemap.h:756 [inline]
ntfs_map_page fs/ntfs3/ntfs_fs.h:897 [inline]
ntfs_fill_super+0x27e9/0x3730 fs/ntfs3/super.c:1145
get_tree_bdev+0x4a2/0x7e0 fs/super.c:1294
vfs_get_tree+0x89/0x2f0 fs/super.c:1501
do_new_mount fs/namespace.c:3040 [inline]
path_mount+0x1320/0x1fa0 fs/namespace.c:3370
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount fs/namespace.c:3568 [inline]
__x64_sys_mount+0x27f/0x300 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f240cf2feaa
Code: 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffefafe8648 EFLAGS: 00000286 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffefafe86a0 RCX: 00007f240cf2feaa
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007ffefafe8660
RBP: 00007ffefafe8660 R08: 00007ffefafe86a0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000286 R12: 00000000200034e8
R13: 0000000000000003 R14: 0000000000000004 R15: 000000000000021f
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:map_buffer_to_folio fs/mpage.c:107 [inline]
RIP: 0010:do_mpage_readpage+0xfe8/0x19f0 fs/mpage.c:228
Code: 85 ed 0f 84 98 01 00 00 49 be 00 00 00 00 00 fc ff df 4c 89 ed 45 31 e4 eb 2c e8 73 8f 93 ff 48 8d 7d 08 48 89 f8 48 c1 e8 03 <42> 80 3c 30 00 0f 85 53 08 00 00 48 8b 6d 08 41 83 c4 01 49 39 ed
RSP: 0018:ffffc90002f9f7c0 EFLAGS: 00010202
RAX: 0000000000000001 RBX: 0000000000000002 RCX: 0000000000000000
RDX: ffff8880206957c0 RSI: ffffffff81e72ddd RDI: 0000000000000008
RBP: 0000000000000000 R08: 0000000000000004 R09: 0000000000000002
R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000
R13: 0000000000000000 R14: dffffc0000000000 R15: ffffc90002f9f960
FS: 000055555626d300(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f240cf1fd20 CR3: 000000007e93c000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 85 ed test %ebp,%ebp
2: 0f 84 98 01 00 00 je 0x1a0
8: 49 be 00 00 00 00 00 movabs $0xdffffc0000000000,%r14
f: fc ff df
12: 4c 89 ed mov %r13,%rbp
15: 45 31 e4 xor %r12d,%r12d
18: eb 2c jmp 0x46
1a: e8 73 8f 93 ff callq 0xff938f92
1f: 48 8d 7d 08 lea 0x8(%rbp),%rdi
23: 48 89 f8 mov %rdi,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1) <-- trapping instruction
2f: 0f 85 53 08 00 00 jne 0x888
35: 48 8b 6d 08 mov 0x8(%rbp),%rbp
39: 41 83 c4 01 add $0x1,%r12d
3d: 49 39 ed cmp %rbp,%r13