Skip to content

Commit cc9206e

Browse files
Avinesh Kumar via ltpacerv
authored andcommitted
tst_security.sh: Use enforce toggle to trigger SELinux measurement
Upstream kernel commit 644132a48f4e ("selinux: prune /sys/fs/selinux/checkreqprot") [0] removed the selinux_ima_measure_state() call from the checkreqprot write handler. This broke tst_update_selinux_state() which relied on writing to checkreqprot to trigger IMA measurements of SELinux state. Switch to toggling the enforce value instead, which still triggers selinux_ima_measure_state() on all kernel versions >= 5.12. [0] torvalds/linux@644132a Signed-off-by: Avinesh Kumar <avinesh.kumar@suse.com> Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
1 parent ad68429 commit cc9206e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

testcases/lib/tst_security.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,13 @@ tst_get_enforce()
142142

143143
tst_update_selinux_state()
144144
{
145-
local val
145+
local val orig_val
146146
local dir=$(tst_get_selinux_dir)
147147
[ -n "$dir" ] || return 1
148148

149-
val=$(cat $dir/checkreqprot)
150-
echo $val > $dir/checkreqprot
149+
# Toggle enforce to trigger SELinux state measurement
150+
orig_val=$(cat $dir/enforce)
151+
val=$((1 - orig_val))
152+
echo $val > $dir/enforce
153+
echo $orig_val > $dir/enforce
151154
}

0 commit comments

Comments
 (0)