Skip to content

Commit 14f84cd

Browse files
committed
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()
2 parents 8d245ac + 5eb4b9a commit 14f84cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/params.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,14 @@ EXPORT_SYMBOL(param_array_ops);
513513
int param_set_copystring(const char *val, const struct kernel_param *kp)
514514
{
515515
const struct kparam_string *kps = kp->str;
516+
const size_t len = strnlen(val, kps->maxlen);
516517

517-
if (strnlen(val, kps->maxlen) == kps->maxlen) {
518+
if (len == kps->maxlen) {
518519
pr_err("%s: string doesn't fit in %u chars.\n",
519520
kp->name, kps->maxlen-1);
520521
return -ENOSPC;
521522
}
522-
strcpy(kps->string, val);
523+
memcpy(kps->string, val, len + 1);
523524
return 0;
524525
}
525526
EXPORT_SYMBOL(param_set_copystring);
@@ -841,7 +842,7 @@ static void __init param_sysfs_builtin(void)
841842
dot = strchr(kp->name, '.');
842843
if (!dot) {
843844
/* This happens for core_param() */
844-
strcpy(modname, "kernel");
845+
strscpy(modname, "kernel");
845846
name_len = 0;
846847
} else {
847848
name_len = dot - kp->name + 1;

0 commit comments

Comments
 (0)