Lines Matching refs:ns

178 static bool maybe_accessible_via_namespace_links(android_namespace_t* ns, const char* name) {  in maybe_accessible_via_namespace_links()  argument
180 for (auto& ns_link : ns->linked_namespaces()) { in maybe_accessible_via_namespace_links()
191 static bool is_greylisted(android_namespace_t* ns, const char* name, const soinfo* needed_by) { in is_greylisted() argument
218 return !maybe_accessible_via_namespace_links(ns, name); in is_greylisted()
278 soinfo* soinfo_alloc(android_namespace_t* ns, const char* name, in soinfo_alloc() argument
285 TRACE("name %s: allocating soinfo for ns=%p", name, ns); in soinfo_alloc()
287 soinfo* si = new (g_soinfo_allocator.alloc()) soinfo(ns, name, file_stat, in soinfo_alloc()
293 ns->add_soinfo(si); in soinfo_alloc()
699 static const ElfW(Sym)* dlsym_handle_lookup_impl(android_namespace_t* ns, in ElfW()
714 if (!ns->is_accessible(current_soinfo)) { in ElfW()
735 static const ElfW(Sym)* dlsym_linear_lookup(android_namespace_t* ns, in ElfW()
743 auto& soinfo_list = ns->soinfo_list(); in ElfW()
1007 static int open_library(android_namespace_t* ns, in open_library() argument
1011 TRACE("[ opening %s from namespace %s ]", name, ns->get_name()); in open_library()
1021 …int fd = open_library_on_paths(zip_archive_cache, name, file_offset, ns->get_ld_library_paths(), r… in open_library()
1026 if (fd != -1 && !ns->is_accessible(*realpath)) { in open_library()
1034 …fd = open_library_on_paths(zip_archive_cache, name, file_offset, ns->get_default_library_paths(), … in open_library()
1074 static bool find_loaded_library_by_inode(android_namespace_t* ns, in find_loaded_library_by_inode() argument
1090 *candidate = ns->soinfo_list().find_if(predicate); in find_loaded_library_by_inode()
1093 for (auto& link : ns->linked_namespaces()) { in find_loaded_library_by_inode()
1107 static bool find_loaded_library_by_realpath(android_namespace_t* ns, const char* realpath, in find_loaded_library_by_realpath() argument
1111 *candidate = ns->soinfo_list().find_if(predicate); in find_loaded_library_by_realpath()
1114 for (auto& link : ns->linked_namespaces()) { in find_loaded_library_by_realpath()
1128 static bool load_library(android_namespace_t* ns, in load_library() argument
1140 ns->get_name(), name, rtld_flags, realpath.c_str(), search_linked_namespaces); in load_library()
1166 if (find_loaded_library_by_inode(ns, file_stat, file_offset, search_linked_namespaces, &si)) { in load_library()
1170 ns->get_name(), name, si->get_realpath()); in load_library()
1189 if ((fs_stat.f_type != TMPFS_MAGIC) && (!ns->is_accessible(realpath))) { in load_library()
1195 if (is_greylisted(ns, name, needed_by)) { in load_library()
1205 name, realpath.c_str(), sopath, ns->get_name()); in load_library()
1215 name, needed_or_dlopened_by, ns->get_name()); in load_library()
1218 if (!maybe_accessible_via_namespace_links(ns, name)) { in load_library()
1224 ns->get_name(), in load_library()
1225 android::base::Join(ns->get_ld_library_paths(), ':').c_str(), in load_library()
1226 android::base::Join(ns->get_default_library_paths(), ':').c_str(), in load_library()
1227 android::base::Join(ns->get_permitted_paths(), ':').c_str()); in load_library()
1233 soinfo* si = soinfo_alloc(ns, realpath.c_str(), &file_stat, file_offset, rtld_flags); in load_library()
1270 ns->get_name(), task->get_name(), name); in load_library()
1271 load_tasks->push_back(LoadTask::create(name, si, ns, task->get_readers_map())); in load_library()
1277 static bool load_library(android_namespace_t* ns, in load_library() argument
1306 return load_library(ns, task, load_tasks, rtld_flags, realpath, search_linked_namespaces); in load_library()
1312 ns->get_name(), name, rtld_flags, search_linked_namespaces); in load_library()
1317 int fd = open_library(ns, zip_archive_cache, name, needed_by, &file_offset, &realpath); in load_library()
1335 return load_library(ns, task, load_tasks, rtld_flags, realpath, search_linked_namespaces); in load_library()
1338 static bool find_loaded_library_by_soname(android_namespace_t* ns, in find_loaded_library_by_soname() argument
1341 return !ns->soinfo_list().visit([&](soinfo* si) { in find_loaded_library_by_soname()
1353 static bool find_loaded_library_by_soname(android_namespace_t* ns, in find_loaded_library_by_soname() argument
1364 bool found = find_loaded_library_by_soname(ns, name, candidate); in find_loaded_library_by_soname()
1368 for (auto& link : ns->linked_namespaces()) { in find_loaded_library_by_soname()
1386 android_namespace_t* ns = namespace_link.linked_namespace(); in find_library_in_linked_namespace() local
1392 if (find_loaded_library_by_soname(ns, task->get_name(), false, &candidate)) { in find_library_in_linked_namespace()
1403 ns->get_name(), task->get_name(), soname.c_str()); in find_library_in_linked_namespace()
1410 ns->get_name(), task->get_name()); in find_library_in_linked_namespace()
1417 LD_LOG(kLogDlopen, "find_library_in_linked_namespace(ns=%s, task=%s): Ok to load", ns->get_name(), in find_library_in_linked_namespace()
1423 static bool find_library_internal(android_namespace_t* ns, in find_library_internal() argument
1430 if (find_loaded_library_by_soname(ns, task->get_name(), true /* search_linked_namespaces */, in find_library_internal()
1434 ns->get_name(), task->get_name(), candidate->get_realpath()); in find_library_internal()
1444 if (load_library(ns, task, zip_archive_cache, load_tasks, rtld_flags, in find_library_internal()
1450 if (ns->is_greylist_enabled() && is_greylisted(ns, task->get_name(), task->get_needed_by())) { in find_library_internal()
1457 ns->get_name(), task->get_name(), g_default_namespace.get_name()); in find_library_internal()
1458 ns = &g_default_namespace; in find_library_internal()
1459 if (load_library(ns, task, zip_archive_cache, load_tasks, rtld_flags, in find_library_internal()
1470 ns->get_name(), task->get_name(), ns->linked_namespaces().size()); in find_library_internal()
1471 for (auto& linked_namespace : ns->linked_namespaces()) { in find_library_internal()
1485 ns->get_name(), task->get_name(), linked_namespace.linked_namespace()->get_name()); in find_library_internal()
1513 bool find_libraries(android_namespace_t* ns, in find_libraries() argument
1530 load_tasks.push_back(LoadTask::create(name, start_with, ns, &readers_map)); in find_libraries()
1567 LD_LOG(kLogDlopen, "find_libraries(ns=%s): task=%s, is_dt_needed=%d", ns->get_name(), in find_libraries()
1704 is_dt_needed ? needed_by->get_primary_namespace() : ns; in find_libraries()
1716 ns->get_name(), in find_libraries()
1717 ns, in find_libraries()
1803 static soinfo* find_library(android_namespace_t* ns, in find_library() argument
1811 } else if (!find_libraries(ns, in find_library()
2072 android_namespace_t* ns = get_caller_namespace(caller); in do_dlopen() local
2080 ns == nullptr ? "(null)" : ns->get_name(), in do_dlopen()
2081 ns, in do_dlopen()
2112 ns = extinfo->library_namespace; in do_dlopen()
2151 if (find_loaded_library_by_realpath(ns, original_path, true, &si)) { in do_dlopen()
2163 soinfo* si = find_library(ns, translated_name, flags, extinfo, caller); in do_dlopen()
2234 android_namespace_t* ns = get_caller_namespace(caller); in do_dlsym() local
2247 ns == nullptr ? "(null)" : ns->get_name(), in do_dlsym()
2248 ns); in do_dlsym()
2268 sym = dlsym_linear_lookup(ns, sym_name, vi, &found, caller, handle); in do_dlsym()
2336 static bool set_anonymous_namespace(android_namespace_t* ns) { in set_anonymous_namespace() argument
2337 if (!g_anonymous_namespace_set && ns != nullptr) { in set_anonymous_namespace()
2338 CHECK(ns->is_also_used_as_anonymous()); in set_anonymous_namespace()
2339 g_anonymous_namespace = ns; in set_anonymous_namespace()
2379 static void add_soinfos_to_namespace(const soinfo_list_t& soinfos, android_namespace_t* ns) { in add_soinfos_to_namespace() argument
2380 ns->add_soinfos(soinfos); in add_soinfos_to_namespace()
2382 si->add_secondary_namespace(ns); in add_soinfos_to_namespace()
2426 android_namespace_t* ns = new (g_namespace_allocator.alloc()) android_namespace_t(); in create_namespace() local
2427 ns->set_name(name); in create_namespace()
2428 ns->set_isolated((type & ANDROID_NAMESPACE_TYPE_ISOLATED) != 0); in create_namespace()
2429 ns->set_greylist_enabled((type & ANDROID_NAMESPACE_TYPE_GREYLIST_ENABLED) != 0); in create_namespace()
2430 ns->set_also_used_as_anonymous((type & ANDROID_NAMESPACE_TYPE_ALSO_USED_AS_ANONYMOUS) != 0); in create_namespace()
2447 add_soinfos_to_namespace(parent_namespace->soinfo_list(), ns); in create_namespace()
2450 ns->add_linked_namespace(link.linked_namespace(), link.shared_lib_sonames(), in create_namespace()
2455 add_soinfos_to_namespace(parent_namespace->get_shared_group(), ns); in create_namespace()
2458 ns->set_ld_library_paths(std::move(ld_library_paths)); in create_namespace()
2459 ns->set_default_library_paths(std::move(default_library_paths)); in create_namespace()
2460 ns->set_permitted_paths(std::move(permitted_paths)); in create_namespace()
2462 if (ns->is_also_used_as_anonymous() && !set_anonymous_namespace(ns)) { in create_namespace()
2465 ns->get_name(), in create_namespace()
2466 android::base::Join(ns->get_ld_library_paths(), ':').c_str(), in create_namespace()
2467 android::base::Join(ns->get_default_library_paths(), ':').c_str(), in create_namespace()
2468 android::base::Join(ns->get_permitted_paths(), ':').c_str()); in create_namespace()
2472 return ns; in create_namespace()
3498 android_namespace_t* ns = new (g_namespace_allocator.alloc()) android_namespace_t(); in init_default_namespaces() local
3499 ns->set_name(ns_config->name()); in init_default_namespaces()
3500 ns->set_isolated(ns_config->isolated()); in init_default_namespaces()
3501 ns->set_default_library_paths(ns_config->search_paths()); in init_default_namespaces()
3502 ns->set_permitted_paths(ns_config->permitted_paths()); in init_default_namespaces()
3503 ns->set_whitelisted_libs(ns_config->whitelisted_libs()); in init_default_namespaces()
3505 namespaces[ns_config->name()] = ns; in init_default_namespaces()
3507 g_exported_namespaces[ns_config->name()] = ns; in init_default_namespaces()