Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp441706iog; Mon, 13 Jun 2022 06:05:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTDNmqhCR60mDj3F158uMU9f6HqLvd+f8sF64UA7dKGz2eY9/NKRaLumWwKGZSZNYwOYly X-Received: by 2002:a17:907:7da5:b0:711:c9cd:61e0 with SMTP id oz37-20020a1709077da500b00711c9cd61e0mr37781394ejc.443.1655125399534; Mon, 13 Jun 2022 06:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125399; cv=none; d=google.com; s=arc-20160816; b=FKA29cvISh9PzHDMKZYrWIdGw1Ax6rOjJJVwrH4Vgzo+97S+Edz8H4AkiqeDu+i5Xz KLkteiNO5H5ndmM3abaYVMB452VXh/J1QrmPmGK9L1SdJkKQgYrubGE62JxD5MfClnHG tfZy7nIraR0bKDT7XU5Y4ZNZtrnlbf8ErTDoK2qmVmZV0ruyeQnv0UpYtYDmDu7cth40 q+C9uUPs1rzi1xBIBXaL2KEQiAfjqQWEhDSTrURfzjx54JL2zH88Mbotdxfo/KpGeI4z mB62BjzpDVdNlfoUHAvm4EqTG4+VJNsgg3+mKJvXZfV2few/NuC7M9Xwka8V8RKwHE79 PhfA== 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=Pe0RmYnyo0B0+QT7lMxvjP6tgHu8UaEj5/VKP3KztNk=; b=0aCc7PtdBfz9wA+DFyfZjIm266yWWGj3YS38oKGbrj2syS22yb+fUFFhKRZSJBzUW3 kJFdyFhsDuabSB3oB9I6UAKyNS2mxqeVu4PjII3W7svr27hVya6dkP+RnOQwtWlYRzh2 NWYz2V3/bPfLki8avLBxiJU4yF8WsvjnS5K3+qF1Rs4w+WKcq18U422OLSHsG/8TXtkP 3y55a5dKLqpGdeOhiuNPe/MO6Z/JYdtOd5MPne7pk/g8F9CLy5DnFqP2knOWeCd0ugUV 7DsF+5BNBa6796b6v6n6xrEpQ+8QSIulb4YAKmskFO9hCundufEqjFdWLm9yf0wgqRpI tJIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nAVA+iMA; 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 e17-20020a056402191100b0042e01b7a135si8111731edz.99.2022.06.13.06.02.53; Mon, 13 Jun 2022 06:03:19 -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=nAVA+iMA; 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 S1354808AbiFMLhN (ORCPT + 99 others); Mon, 13 Jun 2022 07:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354803AbiFMLaK (ORCPT ); Mon, 13 Jun 2022 07:30:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CA33F8A9; Mon, 13 Jun 2022 03:45:45 -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 ams.source.kernel.org (Postfix) with ESMTPS id 63826B80D3C; Mon, 13 Jun 2022 10:45:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C234DC34114; Mon, 13 Jun 2022 10:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117143; bh=I8oULWVL+L4kvTvgtQzqFkRIvj5C38xYUwG6aVPRCpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nAVA+iMAC0rC3hcaB9ylrNZjNgPPxvFQ/Uxh9O+FVAJB2GJaSF43IMBKVFFgSqHPu QptwzJ8mxIcX8RIbIj96po0BcxErVsZ2zO0r0bl87bvd6CP7ETcm7+/k2wq5JOgKsW CIDc2xm3vZl4uV/Nj6JdnkH6Fp/sZvDleOTk6Yrw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Walmsley , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 5.4 312/411] serial: sifive: Sanitize CSIZE and c_iflag Date: Mon, 13 Jun 2022 12:09:45 +0200 Message-Id: <20220613094938.101618816@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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 c069d2756c01ed36121fae6a42c14fdf1325c71d ] Only CS8 is supported but CSIZE was not sanitized 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(). Similarly, INPCK, PARMRK, and BRKINT are reported textually unsupported but were not cleared in termios c_iflag which is the machine-readable format. Fixes: 45c054d0815b (tty: serial: add driver for the SiFive UART) Cc: Paul Walmsley Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220519081808.3776-7-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/sifive.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c index ec9bd2207271..7015632c4990 100644 --- a/drivers/tty/serial/sifive.c +++ b/drivers/tty/serial/sifive.c @@ -667,12 +667,16 @@ static void sifive_serial_set_termios(struct uart_port *port, int rate; char nstop; - if ((termios->c_cflag & CSIZE) != CS8) + if ((termios->c_cflag & CSIZE) != CS8) { dev_err_once(ssp->port.dev, "only 8-bit words supported\n"); + termios->c_cflag &= ~CSIZE; + termios->c_cflag |= CS8; + } if (termios->c_iflag & (INPCK | PARMRK)) dev_err_once(ssp->port.dev, "parity checking not supported\n"); if (termios->c_iflag & BRKINT) dev_err_once(ssp->port.dev, "BREAK detection not supported\n"); + termios->c_iflag &= ~(INPCK|PARMRK|BRKINT); /* Set number of stop bits */ nstop = (termios->c_cflag & CSTOPB) ? 2 : 1; -- 2.35.1