* [PATCH] libata: Read buffer overflow
@ 2009-08-03 11:30 Roel Kluin
2009-08-03 14:37 ` James Bottomley
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-08-03 11:30 UTC (permalink / raw)
To: jgarzik, linux-ide, Andrew Morton
Check whether index is within bounds before grabbing the element.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 2bc2dbe..f88c2ff 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -294,10 +294,11 @@ mpc52xx_ata_compute_mdma_timings(struct mpc52xx_ata_priv *priv, int dev,
int speed)
{
struct mpc52xx_ata_timings *t = &priv->timings[dev];
- const struct mdmaspec *s = &priv->mdmaspec[speed];
+ const struct mdmaspec *s;
if (speed < 0 || speed > 2)
return -EINVAL;
+ s = &priv->mdmaspec[speed];
t->mdma1 = (s->t0M << 24) | (s->td << 16) | (s->tkw << 8) | (s->tm);
t->mdma2 = (s->th << 24) | (s->tj << 16) | (s->tn << 8);
@@ -311,10 +312,11 @@ mpc52xx_ata_compute_udma_timings(struct mpc52xx_ata_priv *priv, int dev,
int speed)
{
struct mpc52xx_ata_timings *t = &priv->timings[dev];
- const struct udmaspec *s = &priv->udmaspec[speed];
+ const struct udmaspec *s;
if (speed < 0 || speed > 2)
return -EINVAL;
+ s = &priv->udmaspec[speed];
t->udma1 = (s->t2cyc << 24) | (s->tcyc << 16) | (s->tds << 8) | s->tdh;
t->udma2 = (s->tdvs << 24) | (s->tdvh << 16) | (s->tfs << 8) | s->tli;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] libata: Read buffer overflow
2009-08-03 11:30 [PATCH] libata: Read buffer overflow Roel Kluin
@ 2009-08-03 14:37 ` James Bottomley
0 siblings, 0 replies; 2+ messages in thread
From: James Bottomley @ 2009-08-03 14:37 UTC (permalink / raw)
To: Roel Kluin; +Cc: jgarzik, linux-ide, Andrew Morton
On Mon, 2009-08-03 at 13:30 +0200, Roel Kluin wrote:
> Check whether index is within bounds before grabbing the element.
This isn't a correct description or analysis.
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
> index 2bc2dbe..f88c2ff 100644
> --- a/drivers/ata/pata_mpc52xx.c
> +++ b/drivers/ata/pata_mpc52xx.c
> @@ -294,10 +294,11 @@ mpc52xx_ata_compute_mdma_timings(struct mpc52xx_ata_priv *priv, int dev,
> int speed)
> {
> struct mpc52xx_ata_timings *t = &priv->timings[dev];
> - const struct mdmaspec *s = &priv->mdmaspec[speed];
This is a *pointer* to the element, *not* a dereference. It's
irrelevant whether the pointer is off the end of the array or not
> + const struct mdmaspec *s;
>
> if (speed < 0 || speed > 2)
> return -EINVAL;
And since the check is immediately after, the pointer is never
dereferenced.
> + s = &priv->mdmaspec[speed];
James
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-03 14:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-03 11:30 [PATCH] libata: Read buffer overflow Roel Kluin
2009-08-03 14:37 ` James Bottomley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.