From patchwork Fri Feb 3 20:18:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karina Yankevich X-Patchwork-Id: 13128334 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 CDFBBC05027 for ; Fri, 3 Feb 2023 20:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233425AbjBCUTt (ORCPT ); Fri, 3 Feb 2023 15:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233333AbjBCUTp (ORCPT ); Fri, 3 Feb 2023 15:19:45 -0500 Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AEC4A9111; Fri, 3 Feb 2023 12:19:44 -0800 (PST) Received: from uxi.kar (171.25.167.209) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.14; Fri, 3 Feb 2023 23:19:35 +0300 From: Karina Yankevich To: Alan Stern CC: Karina Yankevich , Greg Kroah-Hartman , , , , Subject: [PATCH] usb: storage: sddr55: avoid integer overflow Date: Fri, 3 Feb 2023 23:18:21 +0300 Message-ID: <20230203201821.483477-1-k.yankevich@omp.ru> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Originating-IP: [171.25.167.209] X-ClientProxiedBy: msexch01.omp.ru (10.188.4.12) To msexch01.omp.ru (10.188.4.12) X-KSE-ServerInfo: msexch01.omp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.59, Database issued on: 02/03/2023 19:59:06 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 59 X-KSE-AntiSpam-Info: Lua profiles 175255 [Feb 03 2023] X-KSE-AntiSpam-Info: Version: 5.9.59.0 X-KSE-AntiSpam-Info: Envelope from: k.yankevich@omp.ru X-KSE-AntiSpam-Info: LuaCore: 502 502 69dee8ef46717dd3cb3eeb129cb7cc8dab9e30f6 X-KSE-AntiSpam-Info: {rep_avail} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: {relay has no DNS name} X-KSE-AntiSpam-Info: {SMTP from is not routable} X-KSE-AntiSpam-Info: 127.0.0.199:7.1.2;omp.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1 X-KSE-AntiSpam-Info: ApMailHostAddress: 171.25.167.209 X-KSE-AntiSpam-Info: {DNS response errors} X-KSE-AntiSpam-Info: Rate: 59 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dmarc=temperror header.from=omp.ru;spf=temperror smtp.mailfrom=omp.ru;dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 02/03/2023 20:01:00 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 2/3/2023 3:58:00 PM X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org We're possibly losing information by shifting an int. Fix it by adding the necessary cast. 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);