From: Karina Yankevich <k.yankevich@omp.ru>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Karina Yankevich <k.yankevich@omp.ru>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<linux-usb@vger.kernel.org>,
<usb-storage@lists.one-eyed-alien.net>,
<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: [PATCH] usb: storage: sddr55: avoid integer overflow
Date: Fri, 3 Feb 2023 23:18:21 +0300 [thread overview]
Message-ID: <20230203201821.483477-1-k.yankevich@omp.ru> (raw)
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 <k.yankevich@omp.ru>
---
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
next reply other threads:[~2023-02-03 20:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 20:18 Karina Yankevich [this message]
2023-02-03 20:48 ` [PATCH] usb: storage: sddr55: avoid integer overflow Alan Stern
2023-02-06 20:04 ` Sergei Shtylyov
2023-02-06 20:17 ` Alan Stern
2023-02-27 11:25 ` [PATCH v2] usb: storage: sddr55: clean up variable type Karina Yankevich
2023-02-27 11:54 ` Greg Kroah-Hartman
2023-12-01 16:16 ` Sergei Shtylyov
2023-12-01 22:36 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230203201821.483477-1-k.yankevich@omp.ru \
--to=k.yankevich@omp.ru \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox