aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-03-06 16:12:00 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-03-06 21:01:04 -0500
commit059819a41d4331316dd8ddcf977a24ab338f4300 (patch)
treef4d93f613001c195d66dffaa5b3593dcaf4e8d53 /drivers/char/pcmcia
parent266d4f40370757459f8aa063976c932d0de5e59b (diff)
[PATCH] Fix buffer overflow in Omnikey CardMan 4040 driver (CVE-2007-0005)
Based on a patch from Don Howard <dhoward@redhat.com> When calling write() with a buffer larger than 512 bytes, the driver's write buffer overflows, allowing to overwrite the EIP and execute arbitrary code with kernel privileges. In read(), there exists a similar problem, but coming from the device. A malicous or buggy device sending more than 512 bytes can overflow of the driver's read buffer, with the same effects as above. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Harald Welte <laforge@gnumonks.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/pcmcia')
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 0e82968c2f38..f2e4ec4fd407 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -273,6 +273,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
273 DEBUGP(6, dev, "BytesToRead=%lu\n", bytes_to_read); 273 DEBUGP(6, dev, "BytesToRead=%lu\n", bytes_to_read);
274 274
275 min_bytes_to_read = min(count, bytes_to_read + 5); 275 min_bytes_to_read = min(count, bytes_to_read + 5);
276 min_bytes_to_read = min_t(size_t, min_bytes_to_read, READ_WRITE_BUFFER_SIZE);
276 277
277 DEBUGP(6, dev, "Min=%lu\n", min_bytes_to_read); 278 DEBUGP(6, dev, "Min=%lu\n", min_bytes_to_read);
278 279
@@ -340,7 +341,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
340 return 0; 341 return 0;
341 } 342 }
342 343
343 if (count < 5) { 344 if ((count < 5) || (count > READ_WRITE_BUFFER_SIZE)) {
344 DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count); 345 DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count);
345 return -EIO; 346 return -EIO;
346 } 347 }