Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1157325ybf; Thu, 27 Feb 2020 06:05:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxLFf/B39rJ1Ujh4QAal0AzMZNdBLHTOv3kVgA1QN8zlDKMFhwOzY/uW+gXOlCYAh0GBrwc X-Received: by 2002:a9d:61c5:: with SMTP id h5mr3493275otk.85.1582812317506; Thu, 27 Feb 2020 06:05:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582812317; cv=none; d=google.com; s=arc-20160816; b=XlLdrUzl0hOORGIqH4+okjMmqRJ2jWkH+RYaZ8zzUu/gjdnygeWOCUWlFTZEWBE7AS tNbf9oGIMHE7miDwpsi0nv/ftxQcso6QkN0vOu5aFxCtQe1w5Ix9IlgivNz/8UasvnSS 3Z3jpdlF60w5frMwahCQXJIBCdHPCNUsHpAcVBJ/SEECvymhuiZNcERLTRrfVkVhzv+s yS0iFehzLfR53U4AYREqQqIc1H9UIqO568keOQqC5GVDW8jUL70WU5Be3NfiRkXT5THJ Jo4H3ghNk4/Mqb9qddzsRqtZfSVhYSkRDYPBfH9HHLxhpSiCq7a150cYXC2cImpJ/JSS S+XA== 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=9OE6yP3eplQuCzPbCtdnJd+qCiNrxGgQRbRLQvqquTc=; b=KRjza9oYxgVx0mteljsAAIW48dl2F8+M6jm6a2KA85Lyy9nFlo278gl4+LsjadJLaq 5O7Tmh/r2w3I1QE/yGYGe0Kjb5kLg5mdtUPw1mNiiYWl5F3fCMdqdJh1hBciWlZVpGe8 LHW3UbIJv7KPVZTuIJfx2AuCMp1FWAtqgZChmX1E1P76K+WoXw+B7LYo9iZITs0heGbY NmZw4UvphD49uM725PWuDrmpVHye6zaoTG8raUNGFzSuJFbfSGpVkl0eQLAaGZibdG9+ QqOcL8ELQJkDTprCXdy3eeBHv8WLZ6RS8sxZCQAN81qSxrMOxecmSURjgabnN1vvAo47 nN9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nqSE5O+w; 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 a20si1590427otf.271.2020.02.27.06.04.52; Thu, 27 Feb 2020 06:05:17 -0800 (PST) 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=nqSE5O+w; 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 S1733227AbgB0OCz (ORCPT + 99 others); Thu, 27 Feb 2020 09:02:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:37792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733221AbgB0OCw (ORCPT ); Thu, 27 Feb 2020 09:02:52 -0500 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 9AC0E24656; Thu, 27 Feb 2020 14:02:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812172; bh=ZznlblGTBFbuds+Sph5WVVJsc6irhIrrzO9HTsUYnug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nqSE5O+w5PE3lMJTnWYGOsyqlWq3MCyawoRs4k3ay4OhAmYVOU1RGnaTyvIEX1/Tr BcdSpmykivnY0jo0ltQYCBCGMnCEnkUu4x0ItIzWWS79IiaWB3AgJdfyUQEK8ukU4f tbl6jDp+zxNcCerrZsoV4UCmqcZubdto59rtOAoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Pitre , Lukas Wunner Subject: [PATCH 4.19 13/97] vt: fix scrollback flushing on background consoles Date: Thu, 27 Feb 2020 14:36:21 +0100 Message-Id: <20200227132216.796677344@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132214.553656188@linuxfoundation.org> References: <20200227132214.553656188@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: Nicolas Pitre commit 3f4ef485be9d54040b695f32ec76d0f1ea50bbf3 upstream. Commit a6dbe4427559 ("vt: perform safe console erase in the right order") provided fixes to an earlier commit by gathering all console scrollback flushing operations in a function of its own. This includes the invocation of vc_sw->con_switch() as previously done through a update_screen() call. That commit failed to carry over the con_is_visible() conditional though, as well as cursor handling, which caused problems when "\e[3J" was written to a background console. One could argue for preserving the call to update_screen(). However this does far more than we need, and it is best to remove scrollback assumptions from it. Instead let's gather the minimum needed to actually perform scrollback flushing properly in that one place. While at it, let's document the vc_sw->con_switch() side effect being relied upon. Signed-off-by: Nicolas Pitre Reported-and-tested-by: Lukas Wunner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/nycvar.YSQ.7.76.2001281205560.1655@knanqh.ubzr Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -936,10 +936,21 @@ static void flush_scrollback(struct vc_d WARN_CONSOLE_UNLOCKED(); set_origin(vc); - if (vc->vc_sw->con_flush_scrollback) + if (vc->vc_sw->con_flush_scrollback) { vc->vc_sw->con_flush_scrollback(vc); - else + } else if (con_is_visible(vc)) { + /* + * When no con_flush_scrollback method is provided then the + * legacy way for flushing the scrollback buffer is to use + * a side effect of the con_switch method. We do it only on + * the foreground console as background consoles have no + * scrollback buffers in that case and we obviously don't + * want to switch to them. + */ + hide_cursor(vc); vc->vc_sw->con_switch(vc); + set_cursor(vc); + } } /*