syzbot


KASAN: null-ptr-deref Read in filemap_fault

Status: fixed on 2023/06/08 14:41
Subsystems: mm udf
[Documentation on labels]
Reported-by: syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com
Fix commit: 38a55db9877c filemap: Handle error return from __filemap_get_folio()
First crash: 419d, last: 377d
Cause bisection: introduced by (bisect log) :
commit 66dabbb65d673aef40dd17bf62c042be8f6d4a4b
Author: Christoph Hellwig <hch@lst.de>
Date: Tue Mar 7 14:34:10 2023 +0000

  mm: return an ERR_PTR from __filemap_get_folio

Crash: KASAN: null-ptr-deref Read in filemap_fault (log)
Repro: C syz .config
  
Discussions (4)
Title Replies (including bot) Last reply
[PATCH] filemap: Handle error return from __filemap_get_folio() 22 (22) 2023/05/12 04:49
[PATCH 1/2] filemap: fix the conditional folio_put in filemap_fault 5 (5) 2023/05/04 03:34
[syzbot] [mm?] [net?] KASAN: null-ptr-deref Read in filemap_fault 1 (4) 2023/05/03 12:23
[syzbot] Monthly mm report (May 2023) 0 (1) 2023/05/03 07:26

Sample crash report:
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

Crashes (112):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/02 20:53 upstream 865fdb08197e 52d40fd2 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 23:12 upstream 2e1e1337881b 90c93c40 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 15:14 upstream 2e1e1337881b 90c93c40 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 10:34 upstream 418d5c98319f 90c93c40 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 09:30 upstream 418d5c98319f 90c93c40 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/05 12:28 upstream 78b421b6a7c6 acf730dc .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/05 09:32 upstream 3c4aa4434377 518a39a6 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/05 06:07 upstream 3c4aa4434377 518a39a6 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/05 03:55 upstream 3c4aa4434377 518a39a6 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/04 16:12 upstream 1a5304fecee5 44cadb8c .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/04 14:45 upstream 1a5304fecee5 44cadb8c .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/03 15:44 upstream 348551ddaf31 b5918830 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/03 06:00 upstream 7df047b3f0aa 48e0a81d .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 20:34 upstream 865fdb08197e 52d40fd2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 13:14 upstream 865fdb08197e 52d40fd2 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 06:51 upstream c8c655c34e33 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 03:11 upstream c8c655c34e33 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/01 21:56 upstream c8c655c34e33 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/01 15:28 upstream 58390c8ce1bd 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/01 07:25 upstream 58390c8ce1bd 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/01 01:54 upstream 58390c8ce1bd 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/01 00:47 upstream 58390c8ce1bd 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/04/30 23:44 upstream 58390c8ce1bd 62df2017 .config console log report info ci-qemu-upstream KASAN: null-ptr-deref Read in filemap_fault
2023/05/07 00:55 upstream 2e1e1337881b 90c93c40 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 19:42 upstream 2e1e1337881b 90c93c40 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 18:30 upstream 2e1e1337881b 90c93c40 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 13:38 upstream 2e1e1337881b 90c93c40 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 12:51 upstream 2e1e1337881b 90c93c40 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 02:24 upstream 418d5c98319f 90c93c40 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 01:01 upstream 418d5c98319f 90c93c40 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/05 13:30 upstream 78b421b6a7c6 acf730dc .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/05 02:07 upstream 3c4aa4434377 518a39a6 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/05 00:52 upstream 3c4aa4434377 518a39a6 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/04 07:33 upstream fa31fc82fb77 5b7ff9dd .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/04 05:10 upstream fa31fc82fb77 5b7ff9dd .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/04 03:45 upstream fa31fc82fb77 b5918830 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/03 23:02 upstream 348551ddaf31 b5918830 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/03 13:48 upstream 348551ddaf31 b5918830 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/03 09:22 upstream 7df047b3f0aa 48e0a81d .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/03 00:36 upstream 7df047b3f0aa 48e0a81d .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 14:36 upstream 865fdb08197e 52d40fd2 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 12:10 upstream 865fdb08197e 52d40fd2 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 08:42 upstream c8c655c34e33 62df2017 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/02 00:26 upstream c8c655c34e33 62df2017 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/01 05:02 upstream 58390c8ce1bd 62df2017 .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/04/29 15:18 upstream 89d77f71f493 62df2017 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: null-ptr-deref Read in filemap_fault
2023/04/28 13:24 upstream 33afd4b76393 70a605de .config console log report info ci-qemu-upstream-386 KASAN: null-ptr-deref Read in filemap_fault
2023/05/11 08:20 net-next 8a690c151134 0fbd49f4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: null-ptr-deref Read in filemap_fault
2023/05/06 17:17 net-next ed23734c23d2 90c93c40 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: null-ptr-deref Read in filemap_fault
2023/04/06 13:21 linux-next e134c93f788f 08707520 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in filemap_fault
2023/03/31 11:45 linux-next 4b0f4525dc4f f325deb0 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in filemap_fault
2023/03/29 14:30 linux-next 198925fae644 f325deb0 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in filemap_fault
* Struck through repros no longer work on HEAD.