* [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store()
@ 2018-10-19 9:19 Dan Carpenter
2018-10-19 23:00 ` Martin K. Petersen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-10-19 9:19 UTC (permalink / raw)
To: kernel-janitors
We only want the value to be zero or one.
It's not a big deal, but say we passed set value to INT_MIN, then
disable_enclosure_messages_show() would return that 12 bytes of "buf"
are initialized but actually only 3 are. I think there are tools like
KASAN which will trigger an info leak warning when that happens.
Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/scsi/myrs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 07e5a3f54e31..55842ed54231 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -1501,7 +1501,7 @@ static ssize_t disable_enclosure_messages_store(struct device *dev,
if (ret)
return ret;
- if (value > 2)
+ if (value < 0 || value > 2)
return -EINVAL;
cs->disable_enc_msg = value;
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store()
2018-10-19 9:19 [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store() Dan Carpenter
@ 2018-10-19 23:00 ` Martin K. Petersen
2018-10-20 8:42 ` Dan Carpenter
2018-10-24 2:28 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2018-10-19 23:00 UTC (permalink / raw)
To: kernel-janitors
Dan,
> We only want the value to be zero or one.
>
> It's not a big deal, but say we passed set value to INT_MIN, then
> disable_enclosure_messages_show() would return that 12 bytes of "buf"
> are initialized but actually only 3 are. I think there are tools like
> KASAN which will trigger an info leak warning when that happens.
s/kstrtoint/kstrtouint/?
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store()
2018-10-19 9:19 [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store() Dan Carpenter
2018-10-19 23:00 ` Martin K. Petersen
@ 2018-10-20 8:42 ` Dan Carpenter
2018-10-24 2:28 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-10-20 8:42 UTC (permalink / raw)
To: kernel-janitors
On Fri, Oct 19, 2018 at 12:19:09PM +0300, Dan Carpenter wrote:
> We only want the value to be zero or one.
>
> It's not a big deal, but say we passed set value to INT_MIN, then
> disable_enclosure_messages_show() would return that 12 bytes of "buf"
> are initialized but actually only 3 are. I think there are tools like
> KASAN which will trigger an info leak warning when that happens.
>
> Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/scsi/myrs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index 07e5a3f54e31..55842ed54231 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
> @@ -1501,7 +1501,7 @@ static ssize_t disable_enclosure_messages_store(struct device *dev,
> if (ret)
> return ret;
>
> - if (value > 2)
> + if (value < 0 || value > 2)
> return -EINVAL;
It's not actually clear to me why we allow 2. Shouldn't we just use
kstrtobool()?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store()
2018-10-19 9:19 [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store() Dan Carpenter
2018-10-19 23:00 ` Martin K. Petersen
2018-10-20 8:42 ` Dan Carpenter
@ 2018-10-24 2:28 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2018-10-24 2:28 UTC (permalink / raw)
To: kernel-janitors
Dan,
>> + if (value < 0 || value > 2)
>> return -EINVAL;
>
> It's not actually clear to me why we allow 2. Shouldn't we just use
> kstrtobool()?
Hannes?
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-24 2:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-19 9:19 [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store() Dan Carpenter
2018-10-19 23:00 ` Martin K. Petersen
2018-10-20 8:42 ` Dan Carpenter
2018-10-24 2:28 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox