Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6633126rwp; Tue, 18 Jul 2023 03:38:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlFNd/MNd5pE52ihbTg6a0WC2hjqRzvvDqiL4C9L4peyd6gJlaBng23gH0hdjFzA2dUGi3eJ X-Received: by 2002:a05:6a21:999d:b0:133:c53d:710c with SMTP id ve29-20020a056a21999d00b00133c53d710cmr12270691pzb.45.1689676716569; Tue, 18 Jul 2023 03:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689676716; cv=none; d=google.com; s=arc-20160816; b=QbqJuvIrMoxCJqVKZG5Y8HeUF+80y98UO29Q7XoGe2nZjURH9eZhwWcSLPmHo4R1K1 BNMqZMyxYUm7H4vv0DBW78OvrYqQGK2KA5OPnVorbEdny8OSy/KEVzvQOcHE8MKSlYwW 2WigwglJPnegYVrxUlxDegW4IrTTXIcuqx3cQOMGIDlZ85J8qb4J0yi9gT6rzDPH1i1S XNKm/OzfoLzhWp03unPUuFLC/XXVo11oalJ9npazT05emjinc0O/Y/g8Pk8XHa2yl60r 5zAV7r/2Wgz6zqhdOdFXBZz6kLTVm1E4gsxM7dNTKqVz4rzSsauXV/2j2MsUHeDRCYS/ 4OEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=jtX0aZAUEmTBUajGaHcj7Q+A5E/7hrFq4SXfHdNkE/M=; fh=voaDjaLUE7A15deObKEeZG2tmA3aJH58eb5kzClFrN8=; b=vFsmQCRxhoaNaEhr+jiF7V51zXPZcULGSuUdCK80f5BfMFrWojS00+zkiDmZjvA7bW xZYXOViiGMsuQcooSA1LDo+bPftUtwqUBSoCuBTvN5yFeSctX40d06U0AXJpYPCE6ooR yR4JeBZGPdA4q/Jbzm8/K2+38J3yVhWrNn+GslDejniEZ+QxQKsfkPwOIChsh//BdFV6 zGU/ItkcazC4jH4gr7+vMxGLb0ApyzjFS2F+eB9Dqp6NRtUM6Ba8iPCE63MgACHNjhWw /2OAzeRYEHBLTPrWYX5mnJW6lKfC39DM4QrfgL8HZwCWgS7ZxfMrpdq+1ix5ptxtNXNw s8tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=auZQ3noy; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id im15-20020a170902bb0f00b001bb42c274a9si1074282plb.504.2023.07.18.03.38.23; Tue, 18 Jul 2023 03:38:36 -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=@intel.com header.s=Intel header.b=auZQ3noy; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232473AbjGRJ5j (ORCPT + 99 others); Tue, 18 Jul 2023 05:57:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232462AbjGRJ5G (ORCPT ); Tue, 18 Jul 2023 05:57:06 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D99261735; Tue, 18 Jul 2023 02:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689674189; x=1721210189; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=kT+WCGrXIntkSsi5bhLytk40kQrUFODgYPeYw5k0HEc=; b=auZQ3noyM/lkFfLBiUNfkzT7eHLN9LlLp+5leHYFqSltEVgUj+nO9Lw6 hj3WVDCVbxM3vzQv7R5EO0etMgu/Lt7y88eQgRbfbUWfm1qByW15sfReG wdNeDWLTygCEgMi6ar7rpmjEEyMaReYHuKEU7VgUGux5i3pVt2tQW3gT8 Gs9ahjb8jYvrhNCUWFCv1jv8mTKynBx3cgHuEhIXm/IZQnoVP7tD7TapX W4e8yU1accLGmkKruBVSw+sMbnV3zVCW66UMdhSejbHmA5JYfdjgn8RHc fkZY56Sa0KHgWQL5MHNLRy4kDd6I5gEk5C10xBOjpT7C9oTEtYAh+mV5X w==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368804780" X-IronPort-AV: E=Sophos;i="6.01,213,1684825200"; d="scan'208";a="368804780" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 02:56:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="673847895" X-IronPort-AV: E=Sophos;i="6.01,213,1684825200"; d="scan'208";a="673847895" Received: from ijarvine-mobl2.ger.corp.intel.com ([10.252.47.53]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 02:56:26 -0700 Date: Tue, 18 Jul 2023 12:56:20 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Sherry Sun cc: Greg Kroah-Hartman , shenwei.wang@nxp.com, linux-serial , LKML , linux-imx@nxp.com, Jiri Slaby Subject: Re: [PATCH] tty: serial: fsl_lpuart: Fix possible integer overflow In-Reply-To: <3652da4b-8ccf-34a8-bdb7-757a3109ac54@kernel.org> Message-ID: References: <20230718065645.6588-1-sherry.sun@nxp.com> <3652da4b-8ccf-34a8-bdb7-757a3109ac54@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tue, 18 Jul 2023, Jiri Slaby wrote: > On 18. 07. 23, 8:56, Sherry Sun wrote: > > This patch addresses the following Coverity report, fix it by casting > > sport->port.frame_time to type u64. > > > > CID 32305660: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) > > Potentially overflowing expression sport->port.frame_time * 8U with type > > unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, > > and then used in a context that expects an expression of type u64 (64 > > bits, unsigned). > > > > Fixes: cf9aa72d2f91 ("tty: serial: fsl_lpuart: optimize the timer based EOP > > logic") > > Signed-off-by: Sherry Sun > > --- > > drivers/tty/serial/fsl_lpuart.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/tty/serial/fsl_lpuart.c > > b/drivers/tty/serial/fsl_lpuart.c > > index c1980ea52666..07b3b26732db 100644 > > --- a/drivers/tty/serial/fsl_lpuart.c > > +++ b/drivers/tty/serial/fsl_lpuart.c > > @@ -1373,7 +1373,7 @@ static inline int lpuart_start_rx_dma(struct > > lpuart_port *sport) > > sport->last_residue = 0; > > sport->dma_rx_timeout = max(nsecs_to_jiffies( > > - sport->port.frame_time * DMA_RX_IDLE_CHARS), 1UL); > > + (u64)sport->port.frame_time * DMA_RX_IDLE_CHARS), 1UL); > > Can you explain how that can overflow? In the worst case (1 start bit, 8 data > bits, 2 stop bits, parity bit, address bit, 50 bauds), frame_time would > contain: > 13*1e9/50 = 260,000,000. (260 ms) > > Then the multiplication above is: > 260,000,000*8 = 2,080,000,000. (2 seconds) > > which is still less than 2^32-1. I was wondering the same thing. This isn't a real bug. All findings from code analysis tools must be carefully evaluated to filter wheat out of chaff and this falls into the latter category. Please make sure next time you understand and explain also in the changelog how the problem can be manifested for real before sending this kind of patches. -- i.