Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp662309iog; Mon, 13 Jun 2022 10:06:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0Nr+DoDMcqIKM+FfNYPeQeDc0Aw66/B/+C6eFHktgqKzWg5hOYLQ7chOZ7hU9G8SC4P2v X-Received: by 2002:a17:902:ec81:b0:163:3142:e0dd with SMTP id x1-20020a170902ec8100b001633142e0ddmr48197plg.40.1655139991992; Mon, 13 Jun 2022 10:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655139991; cv=none; d=google.com; s=arc-20160816; b=rzLNXtWVmydv4C+SL5X8xV6RhB6iI7B9aWqkuOYW3jSbp+Ffy03TahIMTzxSA8MIjg Yx23yUyacLBA/2YyC7ICalh6eIeg967+pZMSrQ8/MAWGRKReAejr2PW/QX+PzRZ1K0Bn M/KlAjmbY4c2Ns7kgySIBj5U3DCpUc8a0f6g/FsvReDuGPUQBQJZ3HRtdrJyh8jMB9cU Yo+wIuT3nRt6n93VeaTf5WXDpoM6TKF1fb7t6eiUr17dcMwf0SZtajTP1ikSy0XBLIGM Oy2AWB5h7yLzg2mBK/uXkCA5MfSWcRagIH+bW0oAK3pGilXqGPXzaGVb82HUWv/rb87o JqCg== 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=yoiEYBzYyMzuNPgvzqiA12IhGgG2sBLcn3hHGU5DD6A=; b=ydX5YNSx69zTmLAS7IHr8hjXbWwqWu4Ve9bd8NLk6NeRQoLtINcdVLwaZhRH+4EIWQ Am2ZLIwP7V/eyAHKQK47Q3rC4JSAcv5tSvz1VfZcUDEzMZ61xZXZlpb8UXRJxf+TLwno GB+KCCyD3/vx037ae0zN6bl1WtuEfh6cIiVfJpXKoLmacUNv3yNv+jL24Xsn8Rgc/6Lf ActN49+JjLR8ZvdDQe3nckIoxvW3Wne1AJP3WhrLQEjrzlaL1nLXRJSGmpyyn7NxjcgC MVn9a/9Xtz3eZuoPi6H72/KmtWwtX8yXyLpUTyW5YWSm4mOFPIeJp4YDlVRovnNgBfq+ oyLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oZu1pnGH; 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 jj11-20020a170903048b00b00163ed1483a6si8671666plb.428.2022.06.13.10.06.18; Mon, 13 Jun 2022 10:06:31 -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=oZu1pnGH; 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 S1378231AbiFMNk4 (ORCPT + 99 others); Mon, 13 Jun 2022 09:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378508AbiFMNi5 (ORCPT ); Mon, 13 Jun 2022 09:38:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31FE2762B1; Mon, 13 Jun 2022 04:27:41 -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 A0C5BB80E93; Mon, 13 Jun 2022 11:27:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 011ADC34114; Mon, 13 Jun 2022 11:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655119658; bh=H65ToNfa6uoL6K3/CKfn57Ny3hBH3z4vRMtAoOAG/hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZu1pnGHb37WTkx84XptBAu81EevNnHvM/iBANCm9ah7viOhKp5E3fWQlpIkRN6LQ vqvnZ2YnCMi89q/hnbgPFAZkUxOW9wLH6vKIfSCxi5RnMp33baH7VJWl4me4ni2kuI MRonUgSyEEw8YBjyiCmpFcxuibzrRGQ+MhvbD8g0= 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.18 072/339] serial: sifive: Sanitize CSIZE and c_iflag Date: Mon, 13 Jun 2022 12:08:17 +0200 Message-Id: <20220613094928.706085544@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@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 6140166b7ed5..776aec6516c4 100644 --- a/drivers/tty/serial/sifive.c +++ b/drivers/tty/serial/sifive.c @@ -666,12 +666,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