Received: by 10.223.185.116 with SMTP id b49csp5525438wrg; Tue, 27 Feb 2018 15:08:44 -0800 (PST) X-Google-Smtp-Source: AG47ELshYxij7Zhu1od5P0dGth46w+OojSoXNq1QbrXiSVLRiZrlOkHfjcuYRQk+w5ubF++9RwEK X-Received: by 2002:a17:902:407:: with SMTP id 7-v6mr3024301ple.9.1519772924001; Tue, 27 Feb 2018 15:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519772923; cv=none; d=google.com; s=arc-20160816; b=hkSHIMJi1G5DuXvjucE7o88CZmaWULezkzA9L+CDualJqgcGEi4kJigDXDC7FBrY7C ZymCFaeQDRUQ24+RxESzf7HBzQKW+fJjRN9i77rUc7qqfLJGPH/6PG1P2wpit009kXQp /a/PQRpaWxQxnvWYmnWHPwbgrEUrBdT++JiN76ogfO7HCvxFskbntzy6BEBjeEvXrFml ttpw4mE5+DLoenF63ohyekCRwwqsKkJKg7PgGIe+GNah8jemeHFDyduO4kCOkhFA4frk 25/bjp2grbCcKuSxNJ0WWm/yFV5kxIX81gY2v6NofwSgLZklowp9Y0NcXEHIkJNtLs52 D6Lg== 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=pqUn7+BoO8vTyFOsmua1OAcaJqYH5aY32Avdjw/ZTMw=; b=j3nkyPxbx3abo7aOc41qmZQQ1g2fkq1PwLxiJh1B4eFbdDKfCJQd75ayhLr9bIBFdP 98JSe7+nP2I4Sk9rl/7lQG2Q1an7aZkg9sHLEb86qHqN5wiuqd1KIP5qRei+USXSpZIW 0HCu62C8gdpDtd63OMg/jSNSIFvSukxxaxo8cd1AUNAZ1aon7xRDJJc/P4G+/TxbkSSW HsWKWTABzrYUHz6CkSqdiIIil0tQlXMJCK3KVT/J8ugtnYjflJfdoWhjeBgYKYYbfXAx 4rn8hUvtrqqp6RdKYY1PYTyrSsrYUG/TCZxtxPkghW1AVqaqB5475vf1vG/u1bGB0HK3 ABNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=ohenyVVM; dkim=fail header.i=@chromium.org header.s=google header.b=Xbs7EQLE; 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 k8si169848pfi.3.2018.02.27.15.08.28; Tue, 27 Feb 2018 15:08:43 -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=ohenyVVM; dkim=fail header.i=@chromium.org header.s=google header.b=Xbs7EQLE; 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 S1751901AbeB0XHx (ORCPT + 99 others); Tue, 27 Feb 2018 18:07:53 -0500 Received: from mail-vk0-f68.google.com ([209.85.213.68]:42528 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751800AbeB0XHu (ORCPT ); Tue, 27 Feb 2018 18:07:50 -0500 Received: by mail-vk0-f68.google.com with SMTP id y127so340370vky.9 for ; Tue, 27 Feb 2018 15:07:50 -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=pqUn7+BoO8vTyFOsmua1OAcaJqYH5aY32Avdjw/ZTMw=; b=ohenyVVMjnaF8vBQqPqG0NhEpzI1WhdcaUZpdbFsLnWnbi8w5/pnNG6pFtp0AxJe9G E2pZq1aEqgu1mVDRxiHlfS7zwyuo4ciGmSXSTSN5vpPnw6ib+AqS7Y1D1ySMAtd8Mxrr kQaWvMntHqZy5n3rgA103cvXqN50gEUJxMQH8GlSNvsLHOSBizaKOKOJ1C7oM1XPJxGP DDbwsfXAY7SAb6jeucnvnpLjHfADI9LyzLMTfWqajCS7JR5kSNQFM5JytV2tdEpm3lye mqXZdpyjcusSCM56IpXS10sEHRNNgYCnDOh6eV0KZKTkCI9QwUlI2q/HUE7Cywf8OCnC Ylbw== 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=pqUn7+BoO8vTyFOsmua1OAcaJqYH5aY32Avdjw/ZTMw=; b=Xbs7EQLEfscB9r2iIQ4lTfeVVeb/Y0VIkGu2k/G+/EVsnLyo0QxrCzPcx3+kzYUYgm cgxnUnoNaBhJS785L/eUKu3wF7i75nbjKmkf3WSc4EFFvVt/Awd5tO1Z+L74Cb8k2DUA NgLBInfzV5ZMwHEK+cyNOHgcD86nRIz6KttcU= 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=pqUn7+BoO8vTyFOsmua1OAcaJqYH5aY32Avdjw/ZTMw=; b=MdLc0X27l00QNohzWxCyZR2WC/x09oNwdkq2Y4X2LytaGzscE19BGDDEEex2W8Hqii OInYh5XYs3O+2MTYcEISLP6bIpDFSFaGv0V7gZgzMxZvYi+S7eL5SKefuw74HyhOzUGE gfOmrogDpTXkPoUZ4KzMTbRmHFTCZpOXUw86zU5HV+TX3XfwBGsywxBLz1q5VmYDwU6n 7ZWG749tHt8sTFevNUxcjpHwgaIuEvxPL9pJiXUaVE69VISHmSlS3TrvLZfetjbXatOj 9WwrSEGgLWPvqz0R35QxkIYrc22D+Wz0Ul3QvftUz/NuA3pvLvHLqEjyIBmPVewum8xO Df3Q== X-Gm-Message-State: APf1xPAJ7LKUR7L80Bif2VdT57qhzT+oPKzvg3tqdELepuHey0wikzRH xPv2wvytUbsd0FYZ1PsMk7DIpyxASJTebJJegVeTog== X-Received: by 10.31.168.142 with SMTP id r136mr11676541vke.149.1519772869850; Tue, 27 Feb 2018 15:07:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.242.140 with HTTP; Tue, 27 Feb 2018 15:07:49 -0800 (PST) In-Reply-To: <20180224024613.24078-2-mcgrof@kernel.org> References: <20180224024613.24078-1-mcgrof@kernel.org> <20180224024613.24078-2-mcgrof@kernel.org> From: Kees Cook Date: Tue, 27 Feb 2018 15:07:49 -0800 X-Google-Sender-Auth: QO7Jtylc7Tb_B716tNSeEcPq6IY Message-ID: Subject: Re: [PATCH v2 01/11] test_firmware: enable custom fallback testing on limited kernel configs 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: > When a kernel is not built with: > > CONFIG_HAS_FW_LOADER_USER_HELPER_FALLBACK=y > > We don't currently enable testing fw_fallback.sh. For kernels that > still enable the fallback mechanism, its possible to use the async > request firmware API call request_firmware_nowait() using the custom > interface to use the fallback mechanism, so we should be able to test > this but we currently cannot. > > We can enable testing without CONFIG_HAS_FW_LOADER_USER_HELPER_FALLBACK=y > by relying on /proc/config.gz (CONFIG_IKCONFIG_PROC), if present. If you > don't have this we'll have no option but to rely on old heuristics for now. > > Signed-off-by: Luis R. Rodriguez > --- > tools/testing/selftests/firmware/config | 4 +++ > tools/testing/selftests/firmware/fw_fallback.sh | 45 ++++++++++++++++++++++++- > 2 files changed, 48 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/firmware/config b/tools/testing/selftests/firmware/config > index c8137f70e291..bf634dda0720 100644 > --- a/tools/testing/selftests/firmware/config > +++ b/tools/testing/selftests/firmware/config > @@ -1 +1,5 @@ > CONFIG_TEST_FIRMWARE=y > +CONFIG_FW_LOADER=y > +CONFIG_FW_LOADER_USER_HELPER=y > +CONFIG_IKCONFIG=y > +CONFIG_IKCONFIG_PROC=y > diff --git a/tools/testing/selftests/firmware/fw_fallback.sh b/tools/testing/selftests/firmware/fw_fallback.sh > index 722cad91df74..a42e437363d9 100755 > --- a/tools/testing/selftests/firmware/fw_fallback.sh > +++ b/tools/testing/selftests/firmware/fw_fallback.sh > @@ -6,7 +6,46 @@ > # won't find so that we can do the load ourself manually. > set -e > > +PROC_CONFIG="/proc/config.gz" > +TEST_DIR=$(dirname $0) > + > modprobe test_firmware > +if [ ! -f $PROC_CONFIG ]; then > + if modprobe configs 2>/dev/null; then > + echo "Loaded configs module" > + if [ ! -f $PROC_CONFIG ]; then > + echo "You must have the following enabled in your kernel:" >&2 > + cat $TEST_DIR/config >&2 > + echo "Resorting to old heuristics" >&2 > + fi > + else > + echo "Failed to load configs module, using old heuristics" >&2 > + fi > +fi > + > +kconfig_has() > +{ > + if [ -f $PROC_CONFIG ]; then > + if zgrep -q $1 $PROC_CONFIG 2>/dev/null; then > + echo "yes" > + else > + echo "no" > + fi > + else > + # We currently don't have easy heuristics to infer this > + # so best we can do is just try to use the kernel assuming > + # you had enabled it. This matches the old behaviour. > + if [ "$1" = "CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y" ]; then > + echo "yes" > + elif [ "$1" = "CONFIG_FW_LOADER_USER_HELPER=y" ]; then > + if [ -d /sys/class/firmware/ ]; then > + echo yes > + else > + echo no > + fi > + fi > + fi > +} Some day when we have more formalized CONFIG-scanning for selftests, we can probably describe all of this better in a cleaner way. In the meantime, yeah, this seems fine. > > DIR=/sys/devices/virtual/misc/test_firmware > > @@ -14,6 +53,7 @@ DIR=/sys/devices/virtual/misc/test_firmware > # These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that > # as an indicator for CONFIG_FW_LOADER_USER_HELPER. > HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi) > +HAS_FW_LOADER_USER_HELPER_FALLBACK=$(kconfig_has CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y) > > if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then > OLD_TIMEOUT=$(cat /sys/class/firmware/timeout) > @@ -286,7 +326,10 @@ run_sysfs_custom_load_tests() > fi > } > > -run_sysfs_main_tests > +if [ "$HAS_FW_LOADER_USER_HELPER_FALLBACK" = "yes" ]; then > + run_sysfs_main_tests > +fi > + > run_sysfs_custom_load_tests > > exit 0 > -- > 2.16.2 > Acked-by: Kees Cook -Kees -- Kees Cook Pixel Security