diff --git a/porting/linux/user/config/ld-musl-namespace-aarch64-test.ini b/porting/linux/user/config/ld-musl-namespace-aarch64-test.ini index e2da328130730d193e3c330383d516e32cdfc648..e18456f58c615bca63658bec6047c3f7dd2614e4 100644 --- a/porting/linux/user/config/ld-musl-namespace-aarch64-test.ini +++ b/porting/linux/user/config/ld-musl-namespace-aarch64-test.ini @@ -3,8 +3,8 @@ test = /data/tests/libc-test/src/functionalext:/data/tests/libc-test/src/functionalext/dlns [acquiescence] - namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/vendor/lib:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib - namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib + namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/vendor/lib:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib:/data/lib:/data/lib64 + namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib:/data/lib:/data/lib64 [test] added.nslist=ns_no_allowed_libs,ns_normal,ns_wrong_lib_path,ns_wrong_allowed_path,for_inherit_A,for_inherit_AA,inherited_class,ns_separated_flase,ns_asan_lib_path,ns_asan_permit_path diff --git a/porting/linux/user/config/ld-musl-namespace-aarch64.ini b/porting/linux/user/config/ld-musl-namespace-aarch64.ini index 34747a703a94a30a2e7aec864333603fe5ce1ea3..6f219091f55251c521b25d388bbcaeb983e019f1 100644 --- a/porting/linux/user/config/ld-musl-namespace-aarch64.ini +++ b/porting/linux/user/config/ld-musl-namespace-aarch64.ini @@ -2,5 +2,5 @@ acquiescence = / [acquiescence] - namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/vendor/lib:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib - namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib + namespace.default.lib.paths = /system/lib64:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/ndk:/system/lib64/chipset-pub-sdk:/system/lib64/chipset-sdk:/system/lib64/platformsdk:/system/lib64/priv-platformsdk:/system/lib64/priv-module:/system/lib64/module:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/vendor/lib:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib:/data/lib:/data/lib64 + namespace.default.asan.lib.paths = /system/lib64:/system/lib64/module:/vendor/lib64:/vendor/lib64/chipsetsdk:/system/lib64/module/data:/system/lib64/module/multimedia:/system/lib:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib64:/lib:/usr/local/lib:/usr/lib:/data/lib:/data/lib64 diff --git a/porting/linux/user/config/ld-musl-namespace-arm-test.ini b/porting/linux/user/config/ld-musl-namespace-arm-test.ini index c7aa19a9a106998d1863586c95d61e5e3949d5de..1f25429d1be1ef9a9250136754cb8d6b81ad4233 100644 --- a/porting/linux/user/config/ld-musl-namespace-arm-test.ini +++ b/porting/linux/user/config/ld-musl-namespace-arm-test.ini @@ -3,8 +3,8 @@ test = /data/tests/libc-test/src/functionalext:/data/tests/libc-test/src/functionalext/dlns [acquiescence] - namespace.default.lib.paths = /system/lib:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib - namespace.default.asan.lib.paths = /system/lib:/system/lib/module:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib + namespace.default.lib.paths = /system/lib:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib:/data/lib + namespace.default.asan.lib.paths = /system/lib:/system/lib/module:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib:/data/lib [test] added.nslist=ns_no_allowed_libs,ns_normal,ns_wrong_lib_path,ns_wrong_allowed_path,for_inherit_A,for_inherit_AA,inherited_class,ns_separated_flase,ns_asan_lib_path,ns_asan_permit_path diff --git a/porting/linux/user/config/ld-musl-namespace-arm.ini b/porting/linux/user/config/ld-musl-namespace-arm.ini index 98f7a1bdb6ade47ab36ad493907d75dd7c1387b5..846b86f201c822624e52059c5a5e42f7d80235ea 100644 --- a/porting/linux/user/config/ld-musl-namespace-arm.ini +++ b/porting/linux/user/config/ld-musl-namespace-arm.ini @@ -2,5 +2,5 @@ acquiescence = / [acquiescence] - namespace.default.lib.paths = /system/lib:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib - namespace.default.asan.lib.paths = /system/lib:/system/lib/module:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib + namespace.default.lib.paths = /system/lib:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/ndk:/system/lib/chipset-pub-sdk:/system/lib/chipset-sdk:/system/lib/platformsdk:/system/lib/priv-platformsdk:/system/lib/priv-module:/system/lib/module:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib:/data/lib + namespace.default.asan.lib.paths = /system/lib:/system/lib/module:/vendor/lib:/vendor/lib/chipsetsdk:/system/lib/module/data:/system/lib/module/multimedia:/lib:/usr/local/lib:/usr/lib:/data/lib diff --git a/porting/linux/user/ldso/dynlink.c b/porting/linux/user/ldso/dynlink.c index 321de8e17d2551be7cb5e47c41930c190f0cfab3..8f184de1a931b7c7ceb3422e04523477c6a29b7d 100644 --- a/porting/linux/user/ldso/dynlink.c +++ b/porting/linux/user/ldso/dynlink.c @@ -206,7 +206,7 @@ static void load_preload(char *s, ns_t *ns, struct loadtasks *tasks); static void handle_relro_sharing(struct dso *p, const dl_extinfo *extinfo, ssize_t *relro_fd_offset); /* asan path open */ -int handle_asan_path_open(int fd, const char *name, ns_t *namespace, char *buf); +int handle_asan_path_open(int fd, const char *name, ns_t *namespace, char *buf, size_t buf_size); /* add namespace function */ static void *addr2dso(size_t a); @@ -333,7 +333,7 @@ static void init_namespace(struct dso *app) nslist *nsl = nslist_init(); ns_configor *conf = configor_init(); - char file_path[sizeof "/etc/ld-musl-namespace-" + sizeof (LDSO_ARCH) + sizeof ".ini" + 1]; + char file_path[sizeof "/etc/ld-musl-namespace-" + sizeof (LDSO_ARCH) + sizeof ".ini" + 1] = {0}; (void)snprintf(file_path, sizeof file_path, "/etc/ld-musl-namespace-%s.ini", LDSO_ARCH); LD_LOGI("init_namespace file_path:%s", file_path); int ret = conf->parse(file_path, app_path); @@ -1262,7 +1262,8 @@ static struct dso *find_library_by_name(const char *name, const ns_t *ns, bool c } /* Find loaded so by file stat */ static struct dso *find_library_by_fstat(const struct stat *st, const ns_t *ns, bool check_inherited) { - LD_LOGD("find_library_by_fstat st->st_dev:%lu, st->st_ino:%lu, ns:%p, check_inherited:%d\n", st->st_dev, st->st_ino, ns, check_inherited); + LD_LOGD("find_library_by_fstat st->st_dev:%lu, st->st_ino:%lu, ns:%p, check_inherited:%d\n", + st->st_dev, st->st_ino, ns, check_inherited); struct dso *p = search_dso_by_fstat(st, ns); if (p) return p; if (check_inherited && ns->ns_inherits) { @@ -1373,7 +1374,7 @@ struct dso *load_library( } if (g_is_asan) { - fd = handle_asan_path_open(fd, name, namespace, buf); + fd = handle_asan_path_open(fd, name, namespace, buf, sizeof buf); LD_LOGD("load_library handle_asan_path_open fd:%d.\n", fd); } else { if (fd == -1 && namespace->lib_paths) { @@ -2538,7 +2539,6 @@ static void *dlopen_impl( do_dlclose(p); p = 0; } - LD_LOGD("dlopen %s: realpath=%s, handle=%p", name, p->rpath, handle); #endif end: #ifdef LOAD_ORDER_RANDOMIZATION @@ -3085,7 +3085,7 @@ int dlns_set_namespace_allowed_libs(const char * name, const char * allowed_libs return 0; } -int handle_asan_path_open(int fd, const char *name, ns_t *namespace, char *buf) +int handle_asan_path_open(int fd, const char *name, ns_t *namespace, char *buf, size_t buf_size) { LD_LOGD("handle_asan_path_open fd:%d, name:%s , namespace:%p , buf:%s.\n", fd, name, namespace, buf); int fd_tmp = fd; @@ -3097,14 +3097,14 @@ int handle_asan_path_open(int fd, const char *name, ns_t *namespace, char *buf) strcpy(new_lib_paths, namespace->asan_lib_paths); strcat(new_lib_paths, ":"); strcat(new_lib_paths, namespace->lib_paths); - fd_tmp = path_open(name, new_lib_paths, buf, sizeof buf); + fd_tmp = path_open(name, new_lib_paths, buf, buf_size); LD_LOGD("handle_asan_path_open path_open new_lib_paths:%s ,fd: %d.\n", new_lib_paths, fd_tmp); free(new_lib_paths); } else if (namespace->asan_lib_paths) { - fd_tmp = path_open(name, namespace->asan_lib_paths, buf, sizeof buf); + fd_tmp = path_open(name, namespace->asan_lib_paths, buf, buf_size); LD_LOGD("handle_asan_path_open path_open asan_lib_paths:%s ,fd: %d.\n", namespace->asan_lib_paths, fd_tmp); } else { - fd_tmp = path_open(name, namespace->lib_paths, buf, sizeof buf); + fd_tmp = path_open(name, namespace->lib_paths, buf, buf_size); LD_LOGD("handle_asan_path_open path_open lib_paths:%s ,fd: %d.\n", namespace->lib_paths, fd_tmp); } } @@ -3509,7 +3509,7 @@ static bool load_library_header(struct loadtask *task) } } if (g_is_asan) { - task->fd = handle_asan_path_open(task->fd, name, namespace, task->buf); + task->fd = handle_asan_path_open(task->fd, name, namespace, task->buf, sizeof task->buf); LD_LOGD("load_library handle_asan_path_open fd:%d.\n", task->fd); } else { if (task->fd == -1 && namespace->lib_paths) {