[PATCH linux-next] kallsyms: Use strscpy() instead of strlcpy()

From: cuijinpeng666
Date: Thu Oct 20 2022 - 05:06:06 EST


From: Jinpeng Cui <cui.jinpeng2@xxxxxxxxxx>

The implementation of strscpy() is more robust and safer.

Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Signed-off-by: Jinpeng Cui <cui.jinpeng2@xxxxxxxxxx>
---
kernel/kallsyms.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index cc244c02b4cf..639de60ed417 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -660,7 +660,7 @@ static int get_ksymbol_bpf(struct kallsym_iter *iter)
{
int ret;

- strlcpy(iter->module_name, "bpf", MODULE_NAME_LEN);
+ strscpy(iter->module_name, "bpf", MODULE_NAME_LEN);
iter->exported = 0;
ret = bpf_get_kallsym(iter->pos - iter->pos_ftrace_mod_end,
&iter->value, &iter->type,
@@ -680,7 +680,7 @@ static int get_ksymbol_bpf(struct kallsym_iter *iter)
*/
static int get_ksymbol_kprobe(struct kallsym_iter *iter)
{
- strlcpy(iter->module_name, "__builtin__kprobes", MODULE_NAME_LEN);
+ strscpy(iter->module_name, "__builtin__kprobes", MODULE_NAME_LEN);
iter->exported = 0;
return kprobe_get_kallsym(iter->pos - iter->pos_bpf_end,
&iter->value, &iter->type,
--
2.25.1