From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932122AbdI1Pl2 (ORCPT ); Thu, 28 Sep 2017 11:41:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:55259 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753316AbdI1Pl1 (ORCPT ); Thu, 28 Sep 2017 11:41:27 -0400 Date: Thu, 28 Sep 2017 16:25:15 +0200 From: Jean Delvare To: LKML Cc: Andrew Morton , Ingo Molnar , Baoquan He , Michal Hocko Subject: [PATCH v2 1/3] params: Fix the maximum length in param_get_string Message-ID: <20170928162515.24846b4f@endymion> In-Reply-To: <20170928162337.28ae03f4@endymion> References: <20170928162337.28ae03f4@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Jean Delvare --- Changes since v1: * Patch added kernel/params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- linux-4.13.orig/kernel/params.c 2017-09-28 11:09:09.604089430 +0200 +++ linux-4.13/kernel/params.c 2017-09-28 11:09:47.573434740 +0200 @@ -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); -- Jean Delvare SUSE L3 Support