From patchwork Mon May 28 09:21:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 137039 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2591897lji; Mon, 28 May 2018 02:24:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr/kRZhB5W0QYcS/KMVUnpc4WzO0C5X9CswrizT487OzMFTyc9cpkInHcAXR164dVjmePE5 X-Received: by 2002:a17:902:5c6:: with SMTP id f64-v6mr12814434plf.50.1527499469169; Mon, 28 May 2018 02:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527499469; cv=none; d=google.com; s=arc-20160816; b=c1Jj84ldecQbUeN1UlgFCrHTNz/unVPaY+KMPmtJnjPYW3bivmnSi1wETdZU/KWsnX ReCFHSjQC4DPtoXRMWOIlWXYnhNWjJLJwQGVa0rRoQVtMlHkWS5RC4TxF/AifYgdnt2F wQJT1gMVxoLbCqhJdMpaX+tufnkgaa+vJep6ls5YAIRo4gZp81cFJxDgCsl+nHmDsVbz 8F4N3xE95+YghbCMd9LbGaU0P0BUSw41nEgFBJcyiSb9jU+uv4r8A4gh01MRgMsT2xEH wexuSWT+GNOyZSx4Qi/brfRHAkWGtnWTs7dhcY8FPORU/cSW/Ik8DH+wZLNrwCNPywo6 1ZfA== 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 t1-v6si13250726plq.341.2018.05.28.02.24.28; Mon, 28 May 2018 02:24:29 -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 S932145AbeE1JY0 (ORCPT + 30 others); Mon, 28 May 2018 05:24:26 -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(-) -- 2.7.4 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;