summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6eca392)
raw | patch | inline | side by side (parent: 6eca392)
author | Kees Cook <keescook@chromium.org> | |
Fri, 20 Nov 2015 01:18:54 +0000 (17:18 -0800) | ||
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
Thu, 3 Mar 2016 23:06:49 +0000 (15:06 -0800) |
commit 02e2a5bfebe99edcf9d694575a75032d53fe1b73 upstream.
If md->signature == MAC_DRIVER_MAGIC and md->block_size == 1023, a single
512 byte sector would be read (secsize / 512). However the partition
structure would be located past the end of the buffer (secsize % 512).
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
If md->signature == MAC_DRIVER_MAGIC and md->block_size == 1023, a single
512 byte sector would be read (secsize / 512). However the partition
structure would be located past the end of the buffer (secsize % 512).
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/partitions/mac.c | patch | blob | history |
diff --git a/block/partitions/mac.c b/block/partitions/mac.c
index 76d8ba6379a9863673bcacd31946b6712d2c8d71..bd5b91465230023b721e6dc131fe7a621aebea03 100644 (file)
--- a/block/partitions/mac.c
+++ b/block/partitions/mac.c
Sector sect;
unsigned char *data;
int slot, blocks_in_map;
- unsigned secsize;
+ unsigned secsize, datasize, partoffset;
#ifdef CONFIG_PPC_PMAC
int found_root = 0;
int found_root_goodness = 0;
}
secsize = be16_to_cpu(md->block_size);
put_dev_sector(sect);
- data = read_part_sector(state, secsize/512, §);
+ datasize = round_down(secsize, 512);
+ data = read_part_sector(state, datasize / 512, §);
if (!data)
return -1;
- part = (struct mac_partition *) (data + secsize%512);
+ partoffset = secsize % 512;
+ if (partoffset + sizeof(*part) > datasize)
+ return -1;
+ part = (struct mac_partition *) (data + partoffset);
if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
put_dev_sector(sect);
return 0; /* not a MacOS disk */