From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162782AbdEYGNS (ORCPT ); Thu, 25 May 2017 02:13:18 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:6378 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161739AbdEYGNJ (ORCPT ); Thu, 25 May 2017 02:13:09 -0400 Subject: Re: [PATCH] modpost: abort if a module name is too long To: , , References: <1495266381-14755-1-git-send-email-xiexiuqi@huawei.com> CC: Xie XiuQi , , , , , From: Wanlong Gao Message-ID: <2eab8ec4-1dfc-1157-2d0f-bb31399fa39b@huawei.com> Date: Thu, 25 May 2017 14:11:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1495266381-14755-1-git-send-email-xiexiuqi@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.97.93] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.592675F2.0109,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: dcb89d5b0eb68f7457d397cab7f66927 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Folks, Any comments? 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); >