diff --git a/kernel/tkernel/killblock/kill_block.c b/kernel/tkernel/killblock/kill_block.c index 50e8484bd51d3af5426ad422aa7fa80886c9f95c..9d4a95eea56df8de8f854b473fe8969e1054914a 100644 --- a/kernel/tkernel/killblock/kill_block.c +++ b/kernel/tkernel/killblock/kill_block.c @@ -91,15 +91,9 @@ static ssize_t whitelist_write(struct file *file, const char __user *ubuf, if (!rule) return -ENOMEM; - cnt = min_t(size_t, TASK_COMM_LEN - 1, strlen(token[1])); - strncpy(rule->src_comm, token[1], cnt); - rule->src_comm[cnt] = '\0'; - cnt = min_t(size_t, TASK_COMM_LEN - 1, strlen(token[2])); - strncpy(rule->dst_comm, token[2], cnt); - rule->dst_comm[cnt] = '\0'; - cnt = min_t(size_t, KILL_BLOCK_CGRP_LEN - 1, strlen(token[3])); - strncpy(rule->dst_cgrp, token[3], cnt); - rule->dst_cgrp[cnt] = '\0'; + strscpy(rule->src_comm, token[1], sizeof(rule->src_comm)); + strscpy(rule->dst_comm, token[2], sizeof(rule->dst_comm)); + strscpy(rule->dst_cgrp, token[3], sizeof(rule->dst_cgrp)); write_lock(&whitelist_lock); list_for_each_entry(tmp, &whitelist_list, node) { if (!strcasecmp(tmp->src_comm, rule->src_comm) && @@ -213,7 +207,7 @@ static unsigned int kill_block_get_podid_len(char *podid_start) return podid_len; } -bool kill_block_whitelist_match(struct task_struct *p, int sig, +static bool kill_block_whitelist_match(struct task_struct *p, int sig, char *src_cgrp_path, char *src_cgrp_name, char *dst_cgrp_path, char *dst_cgrp_name) { diff --git a/kernel/tkernel/killprotect/kill_protect.c b/kernel/tkernel/killprotect/kill_protect.c index 4474cad05b140197c9946ebb83267f625af47780..386014342cb04bb1d9c8772a0c6ee8ce1d60750c 100644 --- a/kernel/tkernel/killprotect/kill_protect.c +++ b/kernel/tkernel/killprotect/kill_protect.c @@ -87,9 +87,7 @@ static ssize_t blacklist_write(struct file *file, const char __user *ubuf, if (!rule) return -ENOMEM; - cnt = min_t(size_t, TASK_COMM_LEN - 1, strlen(token[1])); - strncpy(rule->comm, token[1], cnt); - rule->comm[cnt] = '\0'; + strscpy(rule->comm, token[1], sizeof(rule->comm)); write_lock(&blacklist_lock); list_for_each_entry(tmp, &blacklist_list, node) { @@ -103,9 +101,7 @@ static ssize_t blacklist_write(struct file *file, const char __user *ubuf, write_unlock(&blacklist_lock); atomic_inc(&kp_rule_cnt); } else if (strcmp(token[0], "del") == 0) { - cnt = min_t(size_t, TASK_COMM_LEN - 1, strlen(token[1])); - strncpy(comm, token[1], cnt); - comm[cnt] = '\0'; + strscpy(comm, token[1], sizeof(comm)); write_lock(&blacklist_lock); list_for_each_entry_safe(rule, tmp, &blacklist_list, node) { @@ -183,7 +179,7 @@ static int stat_proc_show(struct seq_file *m, void *v) return 0; } -bool kill_protect_blacklist_match(struct task_struct *p, int sig) +static bool kill_protect_blacklist_match(struct task_struct *p, int sig) { struct kp_blacklist_rule *rule; bool curr_match = false;