Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp444625iog; Mon, 13 Jun 2022 06:07:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM1/zpcgKsNyUW/oujgARlCJtOIcustHR97WFZYp9rTkuS8I6pb6zmyCc9YdY9MEHt+N6e X-Received: by 2002:a17:902:f254:b0:164:1078:2c28 with SMTP id j20-20020a170902f25400b0016410782c28mr58263740plc.64.1655125659800; Mon, 13 Jun 2022 06:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125659; cv=none; d=google.com; s=arc-20160816; b=x1Dt6SeVqMCZH6CHaJohU5RcSkfgJkjBo4ClWpw5cZ0JqWnlFHR9z2lWbGSKR2CodE l9ubc0hayBb+RA0N7hgwf7ur2EloWfak+Y7+d5kEucci4PVIvMNmtQ6JUlbJXBpu3ACA 4LZp0yddgU3VnORYsI7yvom1EcjpZENEaOFpsblETGy2A0s5dooqRroowZLc+OD+aN6W 5lecnrxgCXiwk47LCM6gATzuBp2nY0jZt87MjKvGzB9P919IoYHFhqbr4Rn04zoAi5Wr 58C+uyA+523jfg4lQb9WUdoGa51YLDNV0xHMGp40IgWuJRA2AJESfwN0GG6KxarX/o4+ xLtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D9zscZBnFgRPF05ka3CegCiw1olo96cGcNUUWdGEZLQ=; b=lCy/TD4nKbq551gR8iRq8MtC4b/O2JIVs2CR7tkxie6j1bHXasu4OYaMbgIzuTVQPb aqsvXyXuE719O3WZKposVemfIyc9/zqPXaxy4qq3dpc44jmNeKnjSVQ+NHC3dRUsJHpy 1l/Yqss5v/ZNi2qcxjv2KuU/aV07kZ8Js4x+h0ciMpQoKF1gcPx3cn7NCN/G6us9Pw2t xtJzONyPFkMF391lZRpF+F/ESONP+H2kRAv6gb5HyPg1aR1RywvAXSNeidTXML35s2Ix MnxX1tcCmbjoxO4x2ULE8gnxoPU2ASJ7pKgzkhW4KG4WA9sZUpsDqMfIyPf1rGhyQULx ltaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ynqDCNVZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a637701000000b003fca2707583si9495095pgc.224.2022.06.13.06.07.25; Mon, 13 Jun 2022 06:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ynqDCNVZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350482AbiFMLBd (ORCPT + 99 others); Mon, 13 Jun 2022 07:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350223AbiFMKyq (ORCPT ); Mon, 13 Jun 2022 06:54:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E5855B8; Mon, 13 Jun 2022 03:30:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9863560F09; Mon, 13 Jun 2022 10:30:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC393C34114; Mon, 13 Jun 2022 10:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116226; bh=t5HIl67g2jwSScHPwn9iUau0Gi2bGRH/gEUJaM81zWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ynqDCNVZmwT/zGMAoPbyJ0jG/jKXDoqnMduquzyQ88cwVP0WhklISwbnNmZDY/3sa O92y45eX661UiHpCNrkQAjYDa10hxZ9eNu5UJMa5qeqFvt3fR/Q/5Gq4yGE6VaXCeT /EMFZ7w8eRDP2ld6TN4b8194BgFfVxcpjGuVPSTs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 4.14 154/218] serial: sh-sci: Dont allow CS5-6 Date: Mon, 13 Jun 2022 12:10:12 +0200 Message-Id: <20220613094925.264540003@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilpo Järvinen [ Upstream commit 9b87162de8be26bf3156460b37deee6399fd0fcb ] Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or CS6 to CS8. Set CSIZE correctly so that userspace knows the effective value. Incorrect CSIZE also results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout(). Fixes: 1da177e4c3f4 (Linux-2.6.12-rc2) Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220519081808.3776-6-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/sh-sci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 21f81dc08139..f7dd843a3eff 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2267,8 +2267,12 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, unsigned long max_freq = 0; int best_clk = -1; - if ((termios->c_cflag & CSIZE) == CS7) + if ((termios->c_cflag & CSIZE) == CS7) { smr_val |= SCSMR_CHR; + } else { + termios->c_cflag &= ~CSIZE; + termios->c_cflag |= CS8; + } if (termios->c_cflag & PARENB) smr_val |= SCSMR_PE; if (termios->c_cflag & PARODD) -- 2.35.1