Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1651017imm; Wed, 23 May 2018 21:36:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqt/Lek9IKbsgDSod1t5JwhV9wTErzNp+mKibBEhPV0PzdYHY4Q3V9qZH/BJZRzgLFmzk9M X-Received: by 2002:a17:902:b681:: with SMTP id c1-v6mr5676498pls.286.1527136605156; Wed, 23 May 2018 21:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527136605; cv=none; d=google.com; s=arc-20160816; b=zawRmBEWxdS8zFQA68IIwMdrueCUEM28doYEuAmAMAYcsnSKVtb0mQ5Wp8YEahFnt3 7pMQzVO/NS8nUUit00fdxjZ3ZesG387I7CCIF23FqtFpqFZ+o3DfK8eUg8X3/g+17jhu kKo0WBgctvRj24sg4l6khtRTBObg5tQk+fz6cUpCi7jpddbySGromUm05tHyA+78iYM7 84wGQqfV8oR8s/W0Tw27ycJq0AeMPv5Zuh+HDgoBFT1DCNvmmwxEuODaBZk+M6ZaIQ/y 3E8Z24Y2n21i0o9Fg3Lu5MQpqgtngs0YP6qVbMtf0c1/Wxnbe5PUbbfMEs69qCbdRbH3 5ueg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=6AP3+7wKcoEvsOa4DIZcdZMEzMHbxrvqOBFwIWop0bA=; b=cUeybgg6Az0W0Iels5lknULujsEGP7+YuzhzYi1ZND6p9qFwXmBQCh+zSDYDyZsauc TaH26fMs4HAodfDEhcV+TjMzvRtSBmvwP6EuKw1eFj1NHtw2tgNVx5S+3WfBzXB7n2N/ NnXeYvsXWxuNX0+IQiJRvs4hmSVpPbZYfiaek6YaGNEcXkCSjEAIGOIaapMu5w9x9TXE EsL2dIA+2ZqJw39WWOFonl+Kw9wVeUvwfQsZTq3X8Ou1bTN7JXquaT3iyfYYTeKX09ge v8vKSzPmT/AVPEsFU8b3SJWUHIMtRtg5IlkpgiemVPk+MTDzh0CgYLbJ9UKQIZFgyDcE 8neQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uufcF3z2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30-v6si20491951pld.528.2018.05.23.21.36.29; Wed, 23 May 2018 21:36:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uufcF3z2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751814AbeEXEfL (ORCPT + 99 others); Thu, 24 May 2018 00:35:11 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:51906 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751789AbeEXEfI (ORCPT ); Thu, 24 May 2018 00:35:08 -0400 Received: by mail-it0-f68.google.com with SMTP id d10-v6so743834itj.1; Wed, 23 May 2018 21:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6AP3+7wKcoEvsOa4DIZcdZMEzMHbxrvqOBFwIWop0bA=; b=uufcF3z2XFkPeXxxwYaBVFb3Kp0i1OxFeKbCusnPZ1ji2VKd16LBNveVwknWQ+YkxX p5MZdbJbAPQGMnBYiRsHejFpm9oGDxXr7GaUvlIoMiNo5KeeL4XbvK1XRbJEiSWXWYnD y2LT+Q9g8Etlr3vNI5DA8odV+WazniQedtD8NEVZ9ZIZjKtXLzciB7xtjGAOkoV3Hlwz 49DF8hBZWNblxjXft9JszV+zewLHGm8PtbuNRa4CFqTEBm2dsa1atLZtI7NcESQXvAQM ysgcOCwvmwa5Lowdia5wQlmztCOgOUwh7IsNrZGM2GK7nOoC9Mk2HWZjaMFG+bSPa65w USuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6AP3+7wKcoEvsOa4DIZcdZMEzMHbxrvqOBFwIWop0bA=; b=s8LRo2gNocT9guQTAe28s+z6C/aP0njocazrI14gMF+F4k3wR6BI4l0mYH/tJZAhwc XAb3psLs8YSiXIf06CsH6BWoW7lJ2CCJQ4FP8MfvTqDlt9xy0UII8n6c6Q3z6V6nZA84 5uKlyc29NTQFAk25bDdRZcFhmZqARlLvPNHls4CVsNgDC4AO02BQckCNUzLk17jXmzW3 HK6HYq1VFlKRT0vhBAoZYH78+nejsuz3VdAL5Kr+scAwkNZMSBVTbpXpzvcZIxz/41jp +UUEtuoI/o/JT1NaFtS2wnOi3+WZbtAvh7P4ZqG/YEviUHpYznctHJemwlzhfJJHrdRp 2KMQ== X-Gm-Message-State: ALKqPwdMr3XrIO3IXA3H6YmIOPj3XM+OprKPzf6s9UXhXbH1cJdYoUnz BvOvowmallBgnCp8necy+IjivvIZNOLv79rMF4I= X-Received: by 2002:a24:a90d:: with SMTP id r13-v6mr7619801ite.119.1527136508230; Wed, 23 May 2018 21:35:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:7f83:0:0:0:0:0 with HTTP; Wed, 23 May 2018 21:35:07 -0700 (PDT) In-Reply-To: References: From: Kyungtae Kim Date: Thu, 24 May 2018 00:35:07 -0400 Message-ID: Subject: Re: KASAN: use-after-free Read in vgacon_invert_region To: b.zolnierkie@samsung.com Cc: Byoungyoung Lee , DaeRyong Jeong , linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (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 0x100000 (i.e., 0xffff880000100000 in this case). We think, however, a certain memory area starting from 0x100000 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 ffff880000100000 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:00007f720c4bec68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f720c4bf6cc RCX: 00000000004497b9 RDX: 0000000020000040 RSI: 000200000000541c RDI: 0000000000000013 RBP: 000000000071bf58 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 0000000000005aa8 R14: 00000000006ecb48 R15: 00007f720c4bf700 The buggy address belongs to the page: page:ffffea0000004000 count:0 mapcount:-127 mapping:0000000000000000 index:0x0 flags: 0x0() raw: 0000000000000000 0000000000000000 0000000000000000 00000000ffffff80 raw: ffff88013fff9300 ffff88013fff9300 0000000000000008 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8800000fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8800000fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff880000100000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff880000100080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff880000100100: 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 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 ffff880000100000 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:00007f720c4bec68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 > RAX: ffffffffffffffda RBX: 00007f720c4bf6cc RCX: 00000000004497b9 > RDX: 0000000020000040 RSI: 000200000000541c RDI: 0000000000000013 > RBP: 000000000071bf58 R08: 0000000000000000 R09: 0000000000000000 > R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff > R13: 0000000000005aa8 R14: 00000000006ecb48 R15: 00007f720c4bf700 > > The buggy address belongs to the page: > page:ffffea0000004000 count:0 mapcount:-127 mapping:0000000000000000 index:0x0 > flags: 0x0() > raw: 0000000000000000 0000000000000000 0000000000000000 00000000ffffff80 > raw: ffff88013fff9300 ffff88013fff9300 0000000000000008 0000000000000000 > page dumped because: kasan: bad access detected > > Memory state around the buggy address: > ffff8800000fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > ffff8800000fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>ffff880000100000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff > ^ > ffff880000100080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff > ffff880000100100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff > ============================================================== > > > Thanks, > Kyungtae Kim