Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca20dbf4 authored by Sami Tolvanen's avatar Sami Tolvanen
Browse files

ANDROID: cfi: fix shadow rebasing



If the module area base address changes when loading a new module, the
new CFI shadow will only cover the first allocated page for each existing
module. This will cause cross-DSO look-ups to functions elsewhere in the
module to fall back to a red-black tree, which may be slower.

Bug: 122963951
Change-Id: I9262034d39351afcd42590ead8d6384fc30a8ce8
Reported-by: default avatarWu,Le <wule01@baidu.com>
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent d34411de
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -88,6 +88,14 @@ static inline unsigned long shadow_to_ptr(const struct cfi_shadow *s,
	return (s->r.min_page + s->shadow[index]) << PAGE_SHIFT;
}

static inline unsigned long shadow_to_page(const struct cfi_shadow *s,
	int index)
{
	BUG_ON(index < 0 || index >= SHADOW_SIZE);

	return (s->r.min_page + index) << PAGE_SHIFT;
}

static void prepare_next_shadow(const struct cfi_shadow __rcu *prev,
		struct cfi_shadow *next)
{
@@ -110,7 +118,7 @@ static void prepare_next_shadow(const struct cfi_shadow __rcu *prev,
		if (prev->shadow[i] == SHADOW_INVALID)
			continue;

		index = ptr_to_shadow(next, shadow_to_ptr(prev, i));
		index = ptr_to_shadow(next, shadow_to_page(prev, i));
		if (index < 0)
			continue;