public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Shuah Khan <skhan@linuxfoundation.org>
Cc: shuah@kernel.org, mcgrof@kernel.org, scott.branden@broadcom.com,
	tiwai@suse.de, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests: firmware: Fix it to do root uid check and skip
Date: Fri, 13 Dec 2019 08:31:21 +0100	[thread overview]
Message-ID: <20191213073121.GH1750354@kroah.com> (raw)
In-Reply-To: <20191213015606.23058-1-skhan@linuxfoundation.org>

On Thu, Dec 12, 2019 at 06:56:06PM -0700, Shuah Khan wrote:
> firmware attempts to load test modules that require root access
> and fail. Fix it to check for root uid and exit with skip code
> instead.
> 
> Before this fix:
> 
> selftests: firmware: fw_run_tests.sh
> modprobe: ERROR: could not insert 'test_firmware': Operation not permitted
> You must have the following enabled in your kernel:
> CONFIG_TEST_FIRMWARE=y
> CONFIG_FW_LOADER=y
> CONFIG_FW_LOADER_USER_HELPER=y
> CONFIG_IKCONFIG=y
> CONFIG_IKCONFIG_PROC=y
> not ok 1 selftests: firmware: fw_run_tests.sh # SKIP
> 
> With this fix:
> 
> selftests: firmware: fw_run_tests.sh
> skip all tests: must be run as root
> not ok 1 selftests: firmware: fw_run_tests.sh # SKIP
> 
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
> ---
>  tools/testing/selftests/firmware/fw_lib.sh | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/testing/selftests/firmware/fw_lib.sh b/tools/testing/selftests/firmware/fw_lib.sh
> index b879305a766d..5b8c0fedee76 100755
> --- a/tools/testing/selftests/firmware/fw_lib.sh
> +++ b/tools/testing/selftests/firmware/fw_lib.sh
> @@ -34,6 +34,12 @@ test_modprobe()
>  
>  check_mods()
>  {
> +	local uid=$(id -u)
> +	if [ $uid -ne 0 ]; then
> +		echo "skip all tests: must be run as root" >&2
> +		exit $ksft_skip
> +	fi
> +
>  	trap "test_modprobe" EXIT
>  	if [ ! -d $DIR ]; then
>  		modprobe test_firmware
> -- 
> 2.20.1
> 

Reviwed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

      reply	other threads:[~2019-12-13  7:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13  1:56 [PATCH] selftests: firmware: Fix it to do root uid check and skip Shuah Khan
2019-12-13  7:31 ` Greg KH [this message]

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=20191213073121.GH1750354@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=scott.branden@broadcom.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tiwai@suse.de \
    /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