Commit 90ceb2a3 authored by Jean Delvare's avatar Jean Delvare Committed by Linus Torvalds

kernel/params.c: fix the maximum length in param_get_string

The length parameter of strlcpy() is supposed to reflect the size of the
target buffer, not of the source string.  Harmless in this case as the
buffer is PAGE_SIZE long and the source string is always much shorter than
this, but conceptually wrong, so let's fix it.

Link: http://lkml.kernel.org/r/20170928162515.24846b4f@endymionSigned-off-by: default avatarJean Delvare <jdelvare@suse.de>
Acked-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d09b0137
...@@ -507,7 +507,7 @@ EXPORT_SYMBOL(param_set_copystring); ...@@ -507,7 +507,7 @@ EXPORT_SYMBOL(param_set_copystring);
int param_get_string(char *buffer, const struct kernel_param *kp) int param_get_string(char *buffer, const struct kernel_param *kp)
{ {
const struct kparam_string *kps = kp->str; const struct kparam_string *kps = kp->str;
return strlcpy(buffer, kps->string, kps->maxlen); return strlcpy(buffer, kps->string, PAGE_SIZE);
} }
EXPORT_SYMBOL(param_get_string); EXPORT_SYMBOL(param_get_string);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment