aboutsummaryrefslogtreecommitdiffstats
path: root/tools/sepolicy-analyze.c
Commit message (Collapse)AuthorAgeFilesLines
* Add permissive domains check to sepolicy-analyze.dcashman2014-08-221-4/+28
| | | | | | | Also enable global reading of kernel policy file. Motivation for this is to allow read access to the kernel version of the binary selinux policy. Change-Id: I1eefb457cea1164a8aa9eeb7683b3d99ee56ca99
* Refine sepolicy-analyze -D / dup detection.Stephen Smalley2014-06-171-4/+25
| | | | | | | | | | We were incorrectly reporting overlapping rules as duplicates. Only report cases where an attribute-based rule is a superset of type-based rule. Also omit self rules as they are often due to expansion of domain self rules by checkpolicy. Change-Id: I27f33cdf9467be5fdb6ce148aa0006d407291833 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* Add support for duplicate allow rule detection (-D / --dups).Stephen Smalley2013-11-181-18/+79
| | | | | | | | | | | | | | | | | | | | | Usage: sepolicy-analyze -D -P out/target/product/<board>/root/sepolicy Displays duplicate allow rules, i.e. pairs of allow rules that grant the same permissions where one allow rule is written directly in terms of individual types and the other is written in terms of attributes associated with those same types. The rule with individual types is a candidate for removal. The rule with individual types may be directly represented in the source policy or may be a result of expansion of a type negation (e.g. domain -foo -bar is expanded to individual allow rules by the policy compiler). Domains with unconfineddomain will typically have such duplicate rules as a natural side effect and can be ignored. Also add a tools/README with a description of all of the tools. Change-Id: I07838dbd22c5cc8a4a65b57003ccae38129050f5 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
* Add sepolicy-analyze tool.Stephen Smalley2013-10-311-0/+379
And also remove the unnecessary references to libselinux for sepolicy-check, as it has no dependencies on libselinux. Also enable -Wall -Werror on building all of these tools and fix up all such errors. Usage: $ sepolicy-analyze -e -P out/target/product/<device>/root/sepolicy or $ sepolicy-analyze -d -P out/target/product/<device>/root/sepolicy The first form will display all type pairs that are "equivalent", i.e. they are identical with respect to allow rules, including indirect allow rules via attributes and default-enabled conditional rules (i.e. default boolean values yield a true conditional expression). Equivalent types are candidates for being coalesced into a single type. However, there may be legitimate reasons for them to remain separate, for example: - the types may differ in a respect not included in the current analysis, such as default-disabled conditional rules, audit-related rules (auditallow or dontaudit), default type transitions, or constraints (e.g. mls), or - the current policy may be overly permissive with respect to one or the other of the types and thus the correct action may be to tighten access to one or the other rather than coalescing them together, or - the domains that would in fact have different accesses to the types may not yet be defined or may be unconfined in the policy you are analyzing (e.g. in AOSP policy). The second form will display type pairs that differ and the first difference found between the two types. This output can be long. We have plans to explore further enhancements to this tool, including support for identifying isomorphic types. That will be required to identify similar domains since all domains differ in at least their entrypoint type and in their tmpfs type and thus will never show up as equivalent even if they are in all other respects identical to each other. Change-Id: If0ee00188469d2a1e165fdd52f235c705d22cd4e Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>