summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Dabros <jsd@semihalf.com>2020-08-21 08:24:41 +0200
committerPatrick Georgi <pgeorgi@google.com>2020-08-26 07:33:05 +0000
commit086c5e6fc866e99208da3c1c9c8840cd0aeaec80 (patch)
tree652ef5ad8dc0e3c43c57e28996afde03a9a1ea92
parent93d56f51653b0310d81d63c5ee0c9e5c252e9cbe (diff)
lib/imd: Fix imdr_recover for small regions
One of the checks inside imdr_recover() was written with the assumption that imdr limit is always aligned to LIMIT_ALIGN. This is true only for large allocations, thus may fail for small regions. It's not necessary to check if root_pointer is under the limit, since this is implicitly verified by imdr_get_root_pointer(). Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: I25d6291301797d10c6a267b5f6e56ac38b995b7b Reviewed-on: https://review.coreboot.org/c/coreboot/+/44667 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
-rw-r--r--src/lib/imd.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/imd.c b/src/lib/imd.c
index 53d0616ab8..c86cf324c8 100644
--- a/src/lib/imd.c
+++ b/src/lib/imd.c
@@ -201,9 +201,8 @@ static int imdr_recover(struct imdr *imdr)
r = relative_pointer(rp, rp->root_offset);
- /* Confirm the root and root pointer are just under the limit. */
- if (ALIGN_UP((uintptr_t)&r->entries[r->max_entries], LIMIT_ALIGN) !=
- imdr->limit)
+ /* Ensure that root is just under the root pointer */
+ if ((intptr_t)rp - (intptr_t)&r->entries[r->max_entries] > sizeof(struct imd_entry))
return -1;
if (r->num_entries > r->max_entries)