Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp441752iog; Mon, 13 Jun 2022 06:05:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz54W7AKPRNhvag9XsIqKPqu549nG12AzwmaFITgRVA2HEguK30Cs9+/l6k7SkRJC01dBXy X-Received: by 2002:a17:902:f609:b0:168:dcbe:7c4d with SMTP id n9-20020a170902f60900b00168dcbe7c4dmr5689208plg.169.1655125520490; Mon, 13 Jun 2022 06:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125520; cv=none; d=google.com; s=arc-20160816; b=VDrjebn81IjpjSuiBblI/+Ol6gx30LmPyIgmwLpFu1sW8xEDWyiPG5BLtxKpvAzOvd MQhOHGyiNq2qA67NrH9gc3HNWLzmlISydIz+UQnxEL9N59OdFvXbBk9Mvvh+hHlMo2zZ bAYhd0EsuZwVLnoFM9EvvH1HQhLyv0WT2XRAnbLtDbtYMin4njp3WPM+deMD4ECCRKqf SItbcQL9ZplSwIA3Jlhq4EyHyjkOd5vLperpSNg5GQspL8XEx6z4Tl2ZYzM3ANTgnWPd i94qKGOvCItrVwQRnc5GIHPNriwUMdHmcyF05L3UAE/Q4aSrrYh0Lh8asCkml1bTtqFN A3cw== 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=z7lqtnZh62zM51xRlNAATqg8/Mm/wLuPtZ4x2bd8Vus=; b=fShSPlVawnDFKzlyXJtbp3jggKsMOtXUECVCPrCk61cOnb63kCRJHMLJoj1rHZS+cu LLNUXfmrWpfBIvwqbkiXYay5AMN/JpM4CAUt6S68YQGewADXS1jHHayOwPxeOeWY/cXn J0Wvp0TZEdAAoSn4AJ80atZEFmV62KWiyexzcn3VzXRGi237PmF4jMAJrgLKTv+vrO5I D+WyV5BBGNfonFeO95iQ4yjzdZYUmsvdzV8OAdpBJ3cfdYYPkyupYaONdgv2slMtc5Vj 8zEanQ6I4e5tPgRiNZdqNflPfm5jnmrveyDrSKKvNsB61f4N38PJWbd1ClL5+mhBQsYj Jg4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HrT+aOdK; 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 p29-20020a056a000a1d00b00518fc8adc58si10568581pfh.380.2022.06.13.06.05.06; Mon, 13 Jun 2022 06:05:20 -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=HrT+aOdK; 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 S1350600AbiFMLCy (ORCPT + 99 others); Mon, 13 Jun 2022 07:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350425AbiFMKyw (ORCPT ); Mon, 13 Jun 2022 06:54:52 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812901FA52; Mon, 13 Jun 2022 03:31: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 sin.source.kernel.org (Postfix) with ESMTPS id EE17ACE1171; Mon, 13 Jun 2022 10:31:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9729C34114; Mon, 13 Jun 2022 10:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116284; bh=h4DIRPIkd+t7iQudHWhOEiQWDM93GOEVD1Vy7LOVC1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrT+aOdKj3jVa8v5Dq//OyQpj/szBcr0LdJqGHyUWzcKOg+ilwdn0Ov7JOjAEiPHR ShjB77/oO0Lhlt7XVfnwM8s7dSbJ61Wnt19rFAKnIjBZnXZrb1BeaZsYxjnJ5HChPp Yg/t4k17/jUXdmYsnGt74BA7XdtHLPcUZF0dhOik= 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.14 155/218] serial: st-asc: Sanitize CSIZE and correct PARENB for CS7 Date: Mon, 13 Jun 2022 12:10:13 +0200 Message-Id: <20220613094925.295221300@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 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 b313a792b149..44d52c087c56 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -545,10 +545,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