Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
e8e21fcc
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e8e21fcc
编写于
2月 02, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 02, 2023
浏览文件
操作
浏览文件
下载
差异文件
!1091 LMS特性安全合规整改
Merge pull request !1091 from JerryH/lms
上级
f3a7a9c6
c592fe73
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
56 addition
and
36 deletion
+56
-36
apps/config.mk
apps/config.mk
+4
-0
apps/lms/src/sample_usr_lms.c
apps/lms/src/sample_usr_lms.c
+2
-1
kernel/base/mem/tlsf/los_memory.c
kernel/base/mem/tlsf/los_memory.c
+20
-11
kernel/extended/lms/los_lms.c
kernel/extended/lms/los_lms.c
+22
-21
kernel/extended/lms/los_lms_pri.h
kernel/extended/lms/los_lms_pri.h
+2
-1
lib/libc/musl/src/arch/arm/memset.S
lib/libc/musl/src/arch/arm/memset.S
+4
-0
tools/build/liteos.ld
tools/build/liteos.ld
+1
-1
tools/build/liteos_llvm.ld
tools/build/liteos_llvm.ld
+1
-1
未找到文件。
apps/config.mk
浏览文件 @
e8e21fcc
...
...
@@ -58,6 +58,10 @@ APP_SUBDIRS += mksh
APP_SUBDIRS
+=
toybox
endif
ifeq
($(LOSCFG_KERNEL_LMS), y)
APP_SUBDIRS
+=
lms
endif
ifeq
($(LOSCFG_USER_INIT_DEBUG), y)
APP_SUBDIRS
+=
init
endif
...
...
apps/lms/src/sample_usr_lms.c
浏览文件 @
e8e21fcc
...
...
@@ -231,7 +231,7 @@ int main(int argc, char * const *argv)
printf
(
"
\n
############### Lms Test start ###############
\n
"
);
char
*
tmp
=
(
char
*
)
malloc
(
5000
);
/* 5000: test mem size */
if
(
tmp
==
NULL
)
{
return
;
return
-
1
;
}
LmsMallocTest
();
LmsReallocTest
();
...
...
@@ -246,4 +246,5 @@ int main(int argc, char * const *argv)
LmsFreeTest
();
free
(
tmp
);
printf
(
"
\n
############### Lms Test End ###############
\n
"
);
return
0
;
}
kernel/base/mem/tlsf/los_memory.c
浏览文件 @
e8e21fcc
...
...
@@ -837,6 +837,9 @@ STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
struct
OsMemPoolHead
*
poolHead
=
(
struct
OsMemPoolHead
*
)
pool
;
struct
OsMemNodeHead
*
newNode
=
NULL
;
struct
OsMemNodeHead
*
endNode
=
NULL
;
(
VOID
)
memset_s
(
poolHead
,
sizeof
(
struct
OsMemPoolHead
),
0
,
sizeof
(
struct
OsMemPoolHead
));
#ifdef LOSCFG_KERNEL_LMS
UINT32
resize
=
0
;
if
(
g_lms
!=
NULL
)
{
...
...
@@ -848,7 +851,6 @@ STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
size
=
(
resize
==
0
)
?
size
:
resize
;
}
#endif
(
VOID
)
memset
(
poolHead
,
0
,
sizeof
(
struct
OsMemPoolHead
));
LOS_SpinInit
(
&
poolHead
->
spinlock
);
poolHead
->
info
.
pool
=
pool
;
...
...
@@ -885,9 +887,14 @@ STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
}
#ifdef LOSCFG_MEM_MUL_POOL
STATIC
VOID
OsMemPoolDeinit
(
VOID
*
pool
)
STATIC
VOID
OsMemPoolDeinit
(
const
VOID
*
pool
,
UINT32
size
)
{
(
VOID
)
memset
(
pool
,
0
,
sizeof
(
struct
OsMemPoolHead
));
#ifdef LOSCFG_KERNEL_LMS
if
(
g_lms
!=
NULL
)
{
g_lms
->
deInit
(
pool
);
}
#endif
(
VOID
)
memset_s
(
pool
,
size
,
0
,
sizeof
(
struct
OsMemPoolHead
));
}
STATIC
UINT32
OsMemPoolAdd
(
VOID
*
pool
,
UINT32
size
)
...
...
@@ -961,7 +968,7 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
#ifdef LOSCFG_MEM_MUL_POOL
if
(
OsMemPoolAdd
(
pool
,
size
))
{
(
VOID
)
OsMemPoolDe
init
(
pool
);
(
VOID
)
OsMemPoolDe
Init
(
pool
,
size
);
return
OS_ERROR
;
}
#endif
...
...
@@ -973,17 +980,21 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
#ifdef LOSCFG_MEM_MUL_POOL
UINT32
LOS_MemDeInit
(
VOID
*
pool
)
{
if
(
pool
==
NULL
)
{
struct
OsMemPoolHead
*
tmpPool
=
(
struct
OsMemPoolHead
*
)
pool
;
if
((
tmpPool
==
NULL
)
||
(
tmpPool
->
info
.
pool
!=
pool
)
||
(
tmpPool
->
info
.
totalSize
<=
OS_MEM_MIN_POOL_SIZE
))
{
return
OS_ERROR
;
}
if
(
OsMemPoolDelete
(
p
ool
))
{
if
(
OsMemPoolDelete
(
tmpP
ool
))
{
return
OS_ERROR
;
}
OsMemPoolDe
init
(
pool
);
OsMemPoolDe
Init
(
tmpPool
,
tmpPool
->
info
.
totalSize
);
OsHookCall
(
LOS_HOOK_TYPE_MEM_DEINIT
,
p
ool
);
OsHookCall
(
LOS_HOOK_TYPE_MEM_DEINIT
,
tmpP
ool
);
return
LOS_OK
;
}
...
...
@@ -1896,7 +1907,7 @@ UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus)
return
LOS_NOK
;
}
(
VOID
)
memset
(
poolStatus
,
0
,
sizeof
(
LOS_MEM_POOL_STATUS
));
(
VOID
)
memset
_s
(
poolStatus
,
sizeof
(
LOS_MEM_POOL_STATUS
)
,
0
,
sizeof
(
LOS_MEM_POOL_STATUS
));
struct
OsMemNodeHead
*
tmpNode
=
NULL
;
struct
OsMemNodeHead
*
endNode
=
NULL
;
...
...
@@ -2070,5 +2081,3 @@ BOOL OsMemIsHeapNode(const VOID *ptr)
#endif
return
FALSE
;
}
kernel/extended/lms/los_lms.c
浏览文件 @
e8e21fcc
...
...
@@ -80,20 +80,25 @@ EXIT:
STATIC
LmsMemListNode
*
OsLmsGetPoolNodeFromAddr
(
UINTPTR
addr
)
{
LmsMemListNode
*
current
=
NULL
;
LmsMemListNode
*
previous
=
NULL
;
LOS_DL_LIST
*
listHead
=
&
g_lmsCheckPoolList
;
if
(
LOS_ListEmpty
(
&
g_lmsCheckPoolList
))
{
goto
EXIT
;
return
NULL
;
}
LOS_DL_LIST_FOR_EACH_ENTRY
(
current
,
listHead
,
LmsMemListNode
,
node
)
{
if
((
addr
>=
current
->
poolAddr
)
&&
(
addr
<
current
->
poolAddr
+
current
->
poolSize
))
{
return
current
;
if
((
addr
<
current
->
poolAddr
)
||
(
addr
>=
(
current
->
poolAddr
+
current
->
poolSize
)))
{
continue
;
}
if
((
previous
==
NULL
)
||
((
previous
->
poolAddr
<=
current
->
poolAddr
)
&&
((
current
->
poolAddr
+
current
->
poolSize
)
<=
(
previous
->
poolAddr
+
previous
->
poolSize
))))
{
previous
=
current
;
}
}
EXIT:
return
NULL
;
return
previous
;
}
STATIC
LmsMemListNode
*
OsLmsCheckPoolCreate
(
VOID
)
...
...
@@ -123,18 +128,12 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
LMS_LOCK
(
intSave
);
lmsPoolNode
=
OsLmsGetPoolNodeFromAddr
((
UINTPTR
)
pool
);
if
(
lmsPoolNode
!=
NULL
)
{
/* if pool range already on checklist */
if
(
lmsPoolNode
->
poolAddr
!=
(
UINTPTR
)
pool
)
{
/* pool is a subset of lmsPoolNode->poolAddr */
/* do not add it again, just return */
PRINT_DEBUG
(
"[LMS]pool %p already on lms checklist !
\n
"
,
pool
);
LMS_UNLOCK
(
intSave
);
return
size
;
/* return size indicate the shadow memory init successful */
}
else
{
/* Re-initialize the same pool, maybe with different size */
/* delete the old node, then add a new one */
lmsPoolNode
->
used
=
LMS_POOL_UNUSED
;
LOS_ListDelete
(
&
(
lmsPoolNode
->
node
));
}
lmsPoolNode
=
OsLmsGetPoolNode
(
pool
);
if
(
lmsPoolNode
!=
NULL
)
{
/* if pool already on checklist */
/* Re-initialize the same pool, maybe with different size */
/* delete the old node, then add a new one */
lmsPoolNode
->
used
=
LMS_POOL_UNUSED
;
LOS_ListDelete
(
&
(
lmsPoolNode
->
node
));
}
lmsPoolNode
=
OsLmsCheckPoolCreate
();
...
...
@@ -150,7 +149,8 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
lmsPoolNode
->
shadowStart
=
(
UINTPTR
)
poolAddr
+
realSize
;
lmsPoolNode
->
shadowSize
=
poolAddr
+
size
-
lmsPoolNode
->
shadowStart
;
/* init shadow value */
(
VOID
)
memset
((
VOID
*
)
lmsPoolNode
->
shadowStart
,
LMS_SHADOW_AFTERFREE_U8
,
lmsPoolNode
->
shadowSize
);
(
VOID
)
memset_s
((
VOID
*
)
lmsPoolNode
->
shadowStart
,
lmsPoolNode
->
shadowSize
,
LMS_SHADOW_AFTERFREE_U8
,
lmsPoolNode
->
shadowSize
);
LOS_ListAdd
(
&
g_lmsCheckPoolList
,
&
(
lmsPoolNode
->
node
));
...
...
@@ -179,10 +179,11 @@ Release:
STATIC
UINT32
OsLmsInit
(
VOID
)
{
(
VOID
)
memset
(
g_lmsCheckPoolArray
,
0
,
sizeof
(
g_lmsCheckPoolArray
));
(
VOID
)
memset
_s
(
g_lmsCheckPoolArray
,
sizeof
(
g_lmsCheckPoolArray
)
,
0
,
sizeof
(
g_lmsCheckPoolArray
));
LOS_ListInit
(
&
g_lmsCheckPoolList
);
static
LmsHook
hook
=
{
.
init
=
LOS_LmsCheckPoolAdd
,
.
deInit
=
LOS_LmsCheckPoolDel
,
.
mallocMark
=
OsLmsLosMallocMark
,
.
freeMark
=
OsLmsLosFreeMark
,
.
simpleMark
=
OsLmsSimpleMark
,
...
...
@@ -595,7 +596,7 @@ VOID OsLmsReportError(UINTPTR p, UINT32 size, UINT32 errMod)
(
VOID
)
LOS_AtomicAdd
(
&
g_checkDepth
,
1
);
LMS_LOCK
(
intSave
);
(
VOID
)
memset
(
&
info
,
0
,
sizeof
(
LmsAddrInfo
));
(
VOID
)
memset
_s
(
&
info
,
sizeof
(
LmsAddrInfo
)
,
0
,
sizeof
(
LmsAddrInfo
));
PRINT_ERR
(
"***** Kernel Address Sanitizer Error Detected Start *****
\n
"
);
...
...
@@ -766,4 +767,4 @@ VOID __asan_handle_no_return(VOID)
return
;
}
LOS_MODULE_INIT
(
OsLmsInit
,
LOS_INIT_LEVEL_KMOD_PREVM
);
\ No newline at end of file
LOS_MODULE_INIT
(
OsLmsInit
,
LOS_INIT_LEVEL_KMOD_PREVM
);
kernel/extended/lms/los_lms_pri.h
浏览文件 @
e8e21fcc
...
...
@@ -95,6 +95,7 @@ typedef struct {
typedef
struct
{
UINT32
(
*
init
)(
const
VOID
*
pool
,
UINT32
size
);
VOID
(
*
deInit
)(
const
VOID
*
pool
);
VOID
(
*
mallocMark
)(
const
VOID
*
curNodeStart
,
const
VOID
*
nextNodeStart
,
UINT32
nodeHeadSize
);
VOID
(
*
freeMark
)(
const
VOID
*
curNodeStart
,
const
VOID
*
nextNodeStart
,
UINT32
nodeHeadSize
);
VOID
(
*
simpleMark
)(
UINTPTR
startAddr
,
UINTPTR
endAddr
,
UINT32
value
);
...
...
@@ -132,4 +133,4 @@ extern SANITIZER_INTERFACE_ATTRIBUTE VOID __asan_handle_no_return(VOID);
#endif
/* __cplusplus */
#endif
/* __cplusplus */
#endif
/* _LOS_LMS_PRI_H */
\ No newline at end of file
#endif
/* _LOS_LMS_PRI_H */
lib/libc/musl/src/arch/arm/memset.S
浏览文件 @
e8e21fcc
...
...
@@ -131,6 +131,10 @@ Lreturn:
pop
{
r4
}
bx
lr
Lfunc_end
:
#if defined(LOSCFG_KERNEL_LMS)
.
size
__memset
,
Lfunc_end
-
__memset
#else
.
size
memset
,
Lfunc_end
-
memset
#endif
.
cantunwind
.
fnend
@
--
End
function
tools/build/liteos.ld
浏览文件 @
e8e21fcc
...
...
@@ -139,7 +139,7 @@ SECTIONS
.ctors : ALIGN(0x4) {
__ctor_list__ = .;
KEEP (*(.ctors .init_array))
KEEP (*(.ctors .init_array
.* .init_array
))
__ctor_end__ = .;
} > ram
.dtors : ALIGN(0x4) {
...
...
tools/build/liteos_llvm.ld
浏览文件 @
e8e21fcc
...
...
@@ -45,7 +45,7 @@ SECTIONS
.ctors : ALIGN(0x4) {
__ctor_list__ = .;
KEEP (*(.ctors .init_array))
KEEP (*(.ctors .init_array
.* .init_array
))
__ctor_end__ = .;
} > ram
.dtors : ALIGN(0x4) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录