mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-25 16:49:23 +00:00
disk/lvm: Don't blast past the end of the circular metadata buffer
This catches at least some OOB reads, and it's possible I suppose that if 2 * mda_size is less than GRUB_LVM_MDA_HEADER_SIZE it might catch some OOB writes too (although that hasn't showed up as a crash in fuzzing yet). It's a bit ugly and I'd appreciate better suggestions. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
a8cc95de74
commit
27a79bf38e
1 file changed
+10
@@ -251,6 +251,16 @@ grub_lvm_detect (grub_disk_t disk,
|
|||||||
if (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) >
|
if (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) >
|
||||||
grub_le_to_cpu64 (mdah->size))
|
grub_le_to_cpu64 (mdah->size))
|
||||||
{
|
{
|
||||||
|
if (2 * mda_size < GRUB_LVM_MDA_HEADER_SIZE ||
|
||||||
|
(grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) -
|
||||||
|
grub_le_to_cpu64 (mdah->size) > mda_size - GRUB_LVM_MDA_HEADER_SIZE))
|
||||||
|
{
|
||||||
|
#ifdef GRUB_UTIL
|
||||||
|
grub_util_info ("cannot copy metadata wrap in circular buffer");
|
||||||
|
#endif
|
||||||
|
goto fail2;
|
||||||
|
}
|
||||||
|
|
||||||
/* Metadata is circular. Copy the wrap in place. */
|
/* Metadata is circular. Copy the wrap in place. */
|
||||||
grub_memcpy (metadatabuf + mda_size,
|
grub_memcpy (metadatabuf + mda_size,
|
||||||
metadatabuf + GRUB_LVM_MDA_HEADER_SIZE,
|
metadatabuf + GRUB_LVM_MDA_HEADER_SIZE,
|
||||||
|
|||||||
Reference in new issue
Block a user