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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 CB832C433EF for ; Wed, 22 Sep 2021 16:17:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACE5E60231 for ; Wed, 22 Sep 2021 16:17:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236617AbhIVQTO convert rfc822-to-8bit (ORCPT ); Wed, 22 Sep 2021 12:19:14 -0400 Received: from lithops.sigma-star.at ([195.201.40.130]:38220 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236523AbhIVQTN (ORCPT ); Wed, 22 Sep 2021 12:19:13 -0400 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 9A7306171B1D; Wed, 22 Sep 2021 18:17:41 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id g_Xj6GkVOxov; Wed, 22 Sep 2021 18:17:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 0FFDE6171AF5; Wed, 22 Sep 2021 18:17:41 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Czl4Cj8z4wMN; Wed, 22 Sep 2021 18:17:40 +0200 (CEST) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id DA4B860F6B83; Wed, 22 Sep 2021 18:17:40 +0200 (CEST) Date: Wed, 22 Sep 2021 18:17:40 +0200 (CEST) From: Richard Weinberger To: Boris Kolpackov Cc: masahiroy , linux-kernel , linux-kbuild Message-ID: <1942256037.97524.1632327460626.JavaMail.zimbra@nod.at> In-Reply-To: References: <20210920213957.1064-1-richard@nod.at> <20210920213957.1064-2-richard@nod.at> <1402570794.96583.1632295660867.JavaMail.zimbra@nod.at> Subject: Re: [PATCH 2/2] kconfig: Deny command substitution in string values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF92 (Linux)/8.8.12_GA_3809) Thread-Topic: kconfig: Deny command substitution in string values Thread-Index: UN+UPErbzOHavDcXoin7FTqpapyswg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Boris, ----- Ursprüngliche Mail ----- > Von: "Boris Kolpackov" > An: "richard" > CC: "masahiroy" , "linux-kernel" , "linux-kbuild" > > Gesendet: Mittwoch, 22. September 2021 17:18:43 > Betreff: Re: [PATCH 2/2] kconfig: Deny command substitution in string values > Richard Weinberger writes: > >> > So effectively it's now impossible to include ` or $ in kconfig >> > string values. Seems like a major, backwards-incompatible >> > restriction. >> >> Do you have a working example? > > You mean of a project that uses kconfig and that is capable of > handling string values with these characters? If so, then yes, > see for example, libbuild2-kconfig[1] which is a build system > module that implements kconfig-based configuration support for > build2. In particular, it exposes values from .config as > buildfile variables but it doesn't do this by sourcing .config. > Instead it loads .config using the kconfig API and then sets > the corresponding buildfile variables programmatically. I had a config setting of Linux in mind. :-) > >> Since the config is sourced in the scripts/setlocalversion it will >> not work correctly anyway. > > The actual file being sources is include/config/auto.conf, not > .config, right? > Yes. auto.conf is .config post processed. This is exactly where my mitigation takes place. >> > I think if this is really desired, then it should be re-done with >> > escaping (similar to ") rather than outright banning inconvenient >> > characters. >> >> Escaping is not so easy since the very same content is included >> in shell scripts (sertlocalversion), in Makefiles and in C files. > > Again, I don't think it's .config that gets included in C files but > rather include/generated/autoconf.h, right? > Yes. But the key/values are taken as-is. Just add some odd characters to your .config, build the kernel and observe the breakage at different levels. Or something like CONFIG_DEFAULT_HOSTNAME="`touch owned`". ;-) >> At least I didn't find find a good way to escape these characters >> such that all three programming environments will accept it. > > If my understanding is correct, then you are concerned with the > autoconf functionality: the auto.conf makefile and autoconf.h > header, and not the .config file itself. Perhaps it will be less > disruptive to do the escaping (or banning) at that level? My concern is that currently a .config file can contain hostile content that will get executed at build time. .config files are often blindly shared across untrusted developers. So I thought that mitigating this whole is worth it. > Specifically: > > 1. If you do escaping at that level, then you can do it differently > for auto.conf and autoconf.h. Though auto.conf still seems to be > read by both make and shell. I need to think about that. Thanks for the pointer. Thanks, //richard