feat: 支持Lms

1.【需求描述】:
   支持内核态堆内存非法访问检测,包括:越界访问、double free、释放后使用;支持libc常用高频函数内存检测;支持安全函数内存检测;读写检测可配可裁剪。
2.【方案描述】:
   (1).影子内存映射与标记
   (2).编译器使能-fsanitize=kernel-address 自动插桩检测点
   (3).实时校验影子内存的合法性;
   (4).错误访问打印回溯栈

BREAKING CHANGE: 新增支持API:

LOS_LmsCheckPoolAdd使能检测指定内存池
LOS_LmsCheckPoolDel不检测指定内存池
LOS_LmsAddrProtect为指定内存段上锁,不允许访问
LOS_LmsAddrDisableProtect去能指定内存段的访问保护

Close #I4HYBG

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
Change-Id: Ia356a003088b9df37df667ea8ba91c80f5a41967
This commit is contained in:
LiteOS2021
2021-11-26 16:33:06 +08:00
parent 2cf3b19563
commit 7b838e8a7b
42 changed files with 3142 additions and 21 deletions

View File

@@ -33,7 +33,21 @@ import("//third_party/bounds_checking_function/libsec_src.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = libsec_sources
if (defined(LOSCFG_KERNEL_LMS)) {
if ("$ohos_build_compiler" == "gcc") {
cflags_c = [ "-fsanitize=kernel-address" ]
} else {
cflags_c = [
"-fsanitize=kernel-address",
"-mllvm",
"-asan-instrumentation-with-call-threshold=0",
"-mllvm",
"-asan-stack=0",
"-mllvm",
"-asan-globals=0",
]
}
}
public_configs = [ ":public" ]
}