[syzbot] [mm?] [net?] KASAN: null-ptr-deref Read in filemap_fault

8 views
Skip to first unread message

syzbot

unread,
Apr 28, 2023, 9:25:54 AM4/28/23
to linux-...@vger.kernel.org, linu...@kvack.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 33afd4b76393 Merge tag 'mm-nonmm-stable-2023-04-27-16-01' ..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17bc1008280000
kernel config: https://syzkaller.appspot.com/x/.config?x=70288413d8a92398
dashboard link: https://syzkaller.appspot.com/bug?extid=48011b86c8ea329af1b9
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: i386

Unfortunately, I don't have any reproducer for this issue yet.

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

==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:68 [inline]
BUG: KASAN: null-ptr-deref in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: null-ptr-deref in page_ref_count include/linux/page_ref.h:67 [inline]
BUG: KASAN: null-ptr-deref in put_page_testzero include/linux/mm.h:1007 [inline]
BUG: KASAN: null-ptr-deref in folio_put_testzero include/linux/mm.h:1013 [inline]
BUG: KASAN: null-ptr-deref in folio_put include/linux/mm.h:1440 [inline]
BUG: KASAN: null-ptr-deref in filemap_fault+0x544/0x24a0 mm/filemap.c:3382
Read of size 4 at addr 0000000000000028 by task syz-executor.2/19418

CPU: 1 PID: 19418 Comm: syz-executor.2 Not tainted 6.3.0-syzkaller-10620-g33afd4b76393 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
print_report mm/kasan/report.c:465 [inline]
kasan_report+0xec/0x130 mm/kasan/report.c:572
check_region_inline mm/kasan/generic.c:181 [inline]
kasan_check_range+0x141/0x190 mm/kasan/generic.c:187
instrument_atomic_read include/linux/instrumented.h:68 [inline]
atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
page_ref_count include/linux/page_ref.h:67 [inline]
put_page_testzero include/linux/mm.h:1007 [inline]
folio_put_testzero include/linux/mm.h:1013 [inline]
folio_put include/linux/mm.h:1440 [inline]
filemap_fault+0x544/0x24a0 mm/filemap.c:3382
__do_fault+0x107/0x600 mm/memory.c:4176
do_read_fault mm/memory.c:4530 [inline]
do_fault mm/memory.c:4659 [inline]
do_pte_missing mm/memory.c:3647 [inline]
handle_pte_fault mm/memory.c:4947 [inline]
__handle_mm_fault+0x27f6/0x4170 mm/memory.c:5089
handle_mm_fault+0x2af/0x9f0 mm/memory.c:5243
do_user_addr_fault+0x51a/0x1210 arch/x86/mm/fault.c:1440
handle_page_fault arch/x86/mm/fault.c:1534 [inline]
exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1590
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0023:0xf72255d0
Code: Unable to access opcode bytes at 0xf72255a6.
RSP: 002b:00000000ffb4674c EFLAGS: 00010202
RAX: 00000000f734e000 RBX: 00000000f734e000 RCX: 00000000f737c038
RDX: 000000002e220000 RSI: 0000000000000004 RDI: 00000000000e257f
RBP: 00000000f737c0c0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000282 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
May 2, 2023, 4:54:44 PM5/2/23
to ak...@linux-foundation.org, ja...@suse.com, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, net...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 865fdb08197e Merge tag 'input-for-v6.4-rc0' of git://git.k..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=133efa8c280000
kernel config: https://syzkaller.appspot.com/x/.config?x=d1c8518c09009bad
dashboard link: https://syzkaller.appspot.com/bug?extid=48011b86c8ea329af1b9
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=137594c4280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10cfd602280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c667de87f318/disk-865fdb08.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f5d4a94eb2fa/vmlinux-865fdb08.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2b0950e1688b/bzImage-865fdb08.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/21df08f169b8/mount_0.gz

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

Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdb7ca8738 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f56c0f9bd69
RDX: 000000000208e24b RSI: 0000000020000000 RDI: 0000000000000005
RBP: 00007ffdb7ca8740 R08: 0000000000000001 R09: 00007f56c0f50032
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000007
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:68 [inline]
BUG: KASAN: null-ptr-deref in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: null-ptr-deref in page_ref_count include/linux/page_ref.h:67 [inline]
BUG: KASAN: null-ptr-deref in put_page_testzero include/linux/mm.h:996 [inline]
BUG: KASAN: null-ptr-deref in folio_put_testzero include/linux/mm.h:1002 [inline]
BUG: KASAN: null-ptr-deref in folio_put include/linux/mm.h:1429 [inline]
BUG: KASAN: null-ptr-deref in filemap_fault+0x121e/0x1810 mm/filemap.c:3382
Read of size 4 at addr 0000000000000028 by task syz-executor223/4990

CPU: 0 PID: 4990 Comm: syz-executor223 Not tainted 6.3.0-syzkaller-12423-g865fdb08197e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
print_report+0xe6/0x540 mm/kasan/report.c:465
kasan_report+0x176/0x1b0 mm/kasan/report.c:572
kasan_check_range+0x283/0x290 mm/kasan/generic.c:187
instrument_atomic_read include/linux/instrumented.h:68 [inline]
atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
page_ref_count include/linux/page_ref.h:67 [inline]
put_page_testzero include/linux/mm.h:996 [inline]
folio_put_testzero include/linux/mm.h:1002 [inline]
folio_put include/linux/mm.h:1429 [inline]
filemap_fault+0x121e/0x1810 mm/filemap.c:3382
__do_fault+0x136/0x500 mm/memory.c:4176
do_read_fault mm/memory.c:4530 [inline]
do_fault mm/memory.c:4659 [inline]
do_pte_missing mm/memory.c:3647 [inline]
handle_pte_fault mm/memory.c:4947 [inline]
__handle_mm_fault mm/memory.c:5089 [inline]
handle_mm_fault+0x41a8/0x5860 mm/memory.c:5243
do_user_addr_fault arch/x86/mm/fault.c:1440 [inline]
handle_page_fault arch/x86/mm/fault.c:1534 [inline]
exc_page_fault+0x7d2/0x910 arch/x86/mm/fault.c:1590
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0010:fault_in_readable+0x1db/0x350 mm/gup.c:1863
Code: bf ff 48 89 d8 4c 8d ab ff 0f 00 00 4d 01 e5 49 81 e5 00 f0 ff ff 49 39 c5 72 70 e8 6f b5 bf ff 4c 39 eb 74 73 4c 89 64 24 10 <44> 8a 23 43 0f b6 04 3e 84 c0 75 18 44 88 64 24 40 48 81 c3 00 10
RSP: 0018:ffffc90003aaf9c0 EFLAGS: 00050287
RAX: ffffffff81cbda01 RBX: 0000000020000000 RCX: ffff888027d3bb80
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90003aafa78 R08: ffffffff81cbd9a3 R09: ffffffff84310069
R10: 0000000000000002 R11: ffff888027d3bb80 R12: 0000000000001000
R13: 0000000020001000 R14: 1ffff92000755f40 R15: dffffc0000000000
fault_in_iov_iter_readable+0xdf/0x280 lib/iov_iter.c:362
generic_perform_write+0x20b/0x5e0 mm/filemap.c:3913
__generic_file_write_iter+0x17a/0x400 mm/filemap.c:4051
udf_file_write_iter+0x2fc/0x660 fs/udf/file.c:115
call_write_iter include/linux/fs.h:1868 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x7ec/0xc10 fs/read_write.c:584
ksys_write+0x1a0/0x2c0 fs/read_write.c:637
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:0x7f56c0f9bd69
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdb7ca8738 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f56c0f9bd69
RDX: 000000000208e24b RSI: 0000000020000000 RDI: 0000000000000005
RBP: 00007ffdb7ca8740 R08: 0000000000000001 R09: 00007f56c0f50032
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000007
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>
==================================================================
----------------
Code disassembly (best guess):
0: 28 00 sub %al,(%rax)
2: 00 00 add %al,(%rax)
4: 75 05 jne 0xb
6: 48 83 c4 28 add $0x28,%rsp
a: c3 retq
b: e8 51 14 00 00 callq 0x1461
10: 90 nop
11: 48 89 f8 mov %rdi,%rax
14: 48 89 f7 mov %rsi,%rdi
17: 48 89 d6 mov %rdx,%rsi
1a: 48 89 ca mov %rcx,%rdx
1d: 4d 89 c2 mov %r8,%r10
20: 4d 89 c8 mov %r9,%r8
23: 4c 8b 4c 24 08 mov 0x8(%rsp),%r9
28: 0f 05 syscall
* 2a: 48 3d 01 f0 ff ff cmp $0xfffffffffffff001,%rax <-- trapping instruction
30: 73 01 jae 0x33
32: c3 retq
33: 48 c7 c1 c0 ff ff ff mov $0xffffffffffffffc0,%rcx
3a: f7 d8 neg %eax
3c: 64 89 01 mov %eax,%fs:(%rcx)
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

unread,
May 3, 2023, 5:23:20 AM5/3/23
to ak...@linux-foundation.org, h...@lst.de, ja...@suse.com, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, net...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 66dabbb65d673aef40dd17bf62c042be8f6d4a4b
Author: Christoph Hellwig <h...@lst.de>
Date: Tue Mar 7 14:34:10 2023 +0000

mm: return an ERR_PTR from __filemap_get_folio

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15220608280000
start commit: 865fdb08197e Merge tag 'input-for-v6.4-rc0' of git://git.k..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=17220608280000
console output: https://syzkaller.appspot.com/x/log.txt?x=13220608280000
Reported-by: syzbot+48011b...@syzkaller.appspotmail.com
Fixes: 66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Jan Kara

unread,
May 3, 2023, 8:23:40 AM5/3/23
to syzbot, ak...@linux-foundation.org, h...@lst.de, ja...@suse.com, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Actually looking into commit 66dabbb65d67 it seems it has two problems -
one in filemap_fault() where in:

if (IS_ERR(folio)) {
if (fpin)
goto out_retry;

we need to clear folio so that we don't try to folio_put() the error
pointer. And another in afs_dir_get_folio() where the changes effectively
make that function return ERR_PTR instead of NULL as well which will then
confuse afs_edit_dir_add() and other callers (which were not updated).

Honza
--
Jan Kara <ja...@suse.com>
SUSE Labs, CR
Reply all
Reply to author
Forward
0 new messages