Received: by 10.223.185.116 with SMTP id b49csp5535594wrg; Tue, 27 Feb 2018 15:21:15 -0800 (PST) X-Google-Smtp-Source: AH8x226IpPODhEbDELphYfIcTFPZLu4EDJecUSq/CnjnxAET/ew6VL+hOWXb14tXm+5aP9oLvxoe X-Received: by 2002:a17:902:20c9:: with SMTP id v9-v6mr15924063plg.41.1519773675130; Tue, 27 Feb 2018 15:21:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519773675; cv=none; d=google.com; s=arc-20160816; b=iXYNdq5RpE9XGpshShIpQlbY0bP7JVhlY+8Zt9XpJ14EgjfYVpE7WX7sKhcE3tAboP zcFEg6NMVSG5uuiD/mmSajoY8lzga7jr25aUBEenjUSrhRGwaGGqT8vb51h0Ia+10IBG 2I1uqKT9V+Aup+/EF8f238C+VDgS0rg5qbd/UOlA/10ldsNqULq2JNvOzP/AU5zWZrk3 qC0nPiy9j8lz07OK+d+J+hPMPf8nIgWPvGxUisT5OJCj+uQgu2vOkCoru1TEdEtHwk3T tKd9yrMpeAoDtr8mdw41l/tRC9o5iKidRJP0TuRY7rVRQynlIxcHWyEm0wtN1Z5G2cBF IUXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=J1FuwBOujuUzNf891scewCjH5fmMd7isBW+Ne4cV/Uk=; b=bUwVVs0k6ktE1Yyg93VuPFthqgrefmbAsntnCbEMgysTWu1KvLihv/YoYtkEGP+HxR 3Zl1QGtE+21mw5bjogeAd+b4hfFWH8rdU/PXiRxoViEoXbAfoI3+1cytUjao/Hx1qo1u SJFCkT2odcU78FG8n66eP9sll5N1QcrWJ3YV8xN/a1uKodbHaqx6mUHKjpymadxeJGFx spI8Bel3NAjwGIQlrn7rD6h7ajJNd4JIc1MdUpKDMWb/kwPy6fzF9eXBZrrKPQZs1vsB r5HhlzyNLlTw0dddEuzjIg3sAnVyBYspMs57+Lm3TFyba48hUToT7jR3UQM40cgTeh17 aYGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=rO9qGZ0N; dkim=fail header.i=@chromium.org header.s=google header.b=knc2+Tl9; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si165340pgr.485.2018.02.27.15.21.00; Tue, 27 Feb 2018 15:21:15 -0800 (PST) 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=fail header.i=@google.com header.s=20161025 header.b=rO9qGZ0N; dkim=fail header.i=@chromium.org header.s=google header.b=knc2+Tl9; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbeB0XUJ (ORCPT + 99 others); Tue, 27 Feb 2018 18:20:09 -0500 Received: from mail-vk0-f65.google.com ([209.85.213.65]:33639 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbeB0XUH (ORCPT ); Tue, 27 Feb 2018 18:20:07 -0500 Received: by mail-vk0-f65.google.com with SMTP id z130so371683vkd.0 for ; Tue, 27 Feb 2018 15:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=J1FuwBOujuUzNf891scewCjH5fmMd7isBW+Ne4cV/Uk=; b=rO9qGZ0NMFaeq0uM/IRl540w+30beaFsPeD9aAzas+NukhRRISNo9+by/bZsYoftqg RpXOVEq348PSu3m60VWUpy2bOrjB+KJdznQy9rCUn5ApTDHVp6AjIkuLbHUuB1DSY8kQ T52Q/fWFEVvurL2U4CM/bMZNHs9yIf4oyfRPUsiCbtF5JfvRK5cGltfLyVfAXPFz8zM3 rFnDQhT9/WlSUUcYvpouLwYr2PJ9cJHwXnea7lYuQJ9lK+bZ0AFpdKzILVQHskq6gZ6f YHsQslyvYgywghUUGWrL1/NizC4R3vXBLjguhF2qr05ymCGBjJIol+IB0jRYqaizQE5T QOSw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=J1FuwBOujuUzNf891scewCjH5fmMd7isBW+Ne4cV/Uk=; b=knc2+Tl9Wyr/vKfNUHlGFsiQboOVZwqa+CPyeOqpQG2PLDmn2SNNaBwo1zL7jRGyyG /v/9sad/G8/a9g72ixWgIkIvrWf+R3dfA166NanZIu32apkrllMhw4w2s2TOVd7Y7UFw W+C56bsOYHSJTdPoAcAW3S+G4GD5ECHWRdQzQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=J1FuwBOujuUzNf891scewCjH5fmMd7isBW+Ne4cV/Uk=; b=ougqZHjEPwyw8pc1CsQjQcDG/j8+lhnaB5OkgU18SUienxc2v58WxPFXTklH7L3wyB vQ1VmOn8LEQ1ut6PU9Vlv15ksz7u3iG6g1HYlPHWw4Yj+ZbdnIibrX694pXwW4uKIz9a 7I667mORVzwNP5XihHD9stpMPyNrkOTrL2R0Nhm1lbhLGr5hc/ockTeVgJsbxGpGRVlm 85/nmjneoD7oxIGLdqcmyuS500ny742EKfVYi4F97jzHiaulfZgujh960hHZk6TnZtmq 2A+gMiqgJ67zme6tK7iff9IY3hE21vnAEJZr5mJw/rTtjPsyJm3Hu+CelJef8zgibxGi EiCQ== X-Gm-Message-State: APf1xPDru40bd3EPShGF0Y7kutlY/sdXykgre4/rYpGs47+vBB+s3ypT 6WIh61bZbZl2CZJ0jnXOHzMU2nF/znh1X0RYerDt1w== X-Received: by 10.31.196.131 with SMTP id u125mr11747436vkf.158.1519773606093; Tue, 27 Feb 2018 15:20:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.242.140 with HTTP; Tue, 27 Feb 2018 15:20:05 -0800 (PST) In-Reply-To: <20180224024613.24078-5-mcgrof@kernel.org> References: <20180224024613.24078-1-mcgrof@kernel.org> <20180224024613.24078-5-mcgrof@kernel.org> From: Kees Cook Date: Tue, 27 Feb 2018 15:20:05 -0800 X-Google-Sender-Auth: Y7o7c07M6dfyi9Foc3kdHyK3KMo Message-ID: Subject: Re: [PATCH v2 04/11] firmware: simplify CONFIG_FW_LOADER_USER_HELPER_FALLBACK further To: "Luis R. Rodriguez" Cc: Greg KH , Andrew Morton , Shuah Khan , Martin Fuzzey , Mimi Zohar , David Howells , pali.rohar@gmail.com, Takashi Iwai , arend.vanspriel@broadcom.com, =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , nbroeking@me.com, Vikram Mulukutla , stephen.boyd@linaro.org, Mark Brown , Dmitry Torokhov , David Woodhouse , Linus Torvalds , Abhay_Salunke@dell.com, bjorn.andersson@linaro.org, jewalt@lgsinnovations.com, LKML , "linux-fsdevel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 23, 2018 at 6:46 PM, Luis R. Rodriguez 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 -Kees > > Signed-off-by: Luis R. Rodriguez > --- > 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