Re: KASAN: use-after-free Read in vgacon_invert_region

2018-05-24 Thread Kyungtae Kim
(We analyzed the crash and added the result below.)

We report the crash:
"KASAN: use-after-free Read in vgacon_invert_region"

This crash was found in v4.17-rc3. Specifically, memory access (read
operation) is invalid and which is detected by KASAN.

Analysis:
The function "vt_do_resize" basically allows for resizing the screen
buffer (i.e., vc_data) beyond memory address 0x10
(i.e., 0x8810 in this case).
We think, however, a certain memory area starting from 0x10 is protected.
So subsequent memory access beyond this address (by
"vgacon_invert_region") causes memory access violation.

C repro code:
 https://kiwi.cs.purdue.edu/static/alexkkid-fuzzer/repro-ba6c1.c
kernel config:
 https://kiwi.cs.purdue.edu/static/alexkkid-fuzzer/kernel-config-v4.17-rc3

Crash log:
==
BUG: KASAN: use-after-free in vgacon_invert_region+0xf9/0x100
drivers/video/console/vgacon.c:663
Read of size 2 at addr 8810 by task syz-executor3/525

CPU: 0 PID: 525 Comm: syz-executor3 Not tainted 4.17.0-rc3 #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xc7/0x138 lib/dump_stack.c:113
 print_address_description+0x78/0x290 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x234/0x350 mm/kasan/report.c:412
 __asan_report_load2_noabort+0x19/0x20 mm/kasan/report.c:431
 vgacon_invert_region+0xf9/0x100 drivers/video/console/vgacon.c:663
 invert_screen+0x197/0x630 drivers/tty/vt/vt.c:461
 highlight drivers/tty/vt/selection.c:51 [inline]
 set_selection+0x6b7/0xf60 drivers/tty/vt/selection.c:276
 tioclinux+0x126/0x410 drivers/tty/vt/vt.c:2691
 vt_ioctl+0x1036/0x2580 drivers/tty/vt/vt_ioctl.c:362
 tty_ioctl+0x288/0x14c0 drivers/tty/tty_io.c:2646
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x191/0xfe0 fs/ioctl.c:686
 ksys_ioctl+0x99/0xb0 fs/ioctl.c:701
 __do_sys_ioctl fs/ioctl.c:708 [inline]
 __se_sys_ioctl fs/ioctl.c:706 [inline]
 __x64_sys_ioctl+0x78/0xb0 fs/ioctl.c:706
 do_syscall_64+0xb0/0x460 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4497b9
RSP: 002b:7f720c4bec68 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 7f720c4bf6cc RCX: 004497b9
RDX: 2040 RSI: 0002541c RDI: 0013
RBP: 0071bf58 R08:  R09: 
R10:  R11: 0246 R12: 
R13: 5aa8 R14: 006ecb48 R15: 7f720c4bf700

The buggy address belongs to the page:
page:ea004000 count:0 mapcount:-127 mapping: index:0x0
flags: 0x0()
raw:    ff80
raw: 88013fff9300 88013fff9300 0008 
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 880fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 880fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>8810: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
   ^
 88100080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 88100100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==


Thanks,
Kyungtae Kim

