selinux/secilc/docs/cil_access_vector_rules.md
Yuli Khodorkovskiy 12c7dfc553 secilc/docs: Convert DocBook documentation into github markdown
Converting to github markdown allows for easier integration with the
SELinux project wiki and viewing of documentation directly on github without
creating PDFs or reading through DocBook XML.

The conversion of DocBook to github markdown would not format tables or
keyword links properly. By maintaining the documentation in github
markdown in the repository, the content is well formatted with a table of
contents when viewing in the github wiki or in the repository.

The migration from DocBook to github markdown was done using Pandoc and
manual fixups. Mappings of CIL keywords to headings that were lost in the DocBook
conversion were added back. An introduction and design philosphy was
also pulled from the SELinux project wiki to provide more cohesion
to the current documentation.

Running make will now convert the github markdown into PDF and HTML.

Signed-off-by: Yuli Khodorkovskiy <ykhodorkovskiy@tresys.com>
2015-12-15 16:18:34 -05:00

15 KiB

Access Vector Rules

allow

Specifies the access allowed between a source and target type. Note that access may be refined by constraint rules based on the source, target and class (validatetrans or mlsvalidatetrans) or source, target class and permissions (constrain or mlsconstrain statements).

Rule definition:

(allow source_id target_id|self classpermissionset_id ...)

Where:

allow

The allow keyword.

source_id

A single previously defined source type, typealias or typeattribute identifier.

target_id

A single previously defined target type, typealias or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

classpermissionset_id

A single named or anonymous classpermissionset or a single set of classmap/classmapping identifiers.

Examples:

These examples show a selection of possible permutations of allow rules:

(class binder (impersonate call set_context_mgr transfer receive))
(class property_service (set))
(class zygote (specifyids specifyrlimits specifycapabilities specifyinvokewith specifyseinfo))

(classpermission cps_zygote)
(classpermissionset cps_zygote (zygote (not (specifyids))))

(classmap android_classes (set_1 set_2 set_3))

(classmapping android_classes set_1 (binder (all)))
(classmapping android_classes set_1 (property_service (set)))
(classmapping android_classes set_1 (zygote (not (specifycapabilities))))

(classmapping android_classes set_2 (binder (impersonate call set_context_mgr transfer)))
(classmapping android_classes set_2 (zygote (specifyids specifyrlimits specifycapabilities specifyinvokewith)))

(classmapping android_classes set_3 cps_zygote)
(classmapping android_classes set_3 (binder (impersonate call set_context_mgr)))

(block av_rules
    (type type_1)
    (type type_2)
    (type type_3)
    (type type_4)
    (type type_5)

    (typeattribute all_types)
    (typeattributeset all_types (all))

; These examples have named and anonymous classpermissionset's and
; classmap/classmapping statements
    (allow type_1 self (property_service (set)))          ; anonymous
    (allow type_2 self (zygote (specifyids)))             ; anonymous
    (allow type_3 self cps_zygote)                        ; named
    (allow type_4 self (android_classes (set_3)))         ; classmap/classmapping
    (allow all_types all_types (android_classes (set_2))) ; classmap/classmapping

;; This rule will cause the build to fail unless --disable-neverallow
;    (neverallow type_5 all_types (property_service (set)))
    (allow type_5 type_5 (property_service (set)))
    (allow type_1 all_types (property_service (set)))
)

auditallow

Audit the access rights defined if there is a valid allow rule. Note: It does NOT allow access, it only audits the event.

Rule definition:

(auditallow source_id target_id|self classpermissionset_id ...)

Where:

auditallow

The auditallow keyword.

source_id

A single previously defined source type, typealias or typeattribute identifier.

target_id

A single previously defined target type, typealias or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

classpermissionset_id

A single named or anonymous classpermissionset or a single set of classmap/classmapping identifiers.

Example:

This example will log an audit event whenever the corresponding allow rule grants access to the specified permissions:

(allow release_app.process secmark_demo.browser_packet (packet (send recv append bind)))

(auditallow release_app.process secmark_demo.browser_packet (packet (send recv)))

dontaudit

Do not audit the access rights defined when access denied. This stops excessive log entries for known events.

Note that these rules can be omitted by the CIL compiler command line parameter -D or --disable-dontaudit flags.

Rule definition:

(dontaudit source_id target_id|self classpermissionset_id ...)

Where:

dontaudit

The dontaudit keyword.

source_id

A single previously defined source type, typealias or typeattribute identifier.

