From patchwork Fri Apr 13 05:06:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 133326 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp346456ljb; Thu, 12 Apr 2018 22:11:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx49oTKvRJIuFcyOA1kYJuA1mMDNRHiHA1QI3zycrV//MWCJR3O7PXISVsdQnyBImANSSqatx X-Received: by 10.98.180.24 with SMTP id h24mr10169876pfn.213.1523596307054; Thu, 12 Apr 2018 22:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523596307; cv=none; d=google.com; s=arc-20160816; b=pm4agRrPpsng4k+A6oWn99M+pGoodWUTPVV2gEa14SX3WbYGwyAUJ42/V3Eb1cYlKy ThNpC+7nKsDAmmR5YogYxnaHVtIDgYso+rV8jtrXhDWjNCzw3Nuc1Taocif62yw6xDCL y0ZSStQODDgqsHatnDDffeqIsysm4g42Awg2QXUFjEln39nETyqgfDmK1r572Ew+kw4V qJ2hpqszZ+PD8pfN+pnZNZRIXhS6+F6/v3b/VDxyXlKZJHQHzl3iI1gK/qxjTOnC6c+9 Oba7zW6g2emQt4+bJ+bbpbyksjVN0P2khUASG8vqN918P/I3FK7k2B76l8CiqsnqBwKJ /dVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=Va2AisuizRhRW/RFE7j85F4MfFSvDmOzvfaqKUI638k=; b=dBdf+ySuN7hscqk+J1h9vf1ne+xt7JJrJDHLGJHrQ5Tu4AKcg5BRA9Phug4xG3xUfz X4q6VoX7GT9WzSR3tWIAD91ATsxU46XzPgpqPRu+o/Nyms99MwCMgXIaHxJxfwkcwSz6 KiQbw1joPmKFzr3tJPEmiJW8bv6qcsWYmvGuGWU+VFkoCVhf6JC3pKkw2SdIcEUOITNG KAi/s07XWtmBCqvRz04eBiSQgYS/nIHzLrgTJccuANNagL4kqtGFJrtIDK21YpW77X21 eflvtf18KjkiVZ80GW8xKr+DV0K1XYytsSU5qvh6t9IeD66VyD+zxS8AXm3CsLvB+3rr VPlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=X322LuMu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v145si1745943pgb.203.2018.04.12.22.11.46; Thu, 12 Apr 2018 22:11:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=X322LuMu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752007AbeDMFIV (ORCPT + 29 others); Fri, 13 Apr 2018 01:08:21 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:54457 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750867AbeDMFIP (ORCPT ); Fri, 13 Apr 2018 01:08:15 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id w3D56lfx029209; Fri, 13 Apr 2018 14:06:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w3D56lfx029209 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1523596012; bh=Va2AisuizRhRW/RFE7j85F4MfFSvDmOzvfaqKUI638k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X322LuMuZ7OaFQ9udOIJBZf3IpzecG6UeWDBps5Eb9LxcRmi5xM/tGoWibEoRosx9 /3fdF1J17Hm0NjX0GMx9E5f6S1aC8zeC32wyC4Kp1UkX+Jjzbekk07CRoCsq+pSKpu h1t0GNL4xwxhDFw6SlBSidzkOKgIxV+XDyBiA2F65sVkWOYhpRgKRaRSozh+1aJ8Ug W1S6NNyjyoTqpixwszjsbhvsb224sBMNSrfO8Mh/JOlJLHYe4xtEguZ37OGlfGXoe3 /yoPuhWZr9677OJp/ICDPfEilzfGSgxBESgpA47WoG0S7yseZ9ceLKy5FwCj3vSfZ9 nJd3mvaVIcn0Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , Sam Ravnborg , Ulf Magnusson , Nicholas Piggin , Kees Cook , Emese Revfy , x86@kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 05/30] kconfig: remove string expansion in file_lookup() Date: Fri, 13 Apr 2018 14:06:14 +0900 Message-Id: <1523595999-27433-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523595999-27433-1-git-send-email-yamada.masahiro@socionext.com> References: <1523595999-27433-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are two callers of file_lookup(), but there is no more reason to expand the given path. [1] zconf_initscan() This is used to open the first Kconfig. sym_expand_string_value() has never been used in a useful way here; before opening the first Kconfig file, obviously there is no symbol to expand. If you use expand_string_value() instead, environments in KBUILD_KCONFIG would be expanded, but I do not see practical benefits for that. [2] zconf_nextfile() This is used to open the next file from 'source' statement. Symbols in the path like "arch/$SRCARCH/Kconfig" needed expanding, but it was replaced with the direct environment expansion. The environment has already been expanded before the token is passed to the parser. By the way, file_lookup() was already buggy; it expanded a given path, but it used the path before expansion for look-up: if (!strcmp(name, file->name)) { Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook Reviewed-by: Ulf Magnusson --- Changes in v3: None Changes in v2: - Simplify the patch. Just remove text expansion. scripts/kconfig/util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 807147e..790967df 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -14,18 +14,16 @@ struct file *file_lookup(const char *name) { struct file *file; - char *file_name = sym_expand_string_value(name); for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { - free(file_name); return file; } } file = xmalloc(sizeof(*file)); memset(file, 0, sizeof(*file)); - file->name = file_name; + file->name = xstrdup(name); file->next = file_list; file_list = file; return file;