[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100908193956.GB3463@bicker>
Date: Wed, 8 Sep 2010 21:39:56 +0200
From: Dan Carpenter <error27@...il.com>
To: David Woodhouse <dwmw2@...radead.org>
Cc: Artem Bityutskiy <Artem.Bityutskiy@...ia.com>,
Ben Hutchings <bhutchings@...arflare.com>,
H Hartley Sweeten <hsweeten@...ionengravers.com>,
"Kirill A. Shutemov" <kirill@...temov.name>,
linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [patch] mtd: sanity check input
If "ur_idx" is wrong we could go past the end of the array. The
"ur_idx" comes from root so it's not a huge deal, but adding a sanity
check makes the code more robust.
Signed-off-by: Dan Carpenter <error27@...il.com>
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index a825002..9c00549 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -513,6 +513,9 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
if (get_user(ur_idx, &(ur->regionindex)))
return -EFAULT;
+ if (ur_idx >= mtd->numeraseregions)
+ return -EINVAL;
+
kr = &(mtd->eraseregions[ur_idx]);
if (put_user(kr->offset, &(ur->offset))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists