提交 fc3893a8 编写于 作者: X xiacong

bugfix: 修复辅助统计系统调用的问题

Signed-off-by: Nxiacong <xiacong4@huawei.com>
Change-Id: I82179b6dae6e6c7a8e770555787aa24dc02030ed
Signed-off-by: Nxiacong <xiacong4@huawei.com>
上级 923f8528
......@@ -59,8 +59,9 @@ def get_item_content(name_nr_table, arch_nr_table):
syscall_name_dict.get('arm').remove(func_name)
else:
content = '{}{};arm64\n'.format(content, func_name)
content = '{}{};arm\n'.format(content, ';arm\n'.join([func_name for func_name in syscall_name_dict.get('arm')]))
if not syscall_name_dict.get('arm'):
content = '{}{};arm\n'.format(content, ';arm\n'.join(
[func_name for func_name in syscall_name_dict.get('arm')]))
return content
......@@ -72,9 +73,9 @@ def gen_output_file(filter_name, content):
output_file.write(content)
def parse_file(file_name):
def parse_file(file_name, arch_nr):
with open(file_name) as f:
parse_line(f)
parse_line(f, arch_nr)
def converse_fuction_name_nr(dict_dst, dict_src):
......
......@@ -53,9 +53,9 @@ def create_needed_file(elf_path, locate_path, cmd, suffix):
def generate_libc_asm(target_cpu, elf_path, locate_path):
if target_cpu == 'arm':
cmd_obj_dump = 'arm-linux-musleabi-obj_dump_path'
cmd_obj_dump = 'arm-linux-musleabi-objdump'
elif target_cpu == 'arm64':
cmd_obj_dump = get_obj_dump_path()
cmd_obj_dump = 'aarch64-linux-musl-objdump'
else:
raise ValueError("target cpu error")
......@@ -268,6 +268,17 @@ def extract_libc_func(callee_und_func_name, libc_func_maps):
return libc_func
def get_function_name_nr_table(src_syscall_path):
function_name_nr_table_dict = {}
for file_name in src_syscall_path:
file_name_tmp = file_name.split('/')[-1]
if not file_name_tmp.lower().startswith('libsyscall_to_nr_'):
continue
gen_policy.gen_syscall_nr_table(file_name, function_name_nr_table_dict)
return function_name_nr_table_dict
def collect_concrete_syscall(args):
if args.target_cpu == 'arm64':
arch_str = 'aarch64'
......@@ -303,7 +314,8 @@ def collect_concrete_syscall(args):
syscall_nr_list = collect_syscall(libc_func_used, libc_func_map)
nr_to_func_dict = dict()
audit_policy.converse_fuction_name_nr(nr_to_func_dict, gen_libc.function_name_nr_table_dict)
function_name_nr_table_dict = get_function_name_nr_table(args.src_syscall_path)
audit_policy.converse_fuction_name_nr(nr_to_func_dict, function_name_nr_table_dict)
content = get_item_content(args.target_cpu, syscall_nr_list, nr_to_func_dict)
audit_policy.gen_output_file(args.filter_name, content)
......
......@@ -81,8 +81,9 @@ class MergePolicy:
break
if not flag:
content = '{}{};arm64\n'.format(content, func_name)
content = '{}{};arm\n'.format(content, ';arm\n'.join([func_name for func_name in syscall_name_dict.get('arm')]))
if (syscall_name_dict.get('arm')):
content = '{}{};arm\n'.format(content, ';arm\n'.join(
[func_name for func_name, _ in syscall_name_dict.get('arm')]))
return content
......@@ -138,7 +139,7 @@ class MergePolicy:
content += self.get_item_content(function_name_nr_table_dict, "@priorityWithArgs", dict_priority_with_args)
content += self.get_item_content(function_name_nr_table_dict, "@allowListWithArgs", dict_allow_list_with_args)
content += self.get_item_content(function_name_nr_table_dict, "@blockList", dict_blocklist)
audit_policy.gen_output_file(args.filter_name, content)(args.filter_name, content)
audit_policy.gen_output_file(args.filter_name, content)
def main():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册