mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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()
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user