diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2010-07-07 08:37:30 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2010-07-13 03:47:47 -0400 |
commit | a8e93f3dccc066cd6dd1e9db1e35942914fc57d1 (patch) | |
tree | 9165f872029ef76e99fd40c0afb6d8c896f8cabc /drivers/firewire | |
parent | 250b2b6dd421c9f8844a867d2ac06e0661e0ad93 (diff) |
firewire: cdev: check write quadlet request length to avoid buffer overflow
Check that the data length of a write quadlet request actually is large
enough for a quadlet. Otherwise, fw_fill_request could access the four
bytes after the end of the outbound_transaction_event structure.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Modification of Clemens' change: Consolidate the check into
init_request() which is used by the affected ioctl_send_request() and
ioctl_send_broadcast_request() and the unaffected
ioctl_send_stream_packet(), to save a few lines of code.
Note, since struct outbound_transaction_event *e is slab-allocated, such
an out-of-bounds access won't hit unallocated memory but may result in a
(virtually impossible to exploit) information disclosure.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/core-cdev.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index d8ac0ce2d6bf..f7559bfeaba3 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -563,6 +563,10 @@ static int init_request(struct client *client, | |||
563 | (request->length > 4096 || request->length > 512 << speed)) | 563 | (request->length > 4096 || request->length > 512 << speed)) |
564 | return -EIO; | 564 | return -EIO; |
565 | 565 | ||
566 | if (request->tcode == TCODE_WRITE_QUADLET_REQUEST && | ||
567 | request->length < 4) | ||
568 | return -EINVAL; | ||
569 | |||
566 | e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL); | 570 | e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL); |
567 | if (e == NULL) | 571 | if (e == NULL) |
568 | return -ENOMEM; | 572 | return -ENOMEM; |