Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1516991ybb; Sat, 11 Apr 2020 05:27:12 -0700 (PDT) X-Google-Smtp-Source: APiQypJKi/nsH0LQv1OKU+M9Q1Q0ewBqoRkGjKGY/y8gMoIGiaxQB1U8Js/5Ale6rfNHfgMkxU+v X-Received: by 2002:a05:6214:294:: with SMTP id l20mr9286639qvv.46.1586608032217; Sat, 11 Apr 2020 05:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586608032; cv=none; d=google.com; s=arc-20160816; b=Rul//1wvpwQfD5kaaHlg7t6u1IJ3AjLcnNO9RXfOKbBYhmP75957bf2whqrURpSNJF kvbQYjX4JQGBLikSEpk2QMnnP9ESTke0G8TpujLnaPGGw4vfXd2V2RWTn+OOa8MKGETF pwLR9ZGrQAA68OWYrQDJwM5EkaP9Eqrqlb+txzU6yuhkBdBp0evanevcdvhhmvUAO+df aVRIWw8rtF2h3ebtPr8Nko+pfJ5Ayk9pjnHqI+sFMsbNzsbH36A5Y79WVoWJvKIQuzbl Gq+0tIW2kcycEQ72yPIxhvJ/gFB2W9hv/HXftjr2+ewNYni37VJJ0eIjqVLYPxoMSGiV Oecw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vZk3UJco+AMuvfo3awAaXctcCyuoPesx+COJTQo3rsQ=; b=E3i+B8zO6Md+LOqOtf/xopE2uXhH3tqqEqTuzqMkDPrWv5dZGn9pUK+lNjZmYajqkr m3aA0imuL1JE3IygbKT9zRMeGpHRuF5h59iVZN9mD4ftVllNb/C3eHUyDTsqbYMdFNqe 5BLm/DlHAG5NokpxBge07TwI8ASaBSLsZQLlVmKYKAGaQn5CFlGD/SsIKAIfmjV5xYWE PGfXMhpJ7SAd9h7HuzNOYnb+SoubBe1osS69WNYoIeY7ZXydkGfkpkZsRWakPCYyJRXb K18Dmw1V2J6piHWa+VnjBbpMeOYK4pHMEujV3xH+h6mK7qPmoPXYcJHh7VPwKBmuOTIJ rhuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kzUaV2yg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f92si2689820qtd.341.2020.04.11.05.26.58; Sat, 11 Apr 2020 05:27:12 -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=@kernel.org header.s=default header.b=kzUaV2yg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727979AbgDKMQW (ORCPT + 99 others); Sat, 11 Apr 2020 08:16:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:50526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727500AbgDKMQS (ORCPT ); Sat, 11 Apr 2020 08:16:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B423220692; Sat, 11 Apr 2020 12:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607378; bh=zCkvkTQCkcQDa2WlhjVa5LsJRvCTWWWgZ54hpuWZ54A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kzUaV2ygrOftZEDlek+B7/4bHB5bDJd51t6A8ZQEr8AXVFNJDIIT3cdyS1Yjd6gad gyzq64W59NmYY0VPq3U0S30lZHw8B37ghxBDK5maSMQc1c1nUcxID11+k8g39bh6JS XFdvWJtCBYwP9zkLbggLud8l3mxOeq7g8aVOMEWM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+732528bae351682f1f27@syzkaller.appspotmail.com, Qiujun Huang , Sam Ravnborg , Daniel Vetter Subject: [PATCH 4.19 48/54] fbcon: fix null-ptr-deref in fbcon_switch Date: Sat, 11 Apr 2020 14:09:30 +0200 Message-Id: <20200411115513.529862176@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115508.284500414@linuxfoundation.org> References: <20200411115508.284500414@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiujun Huang commit b139f8b00db4a8ea75a4174346eafa48041aa489 upstream. Set logo_shown to FBCON_LOGO_CANSHOW when the vc was deallocated. syzkaller report: https://lkml.org/lkml/2020/3/27/403 general protection fault, probably for non-canonical address 0xdffffc000000006c: 0000 [#1] SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000360-0x0000000000000367] RIP: 0010:fbcon_switch+0x28f/0x1740 drivers/video/fbdev/core/fbcon.c:2260 Call Trace: redraw_screen+0x2a8/0x770 drivers/tty/vt/vt.c:1008 vc_do_resize+0xfe7/0x1360 drivers/tty/vt/vt.c:1295 fbcon_init+0x1221/0x1ab0 drivers/video/fbdev/core/fbcon.c:1219 visual_init+0x305/0x5c0 drivers/tty/vt/vt.c:1062 do_bind_con_driver+0x536/0x890 drivers/tty/vt/vt.c:3542 do_take_over_console+0x453/0x5b0 drivers/tty/vt/vt.c:4122 do_fbcon_takeover+0x10b/0x210 drivers/video/fbdev/core/fbcon.c:588 fbcon_fb_registered+0x26b/0x340 drivers/video/fbdev/core/fbcon.c:3259 do_register_framebuffer drivers/video/fbdev/core/fbmem.c:1664 [inline] register_framebuffer+0x56e/0x980 drivers/video/fbdev/core/fbmem.c:1832 dlfb_usb_probe.cold+0x1743/0x1ba3 drivers/video/fbdev/udlfb.c:1735 usb_probe_interface+0x310/0x800 drivers/usb/core/driver.c:374 accessing vc_cons[logo_shown].d->vc_top causes the bug. Reported-by: syzbot+732528bae351682f1f27@syzkaller.appspotmail.com Signed-off-by: Qiujun Huang Acked-by: Sam Ravnborg Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20200329085647.25133-1-hqjagain@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/core/fbcon.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1243,6 +1243,9 @@ finished: if (!con_is_bound(&fb_con)) fbcon_exit(); + if (vc->vc_num == logo_shown) + logo_shown = FBCON_LOGO_CANSHOW; + return; }