Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2139988imm; Mon, 28 May 2018 02:25:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq+k0j+pgK7ZcXtRZGYEN8jO6pHZyECHA1yhYW/Jnwui9bIAjESj74DUHN29s/DYQ2B9l5u X-Received: by 2002:a17:902:4b:: with SMTP id 69-v6mr13188173pla.178.1527499503713; Mon, 28 May 2018 02:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527499503; cv=none; d=google.com; s=arc-20160816; b=tXzXaMV5fN85t0My3Lk31VEwQwxt1PnlW1X4LpRyk12Irl1HaMcPhll+I//5eU/sod sPX7bfPjC27f7EVqROF/n5RU2jbshfUHrEVOkEVmK0R6O87Tb8AQS23mqdiRV/2SeU/Q fleXEPrkG2j7bZpUlgR2SEgnLWfDLq1x1AjwCRkRkQcDVJYlGns2IA3+3f1mfaQXVb/l 1IRkigP8LiEW02KHrq/nYhKbUWG1AcCDpwyn/7cXVszp5cqXCC7ssCKPGRnEABp/mbht G+3kh2pGug3i+MLuEu5JebDQz7jsyIg+re8+ENmmlKIBumCCacHlvcsry9+J7k+kJyZT xraQ== 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=hnIoSO7D1B5Ka5B/TDr8jeVdLbfoSN4957XMK3FjJzs=; b=NRrelqiDxWHNOXyjmQ9IlvqBePiMmFzWDsoez9DyTiBFxMLNA9emjuD97MqiQNAdpL XnGBdQmvEPPSrSjKsRKW2HX5a2OWxXuydnfNr6SuhvsyO5yUiTUG0ROECeofHbE7shAf icGAhYhuwk8a2PpJjbgnAwAcKuns9zHcYYdu0gOJpK4UqVbm1PN3rgMrIgpcW4Uul3cI GSaf+VyJNHCSO/AgRpoT3N2jKssBIrwO0LcIp/yjQgqjEM0HgFuVHT3I1j89Z5wH0uFI fzNSST88tbjqVMz/5KnEz4mRXkeRCTBjBe/MeGL2Ut0PSm/YJzU3j6qdiSSew/GT0PMW 2sng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=okKxtupT; 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 c74-v6si11101226pga.522.2018.05.28.02.24.49; Mon, 28 May 2018 02:25:03 -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=okKxtupT; 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 S932134AbeE1JYZ (ORCPT + 99 others); Mon, 28 May 2018 05:24:25 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:21481 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754207AbeE1JYN (ORCPT ); Mon, 28 May 2018 05:24:13 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-10.nifty.com with ESMTP id w4S9MInL027506; Mon, 28 May 2018 18:22:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w4S9MInL027506 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1527499343; bh=hnIoSO7D1B5Ka5B/TDr8jeVdLbfoSN4957XMK3FjJzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=okKxtupTwSJZnwZ+edd3dgoiU8la0VrRGrk2tro7s9lZTS/rGOAvM7StiFYsGJoc+ ootTiy99iGxlgDD4QaY69rjVriHQvKSKwhrIziEN6HwWVx7px4H0qr8J1WeH8wJQQQ 38tYc36yEHU2mQrmpgq8glTiAKESbZApQCA/HWmTfQYgowl4oiFssRaiBA/pPPMOL3 JEVciya7i+J9uULeFz4GY9aArYYK1eOC+3GzNh7zCxGXnIBreisg/qaIpgGBj3yWn3 taCLeBywMZJ0caDxZbnLlnMWXH+7pUMnESsD0AY+uK38WHCJyDIehYJdq+IiejuS5a z9q7yDSL80Mbg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kees Cook , Nicholas Piggin , "Luis R . Rodriguez" , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Linus Torvalds , Masahiro Yamada Subject: [PATCH v5 04/31] kconfig: remove string expansion in file_lookup() Date: Mon, 28 May 2018 18:21:41 +0900 Message-Id: <1527499328-13213-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527499328-13213-1-git-send-email-yamada.masahiro@socionext.com> References: <1527499328-13213-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 v5: None Changes in v4: None 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 703ee49..a365594 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