Message ID | 20190405165225.27216-4-pvorel@suse.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | LTP reproducer on broken IMA on overlayfs | expand |
Hi Petr, thanks a lot for your continued work on the IMA / EVM tests and sorry for missing feedback - the mail got lost in my stack of TODO items. Am 05.04.19 um 18:52 Uhr schrieb Petr Vorel: > Should I check EVM enabled? As these tests require an appropriately prepared machine anyway: How about printing a message whether only IMA or both IMA and EVM are enabled. These tests make sense in both cases, so I wouldn't block them on either setup. > /sys/kernel/security/evm should be 1? Yes, that should be enough to detect whether EVM is enabled. > +test1() > +{ > + local file="foo1.txt" > + > + tst_res TINFO "overwrite file in overlay" > + ROD echo lower \> $lower/$file > + EXPECT_PASS echo overlay \> $merged/$file It seems the redirection / escaping is wrong here: the string "overlay" never ends up in the target file. > +} > + > +test2() > +{ > + local file="foo2.txt" > + > + tst_res TINFO "append file in overlay" > + ROD echo lower \> $lower/$file > + EXPECT_PASS echo overlay \>\> $merged/$file Same here: "overlay" never ends up in the target file. Ignaz
Hi Ignaz, > thanks a lot for your continued work on the IMA / EVM tests and sorry for > missing feedback - the mail got lost in my stack of TODO items. Not a big deal and thanks a lot for a feedback and info. > Am 05.04.19 um 18:52 Uhr schrieb Petr Vorel: > > Should I check EVM enabled? > As these tests require an appropriately prepared machine anyway: How about > printing a message whether only IMA or both IMA and EVM are enabled. These > tests make sense in both cases, so I wouldn't block them on either setup. > > /sys/kernel/security/evm should be 1? > Yes, that should be enough to detect whether EVM is enabled. > > +test1() > > +{ > > + local file="foo1.txt" > > + > > + tst_res TINFO "overwrite file in overlay" > > + ROD echo lower \> $lower/$file > > + EXPECT_PASS echo overlay \> $merged/$file > It seems the redirection / escaping is wrong here: the string "overlay" > never ends up in the target file. I'm pretty sure that '>' should be escaped for both ROD and EXPECT_PASS. EXPECT_PASS should fail (something like "evm_overlay 1 TFAIL: echo overlay ... failed unexpectedly") if "overlay" string didn't get into $merged/$file file. Can you sent whole output? Kind regards, Petr
diff --git a/runtest/ima b/runtest/ima index bcae16bb7..f3ea88cf0 100644 --- a/runtest/ima +++ b/runtest/ima @@ -3,3 +3,4 @@ ima_measurements ima_measurements.sh ima_policy ima_policy.sh ima_tpm ima_tpm.sh ima_violations ima_violations.sh +evm_overlay evm_overlay.sh diff --git a/testcases/kernel/security/integrity/ima/tests/evm_overlay.sh b/testcases/kernel/security/integrity/ima/tests/evm_overlay.sh new file mode 100755 index 000000000..08ec1ea37 --- /dev/null +++ b/testcases/kernel/security/integrity/ima/tests/evm_overlay.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz> +# Based on reproducer and further discussion with Ignaz Forster <iforster@suse.de> + +TST_SETUP="setup" +TST_CLEANUP="cleanup" +TST_NEEDS_DEVICE=1 +TST_CNT=4 +. ima_setup.sh + +setup() +{ + lower="$TST_MNTPOINT/lower" + upper="$TST_MNTPOINT/upper" + work="$TST_MNTPOINT/work" + merged="$TST_MNTPOINT/merged" + mkdir -p $lower $upper $work $merged + + device_backup="$TST_DEVICE" + TST_DEVICE="overlay" + + fs_type_backup="$TST_FS_TYPE" + TST_FS_TYPE="overlay" + + mntpoint_backup="$TST_MNTPOINT" + TST_MNTPOINT="$merged" + + params_backup="$TST_MNT_PARAMS" + TST_MNT_PARAMS="-o lowerdir=$lower,upperdir=$upper,workdir=$work" + + grep -q -e ima_policy= -e ima_appraise_tcb /proc/cmdline || \ + tst_brk TCONF "Test requires specify IMA policy as kernel parameter" + + tst_mount + mounted=1 +} + +test1() +{ + local file="foo1.txt" + + tst_res TINFO "overwrite file in overlay" + ROD echo lower \> $lower/$file + EXPECT_PASS echo overlay \> $merged/$file +} + +test2() +{ + local file="foo2.txt" + + tst_res TINFO "append file in overlay" + ROD echo lower \> $lower/$file + EXPECT_PASS echo overlay \>\> $merged/$file +} + +test3() +{ + local file="foo3.txt" + + tst_res TINFO "create a new file in overlay" + EXPECT_PASS echo overlay \> $merged/$file +} + +test4() +{ + local f + + tst_res TINFO "read all created files" + for f in $(find $TST_MNTPOINT -type f); do + EXPECT_PASS cat $f \> /dev/null 2\> /dev/null + done +} + +cleanup() +{ + [ -n "$mounted" ] || return 0 + + tst_umount $TST_DEVICE + + TST_DEVICE="$device_backup" + TST_FS_TYPE="$fs_type_backup" + TST_MNTPOINT="$mntpoint_backup" + TST_MNT_PARAMS="$params_backup" +} + +tst_run diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh index da49eb1b2..08aa5300a 100644 --- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh @@ -64,14 +64,14 @@ print_ima_config() local config="/boot/config-$(uname -r)" local i - tst_res TINFO "/proc/cmdline: $(cat /proc/cmdline)" - if [ -r "$config" ]; then tst_res TINFO "IMA kernel config:" for i in $(grep ^CONFIG_IMA $config); do tst_res TINFO "$i" done fi + + tst_res TINFO "/proc/cmdline: $(cat /proc/cmdline)" } ima_setup()