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: Wu,Le <wule01@baidu.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
This commit is contained in:
parent
f9b2849005
commit
046daa57dd
1 changed files with 9 additions and 1 deletions
10
kernel/cfi.c
10
kernel/cfi.c
|
@ -87,6 +87,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)
|
||||
{
|
||||
|
@ -109,7 +117,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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue