Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
9b9f2ce4
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9b9f2ce4
编写于
6月 27, 2022
作者:
R
roger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
customize the asan detection of some modules
Signed-off-by:
N
roger
<
kongzhengrong@huawei.com
>
上级
647e000c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
81 addition
and
0 deletion
+81
-0
services/init/init_service_manager.c
services/init/init_service_manager.c
+78
-0
services/init/standard/BUILD.gn
services/init/standard/BUILD.gn
+3
-0
未找到文件。
services/init/init_service_manager.c
浏览文件 @
9b9f2ce4
...
...
@@ -31,6 +31,9 @@
#include "init_utils.h"
#include "securec.h"
#include "service_control.h"
#ifdef ASAN_DETECTOR
#include "init_param.h"
#endif
#ifdef WITH_SELINUX
# include "init_selinux_param.h"
...
...
@@ -809,6 +812,78 @@ static int GetServiceSandbox(const cJSON *curItem, Service *service)
return
SERVICE_SUCCESS
;
}
#ifdef ASAN_DETECTOR
static
int
WrapPath
(
char
*
dest
,
size_t
len
,
char
*
source
,
int
i
)
{
char
*
q
=
source
;
char
*
p
=
dest
;
if
(
q
==
NULL
)
{
return
-
1
;
}
while
(
*
p
!=
'\0'
)
{
if
(
--
i
<=
0
)
{
int
ret
=
memmove_s
(
p
+
strlen
(
source
),
len
,
p
,
strlen
(
p
)
+
1
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
-
1
,
"Dest is %s, source is %s, ret is %d."
,
dest
,
source
,
ret
);
break
;
}
p
++
;
}
while
(
*
q
!=
'\0'
)
{
*
p
=
*
q
;
p
++
;
q
++
;
}
return
0
;
}
static
int
GetWrapServiceNameValue
(
const
char
*
serviceName
)
{
char
wrapServiceNameKey
[
PARAM_VALUE_LEN_MAX
]
=
{
0
};
char
wrapServiceNameValue
[
PARAM_VALUE_LEN_MAX
]
=
{
0
};
unsigned
int
valueLen
=
PARAM_VALUE_LEN_MAX
;
int
len
=
sprintf_s
(
wrapServiceNameKey
,
PARAM_VALUE_LEN_MAX
,
"wrap.%s"
,
serviceName
);
INIT_INFO_CHECK
(
len
>
0
&&
(
len
<
PARAM_VALUE_LEN_MAX
),
return
-
1
,
"Invalid to format wrapServiceNameKey"
);
int
ret
=
SystemReadParam
(
wrapServiceNameKey
,
wrapServiceNameValue
,
&
valueLen
);
INIT_INFO_CHECK
(
ret
==
0
,
return
-
1
,
"Not wrap %s."
,
serviceName
);
INIT_LOGI
(
"Asan: GetParameter %s the value is %s."
,
serviceName
,
wrapServiceNameValue
);
return
0
;
}
void
SetServicePathWithAsan
(
Service
*
service
)
{
char
tmpPathName
[
MAX_ONE_ARG_LEN
]
=
{
0
};
int
anchorPos
=
-
1
;
if
(
GetWrapServiceNameValue
(
service
->
name
)
!=
0
)
{
return
;
}
int
ret
=
strcpy_s
(
tmpPathName
,
MAX_ONE_ARG_LEN
,
service
->
pathArgs
.
argv
[
0
]);
INIT_ERROR_CHECK
(
ret
==
0
,
return
,
"Asan: failed to copy service path %s"
,
service
->
pathArgs
.
argv
[
0
]);
if
(
strstr
(
tmpPathName
,
"/system/bin"
)
!=
NULL
)
{
anchorPos
=
strlen
(
"/system"
)
+
1
;
}
else
if
(
strstr
(
tmpPathName
,
"/vendor/bin"
)
!=
NULL
)
{
anchorPos
=
strlen
(
"/vendor"
)
+
1
;
}
else
{
INIT_LOGE
(
"Asan: %s is not a system or vendor binary"
,
tmpPathName
);
return
;
}
ret
=
WrapPath
(
tmpPathName
,
MAX_ONE_ARG_LEN
,
"/asan"
,
anchorPos
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
,
"Asan: failed to add asan path."
);
free
(
service
->
pathArgs
.
argv
[
0
]);
service
->
pathArgs
.
argv
[
0
]
=
strdup
(
tmpPathName
);
INIT_LOGI
(
"Asan: replace module %s with %s successfully."
,
service
->
name
,
service
->
pathArgs
.
argv
[
0
]);
return
;
}
#endif
int
ParseOneService
(
const
cJSON
*
curItem
,
Service
*
service
)
{
INIT_CHECK_RETURN_VALUE
(
curItem
!=
NULL
&&
service
!=
NULL
,
SERVICE_FAILURE
);
...
...
@@ -827,6 +902,9 @@ int ParseOneService(const cJSON *curItem, Service *service)
INIT_LOGE
(
"Service %s is forbidden."
,
service
->
name
);
return
SERVICE_FAILURE
;
}
#ifdef ASAN_DETECTOR
SetServicePathWithAsan
(
service
);
#endif
ret
=
GetUid
(
cJSON_GetObjectItem
(
curItem
,
UID_STR_IN_CFG
),
&
service
->
servPerm
.
uID
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to get uid for service %s"
,
service
->
name
);
ret
=
GetServiceGids
(
curItem
,
service
);
...
...
services/init/standard/BUILD.gn
浏览文件 @
9b9f2ce4
...
...
@@ -117,6 +117,9 @@ ohos_executable("init") {
if (support_jsapi) {
defines += [ "SUPPORT_PROFILER_HIDEBUG" ]
}
if (asan_detector) {
defines += [ "ASAN_DETECTOR" ]
}
if (defined(product_name) && product_name == "rk3568") {
defines += [ "PRODUCT_RK" ]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录