File: cil_constraint_statements.md

package info (click to toggle)
android-platform-external-libselinux 10.0.0%2Br36-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 34,176 kB
  • sloc: ansic: 147,112; python: 25,790; makefile: 1,930; yacc: 1,389; sh: 1,206; lex: 452; xml: 180
file content (313 lines) | stat: -rw-r--r-- 11,616 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
Constraint Statements
=====================

constrain
---------

Enable constraints to be placed on the specified permissions of the object class based on the source and target security context components.

**Statement definition:**

    (constrain classpermissionset_id ... expression | expr ...)

**Where:**

<table>
<colgroup>
<col width="27%" />
<col width="72%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><p><code>constrain</code></p></td>
<td align="left"><p>The <code>constrain</code> keyword.</p></td>
</tr>
<tr class="even">
<td align="left"><p><code>classpermissionset_id</code></p></td>
<td align="left"><p>A single named or anonymous <code>classpermissionset</code> or a single set of <code>classmap</code>/<code>classmapping</code> identifiers.</p></td>
</tr>
<tr class="odd">
<td align="left"><p><code>expression</code></p></td>
<td align="left"><p>There must be one constraint <code>expression</code> or one or more <code>expr</code>'s. The expression consists of an operator and two operands as follows:</p>
<p><code>    (op u1 u2)</code></p>
<p><code>    (role_op r1 r2)</code></p>
<p><code>    (op t1 t2)</code></p>
<p><code>    (op u1 user_id)</code></p>
<p><code>    (op u2 user_id)</code></p>
<p><code>    (op r1 role_id)</code></p>
<p><code>    (op r2 role_id)</code></p>
<p><code>    (op t1 type_id)</code></p>
<p><code>    (op t2 type_id)</code></p>
<p>where:</p>
<p><code>  u1, r1, t1 = Source context: user, role or type</code></p>
<p><code>  u2, r2, t2 = Target context: user, role or type</code></p>
<p>and:</p>
<p><code>  op      : eq neq</code></p>
<p><code>  role_op : eq neq dom domby incomp</code></p>
<p><code>  user_id : A single user or userattribute identifier.</code></p>
<p><code>  role_id : A single role or roleattribute identifier.</code></p>
<p><code>  type_id : A single type, typealias or typeattribute identifier.</code></p></td>
</tr>
<tr class="even">
<td align="left"><p><code>expr</code></p></td>
<td align="left"><p>Zero or more <code>expr</code>'s, the valid operators and syntax are:</p>
<p><code>    (and expression expression)</code></p>
<p><code>    (or  expression expression)</code></p>
<p><code>    (not expression)</code></p></td>
</tr>
</tbody>
</table>

**Examples:**

Two constrain statements are shown with their equivalent kernel policy language statements:

    ;; constrain { file } { write }
    ;;    (( t1 == unconfined.process  ) and ( t2 == unconfined.object  ) or ( r1 eq r2 ));
    (constrain (file (write))
        (or
            (and
                (eq t1 unconfined.process)
                (eq t2 unconfined.object)
            )
            (eq r1 r2)
        )
    )

    ;; constrain { file } { read }
    ;;    (not( t1 == unconfined.process  ) and ( t2 == unconfined.object  ) or ( r1 eq r2 ));
    (constrain (file (read))
        (not
            (or
                (and
                    (eq t1 unconfined.process)
                    (eq t2 unconfined.object)
                )
                (eq r1 r2)
            )
        )
    )

validatetrans
-------------

