]> git.ipfire.org Git - thirdparty/grub.git/commit
mm: Assert that we preserve header vs region alignment
authorDaniel Axtens <dja@axtens.net>
Thu, 21 Apr 2022 05:24:14 +0000 (15:24 +1000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 29 Jun 2022 10:41:29 +0000 (12:41 +0200)
commit1df8fe66c57087eb33bd6dc69f786ed124615aa7
tree5bf8ba10b8e4a6e8cd3ee29b409d6dc756985dcc
parent188d2ff1c3a5d72220bb599e0d95e0f752bae7e9
mm: Assert that we preserve header vs region alignment

grub_mm_region_init() does:

  h = (grub_mm_header_t) (r + 1);

where h is a grub_mm_header_t and r is a grub_mm_region_t.

Cells are supposed to be GRUB_MM_ALIGN aligned, but while grub_mm_dump
ensures this vs the region header, grub_mm_region_init() does not.

It's better to be explicit than implicit here: rather than changing
grub_mm_region_init() to ALIGN_UP(), require that the struct is
explicitly a multiple of the header size.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Patrick Steinhardt <ps@pks.im>
include/grub/mm_private.h