* [PATCH] usb: storage: sddr55: avoid integer overflow
@ 2023-02-03 20:18 Karina Yankevich
2023-02-03 20:48 ` Alan Stern
0 siblings, 1 reply; 8+ messages in thread
From: Karina Yankevich @ 2023-02-03 20:18 UTC (permalink / raw)
To: Alan Stern
Cc: Karina Yankevich, Greg Kroah-Hartman, linux-usb, usb-storage,
linux-kernel, lvc-project
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
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] usb: storage: sddr55: avoid integer overflow
2023-02-03 20:18 [PATCH] usb: storage: sddr55: avoid integer overflow Karina Yankevich
@ 2023-02-03 20:48 ` Alan Stern
2023-02-06 20:04 ` Sergei Shtylyov
0 siblings, 1 reply; 8+ messages in thread
From: Alan Stern @ 2023-02-03 20:48 UTC (permalink / raw)
To: Karina Yankevich
Cc: Greg Kroah-Hartman, linux-usb, usb-storage, linux-kernel,
lvc-project
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 <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
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] usb: storage: sddr55: avoid integer overflow
2023-02-03 20:48 ` 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
0 siblings, 2 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2023-02-06 20:04 UTC (permalink / raw)
To: Alan Stern, Karina Yankevich
Cc: Greg Kroah-Hartman, linux-usb, usb-storage, linux-kernel,
lvc-project
Hello!
On 2/3/23 11:48 PM, Alan Stern 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.
Then the 'address' variables shouldn't be declared *unsigned long*, right?
That should fix the SVACE's report as well. Would you accept such a patch?
> Alan Stern
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] usb: storage: sddr55: avoid integer overflow
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
1 sibling, 0 replies; 8+ messages in thread
From: Alan Stern @ 2023-02-06 20:17 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Karina Yankevich, Greg Kroah-Hartman, linux-usb, usb-storage,
linux-kernel, lvc-project
On Mon, Feb 06, 2023 at 11:04:54PM +0300, Sergei Shtylyov wrote:
> Hello!
>
> On 2/3/23 11:48 PM, Alan Stern 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.
>
> Then the 'address' variables shouldn't be declared *unsigned long*, right?
> That should fix the SVACE's report as well. Would you accept such a patch?
Yes.
Alan Stern
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] usb: storage: sddr55: clean up variable type
2023-02-06 20:04 ` Sergei Shtylyov
2023-02-06 20:17 ` Alan Stern
@ 2023-02-27 11:25 ` Karina Yankevich
2023-02-27 11:54 ` Greg Kroah-Hartman
1 sibling, 1 reply; 8+ messages in thread
From: Karina Yankevich @ 2023-02-27 11:25 UTC (permalink / raw)
To: Alan Stern
Cc: Karina Yankevich, Greg Kroah-Hartman, linux-usb, usb-storage,
linux-kernel, lvc-project
SVACE static analyzer complains that we're possibly
losing information by shifting an 'unsigned int pba'
variables in sddr55_{read,write}_data().
It is a false positive, because of the card's total capacity
is no larger than 128 MB. But 'unsigned int' is more
suitable in this case.
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..0aa079405d23 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -196,7 +196,7 @@ static int sddr55_read_data(struct us_data *us,
unsigned char *buffer;
unsigned int pba;
- unsigned long address;
+ unsigned int address;
unsigned short pages;
unsigned int len, offset;
@@ -316,7 +316,7 @@ static int sddr55_write_data(struct us_data *us,
unsigned int pba;
unsigned int new_pba;
- unsigned long address;
+ unsigned int address;
unsigned short pages;
int i;
--
2.39.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2] usb: storage: sddr55: clean up variable type
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
0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-27 11:54 UTC (permalink / raw)
To: Karina Yankevich
Cc: Alan Stern, linux-usb, usb-storage, linux-kernel, lvc-project
On Mon, Feb 27, 2023 at 02:25:41PM +0300, Karina Yankevich wrote:
> SVACE static analyzer complains that we're possibly
> losing information by shifting an 'unsigned int pba'
> variables in sddr55_{read,write}_data().
> It is a false positive, because of the card's total capacity
> is no larger than 128 MB. But 'unsigned int' is more
> suitable in this case.
Please wrap at 72 columns.
> Found by OMP on behalf of Linux Verification Center
> (linuxtesting.org) with SVACE.
What is "OMP"?
What is "SVACE"?
And why change anything if there is not a real issue?
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
That's obviously not the correct commit id for such a "fix" as this is
not a real issue.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2] usb: storage: sddr55: clean up variable type
2023-02-27 11:54 ` Greg Kroah-Hartman
@ 2023-12-01 16:16 ` Sergei Shtylyov
2023-12-01 22:36 ` Greg Kroah-Hartman
0 siblings, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2023-12-01 16:16 UTC (permalink / raw)
To: Greg Kroah-Hartman, Karina Yankevich
Cc: Alan Stern, linux-usb, usb-storage, linux-kernel, lvc-project
Hello!
Sorry for the really long delay! Your reply scared off Karina
(it was her 1st kernel patch), so I'm trying to pick this patch up
where it was left back in February...
On 2/27/23 2:54 PM, Greg Kroah-Hartman wrote:
[...]
>> SVACE static analyzer complains that we're possibly
>> losing information by shifting an 'unsigned int pba'
>> variables in sddr55_{read,write}_data().
>> It is a false positive, because of the card's total capacity
>> is no larger than 128 MB. But 'unsigned int' is more
>> suitable in this case.
>
> Please wrap at 72 columns.
>
>> Found by OMP on behalf of Linux Verification Center
>> (linuxtesting.org) with SVACE.
>
> What is "OMP"?
Open Mobile Platform, LLC. The website is in Russian only:
https://www.omp.ru
> What is "SVACE"?
The patch description said thst it's a static analyzer.
Here's the link to the Institute for System Programming web page about it:
https://www.ispras.ru/en/technologies/svace/
> And why change anything if there is not a real issue?
We needlessly use 64-bit type on 64-bit arches.
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>
> That's obviously not the correct commit id for such a "fix" as this is
> not a real issue.
That's correct. We'll remove this tag.
> thanks,
>
> greg k-h
MBR, Srrgey
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2] usb: storage: sddr55: clean up variable type
2023-12-01 16:16 ` Sergei Shtylyov
@ 2023-12-01 22:36 ` Greg Kroah-Hartman
0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2023-12-01 22:36 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Karina Yankevich, Alan Stern, linux-usb, usb-storage,
linux-kernel, lvc-project
On Fri, Dec 01, 2023 at 07:16:56PM +0300, Sergei Shtylyov wrote:
> Hello!
>
> Sorry for the really long delay! Your reply scared off Karina
> (it was her 1st kernel patch), so I'm trying to pick this patch up
> where it was left back in February...
Note, any submitter should be able to answer questions about their
change, as remember, if I take it I am now responsible for it. If they
do not want to respond that means they do not want to be responsible for
it, which of course means we can't accept it :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-01 22:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03 20:18 [PATCH] usb: storage: sddr55: avoid integer overflow Karina Yankevich
2023-02-03 20:48 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox