Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp76953rdb; Sun, 14 Jan 2024 07:16:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeIaq5WYCMYHsUTt+UwQaMTef0yxePEzcg825c8fVmNamCAUbAC+JpqgebhT0TsiCaxPFv X-Received: by 2002:a05:6e02:503:b0:360:63a2:2fca with SMTP id d3-20020a056e02050300b0036063a22fcamr5126501ils.28.1705245377832; Sun, 14 Jan 2024 07:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705245377; cv=none; d=google.com; s=arc-20160816; b=L2RzPX4Uso8V793mdyVRk5I88OGA/va69e0Y/kaJDA+PdNNU+hOzOA34+8ti15ARsb wNNOJ3Lc6cn1byH98e7x1RXidT7ri2wsV9AFGWDn8zdzWLYSIxrk6U6w6e7ZMhg/94az GsXrO9oT5JaPbXXz1Ka95BwUbDXWo9dO//VAp9d5bnGdiV7rQq+KBRBbWpnx75yiYNeM /whf7m859r8u49zIVCRzusJhC7iBVpnTDm6WERnkPQ0431dhCvAynRsiKmrMY9TKf9AN Q1jgVB1qDyaW0lyzEuHkFMoIUaYL50hWfv+kcb2+qmT0dbZaBWE80u/luyQ9lyIVBXrp tXWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=E6IA3TOK5uYYlnG2dPnLpORoQUsvlcQaWHX7grVWJqc=; fh=Jvkufsc2nIb73xtXH7Ycpka66L0FE2iFcmPkn0KQ/Ls=; b=j1RMhsnxB/SMg10jLOfd6y8ozD9tozvVUBpYHSm8Kn3/dyx2Cr33aUah8njTHipmO1 AAArpr3WktkkAk54ngsAIhmU4dP7TzeiBDJJBgq5Urp4htxeFfN7tj9bjkiyJSIXxscG wMQyt9xrejxTan+gpbpvvl1ar5ri/CRjSX3YQxN+S1TCKCPyvjxpDYS6e9j9aSbSMN7X 6Q3KbB/AVQCFNF8LCbOwxOxo7Zw3RB7WT1+9QxOAEx3VZ+NGtOdzOwBZmARuHKPpcgwh LrM7eGa/xO6pyZFtT9RLS1Y5H9nltqSigrtzIfC9RKn4kjhSykHysneJhWULFUCQ0LWX rFOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@uchuujin.de header.s=h header.b="wwAx7v5/"; spf=pass (google.com: domain of linux-kernel+bounces-25495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25495-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a63-20020a636642000000b005cd84983a5asi7113702pgc.721.2024.01.14.07.16.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 07:16:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@uchuujin.de header.s=h header.b="wwAx7v5/"; spf=pass (google.com: domain of linux-kernel+bounces-25495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25495-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B4373B2139B for ; Sun, 14 Jan 2024 15:16:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3395F2581; Sun, 14 Jan 2024 15:15:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=uchuujin.de header.i=@uchuujin.de header.b="wwAx7v5/" Received: from mxout.uchuujin.de (82.245.131.213.static.inetbone.net [213.131.245.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC09E7E; Sun, 14 Jan 2024 15:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=uchuujin.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uchuujin.de Received: by neutronstar.dyndns.org (Postfix, from userid 1000) id CB1231430A3FB; Sun, 14 Jan 2024 16:08:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=uchuujin.de; s=h; t=1705244902; bh=VqBi8P/8QXs0eKF0LplhfgJL8qxug0zUG0douZc9RAY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wwAx7v5/neFDUkBsQTcTZ78/yUjzEN0Z11qQHiEbyZi9Dl29wYtHyG1cM5UdAJVl0 raj+fsVZ8VPTbjamL6s4m4+yyTh0dnpVXdK5UYxV7b+SxegdLVlElFp2yTXpjjIlFW ogsp4vi1UIGIby+feVdkSpWGpJXtQztc064UKmBL7dz5mLNmOeRxhX55v46L2aEbVa 3Hd+oz11FKYNj3Fe6sFzLaC0MHr78BBBDWdvf8mXIwPlGYz7MoY2oVLQpdRcY2qBbZ rbh1lSNb7MZuMo1CDo1ESZ2fv5EJvEjV/O3g5LztMDnEywKonh6uJovX5FeqyH1v01 0uKE+YMwWFQnA== Date: Sun, 14 Jan 2024 16:08:21 +0100 From: Martin Hostettler To: Jiri Slaby Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Nicolas Pitre , Adam Borowski , Egmont Koblinger Subject: Re: [PATCH 3/4] vt: ignore csi sequences with intermediate characters. Message-ID: References: <20181215143423.4556-1-textshell@uchuujin.de> <20181215143423.4556-4-textshell@uchuujin.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Dec 14, 2023 at 01:10:07PM +0100, Jiri Slaby wrote: > On 15. 12. 18, 15:34, Martin Hostettler wrote: > > Various csi sequences contain intermediate characters between the > > parameters and the final character. Introduce a additional state that > > cleanly ignores these sequences. > > > > This allows the vt to ignore these sequences used by more capable > > terminal implementations such as "request mode", etc. > > > > Signed-off-by: Martin Hostettler > > --- > > drivers/tty/vt/vt.c | 11 ++++++++++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c > > index 448b4f6be7d1..24cd0e9c037b 100644 > > --- a/drivers/tty/vt/vt.c > > +++ b/drivers/tty/vt/vt.c > > @@ -2023,7 +2023,7 @@ static void restore_cur(struct vc_data *vc) > > } > > enum { ESnormal, ESesc, ESsquare, ESgetpars, ESfunckey, > > - EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd, > > + EShash, ESsetG0, ESsetG1, ESpercent, EScsiignore, ESnonstd, > > ESpalette, ESosc }; > > /* console_lock is held (except via vc_init()) */ > > @@ -2259,6 +2259,10 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) > > vc->vc_par[vc->vc_npar] += c - '0'; > > return; > > } > > + if (c >= 0x20 && c <= 0x2f) { > > + vc->vc_state = EScsiignore; > > + return; > > + } > > vc->vc_state = ESnormal; > > switch(c) { > > case 'h': > > @@ -2421,6 +2425,11 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) > > return; > > } > > return; > > + case EScsiignore: > > + if (c >= 20 && c <= 0x3f) > > Staring at the current code, I am confused as I cannot find out why "20". > Was this supposed to be 0x20 (the same as above -- 0x20 is SPACE and that > _is_ sensible)? Or why was this arbitrary 20 chosen? I'm not sure what happend here. But i agree this should be 0x20 or it should be removed (see below) but not decimal 20. This is supposed to match what ECMA-48, xterm and the usual terminal parsers do. The most important behavior here is that common usages work, which fortunatly it seems this did not break. CAN, SUB and ESC are in the range 20 to 0x20, but they are already handled before the switch. And 0x20 to 0x3f are properly ignored. I think that is all that really matters for terminal interoperablity. When comparing with how xterm handles this state [1], xterm ignores more characters. If we want to match that, i think we would want to remove the whole `c >= 20 &&` part. xterm ignores 0-4, 6, 16-23, 25, 28-0x3f and 127. Or in other words, it does not ignore 5 (ENQ), 7 (BEL), 8 (BS), 9 (TAB), 10-13, 14 (Shift out), 15 (shift in), 24 (CAN), 26 (SUB), 27 (ESC) and 0x40-126 This code already handles 7, 8-15, 24, 26, 27, 127 before the switch. The code also does not implement ENQ so effectivly ignoring it is the same as handling it. But if we match xterm here, we should also match it in other cases like ESsquare and ESgetpars. So in summary i think we should fix this, but the fix does not need any backporting to stable kernels. Do you want to send a patch to fix this, or should i send a fix. Do you have thoughts in which of the two plausible directions we should change the code? [1] https://github.com/ThomasDickey/xterm-snapshots/blob/3a151f2f31358d135204c8f90759f3cfd0697b9e/VTPrsTbl.c#L5290 > > thanks, > -- > js > suse labs >