From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755435AbdE0KGn (ORCPT ); Sat, 27 May 2017 06:06:43 -0400 Received: from ozlabs.org ([103.22.144.67]:44737 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750844AbdE0KGm (ORCPT ); Sat, 27 May 2017 06:06:42 -0400 From: Rusty Russell To: Wanlong Gao , akpm@linux-foundation.org, jeyu@redhat.com Cc: Xie XiuQi , gaowanlong@huawei.com, linux-kernel@vger.kernel.org, john.wanghui@huawei.com, wencongyang2@huawei.com, guijianfeng@huawei.com, Jessica Yu Subject: Re: [PATCH] modpost: abort if a module name is too long In-Reply-To: <2eab8ec4-1dfc-1157-2d0f-bb31399fa39b@huawei.com> References: <1495266381-14755-1-git-send-email-xiexiuqi@huawei.com> <2eab8ec4-1dfc-1157-2d0f-bb31399fa39b@huawei.com> Date: Sat, 27 May 2017 10:57:56 +0930 Message-ID: <87a85z142r.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wanlong Gao writes: > Folks, > > Any comments? I've CC'd the module maintainer, who can help with this :_ Cheers, Rusty. > On 2017/5/20 15:46, Xie XiuQi wrote: >> From: Wanlong Gao >> >> Module name has a limited length, but currently the build system >> allows the build finishing even if the module name is too long. >> >> CC /root/kprobe_example/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.mod.o >> /root/kprobe_example/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.mod.c:9:2: >> warning: initializer-string for array of chars is too long [enabled by default] >> .name = KBUILD_MODNAME, >> ^ >> >> but it's merely a warning. >> >> This patch adds the check of the module name length in modpost and stops >> the build properly. >> >> Signed-off-by: Wanlong Gao >> Signed-off-by: Xie XiuQi >> --- >> scripts/mod/modpost.c | 11 +++++++++++ >> 1 file changed, 11 insertions(+) >> >> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c >> index 30d752a..db11c57 100644 >> --- a/scripts/mod/modpost.c >> +++ b/scripts/mod/modpost.c >> @@ -2166,6 +2166,17 @@ static int add_versions(struct buffer *b, struct module *mod) >> { >> struct symbol *s, *exp; >> int err = 0; >> + const char *mod_name; >> + >> + mod_name = strrchr(mod->name, '/'); >> + if (mod_name == NULL) >> + mod_name = mod->name; >> + else >> + mod_name++; >> + if (strlen(mod_name) >= MODULE_NAME_LEN) { >> + merror("module name is too long [%s.ko]\n", mod->name); >> + return 1; >> + } >> >> for (s = mod->unres; s; s = s->next) { >> exp = find_symbol(s->name); >>