[PATCH 0/2] checkpolicy: extend bad-data and robustness tests
Akhil Kohli <[email protected]> Mon, 27 Jul 2026 17:25:15 +0200
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <[email protected]> |
This is a follow-up to the checkmodule bad-data harness already merged: checkpolicy: add bad data protection tests https://lore.kernel.org/selinux/[email protected]/ Patch 1 adds negative .te fixtures for duplicate type/attribute declarations, type/attribute name conflicts, invalid type names, and malformed role/user stanzas. It also runs the negative suite as non-root in CI so the unreadable .te case is exercised (root can still read mode 000 files). Patch 2 adds expect_robust coverage for oversized generated .te/.conf inputs and a large attribute membership set, with tunable sizes. It also fixes expect_* helpers to return 0 after counting a failure so set -e does not abort the suite early; the script exit status is still non-zero when FAIL != 0. Together these bring the harness from 16 to 25 tests (1 positive + 21 negative + 3 robust). Tested with: cd checkpolicy make checkmodule checkpolicy LIBSEPOLA=../libsepol/src/libsepol.a \ CPPFLAGS='-I../libsepol/include' make test LIBSEPOLA=../libsepol/src/libsepol.a \ CPPFLAGS='-I../libsepol/include' Result: roundtrip tests pass; checkmodule negative tests: 25 passed, 0 failed. Akhil Kohli (2): checkpolicy: extend bad-data tests for type, role, and user errors checkpolicy: add robustness tests for large policy inputs .github/workflows/run_tests.yml | 11 ++ checkpolicy/tests/negative/bad_role.te | 12 ++ checkpolicy/tests/negative/bad_user.te | 3 + checkpolicy/tests/negative/dup_attribute.te | 13 ++ checkpolicy/tests/negative/dup_type.te | 11 ++ .../tests/negative/invalid_type_name.te | 9 + .../tests/negative/type_attr_conflict.te | 10 + .../tests/test_checkmodule_negative.sh | 187 +++++++++++++++++- 8 files changed, 248 insertions(+), 8 deletions(-) create mode 100644 checkpolicy/tests/negative/bad_role.te create mode 100644 checkpolicy/tests/negative/bad_user.te create mode 100644 checkpolicy/tests/negative/dup_attribute.te create mode 100644 checkpolicy/tests/negative/dup_type.te create mode 100644 checkpolicy/tests/negative/invalid_type_name.te create mode 100644 checkpolicy/tests/negative/type_attr_conflict.te -- 2.55.0