Update validate() to support multiple violations
Mimi Zohar
maintainerRFC PATCH 1/3 Update validate() to support multiple violations
Add support for the number of expected violations. Include the expected number of violations in the output.
--- .../security/integrity/ima/tests/ima_violations.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +8 -2
@@ -71,20 +71,26 @@ validate() local num_violations="$1" local count="$2" local search="$3" + local expected_violations=$4 local max_attempt=3 local count2 i num_violations_new + [ -z $expected_violations ] && expected_violations=1 + for i in $(seq 1 $max_attempt); do read num_violations_new < $IMA_VIOLATIONS count2="$(get_count $search)" - if [ $(($num_violations_new - $num_violations)) -gt 0 ]; then + if [ $(($num_violations_new - $num_violations)) -eq $expected_violations ]; then if [ $count2 -gt $count ]; then - tst_res TPASS "$search violation added" + tst_res TPASS "$expected_violations $search violation(s) added" return else tst_res TINFO "$search not found in $LOG ($i/$max_attempt attempt)..." tst_sleep 1s fi + elif [ $(($num_violations_new - $num_violations)) -gt 0 ]; then + tst_res $IMA_FAIL "$search too many violations added" + return else tst_res $IMA_FAIL "$search violation not added" return
Signature · 1 line
2.48.1
Mimi Zohar
maintainerRFC PATCH 2/3 ima: additional open-writer violation tests
Kernel patch "ima: limit the number of open-writers integrity violations" prevents superfluous "open-writers" violations. Add corresponding LTP tests.
--- .../integrity/ima/tests/ima_violations.sh | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-)
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +86 -1
@@ -8,7 +8,7 @@ TST_SETUP="setup" TST_CLEANUP="cleanup" -TST_CNT=3 +TST_CNT=6 REQUIRED_BUILTIN_POLICY="tcb" REQUIRED_POLICY_CONTENT='violations.policy'
@@ -60,6 +60,17 @@ close_file_write() exec 4>&- } +open_file_write2() +{ + exec 5> $FILE || exit 1 + echo 'test writing2' >&5 +} + +close_file_write2() +{ + exec 5>&- +} + get_count() { local search="$1"
@@ -160,6 +171,80 @@ test3() tst_sleep 2s } +test4() +{ + tst_res TINFO "verify limiting single open writer violation" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_read + close_file_read + + close_file_write + + validate $num_violations $count $search 1 +} + +test5() +{ + tst_res TINFO "verify limiting multiple open writers violations" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_write2 + open_file_read + close_file_read + close_file_write2 + + open_file_read + close_file_read + + close_file_write + + validate $num_violations $count $search 1 +} + +test6() +{ + tst_res TINFO "verify new open writer causes additional violation" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_read + close_file_read + close_file_write + + open_file_write + open_file_read + close_file_read + close_file_write + validate $num_violations $count $search 2 +} + . ima_setup.sh . daemonlib.sh tst_run
Signature · 1 line
2.48.1
Re: [RFC PATCH 2/3] ima: additional open-writer violation tests
Hi Mimi,
Quoted 24 lines
Kernel patch "ima: limit the number of open-writers integrity violations" prevents superfluous "open-writers" violations. Add corresponding LTP tests.
Signed-off-by Mimi Zohar <[email protected]>--- .../integrity/ima/tests/ima_violations.sh | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-)testcases/kernel/security/integrity/ima/tests/ima_violations.sh +1
-1@@ -8,7 +8,7 @@ TST_SETUP="setup" TST_CLEANUP="cleanup" -TST_CNT=3 +TST_CNT=6 REQUIRED_BUILTIN_POLICY="tcb" REQUIRED_POLICY_CONTENT='violations.policy'
testcases/kernel/security/integrity/ima/tests/ima_violations.sh close_file_write() · line 65
Quoted 6 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +3
-0@@ -60,6 +60,17 @@ close_file_write() exec 4>&- } +open_file_write2() +{ + exec 5> $FILE || exit 1
maybe:
exec 5> $FILE || tst_brk TBROK "exec 5> $FILE failed"
Because tst_brk TBROK calls test cleanup. Plain exit kills everything. We also have ROD, but that requires binaries ('exec' is a shell builtin). (It applies to the third patch as well.)
Quoted 52 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +45
-0+ echo 'test writing2' >&5 +} + +close_file_write2() +{ + exec 5>&- +} + get_count() { local search="$1"@@ -160,6 +171,80 @@ test3() tst_sleep 2s } +test4() +{ + tst_res TINFO "verify limiting single open writer violation" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_read + close_file_read + + close_file_write + + validate $num_violations $count $search 1 +} + +test5() +{ + tst_res TINFO "verify limiting multiple open writers violations" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read + + open_file_write2
testcases/kernel/security/integrity/ima/tests/ima_violations.sh test3() · line 220
Quoted 10 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +10
-0+ open_file_read + close_file_read + close_file_write2 + + open_file_read + close_file_read + + close_file_write + + validate $num_violations $count $search 1
nit: safer to quote
validate "$num_violations" "$count" "$search" 1
Quoted 15 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +15
-0+} + +test6() +{ + tst_res TINFO "verify new open writer causes additional violation" + + local search="open_writers" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_write + open_file_read + close_file_read
testcases/kernel/security/integrity/ima/tests/ima_violations.sh test3() · line 245
Quoted 10 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +10
-0+ + open_file_read + close_file_read + close_file_write + + open_file_write + open_file_read + close_file_read + close_file_write + validate $num_violations $count $search 2
And here.
Kind regards,
Petr
Mimi Zohar
maintainerRFC PATCH 3/3 ima: additional ToMToU violation tests
In reply to Mimi ZoharKernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
--- .../integrity/ima/tests/ima_violations.sh | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +45 -1
@@ -8,7 +8,7 @@ TST_SETUP="setup" TST_CLEANUP="cleanup" -TST_CNT=6 +TST_CNT=8 REQUIRED_BUILTIN_POLICY="tcb" REQUIRED_POLICY_CONTENT='violations.policy'
@@ -245,6 +245,50 @@ test6() validate $num_violations $count $search 2 } +test7() +{ + tst_res TINFO "verify limiting single open reader ToMToU violations" + + local search="ToMToU" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_read + open_file_write + close_file_write + + open_file_write + close_file_write + close_file_read + + validate $num_violations $count $search 1 +} + +test8() +{ + tst_res TINFO "verify new open reader causes additional ToMToU violation" + + local search="ToMToU" + local count num_violations + + read num_violations < $IMA_VIOLATIONS + count="$(get_count $search)" + + open_file_read + open_file_write + close_file_write + close_file_read + + open_file_read + open_file_write + close_file_write + close_file_read + + validate $num_violations $count $search 2 +} + . ima_setup.sh . daemonlib.sh tst_run
Signature · 1 line
2.48.1
Re: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Hi Mimi,
Quoted 5 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Unfortunately tests fail on both mainline kernel and kernel with your patches.
Any hint what could be wrong?
Mainline kernel (on kernel with your patches it looks the same):ima_violations 1 TINFO: Running: ima_violations.shima_violations 1 TINFO: Tested kernel: Linux ts 6.13.0-2.g0127a37-default #1 SMP PREEMPT_DYNAMIC Thu Jan 23 11:21:55 UTC 2025 (0127a37) x86_64 x86_64 x86_64 GNU/Linuxima_violations 1 TINFO: Using /tmp/LTP_ima_violations.cKm34XVZk2 as tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations 1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations 1 TINFO: Mounting device: mount -t ext3 /dev/loop0 /tmp/LTP_ima_violations.cKm34XVZk2/mntpointima_violations 1 TINFO: timeout per run is 0h 5m 0sima_violations 1 TINFO: IMA kernel config:ima_violations 1 TINFO: CONFIG_IMA=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations 1 TINFO: CONFIG_IMA_LSM_RULES=yima_violations 1 TINFO: CONFIG_IMA_NG_TEMPLATE=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations 1 TINFO: CONFIG_IMA_READ_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE=yima_violations 1 TINFO: CONFIG_IMA_ARCH_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_MODSIG=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations 1 TINFO: CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations 1 TINFO: CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations 1 TINFO: CONFIG_IMA_DISABLE_HTABLE=yima_violations 1 TINFO: /proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.13.0-2.g0127a37-default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmor ignore_loglevel ima_violations 1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations 1 TINFO: test requires IMA policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations 1 TINFO: SUT has required policy contentima_violations 1 TINFO: using log /var/log/audit/audit.logima_violations 1 TINFO: verify open writers violationima_violations 1 TFAIL: open_writers too many violations addedima_violations 2 TINFO: verify ToMToU violationima_violations 2 TFAIL: ToMToU too many violations addedima_violations 3 TINFO: verify open_writers using mmapped files
tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f
tst_test.c:1904: TINFO: Tested kernel: 6.13.0-2.g0127a37-default #1 SMP PREEMPT_DYNAMIC Thu Jan 23 11:21:55 UTC 2025 (0127a37) x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
ima_mmap.c:38: TINFO: sleep 3sima_violations 3 TFAIL: open_writers too many violations added
ima_mmap.c:41: TPASS: test completed
Summary:
passed 1 failed 0 broken 0 skipped 0
warnings 0ima_violations 4 TINFO: verify limiting single open writer violation ima_violations 4 TFAIL: open_writers too many violations added ima_violations 5 TINFO: verify limiting multiple open writers violations ima_violations 5 TFAIL: open_writers too many violations added ima_violations 6 TINFO: verify new open writer causes additional violation ima_violations 6 TFAIL: open_writers too many violations added ima_violations 7 TINFO: verify limiting single open reader ToMToU violations ima_violations 7 TFAIL: ToMToU too many violations added ima_violations 8 TINFO: verify new open reader causes additional ToMToU violation ima_violations 8 TFAIL: ToMToU too many violations added
Kind regards,
Petr
Re: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Hi Mimi,
Quoted 5 lines
Hi Mimi,
Quoted 2 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Quoted 8 lines
Quoted 2 lines
Unfortunately tests fail on both mainline kernel and kernel with your patches.
Any hint what could be wrong?
Mainline kernel (on kernel with your patches it looks the same):
I'm sorry, I accidentally tested only on vanilla kernel. Rerunning tests with updated kernel.
Is it this considered as a security feature? If yes, than failures on vanilla kernel are ok, we just need to later add kernel hashes to let testers know about missing backports. If it's a feature (not to be backported) we should test new feature only on newer kernels.
Kind regards,
Petr
Quoted 64 lines
ima_violations1 TINFO: Running:ima_violations.shima_violations1 TINFO: Tested kernel: Linux ts 6.13.0-2.g0127a37-default #1 SMPPREEMPT_DYNAMICThu Jan 23 11:21:55 UTC 2025 (0127a37)x86_64x86_64x86_64GNU/Linuxima_violations1 TINFO: Using/tmp/LTP_ima_violations.cKm34XVZk2as tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations1 TINFO: Mounting device: mount -t ext3/dev/loop0/tmp/LTP_ima_violations.cKm34XVZk2/mntpointima_violations1 TINFO: timeout per run is 0h 5m 0sima_violations1 TINFO: IMA kernel config:ima_violations1 TINFO:CONFIG_IMA=yima_violations1 TINFO:CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations1 TINFO:CONFIG_IMA_LSM_RULES=yima_violations1 TINFO:CONFIG_IMA_NG_TEMPLATE=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations1 TINFO:CONFIG_IMA_READ_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE=yima_violations1 TINFO:CONFIG_IMA_ARCH_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_MODSIG=yima_violations1 TINFO:CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations1 TINFO:CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations1 TINFO:CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations1 TINFO:CONFIG_IMA_DISABLE_HTABLE=yima_violations1 TINFO:/proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.13.0-2.g0127a37-default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmorignore_loglevelima_violations1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations1 TINFO: test requires IMA policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations1 TINFO: SUT has required policy contentima_violations1 TINFO: using log/var/log/audit/audit.logima_violations1 TINFO: verify open writers violationima_violations1 TFAIL:open_writerstoo many violations addedima_violations2 TINFO: verify ToMToU violationima_violations2 TFAIL: ToMToU too many violations addedima_violations3 TINFO: verifyopen_writersusing mmapped files
tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f
tst_test.c:1904: TINFO: Tested kernel: 6.13.0-2.g0127a37-default #1 SMPPREEMPT_DYNAMICThu Jan 23 11:21:55 UTC 2025 (0127a37)x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
ima_mmap.c:38: TINFO: sleep 3sima_violations3 TFAIL:open_writerstoo many violations added
ima_mmap.c:41: TPASS: test completedSummary:
passed 1 failed 0 broken 0 skipped 0warnings 0
ima_violations4 TINFO: verify limiting single open writer violationima_violations4 TFAIL:open_writerstoo many violations addedima_violations5 TINFO: verify limiting multiple open writers violationsima_violations5 TFAIL:open_writerstoo many violations addedima_violations6 TINFO: verify new open writer causes additional violationima_violations6 TFAIL:open_writerstoo many violations addedima_violations7 TINFO: verify limiting single open reader ToMToU violationsima_violations7 TFAIL: ToMToU too many violations addedima_violations8 TINFO: verify new open reader causes additional ToMToU violationima_violations8 TFAIL: ToMToU too many violations addedKind regards,
Petr
Mimi Zohar
maintainerRe: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Hi Petr,
Quoted 4 lines · Petr Vorel
Is it this considered as a security feature? If yes, than failures on vanilla kernel are ok, we just need to later add kernel hashes to let testers know about missing backports. If it's a feature (not to be backported) we should test new feature only on newer kernels.
I posted these LTP patches as RFC since the kernel patches themselves haven't been upstreamed. I'm still waiting for some kernel patch reviews. Posting these LTP patches might help with that.
Having multiple open-writers or ToMToU violations doesn't provide any benefit in terms of attestation. It just clutters the audit log and the IMA measurement list. Not extending the TPM would be a performance improvement. I'm not sure it would be classified as a security feature or bug fix.
Mimi
Mimi Zohar
maintainerRe: [RFC PATCH 3/3] ima: additional ToMToU violation tests
In reply to Petr VorelQuoted 10 lines · Petr Vorel
Hi Mimi,
Quoted 6 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel patches.
Quoted 2 lines
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with the IMA TCB measurement policy or similar policy being loaded. Can you share the IMA policy? e.g. cat /sys/kernel/security/ima/policy
thanks,
Mimi
Quoted 76 lines
Mainline kernel (on kernel with your patches it looks the same):
ima_violations1 TINFO: Running:ima_violations.shima_violations1 TINFO: Tested kernel: Linux ts 6.13.0-2.g0127a37-default #1 SMPPREEMPT_DYNAMICThu Jan 23 11:21:55 UTC 2025 (0127a37)x86_64x86_64x86_64GNU/Linuxima_violations1 TINFO: Using/tmp/LTP_ima_violations.cKm34XVZk2as tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations1 TINFO: Mounting device: mount -t ext3/dev/loop0/tmp/LTP_ima_violations.cKm34XVZk2/mntpointima_violations1 TINFO: timeout per run is 0h 5m 0sima_violations1 TINFO: IMA kernel config:ima_violations1 TINFO:CONFIG_IMA=yima_violations1 TINFO:CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations1 TINFO:CONFIG_IMA_LSM_RULES=yima_violations1 TINFO:CONFIG_IMA_NG_TEMPLATE=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations1 TINFO:CONFIG_IMA_READ_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE=yima_violations1 TINFO:CONFIG_IMA_ARCH_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_MODSIG=yima_violations1 TINFO:CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations1 TINFO:CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations1 TINFO:CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations1 TINFO:CONFIG_IMA_DISABLE_HTABLE=yima_violations1 TINFO:/proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.13.0-2.g0127a37- default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmorignore_loglevelima_violations1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations1 TINFO: test requires IMA policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations1 TINFO: SUT has required policy contentima_violations1 TINFO: using log/var/log/audit/audit.logima_violations1 TINFO: verify open writers violationima_violations1 TFAIL:open_writerstoo many violations addedima_violations2 TINFO: verify ToMToU violationima_violations2 TFAIL: ToMToU too many violations addedima_violations3 TINFO: verifyopen_writersusing mmapped files tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f tst_test.c:1904: TINFO: Tested kernel: 6.13.0-2.g0127a37-default #1 SMPPREEMPT_DYNAMICThu Jan 23 11:21:55 UTC 2025 (0127a37)x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_kconfig.c:676: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s ima_mmap.c:38: TINFO: sleep 3sima_violations3 TFAIL:open_writerstoo many violations added ima_mmap.c:41: TPASS: test completedSummary:
passed 1
failed 0
broken 0
skipped 0
warnings 0ima_violations4 TINFO: verify limiting single open writer violationima_violations4 TFAIL:open_writerstoo many violations addedima_violations5 TINFO: verify limiting multiple open writers violationsima_violations5 TFAIL:open_writerstoo many violations addedima_violations6 TINFO: verify new open writer causes additional violationima_violations6 TFAIL:open_writerstoo many violations addedima_violations7 TINFO: verify limiting single open reader ToMToU violationsima_violations7 TFAIL: ToMToU too many violations addedima_violations8 TINFO: verify new open reader causes additional ToMToU violationima_violations8 TFAIL: ToMToU too many violations addedKind regards,
Petr
Re: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 16 lines · Petr Vorel
Quoted 10 lines
Hi Mimi,
Quoted 6 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel patches.
Quoted 1 line
Any hint what could be wrong?
Quoted 7 lines
Of course it's dependent on the IMA policy. The tests assume being booted with the IMA TCB measurement policy or similar policy being loaded. Can you share the IMA policy? e.g. cat
/sys/kernel/security/ima/policythanks,
Mimi
Now testing on kernel *with* your patches. First run always fails, regardless whether using ima_policy=tcb or /opt/ltp/testcases/data/ima_violations/violations.policy).
Kind regards,
Petr
First run fails:
# LTP_IMA_LOAD_POLICY=1 LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH" ima_violations.sh
(policy is /opt/ltp/testcases/data/ima_violations/violations.policy)ima_violations 1 TINFO: Running: ima_violations.shima_violations 1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64 x86_64 x86_64 GNU/Linuxima_violations 1 TINFO: Using /tmp/LTP_ima_violations.XR34KhtnDM as tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations 1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations 1 TINFO: Mounting device: mount -t ext3 /dev/loop0 /tmp/LTP_ima_violations.XR34KhtnDM/mntpointima_violations 1 TINFO: timeout per run is 0h 5m 0sima_violations 1 TINFO: IMA kernel config:ima_violations 1 TINFO: CONFIG_IMA=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations 1 TINFO: CONFIG_IMA_LSM_RULES=yima_violations 1 TINFO: CONFIG_IMA_NG_TEMPLATE=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations 1 TINFO: CONFIG_IMA_READ_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE=yima_violations 1 TINFO: CONFIG_IMA_ARCH_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_MODSIG=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations 1 TINFO: CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations 1 TINFO: CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations 1 TINFO: CONFIG_IMA_DISABLE_HTABLE=yima_violations 1 TINFO: /proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102-default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmor ignore_loglevel ima_violations 1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations 1 TINFO: test requires IMA policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations 1 TINFO: WARNING: missing required policy content: 'measure func=FILE_CHECK mask=^MAY_READ euid=0'ima_violations 1 TINFO: trying to load '/opt/ltp/testcases/data/ima_violations/violations.policy' policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations 1 TINFO: example policy successfully loadedima_violations 1 TINFO: using log /var/log/audit/audit.logima_violations 1 TINFO: verify open writers violationima_violations 1 TFAIL: open_writers too many violations added: 2 - 0ima_violations 2 TINFO: verify ToMToU violationima_violations 2 TPASS: 1 ToMToU violation(s) addedima_violations 3 TINFO: verify open_writers using mmapped files
tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f
tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
ima_mmap.c:38: TINFO: sleep 3sima_violations 3 TPASS: 1 open_writers violation(s) added
ima_mmap.c:41: TPASS: test completed
Summary:
passed 1 failed 0 broken 0 skipped 0
warnings 0ima_violations 4 TINFO: verify limiting single open writer violation ima_violations 4 TPASS: 1 open_writers violation(s) addedima_violations 5 TINFO: verify limiting multiple open writers violations ima_violations 5 TPASS: 1 open_writers violation(s) addedima_violations 6 TINFO: verify new open writer causes additional violation ima_violations 6 TPASS: 2 open_writers violation(s) addedima_violations 7 TINFO: verify limiting single open reader ToMToU violations ima_violations 7 TPASS: 1 ToMToU violation(s) addedima_violations 8 TINFO: verify new open reader causes additional ToMToU violation ima_violations 8 TPASS: 2 ToMToU violation(s) addedima_violations 9 TINFO: WARNING: policy loaded via LTP_IMA_LOAD_POLICY=1, reboot recommended
Summary:
passed 7 failed 1 broken 0 skipped 0
warnings 0
Second run is ok:
# LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH" ima_violations.shima_violations 1 TINFO: Running: ima_violations.shima_violations 1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64 x86_64 x86_64 GNU/Linuxima_violations 1 TINFO: Using /var/tmp/LTP_ima_violations.SWERFjvPTp as tmpdir (btrfs filesystem)ima_violations 1 TINFO: timeout per run is 0h 5m 0sima_violations 1 TINFO: IMA kernel config:ima_violations 1 TINFO: CONFIG_IMA=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations 1 TINFO: CONFIG_IMA_LSM_RULES=yima_violations 1 TINFO: CONFIG_IMA_NG_TEMPLATE=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations 1 TINFO: CONFIG_IMA_READ_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE=yima_violations 1 TINFO: CONFIG_IMA_ARCH_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_MODSIG=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations 1 TINFO: CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations 1 TINFO: CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations 1 TINFO: CONFIG_IMA_DISABLE_HTABLE=yima_violations 1 TINFO: /proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102-default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmor ignore_loglevel ima_violations 1 TINFO: test requires IMA policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations 1 TINFO: SUT has required policy contentima_violations 1 TINFO: using log /var/log/audit/audit.logima_violations 1 TINFO: verify open writers violationima_violations 1 TPASS: 1 open_writers violation(s) addedima_violations 2 TINFO: verify ToMToU violationima_violations 2 TPASS: 1 ToMToU violation(s) addedima_violations 3 TINFO: verify open_writers using mmapped files
tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f
tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
ima_mmap.c:38: TINFO: sleep 3sima_violations 3 TPASS: 1 open_writers violation(s) added
ima_mmap.c:41: TPASS: test completed
Summary:
passed 1 failed 0 broken 0 skipped 0
warnings 0ima_violations 4 TINFO: verify limiting single open writer violation ima_violations 4 TPASS: 1 open_writers violation(s) added ima_violations 5 TINFO: verify limiting multiple open writers violations ima_violations 5 TPASS: 1 open_writers violation(s) added ima_violations 6 TINFO: verify new open writer causes additional violation ima_violations 6 TPASS: 2 open_writers violation(s) added ima_violations 7 TINFO: verify limiting single open reader ToMToU violations ima_violations 7 TPASS: 1 ToMToU violation(s) addedima_violations 8 TINFO: verify new open reader causes additional ToMToU violation ima_violations 8 TPASS: 2 ToMToU violation(s) added
Summary:
passed 8 failed 0 broken 0 skipped 0
warnings 0
Reboot and running with ima_policy=tcb also fails on the first time:
# LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH" ima_violations.sh
tmpfs is skippedima_violations 1 TINFO: Running: ima_violations.shima_violations 1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64 x86_64 x86_64 GNU/Linuxima_violations 1 TINFO: Using /tmp/LTP_ima_violations.FKQSfezAwR as tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations 1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations 1 TINFO: Mounting device: mount -t ext3 /dev/loop0 /tmp/LTP_ima_violations.FKQSfezAwR/mntpointima_violations 1 TINFO: timeout per run is 0h 5m 0sima_violations 1 TINFO: IMA kernel config:ima_violations 1 TINFO: CONFIG_IMA=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations 1 TINFO: CONFIG_IMA_LSM_RULES=yima_violations 1 TINFO: CONFIG_IMA_NG_TEMPLATE=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations 1 TINFO: CONFIG_IMA_READ_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE=yima_violations 1 TINFO: CONFIG_IMA_ARCH_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_MODSIG=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations 1 TINFO: CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations 1 TINFO: CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations 1 TINFO: CONFIG_IMA_DISABLE_HTABLE=yima_violations 1 TINFO: /proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102-default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmor ignore_loglevel ima_policy=tcb ima_violations 1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations 1 TINFO: booted with IMA policy: tcbima_violations 1 TINFO: using log /var/log/audit/audit.logima_violations 1 TINFO: verify open writers violationima_violations 1 TFAIL: open_writers too many violations added: 3 - 1ima_violations 2 TINFO: verify ToMToU violationima_violations 2 TPASS: 1 ToMToU violation(s) addedima_violations 3 TINFO: verify open_writers using mmapped files
tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f
tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
ima_mmap.c:38: TINFO: sleep 3sima_violations 3 TPASS: 1 open_writers violation(s) added
ima_mmap.c:41: TPASS: test completed
Summary:
passed 1 failed 0 broken 0 skipped 0
warnings 0ima_violations 4 TINFO: verify limiting single open writer violation ima_violations 4 TPASS: 1 open_writers violation(s) added ima_violations 5 TINFO: verify limiting multiple open writers violations ima_violations 5 TPASS: 1 open_writers violation(s) added ima_violations 6 TINFO: verify new open writer causes additional violation ima_violations 6 TPASS: 2 open_writers violation(s) added ima_violations 7 TINFO: verify limiting single open reader ToMToU violations ima_violations 7 TPASS: 1 ToMToU violation(s) addedima_violations 8 TINFO: verify new open reader causes additional ToMToU violation ima_violations 8 TPASS: 2 ToMToU violation(s) added
Summary:
passed 7 failed 1 broken 0 skipped 0
warnings 0
Second and later run is again OK
# LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH" ima_violations.sh
tmpfs is skippedima_violations 1 TINFO: Running: ima_violations.shima_violations 1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64 x86_64 x86_64 GNU/Linuxima_violations 1 TINFO: Using /tmp/LTP_ima_violations.1Qf6qJuSoo as tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations 1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations 1 TINFO: Mounting device: mount -t ext3 /dev/loop0 /tmp/LTP_ima_violations.1Qf6qJuSoo/mntpointima_violations 1 TINFO: timeout per run is 0h 5m 0sima_violations 1 TINFO: IMA kernel config:ima_violations 1 TINFO: CONFIG_IMA=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations 1 TINFO: CONFIG_IMA_LSM_RULES=yima_violations 1 TINFO: CONFIG_IMA_NG_TEMPLATE=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations 1 TINFO: CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations 1 TINFO: CONFIG_IMA_READ_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE=yima_violations 1 TINFO: CONFIG_IMA_ARCH_POLICY=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations 1 TINFO: CONFIG_IMA_APPRAISE_MODSIG=yima_violations 1 TINFO: CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations 1 TINFO: CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations 1 TINFO: CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations 1 TINFO: CONFIG_IMA_DISABLE_HTABLE=yima_violations 1 TINFO: /proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102-default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmor ignore_loglevel ima_policy=tcb ima_violations 1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations 1 TINFO: booted with IMA policy: tcbima_violations 1 TINFO: using log /var/log/audit/audit.logima_violations 1 TINFO: verify open writers violationima_violations 1 TPASS: 1 open_writers violation(s) addedima_violations 2 TINFO: verify ToMToU violationima_violations 2 TPASS: 1 ToMToU violation(s) addedima_violations 3 TINFO: verify open_writers using mmapped files
tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f
tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMP PREEMPT_DYNAMIC Thu Feb 20 12:26:55 UTC 2025 (b6b4102) x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
ima_mmap.c:38: TINFO: sleep 3sima_violations 3 TPASS: 1 open_writers violation(s) added
ima_mmap.c:41: TPASS: test completed
Summary:
passed 1 failed 0 broken 0 skipped 0
warnings 0ima_violations 4 TINFO: verify limiting single open writer violation ima_violations 4 TPASS: 1 open_writers violation(s) added ima_violations 5 TINFO: verify limiting multiple open writers violations ima_violations 5 TPASS: 1 open_writers violation(s) added ima_violations 6 TINFO: verify new open writer causes additional violation ima_violations 6 TPASS: 2 open_writers violation(s) added ima_violations 7 TINFO: verify limiting single open reader ToMToU violations ima_violations 7 TPASS: 1 ToMToU violation(s) addedima_violations 8 TINFO: verify new open reader causes additional ToMToU violation ima_violations 8 TPASS: 2 ToMToU violation(s) added
Summary:
passed 8 failed 0 broken 0 skipped 0
warnings 0
Mimi Zohar
maintainerRe: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 23 lines · Petr Vorel
Quoted 22 lines · Petr Vorel
Quoted 10 lines
Hi Mimi,
Quoted 6 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel patches.
Quoted 1 line
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with the IMA
TCB measurement policy or similar policy being loaded. Can you share the IMA policy? e.g. cat/sys/kernel/security/ima/policythanks,
Quoted 8 lines
Quoted 1 line
Mimi
Now testing on kernel *with* your patches. First run always fails, regardless whether using ima_policy=tcb or
/opt/ltp/testcases/data/ima_violations/violations.policy).Kind regards,
Petr
I'm not seeing that on my test machine. Could there be other things running on your
system causing violations. In anycase, your original test was less exacting. Similarly,
instead of "-eq", try using "-qe" in the following test and removing the subsequent new "gt" test.
if [ $(($num_violations_new - $num_violations)) -eq $expected_violations ]; then
Quoted 324 lines
First run fails:
# LTP_IMA_LOAD_POLICY=1 LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH"
ima_violations.sh
(policy is/opt/ltp/testcases/data/ima_violations/violations.policy)ima_violations1 TINFO: Running:ima_violations.shima_violations1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64x86_64x86_64GNU/Linuxima_violations1 TINFO: Using/tmp/LTP_ima_violations.XR34KhtnDMas tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations1 TINFO: Mounting device: mount -t ext3/dev/loop0/tmp/LTP_ima_violations.XR34KhtnDM/mntpointima_violations1 TINFO: timeout per run is 0h 5m 0sima_violations1 TINFO: IMA kernel config:ima_violations1 TINFO:CONFIG_IMA=yima_violations1 TINFO:CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations1 TINFO:CONFIG_IMA_LSM_RULES=yima_violations1 TINFO:CONFIG_IMA_NG_TEMPLATE=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations1 TINFO:CONFIG_IMA_READ_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE=yima_violations1 TINFO:CONFIG_IMA_ARCH_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_MODSIG=yima_violations1 TINFO:CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations1 TINFO:CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations1 TINFO:CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations1 TINFO:CONFIG_IMA_DISABLE_HTABLE=yima_violations1 TINFO:/proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102- default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmorignore_loglevelima_violations1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations1 TINFO: test requires IMA policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations1 TINFO: WARNING: missing required policy content: 'measure func=FILE_CHECK mask=^MAY_READ euid=0'ima_violations1 TINFO: trying to load '/opt/ltp/testcases/data/ima_violations/violations.policy' policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations1 TINFO: example policy successfully loadedima_violations1 TINFO: using log/var/log/audit/audit.logima_violations1 TINFO: verify open writers violationima_violations1 TFAIL:open_writerstoo many violations added: 2 - 0ima_violations2 TINFO: verify ToMToU violationima_violations2 TPASS: 1 ToMToU violation(s) addedima_violations3 TINFO: verifyopen_writersusing mmapped files tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_kconfig.c:676: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s ima_mmap.c:38: TINFO: sleep 3sima_violations3 TPASS: 1open_writersviolation(s) added
ima_mmap.c:41: TPASS: test completedSummary:
passed 1
failed 0
broken 0
skipped 0
warnings 0ima_violations4 TINFO: verify limiting single open writer violationima_violations4 TPASS: 1open_writersviolation(s) addedima_violations5 TINFO: verify limiting multiple open writers violationsima_violations5 TPASS: 1open_writersviolation(s) addedima_violations6 TINFO: verify new open writer causes additional violationima_violations6 TPASS: 2open_writersviolation(s) addedima_violations7 TINFO: verify limiting single open reader ToMToU violationsima_violations7 TPASS: 1 ToMToU violation(s) addedima_violations8 TINFO: verify new open reader causes additional ToMToU violationima_violations8 TPASS: 2 ToMToU violation(s) addedima_violations9 TINFO: WARNING: policy loaded via LTP_IMA_LOAD_POLICY=1, reboot recommendedSummary:
passed 7
failed 1
broken 0
skipped 0
warnings 0Second run is ok:
# LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH"ima_violations.shima_violations1 TINFO: Running:ima_violations.shima_violations1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64x86_64x86_64GNU/Linuxima_violations1 TINFO: Using/var/tmp/LTP_ima_violations.SWERFjvPTpas tmpdir (btrfs filesystem)ima_violations1 TINFO: timeout per run is 0h 5m 0sima_violations1 TINFO: IMA kernel config:ima_violations1 TINFO:CONFIG_IMA=yima_violations1 TINFO:CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations1 TINFO:CONFIG_IMA_LSM_RULES=yima_violations1 TINFO:CONFIG_IMA_NG_TEMPLATE=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations1 TINFO:CONFIG_IMA_READ_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE=yima_violations1 TINFO:CONFIG_IMA_ARCH_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_MODSIG=yima_violations1 TINFO:CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations1 TINFO:CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations1 TINFO:CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations1 TINFO:CONFIG_IMA_DISABLE_HTABLE=yima_violations1 TINFO:/proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102- default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmorignore_loglevelima_violations1 TINFO: test requires IMA policy:
measure func=FILE_CHECK mask=^MAY_READ euid=0
measure func=FILE_CHECK mask=^MAY_READ uid=0ima_violations1 TINFO: SUT has required policy contentima_violations1 TINFO: using log/var/log/audit/audit.logima_violations1 TINFO: verify open writers violationima_violations1 TPASS: 1open_writersviolation(s) addedima_violations2 TINFO: verify ToMToU violationima_violations2 TPASS: 1 ToMToU violation(s) addedima_violations3 TINFO: verifyopen_writersusing mmapped files tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_kconfig.c:676: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s ima_mmap.c:38: TINFO: sleep 3sima_violations3 TPASS: 1open_writersviolation(s) added
ima_mmap.c:41: TPASS: test completedSummary:
passed 1
failed 0
broken 0
skipped 0
warnings 0ima_violations4 TINFO: verify limiting single open writer violationima_violations4 TPASS: 1open_writersviolation(s) addedima_violations5 TINFO: verify limiting multiple open writers violationsima_violations5 TPASS: 1open_writersviolation(s) addedima_violations6 TINFO: verify new open writer causes additional violationima_violations6 TPASS: 2open_writersviolation(s) addedima_violations7 TINFO: verify limiting single open reader ToMToU violationsima_violations7 TPASS: 1 ToMToU violation(s) addedima_violations8 TINFO: verify new open reader causes additional ToMToU violationima_violations8 TPASS: 2 ToMToU violation(s) addedSummary:
passed 8
failed 0
broken 0
skipped 0
warnings 0Reboot and running with ima_policy=tcb also fails on the first time:
# LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH"
ima_violations.shtmpfs is skippedima_violations1 TINFO: Running:ima_violations.shima_violations1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64x86_64x86_64GNU/Linuxima_violations1 TINFO: Using/tmp/LTP_ima_violations.FKQSfezAwRas tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations1 TINFO: Mounting device: mount -t ext3/dev/loop0/tmp/LTP_ima_violations.FKQSfezAwR/mntpointima_violations1 TINFO: timeout per run is 0h 5m 0sima_violations1 TINFO: IMA kernel config:ima_violations1 TINFO:CONFIG_IMA=yima_violations1 TINFO:CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations1 TINFO:CONFIG_IMA_LSM_RULES=yima_violations1 TINFO:CONFIG_IMA_NG_TEMPLATE=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations1 TINFO:CONFIG_IMA_READ_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE=yima_violations1 TINFO:CONFIG_IMA_ARCH_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_MODSIG=yima_violations1 TINFO:CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations1 TINFO:CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations1 TINFO:CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations1 TINFO:CONFIG_IMA_DISABLE_HTABLE=yima_violations1 TINFO:/proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102- default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmorignore_loglevelima_policy=tcbima_violations1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations1 TINFO: booted with IMA policy: tcbima_violations1 TINFO: using log/var/log/audit/audit.logima_violations1 TINFO: verify open writers violationima_violations1 TFAIL:open_writerstoo many violations added: 3 - 1ima_violations2 TINFO: verify ToMToU violationima_violations2 TPASS: 1 ToMToU violation(s) addedima_violations3 TINFO: verifyopen_writersusing mmapped files tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_kconfig.c:676: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s ima_mmap.c:38: TINFO: sleep 3sima_violations3 TPASS: 1open_writersviolation(s) added
ima_mmap.c:41: TPASS: test completedSummary:
passed 1
failed 0
broken 0
skipped 0
warnings 0ima_violations4 TINFO: verify limiting single open writer violationima_violations4 TPASS: 1open_writersviolation(s) addedima_violations5 TINFO: verify limiting multiple open writers violationsima_violations5 TPASS: 1open_writersviolation(s) addedima_violations6 TINFO: verify new open writer causes additional violationima_violations6 TPASS: 2open_writersviolation(s) addedima_violations7 TINFO: verify limiting single open reader ToMToU violationsima_violations7 TPASS: 1 ToMToU violation(s) addedima_violations8 TINFO: verify new open reader causes additional ToMToU violationima_violations8 TPASS: 2 ToMToU violation(s) addedSummary:
passed 7
failed 1
broken 0
skipped 0
warnings 0Second and later run is again OK
# LTPROOT="/opt/ltp" PATH="/opt/ltp/testcases/bin:$PATH"ima_violations.shtmpfs is skippedima_violations1 TINFO: Running:ima_violations.shima_violations1 TINFO: Tested kernel: Linux ts 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64x86_64x86_64GNU/Linuxima_violations1 TINFO: Using/tmp/LTP_ima_violations.1Qf6qJuSooas tmpdir (tmpfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'ima_violations1 TINFO: Formatting ext3 with opts='/dev/loop0'ima_violations1 TINFO: Mounting device: mount -t ext3/dev/loop0/tmp/LTP_ima_violations.1Qf6qJuSoo/mntpointima_violations1 TINFO: timeout per run is 0h 5m 0sima_violations1 TINFO: IMA kernel config:ima_violations1 TINFO:CONFIG_IMA=yima_violations1 TINFO:CONFIG_IMA_MEASURE_PCR_IDX=10ima_violations1 TINFO:CONFIG_IMA_LSM_RULES=yima_violations1 TINFO:CONFIG_IMA_NG_TEMPLATE=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"ima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH_SHA256=yima_violations1 TINFO:CONFIG_IMA_DEFAULT_HASH="sha256"ima_violations1 TINFO:CONFIG_IMA_READ_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE=yima_violations1 TINFO:CONFIG_IMA_ARCH_POLICY=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_BOOTPARAM=yima_violations1 TINFO:CONFIG_IMA_APPRAISE_MODSIG=yima_violations1 TINFO:CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=yima_violations1 TINFO:CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=yima_violations1 TINFO:CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT=yima_violations1 TINFO:CONFIG_IMA_DISABLE_HTABLE=yima_violations1 TINFO:/proc/cmdline: BOOT_IMAGE=/boot/vmlinuz-6.14.0-rc3-1.gb6b4102- default root=UUID=e36b2366-1af2-4408-903c-1fca82c60f4c splash=silent video=1024x768 plymouth.ignore-serial-consoles console=ttyS0 console=tty kernel.softlockup_panic=1 resume=/dev/disk/by-uuid/c3b865f9-5d5b-410e-a6d1-9ebcf721584c mitigations=auto security=apparmorignore_loglevelima_policy=tcbima_violations1 TINFO: $TMPDIR is on tmpfs => run on loop deviceima_violations1 TINFO: booted with IMA policy: tcbima_violations1 TINFO: using log/var/log/audit/audit.logima_violations1 TINFO: verify open writers violationima_violations1 TPASS: 1open_writersviolation(s) addedima_violations2 TINFO: verify ToMToU violationima_violations2 TPASS: 1 ToMToU violation(s) addedima_violations3 TINFO: verifyopen_writersusing mmapped files tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f tst_test.c:1904: TINFO: Tested kernel: 6.14.0-rc3-1.gb6b4102-default #1 SMPPREEMPT_DYNAMICThu Feb 20 12:26:55 UTC 2025 (b6b4102)x86_64tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_kconfig.c:676: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution
tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s ima_mmap.c:38: TINFO: sleep 3sima_violations3 TPASS: 1open_writersviolation(s) added
ima_mmap.c:41: TPASS: test completedSummary:
passed 1
failed 0
broken 0
skipped 0
warnings 0ima_violations4 TINFO: verify limiting single open writer violationima_violations4 TPASS: 1open_writersviolation(s) addedima_violations5 TINFO: verify limiting multiple open writers violationsima_violations5 TPASS: 1open_writersviolation(s) addedima_violations6 TINFO: verify new open writer causes additional violationima_violations6 TPASS: 2open_writersviolation(s) addedima_violations7 TINFO: verify limiting single open reader ToMToU violationsima_violations7 TPASS: 1 ToMToU violation(s) addedima_violations8 TINFO: verify new open reader causes additional ToMToU violationima_violations8 TPASS: 2 ToMToU violation(s) addedSummary:
passed 8
failed 0
broken 0
skipped 0
warnings 0
Mimi Zohar
maintainerRe: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 32 lines · Mimi Zohar
Quoted 31 lines · Petr Vorel
Quoted 23 lines · Petr Vorel
Quoted 10 lines
Hi Mimi,
Quoted 6 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel patches.
Quoted 1 line
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with the IMA
TCB measurement policy or similar policy being loaded. Can you share the IMA policy?
e.g. cat/sys/kernel/security/ima/policyQuoted 3 lines
thanks,
Mimi
Now testing on kernel *with* your patches. First run always fails, regardless whether using ima_policy=tcb or
/opt/ltp/testcases/data/ima_violations/violations.policy).
Quoted 8 lines
Quoted 2 lines
Kind regards,
PetrI'm not seeing that on my test machine. Could there be other things running on your system causing violations. In anycase, your original test was less exacting. Similarly,
instead of "-eq", try using "-qe" in the following test and removing the subsequent new "gt" test.
-> "-ge"
Quoted 3 lines
if [ $(($num_violations_new - $num_violations)) -eq $expected_violations ]; then
Re: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 36 lines · Mimi Zohar
Quoted 34 lines · Petr Vorel
Quoted 33 lines
Quoted 23 lines · Petr Vorel
Quoted 10 lines
Hi Mimi,
Quoted 6 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel patches.
Quoted 1 line
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with the IMA
TCB measurement policy or similar policy being loaded. Can you share the IMA policy?
e.g. cat/sys/kernel/security/ima/policyQuoted 3 lines
thanks,
Mimi
Now testing on kernel *with* your patches. First run always fails, regardless whether using ima_policy=tcb or
/opt/ltp/testcases/data/ima_violations/violations.policy).Kind regards,
Petr
Quoted 7 lines
Quoted 5 lines
I'm not seeing that on my test machine. Could there be other things running on your system causing violations. In anycase, your original test was less exacting. Similarly,
instead of "-eq", try using "-qe" in the following test and removing the subsequent new "gt" test.-> "-ge"
Sure, changing to -ge fixes the problem:
if [ $(($num_violations_new - $num_violations)) -ge $expected_violations ]; then
I guess we need "-ge" for older kernels (unless "fix" for stable). Should we accept "$expected_violations || $expected_violations + 1" for new kernels to avoid problems like the one on my system.
I wonder if the problem was somehow caused by the fact that I built kernel. OTOH it's build by OBS (official openSUSE build service).
I don't expect you'd have time to look into it, in case you're interested and have time sending a links to rpm binary and src package.
https://download.opensuse.org/repositories/home:/pevik:/ima-limit-open-writers-ToMToU/standard/x86_64/kernel-default-6.14~rc3-1.1.gb6b4102.x86_64.rpm
https://download.opensuse.org/repositories/home:/pevik:/ima-limit-open-writers-ToMToU/standard/src/kernel-source-6.14~rc3-1.1.gb6b4102.src.rpm
Kind regards,
Petr
Quoted 1 line
Quoted 1 line
if [ $(($num_violations_new - $num_violations)) -eq $expected_violations ]; then
Mimi Zohar
maintainerRe: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 44 lines · Petr Vorel
Quoted 43 lines · Mimi Zohar
Quoted 42 lines · Petr Vorel
Quoted 26 lines
Quoted 25 lines · Petr Vorel
Quoted 10 lines
Hi Mimi,
Quoted 6 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel patches.
Quoted 1 line
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with the
IMA
TCB measurement policy or similar policy being loaded. Can you share the IMA policy?
e.g. cat/sys/kernel/security/ima/policythanks,
Quoted 8 lines
Quoted 1 line
Mimi
Now testing on kernel *with* your patches. First run always fails, regardless whether using ima_policy=tcb or
/opt/ltp/testcases/data/ima_violations/violations.policy).Kind regards,
PetrI'm not seeing that on my test machine. Could there be other things running on your system causing violations. In anycase, your original test was less exacting. Similarly,
instead of "-eq", try using "-qe" in the following test and removing the subsequent new
"gt" test.
Quoted 8 lines
Quoted 1 line
-> "-ge"
Sure, changing to -ge fixes the problem:
if [ $(($num_violations_new - $num_violations)) -ge $expected_violations ]; thenI guess we need "-ge" for older kernels (unless "fix" for stable). Should we accept "$expected_violations || $expected_violations + 1" for new kernels to avoid problems like the one on my system.
The problem is that we don't control what else is running on the system. So there could be other violations independent of these tests. I'll have to think about it some more and get back to you. (There's no rush to do anything with these LTP IMA violation tests.)
Quoted 3 lines
I wonder if the problem was somehow caused by the fact that I built kernel. OTOH it's build by OBS (official openSUSE build service).
As long as you weren't building the kernel and running the tests at the same, I doubt it would be the problem.
Quoted 3 lines
I don't expect you'd have time to look into it, in case you're interested and have time sending a links to rpm binary and src package.
Ok.
Quoted 4 lines
https://download.opensuse.org/repositories/home:/pevik:/ima-limit-open-writers-ToMToU/standard/x86_64/kernel-default-6.14~rc3-1.1.gb6b4102.x86_64.rpm
https://download.opensuse.org/repositories/home:/pevik:/ima-limit-open-writers-ToMToU/standard/src/kernel-source-6.14~rc3-1.1.gb6b4102.src.rpm
thanks,
Mimi
Re: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 50 lines · Petr Vorel
Quoted 48 lines
Quoted 37 lines · Mimi Zohar
Quoted 35 lines · Petr Vorel
Quoted 34 lines
Quoted 24 lines · Petr Vorel
Quoted 10 lines
Hi Mimi,
Quoted 6 lines
Kernel patch "ima: limit the number of ToMToU integrity violations" prevents superfluous ToMToU violations. Add corresponding LTP tests.
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel patches.
Quoted 1 line
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with the
IMA
TCB measurement policy or similar policy being loaded. Can you share the IMA policy?
e.g. cat/sys/kernel/security/ima/policyQuoted 3 lines
thanks,
Mimi
Now testing on kernel *with* your patches. First run always fails, regardless whether using ima_policy=tcb or
/opt/ltp/testcases/data/ima_violations/violations.policy).Kind regards,
PetrQuoted 8 lines
Quoted 6 lines
I'm not seeing that on my test machine. Could there be other things running on your system causing violations. In anycase, your original test was less exacting. Similarly,
instead of "-eq", try using "-qe" in the following test and removing the subsequent new
"gt" test.-> "-ge"
Sure, changing to -ge fixes the problem:
if [ $(($num_violations_new - $num_violations)) -ge $expected_violations ]; then
Quoted 7 lines
Quoted 3 lines
I guess we need "-ge" for older kernels (unless "fix" for stable). Should we accept "$expected_violations || $expected_violations + 1" for new kernels to avoid problems like the one on my system.
The problem is that we don't control what else is running on the system. So there could be other violations independent of these tests. I'll have to think about it some more and get back to you. (There's no rush to do anything with these LTP IMA violation tests.)
OK, thank you. The worse scenario would be to use less precise variant "-ge".
Quoted 5 lines
Quoted 2 lines
I wonder if the problem was somehow caused by the fact that I built kernel. OTOH it's build by OBS (official openSUSE build service).
As long as you weren't building the kernel and running the tests at the same, I doubt it would be the problem.
Understand, just something on openSUSE Tumbleweed system.
Kind regards,
Petr
Quoted 12 lines
Quoted 2 lines
I don't expect you'd have time to look into it, in case you're interested and have time sending a links to rpm binary and src package.
Ok.
Quoted 2 lines
https://download.opensuse.org/repositories/home:/pevik:/ima-limit-open-writers-ToMToU/standard/x86_64/kernel-default-6.14~rc3-1.1.gb6b4102.x86_64.rpm
https://download.opensuse.org/repositories/home:/pevik:/ima-limit-open-writers-ToMToU/standard/src/kernel-source-6.14~rc3-1.1.gb6b4102.src.rpmthanks,
Mimi
Mimi Zohar
maintainerRe: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 80 lines · Petr Vorel
Quoted 67 lines · Petr Vorel
Quoted 60 lines
Quoted 54 lines · Mimi Zohar
Quoted 43 lines · Petr Vorel
Quoted 34 lines
Quoted 30 lines · Petr Vorel
Quoted 7 lines
Hi Mimi,
Quoted 4 lines
Kernel patch "ima: limit the number of ToMToU integrity violations"
prevents superfluous ToMToU violations. Add corresponding LTP tests.Quoted 6 lines
Quoted 3 lines
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel
patches.Quoted 1 line
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with
the
IMA
TCB measurement policy or similar policy being loaded. Can you share the IMA
policy?
e.g. cat/sys/kernel/security/ima/policyQuoted 3 lines
thanks,
Mimi
Quoted 7 lines
Now testing on kernel *with* your patches. First run always fails, regardless
whether using ima_policy=tcb or/opt/ltp/testcases/data/ima_violations/violations.policy).Kind regards,
PetrQuoted 9 lines
I'm not seeing that on my test machine. Could there be other things running on your
system causing violations. In anycase, your original test was less exacting.
Similarly,
instead of "-eq", try using "-qe" in the following test and removing the subsequent
new
"gt" test.Quoted 1 line
-> "-ge"
Sure, changing to -ge fixes the problem:
if [ $(($num_violations_new - $num_violations)) -ge $expected_violations ]; thenQuoted 5 lines
I guess we need "-ge" for older kernels (unless "fix" for stable). Should we
accept "$expected_violations || $expected_violations + 1" for new kernels to
avoid problems like the one on my system.Quoted 6 lines
The problem is that we don't control what else is running on the system. So there could
be other violations independent of these tests. I'll have to think about it some more and
get back to you. (There's no rush to do anything with these LTP IMA violation tests.)OK, thank you. The worse scenario would be to use less precise variant "-ge".
Quoted 3 lines
Quoted 3 lines
I wonder if the problem was somehow caused by the fact that I built kernel. OTOH
it's build by OBS (official openSUSE build service).
Quoted 5 lines
Quoted 3 lines
As long as you weren't building the kernel and running the tests at the same, I doubt it
would be the problem.Understand, just something on openSUSE Tumbleweed system.
Peter, thank you for the tumbleweed image.
The default IMA tcb policy results is measuring $LOG (/var/log/audit/audit.log) on the first call to validate(). To prevent that from interfering with test1, I would add the following line or something similar in setup() to force measuring $LOG to happen earlier.
exec 3< $LOG || exit 1
Assuming that works, I'll update the kernel and LTP tests.
thanks,
Mimi
Re: [RFC PATCH 3/3] ima: additional ToMToU violation tests
Quoted 81 lines · Petr Vorel
Quoted 79 lines
Quoted 67 lines · Petr Vorel
Quoted 60 lines
Quoted 54 lines · Mimi Zohar
Quoted 43 lines · Petr Vorel
Quoted 34 lines
Quoted 30 lines · Petr Vorel
Quoted 7 lines
Hi Mimi,
Quoted 4 lines
Kernel patch "ima: limit the number of ToMToU integrity violations"
prevents superfluous ToMToU violations. Add corresponding LTP tests.Quoted 6 lines
Quoted 3 lines
Link:
https://lore.kernel.org/linux-integrity/[email protected]/Signed-off-by Mimi Zohar <[email protected]>Unfortunately tests fail on both mainline kernel and kernel with your patches.
The new LTP IMA violations patches should fail without the associated kernel
patches.Quoted 1 line
Any hint what could be wrong?
Of course it's dependent on the IMA policy. The tests assume being booted with
the
IMA
TCB measurement policy or similar policy being loaded. Can you share the IMA
policy?
e.g. cat/sys/kernel/security/ima/policyQuoted 3 lines
thanks,
Mimi
Quoted 7 lines
Now testing on kernel *with* your patches. First run always fails, regardless
whether using ima_policy=tcb or/opt/ltp/testcases/data/ima_violations/violations.policy).Kind regards,
PetrQuoted 9 lines
I'm not seeing that on my test machine. Could there be other things running on your
system causing violations. In anycase, your original test was less exacting.
Similarly,
instead of "-eq", try using "-qe" in the following test and removing the subsequent
new
"gt" test.Quoted 1 line
-> "-ge"
Sure, changing to -ge fixes the problem:
if [ $(($num_violations_new - $num_violations)) -ge $expected_violations ]; thenQuoted 5 lines
I guess we need "-ge" for older kernels (unless "fix" for stable). Should we
accept "$expected_violations || $expected_violations + 1" for new kernels to
avoid problems like the one on my system.Quoted 6 lines
The problem is that we don't control what else is running on the system. So there could
be other violations independent of these tests. I'll have to think about it some more and
get back to you. (There's no rush to do anything with these LTP IMA violation tests.)OK, thank you. The worse scenario would be to use less precise variant "-ge".
Quoted 3 lines
Quoted 3 lines
I wonder if the problem was somehow caused by the fact that I built kernel. OTOH
it's build by OBS (official openSUSE build service).
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
As long as you weren't building the kernel and running the tests at the same, I doubt it
would be the problem.Understand, just something on openSUSE Tumbleweed system.
Hi Mimi,
Quoted 1 line
Peter, thank you for the tumbleweed image.
Thanks for debugging on the image!
Quoted 4 lines
The default IMA tcb policy results is measuring $LOG (
/var/log/audit/audit.log) on the first call tovalidate(). To prevent that from interfering with test1, I would add the following line or something similar insetup()to force measuring $LOG to happen earlier.
+1
Quoted 1 line
exec 3< $LOG || exit 1
Ideally use:
exec 3< $LOG || tst_brk TBROK "some explanation..."
Quoted 1 line
Assuming that works, I'll update the kernel and LTP tests.
+1 (patch from you is preferred)
Kind regards,
Petr
Quoted 3 lines
thanks,
Mimi
Hi Mimi,
Quoted 13 lines
Add support for the number of expected violations. Include the expected number of violations in the output.
Signed-off-by Mimi Zohar <[email protected]>--- .../security/integrity/ima/tests/ima_violations.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)testcases/kernel/security/integrity/ima/tests/ima_violations.sh +0
-0
testcases/kernel/security/integrity/ima/tests/ima_violations.sh validate() · line 74
Quoted 4 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +1
-0@@ -71,20 +71,26 @@ validate() local num_violations="$1" local count="$2" local search="$3" + local expected_violations=$4
nit: safer to quote as much as possible (="$4") to avoid errors.
testcases/kernel/security/integrity/ima/tests/ima_violations.sh validate() · line 78
Quoted 4 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +1
-0local max_attempt=3 local count2 i num_violations_new + [ -z $expected_violations ] && expected_violations=1
Also here: -z "$expected_violations"
I can add quotes before merge if you don't want to bother (I would send you a diff to ack it before merging).
Quoted 6 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +2
-1+ for i in $(seq 1 $max_attempt); do read num_violations_new < $IMA_VIOLATIONS count2="$(get_count $search)" - if [ $(($num_violations_new - $num_violations)) -gt 0 ]; then + if [ $(($num_violations_new - $num_violations)) -eq $expected_violations ]; then
testcases/kernel/security/integrity/ima/tests/ima_violations.sh validate() · line 92
Quoted 10 lines
testcases/kernel/security/integrity/ima/tests/ima_violations.sh +3
-1if [ $count2 -gt $count ]; then - tst_res TPASS "$search violation added" + tst_res TPASS "$expected_violations $search violation(s) added" return else tst_res TINFO "$search not found in $LOG ($i/$max_attempt attempt)..." tst_sleep 1s fi + elif [ $(($num_violations_new - $num_violations)) -gt 0 ]; then + tst_res $IMA_FAIL "$search too many violations added"
nit: maybe print values for debugging?
tst_res $IMA_FAIL "$search too many violations added: $num_violations_new - $num_violations"
FYI failing tests has 2 or 3 higher:
ima_violations 1 TINFO: SUT has required policy contentima_violations 1 TINFO: using log /var/log/audit/audit.logima_violations 1 TINFO: verify open writers violationima_violations 1 TFAIL: open_writers too many violations added: 106 - 104ima_violations 2 TINFO: verify ToMToU violationima_violations 2 TFAIL: ToMToU too many violations added: 109 - 107ima_violations 3 TINFO: verify open_writers using mmapped files
tst_test.c:1900: TINFO: LTP version: 20250130-22-gcd2215702f
tst_test.c:1904: TINFO: Tested kernel: 6.13.0-2.g0127a37-default #1 SMP PREEMPT_DYNAMIC Thu Jan 23 11:21:55 UTC 2025 (0127a37) x86_64 tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
ima_mmap.c:38: TINFO: sleep 3sima_violations 3 TFAIL: open_writers too many violations added: 112 - 110
ima_mmap.c:41: TPASS: test completed
Summary:
passed 1 failed 0 broken 0 skipped 0
warnings 0ima_violations 4 TINFO: verify limiting single open writer violation ima_violations 4 TFAIL: open_writers too many violations added: 116 - 113 ima_violations 5 TINFO: verify limiting multiple open writers violations ima_violations 5 TFAIL: open_writers too many violations added: 121 - 117 ima_violations 6 TINFO: verify new open writer causes additional violation ima_violations 6 TFAIL: open_writers too many violations added: 126 - 122 ima_violations 7 TINFO: verify limiting single open reader ToMToU violations ima_violations 7 TFAIL: ToMToU too many violations added: 130 - 127 ima_violations 8 TINFO: verify new open reader causes additional ToMToU violation ima_violations 8 TFAIL: ToMToU too many violations added: 134 - 131
As I noted in previous mail, either has of a backport (can be added later, we don't have to wait for merging) or skip on older kernels (tst_kvcmp -lt ...).
Kind regards,
Petr