From: Richard Weinberger <richard@nod.at>
To: Boris Kolpackov <boris@codesynthesis.com>
Cc: masahiroy <masahiroy@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-kbuild <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH 2/2] kconfig: Deny command substitution in string values
Date: Wed, 22 Sep 2021 18:17:40 +0200 (CEST) [thread overview]
Message-ID: <1942256037.97524.1632327460626.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <boris.20210922165140@codesynthesis.com>
Boris,
----- Ursprüngliche Mail -----
> Von: "Boris Kolpackov" <boris@codesynthesis.com>
> An: "richard" <richard@nod.at>
> CC: "masahiroy" <masahiroy@kernel.org>, "linux-kernel" <linux-kernel@vger.kernel.org>, "linux-kbuild"
> <linux-kbuild@vger.kernel.org>
> Gesendet: Mittwoch, 22. September 2021 17:18:43
> Betreff: Re: [PATCH 2/2] kconfig: Deny command substitution in string values
> Richard Weinberger <richard@nod.at> 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
next prev parent reply other threads:[~2021-09-22 16:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 21:39 [PATCH 1/2] kconfig: Refactor sym_escape_string_value Richard Weinberger
2021-09-20 21:39 ` [PATCH 2/2] kconfig: Deny command substitution in string values Richard Weinberger
2021-09-22 7:17 ` Boris Kolpackov
2021-09-22 7:27 ` Richard Weinberger
2021-09-22 15:18 ` Boris Kolpackov
2021-09-22 16:17 ` Richard Weinberger [this message]
2021-09-25 8:58 ` Masahiro Yamada
2021-09-27 14:34 ` Boris Kolpackov
2021-09-27 12:36 ` [PATCH 1/2] kconfig: Refactor sym_escape_string_value Masahiro Yamada
2021-10-05 15:42 ` Masahiro Yamada
2021-10-07 6:45 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1942256037.97524.1632327460626.JavaMail.zimbra@nod.at \
--to=richard@nod.at \
--cc=boris@codesynthesis.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox