]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
selftests: firmware: Fix it to do root uid check and skip
authorShuah Khan <skhan@linuxfoundation.org>
Fri, 13 Dec 2019 01:56:06 +0000 (18:56 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 06:00:53 +0000 (01:00 -0500)
BugLink: https://bugs.launchpad.net/bugs/1862227
[ Upstream commit c65e41538b04e0d64a673828745a00cb68a24371 ]

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>
Reviwed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
tools/testing/selftests/firmware/fw_lib.sh

index f236cc2954502b1db162bbea8e49845120afea59..eb886acadef935073c78495095183370a3c3bbe0 100755 (executable)
@@ -28,6 +28,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