diff options
author | 2025-08-24 09:43:50 -0400 | |
---|---|---|
committer | 2025-08-24 09:43:50 -0400 | |
commit | 14f84cd318bed3fc64c6e4ee6b251f9b6a8e2a05 (patch) | |
tree | a908156a00c9e4c5e98436ee5cf9bb5e49abbf58 | |
parent | Merge tag 'char-misc-6.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc (diff) | |
parent | params: Replace deprecated strcpy() with strscpy() and memcpy() (diff) | |
download | wireguard-linux-14f84cd318bed3fc64c6e4ee6b251f9b6a8e2a05.tar.xz wireguard-linux-14f84cd318bed3fc64c6e4ee6b251f9b6a8e2a05.zip |
Merge tag 'modules-6.17-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux
Pull modules fix from Daniel Gomez:
"This includes a fix part of the KSPP (Kernel Self Protection Project)
to replace the deprecated and unsafe strcpy() calls in the kernel
parameter string handler and sysfs parameters for built-in modules.
Single commit, no functional changes"
* tag 'modules-6.17-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux:
params: Replace deprecated strcpy() with strscpy() and memcpy()
-rw-r--r-- | kernel/params.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/params.c b/kernel/params.c index b92d64161b75..b96cfd693c99 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -513,13 +513,14 @@ EXPORT_SYMBOL(param_array_ops); int param_set_copystring(const char *val, const struct kernel_param *kp) { const struct kparam_string *kps = kp->str; + const size_t len = strnlen(val, kps->maxlen); - if (strnlen(val, kps->maxlen) == kps->maxlen) { + if (len == kps->maxlen) { pr_err("%s: string doesn't fit in %u chars.\n", kp->name, kps->maxlen-1); return -ENOSPC; } - strcpy(kps->string, val); + memcpy(kps->string, val, len + 1); return 0; } EXPORT_SYMBOL(param_set_copystring); @@ -841,7 +842,7 @@ static void __init param_sysfs_builtin(void) dot = strchr(kp->name, '.'); if (!dot) { /* This happens for core_param() */ - strcpy(modname, "kernel"); + strscpy(modname, "kernel"); name_len = 0; } else { name_len = dot - kp->name + 1; |