On Thu, May 17, 2018 at 2:04 PM, Kyungtae Kim <kt0...@gmail.com> wrote:
> We report the crash:
> "KASAN: use-after-free Read in vgacon_invert_region"
>
> This crash was found in v4.17-rc3. Specifically, memory access (read
> operation) is invalid, and it is detected by KASAN.
>
> C repro code:
>  https://kiwi.cs.purdue.edu/static/alexkkid-fuzzer/repro-ba6c1.c
> kernel config:
>  https://kiwi.cs.purdue.edu/static/alexkkid-fuzzer/kernel-config-v4.17-rc3
>
> Crash log:
> ==
> BUG: KASAN: use-after-free in vgacon_invert_region+0xf9/0x100
> drivers/video/console/vgacon.c:663
> Read of size 2 at addr 8810 by task syz-executor3/525
>
> CPU: 0 PID: 525 Comm: syz-executor3 Not tainted 4.17.0-rc3 #3
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> Call Trace:
>  __dump_stack lib/dump_stack.c:77 [inline]
>  dump_stack+0xc7/0x138 lib/dump_stack.c:113
>  print_address_description+0x78/0x290 mm/kasan/report.c:256
>  kasan_report_error mm/kasan/report.c:354 [inline]
>  kasan_report+0x234/0x350 mm/kasan/report.c:412
>  __asan_report_load2_noabort+0x19/0x20 mm/kasan/report.c:431
>  vgacon_invert_region+0xf9/0x100 drivers/video/console/vgacon.c:663
>  invert_screen+0x197/0x630 drivers/tty/vt/vt.c:461
>  highlight drivers/tty/vt/selection.c:51 [inline]
>  set_selection+0x6b7/0xf60 drivers/tty/vt/selection.c:276
>  tioclinux+0x

KASAN: use-after-free Read in vgacon_invert_region

2018-05-18 Thread Kyungtae Kim
We report the crash:
"KASAN: use-after-free Read in vgacon_invert_region"

This crash was found in v4.17-rc3. Specifically, memory access (read
operation) is invalid, and it is detected by KASAN.

C repro code:
 https://kiwi.cs.purdue.edu/static/alexkkid-fuzzer/repro-ba6c1.c
kernel config:
 https://kiwi.cs.purdue.edu/static/alexkkid-fuzzer/kernel-config-v4.17-rc3

Crash log:
==
BUG: KASAN: use-after-free in vgacon_invert_region+0xf9/0x100
drivers/video/console/vgacon.c:663
Read of size 2 at addr 8810 by task syz-executor3/525

CPU: 0 PID: 525 Comm: syz-executor3 Not tainted 4.17.0-rc3 #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xc7/0x138 lib/dump_stack.c:113
 print_address_description+0x78/0x290 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x234/0x350 mm/kasan/report.c:412
 __asan_report_load2_noabort+0x19/0x20 mm/kasan/report.c:431
 vgacon_invert_region+0xf9/0x100 drivers/video/console/vgacon.c:663
 invert_screen+0x197/0x630 drivers/tty/vt/vt.c:461
 highlight drivers/tty/vt/selection.c:51 [inline]
 set_selection+0x6b7/0xf60 drivers/tty/vt/selection.c:276
 tioclinux+0x126/0x410 drivers/tty/vt/vt.c:2691
 vt_ioctl+0x1036/0x2580 drivers/tty/vt/vt_ioctl.c:362
 tty_ioctl+0x288/0x14c0 drivers/tty/tty_io.c:2646
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x191/0xfe0 fs/ioctl.c:686
 ksys_ioctl+0x99/0xb0 fs/ioctl.c:701
 __do_sys_ioctl fs/ioctl.c:708 [inline]
 __se_sys_ioctl fs/ioctl.c:706 [inline]
 __x64_sys_ioctl+0x78/0xb0 fs/ioctl.c:706
 do_syscall_64+0xb0/0x460 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4497b9
RSP: 002b:7f720c4bec68 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 7f720c4bf6cc RCX: 004497b9
RDX: 2040 RSI: 0002541c RDI: 0013
RBP: 0071bf58 R08:  R09: 
R10:  R11: 0246 R12: 
R13: 5aa8 R14: 006ecb48 R15: 7f720c4bf700

The buggy address belongs to the page:
page:ea004000 count:0 mapcount:-127 mapping: index:0x0
flags: 0x0()
raw:    ff80
raw: 88013fff9300 88013fff9300 0008 
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 880fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 880fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>8810: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
   ^
 88100080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 88100100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==


Thanks,
Kyungtae Kim
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel