[LTP] [PATCH 1/1] ima_setup.sh: Fix loop device workaround

Petr Vorel pvorel@suse.cz
Tue Sep 20 23:43:01 CEST 2022


Since 1f6bd6e66 ("tst_test.sh: Add $TST_ALL_FILESYSTEMS") ima_keys.sh
and other following tests fail on systems with tmpfs on $TMPDIR:

    ima_keys 1 TCONF: IMA policy does not specify '^measure.*func=KEY_CHECK'
    tst_device.c:255: TWARN: ioctl(/dev/loop0, LOOP_CLR_FD, 0) no ENXIO for too long

    Usage:
    tst_device acquire [size [filename]]
    tst_device release /path/to/device
    tst_device clear /path/to/device

    ima_keys 1 TWARN: Failed to release device '/dev/loop0'
    rm: cannot remove '/tmp/LTP_ima_keys.YArl935DCg/mntpoint': Device or resource busy

unset TST_NEEDS_DEVICE should have been done before loading tst_test.sh,
as it's not a good idea to modify TST_* variables after loading tst_test.sh
(It worked before just by change).

Fixes: 04021637f ("tst_test.sh: Cleanup getopts usage")

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/security/integrity/ima/tests/ima_setup.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index a626aae44..4b6690ce6 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -348,10 +348,9 @@ require_evmctl()
 	fi
 }
 
-. tst_test.sh
-
 # loop device is needed to use only for tmpfs
 TMPDIR="${TMPDIR:-/tmp}"
 if [ "$(df -T $TMPDIR | tail -1 | awk '{print $2}')" != "tmpfs" -a -n "$TST_NEEDS_DEVICE" ]; then
 	unset TST_NEEDS_DEVICE
 fi
+. tst_test.sh
-- 
2.37.3



More information about the ltp mailing list