1 |
Notes for TOMOYO Linux project |
Notes for TOMOYO Linux project |
2 |
|
|
3 |
This is a handy Mandatory Access Control patch for Linux kernels. |
This is a handy Mandatory Access Control patch for Linux kernels. |
4 |
This patch is released under the GPL. |
This patch is released under the GPLv2. |
5 |
|
|
6 |
Project URL: http://tomoyo.sourceforge.jp/ |
Project URL: http://tomoyo.sourceforge.jp/ |
7 |
|
|
1146 |
|
|
1147 |
Fix 2008/02/05 |
Fix 2008/02/05 |
1148 |
|
|
1149 |
@ Use find_task_by_vpid() instead of find_task_pid(). |
@ Use find_task_by_vpid() instead of find_task_by_pid(). |
1150 |
|
|
1151 |
Kernel 2.6.24 introduced PID namespace. |
Kernel 2.6.24 introduced PID namespace. |
1152 |
To search PID given from userland, the kernel needs to use |
To search PID given from userland, the kernel needs to use |
1153 |
find_task_by_vpid() instead of find_task_pid(). |
find_task_by_vpid() instead of find_task_by_pid(). |
1154 |
|
|
1155 |
Fix 2008/02/14 |
Fix 2008/02/14 |
1156 |
|
|
1203 |
I made "(current->uid == 0 && current->euid == 0)" requirement optional. |
I made "(current->uid == 0 && current->euid == 0)" requirement optional. |
1204 |
If this requirement is disabled, only "conventional DAC permission |
If this requirement is disabled, only "conventional DAC permission |
1205 |
checks" and "/proc/ccs/manager checks" are used. |
checks" and "/proc/ccs/manager checks" are used. |
1206 |
|
|
1207 |
|
Fix 2008/02/29 |
1208 |
|
|
1209 |
|
@ Add sleep_on_violation feature. |
1210 |
|
|
1211 |
|
Some exploit codes (e.g. trans2open for Samba) continue running |
1212 |
|
until it achieves the purpose of the exploit code (e.g. invoke /bin/sh). |
1213 |
|
|
1214 |
|
If such code is injected due to buffer overflow but the kernel |
1215 |
|
rejects the request, it triggers infinite "Permission denied" loop. |
1216 |
|
As a result, the CPU usage becomes 100% and gives bad effects to |
1217 |
|
the rest of processes. |
1218 |
|
This is a side effect of rejecting the request from the exploit code |
1219 |
|
which wouldn't happen if the request from the exploit code was granted. |
1220 |
|
|
1221 |
|
To avoid such CPU consumption, I added a penalty that forcibly |
1222 |
|
sleeps for specified period when a request is rejected. |
1223 |
|
|
1224 |
|
This penalty doesn't work if the exploit code does nothing but |
1225 |
|
continue running, but I think most exploit code's purpose is |
1226 |
|
to start some program rather than to slow down the target system. |
1227 |
|
|
1228 |
|
@ Add alt_exec feature. |
1229 |
|
|
1230 |
|
Since TOMOYO Linux's approach is "know all essential requests in advance |
1231 |
|
and create policy that permits only them", you can regard anomalous |
1232 |
|
requests as attacks (if you want to do so). |
1233 |
|
|
1234 |
|
Common MAC implementations merely reject requests that violate policy. |
1235 |
|
But I added a special handler for execve() to TOMOYO Linux. |
1236 |
|
|
1237 |
|
This handler is triggered when a process requested to execute a program |
1238 |
|
but the request was rejected by the policy. |
1239 |
|
This handler executes a program specified by the administrator |
1240 |
|
instead of a program requested by the process. |
1241 |
|
|
1242 |
|
Most attackers attempt to execute /bin/sh to start something malicious. |
1243 |
|
Attackers execute an exploit code using buffer overflow vulnerability |
1244 |
|
to steal control of a process. But this handler can get back control |
1245 |
|
if an exploit code requests execve() that is not permitted by policy. |
1246 |
|
|
1247 |
|
By default, this handler does nothing (i.e. merely reject execve() |
1248 |
|
request). You can specify any program to start what you want to do. |
1249 |
|
|
1250 |
|
You can redirect attackers to somewhere else (e.g. honey pot). |
1251 |
|
This makes it possible to act your Linux box as an on-demand honey pot |
1252 |
|
while keeping regular services for your usage. |
1253 |
|
|
1254 |
|
You can collect information of the attacker (e.g. IP address) and |
1255 |
|
update firewall configuration. |
1256 |
|
|
1257 |
|
You can silently terminate a process who requested execve() |
1258 |
|
that is not permitted by policy. |
1259 |
|
|
1260 |
|
Fix 2008/03/03 |
1261 |
|
|
1262 |
|
@ Add "force_alt_exec" keyword. |
1263 |
|
|
1264 |
|
To be able to fully utilize "alt_exec" feature, |
1265 |
|
I added "force_alt_exec" keyword so that |
1266 |
|
all execute requests are replaced by the execute request of a program |
1267 |
|
specified by alt_exec feature. |
1268 |
|
|
1269 |
|
If this keyword is specified for a domain, the domain no longer |
1270 |
|
executes any programs regardless of the mode of file access control |
1271 |
|
(i.e. the domain won't execute even if MAC_FOR_FILE=0 ). |
1272 |
|
Instead, the domain executes the program specified by alt_exec feature |
1273 |
|
and the program specified by alt_exec feature validates the execute |
1274 |
|
request and executes it if it is appropriate to execute. |
1275 |
|
|
1276 |
|
If you can tolerate that there is no chance to return an error code |
1277 |
|
to the caller to tell the execute request was rejected, |
1278 |
|
this is more flexible approach than in-kernel execve() parameter |
1279 |
|
checking because we can do argv[] and envp[] checking easily. |
1280 |
|
|
1281 |
|
Fix 2008/03/04 |
1282 |
|
|
1283 |
|
@ Use string for access control mode. |
1284 |
|
|
1285 |
|
An integer expression for access control mode sometimes confuses |
1286 |
|
administrators because profile number is also an integer expression. |
1287 |
|
To avoid confusion between profile number and access control mode, |
1288 |
|
I introduced a string expression for access control mode. |
1289 |
|
|
1290 |
|
Modes which take an integer between 0 and 3. |
1291 |
|
|
1292 |
|
0 -> disabled |
1293 |
|
1 -> learning |
1294 |
|
2 -> permissive |
1295 |
|
3 -> enforcing |
1296 |
|
|
1297 |
|
Modes which take 0 or 1. |
1298 |
|
|
1299 |
|
0 -> disabled |
1300 |
|
1 -> enabled |
1301 |
|
|
1302 |
|
Fix 2008/03/10 |
1303 |
|
|
1304 |
|
@ Rename "force_alt_exec" keyword to "execute_handler". |
1305 |
|
|
1306 |
|
To be able to use different programs for validating execve() parameters, |
1307 |
|
I moved the location to specify the program's pathname from profile |
1308 |
|
to domain policy. |
1309 |
|
|
1310 |
|
The "execute_handler" keyword takes one pathname which is |
1311 |
|
invoked whenever execve() request is issued. Thus, any "allow_execute" |
1312 |
|
keywords in a domain with "execute_handler" are ignored. |
1313 |
|
This keyword is designed for validating expected/desirable execve() |
1314 |
|
requests in userspace, although there is no way to tell the caller |
1315 |
|
that the execve() request was rejected. |
1316 |
|
|
1317 |
|
@ Rename "alt_exec" keyword to "denied_execute_handler". |
1318 |
|
|
1319 |
|
The "denied_execute_handler" keyword takes one pathname which is |
1320 |
|
invoked only when execve() request was rejected. In other words, |
1321 |
|
this program is invoked only when the following conditions are met. |
1322 |
|
|
1323 |
|
(1) None of "allow_execute" keywords in the domain matched. |
1324 |
|
(2) The execve() request was rejected in enforcing mode. |
1325 |
|
(3) "execute_handler" keyword is not used by the domain. |
1326 |
|
|
1327 |
|
This keyword is designed for handling unexpected/undesirable execve() |
1328 |
|
requests, to redirect the process issuing such requests to somewhere. |
1329 |
|
|
1330 |
|
Fix 2008/03/18 |
1331 |
|
|
1332 |
|
@ Fix wrong/redundant locks in pre-vfs functions. |
1333 |
|
|
1334 |
|
lock_kernel()/unlock_kernel() in pre_vfs_rename() were redundant for |
1335 |
|
2.6 kernels. |
1336 |
|
|
1337 |
|
Locking order in pre_vfs_link() and pre_vfs_unlink() for 2.4 kernels |
1338 |
|
after 2.4.33 were different from before 2.4.32 . |
1339 |
|
|
1340 |
|
Fix 2008/03/28 |
1341 |
|
|
1342 |
|
@ Disable execute handler loop. |
1343 |
|
|
1344 |
|
To be able to use "execute_handler" in a "keep_domain" domain, |
1345 |
|
ignore "execute_handler" and "denied_execute_handler" keywords |
1346 |
|
if the current process is executing programs specified by |
1347 |
|
"execute_handler" or "denied_execute_handler" keyword. |
1348 |
|
|
1349 |
|
This exception is needed to avoid infinite execute handler loop. |
1350 |
|
If a domain has both "keep_domain" and "execute_handler", |
1351 |
|
any execute request by that domain is handled by an execute handler, |
1352 |
|
and the execute handler attempts to process original execute request. |
1353 |
|
But the original execute request is handled by the same execute handler |
1354 |
|
unless the execute handler ignores "execute_handler". |
1355 |
|
|
1356 |
|
@ Update coding style. |
1357 |
|
|
1358 |
|
I rewrote the code to pass scripts/checkpatch.pl as much as possible. |
1359 |
|
Function names were changed to use only lower letters. |
1360 |
|
|
1361 |
|
Version 1.6.0 2008/04/01 Feature enhancement release. |
1362 |
|
|
1363 |
|
Fix 2008/04/14 |
1364 |
|
|
1365 |
|
@ Fix "Compilation failures" and "Initialization ordering bugs" |
1366 |
|
with kernels before 2.4.30/2.6.11 . |
1367 |
|
|
1368 |
|
2.6 kernels before 2.6.9 didn't have include/linux/hardirq.h , |
1369 |
|
resulting compilation error at #include <linux/hardirq.h> . |
1370 |
|
I added #elif condition. |
1371 |
|
|
1372 |
|
CentOS 4.6's 2.6.9 kernel calls do_execve() before initialization of |
1373 |
|
ccs_alloc(), resulting NULL pointer dereference. |
1374 |
|
I changed __initcall to core_initcall. |
1375 |
|
|
1376 |
|
CentOS 4.6's 2.6.9 kernel backported kzalloc() from 2.6.14 , |
1377 |
|
resulting compilation error at kzalloc(). |
1378 |
|
I modified prototype of kzalloc(). |
1379 |
|
|
1380 |
|
Fix 2008/04/20 |
1381 |
|
|
1382 |
|
@ Fix "Compilation failures" with kernels before 2.4.30/2.6.11 . |
1383 |
|
|
1384 |
|
Turbolinux 10 Server's 2.6.8 kernel backported kzalloc() as an inlined |
1385 |
|
function, resulting compilation error at kzalloc(). |
1386 |
|
I converted kzalloc() from an inlined function into a macro. |
1387 |
|
|
1388 |
|
Fix 2008/04/21 |
1389 |
|
|
1390 |
|
@ Add workaround for gcc 3.2.2's inline bug. |
1391 |
|
|
1392 |
|
RedHat Linux 9's gcc 3.2.2 generated a bad code |
1393 |
|
if ((var_of_u8 & 0x000000BF) & 0x80000000) { } |
1394 |
|
where the expected code is |
1395 |
|
if ((var_of_u8 & 0xBF) & 0x80) { } |
1396 |
|
when embedding ccs_acl_type2() into print_entry(), |
1397 |
|
resulting runtime BUG(). |
1398 |
|
I added the expected code explicitly as a workaround. |
1399 |
|
|
1400 |
|
Fix 2008/05/06 |
1401 |
|
|
1402 |
|
@ Add memory quota. |
1403 |
|
|
1404 |
|
1.5.x returns -ENOMEM when FindNextDomain() failed to create a new |
1405 |
|
domain, but I forgot to return -ENOMEM when find_next_domain() failed to |
1406 |
|
create a new domain. |
1407 |
|
|
1408 |
|
A domain is automatically created by find_next_domain() only if |
1409 |
|
the domain for the requested program doesn't exist. |
1410 |
|
This behavior is for the administrator's convenience. |
1411 |
|
The administrator needn't to know how many domains are needed for running |
1412 |
|
the whole programs in the system beforehand when developing the policy. |
1413 |
|
But the administrator does not want the kernel to reject execution of the |
1414 |
|
requested program when developing the policy. |
1415 |
|
|
1416 |
|
So, I think it is better to grant execution of programs even if |
1417 |
|
find_next_domain() failed to create a new domain than reject execution. |
1418 |
|
Thus, I decided not to return -ENOMEM when find_next_domain() failed to |
1419 |
|
create a new domain. This exception breaks the domain transition rules, |
1420 |
|
so I print "transition_failed" warning in /proc/ccs/domain_policy |
1421 |
|
when this exception happened. |
1422 |
|
|
1423 |
|
Also, to prevent the system from being halted by unexpectedly allocating |
1424 |
|
all kernel memory for the policy, I added memory quota. |
1425 |
|
This quota is configurable via /proc/ccs/meminfo like |
1426 |
|
|
1427 |
|
echo Shared: 1048576 > /proc/ccs/meminfo |
1428 |
|
echo Private: 1048576 > /proc/ccs/meminfo |
1429 |
|
|
1430 |
|
Version 1.6.1 2008/05/10 Bug fix release. |
1431 |
|
|
1432 |
|
Fix 2008/06/04 |
1433 |
|
|
1434 |
|
@ Check open mode of /proc/ccs/ interface. |
1435 |
|
|
1436 |
|
It turned out that I can avoid allocating memory for reading if |
1437 |
|
FMODE_READ is not set and memory for writing if FMODE_WRITE is not set. |
1438 |
|
|
1439 |
|
@ Wait for completion of /sbin/ccs-init . |
1440 |
|
|
1441 |
|
Since 2.4 kernel's call_usermodehelper() can't wait for termination of |
1442 |
|
the executed program, I was using the close() request of |
1443 |
|
/proc/ccs/meminfo to indicate that loading policy has finished. |
1444 |
|
But since /proc/ccs/meminfo could be accessed for setting memory quota |
1445 |
|
by /etc/ccs/ccs-post-init , I stopped using the close() request. |
1446 |
|
The policy loader no longer need to access /proc/ccs/meminfo to notify |
1447 |
|
the kernel that loading policy has finished. |
1448 |
|
|
1449 |
|
Fix 2008/06/05 |
1450 |
|
|
1451 |
|
@ Fix realpath for pipes and sockets. |
1452 |
|
|
1453 |
|
Kernel 2.6.22 and later use different method for calculating d_path(). |
1454 |
|
Since fs/realpath.c didn't notice the change, the realpath of pipes |
1455 |
|
appeared as "pipe:" rather than "pipe:[\$]" when they are opened via |
1456 |
|
/proc/PID/fd/ directory. |
1457 |
|
|
1458 |
|
@ Add process's information into /proc/ccs/query . |
1459 |
|
|
1460 |
|
While /proc/ccs/grant_log and /proc/ccs/reject_log contain process's |
1461 |
|
information, /proc/ccs/query doesn't contain it. |
1462 |
|
To be able to utilize ccs-queryd and ccs-notifyd more, I added it into |
1463 |
|
/proc/ccs/query . |