Skip to content

Commit b2ea426

Browse files
mimizoharpevik
authored andcommitted
ima_selinux.sh: test2 assumes CONFIG_IMA_DISABLE_HTABLE is configured
test2 uses the last "selinux-state" record stored in the IMA measurement list to determine whether SELinux is in enforcing mode and then compares it to the selinux enforce file status. The tst_update_selinux_state flips the SELinux enforce status (/sys/fs/selinux/enforce) to force a new "selinux-state" record to be appended to the IMA measurement list. However, this only happens when CONFIG_IMA_DISABLE_HTABLE is configured. Don't fail the test when CONFIG_IMA_DISABLE_HTABLE is not configured. Link: https://lore.kernel.org/ltp/20260821200620.902699-1-zohar@linux.ibm.com/ Reviewed-by: Petr Vorel <pvorel@suse.cz> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> [ pvorel: TPASS => TCONF ] Signed-off-by: Petr Vorel <pvorel@suse.cz>
1 parent 6e96605 commit b2ea426

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

testcases/kernel/security/integrity/ima/tests/ima_selinux.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ test2()
147147
enforced_value=$(echo $measured_data | awk -F'[=;]' '{print $4}')
148148
expected_enforced_value=$(cat $SELINUX_DIR/enforce)
149149
if [ "$expected_enforced_value" != "$enforced_value" ]; then
150-
tst_res $IMA_FAIL "enforce: expected: $expected_enforced_value, got: $enforced_value"
150+
if ! tst_check_kconfigs "CONFIG_IMA_DISABLE_HTABLE=y"; then
151+
tst_res TCONF "Duplicate \"selinux-state\" record missing (CONFIG_IMA_DISABLE_HTABLE not set)"
152+
else
153+
tst_res $IMA_FAIL "enforce: expected: $expected_enforced_value, got: $enforced_value"
154+
fi
151155
return
152156
fi
153157

0 commit comments

Comments
 (0)