Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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>

authored by

Marcel Holtmann and committed by
Linus Torvalds
059819a4 266d4f40

+2 -1
+2 -1
drivers/char/pcmcia/cm4040_cs.c
··· 273 273 DEBUGP(6, dev, "BytesToRead=%lu\n", bytes_to_read); 274 274 275 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 278 DEBUGP(6, dev, "Min=%lu\n", min_bytes_to_read); 278 279 ··· 341 340 return 0; 342 341 } 343 342 344 - if (count < 5) { 343 + if ((count < 5) || (count > READ_WRITE_BUFFER_SIZE)) { 345 344 DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count); 346 345 return -EIO; 347 346 }