Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164152AbdDXCMU (ORCPT ); Sun, 23 Apr 2017 22:12:20 -0400 Received: from mail.kernel.org ([198.145.29.136]:55428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164137AbdDXCML (ORCPT ); Sun, 23 Apr 2017 22:12:11 -0400 Date: Mon, 24 Apr 2017 11:12:00 +0900 From: Masami Hiramatsu To: "Naveen N. Rao" Cc: Jessica Yu , Rusty Russell , Michael Ellerman , Masami Hiramatsu , linux-kernel@vger.kernel.org Subject: Re: [PATCH] kallsyms: Use bounded strnchr() when parsing string Message-Id: <20170424111200.8fe9ea1667b433709b265a1b@kernel.org> In-Reply-To: <20170423172343.12739-1-naveen.n.rao@linux.vnet.ibm.com> References: <20170423172343.12739-1-naveen.n.rao@linux.vnet.ibm.com> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.31; x86_64-redhat-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 Content-Length: 1133 Lines: 39 On Sun, 23 Apr 2017 22:53:43 +0530 "Naveen N. Rao" wrote: > When parsing for the format, we use strchr() to look for > the separator, when we know that the module name can't be longer than > MODULE_NAME_LEN. Enforce the same using strnchr(). Looks good to me :) Reviewed-by: Masami Hiramatsu Thanks, > > Signed-off-by: Naveen N. Rao > --- > kernel/module.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/module.c b/kernel/module.c > index 7eba6dea4f41..d3bd56ed3541 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -4017,7 +4017,7 @@ unsigned long module_kallsyms_lookup_name(const char *name) > > /* Don't lock: we're in enough trouble already. */ > preempt_disable(); > - if ((colon = strchr(name, ':')) != NULL) { > + if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) { > if ((mod = find_module_all(name, colon - name, false)) != NULL) > ret = mod_find_symname(mod, colon+1); > } else { > -- > 2.12.1 > -- Masami Hiramatsu