greylist is no longer enabled by default.
greylist is needed only for application namepaces. Since we started using
linker-namesapces for vendors and other platform apps linker should not
enable greylist workaround by default.
Bug: http://b/37731053
Bug: https://issuetracker.google.com/38146125
Test: sailfish builds and boots
Test: bionic-unit-tests and linker-unit-tests pass
Change-Id: Iee83db6fb1ae754f5ade18491321d9bca3b5ead4
(cherry picked from commit e8ffe56a9c2bacc6bd880238250ad61e2bbb257b)
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index cf642cd..e3ee7d7 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -1050,7 +1050,7 @@
"\" wasn't loaded and RTLD_NOLOAD prevented it", dlerror());
}
-TEST(dlext, ns_greylist) {
+TEST(dlext, ns_greylist_enabled) {
ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr));
const std::string ns_search_path = get_testlib_root() + "/private_namespace_libs";
@@ -1059,7 +1059,7 @@
android_create_namespace("namespace",
nullptr,
ns_search_path.c_str(),
- ANDROID_NAMESPACE_TYPE_ISOLATED,
+ ANDROID_NAMESPACE_TYPE_ISOLATED | ANDROID_NAMESPACE_TYPE_GREYLIST_ENABLED,
nullptr,
nullptr);
@@ -1088,6 +1088,31 @@
ASSERT_STREQ("dlopen failed: library \"libnativehelper.so\" not found", dlerror());
}
+TEST(dlext, ns_greylist_disabled_by_default) {
+ ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr));
+
+ const std::string ns_search_path = get_testlib_root() + "/private_namespace_libs";
+
+ android_namespace_t* ns =
+ android_create_namespace("namespace",
+ nullptr,
+ ns_search_path.c_str(),
+ ANDROID_NAMESPACE_TYPE_ISOLATED,
+ nullptr,
+ nullptr);
+
+ ASSERT_TRUE(android_link_namespaces(ns, nullptr, g_core_shared_libs.c_str())) << dlerror();
+
+ android_dlextinfo extinfo;
+ extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE;
+ extinfo.library_namespace = ns;
+
+ android_set_application_target_sdk_version(__ANDROID_API_M__);
+ void* handle = android_dlopen_ext("libnativehelper.so", RTLD_NOW, &extinfo);
+ ASSERT_TRUE(handle == nullptr);
+ ASSERT_STREQ("dlopen failed: library \"libnativehelper.so\" not found", dlerror());
+}
+
TEST(dlext, ns_cyclic_namespaces) {
// Test that ns1->ns2->ns1 link does not break the loader
ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr));