syzbot


KASAN: out-of-bounds Write in virtio_gpu_cmd_set_scanout
Status: fixed on 2022/03/08 16:11
Reported-by: syzbot+@syzkaller.appspotmail.com
Fix commit: 5bd4f20de8ac virtio-gpu: fix possible memory allocation failure
First crash: 204d, last: 204d

Sample crash report:
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007ffcde6828ff R14: 00007fecfe62c300 R15: 0000000000022000
==================================================================
BUG: KASAN: out-of-bounds in memset include/linux/fortify-string.h:209 [inline]
BUG: KASAN: out-of-bounds in virtio_gpu_cmd_set_scanout+0xc5/0x280 drivers/gpu/drm/virtio/virtgpu_vq.c:563
Write of size 48 at addr fffffffffffffff4 by task syz-executor.2/29244

CPU: 2 PID: 29244 Comm: syz-executor.2 Not tainted 5.15.0-syzkaller #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xf/0x2d6 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
 memset+0x20/0x40 mm/kasan/shadow.c:44
 memset include/linux/fortify-string.h:209 [inline]
 virtio_gpu_cmd_set_scanout+0xc5/0x280 drivers/gpu/drm/virtio/virtgpu_vq.c:563
 virtio_gpu_primary_plane_update+0x33a/0x1650 drivers/gpu/drm/virtio/virtgpu_plane.c:186
 drm_atomic_helper_commit_planes+0x332/0xb60 drivers/gpu/drm/drm_atomic_helper.c:2552
 drm_atomic_helper_commit_tail+0x62/0xf0 drivers/gpu/drm/drm_atomic_helper.c:1582
 commit_tail+0x32d/0x420 drivers/gpu/drm/drm_atomic_helper.c:1667
 drm_atomic_helper_commit drivers/gpu/drm/drm_atomic_helper.c:1884 [inline]
 drm_atomic_helper_commit+0x2eb/0x370 drivers/gpu/drm/drm_atomic_helper.c:1817
 drm_atomic_commit+0xd8/0x110 drivers/gpu/drm/drm_atomic.c:1412
 drm_client_modeset_commit_atomic+0x685/0x7c0 drivers/gpu/drm/drm_client_modeset.c:1043
 drm_client_modeset_dpms+0x170/0x200 drivers/gpu/drm/drm_client_modeset.c:1224
 drm_fb_helper_dpms drivers/gpu/drm/drm_fb_helper.c:324 [inline]
 drm_fb_helper_blank+0xc6/0x250 drivers/gpu/drm/drm_fb_helper.c:345
 fb_blank+0x101/0x190 drivers/video/fbdev/core/fbmem.c:1079
 do_fb_ioctl+0x5e2/0x690 drivers/video/fbdev/core/fbmem.c:1165
 fb_ioctl+0xe7/0x150 drivers/video/fbdev/core/fbmem.c:1189
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl fs/ioctl.c:860 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
 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+0x44/0xae
RIP: 0033:0x7fed010b6ae9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fecfe62c188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fed011c9f60 RCX: 00007fed010b6ae9
RDX: 0000000000000003 RSI: 0000000000004611 RDI: 0000000000000003
RBP: 00007fecfe62c1d0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007ffcde6828ff R14: 00007fecfe62c300 R15: 0000000000022000


Memory state around the buggy address:
 fffffffffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffffffffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffffffffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
