Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9D0DC05027 for ; Fri, 3 Feb 2023 20:48:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbjBCUsy (ORCPT ); Fri, 3 Feb 2023 15:48:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbjBCUst (ORCPT ); Fri, 3 Feb 2023 15:48:49 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 8BEE5945D5 for ; Fri, 3 Feb 2023 12:48:48 -0800 (PST) Received: (qmail 575339 invoked by uid 1000); 3 Feb 2023 15:48:47 -0500 Date: Fri, 3 Feb 2023 15:48:47 -0500 From: Alan Stern To: Karina Yankevich Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH] usb: storage: sddr55: avoid integer overflow Message-ID: References: <20230203201821.483477-1-k.yankevich@omp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230203201821.483477-1-k.yankevich@omp.ru> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2023 at 11:18:21PM +0300, Karina Yankevich wrote: > We're possibly losing information by shifting an int. > Fix it by adding the necessary cast. Nonsense. The card's _total_ capacity is no larger than 128 MB, so a page address can't possibly overflow an int. Alan Stern > Found by OMP on behalf of Linux Verification Center > (linuxtesting.org) with SVACE. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Signed-off-by: Karina Yankevich > --- > drivers/usb/storage/sddr55.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c > index 15dc25801cdc..4aeff73de147 100644 > --- a/drivers/usb/storage/sddr55.c > +++ b/drivers/usb/storage/sddr55.c > @@ -236,7 +236,7 @@ static int sddr55_read_data(struct us_data *us, > memset (buffer, 0, len); > } else { > > - address = (pba << info->blockshift) + page; > + address = ((unsigned long)pba << info->blockshift) + page; > > command[0] = 0; > command[1] = LSB_of(address>>16); > @@ -411,7 +411,7 @@ static int sddr55_write_data(struct us_data *us, > command[4] = 0x40; > } > > - address = (pba << info->blockshift) + page; > + address = ((unsigned long)pba << info->blockshift) + page; > > command[1] = LSB_of(address>>16); > command[2] = LSB_of(address>>8); > -- > 2.39.1 >