From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0E77C04AB4 for ; Fri, 17 May 2019 03:40:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B37CB2084A for ; Fri, 17 May 2019 03:40:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="ZeFhm8iN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727793AbfEQDkP (ORCPT ); Thu, 16 May 2019 23:40:15 -0400 Received: from conssluserg-03.nifty.com ([210.131.2.82]:24977 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfEQDkP (ORCPT ); Thu, 16 May 2019 23:40:15 -0400 Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) (authenticated) by conssluserg-03.nifty.com with ESMTP id x4H3dq7C000772; Fri, 17 May 2019 12:39:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com x4H3dq7C000772 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1558064393; bh=aPOO/0Ic2Zo5pJTXO2MkJ+6Frm2tT+vQWrhjA4zb4BI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZeFhm8iNQvKxOgOzJWr7/o6OtX7F4Lxa0wUCTBGV69TYMLML6wQ7K9UOnXlJU0wLf 8ffdI+68f+YBkErO8l1H/SR1Uz0DKZeJZ+WNwmmn6/89QxwHKWep8ma0tK5h99p0BJ WY0frH74nw9YksjDx4MJ6IO8iuALC4Q83DGcbGRp2gVMMRohQWCdEtEhXurKTEcx5Q LScG0KR3IAwo8OcjQRVESTckMsH+UBtQWReKYZ/T/TBlqpQT7wRPBIg462YjRRn8xZ SVz9v5ZXq5swtT+4781LPSq96Ky868bAgG8sgt4BHpApBuqp2VkGTH5cczGAEDBPVg lx7sV7Nxv8ebQ== X-Nifty-SrcIP: [209.85.217.50] Received: by mail-vs1-f50.google.com with SMTP id o10so3700327vsp.12; Thu, 16 May 2019 20:39:53 -0700 (PDT) X-Gm-Message-State: APjAAAWNkBV3U/FkyHeebOVCMzSTfXU2iz5TPcz0s3wvytP3NB0gs+DG zk3066Dy57ZgilKc6L+zyQdfc6w55dR80zdY2IU= X-Google-Smtp-Source: APXvYqyJYt//bi0OLphS4zjzMdOO8iQShOOU3Cv+ZZqhidFdjKZjqjhjLt6s4xx0+3+cHb8C5qRppv8T9a2h1KGBGHY= X-Received: by 2002:a67:ad0f:: with SMTP id t15mr7818917vsl.179.1558064391987; Thu, 16 May 2019 20:39:51 -0700 (PDT) MIME-Version: 1.0 References: <20190515073818.22486-1-yamada.masahiro@socionext.com> <201905150913.C23BD99AD@keescook> <201905151131.EBB45E5@keescook> In-Reply-To: <201905151131.EBB45E5@keescook> From: Masahiro Yamada Date: Fri, 17 May 2019 12:39:16 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] kbuild: check uniqueness of basename of modules To: Kees Cook 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kees, On Thu, May 16, 2019 at 3:38 AM Kees Cook wrote: > > On Thu, May 16, 2019 at 02:55:02AM +0900, Masahiro Yamada wrote: > > > > On Thu, May 16, 2019 at 1:20 AM Kees Cook wrote: > > > > > > On Wed, May 15, 2019 at 04:53:15PM +0900, Masahiro Yamada wrote: > > > > On Wed, May 15, 2019 at 4:40 PM Masahiro Yamada > > > > wrote: > > > > > > > > > > [...] > > > > > 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) > > > > > > While probably it'll never be a problem, just for robustness, I'd add "--" > > > to the end basename to terminate argument interpretation: > > > > > > xargs basename -a -- | sort | ... > > > > > > Sorry for my ignorance, but could you > > teach me the effect of "--" ? > > > > > > I sometimes use "--" as a separator > > when there is ambiguity in arguments > > for example, "git log -- " > > > > > > In this case, what is intended by "--"? > > It means "end of arguments" so that whatever xargs passes into the > program aren't interpretted as an argument. In this case, if there was > a module path somehow ever named --weird/build/path/foo.o, xargs would > launch basename as: > > basename -a --weird/build/path/foo.o > > and basename would fail since it didn't recognize the argument. Having > "--" will stop argument parsing: > > basename -a -- --weird/build/path/foo.o > > This is just a robustness suggestion that I always recommend for xargs > piping, since this can turn into a security flaw (though not here) when > an argument may have behavioral side-effects. So, it's just a thing that > always jumps out at me, though in this particular case I don't think > we could ever see it cause a problem, but better to always write these > xargs patterns as safely as possible. I did not think about the security issue. Thanks for your expert comments! -- Best Regards Masahiro Yamada