Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp584991iog; Mon, 13 Jun 2022 08:36:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWlkKxX6O8wU7dSmWu0HZ5PQceGDPuEz2pV9fM7x65mvm59CvMfP+gdiHKDeefviXsmW9e X-Received: by 2002:a05:6402:1713:b0:42d:cb5e:d799 with SMTP id y19-20020a056402171300b0042dcb5ed799mr373409edu.34.1655134588641; Mon, 13 Jun 2022 08:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134588; cv=none; d=google.com; s=arc-20160816; b=p1QyiqWaibEPNRrWpLbOw+PYneMmwG/SDelfWrt8d+RgBQ1urxuBGtZx9KXOUsborA Zhe/b3tAjbWadEkzWILWifATq6gbJMN41cxtzOPbuebxFpsMenAfa5Q5etXsGCYXkxSF GRbp9r85TTrH3ixDOugxiUSSRiSYUoiiv7MFlqtUbZz8FXe6Wp6HbCZE4QRGtATxSeTC uW9RNPe8KN5U9VXq3Kh5EcHivfRh0EpNnlfBNwZqQ0uwii3zL9XAxkSXtwjh26KePYHM H/ztm00JX7TkWtRJ/U//Z3Tqmv4rE9uim9vWo+wLJ3zLRP6Rxzi1uJGciXddrLiu7PrU oRfg== 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=2JepNhbHQaG6VmBf2T3C41YwvBYsH/hAUcjb2n5GPZo=; b=A2oVI6Z6hiJnfHB/NT3bi1WSgcQAfIS+bCJhftIeUG4v827k61ZtwgrQZYt1YvQ0sO ifofZ+BE7NZ5LqB5yeBQoxQfnV6SVfoMR4rNNOkWJ6P6g9uoC/6SW3mzj0oF0L4kAMcs JCs0eB04lzqvCh599G7XwAdUGyhdgjPJ/4f7k74c6okxxVdnxHqKSKM4CMK7IXUXHKR8 n4ZmH75TZYV54QeK/qA5ErYO7C+M94KqmrBMrBc0WtVkwJQ4RKV3ZtcVrZc1bKu7DOLR tzR9y7inKxQgP1EpoCWm1N++WynAy9tAXdRA3ws737mNFys+JWigZJlhs6ocW2A83SLY i32g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1L39Lug9; 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 hc14-20020a170907168e00b00711d84d041dsi9271616ejc.640.2022.06.13.08.36.03; Mon, 13 Jun 2022 08:36:28 -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=1L39Lug9; 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 S1351850AbiFMMMO (ORCPT + 99 others); Mon, 13 Jun 2022 08:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358704AbiFMMHt (ORCPT ); Mon, 13 Jun 2022 08:07:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0B1C515BE; Mon, 13 Jun 2022 04:00:11 -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 0D5B4B80D3A; Mon, 13 Jun 2022 11:00:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B875C3411E; Mon, 13 Jun 2022 11:00:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655118008; bh=gDBS5ivrfzV13GZedBnzpygN0y4DfOtxPoTKpGomeQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1L39Lug9eIS1hMaMO9SA58+KfRvynnjxfmRQ7yidNFVRPbEowzpAeiznQ/G+f/ZnK FM3GdCN2BjpmfrPmNAXlBScvTymKTJnJkSn7tvBu5GKLd8+sRv17HCKpjO3MJYgdzr Qss7Cbv+epsE3C7Gn6tT8P5XtYarkjM/fJvJoW1o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Kandagatla , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 4.19 210/287] serial: st-asc: Sanitize CSIZE and correct PARENB for CS7 Date: Mon, 13 Jun 2022 12:10:34 +0200 Message-Id: <20220613094930.230209297@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094923.832156175@linuxfoundation.org> References: <20220613094923.832156175@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 52bb1cb7118564166b04d52387bd8403632f5190 ] Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or CS6 to CS8. In addition, ASC_CTL_MODE_7BIT_PAR suggests that CS7 has to have parity, thus add PARENB. Incorrect CSIZE 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: c4b058560762 (serial:st-asc: Add ST ASC driver.) Cc: Srinivas Kandagatla Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220519081808.3776-8-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/st-asc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index 7971997cdead..ce35e3a131b1 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -540,10 +540,14 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, /* set character length */ if ((cflag & CSIZE) == CS7) { ctrl_val |= ASC_CTL_MODE_7BIT_PAR; + cflag |= PARENB; } else { ctrl_val |= (cflag & PARENB) ? ASC_CTL_MODE_8BIT_PAR : ASC_CTL_MODE_8BIT; + cflag &= ~CSIZE; + cflag |= CS8; } + termios->c_cflag = cflag; /* set stop bit */ ctrl_val |= (cflag & CSTOPB) ? ASC_CTL_STOP_2BIT : ASC_CTL_STOP_1BIT; -- 2.35.1