Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2806098lqo; Tue, 14 May 2024 09:36:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDIxJNBODIusYRaLQpq4hJncPxZxKPjWYJUu8t78Xg2uTFx/NiHFWNN16I55r05hjip4UwgdNE063fT41ORKYH7NEsf09E2W9WphvHuw== X-Google-Smtp-Source: AGHT+IGgn0BRxQ6EZVnNuDX75GsuPEdF4XDLg5RkzWZjK+V+N6NNA80zJbwQFZSsf5vvzYscJe4S X-Received: by 2002:a92:c561:0:b0:36c:4eb4:3afb with SMTP id e9e14a558f8ab-36cc1503186mr153681905ab.32.1715704595535; Tue, 14 May 2024 09:36:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715704595; cv=pass; d=google.com; s=arc-20160816; b=dMNNO9AGez/GinTEHBvx+hUAlXXurNsYk32gxz1hRDRyVpmoGh/mPxTg78M38SIb+J qHeGARVDeBDu0wflz3JCWq9qUqShO0tAGajjmLv7V1Y4iEEynZiJ7Rf632XooLHRIAxj +C+BbeZVrzJec7AvzKK6pAACUi8Xfpl1I9ssGprQCNZHAjpvQ0Yyeom8fArnwKrAJwpX ckVgdW1YAjQgr91YvlwxoS5zosmHXGXNEq99skOcrLJqoe8GbY1heVXNCWpMm5VxcvPp eBzrpV/jY+XPAXk9aAzPuKKiDhHfrgUSlkjItEQIlCOazE4DW1Xs+OhIzEV3+m+Z9IYr QY+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=zCh82s+8fIh8SutCb0WYETRsox/oHYav3r0OwQvqYtE=; fh=gHH4WhV3zhzx5Wnqt2nAHyovM8+kG7Bv6RnBfnrkla4=; b=y6Yh3P9andJQuvtAqPTwPiMrBb5BXOhRfNTgD8uE43VG8wrnxWMy9PPl3kc60cIk2i 4N+lgzDYjUJx3YJV5kwzEsFuBmNIb4PLSI0Bh5oPAlm57jz/Gxw4PeqLru4e2nsqe4Sx sWkynQDTRf1ESB9yINYVzIQ5Byn0J7lpsi6wLzucqiqowHnMhpeq4B4cMNff7jQtA6ig GvkLIQFqV/D+6y+1X53iEre/HqIH9p6lxu8+nIjUnr4nrCIwSZpsrxuQs64J3piHj7+5 CI6y520KVJeMDSQglLNGZ1nHLpfQatqXqudBVz4lbBe/L7vPb1LO29BZgE1qNLDzp8mj ltEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fWX2K2SC; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-178756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6357311686esi10429873a12.803.2024.05.14.09.36.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 09:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178756-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=@intel.com header.s=Intel header.b=fWX2K2SC; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-178756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 A57BAB23174 for ; Tue, 14 May 2024 13:32:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E96C6144D34; Tue, 14 May 2024 13:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fWX2K2SC" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 580031448FA; Tue, 14 May 2024 13:30:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715693455; cv=none; b=l0zDWYa7JakuDpjpD9k9/hQTzbJBvUxHubWvh6Q0DuZU17LFWwDtMarueXk9irGkm8wrG2gGdeDXinzGWliVoOEFfGWcbW0wynKdHH9ysnzHBZadpd3/RocwNI5lEWm4BlVVpcWoqA2cIyRd1FpVVxuCFiRZM/b+f9rxoLI3g+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715693455; c=relaxed/simple; bh=nV9cCdyWa6uNoKVhoHvsrtVk11wlmfVkj3k9QaXbYy8=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=cidFAO7b8erAkPhvhqSTwyBmUTRU/2wsNp+JDsKFWvG3NugceD8PktkL+8pdS3ljPuy8CvTOeUqCtz1BecZUS6UCLh/B3Ec3gjUf+6HbCHHBbWvvKSjReRMcH0kkq9/NyDWZchZSxNthG2l62emEJoAFyZNAGqYC+nTqRBbSRss= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fWX2K2SC; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715693453; x=1747229453; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=nV9cCdyWa6uNoKVhoHvsrtVk11wlmfVkj3k9QaXbYy8=; b=fWX2K2SCx9RqFByrqCHjCTJYkTSeAecl0RpmidKnVXD1cC50jAL/zdDD E2dojVx/LXrTjyut51butn/xH9+Fr1ukAT29vV/cVkgr8YlFOPPLjZXak N+rDCTG9yEhZGP5c4qbWEFYfkf9z9oEY21GiB+5QeRJgo6jhBXHRDt2Dh cDxhINqz7FCUkd1nyFh+WPKKHdkm/Hk1oTe6sdECaKiE9/O102VT3b9EO Vn69dUsDiXHx/2XONZfhwT+4rnd9mYyOiU8bDvQ5dgI01OcDUyeDcTcIY QzHHAs4UYuK2qrj4318FBojBOUQjLUdPCAYgn8b7H9E5Dwef7n3ANUPtP Q==; X-CSE-ConnectionGUID: f8KNrwTyQ/O0p9Z4uZhWlA== X-CSE-MsgGUID: Z5CdlS0WTtS0SW4DNYCQbA== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="11507725" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="11507725" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 06:30:52 -0700 X-CSE-ConnectionGUID: E8HEEfvkQ8y2UtObp/BVIQ== X-CSE-MsgGUID: hOQLxRn9QuK8XMwaYAWxlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="30701483" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 06:30:49 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Tue, 14 May 2024 16:30:41 +0300 (EEST) To: Vadym Krevs cc: Andy Shevchenko , Bagas Sanjaya , Linux Kernel Mailing List , Linux Regressions , Linux Serial , Gilles Buloz , Greg Kroah-Hartman , Jiri Slaby Subject: Re: [regression] [bisected] commit 6bb6fa6908ebd3cb4e14cd4f0ce272ec885d2eb0 corrupts data sent via pseudoterminal device In-Reply-To: <645803059.1237606.1715692880298@mail.yahoo.com> Message-ID: <386fae3e-5286-e13d-4171-3a6e87cb1567@linux.intel.com> References: <606328522.1205749.1715678929830@mail.yahoo.com> <6bfafddc-cf5b-4829-e09b-2622aaf83093@linux.intel.com> <645803059.1237606.1715692880298@mail.yahoo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323328-191811837-1715693441=:6875" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-191811837-1715693441=:6875 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 14 May 2024, Vadym Krevs wrote: > On Tuesday, 14 May 2024 at 12:03:25 BST, Ilpo J=C3=A4rvinen wrote: > =C2=A0 > > On Tue, 14 May 2024, Andy Shevchenko wrote: > >=C2=A0 > > > On Tue, May 14, 2024 at 12:28=E2=80=AFPM Vadym Krevs wrote: > > > > > > > > It's a standard setup for an out-of-the box default install of open= SUSE 15.5 with KDE. All tests done in Konsole with bash as shell. > > > > > > > > stty -a -F /dev/pts/1 > > > > speed 38400 baud; rows 57; columns 217; line =3D 0; > > > > intr =3D ^C; quit =3D ^; erase =3D ^?; kill =3D ^U; eof =3D ^D; eol= =3D ; eol2 =3D ; swtch =3D ; start =3D ^Q; stop =3D ^= S; susp =3D ^Z; rprnt =3D ^R; werase =3D ^W; lnext =3D ^V; discard =3D ^O; = min =3D 1; time =3D 0; > > > > -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts > > > > -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl = ixon ixoff -iuclc -ixany -imaxbel iutf8 > > > > opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0= bs0 vt0 ff0 > > > > isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop = -echoprt echoctl echoke -flusho -extproc > > > > > > Thank you! > > > > > > Yeah. SW flow control is enabled, but I don't see which character is > > > being used for that. Anyway, let's give Ilpo a chance to look into > > > this. > >=C2=A0 > > Thanks a lot for pinpointing the commit with bisect. It turns out this > > is a quite bad corruption bug and I'm quite surprised I didn't see (or > > notice) it while testing the patch. > >=C2=A0 > > Could you please test and confirm the patch below fixes the issue? > > -- > > [PATCH] tty: n_tty: Fix buffer offsets when looked ahead is used > >=C2=A0 > > When lookahead has "consumed" some characters (la_count > 0), > > n_tty_receive_buf_standard() and n_tty_receive_buf_closing() for > > characters beyond the la_count are given wrong cp/fp offsets which > > leads to duplicating and losing some characters. > >=C2=A0 > > If la_count > 0, correct buffer pointers and make count consistency too > > (the latter is not strictly necessary to fix the issue but seems more > > logical to adjust all variables immediately to keep state consistent). > >=C2=A0 > > Reported-by: Vadym Krevs > > Fixes: 6bb6fa6908eb ("tty: Implement lookahead to process XON/XOFF time= ly") > > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D218834 > > Cc: stable@vger.kernel.org > > Signed-off-by: Ilpo J=C3=A4rvinen > > --- > > drivers/tty/n_tty.c | 22 ++++++++++++++++------ > > 1 file changed, 16 insertions(+), 6 deletions(-) > >=C2=A0 > > diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c > > index f252d0b5a434..5e9ca4376d68 100644 > > --- a/drivers/tty/n_tty.c > > +++ b/drivers/tty/n_tty.c > > @@ -1619,15 +1619,25 @@ static void __receive_buf(struct tty_struct *tt= y, const u8 *cp, const u8 *fp, > > else if (ldata->raw || (L_EXTPROC(tty) && !preops)) > > n_tty_receive_buf_raw(tty, cp, fp, count); > > else if (tty->closing && !L_EXTPROC(tty)) { > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (la_count > 0) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (la_count > 0) { > > n_tty_receive_buf_closing(tty, cp, fp, la_count, true); > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (count > la_count) > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n_tty_receive_buf_closing(tt= y, cp, fp, count - la_count, false); > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cp +=3D la_count; > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (fp) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fp +=3D la_cou= nt; > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 count -=3D la_count; > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (count > 0) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n_tty_receive_buf_closing(tt= y, cp, fp, count, false); > > } else { > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (la_count > 0) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (la_count > 0) { > > n_tty_receive_buf_standard(tty, cp, fp, la_count, true); > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (count > la_count) > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n_tty_receive_buf_standard(t= ty, cp, fp, count - la_count, false); > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cp +=3D la_count; > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (fp) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fp +=3D la_cou= nt; > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 count -=3D la_count; > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (count > 0) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n_tty_receive_buf_standard(t= ty, cp, fp, count, false); > >=C2=A0 > > flush_echoes(tty); > > if (tty->ops->flush_chars) > > -- > > 2.39.2 >=20 > Yes, I've tested the patch against the 6.9.0-rc7-local-00012-gdccb07f2914= c kernel (last commit=C2=A045db3ab70092637967967bfd8e6144017638563c from Ma= y 8th)=C2=A0and it works just fine.=C2=A0 >=20 > Thank you very much for fixing the problem so quicky. >=20 > Kind regards, > Vadym >=20 > P.S.: Hopefully, Yahoo mail has actually sent this reply as plain text. Thanks for testing. Can I put your Tested-by tag into the fix? --=20 i. --8323328-191811837-1715693441=:6875--