Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1184771ybf; Thu, 27 Feb 2020 06:29:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxgRJtUFnMFkMBy+ngIkelT8hmJ2elr9+uoch8bwa0cz/1lBhAWpCH3axWG1yWu6VSe4RIm X-Received: by 2002:a9d:69ce:: with SMTP id v14mr3666306oto.248.1582813748260; Thu, 27 Feb 2020 06:29:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582813748; cv=none; d=google.com; s=arc-20160816; b=BPPMXBHe8zksu4ipcESCbb5LMa83ZAEg/3lKA2VJoDGwpAW9ruNrxamJbywsmVP4xs 4rMGPNttP0ZYpJD6hN3PZ8rtGEg+E3uIQiD4/den+2L6XS5sf2HVwufrr54K46AquA2X 6py3axT5HRiDjZ9iuG3l2MVHU0bInDqRv3nIuVqZwSRB58hlLlCUxZl7SdlUAcbeR9zp 0A2P5yzw9gK41YSixQ+18hsYQjaM6EprlFFI6jFMfkRq7fjMArCp+h+v9Wqb0x6zodvv Smk1B4Au0Ln09/m4V/wtQtMrPjKAj6O2cHhSO8GFEt3N72Mrdqz3c/vRU81pDmGf5VnK 7W0Q== 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=hTh9Akmvon3tiSlGvzbmOxylaLHJSPmuZH/3m2VbltnaFeJnPyHklqzA3DumCGJQhv eg8H50JpvfwzM2bGM46RqgIjH2DJuF9g1ikmVyBFvNT1oAPsHsnzir2cGWhbgUSYQ9if cLODR5SWYWiGcWeUFo96kshbO2dl3DEyy2tOToO3jjTU/O0MzwizC0F99zHoeYgccqhz mOqunAwAf6N9tQYit8zEQ8ZqxR4SFKrDuAXdsIv0N0Ue4avx8c0hGFaG6+nzOwuygb7N ttmM3LwZtJ0xGoF0M2ACU1f52D9GTRVExV09yoA3+oX0WfBiRsoOCp2hsvLH+1Zvbo4F Q2WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PtpYspro; 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 104si921630otj.252.2020.02.27.06.28.56; Thu, 27 Feb 2020 06:29:08 -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=PtpYspro; 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 S2387642AbgB0OHR (ORCPT + 99 others); Thu, 27 Feb 2020 09:07:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:44682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388040AbgB0OHP (ORCPT ); Thu, 27 Feb 2020 09:07:15 -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 06DD020578; Thu, 27 Feb 2020 14:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812435; bh=ZznlblGTBFbuds+Sph5WVVJsc6irhIrrzO9HTsUYnug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PtpYsproE1cueskiamM+XEJf/UGuQP2fBduP3yfQdwMfyvd2EKA3YJyg8ysdIYoa5 2pU4ftjh6qucHtn3UE6aNZda7QxFkFjZWL0sZLjRzfgxrvlWwn9CbJ4oKf9+YjEmMA h9DNVzo0rSV28XQazRrpY+Qf3G4jvH9GxnEmHZH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Pitre , Lukas Wunner Subject: [PATCH 5.4 017/135] vt: fix scrollback flushing on background consoles Date: Thu, 27 Feb 2020 14:35:57 +0100 Message-Id: <20200227132231.842760423@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132228.710492098@linuxfoundation.org> References: <20200227132228.710492098@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); + } } /*