The [`validatetrans`](cil_constraint_statements.md#validatetrans) statement is only used for `file` related object classes where it is used to control the ability to change the objects security context based on old, new and the current process security context.

**Statement definition:**

    (validatetrans class_id expression | expr ...)

**Where:**

<table>
<colgroup>
<col width="25%" />
<col width="75%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><p><code>validatetrans</code></p></td>
<td align="left"><p>The <code>validatetrans</code> keyword.</p></td>
</tr>
<tr class="even">
<td align="left"><p><code>class_id</code></p></td>
<td align="left"><p>A single previously declared <code>class</code> or <code>classmap</code> identifier.</p></td>
</tr>
<tr class="odd">
<td align="left"><p><code>expression</code></p></td>
<td align="left"><p>There must be one constraint <code>expression</code> or one or more <code>expr</code>'s. The expression consists of an operator and two operands as follows:</p>
<p><code>    (op u1 u2)</code></p>
<p><code>    (role_op r1 r2)</code></p>
<p><code>    (op t1 t2)</code></p>
<p><code>    (op u1 user_id)</code></p>
<p><code>    (op u2 user_id)</code></p>
<p><code>    (op u3 user_id)</code></p>
<p><code>    (op r1 role_id)</code></p>
<p><code>    (op r2 role_id)</code></p>
<p><code>    (op r3 role_id)</code></p>
<p><code>    (op t1 type_id)</code></p>
<p><code>    (op t2 type_id)</code></p>
<p><code>    (op t3 type_id)</code></p>
<p>where:</p>
<p><code>  u1, r1, t1 = Old context: user, role or type</code></p>
<p><code>  u2, r2, t2 = New context: user, role or type</code></p>
<p><code>  u3, r3, t3 = Process context: user, role or type</code></p>
<p>and:</p>
<p><code>  op      : eq neq</code></p>
<p><code>  role_op : eq neq dom domby incomp</code></p>
<p><code>  user_id : A single user or userattribute identifier.</code></p>
<p><code>  role_id : A single role or roleattribute identifier.</code></p>
<p><code>  type_id : A single type, typealias or typeattribute identifier.</code></p></td>
</tr>
<tr class="even">
<td align="left"><p><code>expr</code></p></td>
<td align="left"><p>Zero or more <code>expr</code>'s, the valid operators and syntax are:</p>
<p><code>    (and expression expression)</code></p>
<p><code>    (or  expression expression)</code></p>
<p><code>    (not expression)</code></p></td>
</tr>
</tbody>
</table>

**Example:**

A validate transition statement with the equivalent kernel policy language statement:

    ; validatetrans { file } ( t1 == unconfined.process  );

    (validatetrans file (eq t1 unconfined.process))

mlsconstrain
------------

Enable MLS constraints to be placed on the specified permissions of the object class based on the source and target security context components.

**Statement definition:**

    (mlsconstrain classpermissionset_id ... expression | expr ...)

**Where:**

<table>
<colgroup>
<col width="27%" />
<col width="72%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><p><code>mlsconstrain</code></p></td>
<td align="left"><p>The <code>mlsconstrain</code> keyword.</p></td>
</tr>
<tr class="even">
<td align="left"><p><code>classpermissionset_id</code></p></td>
<td align="left"><p>A single named or anonymous <code>classpermissionset</code> or a single set of <code>classmap</code>/<code>classmapping</code> identifiers.</p></td>
</tr>
<tr class="odd">
<td align="left"><p><code>expression</code></p></td>
<td align="left"><p>There must be one constraint <code>expression</code> or one or more <code>expr</code>'s. The expression consists of an operator and two operands as follows:</p>
<p><code>    (op u1 u2)</code></p>
<p><code>    (mls_role_op r1 r2)</code></p>
<p><code>    (op t1 t2)</code></p>
<p><code>    (mls_role_op l1 l2)</code></p>
<p><code>    (mls_role_op l1 h2)</code></p>
<p><code>    (mls_role_op h1 l2)</code></p>
<p><code>    (mls_role_op h1 h2)</code></p>
<p><code>    (mls_role_op l1 h1)</code></p>
<p><code>    (mls_role_op l2 h2)</code></p>
<p><code>    (op u1 user_id)</code></p>
<p><code>    (op u2 user_id)</code></p>
<p><code>    (op r1 role_id)</code></p>
<p><code>    (op r2 role_id)</code></p>
<p><code>    (op t1 type_id)</code></p>
<p><code>    (op t2 type_id)</code></p>
<p>where:</p>
<p><code>  u1, r1, t1, l1, h1 = Source context: user, role, type, low level or high level</code></p>
<p><code>  u2, r2, t2, l2, h2 = Target context: user, role, type, low level or high level</code></p>
<p>and:</p>
<p><code>  op          : eq neq</code></p>
<p><code>  mls_role_op : eq neq dom domby incomp</code></p>
<p><code>  user_id     : A single user or userattribute identifier.</code></p>
<p><code>  role_id     : A single role or roleattribute identifier.</code></p>
<p><code>  type_id     : A single type, typealias or typeattribute identifier.</code></p></td>
</tr>
<tr class="even">
<td align="left"><p><code>expr</code></p></td>
<td align="left"><p>Zero or more <code>expr</code>'s, the valid operators and syntax are:</p>
<p><code>    (and expression expression)</code></p>
<p><code>    (or  expression expression)</code></p>
<p><code>    (not expression)</code></p></td>
</tr>
</tbody>
</table>

**Example:**

An MLS constrain statement with the equivalent kernel policy language statement:

    ;; mlsconstrain { file } { open }
    ;;     (( l1 eq l2 ) and ( u1 == u2 ) or ( r1 != r2 ));

    (mlsconstrain (file (open))
        (or
            (and
                (eq l1 l2)
                (eq u1 u2)
            )
            (neq r1 r2)
        )
    )

mlsvalidatetrans
----------------

The [`mlsvalidatetrans`](cil_constraint_statements.md#mlsvalidatetrans) statement is only used for `file` related object classes where it is used to control the ability to change the objects security context based on old, new and the current process security context.

**Statement definition:**

    (mlsvalidatetrans class_id expression | expr ...)

**Where:**

<table>
<colgroup>
<col width="25%" />
<col width="75%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><p><code>mlsvalidatetrans</code></p></td>
<td align="left"><p>The <code>mlsvalidatetrans</code> keyword.</p></td>
</tr>
<tr class="even">
<td align="left"><p><code>class_id</code></p></td>
<td align="left"><p>A single previously declared <code>class</code> or <code>classmap</code> identifier.</p></td>
</tr>
<tr class="odd">
<td align="left"><p><code>expression</code></p></td>
<td align="left"><p>There must be one constraint <code>expression</code> or one or more <code>expr</code>'s. The expression consists of an operator and two operands as follows:</p>
<p><code>    (op u1 u2)</code></p>
<p><code>    (mls_role_op r1 r2)</code></p>
<p><code>    (op t1 t2)</code></p>
<p><code>    (mls_role_op l1 l2)</code></p>
<p><code>    (mls_role_op l1 h2)</code></p>
<p><code>    (mls_role_op h1 l2)</code></p>
<p><code>    (mls_role_op h1 h2)</code></p>
<p><code>    (mls_role_op l1 h1)</code></p>
<p><code>    (mls_role_op l2 h2)</code></p>
<p><code>    (op u1 user_id)</code></p>
<p><code>    (op u2 user_id)</code></p>
<p><code>    (op u3 user_id)</code></p>
<p><code>    (op r1 role_id)</code></p>
<p><code>    (op r2 role_id)</code></p>
<p><code>    (op r3 role_id)</code></p>
<p><code>    (op t1 type_id)</code></p>
<p><code>    (op t2 type_id)</code></p>
<p><code>    (op t3 type_id)</code></p>
<p>where:</p>
<p><code>  u1, r1, t1, l1, h1 = Source context: user, role, type, low level or high level</code></p>
<p><code>  u2, r2, t2, l2, h2 = Target context: user, role, type, low level or high level</code></p>
<p><code>  u3, r3, t3         = Process context: user, role or type</code></p>
<p>and:</p>
<p><code>  op          : eq neq</code></p>
<p><code>  mls_role_op : eq neq dom domby incomp</code></p>
<p><code>  user_id     : A single user or userattribute identifier.</code></p>
<p><code>  role_id     : A single role or roleattribute identifier.</code></p>
<p><code>  type_id     : A single type, typealias or typeattribute identifier.</code></p></td>
</tr>
<tr class="even">
<td align="left"><p><code>expr</code></p></td>
<td align="left"><p>Zero or more <code>expr</code>'s, the valid operators and syntax are:</p>
<p><code>    (and expression expression)</code></p>
<p><code>    (or  expression expression)</code></p>
<p><code>    (not expression)</code></p></td>
</tr>
</tbody>
</table>

**Example:**

An MLS validate transition statement with the equivalent kernel policy language statement:

    ;; mlsvalidatetrans { file } ( l1 domby h2 );

    (mlsvalidatetrans file (domby l1 h2))