general protection fault, maybe for address 0xffffc90003fa7654: 0000 [#1] PREEMPT SMP KASAN
CPU: 2 PID: 29244 Comm: syz-executor.2 Not tainted 5.15.0-syzkaller #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
RIP: 0010:memcpy_erms+0x6/0x10 arch/x86/lib/memcpy_64.S:55
Code: cc cc cc cc eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 fe
RSP: 0018:ffffc90003fa7648 EFLAGS: 00010086
RAX: ffffc90003fa7654 RBX: 0000000000000000 RCX: 0000000000000010
RDX: 0000000000000010 RSI: dffffc0000000000 RDI: ffffc90003fa7654
RBP: fffffffffffffff4 R08: 0000000000000000 R09: 0000000000000000
R10: ffffffff83f5b373 R11: 0000000000000000 R12: 0000000000000001
R13: 0000000000000080 R14: ffffffff84621555 R15: 0000000000000000
FS:  00007fecfe62c700(0000) GS:ffff88802cc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fecfe62bf78 CR3: 000000007948b000 CR4: 0000000000150ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 print_memory_metadata+0x5a/0xdf mm/kasan/report.c:322
 __kasan_report mm/kasan/report.c:444 [inline]
 kasan_report.cold+0x99/0xdf mm/kasan/report.c:459
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
 memset+0x20/0x40 mm/kasan/shadow.c:44
 memset include/linux/fortify-string.h:209 [inline]
 virtio_gpu_cmd_set_scanout+0xc5/0x280 drivers/gpu/drm/virtio/virtgpu_vq.c:563
 virtio_gpu_primary_plane_update+0x33a/0x1650 drivers/gpu/drm/virtio/virtgpu_plane.c:186
 drm_atomic_helper_commit_planes+0x332/0xb60 drivers/gpu/drm/drm_atomic_helper.c:2552
 drm_atomic_helper_commit_tail+0x62/0xf0 drivers/gpu/drm/drm_atomic_helper.c:1582
 commit_tail+0x32d/0x420 drivers/gpu/drm/drm_atomic_helper.c:1667
 drm_atomic_helper_commit drivers/gpu/drm/drm_atomic_helper.c:1884 [inline]
 drm_atomic_helper_commit+0x2eb/0x370 drivers/gpu/drm/drm_atomic_helper.c:1817
 drm_atomic_commit+0xd8/0x110 drivers/gpu/drm/drm_atomic.c:1412
 drm_client_modeset_commit_atomic+0x685/0x7c0 drivers/gpu/drm/drm_client_modeset.c:1043
 drm_client_modeset_dpms+0x170/0x200 drivers/gpu/drm/drm_client_modeset.c:1224
 drm_fb_helper_dpms drivers/gpu/drm/drm_fb_helper.c:324 [inline]
 drm_fb_helper_blank+0xc6/0x250 drivers/gpu/drm/drm_fb_helper.c:345
 fb_blank+0x101/0x190 drivers/video/fbdev/core/fbmem.c:1079
 do_fb_ioctl+0x5e2/0x690 drivers/video/fbdev/core/fbmem.c:1165
 fb_ioctl+0xe7/0x150 drivers/video/fbdev/core/fbmem.c:1189
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl fs/ioctl.c:860 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
 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+0x44/0xae
RIP: 0033:0x7fed010b6ae9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fecfe62c188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fed011c9f60 RCX: 00007fed010b6ae9
RDX: 0000000000000003 RSI: 0000000000004611 RDI: 0000000000000003
RBP: 00007fecfe62c1d0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007ffcde6828ff R14: 00007fecfe62c300 R15: 0000000000022000
Modules linked in:
---[ end trace 5b2d51bd6928c984 ]---
RIP: 0010:memcpy_erms+0x6/0x10 arch/x86/lib/memcpy_64.S:55
Code: cc cc cc cc eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 fe
RSP: 0018:ffffc90003fa7648 EFLAGS: 00010086
RAX: ffffc90003fa7654 RBX: 0000000000000000 RCX: 0000000000000010
RDX: 0000000000000010 RSI: dffffc0000000000 RDI: ffffc90003fa7654
RBP: fffffffffffffff4 R08: 0000000000000000 R09: 0000000000000000
R10: ffffffff83f5b373 R11: 0000000000000000 R12: 0000000000000001
R13: 0000000000000080 R14: ffffffff84621555 R15: 0000000000000000
FS:  00007fecfe62c700(0000) GS:ffff88802cc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fecfe62bf78 CR3: 000000007948b000 CR4: 0000000000150ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	cc                   	int3
   1:	cc                   	int3
   2:	cc                   	int3
   3:	cc                   	int3
   4:	eb 1e                	jmp    0x24
   6:	0f 1f 00             	nopl   (%rax)
   9:	48 89 f8             	mov    %rdi,%rax
   c:	48 89 d1             	mov    %rdx,%rcx
   f:	48 c1 e9 03          	shr    $0x3,%rcx
  13:	83 e2 07             	and    $0x7,%edx
  16:	f3 48 a5             	rep movsq %ds:(%rsi),%es:(%rdi)
  19:	89 d1                	mov    %edx,%ecx
  1b:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi)
  1d:	c3                   	retq
  1e:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
  24:	48 89 f8             	mov    %rdi,%rax
  27:	48 89 d1             	mov    %rdx,%rcx
* 2a:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi) <-- trapping instruction
  2c:	c3                   	retq
  2d:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
  34:	48 89 f8             	mov    %rdi,%rax
  37:	48 83 fa 20          	cmp    $0x20,%rdx
  3b:	72 7e                	jb     0xbb
  3d:	40 38 fe             	cmp    %dil,%sil

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-qemu-upstream 2021/11/03 04:34 upstream bfc484fe6abb 17f3edd2 .config log report info KASAN: out-of-bounds Write in virtio_gpu_cmd_set_scanout