ANDROID: GKI: Only protect exports if KMI symbols are present

Only enforce export protection if there are symbols in the
unprotected list for the Kernel Module Interface (KMI).

This is only relevant for targets like arm64 that have
defined ABI symbol lists. This allows non-GKI targets
like arm and x86 to continue using GKI source code
without disabling the feature for those targets.

Bug: 232430739
Test: TH
Fixes: fd1e768866 ("ANDROID: GKI: Protect exports of protected GKI modules")
Change-Id: Ie89e8f63eda99d9b7aacd1bb76d036b3ff4ba37c
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
This commit is contained in:
Ramji Jiyani
2022-12-18 23:09:16 -08:00
committed by Treehugger Robot
parent 16c63232db
commit a6eaf3db80

View File

@@ -34,8 +34,17 @@ static int cmp_name(const void *sym, const void *protected_sym)
*/
bool gki_is_module_protected_export(const char *name)
{
return bsearch(name, gki_protected_exports_symbols, NR_PROTECTED_EXPORTS_SYMBOLS,
if (NR_UNPROTECTED_SYMBOLS) {
return bsearch(name, gki_protected_exports_symbols, NR_PROTECTED_EXPORTS_SYMBOLS,
MAX_PROTECTED_EXPORTS_NAME_LEN, cmp_name) != NULL;
} else {
/*
* If there are no symbols in unprotected list; We don't need to
* protect exports as there is no KMI enforcement.
* Treat everything exportable in this case.
*/
return false;
}
}
/**
@@ -52,7 +61,7 @@ bool gki_is_module_unprotected_symbol(const char *name)
/*
* If there are no symbols in unprotected list;
* there isn't a KMI enforcement for the kernel.
* Treat evertything accessible in this case.
* Treat everything accessible in this case.
*/
return true;
}