mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 45/51] kernel/params.c: fix the maximum length in param_get_string
@ 2017-10-03 23:16 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2017-10-03 23:16 UTC (permalink / raw)
  To: torvalds, mm-commits, akpm, jdelvare, bhe, mhocko, mingo

From: Jean Delvare <jdelvare@suse.de>
Subject: 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@endymion
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/params.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN kernel/params.c~params-fix-the-maximum-length-in-param_get_string kernel/params.c
--- a/kernel/params.c~params-fix-the-maximum-length-in-param_get_string
+++ a/kernel/params.c
@@ -507,7 +507,7 @@ EXPORT_SYMBOL(param_set_copystring);
 int param_get_string(char *buffer, const struct kernel_param *kp)
 {
 	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);
 
_

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-03 23:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 23:16 [patch 45/51] kernel/params.c: fix the maximum length in param_get_string akpm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).