Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp449908iog; Mon, 13 Jun 2022 06:12:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYPiVvUSMNxw2DHd2sdJMffcvRd3X4U6MlyS/yiEYxwKY0SgR/ZKs22nNIbUQ0vNobBpWm X-Received: by 2002:a17:906:77d5:b0:712:171:d3b1 with SMTP id m21-20020a17090677d500b007120171d3b1mr20796864ejn.191.1655125590631; Mon, 13 Jun 2022 06:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125590; cv=none; d=google.com; s=arc-20160816; b=P1I9HhDYdM4wlPUkq5g/aI/5vh3BhN/hqd4CwMlP9RsKNw7oy+fnQMA72TFBVrrDvx MpWJK1IJWCHWLoRqj6DAMsZlWuzJ0+s4+xJOKRO46YxeipHpZThuVbyhuo+837Pe0enq NWEdp+vNQlzDgE2aMWbSUuKmBNaXlcYb1ixRWzTyWtZcZ87zs10JwdWKyYTddSFG5+5b VveNUzBv+1FZP2tSFa3Dsgv2JVIq9k/2pxeH/j3X0M76p+oLCCx3nuiMS1iXsnIP+bss aDSGlSoNCJ/37dMdeeb90S3hQQL/Lmp9v+uHDlKR5YFjPrQ33zSs8YqjLGLvl7rvEVoH VmLw== 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=EZotXh7BzNAFkp0OeZ4hENf8whwtzSGxb0VoNgi3TVs=; b=PQnZyCgvs4LLsDO2N5S8RzkX6KgUJ059qr6u7LbSAdp+MC9T/hLTUuIQiiiLaNp2KR HChUeZSthtYScIT64bgJCH/HqqK1szm6RcCUqOS/WFydL9EetS7XXag/BLGX8bCgfwLY GpkrLuYIyIUEKPsD7q6uBzucd15Z4+a/l+hdyotKQMhlRahdIqbmpwX0rUXarf7MF1M0 CWYztd6YHxR+BwPDbz1BKXhDmVuCvnsEAGpEbSnM/4/bfvnIx+CZUSONvSkVS5CXGl+A mrim3ZnSC32PqNL6v4z9DNi1AD+Uq2MpwRpJ7NJL6LzeFcapKkB9rZ2jJCkRUZkpi3/p ctAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LskNaxqX; 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 w16-20020a05640234d000b0041d76e18accsi10082175edc.548.2022.06.13.06.05.51; Mon, 13 Jun 2022 06:06:30 -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=LskNaxqX; 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 S236414AbiFMK1k (ORCPT + 99 others); Mon, 13 Jun 2022 06:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343779AbiFMKZB (ORCPT ); Mon, 13 Jun 2022 06:25:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A963CE28; Mon, 13 Jun 2022 03:19:28 -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 9B56560B8E; Mon, 13 Jun 2022 10:19:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD1DDC34114; Mon, 13 Jun 2022 10:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115567; bh=OSx5Plsy9bUj2pyXOeEwEF2U7wIAunktWya3GWs0sF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LskNaxqXeDN3TDOG9iYPEEFRzivkM4RsyeHlqxSGDTR4FItDFS4SnRHbXiErDyzEi eksiMx8n2wXxXIZErmGAlhG1gZ2BXUgu0AoPag4Go//NsuSV+XufGLY8XvCQDx1ZSz EemmaiGLH4sIKp/ZZF25/ScUeI2JaiKlto3+2n+k= 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.9 120/167] serial: st-asc: Sanitize CSIZE and correct PARENB for CS7 Date: Mon, 13 Jun 2022 12:09:54 +0200 Message-Id: <20220613094908.870484747@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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 379e5bd37df9..b845cd05e350 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -509,10 +509,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