Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
ed9cd174
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
大约 1 年 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed9cd174
编写于
6月 23, 2022
作者:
W
wangjiahui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RM003 commit
Signed-off-by:
N
wangjiahui
<
wangjiahui27@huawei.com
>
上级
58794811
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
53 deletion
+51
-53
libc-test/src/functionalext/dlns/dlns_inherit.c
libc-test/src/functionalext/dlns/dlns_inherit.c
+1
-1
porting/linux/user/config/ld-musl-namespace-aarch64-test.ini
porting/linux/user/config/ld-musl-namespace-aarch64-test.ini
+8
-9
porting/linux/user/config/ld-musl-namespace-arm-test.ini
porting/linux/user/config/ld-musl-namespace-arm-test.ini
+8
-9
porting/linux/user/ldso/dynlink.c
porting/linux/user/ldso/dynlink.c
+34
-34
未找到文件。
libc-test/src/functionalext/dlns/dlns_inherit.c
浏览文件 @
ed9cd174
...
...
@@ -106,7 +106,7 @@ void dlns_inherit_0400(void)
EXPECT_EQ
(
"dlns_inherit_0400"
,
dlns_inherit
(
&
dlnsA
,
&
dlnsB
,
dllName
),
EOK
);
void
*
handle
=
dlopen_ns
(
&
dlnsA
,
dllName
,
RTLD_LAZY
);
EXPECT_
NE
(
"dlns_inherit_03
00"
,
handle
,
NULL
);
EXPECT_
PTRNE
(
"dlns_inherit_04
00"
,
handle
,
NULL
);
dlclose
(
handle
);
EXPECT_EQ
(
"dlns_inherit_0400"
,
dlns_inherit
(
&
dlnsAA
,
&
dlnsA
,
NULL
),
EOK
);
...
...
porting/linux/user/config/ld-musl-namespace-aarch64-test.ini
浏览文件 @
ed9cd174
...
...
@@ -9,23 +9,22 @@
[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
#ns_no_allowed_libs
未配 allowed libs
#ns_no_allowed_libs
,allowed libs not configed
namespace.ns_no_allowed_libs.separated
=
true
namespace.ns_no_allowed_libs.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
#ns_normal
正常的带有visible属性
#ns_normal
,normal namespace
namespace.ns_normal.separated
=
true
namespace.ns_normal.visible
=
true
namespace.ns_normal.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_normal.allowed.libs
=
libdlopen_ns_dso.so
#ns_wrong_lib_path
在 allowed_libs 内,但是不在 env or lib or permitted Path 不匹配
#ns_wrong_lib_path
,path in allowed_libs,but not in env or lib or permitted Path
namespace.ns_wrong_lib_path.separated
=
true
namespace.ns_wrong_lib_path.lib.paths
=
src/common/
namespace.ns_wrong_lib_path.allowed.libs
=
libdlopen_ns_dso.so
namespace.ns_wrong_lib_path.permitted.paths
=
/data/tests
#ns_wrong_allowed_path
不在 allowed_libs 内
#ns_wrong_allowed_path
,path not in allowed_libs
namespace.ns_wrong_allowed_path.separated
=
true
namespace.ns_wrong_allowed_path.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_wrong_allowed_path.allowed.libs
=
libdlopen_dso.so
...
...
@@ -35,22 +34,22 @@
#for testing inheritance
namespace.for_inherit_AA.separated
=
true
#inherited_class
用于测试继承属性
#inherited_class
namespace.inherited_class.separated
=
true
namespace.inherited_class.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.inherited_class.allowed.libs
=
libdlopen_ns_dso.so:sharedlibtest.so
#ns_separated_flase
不是严格隔离的
#ns_separated_flase
namespace.ns_separated_flase.separated
=
false
namespace.ns_separated_flase.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_separated_flase.allowed.libs
=
libdlopen_ns_dso.so
#ns_asan_lib_path
测试
asan.lib.paths
#ns_asan_lib_path
,testing
asan.lib.paths
namespace.ns_asan_lib_path.separated
=
true
namespace.ns_asan_lib_path.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_asan_lib_path.asan.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns/B
#ns_asan_permit_path
测试
asan.permitted.paths
#ns_asan_permit_path
,testing
asan.permitted.paths
namespace.ns_asan_permit_path.separated
=
true
namespace.ns_asan_permit_path.permitted.paths
=
/data/tests/libc-test/src/functionalext/dlns/C
namespace.ns_asan_permit_path.asan.permitted.paths
=
/data/tests/libc-test/src/functionalext/dlns/B
...
...
porting/linux/user/config/ld-musl-namespace-arm-test.ini
浏览文件 @
ed9cd174
...
...
@@ -9,23 +9,22 @@
[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
#ns_no_allowed_libs
未配 allowed libs
#ns_no_allowed_libs
,allowed libs not configed
namespace.ns_no_allowed_libs.separated
=
true
namespace.ns_no_allowed_libs.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
#ns_normal
正常的带有visible属性
#ns_normal
,normal namespace
namespace.ns_normal.separated
=
true
namespace.ns_normal.visible
=
true
namespace.ns_normal.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_normal.allowed.libs
=
libdlopen_ns_dso.so
#ns_wrong_lib_path
在 allowed_libs 内,但是不在 env or lib or permitted Path 不匹配
#ns_wrong_lib_path
,path in allowed_libs,but not in env or lib or permitted Path
namespace.ns_wrong_lib_path.separated
=
true
namespace.ns_wrong_lib_path.lib.paths
=
src/common/
namespace.ns_wrong_lib_path.allowed.libs
=
libdlopen_ns_dso.so
namespace.ns_wrong_lib_path.permitted.paths
=
/data/tests
#ns_wrong_allowed_path
不在 allowed_libs 内
#ns_wrong_allowed_path
,path not in allowed_libs
namespace.ns_wrong_allowed_path.separated
=
true
namespace.ns_wrong_allowed_path.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_wrong_allowed_path.allowed.libs
=
libdlopen_dso.so
...
...
@@ -35,22 +34,22 @@
#for testing inheritance
namespace.for_inherit_AA.separated
=
true
#inherited_class
用于测试继承属性
#inherited_class
namespace.inherited_class.separated
=
true
namespace.inherited_class.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.inherited_class.allowed.libs
=
libdlopen_ns_dso.so:sharedlibtest.so
#ns_separated_flase
不是严格隔离的
#ns_separated_flase
namespace.ns_separated_flase.separated
=
false
namespace.ns_separated_flase.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_separated_flase.allowed.libs
=
libdlopen_ns_dso.so
#ns_asan_lib_path
测试
asan.lib.paths
#ns_asan_lib_path
,testing
asan.lib.paths
namespace.ns_asan_lib_path.separated
=
true
namespace.ns_asan_lib_path.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns
namespace.ns_asan_lib_path.asan.lib.paths
=
/data/tests/libc-test/src/functionalext/dlns/B
#ns_asan_permit_path
测试
asan.permitted.paths
#ns_asan_permit_path
,testing
asan.permitted.paths
namespace.ns_asan_permit_path.separated
=
true
namespace.ns_asan_permit_path.permitted.paths
=
/data/tests/libc-test/src/functionalext/dlns/C
namespace.ns_asan_permit_path.asan.permitted.paths
=
/data/tests/libc-test/src/functionalext/dlns/B
...
...
porting/linux/user/ldso/dynlink.c
浏览文件 @
ed9cd174
...
...
@@ -189,12 +189,12 @@ static bool get_app_path(char *path, size_t size)
static
void
init_default_namespace
(
struct
dso
*
app
)
{
ns_t
*
default_ns
=
get_default_ns
();
memset
(
default_ns
,
0
,
sizeof
*
default_ns
);
ns_t
*
default_ns
=
get_default_ns
();
memset
(
default_ns
,
0
,
sizeof
*
default_ns
);
ns_set_name
(
default_ns
,
NS_DEFAULT_NAME
);
if
(
env_path
)
ns_set_env_paths
(
default_ns
,
env_path
);
if
(
env_path
)
ns_set_env_paths
(
default_ns
,
env_path
);
ns_set_lib_paths
(
default_ns
,
sys_path
);
ns_set_separated
(
default_ns
,
false
);
ns_set_separated
(
default_ns
,
false
);
app
->
namespace
=
default_ns
;
ns_add_dso
(
default_ns
,
app
);
LD_LOGD
(
"init_default_namespace default_namespace:"
...
...
@@ -203,7 +203,7 @@ static void init_default_namespace(struct dso *app)
"env_path:%s ,"
"separated: false.
\n
"
,
sys_path
,
env_path
);
return
;
return
;
}
static
void
set_ns_attrs
(
ns_t
*
ns
,
ns_configor
*
conf
)
...
...
@@ -255,7 +255,7 @@ static void set_ns_inherits(ns_t *ns, ns_configor *conf)
strlist
*
inherits
=
conf
->
get_inherits
(
ns
->
ns_name
);
if
(
inherits
)
{
for
(
size_t
i
=
0
;
i
<
inherits
->
num
;
i
++
)
{
ns_t
*
inherited_ns
=
find_ns_by_name
(
inherits
->
strs
[
i
]);
ns_t
*
inherited_ns
=
find_ns_by_name
(
inherits
->
strs
[
i
]);
if
(
inherited_ns
)
{
char
*
shared_libs
=
conf
->
get_inherit_shared_libs
(
ns
->
ns_name
,
inherited_ns
->
ns_name
);
ns_add_inherit
(
ns
,
inherited_ns
,
shared_libs
);
...
...
@@ -272,7 +272,7 @@ static void set_ns_inherits(ns_t *ns, ns_configor *conf)
inherited_ns
->
asan_lib_paths
,
inherited_ns
->
permitted_paths
,
inherited_ns
->
asan_permitted_paths
,
inherited_ns
->
allowed_libs
);
}
}
}
strlist_free
(
inherits
);
}
else
{
LD_LOGW
(
"set_ns_inherits inherits is NULL!
\n
"
);
...
...
@@ -281,7 +281,7 @@ static void set_ns_inherits(ns_t *ns, ns_configor *conf)
static
void
init_namespace
(
struct
dso
*
app
)
{
char
app_path
[
PATH_MAX
+
1
];
char
app_path
[
PATH_MAX
+
1
];
if
(
!
get_app_path
(
app_path
,
sizeof
app_path
))
{
strcpy
(
app_path
,
app
->
name
);
}
...
...
@@ -298,7 +298,7 @@ static void init_namespace(struct dso *app)
char
file_path
[
sizeof
"/etc/ld-musl-namespace-"
+
sizeof
(
LDSO_ARCH
)
+
sizeof
".ini"
+
1
];
(
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
);
int
ret
=
conf
->
parse
(
file_path
,
app_path
);
if
(
ret
<
0
)
{
LD_LOGE
(
"init_namespace ini file parse failed!
\n
"
);
/* Init_default_namespace is required even if the ini file parsing fails */
...
...
@@ -322,24 +322,24 @@ static void init_namespace(struct dso *app)
configor_free
();
return
;
}
strlist
*
s_ns
=
conf
->
get_namespaces
();
if
(
s_ns
)
{
for
(
size_t
i
=
0
;
i
<
s_ns
->
num
;
i
++
)
{
ns_t
*
ns
=
ns_alloc
();
strlist
*
s_ns
=
conf
->
get_namespaces
();
if
(
s_ns
)
{
for
(
size_t
i
=
0
;
i
<
s_ns
->
num
;
i
++
)
{
ns_t
*
ns
=
ns_alloc
();
ns_set_name
(
ns
,
s_ns
->
strs
[
i
]);
set_ns_attrs
(
ns
,
conf
);
ns_add_dso
(
ns
,
app
);
nslist_add_ns
(
ns
);
}
strlist_free
(
s_ns
);
}
/* Set inherited namespace */
nslist_add_ns
(
ns
);
}
strlist_free
(
s_ns
);
}
/* Set inherited namespace */
set_ns_inherits
(
d_ns
,
conf
);
for
(
size_t
i
=
0
;
i
<
nsl
->
num
;
i
++
)
{
set_ns_inherits
(
nsl
->
nss
[
i
],
conf
);
}
configor_free
();
return
;
configor_free
();
return
;
}
static
int
dl_strcmp
(
const
char
*
l
,
const
char
*
r
)
...
...
@@ -433,7 +433,7 @@ static Sym *sysv_lookup(const char *s, uint32_t h, struct dso *dso)
char
*
strings
=
dso
->
strings
;
for
(
i
=
hashtab
[
2
+
h
%
hashtab
[
0
]];
i
;
i
=
hashtab
[
2
+
hashtab
[
0
]
+
i
])
{
if
((
!
dso
->
versym
||
dso
->
versym
[
i
]
>=
0
)
&&
(
!
strcmp
(
s
,
strings
+
syms
[
i
].
st_name
)))
&&
(
!
strcmp
(
s
,
strings
+
syms
[
i
].
st_name
)))
return
syms
+
i
;
}
return
0
;
...
...
@@ -452,7 +452,7 @@ static Sym *gnu_lookup(uint32_t h1, uint32_t *hashtab, struct dso *dso, const ch
for
(
h1
|=
1
;
;
i
++
)
{
uint32_t
h2
=
*
hashval
++
;
if
((
h1
==
(
h2
|
1
))
&&
(
!
dso
->
versym
||
dso
->
versym
[
i
]
>=
0
)
&&
!
strcmp
(
s
,
dso
->
strings
+
dso
->
syms
[
i
].
st_name
))
&&
!
strcmp
(
s
,
dso
->
strings
+
dso
->
syms
[
i
].
st_name
))
return
dso
->
syms
+
i
;
if
(
h2
&
1
)
break
;
}
...
...
@@ -499,7 +499,7 @@ static inline struct symdef find_sym2(struct dso *dso, const char *s, int need_d
if
(
!
sym
)
continue
;
if
(
!
sym
->
st_shndx
)
if
(
need_def
||
(
sym
->
st_info
&
0xf
)
==
STT_TLS
||
ARCH_SYM_REJECT_UND
(
sym
))
||
ARCH_SYM_REJECT_UND
(
sym
))
continue
;
if
(
!
sym
->
st_value
)
if
((
sym
->
st_info
&
0xf
)
!=
STT_TLS
)
...
...
@@ -572,7 +572,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
?
(
struct
symdef
){
.
dso
=
dso
,
.
sym
=
sym
}
:
find_sym
(
ctx
,
name
,
type
==
REL_PLT
);
if
(
!
def
.
sym
&&
(
sym
->
st_shndx
!=
SHN_UNDEF
||
sym
->
st_info
>>
4
!=
STB_WEAK
))
{
||
sym
->
st_info
>>
4
!=
STB_WEAK
))
{
if
(
dso
->
lazy
&&
(
type
==
REL_PLT
||
type
==
REL_GOT
))
{
dso
->
lazy
[
3
*
dso
->
lazy_cnt
+
0
]
=
rel
[
0
];
dso
->
lazy
[
3
*
dso
->
lazy_cnt
+
1
]
=
rel
[
1
];
...
...
@@ -595,7 +595,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
tls_val
=
def
.
sym
?
def
.
sym
->
st_value
:
0
;
if
((
type
==
REL_TPOFF
||
type
==
REL_TPOFF_NEG
)
&&
def
.
dso
->
tls_id
>
static_tls_cnt
)
{
&&
def
.
dso
->
tls_id
>
static_tls_cnt
)
{
error
(
"Error relocating %s: %s: initial-exec TLS "
"resolves to dynamic definition in %s"
,
dso
->
name
,
name
,
def
.
dso
->
name
);
...
...
@@ -932,7 +932,7 @@ static void *map_library(int fd, struct dso *dso)
/* Check if the programs headers are in this load segment, and
* if so, record the address for use by dl_iterate_phdr. */
if
(
!
dso
->
phdr
&&
eh
->
e_phoff
>=
ph
->
p_offset
&&
eh
->
e_phoff
+
phsize
<=
ph
->
p_offset
+
ph
->
p_filesz
)
{
&&
eh
->
e_phoff
+
phsize
<=
ph
->
p_offset
+
ph
->
p_filesz
)
{
dso
->
phdr
=
(
void
*
)(
base
+
ph
->
p_vaddr
+
(
eh
->
e_phoff
-
ph
->
p_offset
));
dso
->
phnum
=
eh
->
e_phnum
;
...
...
@@ -959,7 +959,7 @@ static void *map_library(int fd, struct dso *dso)
for
(
i
=
0
;
((
size_t
*
)(
base
+
dyn
))[
i
];
i
+=
2
)
if
(((
size_t
*
)(
base
+
dyn
))[
i
]
==
DT_TEXTREL
)
{
if
(
mprotect
(
map
,
map_len
,
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
)
&&
errno
!=
ENOSYS
)
&&
errno
!=
ENOSYS
)
goto
error
;
break
;
}
...
...
@@ -1387,7 +1387,7 @@ struct dso *load_library(const char *name, struct dso *needed_by, ns_t *namespac
* false positives from interposition-hack libraries. */
decode_dyn
(
&
temp_dso
);
if
(
find_sym
(
&
temp_dso
,
"__libc_start_main"
,
1
).
sym
&&
find_sym
(
&
temp_dso
,
"stdin"
,
1
).
sym
)
{
find_sym
(
&
temp_dso
,
"stdin"
,
1
).
sym
)
{
unmap_library
(
&
temp_dso
);
return
load_library
(
"libc.so"
,
needed_by
,
namespace
,
true
);
}
...
...
@@ -1625,8 +1625,8 @@ static void reloc_all(struct dso *p)
do_relocs
(
p
,
laddr
(
p
,
dyn
[
DT_RELA
]),
dyn
[
DT_RELASZ
],
3
);
if
(
head
!=
&
ldso
&&
p
->
relro_start
!=
p
->
relro_end
&&
mprotect
(
laddr
(
p
,
p
->
relro_start
),
p
->
relro_end
-
p
->
relro_start
,
PROT_READ
)
&&
errno
!=
ENOSYS
)
{
mprotect
(
laddr
(
p
,
p
->
relro_start
),
p
->
relro_end
-
p
->
relro_start
,
PROT_READ
)
&&
errno
!=
ENOSYS
)
{
error
(
"Error relocating %s: RELRO protection failed: %m"
,
p
->
name
);
if
(
runtime
)
longjmp
(
*
rtld_fail
,
1
);
...
...
@@ -2032,7 +2032,7 @@ void __dls3(size_t *sp, size_t *auxv)
if
(
app
.
tls
.
size
)
app
.
tls
.
image
=
laddr
(
&
app
,
tls_image
);
if
(
interp_off
)
ldso
.
name
=
laddr
(
&
app
,
interp_off
);
if
((
aux
[
0
]
&
(
1UL
<<
AT_EXECFN
))
&&
strncmp
((
char
*
)
aux
[
AT_EXECFN
],
"/proc/"
,
6
))
&&
strncmp
((
char
*
)
aux
[
AT_EXECFN
],
"/proc/"
,
6
))
app
.
name
=
(
char
*
)
aux
[
AT_EXECFN
];
else
app
.
name
=
argv
[
0
];
...
...
@@ -2425,7 +2425,7 @@ void *dlopen(const char *file, int mode)
{
const
void
*
caller_addr
=
__builtin_return_address
(
0
);
LD_LOGI
(
"dlopen file:%s, mode:%d ,caller_addr:%p .
\n
"
,
file
,
mode
,
caller_addr
);
return
dlopen_impl
(
file
,
mode
,
NULL
,
caller_addr
);
return
dlopen_impl
(
file
,
mode
,
NULL
,
caller_addr
);
}
void
dlns_init
(
Dl_namespace
*
dlns
,
const
char
*
name
)
...
...
@@ -2447,7 +2447,7 @@ void *dlopen_ns(Dl_namespace *dlns, const char *file, int mode)
{
const
void
*
caller_addr
=
__builtin_return_address
(
0
);
LD_LOGI
(
"dlopen_ns file:%s, mode:%d , caller_addr:%p , dlns->name:%s.
\n
"
,
file
,
mode
,
caller_addr
,
dlns
->
name
);
return
dlopen_impl
(
file
,
mode
,
dlns
->
name
,
caller_addr
);
return
dlopen_impl
(
file
,
mode
,
dlns
->
name
,
caller_addr
);
}
int
dlns_create
(
Dl_namespace
*
dlns
,
const
char
*
lib_path
)
...
...
@@ -2545,7 +2545,7 @@ static void *addr2dso(size_t a)
if
(
DL_FDPIC
&&
p
->
loadmap
)
{
for
(
i
=
0
;
i
<
p
->
loadmap
->
nsegs
;
i
++
)
{
if
(
a
-
p
->
loadmap
->
segs
[
i
].
p_vaddr
<
p
->
loadmap
->
segs
[
i
].
p_memsz
)
<
p
->
loadmap
->
segs
[
i
].
p_memsz
)
return
p
;
}
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录