Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp626889iog; Mon, 13 Jun 2022 09:24:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeEw4rxUrNGV1wCaFSvBNd+2NVZV7tvolV6kaLtqPGOPDO3CWB15irkOy3KM4OuQB4p4ma X-Received: by 2002:a63:ec14:0:b0:401:9e3e:7d23 with SMTP id j20-20020a63ec14000000b004019e3e7d23mr352321pgh.235.1655137491036; Mon, 13 Jun 2022 09:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137491; cv=none; d=google.com; s=arc-20160816; b=EeY3e06rJOs1HCqqQ8O3FR+U2GU4SbpLJrTIZy3zCg6hB1ghK/4yUdjYDpa9429OOa zeNzE3nMtmjXXKS5GMEP2yEFiXcA/zPyBJz1f9vJDW32L8DqTnScnf7X1jP3rgyOSayd fpHY+c2rlxKyv2pyoob2R8IEhPSMK2KvlwRBCsUPn0mVRd1ZnwIVIn4qDzc1aOOWJ3KZ 5I9nT3DYvSYKJnMGvwJTFfWEOUn+1sFNLh3AtxrJFg2ZTAgXXrh46ZHAjbBk8w9tz8O4 VlXeDZZRzbQLgsDxNcNdBhlDLRn+SRoTGXzsTNsutqyaRwbQq+JNpm+/Tytgq5c1iWNZ OuwA== 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=PCY7Lpx+amtxCd/TgNeIJUmGSAcoCXpr/x6i0oOVELuQyJAb/6xE3C9YI3+iwjx+Bo l2stMN0va7MvojQX+/GjcxmLfmNfTxAyANkvfeGMSt4EeCAEtpYaqjU3M57MM3ETH0xJ LhI9v3XQBb3BYMAb8x1THc3uVuBi3U2/A64tNrDi6r9qAZsYPDSJRqHMefUiPIRbOIxo uZLXouThjzqmxKRV3klcGKmlLPrigpso9VoJkb5qVEC9eFH4q43A0r2GDq1F045XgtxK 9OadKXVNFhisXR7Qe7N/eS1YBVVz7ArdBxDPXyn81MVR/jrFAsADQaPLBMSkF9hlPx58 jLng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xd5Sofzl; 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 c3-20020a637243000000b003fe25580540si10462111pgn.476.2022.06.13.09.24.39; Mon, 13 Jun 2022 09:24:51 -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=Xd5Sofzl; 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 S1355119AbiFMLhR (ORCPT + 99 others); Mon, 13 Jun 2022 07:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354813AbiFMLaL (ORCPT ); Mon, 13 Jun 2022 07:30:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E97883F8B9; Mon, 13 Jun 2022 03:45:46 -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 8719961248; Mon, 13 Jun 2022 10:45:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9160EC34114; Mon, 13 Jun 2022 10:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117145; bh=gDBS5ivrfzV13GZedBnzpygN0y4DfOtxPoTKpGomeQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xd5SofzlfmrlpE88qSwCqsrvRKsfYaegkTcBagSSy3RIk7R48Ju8ADz56h1CdShRI qDrV1aPJM4vVmerTKwb+A+s+1uhnIrcW10Jh25D0WI5noVdRV3fe0uaN7yn8Y4qyHB 4U55Zazz2WQNbmO5ixSF4fBA/8Z3ZMD2tjlFb2ZI= 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 5.4 313/411] serial: st-asc: Sanitize CSIZE and correct PARENB for CS7 Date: Mon, 13 Jun 2022 12:09:46 +0200 Message-Id: <20220613094938.130107070@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 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