Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2512898imm; Mon, 24 Sep 2018 05:44:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV62bsyxD8YBSjZdeGMwPrtWUaZrAjOtVGsFsyBpqQeVCx3rW16vAgzCU/wfSFcr6n0Lk2QEW X-Received: by 2002:a63:3e06:: with SMTP id l6-v6mr2053837pga.96.1537793046281; Mon, 24 Sep 2018 05:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793046; cv=none; d=google.com; s=arc-20160816; b=iKo8foxIS3NEBxVCDDE9CT47t0CUjQAu05gUGEYgmleG16EA5eIfBYh3c/oimCiYnw uh4bfr+e8KScY1EYJ+ApSo8Q2NcaDfrdCMfQE2bbSFnHWsYiLqUCM3PJEqPzzc9QjwgQ heOLl12M2vSo9we7TlSbXiBtsfAORvhQPDZ3WmZwPBPanhb3DhK0/oLx38QTY0jC93AJ w0/HmNkUMq4NPBZZQ/iFSAy9vxcox/hQK9B5gd1igFQQtkurzl8xWkkz1MbVRF5cNO+/ jSHKTt2B6msxxXAOlb+E4ct/aXK4o4dToKdGvqnlImUgj2M5Vkje43AvG76BIca8XyVx 6ZRw== 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; bh=FiaiwvcBDXcBZ3B0IJ2r7FAHk5+peoZR4ID6yzys6Gs=; b=dg8vmxxtp+zB3LptEutpZT6x1Np/JTosmtUsGvo21ZlY4x7oythtL5E8t7DIpZ2+lM 6ICYxLKbJSY3GyjV04rWyQqFBvN2uzJOVrmTdVf6hR3/Bu1PQRpYSmgzA4Vd+QzlR6DX wD/dNM5RAlI9t7GM2Of/lWLznrTqhPA/2gewt8JoIc7XZoLnuTbI5LiEH2cRly+4xLXt zSADGwslNwle/BfqaVTdAo1wvqQXZlL0rmhcwhoSxIMWFaf+Zdjttv9aMGWdeFIRCge3 5NxBcz9Iar+1Nft8VR63dmYIy7DsgHyMwHCnhwJm3JUNi8LPICh8zQgzN6qXFd8HJ6fm OtRw== ARC-Authentication-Results: i=1; mx.google.com; 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 u36-v6si6033311pga.185.2018.09.24.05.43.51; Mon, 24 Sep 2018 05:44:06 -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; 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 S2388815AbeIXSni (ORCPT + 99 others); Mon, 24 Sep 2018 14:43:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59172 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729543AbeIXSnh (ORCPT ); Mon, 24 Sep 2018 14:43:37 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EF1AC109E; Mon, 24 Sep 2018 12:41:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Sasha Levin Subject: [PATCH 4.18 179/235] tty: fix termios input-speed encoding when using BOTHER Date: Mon, 24 Sep 2018 13:52:45 +0200 Message-Id: <20180924113122.583646928@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold [ Upstream commit 1cee38f0363a88db374e50b232ca17b9a4c12fa0 ] When the termios CIBAUD bits are left unset (i.e. B0), we use the same output and input speed and should leave CIBAUD unchanged. When the user requests a rate using BOTHER and c_ospeed which the driver cannot set exactly, the driver can report back the actual baud rate using tty_termios_encode_baud_rate(). If this rate is close enough to a standard rate however, we could end up setting CIBAUD to a Bfoo value despite the user having left it unset. This in turn could lead to an unexpected input rate being set on subsequent termios updates. Fix this by using a zero tolerance value also for the input rate when CIBAUD is clear so that the matching logic works as expected. Fixes: 78137e3b34e1 ("[PATCH] tty: improve encode_baud_rate logic") Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/tty_baudrate.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/tty/tty_baudrate.c +++ b/drivers/tty/tty_baudrate.c @@ -157,16 +157,20 @@ void tty_termios_encode_baud_rate(struct termios->c_ospeed = obaud; #ifdef BOTHER + if ((termios->c_cflag >> IBSHIFT) & CBAUD) + ibinput = 1; /* An input speed was specified */ + /* If the user asked for a precise weird speed give a precise weird answer. If they asked for a Bfoo speed they may have problems digesting non-exact replies so fuzz a bit */ - if ((termios->c_cflag & CBAUD) == BOTHER) + if ((termios->c_cflag & CBAUD) == BOTHER) { oclose = 0; + if (!ibinput) + iclose = 0; + } if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER) iclose = 0; - if ((termios->c_cflag >> IBSHIFT) & CBAUD) - ibinput = 1; /* An input speed was specified */ #endif termios->c_cflag &= ~CBAUD;