1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
2 |
<html lang="en-US"> |
3 |
<head> |
4 |
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
5 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
6 |
<title>Policy Specifications of TOMOYO Linux</title> |
7 |
<link rel="stylesheet" href="http://tomoyo.sourceforge.jp/tomoyo.css" media="all" type="text/css"> |
8 |
</head> |
9 |
<body> |
10 |
<p style="text-align:right;"><a href="policy-reference.html.ja">Japanese Page</a></p> |
11 |
<p style="text-align:right;">Last modified: $Date$</p> |
12 |
<h1 style="text-align:center;">Policy Specifications of TOMOYO Linux</h1> |
13 |
<h1><a name="index">Index</a></h1> |
14 |
<h2>1. <a href="#Keyword_Index">Keywords Index</a></h2> |
15 |
<h2>2. <a href="#Common_Rules">Introduction</a></h2> |
16 |
<p>2.1 <a href="#word_expression_rules">Word Expression Rules</a></p> |
17 |
<p>2.2 <a href="#wildcard_expression_rules">Wildcard Expression Rules</a></p> |
18 |
<p>2.3 <a href="#memory_usage_infomation">Memory Usage Information</a></p> |
19 |
<h2>3. <a href="#Policy_Files">Policy Files</a></h2> |
20 |
<p>3.1 <a href="#policy_file_locations">Policy File's Location</a></p> |
21 |
<p>3.2 <a href="#policy_file_modifiers">Policy File's Modification</a></p> |
22 |
<h2>4. <a href="#Domain_Rules">Domain Rules</a></h2> |
23 |
<p>4.1 <a href="#domain_definition">Domain Definition</a></p> |
24 |
<p>4.2 <a href="#domain_transition">Domain Transition</a></p> |
25 |
<p>4.3 <a href="#access_logs">Access Logs</a></p> |
26 |
<h2>5. <a href="#Syntax_Details">Syntax Details</a></h2> |
27 |
<h2>6. <a href="#Advanced_Features">Advanced Features</a></h2> |
28 |
<p>6.1 <a href="#non_root_policy_update">Allowing policy modification by non root user.</a></p> |
29 |
<p>6.2 <a href="#conditional_acl">Using conditional ACL.</a></p> |
30 |
<p>6.3 <a href="#transit_on_match">Domain transition upon ACL match.</a></p> |
31 |
<p>6.4 <a href="#sleep_penalty">Sleep penalty for policy violation.</a></p> |
32 |
<p>6.5 <a href="#auto_execute_handler">Judging execute request outside the kernel.</a></p> |
33 |
<p>6.6 <a href="#denied_execute_handler">Invoking alternative program for execute requests that are not permitted by policy.</a></p> |
34 |
<hr> |
35 |
|
36 |
<h1>1. <a name="Keyword_Index">Keywords Index</a></h1> |
37 |
|
38 |
<p>Used by /proc/ccs/profile and /etc/ccs/profile.conf</p> |
39 |
|
40 |
<ul> |
41 |
<li><a href="#profile_CONFIG::file::execute">CONFIG::file::execute</a></li> |
42 |
<li><a href="#profile_CONFIG::file::open">CONFIG::file::open</a></li> |
43 |
<li><a href="#profile_CONFIG::file::create">CONFIG::file::create</a></li> |
44 |
<li><a href="#profile_CONFIG::file::unlink">CONFIG::file::unlink</a></li> |
45 |
<li><a href="#profile_CONFIG::file::mkdir">CONFIG::file::mkdir</a></li> |
46 |
<li><a href="#profile_CONFIG::file::rmdir">CONFIG::file::rmdir</a></li> |
47 |
<li><a href="#profile_CONFIG::file::mkfifo">CONFIG::file::mkfifo</a></li> |
48 |
<li><a href="#profile_CONFIG::file::mksock">CONFIG::file::mksock</a></li> |
49 |
<li><a href="#profile_CONFIG::file::truncate">CONFIG::file::truncate</a></li> |
50 |
<li><a href="#profile_CONFIG::file::symlink">CONFIG::file::symlink</a></li> |
51 |
<li><a href="#profile_CONFIG::file::rewrite">CONFIG::file::rewrite</a></li> |
52 |
<li><a href="#profile_CONFIG::file::mkblock">CONFIG::file::mkblock</a></li> |
53 |
<li><a href="#profile_CONFIG::file::mkchar">CONFIG::file::mkchar</a></li> |
54 |
<li><a href="#profile_CONFIG::file::link">CONFIG::file::link</a></li> |
55 |
<li><a href="#profile_CONFIG::file::rename">CONFIG::file::rename</a></li> |
56 |
<li><a href="#profile_CONFIG::file::chmod">CONFIG::file::chmod</a></li> |
57 |
<li><a href="#profile_CONFIG::file::chown">CONFIG::file::chown</a></li> |
58 |
<li><a href="#profile_CONFIG::file::chgrp">CONFIG::file::chgrp</a></li> |
59 |
<li><a href="#profile_CONFIG::file::ioctl">CONFIG::file::ioctl</a></li> |
60 |
<li><a href="#profile_CONFIG::file::chroot">CONFIG::file::chroot</a></li> |
61 |
<li><a href="#profile_CONFIG::file::mount">CONFIG::file::mount</a></li> |
62 |
<li><a href="#profile_CONFIG::file::unmount">CONFIG::file::unmount</a></li> |
63 |
<li><a href="#profile_CONFIG::file::pivot_root">CONFIG::file::pivot_root</a></li> |
64 |
<li><a href="#profile_CONFIG::misc::env">CONFIG::misc::env</a></li> |
65 |
<li><a href="#profile_CONFIG::capability::use_route">CONFIG::capability::use_route</a></li> |
66 |
<li><a href="#profile_CONFIG::capability::use_packet">CONFIG::capability::use_packet</a></li> |
67 |
<li><a href="#profile_CONFIG::capability::use_kernel_module">CONFIG::capability::use_kernel_module</a></li> |
68 |
<li><a href="#profile_CONFIG::capability::SYS_REBOOT">CONFIG::capability::SYS_REBOOT</a></li> |
69 |
<li><a href="#profile_CONFIG::capability::SYS_VHANGUP">CONFIG::capability::SYS_VHANGUP</a></li> |
70 |
<li><a href="#profile_CONFIG::capability::SYS_TIME">CONFIG::capability::SYS_TIME</a></li> |
71 |
<li><a href="#profile_CONFIG::capability::SYS_NICE">CONFIG::capability::SYS_NICE</a></li> |
72 |
<li><a href="#profile_CONFIG::capability::SYS_SETHOSTNAME">CONFIG::capability::SYS_SETHOSTNAME</a></li> |
73 |
<li><a href="#profile_CONFIG::capability::SYS_KEXEC_LOAD">CONFIG::capability::SYS_KEXEC_LOAD</a></li> |
74 |
<li><a href="#profile_CONFIG::capability::SYS_PTRACE">CONFIG::capability::SYS_PTRACE</a></li> |
75 |
<li><a href="#profile_CONFIG::network::inet_dgram_bind">CONFIG::network::inet_dgram_bind</a></li> |
76 |
<li><a href="#profile_CONFIG::network::inet_dgram_send">CONFIG::network::inet_dgram_send</a></li> |
77 |
<li><a href="#profile_CONFIG::network::inet_dgram_recv">CONFIG::network::inet_dgram_recv</a></li> |
78 |
<li><a href="#profile_CONFIG::network::inet_stream_bind">CONFIG::network::inet_stream_bind</a></li> |
79 |
<li><a href="#profile_CONFIG::network::inet_stream_listen">CONFIG::network::inet_stream_listen</a></li> |
80 |
<li><a href="#profile_CONFIG::network::inet_stream_connect">CONFIG::network::inet_stream_connect</a></li> |
81 |
<li><a href="#profile_CONFIG::network::inet_stream_accept">CONFIG::network::inet_stream_accept</a></li> |
82 |
<li><a href="#profile_CONFIG::network::inet_raw_bind">CONFIG::network::inet_raw_bind</a></li> |
83 |
<li><a href="#profile_CONFIG::network::inet_raw_send">CONFIG::network::inet_raw_send</a></li> |
84 |
<li><a href="#profile_CONFIG::network::inet_raw_recv">CONFIG::network::inet_raw_recv</a></li> |
85 |
<li><a href="#profile_CONFIG::network::unix_dgram_bind">CONFIG::network::unix_dgram_bind</a></li> |
86 |
<li><a href="#profile_CONFIG::network::unix_dgram_send">CONFIG::network::unix_dgram_send</a></li> |
87 |
<li><a href="#profile_CONFIG::network::unix_dgram_recv">CONFIG::network::unix_dgram_recv</a></li> |
88 |
<li><a href="#profile_CONFIG::network::unix_stream_bind">CONFIG::network::unix_stream_bind</a></li> |
89 |
<li><a href="#profile_CONFIG::network::unix_stream_listen">CONFIG::network::unix_stream_listen</a></li> |
90 |
<li><a href="#profile_CONFIG::network::unix_stream_connect">CONFIG::network::unix_stream_connect</a></li> |
91 |
<li><a href="#profile_CONFIG::network::unix_stream_accept">CONFIG::network::unix_stream_accept</a></li> |
92 |
<li><a href="#profile_CONFIG::network::unix_seqpacket_bind">CONFIG::network::unix_seqpacket_bind</a></li> |
93 |
<li><a href="#profile_CONFIG::network::unix_seqpacket_listen">CONFIG::network::unix_seqpacket_listen</a></li> |
94 |
<li><a href="#profile_CONFIG::network::unix_seqpacket_connect">CONFIG::network::unix_seqpacket_connect</a></li> |
95 |
<li><a href="#profile_CONFIG::network::unix_seqpacket_accept">CONFIG::network::unix_seqpacket_accept</a></li> |
96 |
<li><a href="#profile_CONFIG::ipc::signal">CONFIG::ipc::signal</a></li> |
97 |
<li><a href="#profile_PREFERENCE">PREFERENCE</a></li> |
98 |
</ul> |
99 |
|
100 |
<p>Used by /proc/ccs/exception_policy and /etc/ccs/exception_policy.conf</p> |
101 |
|
102 |
<ul> |
103 |
<li><a href="#exception_policy_acl_group">acl_group</a></li> |
104 |
<li><a href="#exception_policy_aggregator">aggregator</a></li> |
105 |
<li><a href="#exception_policy_initialize_domain">initialize_domain</a></li> |
106 |
<li><a href="#exception_policy_no_initialize_domain">no_initialize_domain</a></li> |
107 |
<li><a href="#exception_policy_keep_domain">keep_domain</a></li> |
108 |
<li><a href="#exception_policy_no_keep_domain">no_keep_domain</a></li> |
109 |
<li><a href="#exception_policy_path_group">path_group</a></li> |
110 |
<li><a href="#exception_policy_number_group">number_group</a></li> |
111 |
<li><a href="#exception_policy_address_group">address_group</a></li> |
112 |
<li><a href="#exception_policy_deny_autobind">deny_autobind</a></li> |
113 |
</ul> |
114 |
|
115 |
<p>Used by /proc/ccs/domain_policy and /etc/ccs/domain_policy.conf</p> |
116 |
|
117 |
<ul> |
118 |
<li><a href="#domain_policy_file_execute">file execute</a></li> |
119 |
<li><a href="#domain_policy_file_read">file read</a></li> |
120 |
<li><a href="#domain_policy_file_write">file write</a></li> |
121 |
<li><a href="#domain_policy_file_append">file append</a></li> |
122 |
<li><a href="#domain_policy_file_create">file create</a></li> |
123 |
<li><a href="#domain_policy_file_unlink">file unlink</a></li> |
124 |
<li><a href="#domain_policy_file_mkdir">file mkdir</a></li> |
125 |
<li><a href="#domain_policy_file_rmdir">file rmdir</a></li> |
126 |
<li><a href="#domain_policy_file_mkfifo">file mkfifo</a></li> |
127 |
<li><a href="#domain_policy_file_mksock">file mksock</a></li> |
128 |
<li><a href="#domain_policy_file_mkblock">file mkblock</a></li> |
129 |
<li><a href="#domain_policy_file_mkchar">file mkchar</a></li> |
130 |
<li><a href="#domain_policy_file_truncate">file truncate</a></li> |
131 |
<li><a href="#domain_policy_file_symlink">file symlink</a></li> |
132 |
<li><a href="#domain_policy_file_link">file link</a></li> |
133 |
<li><a href="#domain_policy_file_rename">file rename</a></li> |
134 |
<li><a href="#domain_policy_file_ioctl">file ioctl</a></li> |
135 |
<li><a href="#domain_policy_file_mount">file mount</a></li> |
136 |
<li><a href="#domain_policy_file_unmount">file unmount</a></li> |
137 |
<li><a href="#domain_policy_file_chroot">file chroot</a></li> |
138 |
<li><a href="#domain_policy_file_pivot_root">file pivot_root</a></li> |
139 |
<li><a href="#domain_policy_misc_env">misc env</a></li> |
140 |
<li><a href="#domain_policy_network">network</a></li> |
141 |
<li><a href="#domain_policy_capability">capability</a></li> |
142 |
<li><a href="#domain_policy_ipc_signal">ipc signal</a></li> |
143 |
<li><a href="#domain_policy_use_profile">use_profile</a></li> |
144 |
<li><a href="#domain_policy_use_group">use_group</a></li> |
145 |
<li><a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a></li> |
146 |
<li><a href="#domain_policy_task_denied_execute_handler">task denied_execute_handler</a></li> |
147 |
<li><a href="#domain_policy_quota_exceeded">quota_exceeded</a></li> |
148 |
<li><a href="#domain_policy_transition_failed">transition_failed</a></li> |
149 |
</ul> |
150 |
|
151 |
<p>Used by /proc/ccs/manager and /etc/ccs/manager.conf</p> |
152 |
|
153 |
<ul> |
154 |
<li><a href="#manager_manage_by_non_root">manage_by_non_root</a></li> |
155 |
</ul> |
156 |
|
157 |
<h1>2. <a name="Common_Rules">Introduction</a></h1> |
158 |
|
159 |
<h2>2.1 <a name="word_expression_rules">Word Expression Rules</a></h2> |
160 |
|
161 |
<p>TOMOYO Linux performs pathname based access control. A pathname may contain not only alphabet and number but also space and carriage return and multibyte (e.g. kanji) characters. Thus, to be able to handle any characters correctly, |
162 |
TOMOYO Linux follows the rules shown below to represent a word. A word means all tokens that are treated as string data, such as pathnames, comments, environment variable's names, parameters for program execution.</p> |
163 |
|
164 |
<ul> |
165 |
<li>\ character (0x5C) is used for indicating octal expression. Thus, you need to use \\ to represent a \.</li> |
166 |
<li>Characters 0x00 - 0x20 and 0x7F - 0xFF are represented using octal expression \ooo .</li> |
167 |
<li>The rest characters (i.e. 0x21 - 0x5B and 0x5D - 0x7E) are represented as is.</li> |
168 |
</ul> |
169 |
|
170 |
<table border="1"> |
171 |
<tr><td><table><tr><td></td><td>Lower 4 bits</td></tr><tr><td>Higher 4 bits</td><td></td></tr></table></td><td>0x0</td><td>0x1</td><td>0x2</td><td>0x3</td><td>0x4</td><td>0x5</td><td>0x6</td><td>0x7</td><td>0x8</td><td>0x9</td><td>0xA</td><td>0xB</td><td>0xC</td><td>0xD</td><td>0xE</td><td>0xF</td></tr> |
172 |
<tr><td>0x0</td><td>\000</td><td>\001</td><td>\002</td><td>\003</td><td>\004</td><td>\005</td><td>\006</td><td>\007</td><td>\010</td><td>\011</td><td>\012</td><td>\013</td><td>\014</td><td>\015</td><td>\016</td><td>\017</td></tr> |
173 |
<tr><td>0x1</td><td>\020</td><td>\021</td><td>\022</td><td>\023</td><td>\024</td><td>\025</td><td>\026</td><td>\027</td><td>\030</td><td>\031</td><td>\032</td><td>\033</td><td>\034</td><td>\035</td><td>\036</td><td>\037</td></tr> |
174 |
<tr><td>0x2</td><td>\040</td><td>!</td><td>"</td><td>#</td><td>$</td><td>%</td><td>&</td><td>'</td><td>(</td><td>)</td><td>*</td><td>+</td><td>,</td><td>-</td><td>.</td><td>/</td></tr> |
175 |
<tr><td>0x3</td><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>:</td><td>;</td><td><</td><td>=</td><td>></td><td>?</td></tr> |
176 |
<tr><td>0x4</td><td>@</td><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td><td>G</td><td>H</td><td>I</td><td>J</td><td>K</td><td>L</td><td>M</td><td>N</td><td>O</td></tr> |
177 |
<tr><td>0x5</td><td>P</td><td>Q</td><td>R</td><td>S</td><td>T</td><td>U</td><td>V</td><td>W</td><td>X</td><td>Y</td><td>Z</td><td>[</td><td>\\</td><td>]</td><td>^</td><td>_</td></tr> |
178 |
<tr><td>0x6</td><td>`</td><td>a</td><td>b</td><td>c</td><td>d</td><td>e</td><td>f</td><td>g</td><td>h</td><td>i</td><td>j</td><td>k</td><td>l</td><td>m</td><td>n</td><td>o</td></tr> |
179 |
<tr><td>0x7</td><td>p</td><td>q</td><td>r</td><td>s</td><td>t</td><td>u</td><td>v</td><td>w</td><td>x</td><td>y</td><td>z</td><td>{</td><td>|</td><td>}</td><td>~</td><td>\177</td></tr> |
180 |
<tr><td>0x8</td><td>\200</td><td>\201</td><td>\202</td><td>\203</td><td>\204</td><td>\205</td><td>\206</td><td>\207</td><td>\210</td><td>\211</td><td>\212</td><td>\213</td><td>\214</td><td>\215</td><td>\216</td><td>\217</td></tr> |
181 |
<tr><td>0x9</td><td>\220</td><td>\221</td><td>\222</td><td>\223</td><td>\224</td><td>\225</td><td>\226</td><td>\227</td><td>\230</td><td>\231</td><td>\232</td><td>\233</td><td>\234</td><td>\235</td><td>\236</td><td>\237</td></tr> |
182 |
<tr><td>0xA</td><td>\240</td><td>\241</td><td>\242</td><td>\243</td><td>\244</td><td>\245</td><td>\246</td><td>\247</td><td>\250</td><td>\251</td><td>\252</td><td>\253</td><td>\254</td><td>\255</td><td>\256</td><td>\257</td></tr> |
183 |
<tr><td>0xB</td><td>\260</td><td>\261</td><td>\262</td><td>\263</td><td>\264</td><td>\265</td><td>\266</td><td>\267</td><td>\270</td><td>\271</td><td>\272</td><td>\273</td><td>\274</td><td>\275</td><td>\276</td><td>\277</td></tr> |
184 |
<tr><td>0xC</td><td>\300</td><td>\301</td><td>\302</td><td>\303</td><td>\304</td><td>\305</td><td>\306</td><td>\307</td><td>\310</td><td>\311</td><td>\312</td><td>\313</td><td>\314</td><td>\315</td><td>\316</td><td>\317</td></tr> |
185 |
<tr><td>0xD</td><td>\320</td><td>\321</td><td>\322</td><td>\323</td><td>\324</td><td>\325</td><td>\326</td><td>\327</td><td>\330</td><td>\331</td><td>\332</td><td>\333</td><td>\334</td><td>\335</td><td>\336</td><td>\337</td></tr> |
186 |
<tr><td>0xE</td><td>\340</td><td>\341</td><td>\342</td><td>\343</td><td>\344</td><td>\345</td><td>\346</td><td>\347</td><td>\350</td><td>\351</td><td>\352</td><td>\353</td><td>\354</td><td>\355</td><td>\356</td><td>\357</td></tr> |
187 |
<tr><td>0xF</td><td>\360</td><td>\361</td><td>\362</td><td>\363</td><td>\364</td><td>\365</td><td>\366</td><td>\367</td><td>\370</td><td>\371</td><td>\372</td><td>\373</td><td>\374</td><td>\375</td><td>\376</td><td>\377</td></tr> |
188 |
</table> |
189 |
|
190 |
<ul> |
191 |
<li>Space character (0x20) is used as a delimiter that separates words. Line feed character (0x0A) is used as a delimiter that separates lines.</li> |
192 |
<li>Only words that follow the rule above and the delimiters (i.e. space character and line feed characters) are valid. All other characters are regarded as space character. Multiple spaces are automatically compressed into one space. Leading and trailing spaces are automatically deleted.</li> |
193 |
</ul> |
194 |
|
195 |
<p>Some examples are shown below.</p> |
196 |
|
197 |
<table border="1"> |
198 |
<tr><td>Word</td><td>Correct expression</td><td>Wrong expression</td></tr> |
199 |
<tr><td>Hello world!</td><td>Hello\040world!</td><td>"Hello world!"</td></tr> |
200 |
<tr><td>/home/user/Documents and Settings/</td><td>/home/user/Documents\040and\040Settings/</td><td>/home/user/Documents and Settings/</td></tr> |
201 |
</table> |
202 |
|
203 |
<h2>2.2 <a name="wildcard_expression_rules">Wildcard Expression Rules</a></h2> |
204 |
|
205 |
<p>Like temporary files, pathnames may contain randomly selected characters. Thus, you often need to define pathnames using wildcards. TOMOYO Linux supports wildcards shown below.</p> |
206 |
|
207 |
<table border="1"> |
208 |
<tr><td>Wildcard</td><td>Meaning</td><td>Example</td></tr> |
209 |
<tr><td>\*</td><td>Zero or more repetitions of characters other than '/'.</td><td>/var/log/samba/\*</td></tr> |
210 |
<tr><td>\@</td><td>Zero or more repetitions of characters other than '/' or '.'.</td><td>/var/www/html/\@.html</td></tr> |
211 |
<tr><td>\?</td><td>1 byte character other than '/'.</td><td>/tmp/mail.\?\?\?\?\?\?</td></tr> |
212 |
<tr><td>\$</td><td>One or more repetitions of decimal digits.</td><td>/proc/\$/cmdline</td></tr> |
213 |
<tr><td>\+</td><td>1 decimal digit.</td><td>/var/tmp/my_work.\+</td></tr> |
214 |
<tr><td>\X</td><td>One or more repetitions of hexadecimal digits.</td><td>/var/tmp/my-work.\X</td></tr> |
215 |
<tr><td>\x</td><td>1 hexadecimal digit.</td><td>/tmp/my-work.\x</td></tr> |
216 |
<tr><td>\A</td><td>One or more repetitions of alphabet characters.</td><td>/var/log/my-work/\$-\A-\$.log</td></tr> |
217 |
<tr><td>\a</td><td>1 alphabet character.</td><td>/home/users/\a/\*/public_html/\*.html</td></tr> |
218 |
<tr><td>\-</td><td>Pathname subtraction operator.</td><td> |
219 |
<ul> |
220 |
<li>/etc/\* for all files in /etc/ directory.</li> |
221 |
<li>/etc/\*\-\*shadow\* for /etc/\* other than /etc/\*shadow\*</li> |
222 |
<li>/\*\-proc\-sys/ for /\*/ other than /proc/ /sys/</li> |
223 |
</ul> |
224 |
</td></tr> |
225 |
<tr><td>/\{dir\}/</td><td>Recursive directory matching operator which matches '/' + one or more repetitions of 'dir/'.</td><td> |
226 |
<ul> |
227 |
<li>/var/www/html/\{\*\}/\*.html for /var/www/html/\*/\*.html /var/www/html/\*/\*/\*.html /var/www/html/\*/\*/\*/\*.html etc.</li> |
228 |
<li>/home/\*/\{\*\-.\*\}/\* for /home/\*/\*\-.\*/\* /home/\*/\*\-.\*/\*\-.\*/\* /home/\*/\*\-.\*/\*\-.\*/\*\-.\*/\* etc.</li> |
229 |
</ul> |
230 |
</td></tr> |
231 |
</table> |
232 |
|
233 |
<h2>2.3 <a name="memory_usage_infomation">Memory Usage Information</a></h2> |
234 |
|
235 |
<p>The memory used by TOMOYO Linux can be obtained via /proc/ccs/meminfo . The unit is byte.</p> |
236 |
|
237 |
<table border="1"> |
238 |
<tr><td> |
239 |
# cat /proc/ccs/meminfo<br> |
240 |
Policy: 377376<br> |
241 |
Audit logs: 0<br> |
242 |
Query lists: 0<br> |
243 |
Total: 377376 |
244 |
</td></tr> |
245 |
</table> |
246 |
|
247 |
<ul> |
248 |
<li>Policy: Memory used for holding access permissions.</li> |
249 |
<li>Audit logs: Memory used for holding access logs.</li> |
250 |
<li>Query lists: Memory used for handling policy violation in enforcing mode.</li> |
251 |
</ul> |
252 |
|
253 |
<p>TOMOYO Linux supports memory quota for limiting maximum memory used by TOMOYO Linux.</p> |
254 |
|
255 |
<p>You can set memory quota by writing to /etc/ccs/meminfo.conf .</p> |
256 |
|
257 |
<table border="1"> |
258 |
<tr><td> |
259 |
# cat /etc/ccs/meminfo.conf<br> |
260 |
Policy: 16777216<br> |
261 |
Audit logs: 1048576<br> |
262 |
Query lists: 1048576 |
263 |
</td></tr> |
264 |
</table> |
265 |
|
266 |
<h1>3. <a name="Policy_Files">Policy Files</a></h1> |
267 |
|
268 |
<h2>3.1 <a name="policy_file_locations">Policy File's Location</a></h2> |
269 |
|
270 |
<p>Policy files are files that contain access permissions. These files are automatically loaded into the kernel upon boot.</p> |
271 |
|
272 |
<p>When a system boots, /sbin/init is executed. When the execution of /sbin/init is requested and if /sbin/ccs-init exists, /sbin/ccs-init is executed, and /sbin/init is executed after /sbin/ccs-init terminates.</p> |
273 |
|
274 |
<p> /sbin/ccs-init loads policy files in /etc/ccs/ directory via the kernel's /proc/ccs/ interface.</p> |
275 |
|
276 |
<table border="1"> |
277 |
<tr><td>The kernel's interface</td><td>Policy file</td><td>Contents</td></tr> |
278 |
<tr><td><a href="#profile">/proc/ccs/profile</a></td><td>/etc/ccs/profile.conf</td><td>Profiles (Collection of access control levels)</td></tr> |
279 |
<tr><td><a href="#manager">/proc/ccs/manager</a></td><td>/etc/ccs/manager.conf</td><td>Managers (Programs that can modify policy via /proc/ccs/ interface)</td></tr> |
280 |
<tr><td><a href="#exception_policy">/proc/ccs/exception_policy</a></td><td>/etc/ccs/exception_policy.conf</td><td>Exception policy (Collection of exceptions for domain policy)</td></tr> |
281 |
<tr><td><a href="#domain_policy">/proc/ccs/domain_policy</a></td><td>/etc/ccs/domain_policy.conf</td><td>Domain policy (Access permissions given to individual domains)</td></tr> |
282 |
<tr><td><a href="#meminfo">/proc/ccs/meminfo</a></td><td>/etc/ccs/meminfo.conf</td><td>Memory usage and quota.</td></tr> |
283 |
</table> |
284 |
|
285 |
<p>There are more interfaces for obtaining information. These interfaces don't have corresponding policy files.</p> |
286 |
|
287 |
<table border="1"> |
288 |
<tr><td>The kernel's interface</td><td>Meaning</td></tr> |
289 |
<tr><td><a href="#query">/proc/ccs/query</a></td><td>Access requests that are waiting for administrator's decision.</td></tr> |
290 |
<tr><td><a href="#.domain_status">/proc/ccs/.domain_status</a></td><td>The list of domainnames and profile numbers currently defined in domain policy.</td></tr> |
291 |
<tr><td><a href="#grant_log">/proc/ccs/grant_log</a></td><td>Access requests that didn't violate domain policy.</td></tr> |
292 |
<tr><td><a href="#reject_log">/proc/ccs/reject_log</a></td><td>Access requests that violated domain policy.</td></tr> |
293 |
<tr><td><a href="#self_domain">/proc/ccs/self_domain</a></td><td>The name of domain the current process belongs to.</td></tr> |
294 |
<tr><td><a href="#.process_status">/proc/ccs/.process_status</a></td><td>The list of domainnames and profile numbers currently running processes belongs to.</td></tr> |
295 |
<tr><td><a href="#version">/proc/ccs/version</a></td><td>Version of TOMOYO Linux.</td></tr> |
296 |
</table> |
297 |
|
298 |
<h2>3.2 <a name="policy_file_modifiers">Policy File's Modification</a></h2> |
299 |
|
300 |
<p>Register the name of programs or domains that can modify policy via the kernel's /proc/ccs/ interface. Only</p> |
301 |
|
302 |
<ul> |
303 |
<li>Processes with programs listed in /proc/ccs/manager</li> |
304 |
<li>Processes with domainnames listed in /proc/ccs/manager</li> |
305 |
</ul> |
306 |
|
307 |
<p>can modify policy via the kernel's /proc/ccs/ interface. Some examples are show below.</p> |
308 |
|
309 |
<table border="1"> |
310 |
<tr><td> |
311 |
# cat /proc/ccs/manager<br> |
312 |
/usr/sbin/ccs-loadpolicy<br> |
313 |
/usr/sbin/ccs-editpolicy<br> |
314 |
/usr/sbin/ccs-setlevel<br> |
315 |
/usr/sbin/ccs-setprofile<br> |
316 |
/usr/sbin/ccs-ld-watch<br> |
317 |
/usr/sbin/ccs-queryd<br> |
318 |
<kernel> /sbin/mingetty /bin/login /bin/bash |
319 |
</td></tr> |
320 |
</table> |
321 |
|
322 |
<p>By default, only processes with UID = 0 and EUID = 0 can modify policy via this interface. But by doing configurations described in <a href="#non_root_policy_update">Allowing policy modification by non root user.</a>, non root user can modify policy via this interface.</p> |
323 |
|
324 |
<p>Exception is, processes that belong to domains with profiles for learning mode can append access permissions to <a href="#domain_policy">/proc/ccs/domain_policy</a> by simply requesting the access.</p> |
325 |
|
326 |
<h1>4. <a name="Domain_Rules">Domain Rules</a></h1> |
327 |
|
328 |
<h2>4.1 <a name="domain_definition">Domain Definition</a></h2> |
329 |
|
330 |
<p>TOMOYO Linux gives access permissions as per a domain. It is managed via <a href="#domain_policy">/proc/ccs/domain_policy</a>.</p> |
331 |
|
332 |
<p>In TOMOYO Linux, every process belongs to a single domain, and all programs belong to different domain. Even the two processes are executing the same program, if their previous domains differ, they belong to different domain.</p> |
333 |
|
334 |
<p>All domains are defined originating from "<kernel>" domain, which the kernel process belongs to. Since /sbin/init is invoked by the "<kernel>" domain, the domain for /sbin/init is defined as "<kernel> /sbin/init". Since /etc/rc.d/rc is invoked by /sbin/init invoked by the kernel, the domain for /etc/rc.d/rc is defined as "<kernel> /sbin/init /etc/rc.d/rc".</p> |
335 |
|
336 |
<h2>4.2 <a name="domain_transition">Domain Transition</a></h2> |
337 |
|
338 |
<p>When a process tries to execute a program, the steps shown below are performed.</p> |
339 |
|
340 |
<table border="1"> |
341 |
<tr><td>Step</td><td>Procedure</td></tr> |
342 |
<tr><td>Getting program's name</td><td> |
343 |
<p>Get the name of program that the process is going to execute and keep it as "Candidate". This procedure does not solve symbolic link if the program is a symbolic link.</p> |
344 |
</td></tr> |
345 |
<tr><td>Aggregating similar programs</td><td> |
346 |
<p>Search exception policy for</p> |
347 |
|
348 |
<ul> |
349 |
<li>aggregator "Candidate" "aggregated name" |
350 |
</ul> |
351 |
|
352 |
<p>and if found one, replace "Candidate" with "aggregated name".</p> |
353 |
</td></tr> |
354 |
<tr><td><a name="exec_stage_check_execute">Checking permission</a></td><td> |
355 |
<p>Search domain policy for</p> |
356 |
|
357 |
<ul> |
358 |
<li>file execute "Candidate" |
359 |
<li>file execute @"a pathname group containing Candidate" |
360 |
</ul> |
361 |
|
362 |
<p>and deny the execute request if not found one.</p> |
363 |
</td></tr> |
364 |
<tr><td><a name="exec_stage_check_destination">Deciding destination domain</a></td><td> |
365 |
|
366 |
<p>(1) Search exception policy for</p> |
367 |
|
368 |
<ul> |
369 |
<li>no_initialize_domain "Candidate" from "the name of the domain the current process belongs to" |
370 |
<li>no_initialize_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
371 |
<li>no_initialize_domain "Candidate" from any |
372 |
<li>no_initialize_domain any from any |
373 |
</ul> |
374 |
|
375 |
<p>and if found one, jump to (3).</p> |
376 |
|
377 |
<p>(2) Search exception policy for</p> |
378 |
|
379 |
<ul> |
380 |
<li>initialize_domain "Candidate" from "the name of the domain the current process belongs to" |
381 |
<li>initialize_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
382 |
<li>initialize_domain "Candidate" from any |
383 |
<li>initialize_domain any from any |
384 |
</ul> |
385 |
|
386 |
<p>and if found one, concatenate "the name of the domain that the kernel belongs to (i.e. <kernel>)" and "Candidate" and keep the result as destination domain, then jump to (6).</p> |
387 |
|
388 |
<p>(3) Search exception policy for</p> |
389 |
|
390 |
<ul> |
391 |
<li>no_keep_domain "Candidate" from "the name of the domain the current process belongs to" |
392 |
<li>no_keep_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
393 |
<li>no_keep_domain any from "the name of the domain the current process belongs to" |
394 |
<li>no_keep_domain any from "the last part of the name of the domain the current process belongs to" |
395 |
<li>no_keep_domain any from any |
396 |
</ul> |
397 |
|
398 |
<p>and if found one, jump to (5).</p> |
399 |
|
400 |
<p>(4) Search exception policy for</p> |
401 |
|
402 |
<ul> |
403 |
<li>keep_domain "Candidate" from "the name of the domain the current process belongs to" |
404 |
<li>keep_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
405 |
<li>keep_domain any from "the name of the domain the current process belongs to" |
406 |
<li>keep_domain any from "the last part of the name of the domain the current process belongs to" |
407 |
<li>keep_domain any from any |
408 |
</ul> |
409 |
|
410 |
<p>and if found one, set "the name of the domain the current process belongs to" as destination domain, then jump to (6).</p> |
411 |
|
412 |
<p>(5) Concatenate "the name of the domain the current process belongs to" and "Candidate" and keep the result as destination domain.</p> |
413 |
|
414 |
<p>(6) Check whether the destination domain is defined, and deny the execute request if not.</p> |
415 |
|
416 |
</td></tr> |
417 |
<tr><td>Checking environment variable names</td><td> |
418 |
|
419 |
<p>(1) Examine all environment variables' names are granted in the destination domain, and deny the execute request if more than one of them are not granted.</p> |
420 |
|
421 |
<p>(2) Perform regular steps for executing program. If successfully completed, the process transits to destination domain.</p> |
422 |
</td></tr> |
423 |
</table> |
424 |
|
425 |
<p>There is an exception. If either</p> |
426 |
|
427 |
<ul> |
428 |
<li>The execute request was denied at "<a href="#exec_stage_check_execute">Checking permission</a>" or "<a href="#exec_stage_check_destination">Deciding destination domain</a>" but the domain the process that issued execute request belongs to has <a href="#domain_policy_task_denied_execute_handler">task denied_execute_handler</a> keyword.</li> |
429 |
<li>The domain the process that issued execute request belongs to has <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> keyword.</li> |
430 |
</ul> |
431 |
|
432 |
<p>and</p> |
433 |
|
434 |
<ul> |
435 |
<li>The process that issued execute request is not a process executed by <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> or <a href="#domain_policy_task_denied_execute_handler">task denied_execute_handler</a> keyword.</li> |
436 |
</ul> |
437 |
|
438 |
<p>the steps shown below are performed instead for the steps shown above. The usage of this exception is explained in "<a href="#auto_execute_handler">Judging execute request outside the kernel.</a>" and "<a href="#denied_execute_handler">Invoking alternative program for execute requests that are not permitted by policy.</a>"</p> |
439 |
|
440 |
<table border="1"> |
441 |
<tr><td>Step</td><td>Procedure</td></tr> |
442 |
<tr><td>Getting program's name</td><td> |
443 |
<p>Keep the pathname of the program specified by <a href="#domain_policy_task_denied_execute_handler">task denied_execute_handler</a> or <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> and keep it as "Candidate".</p> |
444 |
</td></tr> |
445 |
<tr><td>Appending information</td><td> |
446 |
<p>Append all environment variables to the tail of arguments, and delete all environment variables.</p> |
447 |
<p>Insert "Candidate" "the domainname the process that issued execute request belongs to" "the pathname of the process that issued execute request" "state of the process that issued execute request" "the pathname of the requested program" "number of arguments" "number of environment variables" to the top of arguments.</p> |
448 |
</td></tr> |
449 |
<tr><td>Deciding destination domain</td><td> |
450 |
|
451 |
<p>(1) Search exception policy for</p> |
452 |
|
453 |
<ul> |
454 |
<li>no_initialize_domain "Candidate" from "the name of the domain the current process belongs to" |
455 |
<li>no_initialize_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
456 |
<li>no_initialize_domain "Candidate" from any |
457 |
<li>no_initialize_domain any from any |
458 |
</ul> |
459 |
|
460 |
<p>and if found one, jump to (3).</p> |
461 |
|
462 |
<p>(2) Search exception policy for</p> |
463 |
|
464 |
<ul> |
465 |
<li>initialize_domain "Candidate" from "the name of the domain the current process belongs to" |
466 |
<li>initialize_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
467 |
<li>initialize_domain "Candidate" from any |
468 |
<li>initialize_domain any from any |
469 |
</ul> |
470 |
|
471 |
<p>and if found one, concatenate "the name of the domain that the kernel belongs to (i.e. <kernel>)" and "Candidate" and keep the result as destination domain, then jump to (6).</p> |
472 |
|
473 |
<p>(3) Search exception policy for</p> |
474 |
|
475 |
<ul> |
476 |
<li>no_keep_domain "Candidate" from "the name of the domain the current process belongs to" |
477 |
<li>no_keep_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
478 |
<li>no_keep_domain any from "the name of the domain the current process belongs to" |
479 |
<li>no_keep_domain any from "the last part of the name of the domain the current process belongs to" |
480 |
<li>no_keep_domain any from any |
481 |
</ul> |
482 |
|
483 |
<p>and if found one, jump to (5).</p> |
484 |
|
485 |
<p>(4) Search exception policy for</p> |
486 |
|
487 |
<ul> |
488 |
<li>keep_domain "Candidate" from "the name of the domain the current process belongs to" |
489 |
<li>keep_domain "Candidate" from "the last part of the name of the domain the current process belongs to" |
490 |
<li>keep_domain any from "the name of the domain the current process belongs to" |
491 |
<li>keep_domain any from "the last part of the name of the domain the current process belongs to" |
492 |
<li>keep_domain any from any |
493 |
</ul> |
494 |
|
495 |
<p>and if found one, set "the name of the domain the current process belongs to" as destination domain, then jump to (6).</p> |
496 |
|
497 |
<p>(5) Concatenate "the name of the domain the current process belongs to" and "Candidate" and keep the result as destination domain.</p> |
498 |
|
499 |
<p>(6) Check whether the destination domain is defined, and deny the execute request if not.</p> |
500 |
|
501 |
</td></tr> |
502 |
<tr><td>Execute program</td><td> |
503 |
|
504 |
<p>Perform regular steps for executing program. If successfully completed, the process transits to destination domain.</p> |
505 |
|
506 |
</td></tr> |
507 |
</table> |
508 |
|
509 |
<h2>4.3 <a name="access_logs">Access Logs</a></h2> |
510 |
|
511 |
<p>TOMOYO Linux generates two types of access logs. One contains access requests that didn't violate domain policy. The other contains access requests that violated domain policy. The former is called grant log and is readable via /proc/ccs/grant_log . The latter is called reject log and is readable via /proc/ccs/reject_log . A utility program /usr/sbin/ccs-auditd is included for reading these logs and saving the logs as files.</p> |
512 |
|
513 |
<p>Some examples are shown below. The first log is generated by execute request.</p> |
514 |
|
515 |
<table border="1"> |
516 |
<tr><td> |
517 |
#2010-01-13 21:00:50# profile=1 mode=learning (global-pid=2908) task={ pid=2908 ppid=2879 uid=0 gid=0 euid=0 egid=0 suid=0 sgid=0 fsuid=0 fsgid=0 type!=execute_handler } path1={ uid=0 gid=0 ino=852049 major=8 minor=1 perm=0755 type=file } path1.parent={ uid=0 gid=0 ino=851969 perm=0755 } exec={ realpath="/bin/cat" argc=2 envc=20 argv[]={ "cat" "/etc/fstab" } envp[]={ "HOSTNAME=tomoyo" "TERM=vt100" "SHELL=/bin/bash" "HISTSIZE=1000" "SSH_CLIENT=192.168.1.2\0402845\04022" "SSH_TTY=/dev/pts/0" "USER=root" "LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:" "MAIL=/var/spool/mail/root" "PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin:/root/bin" "PWD=/root" "LANG=C" "SHLVL=1" "HOME=/root" "LOGNAME=root" "CVS_RSH=ssh" "SSH_CONNECTION=192.168.1.2\0402845\040192.168.1.7\04022" "LESSOPEN=|/usr/bin/lesspipe.sh\040%s" "G_BROKEN_FILENAMES=1" "_=/bin/cat" } }<br> |
518 |
<kernel> /usr/sbin/sshd /bin/bash<br> |
519 |
file execute /bin/cat |
520 |
</td></tr> |
521 |
</table> |
522 |
|
523 |
<p>This log shows that a process that belongs to "<kernel> /usr/sbin/sshd /bin/bash" domain attempted to execute /bin/cat , and the arguments were "cat" and "/etc/fstab", environment variables were "HOSTNAME=tomoyo" "TERM=vt100" "SHELL=/bin/bash" "HISTSIZE=1000" "SSH_CLIENT=192.168.1.2\0402845\04022" "SSH_TTY=/dev/pts/0" "USER=root" "LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:" "MAIL=/var/spool/mail/root" "PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin:/root/bin" "PWD=/root" "LANG=C" "SHLVL=1" "HOME=/root" "LOGNAME=root" "CVS_RSH=ssh" "SSH_CONNECTION=192.168.1.2\0402845\040192.168.1.7\04022" "LESSOPEN=|/usr/bin/lesspipe.sh\040%s" "G_BROKEN_FILENAMES=1" "_=/bin/cat". Also, process information such as PID, UID are shown.</p> |
524 |
|
525 |
<p>The next log is generated by opening a file for reading.</p> |
526 |
|
527 |
<table border="1"> |
528 |
<tr><td> |
529 |
#2010-01-13 21:00:50# profile=1 mode=learning (global-pid=2908) task={ pid=2908 ppid=2879 uid=0 gid=0 euid=0 egid=0 suid=0 sgid=0 fsuid=0 fsgid=0 type!=execute_handler } path1={ uid=0 gid=0 ino=901920 major=8 minor=1 perm=0644 type=file } path1.parent={ uid=0 gid=0 ino=901121 perm=0755 }<br> |
530 |
<kernel> /usr/sbin/sshd /bin/bash /bin/cat<br> |
531 |
file read /etc/fstab |
532 |
</td></tr> |
533 |
</table> |
534 |
|
535 |
<p>This log shows that a process that belongs to "<kernel> /usr/sbin/sshd /bin/bash /bin/cat" domain opened /etc/fstab for reading.</p> |
536 |
|
537 |
<p>The next log is generated when a new domain is created.</p> |
538 |
|
539 |
<table border="1"> |
540 |
<tr><td> |
541 |
#2010-01-13 21:05:22# profile=1 mode=learning (global-pid=3007) task={ pid=3007 ppid=2991 uid=0 gid=0 euid=0 egid=0 suid=0 sgid=0 fsuid=0 fsgid=0 type=execute_handler }<br> |
542 |
<kernel> /usr/sbin/sshd /bin/bash /bin/bash /bin/audit-exec-param /bin/cat<br> |
543 |
use_profile 1 |
544 |
</td></tr> |
545 |
</table> |
546 |
|
547 |
<p>This log shows that a domain named "<kernel> /usr/sbin/sshd /bin/bash /bin/bash /bin/audit-exec-param /bin/cat" was created and profile 1 was assigned. TOMOYO Linux automatically creates domains as needed. When a domain is automatically created, the profile number of the domain the process that requested program execution belongs to is inherited.</p> |
548 |
|
549 |
<p>The next log is generated when a program that is different from the program being requested was executed because of <a href="#auto_execute_handler">Judging execute request outside the kernel.</a></p> |
550 |
<table border="1"> |
551 |
<tr><td> |
552 |
#2010-01-13 21:05:22# profile=1 mode=learning (global-pid=3007) task={ pid=3007 ppid=2991 uid=0 gid=0 euid=0 egid=0 suid=0 sgid=0 fsuid=0 fsgid=0 type!=execute_handler } path1={ uid=0 gid=0 ino=360482 major=8 minor=1 perm=0755 type=file } path1.parent={ uid=0 gid=0 ino=851969 perm=0755 } exec={ realpath="/bin/audit-exec-param" argc=29 envc=0 argv[]={ "/bin/audit-exec-param" "<kernel>\040/usr/sbin/sshd\040/bin/bash\040/bin/bash" "/bin/bash" "pid=3007\040uid=0\040gid=0\040euid=0\040egid=0\040suid=0\040sgid=0\040fsuid=0\040fsgid=0" "/bin/cat" "2" "20" "cat" "/etc/fstab" "HOSTNAME=tomoyo" "SHELL=/bin/bash" "TERM=vt100" "HISTSIZE=1000" "SSH_CLIENT=192.168.1.2\0402845\04022" "SSH_TTY=/dev/pts/0" "USER=root" "LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:" "PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin:/root/bin:/usr/sbin" "MAIL=/var/spool/mail/root" "PWD=/root" "LANG=C" "HOME=/root" "SHLVL=2" "LOGNAME=root" "CVS_RSH=ssh" "SSH_CONNECTION=192.168.1.2\0402845\040192.168.1.7\04022" "LESSOPEN=|/usr/bin/lesspipe.sh\040%s" "G_BROKEN_FILENAMES=1" "_=/bin/cat" } envp[]={ } }<br> |
553 |
<kernel> /usr/sbin/sshd /bin/bash /bin/bash<br> |
554 |
task auto_execute_handler /bin/audit-exec-param |
555 |
</td></tr> |
556 |
</table> |
557 |
|
558 |
<p>This log shows that a process that belongs to a domain named "<kernel> /usr/sbin/sshd /bin/bash /bin/bash" attempted to execute a program, but since the task auto_execute_handler keyword is specified to the domain, /bin/audit-exec-param was executed, and arguments passed to /bin/audit-exec-param were "/bin/audit-exec-param" "<kernel>\040/usr/sbin/sshd\040/bin/bash\040/bin/bash" "/bin/bash" "pid=3007\040uid=0\040gid=0\040euid=0\040egid=0\040suid=0\040sgid=0\040fsuid=0\040fsgid=0" "/bin/cat" "2" "20" "cat" "/etc/fstab" "HOSTNAME=tomoyo" "SHELL=/bin/bash" "TERM=vt100" "HISTSIZE=1000" "SSH_CLIENT=192.168.1.2\0402845\04022" "SSH_TTY=/dev/pts/0" "USER=root" "LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:" "PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin:/root/bin:/usr/sbin" "MAIL=/var/spool/mail/root" "PWD=/root" "LANG=C" "HOME=/root" "SHLVL=2" "LOGNAME=root" "CVS_RSH=ssh" "SSH_CONNECTION=192.168.1.2\0402845\040192.168.1.7\04022" "LESSOPEN=|/usr/bin/lesspipe.sh\040%s" "G_BROKEN_FILENAMES=1" "_=/bin/cat". To avoid /bin/audit-exec-param affected by environment variables such as LD_PRELOAD, environment variables are moved to arguments.</p> |
559 |
|
560 |
<p>In this way, an access log consists of 3 lines (or 4 lines since /usr/sbin/ccs-auditd inserts an empty line), and they are in the domain policy format and appendable to the domain policy. Pick up portions you want to permit from reject log and save (for example, /var/log/tomoyo/diff.txt) and you can add to domain policy by doing</p> |
561 |
|
562 |
<table border="1"> |
563 |
<tr><td> |
564 |
# /usr/sbin/ccs-loadpolicy -d < /var/log/tomoyo/diff.txt |
565 |
</td></tr> |
566 |
</table> |
567 |
|
568 |
<p>Therefore, you don't need to use "learning mode" from the beginning. If you wish, you can use "permissive mode" from the beginning and let reject logs generated, then edit reject logs and append to domain policy when developing domain policy. When domain policy is generated by "learning mode", process state (the first line of an access logs) is not taken into account. But when domain policy is generated from reject logs, you can use <a href="#conditional_acl">Using conditional ACL.</a> from the beginning. For example, generate a reject log by not using "learning mode" and append like</p> |
569 |
|
570 |
<table border="1"> |
571 |
<tr><td> |
572 |
<kernel> /usr/sbin/sshd /bin/bash<br> |
573 |
file execute /bin/cat exec.argc=2 exec.realpath="/bin/cat" exec.argv[0]="cat" exec.argv[1]="/etc/fstab" |
574 |
</td></tr> |
575 |
</table> |
576 |
|
577 |
<p>then, you can give more precise permission compared to the permission appended by "learning mode"'s log (shown below).</p> |
578 |
|
579 |
<table border="1"> |
580 |
<tr><td> |
581 |
<kernel> /usr/sbin/sshd /bin/bash<br> |
582 |
file execute /bin/cat exec.realpath="/bin/cat" exec.argv[0]="cat" |
583 |
</td></tr> |
584 |
</table> |
585 |
|
586 |
<h1>5. <a name="Syntax_Details">Syntax Details</a></h1> |
587 |
|
588 |
<h2><a name="profile">/proc/ccs/profile</a></h2> |
589 |
|
590 |
<p>TOMOYO Linux can perform several MACs besides MAC for files, but to reduce the load of policy managements, you can disable MACs you think unnecessary.</p> |
591 |
|
592 |
<p>List up functions and their modes in "$number-$variable=$value" format. The $number is profile number between 0 and 255. To modify profile, use "ccs-setlevel" or "ccs-loadpolicy" commands.</p> |
593 |
|
594 |
<p>Each domain is assigned one profile. To assign profile to domains, use "setprofile" or "ccs-editpolicy" or "ccs-loadpolicy" commands.</p> |
595 |
|
596 |
<p>You can see profiles currently assigned to domains using "ccs-editpolicy" command.<br> |
597 |
You can see profiles currently assigned to processes using "ccs-pstree" command.<br> |
598 |
If you saved current policy using "ccs-savepolicy" command, the currently assigned profile number is saved as <a href="#domain_policy_use_profile">use_profile</a> line of domain policy.</p> |
599 |
|
600 |
<p>To read or modify current profiles, operate like below.</p> |
601 |
|
602 |
<p>(Example)<br> |
603 |
cat /proc/ccs/profile<br> |
604 |
ccs-savepolicy -p<br> |
605 |
ccs-setlevel 1-CONFIG::file::execute=learning<br> |
606 |
echo 1-CONFIG::file::execute=learning | ccs-loadpolicy -p</p> |
607 |
|
608 |
<p>See also: <a href="#policy_file_modifiers">Policy File's Modification</a></p> |
609 |
|
610 |
<p>You can specify one of modes shown below for functionalities that start with "CONFIG".</p> |
611 |
|
612 |
<table border="1"> |
613 |
<tr><td>Configuration</td><td>Meaning</td></tr> |
614 |
<tr><td>mode=disabled</td><td>Disabled. Works as if regular kernel.</td></tr> |
615 |
<tr><td>mode=learning</td><td>Learning mode. An access request is not rejected even if the request violates policy. Also, the permission to allow the request is automatically added to policy so that the same request no longer violates policy.</td></tr> |
616 |
<tr><td>mode=permissive</td><td>Permissive mode. An access request is not rejected even if the request violates policy. But, the permission to allow the request is not added to policy.</td></tr> |
617 |
<tr><td>mode=enforcing</td><td>Enforcing mode. An access request is rejected if the request violates policy.</td></tr> |
618 |
<tr><td>grant_log=yes</td><td>Generate grant logs. The max entries are controlled via "max_grant_log=" parameter of "<a href="#profile_PREFERENCE">PREFERENCE</a>" line.</td></tr> |
619 |
<tr><td>grant_log=no</td><td>Don't generate grant logs.</td></tr> |
620 |
<tr><td>reject_log=yes</td><td>Generate reject logs. The max entries are controlled via "max_reject_log=" parameter of "<a href="#profile_PREFERENCE">PREFERENCE</a>" line.</td></tr> |
621 |
<tr><td>reject_log=no</td><td>Don't generate reject logs.</td></tr> |
622 |
</table> |
623 |
|
624 |
<h3><a name="profile_CONFIG::file::execute">CONFIG::file::execute</a></h3> |
625 |
|
626 |
<p>Specifies access control level regarding program execution and domain transition.</p> |
627 |
|
628 |
<h3><a name="profile_CONFIG::file::open">CONFIG::file::open</a></h3> |
629 |
|
630 |
<p>Specifies access control level regarding file open for reading and/or writing.</p> |
631 |
|
632 |
<h3><a name="profile_CONFIG::file::create">CONFIG::file::create</a></h3> |
633 |
|
634 |
<p>Specifies access control level regarding file create.</p> |
635 |
|
636 |
<h3><a name="profile_CONFIG::file::unlink">CONFIG::file::unlink</a></h3> |
637 |
|
638 |
<p>Specifies access control level regarding file delete.</p> |
639 |
|
640 |
<h3><a name="profile_CONFIG::file::mkdir">CONFIG::file::mkdir</a></h3> |
641 |
|
642 |
<p>Specifies access control level regarding directory create.</p> |
643 |
|
644 |
<h3><a name="profile_CONFIG::file::rmdir">CONFIG::file::rmdir</a></h3> |
645 |
|
646 |
<p>Specifies access control level regarding directory delete.</p> |
647 |
|
648 |
<h3><a name="profile_CONFIG::file::mkfifo">CONFIG::file::mkfifo</a></h3> |
649 |
|
650 |
<p>Specifies access control level regarding fifo create.</p> |
651 |
|
652 |
<h3><a name="profile_CONFIG::file::mksock">CONFIG::file::mksock</a></h3> |
653 |
|
654 |
<p>Specifies access control level regarding UNIX domain socket create.</p> |
655 |
|
656 |
<h3><a name="profile_CONFIG::file::truncate">CONFIG::file::truncate</a></h3> |
657 |
|
658 |
<p>Specifies access control level regarding file truncate.</p> |
659 |
|
660 |
<h3><a name="profile_CONFIG::file::symlink">CONFIG::file::symlink</a></h3> |
661 |
|
662 |
<p>Specifies access control level regarding symlink create.</p> |
663 |
|
664 |
<h3><a name="profile_CONFIG::file::rewrite">CONFIG::file::rewrite</a></h3> |
665 |
|
666 |
<p>Specifies access control level regarding file overwrite.</p> |
667 |
|
668 |
<h3><a name="profile_CONFIG::file::mkblock">CONFIG::file::mkblock</a></h3> |
669 |
|
670 |
<p>Specifies access control level regarding block device file create.</p> |
671 |
|
672 |
<h3><a name="profile_CONFIG::file::mkchar">CONFIG::file::mkchar</a></h3> |
673 |
|
674 |
<p>Specifies access control level regarding character device file create.</p> |
675 |
|
676 |
<h3><a name="profile_CONFIG::file::link">CONFIG::file::link</a></h3> |
677 |
|
678 |
<p>Specifies access control level regarding link create.</p> |
679 |
|
680 |
<h3><a name="profile_CONFIG::file::rename">CONFIG::file::rename</a></h3> |
681 |
|
682 |
<p>Specifies access control level regarding rename.</p> |
683 |
|
684 |
<h3><a name="profile_CONFIG::file::chmod">CONFIG::file::chmod</a></h3> |
685 |
|
686 |
<p>Specifies access control level regarding chmod.</p> |
687 |
|
688 |
<h3><a name="profile_CONFIG::file::chown">CONFIG::file::chown</a></h3> |
689 |
|
690 |
<p>Specifies access control level regarding chown.</p> |
691 |
|
692 |
<h3><a name="profile_CONFIG::file::chgrp">CONFIG::file::chgrp</a></h3> |
693 |
|
694 |
<p>Specifies access control level regarding chgrp.</p> |
695 |
|
696 |
<h3><a name="profile_CONFIG::file::ioctl">CONFIG::file::ioctl</a></h3> |
697 |
|
698 |
<p>Specifies access control level regarding ioctl.</p> |
699 |
|
700 |
<h3><a name="profile_CONFIG::file::chroot">CONFIG::file::chroot</a></h3> |
701 |
|
702 |
<p>Specifies access control level regarding chroot.</p> |
703 |
|
704 |
<h3><a name="profile_CONFIG::file::mount">CONFIG::file::mount</a></h3> |
705 |
|
706 |
<p>Specifies access control level regarding mount.</p> |
707 |
|
708 |
<h3><a name="profile_CONFIG::file::unmount">CONFIG::file::unmount</a></h3> |
709 |
|
710 |
<p>Specifies access control level regarding unmount.</p> |
711 |
|
712 |
<h3><a name="profile_CONFIG::file::pivot_root">CONFIG::file::pivot_root</a></h3> |
713 |
|
714 |
<p>Specifies access control level regarding pivot_root.</p> |
715 |
|
716 |
<h3><a name="profile_CONFIG::misc::env">CONFIG::misc::env</a></h3> |
717 |
|
718 |
<p>Specifies access control level regarding environment variable names (a.k.a. envp[]).</p> |
719 |
|
720 |
<h3><a name="profile_CONFIG::capability::use_route">CONFIG::capability::use_route</a></h3> |
721 |
|
722 |
<p>Specifies access control level regarding use of ROUTE sockets.</p> |
723 |
|
724 |
<h3><a name="profile_CONFIG::capability::use_packet">CONFIG::capability::use_packet</a></h3> |
725 |
|
726 |
<p>Specifies access control level regarding use of PACKET sockets.</p> |
727 |
|
728 |
<h3><a name="profile_CONFIG::capability::use_kernel_module">CONFIG::capability::use_kernel_module</a></h3> |
729 |
|
730 |
<p>Specifies access control level regarding use of create_module(2) init_module(2) delete_module(2) syscall.</p> |
731 |
|
732 |
<h3><a name="profile_CONFIG::capability::SYS_REBOOT">CONFIG::capability::SYS_REBOOT</a></h3> |
733 |
|
734 |
<p>Specifies access control level regarding use of reboot(2) syscall.</p> |
735 |
|
736 |
<h3><a name="profile_CONFIG::capability::SYS_VHANGUP">CONFIG::capability::SYS_VHANGUP</a></h3> |
737 |
|
738 |
<p>Specifies access control level regarding use of vhangup(2) syscall.</p> |
739 |
|
740 |
<h3><a name="profile_CONFIG::capability::SYS_TIME">CONFIG::capability::SYS_TIME</a></h3> |
741 |
|
742 |
<p>Specifies access control level regarding use of stime(2) settimeofday(2) adjtimex(2) syscall.</p> |
743 |
|
744 |
<h3><a name="profile_CONFIG::capability::SYS_NICE">CONFIG::capability::SYS_NICE</a></h3> |
745 |
|
746 |
<p>Specifies access control level regarding use of nice(2) setpriority(2) syscall.</p> |
747 |
|
748 |
<h3><a name="profile_CONFIG::capability::SYS_SETHOSTNAME">CONFIG::capability::SYS_SETHOSTNAME</a></h3> |
749 |
|
750 |
<p>Specifies access control level regarding use of sethostname(2) setdomainname(2) syscall.</p> |
751 |
|
752 |
<h3><a name="profile_CONFIG::capability::SYS_KEXEC_LOAD">CONFIG::capability::SYS_KEXEC_LOAD</a></h3> |
753 |
|
754 |
<p>Specifies access control level regarding use of kexec_load(2) syscall.</p> |
755 |
|
756 |
<h3><a name="profile_CONFIG::capability::SYS_PTRACE">CONFIG::capability::SYS_PTRACE</a></h3> |
757 |
|
758 |
<p>Specifies access control level regarding use of ptrace(2) syscall.<br> |
759 |
|
760 |
<h3><a name="profile_CONFIG::network::inet_dgram_bind">CONFIG::network::inet_dgram_bind</a></h3> |
761 |
|
762 |
<p>Specifies access control level regarding UDP socket's local address restriction.</p> |
763 |
|
764 |
<h3><a name="profile_CONFIG::network::inet_dgram_send">CONFIG::network::inet_dgram_send</a></h3> |
765 |
|
766 |
<p>Specifies access control level regarding UDP socket's remote address restriction for outgoing packets.</p> |
767 |
|
768 |
<h3><a name="profile_CONFIG::network::inet_dgram_recv">CONFIG::network::inet_dgram_recv</a></h3> |
769 |
|
770 |
<p>Specifies access control level regarding UDP socket's remote address restriction for incoming packets.</p> |
771 |
|
772 |
<h3><a name="profile_CONFIG::network::inet_stream_bind">CONFIG::network::inet_stream_bind</a></h3> |
773 |
|
774 |
<p>Specifies access control level regarding TCP socket's bind() operation.</p> |
775 |
|
776 |
<h3><a name="profile_CONFIG::network::inet_stream_listen">CONFIG::network::inet_stream_listen</a></h3> |
777 |
|
778 |
<p>Specifies access control level regarding TCP socket's listen() operation.</p> |
779 |
|
780 |
<h3><a name="profile_CONFIG::network::inet_stream_connect">CONFIG::network::inet_stream_connect</a></h3> |
781 |
|
782 |
<p>Specifies access control level regarding TCP socket's connect() operation.</p> |
783 |
|
784 |
<h3><a name="profile_CONFIG::network::inet_stream_accept">CONFIG::network::inet_stream_accept</a></h3> |
785 |
|
786 |
<p>Specifies access control level regarding TCP socket's accept() operation.</p> |
787 |
|
788 |
<h3><a name="profile_CONFIG::network::inet_raw_bind">CONFIG::network::inet_raw_bind</a></h3> |
789 |
|
790 |
<p>Specifies access control level regarding RAW socket's local address restriction.</p> |
791 |
|
792 |
<h3><a name="profile_CONFIG::network::inet_raw_send">CONFIG::network::inet_raw_send</a></h3> |
793 |
|
794 |
<p>Specifies access control level regarding RAW socket's remote address restriction for outgoing packets.</p> |
795 |
|
796 |
<h3><a name="profile_CONFIG::network::inet_raw_recv">CONFIG::network::inet_raw_recv</a></h3> |
797 |
|
798 |
<p>Specifies access control level regarding RAW socket's remote address restriction for incoming packets.</p> |
799 |
|
800 |
<h3><a name="profile_CONFIG::network::unix_dgram_bind">CONFIG::network::unix_dgram_bind</a></h3> |
801 |
|
802 |
<p>Specifies access control level regarding UNIX domain's datagram socket's local address restriction.</p> |
803 |
|
804 |
<h3><a name="profile_CONFIG::network::unix_dgram_send">CONFIG::network::unix_dgram_send</a></h3> |
805 |
|
806 |
<p>Specifies access control level regarding UNIX domain's datagram socket's remote address restriction for outgoing packets.</p> |
807 |
|
808 |
<h3><a name="profile_CONFIG::network::unix_dgram_recv">CONFIG::network::unix_dgram_recv</a></h3> |
809 |
|
810 |
<p>Specifies access control level regarding UNIX domain's datagram socket's remote address restriction for incoming packets.</p> |
811 |
|
812 |
<h3><a name="profile_CONFIG::network::unix_stream_bind">CONFIG::network::unix_stream_bind</a></h3> |
813 |
|
814 |
<p>Specifies access control level regarding UNIX domain's stream socket's bind() operation.</p> |
815 |
|
816 |
<h3><a name="profile_CONFIG::network::unix_stream_listen">CONFIG::network::unix_stream_listen</a></h3> |
817 |
|
818 |
<p>Specifies access control level regarding UNIX domain's stream socket's listen() operation.</p> |
819 |
|
820 |
<h3><a name="profile_CONFIG::network::unix_stream_connect">CONFIG::network::unix_stream_connect</a></h3> |
821 |
|
822 |
<p>Specifies access control level regarding UNIX domain's stream socket's connect() operation.</p> |
823 |
|
824 |
<h3><a name="profile_CONFIG::network::unix_stream_accept">CONFIG::network::unix_stream_accept</a></h3> |
825 |
|
826 |
<p>Specifies access control level regarding UNIX domain's stream socket's accept() operation.</p> |
827 |
|
828 |
<h3><a name="profile_CONFIG::network::unix_seqpacket_bind">CONFIG::network::unix_seqpacket_bind</a></h3> |
829 |
|
830 |
<p>Specifies access control level regarding UNIX domain's seqpacket socket's bind() operation.</p> |
831 |
|
832 |
<h3><a name="profile_CONFIG::network::unix_seqpacket_listen">CONFIG::network::unix_seqpacket_listen</a></h3> |
833 |
|
834 |
<p>Specifies access control level regarding UNIX domain's seqpacket socket's listen() operation.</p> |
835 |
|
836 |
<h3><a name="profile_CONFIG::network::unix_seqpacket_connect">CONFIG::network::unix_seqpacket_connect</a></h3> |
837 |
|
838 |
<p>Specifies access control level regarding UNIX domain's seqpacket socket's connect() operation.</p> |
839 |
|
840 |
<h3><a name="profile_CONFIG::network::unix_seqpacket_accept">CONFIG::network::unix_seqpacket_accept</a></h3> |
841 |
|
842 |
<p>Specifies access control level regarding UNIX domain's seqpacket socket's accept() operation.</p> |
843 |
|
844 |
<h3><a name="profile_CONFIG::ipc::signal">CONFIG::ipc::signal</a></h3> |
845 |
|
846 |
<p>Specifies access control level regarding signal transmission requests.</p> |
847 |
|
848 |
<h3><a name="profile_PREFERENCE">PREFERENCE</a></h3> |
849 |
|
850 |
<p>Specifies preference on auditing / learning / enforcing.</p> |
851 |
|
852 |
<p>"max_grant_log=" limits the max number of grant logs that the kernel can hold. </p> |
853 |
|
854 |
<p>"max_reject_log=" limits the max number of reject logs that the kernel can hold. </p> |
855 |
|
856 |
<p>"max_learning_entry=" controls the max number of ACL entries that are automatically appended in learning mode.</p> |
857 |
|
858 |
<p>"enforcing_penalty=" controls how long (in units of 0.1 second) should the process that violated policy sleep for in enforcing mode.</p> |
859 |
|
860 |
<h2><a name="domain_policy">/proc/ccs/domain_policy</a></h2> |
861 |
|
862 |
<p>This file contains definition of all domains and permissions that are granted to each domain.</p> |
863 |
|
864 |
<p>Lines from the next line to a domain definition ( any lines starting with "<kernel>") to the previous line to the next domain definitions are interpreted as access permissions for that domain.</p> |
865 |
|
866 |
<p>You can specify additional conditions as needed. The syntax for specifying additional conditions are described in <a href="#conditional_acl">Using conditional ACL.</a> Also, how to perform domain transition upon ACL match as needed is described in <a href="#transit_on_match">Domain transition upon ACL match.</a></p> |
867 |
|
868 |
<p>To read or modify current domain policy, operate like below.</p> |
869 |
<p>(Example) Selecting specific domain and appending ACLs. The domain will be created if nonexistent.<br> |
870 |
printf "<kernel> /sbin/init\nfile read /etc/passwd\n" | ccs-loadpolicy -d</p> |
871 |
<p>(Example) Selecting specific domain and appending ACLs. The domain won't be created if nonexistent.<br> |
872 |
printf "select <kernel> /sbin/init\nfile read /etc/passwd\n" | ccs-loadpolicy -d</p> |
873 |
<p>(Example) Selecting specific domain and removing ACLs.<br> |
874 |
printf "select <kernel> /sbin/init\ndelete file read /etc/passwd\ndelete file read /etc/shadow\n" | ccs-loadpolicy -d</p> |
875 |
<p>(Example) Deleting specific domain.<br> |
876 |
printf "delete <kernel> /sbin/init\n" | ccs-loadpolicy -d</p> |
877 |
<p>(Example) Reading current domain policy.<br> |
878 |
cat /proc/ccs/domain_policy</p> |
879 |
|
880 |
<p>See also: <a href="#policy_file_modifiers">Policy File's Modification</a></p> |
881 |
|
882 |
<h3><a name="domain_policy_file_execute">file execute</a></h3> |
883 |
<p>This keyword grants execution of the specified pathname.</p> |
884 |
<p>(Example) file execute /bin/ls</p> |
885 |
<p>See also: <a href="#domain_transition">Domain Transition</a> <a href="#exception_policy_aggregator">aggregator</a></p> |
886 |
|
887 |
<h3><a name="domain_policy_file_write">file write</a></h3> |
888 |
<p>This keyword grants the specified pathname to be opened for writing.</p> |
889 |
<p>(Example) file write /dev/null</p> |
890 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
891 |
|
892 |
<h3><a name="domain_policy_file_read">file read</a></h3> |
893 |
<p>This keyword grants the specified pathname to be opened for reading.</p> |
894 |
<p>(Example) file read /proc/meminfo</p> |
895 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
896 |
|
897 |
<h3><a name="domain_policy_file_append">file append</a></h3> |
898 |
<p>This keyword grants the specified pathname to be opened for appending.</p> |
899 |
<p>(Example) file append /dev/null</p> |
900 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
901 |
|
902 |
<h3><a name="domain_policy_file_create">file create</a></h3> |
903 |
<p>This keyword grants the specified pathname to be created.</p> |
904 |
<p>(Example) file create /var/lock/subsys/crond</p> |
905 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
906 |
|
907 |
<h3><a name="domain_policy_file_unlink">file unlink</a></h3> |
908 |
<p>This keyword grants the specified pathname to be deleted.</p> |
909 |
<p>(Example) file unlink /var/lock/subsys/crond</p> |
910 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
911 |
|
912 |
<h3><a name="domain_policy_file_mkdir">file mkdir</a></h3> |
913 |
<p>This keyword grants the specified pathname to be created. The pathname must be a directory.</p> |
914 |
<p>(Example) file mkdir /tmp/logwatch.\*/</p> |
915 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
916 |
|
917 |
<h3><a name="domain_policy_file_rmdir">file rmdir</a></h3> |
918 |
<p>This keyword grants the specified pathname to be deleted. The pathname must be a directory.</p> |
919 |
<p>(Example) file rmdir /tmp/logwatch.\*/</p> |
920 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
921 |
|
922 |
<h3><a name="domain_policy_file_mkfifo">file mkfifo</a></h3> |
923 |
<p>This keyword grants creation of FIFO by the specified pathname.</p> |
924 |
<p>(Example) file mkfifo /dev/initctl</p> |
925 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
926 |
|
927 |
<h3><a name="domain_policy_file_mksock">file mksock</a></h3> |
928 |
<p>This keyword grants creation of UNIX domain socket by the specified pathname.</p> |
929 |
<p>(Example) file mksock /dev/log</p> |
930 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
931 |
|
932 |
<h3><a name="domain_policy_file_mkblock">file mkblock</a></h3> |
933 |
<p>This keyword grants creation of block device file by the specified pathname.</p> |
934 |
<p>(Example) file mkblock /dev/\*</p> |
935 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
936 |
|
937 |
<h3><a name="domain_policy_file_mkchar">file mkchar</a></h3> |
938 |
<p>This keyword grants creation of character device file by the specified pathname.</p> |
939 |
<p>(Example) file mkchar /dev/\*</p> |
940 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
941 |
|
942 |
<h3><a name="domain_policy_file_truncate">file truncate</a></h3> |
943 |
<p>This keyword grants the specified pathname to be truncated or extended.</p> |
944 |
<p>(Example) file truncate /etc/mtab</p> |
945 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
946 |
|
947 |
<h3><a name="domain_policy_file_symlink">file symlink</a></h3> |
948 |
<p>This keyword grants creation of symbolic link by the specified pathname.</p> |
949 |
<p>(Example) file symlink /dev/cdrom</p> |
950 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
951 |
|
952 |
<h3><a name="domain_policy_file_link">file link</a></h3> |
953 |
<p>This keyword grants creation of hard link by the specified pathnames.</p> |
954 |
<p>(Example) file link /etc/mtab~\$ /etc/mtab~</p> |
955 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
956 |
|
957 |
<h3><a name="domain_policy_file_rename">file rename</a></h3> |
958 |
<p>This keyword grants renaming of the specified pathnames.</p> |
959 |
<p>(Example) file rename /etc/mtab.tmp /etc/mtab</p> |
960 |
<p>See also: <a href="#exception_policy_path_group">path_group</a></p> |
961 |
|
962 |
<h3><a name="domain_policy_file_ioctl">file ioctl</a></h3> |
963 |
|
964 |
<p>This keyword grants doing IOCTL request with the specified command numbers and the specified pathnames.</p> |
965 |
|
966 |
<table border="1"> |
967 |
<tr><td>Example</td><td>Permitted access</td></tr> |
968 |
<tr><td>file ioctl socket:[family=2:type=2:protocol=17] 35093</td><td>Allow sockets with protocol family 2, type 2, protocol 17 to do IOCTL request with command number 35093.</td></tr> |
969 |
<tr><td>file ioctl /dev/null 10000-20000</td><td>Allow /dev/null to do IOCTL request with command number between 10000 and 20000.</td></tr> |
970 |
</table> |
971 |
|
972 |
<p>Regarding the meaning of IOCTL request's command numbers, please refer manuals provided by each module with IOCTL functionality. For example, IOCTL request with command number 21585 means, on i386 platform, FIOCLEX command which turns on the file's close-on-exec flag. For example, IOCTL request with command number 35088 means SIOCGIFNAME command which retrieves the name of network interface.</p> |
973 |
|
974 |
<p>See also: <a href="#conditional_acl">Using conditional ACL.</a></p> |
975 |
|
976 |
<h3><a name="domain_policy_file_mount">file mount</a></h3> |
977 |
<p>To grant mount permission, use file mount keyword followed by "$devicefile $mountpoint $filesystem $options". The $devicefile need to be a canonicalized file if the $filesystem requires device file. The $mountpoint must be a canonicalized file. The $options is a hexadecimal integer expression.</p> |
978 |
|
979 |
<p>To grant "mount -o remount $mountpoint" permission, use file mount keyword followed by "any $mountpoint --remount $options".</p> |
980 |
|
981 |
<p>To grant "mount --bind $source_dir $dest_dir", use "file mount $source_dir $dest_dir --bind $options".<br> |
982 |
To grant "mount --move $source_dir $dest_dir" permission, use "file mount $source_dir $dest_dir --move $options".<br> |
983 |
The $source_dir and $dest_dir must be canonicalized directory.</p> |
984 |
|
985 |
<p>Kernel 2.6.15 and later supports "Shared Subtree" functionality.<br> |
986 |
To grant "mount --make-unbindable $mountpoint" permission, use file mount keyword followed by "any $mountpoint --make-unbindable $options".<br> |
987 |
To grant "mount --make-private $mountpoint" permission, use file mount keyword followed by "any $mountpoint --make-private $options".<br> |
988 |
To grant "mount --make-slave $mountpoint" permission, use file mount keyword followed by "any $mountpoint --make-slave $options".<br> |
989 |
To grant "mount --make-shared $mountpoint" permission, use file mount keyword followed by "any $mountpoint --make-shared $options".</p> |
990 |
|
991 |
<p>(Example)<br> |
992 |
file mount none /dev/pts/ devpts 0x0<br> |
993 |
file mount /proc /proc/ proc 0x0<br> |
994 |
file mount usbdevfs /proc/bus/usb/ usbdevfs 0x0<br> |
995 |
file mount none /data/ tmpfs 0xE<br> |
996 |
file mount none /dev/shm/ tmpfs 0xE<br> |
997 |
file mount /dev/hdc /var/www/ ext2 0xF<br> |
998 |
file mount any / --remount 0x0</p> |
999 |
|
1000 |
<h3><a name="domain_policy_file_unmount">file unmount</a></h3> |
1001 |
<p>To grant unmount request, use file unmount keyword followed by a canonicalized directory.</p> |
1002 |
|
1003 |
<p>(Example)<br> |
1004 |
file unmount /mnt/cdrom/</p> |
1005 |
|
1006 |
<h3><a name="domain_policy_file_chroot">file chroot</a></h3> |
1007 |
<p>To grant chroot permission, use file chroot keyword followed by a canonicalized directory.<br> |
1008 |
Usually, grant /var/empty/sshd/ that sshd uses. In addition, if you have applications that runs in the chroot'ed environment or applications that uses chroot (for example, /usr/share/empty/ is used by vsftpd), grant such directories too.</p> |
1009 |
|
1010 |
<p>(Example)<br> |
1011 |
file chroot /var/empty/sshd/<br> |
1012 |
file chroot /usr/share/empty/<br> |
1013 |
file chroot /var/www/html/<br> |
1014 |
file chroot /</p> |
1015 |
|
1016 |
<h3><a name="domain_policy_file_pivot_root">file pivot_root</a></h3> |
1017 |
<p>To grant pivot_root permission, use file pivot_root keyword followed by the new root's canonicalized directory and the previous root's canonicalized directory.<br> |
1018 |
Usually, you don't need this keyword.</p> |
1019 |
|
1020 |
<h3><a name="domain_policy_misc_env">misc env</a></h3> |
1021 |
|
1022 |
<p>To restrict the name of environment variables, use misc env keyword followed by "the name of environment variable".</p> |
1023 |
|
1024 |
<p>The execve() system call, which is used to execute a program, accepts filename and argv[] and envp[]. Many programs behave differently depending on envp[].</p> |
1025 |
<p>The purpose of this keyword is to restrict the environment variables passed to an executed programs.</p> |
1026 |
|
1027 |
<h3><a name="domain_policy_capability">capability</a></h3> |
1028 |
|
1029 |
<p>To grant capability permission, use capability keyword followed by a capability. The following capabilities are applicable.</p> |
1030 |
|
1031 |
<table border="1"> |
1032 |
<tr><td>capability use_route</td><td>Permit use of ROUTE sockets.</td></tr> |
1033 |
<tr><td>capability use_packet</td><td>Permit use of PACKET sockets.</td></tr> |
1034 |
<tr><td>capability use_kernel_module</td><td>Permit use of create_module(2) init_module(2) delete_module(2) syscall.</td></tr> |
1035 |
<tr><td>capability SYS_REBOOT</td><td>Permit use of reboot(2) syscall.</td></tr> |
1036 |
<tr><td>capability SYS_VHANGUP</td><td>Permit use of vhangup(2) syscall.</td></tr> |
1037 |
<tr><td>capability SYS_TIME</td><td>Permit use of stime(2) settimeofday(2) adjtimex(2) syscall.</td></tr> |
1038 |
<tr><td>capability SYS_NICE</td><td>Permit use of nice(2) setpriority(2) syscall.</td></tr> |
1039 |
<tr><td>capability SYS_SETHOSTNAME</td><td>Permit use of sethostname(2) setdomainname(2) syscall.</td></tr> |
1040 |
<tr><td>capability SYS_KEXEC_LOAD</td><td>Permit use of kexec_load(2) syscall.</td></tr> |
1041 |
<tr><td>capability SYS_PTRACE</td><td>Permit use of ptrace(2) syscall.</td></tr> |
1042 |
</table> |
1043 |
|
1044 |
<h3><a name="domain_policy_network">network</a></h3> |
1045 |
|
1046 |
<p>To grant permission for socket operations, use network keyword followed by protocol(TCP or UDP or RAW) and IP address and port number (for TCP or UDP) / protocol number (for RAW). This permission is applicable to IPv4 and IPv6.</p> |
1047 |
<table border="1"> |
1048 |
<tr><td>Keyword</td><td>Permitted operation</td><td>Example</td></tr> |
1049 |
<tr><td>network inet stream bind</td><td> Bind to local TCP address/port.</td><td>network inet stream bind 0.0.0.0 80</td></tr> |
1050 |
<tr><td>network inet stream listen</td><td>Listen to local TCP address/port.</td><td>network inet stream listen 0.0.0.0 80</td></tr> |
1051 |
<tr><td>network inet stream accept</td><td>Accept from and communicate with remote TCP address/port.</td><td>network inet stream accept 10.0.0.0-10.255.255.255 1024-65535</td></tr> |
1052 |
<tr><td>network inet stream connect</td><td>Connect to and communicate with remote TCP address/port.</td><td>network inet stream connect 127.0.0.1 1024-65535</td></tr> |
1053 |
<tr><td>network inet dgram bind</td><td>Bind to local UDP address/port.</td><td>network inet dgram bind 0.0.0.0 53</td></tr> |
1054 |
|
1055 |
<tr><td>network inet dgram send</td><td>Sending UDP packets to remote address/port.</td><td>network inet dgram send 127.0.0.1 53</td></tr> |
1056 |
<tr><td>network inet dgram recv</td><td>Receiving UDP packets from remote address/port.</td><td>network inet dgram recv 127.0.0.1 53</td></tr> |
1057 |
<tr><td>network inet raw bind</td><td>Bind to local IP address/protocol.</td><td>network inet raw bind 127.0.0.1 255</td></tr> |
1058 |
<tr><td>network inet raw send</td><td>Sending IP packets to remote address/protocol.</td><td>network inet raw send 10.0.0.1 1</td></tr> |
1059 |
<tr><td>network inet raw recv</td><td>Receiving IP packets from remote address/protocol.</td><td>network inet raw recv 10.0.0.1 1</td></tr> |
1060 |
</table> |
1061 |
<p>Use of "::" for IPv6 address representation is not supported. You need to use "0:0:0:0:0:0:0:1" for "::1".</p> |
1062 |
|
1063 |
<p>To reduce the labor of repeating same IP addresses, you can define groups like pathnames.</p> |
1064 |
|
1065 |
<p>See also: <a href="#exception_policy_address_group">address_group</a></p> |
1066 |
|
1067 |
<h3><a name="domain_policy_ipc_signal">ipc signal</a></h3> |
1068 |
|
1069 |
<p>To grant permissions for signals, use ipc signal keyword followed by signal number and target domain.<br> |
1070 |
There are two exceptions. If signal number is 0, it is always granted. If the target domain and the source domain are the same, it is always granted.</p> |
1071 |
<p>In other cases, signals are granted only when the signal number matches and the target domain starts with the target domain declared with this keyword.</p> |
1072 |
<p>If only <kernel> is declared as a target domain, the source domain can send signals to any domain with that signal number.</p> |
1073 |
|
1074 |
<h3><a name="domain_policy_use_profile">use_profile</a></h3> |
1075 |
|
1076 |
<p>This keyword indicates the profile number currently assigned to this domain. The profile number is an integer between 0 and 255.</p> |
1077 |
|
1078 |
<h3><a name="domain_policy_use_group">use_group</a></h3> |
1079 |
|
1080 |
<p>This keyword indicates the group number currently assigned to this domain. The group number is an integer between 0 and 255.</p> |
1081 |
|
1082 |
<h3><a name="domain_policy_task_auto_execute_handler">task auto_execute_handler</a></h3> |
1083 |
|
1084 |
<p>This domain executes only one program specified by this keyword. You can use this keyword for domains you want to validate parameters before executing the requested program.</p> |
1085 |
|
1086 |
<p>If this keyword is specified, only one program specified by this keyword regardless of the mode specified by <a href="#profile_CONFIG::file::execute">CONFIG::file::execute</a>. Thus, if the pathname specified by this program cannot be executed, no programs can be executed from this domain.</p> |
1087 |
|
1088 |
<p>See also: <a href="#domain_policy_task_denied_execute_handler">task denied_execute_handler</a> <a href="#profile_CONFIG::file::execute">CONFIG::file::execute</a> <a href="#domain_policy_file_execute">file execute</a></p> |
1089 |
|
1090 |
<h3><a name="domain_policy_task_denied_execute_handler">task denied_execute_handler</a></h3> |
1091 |
|
1092 |
<p>This domain executes this program only when execute request was rejected and the mode of <a href="#profile_CONFIG::file::execute">CONFIG::file::execute</a> is enforcing. If this keyword is not specified and the mode of <a href="#profile_CONFIG::file::execute">CONFIG::file::execute</a> is enforcing, execute request is rejected.</p> |
1093 |
|
1094 |
<p>Exception is, if the <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> keyword is specified, task denied_execute_handler keyword is ignored.</p> |
1095 |
|
1096 |
<h3><a name="domain_policy_quota_exceeded">quota_exceeded</a></h3> |
1097 |
|
1098 |
<p>This keyword indicates that this domain has failed to append entry in learning mode since the number of entries reached to the limit specified by <a href="#profile_PREFERENCE">PREFERENCE</a> keyword. You need to reduce the number of entries for this domain by tuning policy.</p> |
1099 |
|
1100 |
<p>See also: <a href="#profile_PREFERENCE">PREFERENCE</a></p> |
1101 |
|
1102 |
<h3><a name="domain_policy_transition_failed">transition_failed</a></h3> |
1103 |
|
1104 |
<p>This keyword indicates that some process in this domain was not able to transit to new domain when processing the execute request.</p> |
1105 |
|
1106 |
<p>If this domain was assigned a profile with <a href="#profile_CONFIG::file::execute">CONFIG::file::execute</a>=enforcing , the execute request was rejected.</p> |
1107 |
|
1108 |
<p>Otherwise, the execute request was not rejected. In that case, the process continued execution without domain transition. Since the reason of transition failure is either "the name of the domain was too long" or "the kernel was unable to allocate memory", you need to consider "suppressing domain transitions" or "increasing memory quota" if you are planning to assign a profile with <a href="#profile_CONFIG::file::execute">CONFIG::file::execute</a>=enforcing to this domain.</p> |
1109 |
|
1110 |
<p>See also: <a href="#exception_policy_keep_domain">keep_domain</a> <a href="#memory_usage_infomation">Memory Usage Information</a></p> |
1111 |
|
1112 |
<h2><a name="exception_policy">/proc/ccs/exception_policy</a></h2> |
1113 |
|
1114 |
<p>To read or modify current exception policy, operate like below.</p> |
1115 |
<p>(Example)<br> |
1116 |
echo 'acl_group 0 file read proc:/self/stat' | ccs-loadpolicy -e<br> |
1117 |
echo 'delete acl_group 0 file read proc:/self/stat' | ccs-loadpolicy -e<br> |
1118 |
cat /proc/ccs/exception_policy</p> |
1119 |
|
1120 |
<p>See also: <a href="#policy_file_modifiers">Policy File's Modification</a></p> |
1121 |
|
1122 |
<h3><a name="exception_policy_path_group">path_group</a></h3> |
1123 |
|
1124 |
<p>To declare pathname group, use path_group keyword followed by name of the group and pathname pattern.<br> |
1125 |
For example, if you want to group all files under home directory, you can define</p> |
1126 |
|
1127 |
<table border="1"> |
1128 |
<tr><td> |
1129 |
path_group HOME-DIR-FILE /home/\*/\*<br> |
1130 |
path_group HOME-DIR-FILE /home/\*/\{\*\}/\* |
1131 |
</td></tr> |
1132 |
</table> |
1133 |
|
1134 |
<p>in the exception policy and use like</p> |
1135 |
|
1136 |
<table border="1"> |
1137 |
<tr><td> |
1138 |
file read @HOME-DIR-FILE |
1139 |
</td></tr> |
1140 |
</table> |
1141 |
|
1142 |
<p>to grant file access permission.</p> |
1143 |
|
1144 |
<h3><a name="exception_policy_number_group">number_group</a></h3> |
1145 |
|
1146 |
<p>To declare number group, use number_group keyword followed by name of the group and number ranges.<br> |
1147 |
For example, if you want to group 0644 and 0664, you can define</p> |
1148 |
|
1149 |
<table border="1"> |
1150 |
<tr><td> |
1151 |
number_group CREATE_MODES 0644<br> |
1152 |
number_group CREATE_MODES 0664 |
1153 |
</td></tr> |
1154 |
</table> |
1155 |
|
1156 |
<p>in the exception policy and use like</p> |
1157 |
|
1158 |
<table border="1"> |
1159 |
<tr><td> |
1160 |
file create /tmp/file @CREATE_MODES |
1161 |
</td></tr> |
1162 |
</table> |
1163 |
|
1164 |
<p>to grant access permission.</p> |
1165 |
|
1166 |
<h3><a name="exception_policy_address_group">address_group</a></h3> |
1167 |
|
1168 |
<p>To declare address group, use address_group keyword followed by name of the group and IP address pattern.<br> |
1169 |
For example, if you want to group all local addresses, you can define</p> |
1170 |
|
1171 |
<table border="1"> |
1172 |
<tr><td> |
1173 |
address_group local-address 10.0.0.0-10.255.255.255<br> |
1174 |
address_group local-address 172.16.0.0-172.31.255.255<br> |
1175 |
address_group local-address 192.168.0.0-192.168.255.255 |
1176 |
</td></tr> |
1177 |
</table> |
1178 |
|
1179 |
<p>in the exception policy and use like</p> |
1180 |
|
1181 |
<table border="1"> |
1182 |
<tr><td> |
1183 |
network inet stream accept @local-address 1024-65535 |
1184 |
</td></tr> |
1185 |
</table> |
1186 |
|
1187 |
<p>to grant network access permission.</p> |
1188 |
|
1189 |
<h3><a name="exception_policy_acl_group">acl_group</a></h3> |
1190 |
|
1191 |
<p>To specify group entry which is referenced by domain policy's use_group keyword, use acl_group keyword followed by group number and entry which can be used in domain policy.</p> |
1192 |
<p>For example, "acl_group 0 file read /dev/null" will allow domains with "use_group 0" to open /dev/null for reading.</p> |
1193 |
|
1194 |
<h3><a name="exception_policy_aggregator">aggregator</a></h3> |
1195 |
|
1196 |
<p>To deal multiple programs as a single program, use aggregator keyword followed by name of original program and aggregated program. This keyword is intended to aggregate similar programs.</p> |
1197 |
<p>For example, /usr/bin/tac and /bin/cat are similar. By specifying "aggregator /usr/bin/tac /bin/cat", you can run /usr/bin/tac in the domain for /bin/cat .</p> |
1198 |
|
1199 |
<p>See also: <a href="#domain_policy_file_execute">file execute</a></p> |
1200 |
|
1201 |
<h3><a name="exception_policy_initialize_domain">initialize_domain</a></h3> |
1202 |
|
1203 |
<p>To initialize domain transition when specific program is executed, use initialize_domain directive.</p> |
1204 |
|
1205 |
<ul> |
1206 |
<li>initialize_domain "program" from "domain" |
1207 |
<li>initialize_domain "program" from "the last program part of domain" |
1208 |
<li>initialize_domain "program" from any |
1209 |
</ul> |
1210 |
|
1211 |
<p>If the "domain" doesn't start with "<kernel>", the entry is applied to all domain whose domainname ends with "the last program part of domain".</p> |
1212 |
|
1213 |
<p>This directive is intended to aggregate domain transitions for daemon program and program that are invoked by the kernel on demand, by transiting to different domain.</p> |
1214 |
|
1215 |
<p>See also: <a href="#domain_transition">Domain Transition</a> <a href="#exception_policy_no_initialize_domain">no_initialize_domain</a></p> |
1216 |
|
1217 |
<h3><a name="exception_policy_no_initialize_domain">no_initialize_domain</a></h3> |
1218 |
|
1219 |
<p>To deny the effect of "initialize_domain" directive, use "no_initialize_domain" directive.</p> |
1220 |
|
1221 |
<ul> |
1222 |
<li>no_initialize_domain "program" from "domain" |
1223 |
<li>no_initialize_domain "program" from "the last program part of domain" |
1224 |
<li>no_initialize_domain "program" from any |
1225 |
</ul> |
1226 |
|
1227 |
<p>Use this directive when you don't want to initialize domain transition.</p> |
1228 |
|
1229 |
<p>See also: <a href="#domain_transition">Domain Transition</a> <a href="#exception_policy_initialize_domain">initialize_domain</a></p> |
1230 |
|
1231 |
<h3><a name="exception_policy_keep_domain">keep_domain</a></h3> |
1232 |
|
1233 |
<p>To prevent domain transition when program is executed from specific domain, use keep_domain directive.</p> |
1234 |
|
1235 |
<ul> |
1236 |
<li>keep_domain "program" from "domain" |
1237 |
<li>keep_domain "program" from "the last program part of domain" |
1238 |
<li>keep_domain any from "domain" |
1239 |
<li>keep_domain any from "the last program part of domain" |
1240 |
</ul> |
1241 |
|
1242 |
<p>If the "domain" doesn't start with "<kernel>", the entry is applied to all domain whose domainname ends with "the last program part of domain".</p> |
1243 |
|
1244 |
<p>This directive is intended to reduce total number of domains and memory usage by suppressing unneeded domain transitions.</p> |
1245 |
|
1246 |
<p>See also: <a href="#domain_transition">Domain Transition</a> <a href="#exception_policy_no_keep_domain">no_keep_domain</a></p> |
1247 |
|
1248 |
<h3><a name="exception_policy_no_keep_domain">no_keep_domain</a></h3> |
1249 |
|
1250 |
<p>To deny the effect of "keep_domain" directive, use "no_keep_domain" directive.</p> |
1251 |
|
1252 |
<ul> |
1253 |
<li>no_keep_domain "program" from "domain" |
1254 |
<li>no_keep_domain "program" from "the last program part of domain" |
1255 |
<li>no_keep_domain any from "domain" |
1256 |
<li>no_keep_domain any from "the last program part of domain" |
1257 |
</ul> |
1258 |
|
1259 |
<p>Use this directive when you want to escape from a domain that is kept by "keep_domain" directive.</p> |
1260 |
|
1261 |
<p>See also: <a href="#domain_transition">Domain Transition</a> <a href="#exception_policy_keep_domain">keep_domain</a></p> |
1262 |
|
1263 |
<h3><a name="exception_policy_deny_autobind">deny_autobind</a></h3> |
1264 |
|
1265 |
<p>To prevent specific local port from being selected automatically, use deny_autobind keyword followed by local port number.<br> |
1266 |
This keyword is intended to prevent specific local port from being bound for temporary use. For example, some proxy server uses local port 8080, so port 8080 should not be bound by other programs for temporary use.</p> |
1267 |
|
1268 |
<p>(Example)<br> |
1269 |
deny_autobind 1-1023<br> |
1270 |
deny_autobind 8080</p> |
1271 |
|
1272 |
<h2><a name="query">/proc/ccs/query</a></h2> |
1273 |
|
1274 |
<p>This file is used to manually grant or reject individual access requests when the policy violation occurs in enforcing mode. If a policy violation occur in a process whose domain is assigned a profile for enforcing mode, the administrator can judge interactively using "ccs-queryd" command.</p> |
1275 |
|
1276 |
<h2><a name="manager">/proc/ccs/manager</a></h2> |
1277 |
|
1278 |
<p>This file is used to read or append the list of programs or domains that can write to /proc/ccs/ interface.</p> |
1279 |
|
1280 |
<h3><a name="manager_manage_by_non_root">manage_by_non_root</a></h3> |
1281 |
|
1282 |
<p>By default, only processes with both UID = 0 and EUID = 0 can modify policy via /proc/ccs/ interface. You can use this keyword to allow policy modification by non root user.</p> |
1283 |
|
1284 |
<h2><a name=".domain_status">/proc/ccs/.domain_status</a></h2> |
1285 |
|
1286 |
<p>This is a view (of a DBMS) that contains only profile number and domainnames of domain so that "setprofile" command can do line-oriented processing easily.</p> |
1287 |
|
1288 |
<h2><a name="meminfo">/proc/ccs/meminfo</a></h2> |
1289 |
|
1290 |
<p>This file is to show the total RAM used to keep policy in the kernel by TOMOYO Linux.</p> |
1291 |
<p>(Example)<br> |
1292 |
cat /proc/ccs/meminfo<br></p> |
1293 |
|
1294 |
<h2><a name="grant_log">/proc/ccs/grant_log</a></h2> |
1295 |
|
1296 |
<p>This file holds the granted log. The reader process returns immediately if no granted logs exists. To wait until a granted log is generated, use select(2) for readability. The max number of logs that the kernel can hold is limited to max_grant_log parameter of PREFERENCE, so read out timely.</p> |
1297 |
<p>(Example)<br> |
1298 |
cat /proc/ccs/grant_log</p> |
1299 |
|
1300 |
<h2><a name="reject_log">/proc/ccs/reject_log</a></h2> |
1301 |
|
1302 |
<p>This file holds the rejected log. The reader process returns immediately if no violation logs exists. To wait until a violation log is generated, use select(2) for readability. The max number of logs that the kernel can hold is limited to max_reject_log parameter of PREFERENCE, so read out timely.</p> |
1303 |
<p>(Example)<br> |
1304 |
cat /proc/ccs/reject_log</p> |
1305 |
|
1306 |
<h2><a name="self_domain">/proc/ccs/self_domain</a></h2> |
1307 |
|
1308 |
<p>This file is to show the name of domain the caller process belongs to.</p> |
1309 |
<p>(Example)<br> |
1310 |
cat /proc/ccs/self_domain</p> |
1311 |
|
1312 |
<h2><a name=".process_status">/proc/ccs/.process_status</a></h2> |
1313 |
|
1314 |
<p>This file is used by "ccs-pstree" command to show "list of processes currently running" and "domains which each process belongs to" and "profile number which the domain is currently assigned" like "pstree" command. This file is writable by programs that aren't registered as policy manager.</p> |
1315 |
|
1316 |
<h2><a name="version">/proc/ccs/version</a></h2> |
1317 |
|
1318 |
<p>This file is used for getting TOMOYO Linux's version.</p> |
1319 |
<p>(Example)<br> |
1320 |
cat /proc/ccs/version</p> |
1321 |
|
1322 |
<h1>6. <a name="Advanced_Features">Advanced Features</a></h1> |
1323 |
|
1324 |
<h2>6.1 <a name="non_root_policy_update">Allowing policy modification by non root user.</a></h2> |
1325 |
|
1326 |
<p>By default, only processes with both UID = 0 and EUID = 0 can modify policy via /proc/ccs/ interface. But if you want to permit policy modification via /proc/ccs/ interface by non root user, you can write this keyword like</p> |
1327 |
|
1328 |
<table border="1"> |
1329 |
<tr><td> |
1330 |
# echo manage_by_non_root | /usr/sbin/ccs-loadpolicy -m |
1331 |
</td></tr> |
1332 |
</table> |
1333 |
|
1334 |
<p>to disable UID and EUID checks. Also, you can write this keyword like</p> |
1335 |
|
1336 |
<table border="1"> |
1337 |
<tr><td> |
1338 |
# echo delete manage_by_non_root | /usr/sbin/ccs-loadpolicy -m |
1339 |
</td></tr> |
1340 |
</table> |
1341 |
|
1342 |
<p>to enable UID and EUID checks again. Use chown/chmod as needed since the owner of /proc/ccs/ interface is root.<br> |
1343 |
To be able to do this steps, /sbin/ccs-init also executes /etc/ccs/ccs-post-init if /etc/ccs/ccs-post-init is executable. Therefore, to allow access to /proc/ccs/ interface by user demo, create /etc/ccs/ccs-post-init with</p> |
1344 |
|
1345 |
<table border="1"> |
1346 |
<tr><td> |
1347 |
#! /bin/sh<br> |
1348 |
echo manage_by_non_root > /proc/ccs/manager<br> |
1349 |
chown -R demo /proc/ccs/ |
1350 |
</td></tr> |
1351 |
</table> |
1352 |
|
1353 |
<p>and initialize like</p> |
1354 |
|
1355 |
<table border="1"> |
1356 |
<tr><td> |
1357 |
# chmod 755 /etc/ccs/ccs-post-init<br> |
1358 |
# chown -R demo /etc/ccs/ |
1359 |
</td></tr> |
1360 |
</table> |
1361 |
|
1362 |
<p>Then, user demo will be able to access policy directories and policy editors.</p> |
1363 |
|
1364 |
<h2>6.2 <a name="conditional_acl">Using conditional ACL.</a></h2> |
1365 |
|
1366 |
<p>You can add conditions (e.g. UID and GID) as needed. The condition clause are appended to the tail of each permission.</p> |
1367 |
|
1368 |
<table border="1"> |
1369 |
<tr><td>Example</td><td>Meaning</td></tr> |
1370 |
<tr><td>file read /etc/passwd</td><td>Allow opening /etc/passwd for reading.</td></tr> |
1371 |
<tr><td>file read /etc/passwd task.uid=0</td><td>Allow opening /etc/passwd for reading only if the process's UID is 0.</td></tr> |
1372 |
<tr><td>file read /etc/passwd task.uid!=0</td><td>Allow opening /etc/passwd for reading only if the process's UID is not 0.</td></tr> |
1373 |
<tr><td>network inet stream connect 10.0.0.1 80</td><td>Allow connecting TCP socket to 10.0.0.1 port 80.</td></tr> |
1374 |
<tr><td>network inet stream connect 10.0.0.1 80 task.uid=100</td><td>Allow connecting TCP socket to 10.0.0.1 port 80 only if the process's UID is 100.</td></tr> |
1375 |
<tr><td>capability SYS_PTRACE</td><td>Allow using ptrace(2) syscall.</td></tr> |
1376 |
<tr><td>capability SYS_PTRACE task.ppid=1 task.uid=0 task.euid=0</td><td>Allow using ptrace(2) syscall only if the parent process is /sbin/init and the process's UID is 0 and the process's EUID is 0.</td></tr> |
1377 |
</table> |
1378 |
|
1379 |
<p>The following variables are available.</p> |
1380 |
|
1381 |
<table border="1"> |
1382 |
<tr><td>Variable</td><td>Meaning</td></tr> |
1383 |
<tr><td>task.uid</td><td>UID of current process</td></tr> |
1384 |
<tr><td>task.euid</td><td>Effective UID of current process</td></tr> |
1385 |
<tr><td>task.suid</td><td>Saved UID of current process</td></tr> |
1386 |
<tr><td>task.fsuid</td><td>File System UID of current process</td></tr> |
1387 |
<tr><td>task.gid</td><td>GID of current process</td></tr> |
1388 |
<tr><td>task.egid</td><td>Effective GID of current process</td></tr> |
1389 |
<tr><td>task.sgid</td><td>Saved GID of current process</td></tr> |
1390 |
<tr><td>task.fsgid</td><td>File System GID of current process</td></tr> |
1391 |
<tr><td>task.pid</td><td>PID of current process</td></tr> |
1392 |
<tr><td>task.ppid</td><td>PID of parent process</td></tr> |
1393 |
<tr><td>path1.uid</td><td>UID of object.</td></tr> |
1394 |
<tr><td>path1.gid</td><td>GID of object.</td></tr> |
1395 |
<tr><td>path1.ino</td><td>i-node number of object.</td></tr> |
1396 |
<tr><td>path1.parent.uid</td><td>UID of object's parent directory.</td></tr> |
1397 |
<tr><td>path1.parent.gid</td><td>GID of object's parent directory.</td></tr> |
1398 |
<tr><td>path1.parent.ino</td><td>i-node number of object's parent directory.</td></tr> |
1399 |
<tr><td>path2.parent.uid</td><td>UID of object's parent directory.</td></tr> |
1400 |
<tr><td>path2.parent.gid</td><td>GID of object's parent directory.</td></tr> |
1401 |
<tr><td>path2.parent.ino</td><td>i-node number of object's parent directory.</td></tr> |
1402 |
</table> |
1403 |
|
1404 |
<p>"path1" corresponds to the first pathname of operations that requires pathnames, and "path2" corresponds to the second pathname of operations that requires pathnames. For example, the case of "<a href="#domain_policy_file_rename">file rename</a> file1 file2", path1 corresponds to file1 and path2 corresponds to file2.</p> |
1405 |
|
1406 |
<p>"path1" except "path1.parent" is not available for pathnames that don't exist. Thus, you can't use when creating pathnames (such as <a href="#domain_policy_file_create">file create</a> keyword).</p> |
1407 |
|
1408 |
<p>"path1.parent" is always available.</p> |
1409 |
|
1410 |
<p>"path2.parent" is available only for operations that require 2 pathnames (i.e. <a href="#domain_policy_file_link">file link</a> and <a href="#domain_policy_file_rename">file rename</a> keywords).</p> |
1411 |
|
1412 |
<p>"path2" is available only for mount operations.</p> |
1413 |
|
1414 |
<p>"path1" is not supported when accessing via "sysctl" (i.e. accessing files under /proc/sys/ directories using "sysctl" instead for "open").</p> |
1415 |
|
1416 |
<h3>The following variables and conditions are available for <a href="#domain_policy_file_execute">file execute</a> keyword.</h3> |
1417 |
|
1418 |
<table border="1"> |
1419 |
<tr><td>Variable</td><td>Meaning</td></tr> |
1420 |
<tr><td>exec.realpath</td><td>Dereferenced pathname of the requested program.</td></tr> |
1421 |
<tr><td>exec.argc</td><td>Number of argv[] passed for execute request.</td></tr> |
1422 |
<tr><td>exec.envc</td><td>Number of envp[] passed for execute request.</td></tr></table> |
1423 |
|
1424 |
<table border="1"> |
1425 |
<tr><td>Condition</td><td>Meaning</td></tr> |
1426 |
<tr><td>exec.realpath="value"</td><td>Dereferenced pathname of the requested program matches "value".</td></tr> |
1427 |
<tr><td>exec.realpath!="value"</td><td>Dereferenced pathname of the requested program does not match "value".</td></tr> |
1428 |
<tr><td>exec.argv[index]="value"</td><td>argv[index] (where 0 <= index < exec.argc) matches "value".</td></tr> |
1429 |
<tr><td>exec.argv[index]!="value"</td><td>argv[index] (where 0 <= index < exec.argc) does not match "value".</td></tr> |
1430 |
<tr><td>exec.envp["name"]="value"</td><td>Environment variable "name" is defined and matches "value".</td></tr> |
1431 |
<tr><td>exec.envp["name"]!="value"</td><td>Environment variable "name" is not defined or does not match "value".</td></tr> |
1432 |
<tr><td>exec.envp["name"]!=NULL</td><td>Environment variable "name" is defined.</td></tr> |
1433 |
<tr><td>exec.envp["name"]=NULL</td><td>Environment variable "name" is not defined.</td></tr> |
1434 |
</table> |
1435 |
|
1436 |
<h3>The following conditions are also available.</h3> |
1437 |
|
1438 |
<h4>Type of process</h4> |
1439 |
|
1440 |
<table border="1"> |
1441 |
<tr><td>Condition</td><td>Meaning</td></tr> |
1442 |
<tr><td>task.type=execute_handler</td><td>Current process is a program specified by execute_handler keyword.</td></tr> |
1443 |
<tr><td>task.type!=execute_handler</td><td>Current process is not a program specified by execute_handler keyword.</td></tr> |
1444 |
</table> |
1445 |
|
1446 |
<h4>Type of file.</h4> |
1447 |
|
1448 |
<table border="1"> |
1449 |
<tr><td>Condition</td><td>Meaning</td></tr> |
1450 |
<tr><td>path1.type=file</td><td>path1 is a regular file.</td></tr> |
1451 |
<tr><td>path1.type=directory</td><td>path1 is a directory.</td></tr> |
1452 |
<tr><td>path1.type=fifo</td><td>path1 is a FIFO.</td></tr> |
1453 |
<tr><td>path1.type=socket</td><td>path1 is a socket.</td></tr> |
1454 |
<tr><td>path1.type=symlink</td><td>path1 is a symbolic link.</td></tr> |
1455 |
<tr><td>path1.type=block</td><td>path1 is a block device file.</td></tr> |
1456 |
<tr><td>path1.type=char</td><td>path1 is a character device file.</td></tr> |
1457 |
<tr><td>path1.type!=file</td><td>path1 is not a regular file.</td></tr> |
1458 |
<tr><td>path1.type!=directory</td><td>path1 is not a directory.</td></tr> |
1459 |
<tr><td>path1.type!=fifo</td><td>path1 is not a FIFO.</td></tr> |
1460 |
<tr><td>path1.type!=socket</td><td>path1 is not a socket.</td></tr> |
1461 |
<tr><td>path1.type!=symlink</td><td>path1 is not a symbolic link.</td></tr> |
1462 |
<tr><td>path1.type!=block</td><td>path1 is not a block device file.</td></tr> |
1463 |
<tr><td>path1.type!=char</td><td>path1 is not a character device file.</td></tr></table> |
1464 |
|
1465 |
<p>Since path1.parent and path2.parent are always directory, TOMOYO Linux does not support path1.parent and path2.parent for type of file.</p> |
1466 |
|
1467 |
<h4>Device numbers of a device file where the file resides.</h4> |
1468 |
|
1469 |
<table border="1"> |
1470 |
<tr><td>Condition</td><td>Meaning</td></tr> |
1471 |
<tr><td>path1.major=num1-num2</td><td>Device major number of a device file which path1 resides is between num1 and num2.</td></tr> |
1472 |
<tr><td>path1.minor=num1-num2</td><td>Device minor number of a device file which path1 resides is between num1 and num2.</td></tr> |
1473 |
<tr><td>path1.major!=num1-num2</td><td>Device major number of a device file which path1 resides is not between num1 and num2.</td></tr> |
1474 |
<tr><td>path1.minor!=num1-num2</td><td>Device minor number of a device file which path1 resides is not between num1 and num2.</td></tr> |
1475 |
</table> |
1476 |
|
1477 |
<p>Since a device file where path1.parent and path2.parent reside is always same as the device file where path1 resides (because cross device operation is not permitted), TOMOYO Linux does not support path1.parent and path2.parent for device numbers.</p> |
1478 |
|
1479 |
<p>If num1 and num2 is the same value, you can omit -num2 part.</p> |
1480 |
|
1481 |
<h4>Device numbers of the device file itself.</h4> |
1482 |
|
1483 |
<table border="1"> |
1484 |
<tr><td>Condition</td><td>Meaning</td></tr> |
1485 |
<tr><td>path1.dev_major=num1-num2</td><td>Device file's major number is between num1 and num2.</td></tr> |
1486 |
<tr><td>path1.dev_minor=num1-num2</td><td>Device file's minor number is between num1 and num2.</td></tr> |
1487 |
<tr><td>path1.dev_major!=num1-num2</td><td>Device file's major number is not between num1 and num2.</td></tr> |
1488 |
<tr><td>path1.dev_minor!=num1-num2</td><td>Device file's minor number is not between num1 and num2.</td></tr> |
1489 |
</table> |
1490 |
|
1491 |
<p>These conditions are valid only for path1.type=block or path1.type=char cases.</p> |
1492 |
|
1493 |
<p>If num1 and num2 is the same value, you can omit -num2 part.</p> |
1494 |
|
1495 |
<h4>DAC's permissions</h4> |
1496 |
|
1497 |
<table border="1"> |
1498 |
<tr><td>Condition</td><td>Meaning</td></tr> |
1499 |
<tr><td>path1.perm=num1-num2</td><td>path1's permission is between num1 and num2.</td></tr> |
1500 |
<tr><td>path1.perm!=num1-num2</td><td>path1's permission is not between num1 and num2.</td></tr> |
1501 |
<tr><td>path1.perm=setuid</td><td>path1's setuid bit is on.</td></tr> |
1502 |
<tr><td>path1.perm!=setuid</td><td>path1's setuid bit is off.</td></tr> |
1503 |
<tr><td>path1.perm=setgid</td><td>path1's setgid bit is on.</td></tr> |
1504 |
<tr><td>path1.perm!=setgid</td><td>path1's setgid bit is off.</td></tr> |
1505 |
<tr><td>path1.perm=sticky</td><td>path1's sticky bit is on.</td></tr> |
1506 |
<tr><td>path1.perm!=sticky</td><td>path1's sticky bit is off.</td></tr> |
1507 |
<tr><td>path1.perm=owner_read</td><td>path1's owner read bit is on.</td></tr> |
1508 |
<tr><td>path1.perm!=owner_read</td><td>path1's owner read bit is off.</td></tr> |
1509 |
<tr><td>path1.perm=owner_write</td><td>path1's owner write bit is on.</td></tr> |
1510 |
<tr><td>path1.perm!=owner_write</td><td>path1's owner write bit is off.</td></tr> |
1511 |
<tr><td>path1.perm=owner_execute</td><td>path1's owner execute bit is on.</td></tr> |
1512 |
<tr><td>path1.perm!=owner_execute</td><td>path1's owner execute bit is off.</td></tr> |
1513 |
<tr><td>path1.perm=group_read</td><td>path1's group read bit is on.</td></tr> |
1514 |
<tr><td>path1.perm!=group_read</td><td>path1's group read bit is off.</td></tr> |
1515 |
<tr><td>path1.perm=group_write</td><td>path1's group write bit is on.</td></tr> |
1516 |
<tr><td>path1.perm!=group_write</td><td>path1's group write bit is off.</td></tr> |
1517 |
<tr><td>path1.perm=group_execute</td><td>path1's group execute bit is on.</td></tr> |
1518 |
<tr><td>path1.perm!=group_execute</td><td>path1's group execute bit is off.</td></tr> |
1519 |
<tr><td>path1.perm=others_read</td><td>path1's others read bit is on.</td></tr> |
1520 |
<tr><td>path1.perm!=others_read</td><td>path1's others read bit is off.</td></tr> |
1521 |
<tr><td>path1.perm=others_write</td><td>path1's others write bit is on.</td></tr> |
1522 |
<tr><td>path1.perm!=others_write</td><td>path1's others write bit is off.</td></tr> |
1523 |
<tr><td>path1.perm=others_execute</td><td>path1's others execute bit is on.</td></tr> |
1524 |
<tr><td>path1.perm!=others_execute</td><td>path1's others execute bit is off.</td></tr> |
1525 |
</table> |
1526 |
|
1527 |
<p>These conditions are applicable for path1.parent and path2.parent as well as path1 .</p> |
1528 |
|
1529 |
<p>If num1 and num2 is the same value, you can omit -num2 part.</p> |
1530 |
|
1531 |
<p>To specify value in octal format, start from 0 (e.g. path1.perm=0644 ).</p> |
1532 |
|
1533 |
<h4>Example:</h4> |
1534 |
|
1535 |
<ul> |
1536 |
<li>file append /dev/null path1.type=char path1.major=1 path1.minor=3 path1.perm=0666 |
1537 |
</ul> |
1538 |
|
1539 |
<p>will allow opening /dev/null for reading and writing only if /dev/null's type is character device file and /dev/null's major number is 1 and /dev/null's minor number is 3 and /dev/null's permission is 0666.</p> |
1540 |
|
1541 |
<h3>The following conditions for <a href="#domain_policy_file_symlink">file symlink</a> keyword are also available.</h3> |
1542 |
|
1543 |
<table border="1"> |
1544 |
<tr><td>Condition</td><td>Meaning</td></tr> |
1545 |
<tr><td>symlink.target="value"</td><td>The content of a symlink to be created matches "value".</td></tr> |
1546 |
<tr><td>symlink.target!="value"</td><td>The content of a symlink to be created does not match "value".</td></tr> |
1547 |
</table> |
1548 |
|
1549 |
<h2>6.3 <a name="transit_on_match">Domain transition upon ACL match.</a></h2> |
1550 |
|
1551 |
<p>There are cases you wish to change the range of accessible resources depending on the client's IP address. To support such cases, you can perform domain transition automatically when an access request matched an ACL entry.</a></p> |
1552 |
|
1553 |
<p>To perform domain transition upon match, append auto_domain_transition= part after an ACL.</p> |
1554 |
|
1555 |
<table border="1"> |
1556 |
<tr><td>Example</td><td>Meaning</td></tr> |
1557 |
<tr><td>network inet stream accept @TRUSTED_HOSTS 1024-65535 auto_domain_transition="//trusted_hosts"</td><td>If a TCP connection is accepted from an IP address included in an address group @TRUSTED_HOSTS, transit to a domain which the domainnname is concatenation of current domain's domainname + "//trusted_hosts".</td></tr> |
1558 |
<tr><td>network inet stream accept @UNTRUSTED_HOSTS 1024-65535 auto_domain_transition="//untrusted_hosts"</td><td>If a TCP connection is accepted from an IP address included in an address group @UNTRUSTED_HOSTS, transit to a domain which the domainnname is concatenation of current domain's domainname + "//untrusted_hosts".</td></tr> |
1559 |
</table> |
1560 |
|
1561 |
<p>When using the auto_domain_transition= part, please be careful with the following points.</p> |
1562 |
|
1563 |
<ul> |
1564 |
<li>If the domain transition to a domain specified by auto_domain_transition= part failed, the process will be forcibly terminated.</li> |
1565 |
<li>The domain transition specified by auto_domain_transition= part is performed when the access request is permitted by the policy. Thus, situations that the access request was not processed although the domain transition was performed can happen because of errors after checking the policy (e.g. out of memory).</li> |
1566 |
<li>If an IP address is included in both @TRUSTED_HOSTS and @UNTRUSTED_HOSTS, the permission which matched first is used. So, be careful with using order dependent policy.</li> |
1567 |
</ul> |
1568 |
|
1569 |
<h2>6.4 <a name="sleep_penalty">Sleep penalty for policy violation.</a></h2> |
1570 |
|
1571 |
<p>You can make the process which violated policy in enforcing mode sleep for specified period.</p> |
1572 |
|
1573 |
<table border="1"> |
1574 |
<tr><td>Example of /proc/ccs/profile</td><td>Meaning</td></tr> |
1575 |
<tr><td>3-PREFERENCE={ enforcing_penalty=1 }</td><td>Make the process which violated policy in enforcing mode and which belongs to a domain with profile 3 sleep for 0.1 second.</td></tr> |
1576 |
<tr><td>4-PREFERENCE={ enforcing_penalty = 10 }</td><td>Make the process which violated policy in enforcing mode and which belongs to a domain with profile 4 sleep for 1 second.</td></tr> |
1577 |
</table> |
1578 |
|
1579 |
<p>This feature is a safeguard to avoid that the CPU usage remains 100% when policy violation occurs in an infinite loop. Usually, making processes sleep for 0.1 second is enough.</p> |
1580 |
|
1581 |
<p>This feature is not applied against network's receive operation so that attackers cannot make services sleep for long time (in other words, delay your system's response) by intentionally sending TCP connection requests and UDP packets from unwanted sources.</p> |
1582 |
|
1583 |
<h2>6.5 <a name="auto_execute_handler">Judging execute request outside the kernel.</a></h2> |
1584 |
|
1585 |
<p>Basically, TOMOYO Linux controls whether to execute a program or not according to the domain policy. You can check parameters using exec.argv and exec.envp described in <a href="#conditional_acl">Using conditional ACL.</a> But this approach support only simple pattern matching and you need to specify what programs are permitted to be executed beforehand.</p> |
1586 |
|
1587 |
<p>Therefore, TOMOYO Linux supports a mechanism named <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a>. If this mechanism is used, the kernel no longer controls whether to execute a requested program or not, and the kernel merely executes the program specified by <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a>, and the program specified by <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> determines whether to execute the requested program or not, and the program specified by <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> executes the requested program only if the program specified by <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> considers it is appropriate.</p> |
1588 |
|
1589 |
<p>In Linux, the behavior "execute a program" means "overwrite the process which requested to execute a program with the requested program's image" and "the process which requested to execute a program cannot regain control if the execute request was succeeded". Therefore, the process which requested to execute a program can receive a notification only when the execute request was failed.<br> |
1590 |
For example, let's consider a situation where a process running as program-A attempts to execute program-B.<br> |
1591 |
When the process running as program-A requests the execution of program-B, the kernel checks the domain policy for "whether it is appropriate to execute program-B from a process running as program-A or not" and the kernel overwrites the process running as program-A with program-B if the kernel considers it is appropriate, and the kernel doesn't overwrite the process running as program-A with program-B and notifies the process running as program-A that execution of program-B is not permitted if the kernel considers it is not appropriate.</p> |
1592 |
|
1593 |
<p>When <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> is specified, a different program program-C specified as task auto_execute_handler mediates this behavior.<br> |
1594 |
When the process running as program-A requests the execution of program-B, the kernel overwrites the process running as program-A with program-C to let the program-C judge whether it is appropriate to execute program-B from a process running as program-A or not. |
1595 |
The process now running as program-C determines whether it is appropriate to execute program-B from a process running as program-A or not, and the process now running as program-C requests the execution of program-B (and the kernel will overwrite the process now running as program-C with program-B) if the process now running as program-C considers it is appropriate, and the process now running as program-C terminates without executing program-B if the process now running as program-C considers it is not appropriate.</p> |
1596 |
|
1597 |
<p>As stated above, this mechanism has a side effect that it becomes impossible to notify the process running as program-A that the requested program (i.e. program-B) was not executed since program-C abandons a mean to notify the process running as program-A that the execute request of program-B was not accepted.<br> |
1598 |
But, even if <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> is not specified, there are various factors that cause "the execute request was accepted but the program terminated before starting the expected behavior" such as "the process was unable to read shared libraries", "the process received KILL signal", "the system became out of memory and the process was killed by OOM killer". In other words, there are uncertainties between "the execute request did not fail" and "the executed program starts the expected behavior".<br> |
1599 |
Viewing in this light, there is no guarantee that "the program starts expected behavior unless the process receives a notification that the execution of the program failed" from the beginning. And, it is possible to say that it is an acceptable result that the program-C specified by <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> failed to notify the process previously running as program-A that the execution of program-B failed.</p> |
1600 |
|
1601 |
<p>TOMOYO Linux's assumes that the administrator knows what programs needs to be executed from what programs beforehand and permits execution of minimal programs. Thus, assuming that unexpected execute request which are not permitted by policy won't occur as long as the system is running properly, it is OK to accept all execute requests. If an execute request that should not be accepted occurs, you can take different actions such as terminating the process instead of rejecting the request by using <a href="#domain_policy_task_denied_execute_handler">task denied_execute_handler</a> mechanism. So, you don't have to let the kernel judge whether to execute the program or not alone.</p> |
1602 |
|
1603 |
<p>Thus, you can let external userland program judge whether to execute the requested program or not occurred from a domain by specifying <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> keyword to the domain.</p> |
1604 |
<p>If you try to judge inside the kernel, there are few library functions available and it is more likely to fail when allocating contiguous memory area. But if you try to judge outside the kernel, there are many library functions available and it is less likely to fail when allocating contiguous memory area, and you can do more detailed checking. So, you can let external userland program specified by <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> keyword examine parameters and let the program execute the requested program only if parameters are appropriate.</p> |
1605 |
|
1606 |
<p>The side effect of this approach is that there is no mean to notify the process that the execute request was not accepted when it is not appropriate to execute the requested program. But since you can freely customize the program for <a href="#domain_policy_task_auto_execute_handler">task auto_execute_handler</a> keyword, you can even judge using ssh to ask remotely.</p> |
1607 |
|
1608 |
<p>To use this feature, specify like below.</p> |
1609 |
|
1610 |
<table border="1"> |
1611 |
<tr><td>Example of /proc/ccs/domain_policy</td><td>Meaning</td></tr> |
1612 |
<tr><td>task auto_execute_handler /usr/sbin/check-and-exec</td><td>Whenever a process which belongs to this domain requests execution of a program, execute /usr/sbin/check-and-exec instead for the requested program. /usr/sbin/check-and-exec checks parameters and executes the requested program if /usr/sbin/check-and-exec considers it is appropriate to execute.</td></tr> |
1613 |
</table> |
1614 |
|
1615 |
<p>The program specified by task auto_execute_handler keyword receives the following parameters. Compare with file execute log described in <a href="#access_logs">Access Logs</a>.</p> |
1616 |
|
1617 |
<ul> |
1618 |
<li>argv[0] contains the pathname of the program specified by task auto_execute_handler keyword.</li> |
1619 |
<li>argv[1] contains the name of the domain which the process which issued an execute request belongs to.</li> |
1620 |
<li>argv[2] contains the name of the program which the process which issued an execute request.</li> |
1621 |
<li>argv[3] contains information of the process which the process which issued an execute request.</li> |
1622 |
<li>argv[4] contains the name of the program which was requested by the process.</li> |
1623 |
<li>argv[5] contains the number of arguments.</li> |
1624 |
<li>argv[6] contains the number of environment variables.</li> |
1625 |
<li>From argv[7] to argv[6 + argc] contains the arguments.</li> |
1626 |
<li>From argv[7 + argc] to argv [6 + argc + envc] contains the environment variables.</li> |
1627 |
<li>All environment variables are cleared for safety.</li> |
1628 |
<li>Other resources such as standard input/output are inherited.</li> |
1629 |
</ul> |
1630 |
|
1631 |
<p>Be careful with the following notes when you use this feature.</p> |
1632 |
|
1633 |
<ul> |
1634 |
<li>You need not to and should not give execute permission (<a href="#domain_policy_file_execute">file execute</a> keyword) to the program specified by task auto_execute_handler keyword.</li> |
1635 |
<li>This mechanism can't work if a process cannot access the program specified by task auto_execute_handler keyword because the process is running inside a chroot environment. Since it is dangerous to allow execution of programs outside the chroot environment, the program specified by task auto_execute_handler keyword is searched from the current process's / directory rather than the current process's namespace's / directory.</li> |
1636 |
<li>This mechanism can't work if the domain for the program specified for task auto_execute_handler keyword doesn't exist. So, you need to prepare domains by (for example) creating a domain for the program specified by task auto_execute_handler keyword just under the <kernel> and mark the program specified by task auto_execute_handler keyword using <a href="#exception_policy_initialize_domain">initialize_domain</a> keyword.</li> |
1637 |
<li>The program specified by task auto_execute_handler keyword is invoked with all environment variables cleared so that the program won't be affected by some dangerous environment variables (e.g. LD_PRELOAD). This means that even environment variable PATH is not set, so please be careful when executing external programs. Also, I recommend you to assign profile for enforcing mode against the domain for the program specified by task auto_execute_handler keyword.</li> |
1638 |
</ul> |
1639 |
|
1640 |
<p>A source code named audit-exec-param.c is included as a sample program of how to use this mechanism in the ccs-tools source package. You can customize freely.</p> |
1641 |
<p>This mechanism is just providing a hook. How to utilize this hook is up to you.</p> |
1642 |
|
1643 |
<h2>6.6 <a name="denied_execute_handler">Invoking alternative program for execute requests that are not permitted by policy.</a></h2> |
1644 |
|
1645 |
<p>TOMOYO Linux's approach is "know what programs needs to be executed from what programs beforehand and create policy that permits execution of minimal programs". Thus, you can not only reject unnecessary execution requests but also do different behavior.</p> |
1646 |
|
1647 |
<p>By default, if an execute request of a program which is not permitted by file execute keyword occurs in enforcing mode, the kernel rejects the execute request. But assuming that you know what programs needs to be executed from what programs beforehand, an execute request of a program which is not permitted by file execute keyword will not occur as long as the process is keeping control, and you can regard that the process is not keeping control (in other words, the process already lost control) if such request occurs.</p> |
1648 |
|
1649 |
<p>Attackers steal control of a process by attacking security holes such as buffer overflow and attempt to execute commands such as shells. If the process does not need to execute the shell (in other words, you needn't to give permission like "file execute /bin/bash"), it is considered that the process has already lost control at the moment of the execution request of shells.</p> |
1650 |
|
1651 |
<p>Normally, when execution of a program which is not permitted by the policy is requested, the kernel merely reject the request. But it is unlikely that the process gets back control (in other words, the process resumes proper operations) by just rejecting the request if the request is issued by the process that has lost control.<br> |
1652 |
In Linux, "execute a program" means that the current process is overwritten by the requested program and transfer control to the requested program. This means that a process gets back control by overwriting the process with different program even if the process has lost control because of buffer overflow.</p> |
1653 |
|
1654 |
<p>The control of a process which has once lost control by the attacker and is overwritten by a program requested by the attacker depends on the program used for overwriting. If a program like shells is executed, the control remains on the attacker's side (in other words, the owner of the process) because shells accept whatever the user requested. But if a program which terminates silently (e.g. /bin/true) is executed, the control will not remains on the attacker's side because the process owned by the attacker will terminate immediately.</p> |
1655 |
|
1656 |
<p>As described above, an event that "an execute request of an unnecessary program is issued by an attacker" depending on how you look at it. You can consider that "the attacker is giving the system a chance to get back control on the system's side".<br> |
1657 |
Thus, TOMOYO Linux provides a mechanism that executes different program instead of merely rejecting the request when an execute request of a program which is not permitted by policy occurs. How to utilize this mechanism is up to you.</p> |
1658 |
|
1659 |
<p>For example, you can replace the execute request of a program which is not permitted by the policy with /bin/true so that the process which requested the execution of a program which is not permitted by the policy will terminate immediately.</p> |
1660 |
|
1661 |
<p>For example, you can replace the execute request of shells with a honey pot client's program and observe what requests the attacker issues.</p> |
1662 |
|
1663 |
<p>For example, you can forcibly terminate the login session.</p> |
1664 |
|
1665 |
<p>For example, you can show warning message like "You are not permitted to execute this program." which is similar to Ubuntu's command-not-found package (which tells the user in what package the requested command is included).</p> |
1666 |
|
1667 |
<p>For example, you can change a firewall's configuration if you succeeded to derive the IP address of the attacker.</p> |
1668 |
|
1669 |
<p>To use this feature, specify like below.</p> |
1670 |
|
1671 |
<table border="1"> |
1672 |
<tr><td>Example of /proc/ccs/profile</td><td>Example of /proc/ccs/domain_policy</td><td>Meaning</td></tr> |
1673 |
<tr><td>3-CONFIG::file::execute=enforcing</td><td>use_profile 3<br>task denied_execute_handler /bin/true</td><td>If a process which belongs to a domain with profile 3 requested execution of a program which is not permitted by the domain policy, execute /bin/true instead of rejecting the execute request.</td></tr> |
1674 |
</table> |
1675 |
|
1676 |
<p>Notes on this feature is the same as <a href="#auto_execute_handler">Judging execute request outside the kernel.</a></p> |
1677 |
|
1678 |
<hr> |
1679 |
|
1680 |
<p><a href="index.html.en">Return to index page.</a></p> |
1681 |
<p><a href="http://sourceforge.jp/"><img src="http://sourceforge.jp/sflogo.php?group_id=1973" width="96" height="31" alt="SourceForge.jp"></a></p> |
1682 |
</body> |
1683 |
</html> |