* [patch] sata_sil24: memset() overflow
@ 2010-06-09 12:01 Dan Carpenter
2010-06-09 12:24 ` Tejun Heo
2010-06-10 20:14 ` Jeff Garzik
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2010-06-09 12:01 UTC (permalink / raw)
To: Jeff Garzik
Cc: Tejun Heo, Robert Hancock, Vivek Mahajan, linux-ide, linux-kernel,
kernel-janitors
cb->atapi.cdb is an array of 16 u8 elements. The call too memset()
would set the first part of the sge array to zero as well. It's not
a packed struct.
This one has been around for five years. I found it with Smatch. I
think the reason no one has seen it before is because we normally call
sil24_fill_sg() and that overwrites sge with proper information?
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
I don't have this hardware myself so I can't test it. Sorry. :(
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index e925051..9e459eb 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -865,7 +865,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
} else {
prb = &cb->atapi.prb;
sge = cb->atapi.sge;
- memset(cb->atapi.cdb, 0, 32);
+ memset(cb->atapi.cdb, 0, sizeof(cb->atapi.cdb));
memcpy(cb->atapi.cdb, qc->cdb, qc->dev->cdb_len);
if (ata_is_data(qc->tf.protocol)) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] sata_sil24: memset() overflow
2010-06-09 12:01 [patch] sata_sil24: memset() overflow Dan Carpenter
@ 2010-06-09 12:24 ` Tejun Heo
2010-06-10 20:14 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2010-06-09 12:24 UTC (permalink / raw)
To: Dan Carpenter, Jeff Garzik, Robert Hancock, Vivek Mahajan,
linux-ide
On 06/09/2010 02:01 PM, Dan Carpenter wrote:
> cb->atapi.cdb is an array of 16 u8 elements. The call too memset()
> would set the first part of the sge array to zero as well. It's not
> a packed struct.
>
> This one has been around for five years. I found it with Smatch. I
> think the reason no one has seen it before is because we normally call
> sil24_fill_sg() and that overwrites sge with proper information?
Yeah, the table is built after the memset so it doesn't really break
anything but still where did that 32 come from? :-)
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] sata_sil24: memset() overflow
2010-06-09 12:01 [patch] sata_sil24: memset() overflow Dan Carpenter
2010-06-09 12:24 ` Tejun Heo
@ 2010-06-10 20:14 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2010-06-10 20:14 UTC (permalink / raw)
To: Dan Carpenter, Tejun Heo, Robert Hancock, Vivek Mahajan,
linux-ide, linux-kern
On 06/09/2010 08:01 AM, Dan Carpenter wrote:
> cb->atapi.cdb is an array of 16 u8 elements. The call too memset()
> would set the first part of the sge array to zero as well. It's not
> a packed struct.
>
> This one has been around for five years. I found it with Smatch. I
> think the reason no one has seen it before is because we normally call
> sil24_fill_sg() and that overwrites sge with proper information?
>
> Signed-off-by: Dan Carpenter<error27@gmail.com>
> ---
> I don't have this hardware myself so I can't test it. Sorry. :(
>
> diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
> index e925051..9e459eb 100644
> --- a/drivers/ata/sata_sil24.c
> +++ b/drivers/ata/sata_sil24.c
> @@ -865,7 +865,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
> } else {
> prb =&cb->atapi.prb;
> sge = cb->atapi.sge;
> - memset(cb->atapi.cdb, 0, 32);
> + memset(cb->atapi.cdb, 0, sizeof(cb->atapi.cdb));
> memcpy(cb->atapi.cdb, qc->cdb, qc->dev->cdb_len);
applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-10 20:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-09 12:01 [patch] sata_sil24: memset() overflow Dan Carpenter
2010-06-09 12:24 ` Tejun Heo
2010-06-10 20:14 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).