Received: by 10.192.165.156 with SMTP id m28csp286365imm; Thu, 12 Apr 2018 22:13:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/yV+B2n1bqwGIrcsWXf/eR/04cb4knv42Zm74rORk8g4BgrrWwR8Feb5TfTUbglGAM2FwM X-Received: by 10.98.253.9 with SMTP id p9mr10036620pfh.152.1523596429292; Thu, 12 Apr 2018 22:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523596429; cv=none; d=google.com; s=arc-20160816; b=X9ej2GmFUVLEG+CsvDl6+QMExuQtAKwQ8sDQqVJv+Zo44yyNaJ+JtYblAqmyt19fiC 4o2BYW0jQg3lP+Q1ZLI9gij3Ee6aXEWnbdyZ4vwlp0qDzuLDdPqfusTYsQryadkCDZa6 m3ZR1gkXwDYtNZTE7MOQUsxvxYgsY9kqIhriqp05EniJS3ErJ50DQbrGPPc2/lkPn03w lqvZhCZTiIcNwukCYfuDnW+oB9PW1Akn2SS7NHRdYLLO/+R9prMNWQG9N8wRUTBr/ZBx 4niLoCi7zjzq0OWwDRYXByi4yKWzzcQASytV6irEk5KBPWFMAeQchpLFznAuxaJkymoN +/xg== 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 y16si3775860pfm.142.2018.04.12.22.13.35; Thu, 12 Apr 2018 22:13:49 -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 S1751873AbeDMFIV (ORCPT + 99 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(-) 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; -- 2.7.4