From patchwork Tue Oct 11 01:43:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scot Doyle X-Patchwork-Id: 9370057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A9C7607FD for ; Tue, 11 Oct 2016 01:50:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DCE928D94 for ; Tue, 11 Oct 2016 01:50:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 003F128D96; Tue, 11 Oct 2016 01:50:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6760028D94 for ; Tue, 11 Oct 2016 01:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752849AbcJKBuK (ORCPT ); Mon, 10 Oct 2016 21:50:10 -0400 Received: from mx1.scotdoyle.com ([162.253.176.241]:58728 "EHLO mx1.scotdoyle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752636AbcJKBuJ (ORCPT ); Mon, 10 Oct 2016 21:50:09 -0400 X-Greylist: delayed 370 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Oct 2016 21:50:09 EDT Received: by mx1.scotdoyle.com (Postfix) id 7D6731F0012F; Tue, 11 Oct 2016 01:43:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx1.scotdoyle.com (Postfix) with ESMTP id DB8DB1F40011; Tue, 11 Oct 2016 01:43:54 +0000 (UTC) Date: Mon, 10 Oct 2016 20:43:53 -0500 (CDT) From: Scot Doyle To: Dmitry Vyukov cc: Greg Kroah-Hartman , Peter Hurley , Jiri Slaby , LKML , plagnioj@jcrosoft.com, tomi.valkeinen@ti.com, jean-philippe.brucker@arm.com, linux-fbdev@vger.kernel.org, "Eric W. Biederman" , syzkaller Subject: Re: tty, fbcon: use-after-free in fbcon_invert_region In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 7 Oct 2016, Dmitry Vyukov wrote: > On Sat, Sep 3, 2016 at 9:20 PM, Dmitry Vyukov wrote: > > Hello, > > > > The following program causes use-after-free in fbcon_invert_region: > > > > https://gist.githubusercontent.com/dvyukov/d657f9a9ca39f34c430dcf63ec1153ac/raw/04e1b94aef0fc9eb770d11373b568980ecaa7f34/gistfile1.txt > > > > ================================================================== > > BUG: KASAN: use-after-free in fbcon_invert_region+0x1cc/0x1f0 at addr > > ffff88006cc3f51e > > Read of size 2 by task a.out/4240 > > CPU: 0 PID: 4240 Comm: a.out Not tainted 4.8.0-rc3-next-20160825+ #10 > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 > > ffffffff886b6fe0 ffff88003699f790 ffffffff82db3759 ffffffff8a0ae640 > > fffffbfff10d6dfc ffff88003e800100 ffff88006cc3f500 ffff88006cc3f520 > > 0000000000000000 ffff88006cc3f51e ffff88003699f7b8 ffffffff81809e7c > > > > Call Trace: > > [] __asan_report_load2_noabort+0x14/0x20 > > mm/kasan/report.c:325 > > [] fbcon_invert_region+0x1cc/0x1f0 > > drivers/video/console/fbcon.c:2750 > > [] invert_screen+0x192/0x630 drivers/tty/vt/vt.c:470 > > [< inline >] highlight drivers/tty/vt/selection.c:50 > > [] clear_selection+0x4c/0x60 drivers/tty/vt/selection.c:76 > > [] hide_cursor+0x24e/0x2d0 drivers/tty/vt/vt.c:599 > > [] redraw_screen+0x2e7/0x840 drivers/tty/vt/vt.c:682 > > [] vc_do_resize+0xebc/0x1160 drivers/tty/vt/vt.c:952 > > [] vt_resize+0xaa/0xe0 drivers/tty/vt/vt.c:992 > > [< inline >] tiocswinsz drivers/tty/tty_io.c:2378 > > [] tty_ioctl+0x10c1/0x21e0 drivers/tty/tty_io.c:2892 > > [< inline >] vfs_ioctl fs/ioctl.c:43 > > [] do_vfs_ioctl+0x18c/0x1080 fs/ioctl.c:675 > > [< inline >] SYSC_ioctl fs/ioctl.c:690 > > [] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:681 > > [] entry_SYSCALL_64_fastpath+0x23/0xc1 I wonder if the text selection is outside the newly resized vc? Does this patch help? Tested-by: Dmitry Vyukov --- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- vt.c 2016-10-11 00:32:43.079605599 -0000 +++ vt.c.new 2016-10-11 00:36:12.744650759 -0000 @@ -874,6 +874,9 @@ if (!newscreen) return -ENOMEM; + if (vc == sel_cons) + clear_selection(); + old_rows = vc->vc_rows; old_row_size = vc->vc_size_row;