target_id

A single previously defined target type, typealias or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

classpermissionset_id

A single named or anonymous classpermissionset or a single set of classmap/classmapping identifiers.

Example:

This example will not audit the denied access:

(dontaudit zygote.process self (capability (fsetid)))

neverallow

Never allow access rights defined. This is a compiler enforced action that will stop compilation until the offending rules are modified.

Note that these rules can be over-ridden by the CIL compiler command line parameter -N or --disable-neverallow flags.

Rule definition:

(neverallow source_id target_id|self classpermissionset_id ...)

Where:

neverallow

The neverallow keyword.

source_id

A single previously defined source type, typealias or typeattribute identifier.

target_id

A single previously defined target type, typealias or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

classpermissionset_id

A single named or anonymous classpermissionset or a single set of classmap/classmapping identifiers.

Example:

This example will not compile as type_3 is not allowed to be a source type for the allow rule:

(class property_service (set))

(block av_rules
    (type type_1)
    (type type_2)
    (type type_3)
    (typeattribute all_types)
    (typeattributeset all_types ((all)))

    (neverallow type_3 all_types (property_service (set)))
    ; This rule will fail compilation:
    (allow type_3 self (property_service (set)))
)

allowx

Specifies the access allowed between a source and target type using extended permissions. Unlike the allow statement, the statements validatetrans, mlsvalidatetrans, constrain, and mlsconstrain do not limit accesses granted by allowx.

Rule definition:

(allowx source_id target_id|self permissionx_id)

Where:

allowx

The allowx keyword.

source_id

A single previously defined source type, typealias, or typeattribute identifier.

target_id

A single previously defined target type, typealias, or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

permissionx_id

A single named or anonymous permissionx.

Examples:

These examples show a selection of possible permutations of allowx rules:

(allowx type_1 type_2 (ioctl tcp_socket (range 0x2000 0x20FF)))

(permissionx ioctl_nodebug (ioctl udp_socket (not (range 0x4000 0x4010))))
(allowx type_3 type_4 ioctl_nodebug)

auditallowx

Audit the access rights defined if there is a valid allowx rule. It does NOT allow access, it only audits the event.

Rule definition:

(auditallowx source_id target_id|self permissionx_id)

Where:

auditallowx

The auditallowx keyword.

source_id

A single previously defined source type, typealias or typeattribute identifier.

target_id

A single previously defined target type, typealias or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

permissionx_id

A single named or anonymous permissionx.

Examples:

This example will log an audit event whenever the corresponding allowx rule grants access to the specified extended permissions:

(allowx type_1 type_2 (ioctl tcp_socket (range 0x2000 0x20FF)))

(auditallowx type_1 type_2 (ioctl tcp_socket (range 0x2005 0x2010)))

dontauditx

Do not audit the access rights defined when access denied. This stops excessive log entries for known events.

Note that these rules can be omitted by the CIL compiler command line parameter -D or --disable-dontaudit flags.

Rule definition:

(dontauditx source_id target_id|self permissionx_id)

Where:

dontauditx

The dontauditx keyword.

source_id

A single previously defined source type, typealias or typeattribute identifier.

target_id

A single previously defined target type, typealias or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

permissionx_id

A single named or anonymous permissionx.

Examples:

This example will not audit the denied access:

(dontauditx type_1 type_2 (ioctl tcp_socket (range 0x3000 0x30FF)))

neverallowx

Never allow access rights defined for extended permissions. This is a compiler enforced action that will stop compilation until the offending rules are modified.

Note that these rules can be over-ridden by the CIL compiler command line parameter -N or --disable-neverallow flags.

Rule definition:

(neverallowx source_id target_id|self permissionx_id)

Where:

neverallows

The neverallowx keyword.

source_id

A single previously defined source type, typealias or typeattribute identifier.

target_id

A single previously defined target type, typealias or typeattribute identifier.

The self keyword may be used instead to signify that source and target are the same.

permissionx_id

A single named or anonymous permissionx.

Examples:

This example will not compile as type_3 is not allowed to be a source type and ioctl range for the allowx rule:

(class property_service (ioctl))
(block av_rules
	(type type_1)
	(type type_2)
	(type type_3)
	(typeattribute all_types)
	(typeattributeset all_types ((all)))
	(neverallowx type_3 all_types (ioctl property_service (range 0x2000 0x20FF)))
	; This rule will fail compilation:
	(allowx type_3 self (ioctl property_service (0x20A0)))
)