[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jLHHtehy7ADhRVv7sRTGQseyOE-JJKbciRD1o4jiJ++hg@mail.gmail.com>
Date: Tue, 27 Feb 2018 15:20:05 -0800
From: Kees Cook <keescook@...omium.org>
To: "Luis R. Rodriguez" <mcgrof@...nel.org>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Shuah Khan <shuah@...nel.org>,
Martin Fuzzey <mfuzzey@...keon.com>,
Mimi Zohar <zohar@...ux.vnet.ibm.com>,
David Howells <dhowells@...hat.com>, pali.rohar@...il.com,
Takashi Iwai <tiwai@...e.de>, arend.vanspriel@...adcom.com,
Rafał Miłecki <zajec5@...il.com>,
nbroeking@...com, Vikram Mulukutla <markivx@...eaurora.org>,
stephen.boyd@...aro.org, Mark Brown <broonie@...nel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
David Woodhouse <dwmw2@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Abhay_Salunke@...l.com, bjorn.andersson@...aro.org,
jewalt@...innovations.com, LKML <linux-kernel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH v2 04/11] firmware: simplify CONFIG_FW_LOADER_USER_HELPER_FALLBACK
further
On Fri, Feb 23, 2018 at 6:46 PM, Luis R. Rodriguez <mcgrof@...nel.org> wrote:
> All CONFIG_FW_LOADER_USER_HELPER_FALLBACK really is, is just a bool,
> initailized at build time. Define it as such. This simplifies the
> logic even further, removing now all explicit #ifdefs around the code.
In the next revision, can you mention that struct
firmware_fallback_config is going to grow in future patches. I spent
too long trying to understand why this wasn't just a two line patch
with only IS_ENABLED... added. :)
Acked-by: Kees Cook <keescook@...omium.org>
-Kees
>
> Signed-off-by: Luis R. Rodriguez <mcgrof@...nel.org>
> ---
> drivers/base/firmware_loader.c | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/base/firmware_loader.c b/drivers/base/firmware_loader.c
> index 7dd36ace6152..59dba794ce1a 100644
> --- a/drivers/base/firmware_loader.c
> +++ b/drivers/base/firmware_loader.c
> @@ -266,6 +266,22 @@ static inline bool fw_state_is_aborted(struct fw_priv *fw_priv)
>
> #ifdef CONFIG_FW_LOADER_USER_HELPER
>
> +/**
> + * struct firmware_fallback_config - firmware fallback configuratioon settings
> + *
> + * Helps describe and fine tune the fallback mechanism.
> + *
> + * @force_sysfs_fallback: force the sysfs fallback mechanism to be used
> + * as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
> + */
> +struct firmware_fallback_config {
> + bool force_sysfs_fallback;
> +};
> +
> +static const struct firmware_fallback_config fw_fallback_config = {
> + .force_sysfs_fallback = IS_ENABLED(CONFIG_FW_LOADER_USER_HELPER_FALLBACK),
> +};
> +
> static inline bool fw_sysfs_done(struct fw_priv *fw_priv)
> {
> return __fw_state_check(fw_priv, FW_STATUS_DONE);
> @@ -1151,19 +1167,14 @@ static int fw_load_from_user_helper(struct firmware *firmware,
> return ret;
> }
>
> -#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
> -static bool fw_force_sysfs_fallback(unsigned int opt_flags)
> -{
> - return true;
> -}
> -#else
> static bool fw_force_sysfs_fallback(unsigned int opt_flags)
> {
> + if (fw_fallback_config.force_sysfs_fallback)
> + return true;
> if (!(opt_flags & FW_OPT_USERHELPER))
> return false;
> return true;
> }
> -#endif
>
> static bool fw_run_sysfs_fallback(unsigned int opt_flags)
> {
> --
> 2.16.2
>
--
Kees Cook
Pixel Security
Powered by blists - more mailing lists