From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:34667 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726467AbfEOSbj (ORCPT ); Wed, 15 May 2019 14:31:39 -0400 Received: by mail-pl1-f195.google.com with SMTP id w7so293713plz.1 for ; Wed, 15 May 2019 11:31:38 -0700 (PDT) Date: Wed, 15 May 2019 11:31:36 -0700 From: Kees Cook Subject: Re: [RFC PATCH] kbuild: check uniqueness of basename of modules Message-ID: <201905151130.87CDB73C0@keescook> References: <20190515073818.22486-1-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kbuild-owner@vger.kernel.org List-ID: To: Masahiro Yamada Cc: Linux Kbuild mailing list , Andrew Morton , Sam Ravnborg , Arnd Bergmann , Greg KH , Jessica Yu , Lucas De Marchi , Linus Torvalds , Rusty Russell , Michal Marek , Linux Kernel Mailing List On Thu, May 16, 2019 at 03:07:54AM +0900, Masahiro Yamada wrote: > On Wed, May 15, 2019 at 4:40 PM Masahiro Yamada > wrote: > > > $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin > > diff --git a/scripts/modules-check.sh b/scripts/modules-check.sh > > new file mode 100755 > > index 000000000000..944e68bd22b0 > > --- /dev/null > > +++ b/scripts/modules-check.sh > > @@ -0,0 +1,18 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0 > > + > > +# Warn if two or more modules have the same basename > > +check_same_name_modules() > > +{ > > + same_name_modules=$(cat modules.order modules.builtin | \ > > + xargs basename -a | sort | uniq -d) > > > I noticed a bug here. > > > allnoconfig + CONFIG_MODULES=y > will create empty modules.order and modules.builtin. > > Then, 'basename -a' will emit the error messages > since it receives zero arguments. You can skip running it by adding "-r" to xargs: -r, --no-run-if-empty If the standard input does not contain any nonblanks, do not run the command. Normally, the command is run once even if there is no input. This option is a GNU extension. -- Kees Cook