3 |
* |
* |
4 |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
5 |
* |
* |
6 |
* Version: 1.7.0-pre 2009/08/24 |
* Version: 1.7.0-rc 2009/09/01 |
7 |
* |
* |
8 |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
9 |
* See README.ccs for ChangeLog. |
* See README.ccs for ChangeLog. |
12 |
|
|
13 |
#include "internal.h" |
#include "internal.h" |
14 |
|
|
15 |
|
static struct ccs_profile ccs_default_profile = { |
16 |
|
.learning = &ccs_default_profile.preference, |
17 |
|
.permissive = &ccs_default_profile.preference, |
18 |
|
.enforcing = &ccs_default_profile.preference, |
19 |
|
#ifdef CONFIG_CCSECURITY_AUDIT |
20 |
|
.audit = &ccs_default_profile.preference, |
21 |
|
.preference.audit_max_grant_log = CONFIG_CCSECURITY_MAX_GRANT_LOG, |
22 |
|
.preference.audit_max_reject_log = CONFIG_CCSECURITY_MAX_REJECT_LOG, |
23 |
|
#endif |
24 |
|
.preference.enforcing_penalty = 0, |
25 |
|
.preference.enforcing_verbose = true, |
26 |
|
.preference.learning_max_entry = CONFIG_CCSECURITY_MAX_ACCEPT_ENTRY, |
27 |
|
.preference.learning_verbose = false, |
28 |
|
.preference.learning_exec_realpath = true, |
29 |
|
.preference.learning_exec_argv0 = true, |
30 |
|
.preference.learning_symlink_target = true, |
31 |
|
.preference.permissive_verbose = true |
32 |
|
}; |
33 |
|
|
34 |
/* Profile table. Memory is allocated as needed. */ |
/* Profile table. Memory is allocated as needed. */ |
35 |
static struct ccs_profile *ccs_profile_ptr[CCS_MAX_PROFILES]; |
static struct ccs_profile *ccs_profile_ptr[CCS_MAX_PROFILES]; |
36 |
|
|
264 |
if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) { |
if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) { |
265 |
ptr = entry; |
ptr = entry; |
266 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
267 |
ptr->audit_max_grant_log = CONFIG_CCSECURITY_MAX_GRANT_LOG; |
ptr->audit = &ccs_default_profile.preference; |
|
ptr->audit_max_reject_log = CONFIG_CCSECURITY_MAX_REJECT_LOG; |
|
268 |
#endif |
#endif |
269 |
ptr->enforcing_penalty = 0; |
ptr->learning = &ccs_default_profile.preference; |
270 |
ptr->learning_max_entry = CONFIG_CCSECURITY_MAX_ACCEPT_ENTRY; |
ptr->permissive = &ccs_default_profile.preference; |
271 |
ptr->enforcing_verbose = true; |
ptr->enforcing = &ccs_default_profile.preference; |
|
ptr->permissive_verbose = true; |
|
|
ptr->learning_verbose = false; |
|
|
ptr->learning_exec_realpath = true; |
|
|
ptr->learning_exec_argv0 = true; |
|
272 |
ptr->default_config = CCS_CONFIG_DISABLED | |
ptr->default_config = CCS_CONFIG_DISABLED | |
273 |
CCS_CONFIG_WANT_GRANT_LOG | CCS_CONFIG_WANT_REJECT_LOG; |
CCS_CONFIG_WANT_GRANT_LOG | CCS_CONFIG_WANT_REJECT_LOG; |
274 |
memset(ptr->config, CCS_CONFIG_USE_DEFAULT, |
memset(ptr->config, CCS_CONFIG_USE_DEFAULT, |
291 |
*/ |
*/ |
292 |
struct ccs_profile *ccs_profile(const u8 profile) |
struct ccs_profile *ccs_profile(const u8 profile) |
293 |
{ |
{ |
294 |
if (!ccs_policy_loaded) { |
struct ccs_profile *ptr = ccs_profile_ptr[profile]; |
295 |
static struct ccs_profile dummy; |
if (!ccs_policy_loaded) |
296 |
return &dummy; |
return &ccs_default_profile; |
297 |
} |
BUG_ON(!ptr); |
298 |
return ccs_profile_ptr[profile]; |
return ptr; |
299 |
} |
} |
300 |
|
|
301 |
/** |
/** |
312 |
int value; |
int value; |
313 |
int mode; |
int mode; |
314 |
u8 config; |
u8 config; |
315 |
|
bool use_default = false; |
316 |
char *cp; |
char *cp; |
317 |
struct ccs_profile *profile; |
struct ccs_profile *profile; |
318 |
i = simple_strtoul(data, &cp, 10); |
i = simple_strtoul(data, &cp, 10); |
319 |
if (data != cp) { |
if (data == cp) { |
320 |
|
profile = &ccs_default_profile; |
321 |
|
} else { |
322 |
if (*cp != '-') |
if (*cp != '-') |
323 |
return -EINVAL; |
return -EINVAL; |
324 |
data = cp + 1; |
data = cp + 1; |
325 |
|
profile = ccs_find_or_assign_new_profile(i); |
326 |
|
if (!profile) |
327 |
|
return -EINVAL; |
328 |
} |
} |
|
profile = ccs_find_or_assign_new_profile(i); |
|
|
if (!profile) |
|
|
return -EINVAL; |
|
329 |
cp = strchr(data, '='); |
cp = strchr(data, '='); |
330 |
if (!cp) |
if (!cp) |
331 |
return -EINVAL; |
return -EINVAL; |
332 |
*cp++ = '\0'; |
*cp++ = '\0'; |
333 |
if (!strcmp(data, "COMMENT")) { |
if (profile != &ccs_default_profile) |
334 |
const struct ccs_path_info *new_comment = ccs_get_name(cp); |
use_default = strstr(cp, "use_default") != NULL; |
335 |
const struct ccs_path_info *old_comment; |
if (strstr(cp, "verbose=yes")) |
336 |
/* Protect reader from ccs_put_name(). */ |
value = 1; |
337 |
spin_lock(&ccs_profile_comment_lock); |
else if (strstr(cp, "verbose=no")) |
338 |
old_comment = profile->comment; |
value = 0; |
339 |
profile->comment = new_comment; |
else |
340 |
spin_unlock(&ccs_profile_comment_lock); |
value = -1; |
|
ccs_put_name(old_comment); |
|
|
return 0; |
|
|
} |
|
341 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
342 |
if (!strcmp(data, "PREFERENCE::audit")) { |
if (!strcmp(data, "PREFERENCE::audit")) { |
343 |
char *cp2 = strstr(cp, "max_grant_log="); |
char *cp2; |
344 |
|
if (use_default) { |
345 |
|
profile->audit = &ccs_default_profile.preference; |
346 |
|
return 0; |
347 |
|
} |
348 |
|
profile->audit = &profile->preference; |
349 |
|
cp2 = strstr(cp, "max_grant_log="); |
350 |
if (cp2) |
if (cp2) |
351 |
sscanf(cp2 + 14, "%u", &profile->audit_max_grant_log); |
sscanf(cp2 + 14, "%u", |
352 |
|
&profile->preference.audit_max_grant_log); |
353 |
cp2 = strstr(cp, "max_reject_log="); |
cp2 = strstr(cp, "max_reject_log="); |
354 |
if (cp2) |
if (cp2) |
355 |
sscanf(cp2 + 15, "%u", &profile->audit_max_reject_log); |
sscanf(cp2 + 15, "%u", |
356 |
|
&profile->preference.audit_max_reject_log); |
357 |
return 0; |
return 0; |
358 |
} |
} |
359 |
#endif |
#endif |
|
if (strstr(cp, "verbose=yes")) |
|
|
value = 1; |
|
|
else if (strstr(cp, "verbose=no")) |
|
|
value = 0; |
|
|
else |
|
|
value = -1; |
|
360 |
if (!strcmp(data, "PREFERENCE::enforcing")) { |
if (!strcmp(data, "PREFERENCE::enforcing")) { |
361 |
char *cp2; |
char *cp2; |
362 |
|
if (use_default) { |
363 |
|
profile->enforcing = &ccs_default_profile.preference; |
364 |
|
return 0; |
365 |
|
} |
366 |
|
profile->enforcing = &profile->preference; |
367 |
if (value >= 0) |
if (value >= 0) |
368 |
profile->enforcing_verbose = value; |
profile->preference.enforcing_verbose = value; |
369 |
cp2 = strstr(cp, "penalty="); |
cp2 = strstr(cp, "penalty="); |
370 |
if (cp2) |
if (cp2) |
371 |
sscanf(cp2 + 8, "%u", &profile->enforcing_penalty); |
sscanf(cp2 + 8, "%u", |
372 |
|
&profile->preference.enforcing_penalty); |
373 |
return 0; |
return 0; |
374 |
} |
} |
375 |
if (!strcmp(data, "PREFERENCE::permissive")) { |
if (!strcmp(data, "PREFERENCE::permissive")) { |
376 |
|
if (use_default) { |
377 |
|
profile->permissive = &ccs_default_profile.preference; |
378 |
|
return 0; |
379 |
|
} |
380 |
|
profile->permissive = &profile->preference; |
381 |
if (value >= 0) |
if (value >= 0) |
382 |
profile->permissive_verbose = value; |
profile->preference.permissive_verbose = value; |
383 |
return 0; |
return 0; |
384 |
} |
} |
385 |
if (!strcmp(data, "PREFERENCE::learning")) { |
if (!strcmp(data, "PREFERENCE::learning")) { |
386 |
char *cp2; |
char *cp2; |
387 |
|
if (use_default) { |
388 |
|
profile->learning = &ccs_default_profile.preference; |
389 |
|
return 0; |
390 |
|
} |
391 |
|
profile->learning = &profile->preference; |
392 |
if (value >= 0) |
if (value >= 0) |
393 |
profile->learning_verbose = value; |
profile->preference.learning_verbose = value; |
394 |
cp2 = strstr(cp, "max_entry="); |
cp2 = strstr(cp, "max_entry="); |
395 |
if (cp2) |
if (cp2) |
396 |
sscanf(cp2 + 10, "%u", &profile->learning_max_entry); |
sscanf(cp2 + 10, "%u", |
397 |
|
&profile->preference.learning_max_entry); |
398 |
if (strstr(cp, "exec.realpath=yes")) |
if (strstr(cp, "exec.realpath=yes")) |
399 |
profile->learning_exec_realpath = true; |
profile->preference.learning_exec_realpath = true; |
400 |
else if (strstr(cp, "exec.realpath=no")) |
else if (strstr(cp, "exec.realpath=no")) |
401 |
profile->learning_exec_realpath = false; |
profile->preference.learning_exec_realpath = false; |
402 |
if (strstr(cp, "exec.argv0=yes")) |
if (strstr(cp, "exec.argv0=yes")) |
403 |
profile->learning_exec_argv0 = true; |
profile->preference.learning_exec_argv0 = true; |
404 |
else if (strstr(cp, "exec.argv0=no")) |
else if (strstr(cp, "exec.argv0=no")) |
405 |
profile->learning_exec_argv0 = false; |
profile->preference.learning_exec_argv0 = false; |
406 |
|
if (strstr(cp, "symlink.target=yes")) |
407 |
|
profile->preference.learning_symlink_target = true; |
408 |
|
else if (strstr(cp, "symlink.target=no")) |
409 |
|
profile->preference.learning_symlink_target = false; |
410 |
|
return 0; |
411 |
|
} |
412 |
|
if (profile == &ccs_default_profile) |
413 |
|
return -EINVAL; |
414 |
|
if (!strcmp(data, "COMMENT")) { |
415 |
|
const struct ccs_path_info *new_comment = ccs_get_name(cp); |
416 |
|
const struct ccs_path_info *old_comment; |
417 |
|
/* Protect reader from ccs_put_name(). */ |
418 |
|
spin_lock(&ccs_profile_comment_lock); |
419 |
|
old_comment = profile->comment; |
420 |
|
profile->comment = new_comment; |
421 |
|
spin_unlock(&ccs_profile_comment_lock); |
422 |
|
ccs_put_name(old_comment); |
423 |
return 0; |
return 0; |
424 |
} |
} |
425 |
if (!strcmp(data, "CONFIG")) { |
if (!strcmp(data, "CONFIG")) { |
441 |
} else { |
} else { |
442 |
return -EINVAL; |
return -EINVAL; |
443 |
} |
} |
444 |
if (strstr(cp, "use_default")) { |
if (use_default) { |
445 |
config = CCS_CONFIG_USE_DEFAULT; |
config = CCS_CONFIG_USE_DEFAULT; |
446 |
} else { |
} else { |
447 |
for (mode = 3; mode >= 0; mode--) |
for (mode = 3; mode >= 0; mode--) |
482 |
int index; |
int index; |
483 |
if (head->read_eof) |
if (head->read_eof) |
484 |
return; |
return; |
485 |
|
if (head->read_bit) |
486 |
|
goto body; |
487 |
|
ccs_io_printf(head, "PROFILE_VERSION=%s\n", "20090827"); |
488 |
|
#ifdef CONFIG_CCSECURITY_AUDIT |
489 |
|
ccs_io_printf(head, "PREFERENCE::audit={ max_grant_log=%u " |
490 |
|
"max_reject_log=%u }\n", |
491 |
|
ccs_default_profile.preference.audit_max_grant_log, |
492 |
|
ccs_default_profile.preference.audit_max_reject_log); |
493 |
|
#endif |
494 |
|
ccs_io_printf(head, "PREFERENCE::learning={ verbose=%s max_entry=%u " |
495 |
|
"exec.realpath=%s exec.argv0=%s symlink.target=%s }\n", |
496 |
|
ccs_yesno(ccs_default_profile.preference. |
497 |
|
learning_verbose), |
498 |
|
ccs_default_profile.preference.learning_max_entry, |
499 |
|
ccs_yesno(ccs_default_profile.preference. |
500 |
|
learning_exec_realpath), |
501 |
|
ccs_yesno(ccs_default_profile.preference. |
502 |
|
learning_exec_argv0), |
503 |
|
ccs_yesno(ccs_default_profile.preference. |
504 |
|
learning_symlink_target)); |
505 |
|
ccs_io_printf(head, "PREFERENCE::permissive={ verbose=%s }\n", |
506 |
|
ccs_yesno(ccs_default_profile.preference. |
507 |
|
permissive_verbose)); |
508 |
|
ccs_io_printf(head, "PREFERENCE::enforcing={ verbose=%s penalty=%u " |
509 |
|
"}\n", |
510 |
|
ccs_yesno(ccs_default_profile.preference. |
511 |
|
enforcing_verbose), |
512 |
|
ccs_default_profile.preference.enforcing_penalty); |
513 |
|
head->read_bit = 1; |
514 |
|
body: |
515 |
for (index = head->read_step; index < CCS_MAX_PROFILES; index++) { |
for (index = head->read_step; index < CCS_MAX_PROFILES; index++) { |
516 |
bool done; |
bool done; |
517 |
u8 config; |
u8 config; |
518 |
int i; |
int i; |
519 |
int pos = head->read_avail; |
int pos; |
520 |
const struct ccs_profile *profile = ccs_profile_ptr[index]; |
const struct ccs_profile *profile = ccs_profile_ptr[index]; |
521 |
head->read_step = index; |
head->read_step = index; |
522 |
if (!profile) |
if (!profile) |
523 |
continue; |
continue; |
524 |
|
pos = head->read_avail; |
525 |
spin_lock(&ccs_profile_comment_lock); |
spin_lock(&ccs_profile_comment_lock); |
526 |
done = ccs_io_printf(head, "%u-COMMENT=%s\n", index, |
done = ccs_io_printf(head, "%u-COMMENT=%s\n", index, |
527 |
profile->comment ? profile->comment->name |
profile->comment ? profile->comment->name |
567 |
ccs_mode_4[config & 3])) |
ccs_mode_4[config & 3])) |
568 |
goto out; |
goto out; |
569 |
#endif |
#endif |
|
|
|
570 |
} |
} |
571 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
572 |
if (!ccs_io_printf(head, "%u-PREFERENCE::audit={ " |
if (profile->audit != &ccs_default_profile.preference && |
573 |
|
!ccs_io_printf(head, "%u-PREFERENCE::audit={ " |
574 |
"max_grant_log=%u max_reject_log=%u }\n", |
"max_grant_log=%u max_reject_log=%u }\n", |
575 |
index, profile->audit_max_grant_log, |
index, |
576 |
profile->audit_max_reject_log)) |
profile->preference.audit_max_grant_log, |
577 |
|
profile->preference.audit_max_reject_log)) |
578 |
goto out; |
goto out; |
579 |
#endif |
#endif |
580 |
if (!ccs_io_printf(head, "%u-PREFERENCE::learning={ " |
if (profile->learning != &ccs_default_profile.preference && |
581 |
|
!ccs_io_printf(head, "%u-PREFERENCE::learning={ " |
582 |
"verbose=%s max_entry=%u exec.realpath=%s " |
"verbose=%s max_entry=%u exec.realpath=%s " |
583 |
"exec.argv0=%s }\n", index, |
"exec.argv0=%s symlink.target=%s }\n", |
584 |
ccs_yesno(profile->learning_verbose), |
index, |
585 |
profile->learning_max_entry, |
ccs_yesno(profile->preference. |
586 |
ccs_yesno(profile->learning_exec_realpath), |
learning_verbose), |
587 |
ccs_yesno(profile->learning_exec_argv0)) || |
profile->preference.learning_max_entry, |
588 |
|
ccs_yesno(profile->preference. |
589 |
|
learning_exec_realpath), |
590 |
|
ccs_yesno(profile->preference. |
591 |
|
learning_exec_argv0), |
592 |
|
ccs_yesno(profile->preference. |
593 |
|
learning_symlink_target))) |
594 |
|
goto out; |
595 |
|
if (profile->permissive != &ccs_default_profile.preference && |
596 |
!ccs_io_printf(head, "%u-PREFERENCE::permissive={ " |
!ccs_io_printf(head, "%u-PREFERENCE::permissive={ " |
597 |
"verbose=%s }\n", index, |
"verbose=%s }\n", index, |
598 |
ccs_yesno(profile->permissive_verbose)) || |
ccs_yesno(profile->preference. |
599 |
|
permissive_verbose))) |
600 |
|
goto out; |
601 |
|
if (profile->enforcing != &ccs_default_profile.preference && |
602 |
!ccs_io_printf(head, "%u-PREFERENCE::enforcing={ " |
!ccs_io_printf(head, "%u-PREFERENCE::enforcing={ " |
603 |
"verbose=%s penalty=%u }\n", index, |
"verbose=%s penalty=%u }\n", index, |
604 |
ccs_yesno(profile->enforcing_verbose), |
ccs_yesno(profile->preference. |
605 |
profile->enforcing_penalty)) |
enforcing_verbose), |
606 |
|
profile->preference.enforcing_penalty)) |
607 |
goto out; |
goto out; |
608 |
continue; |
continue; |
609 |
out: |
out: |
800 |
{ |
{ |
801 |
unsigned int pid; |
unsigned int pid; |
802 |
struct ccs_domain_info *domain = NULL; |
struct ccs_domain_info *domain = NULL; |
803 |
|
bool global_pid = false; |
804 |
if (!strcmp(data, "allow_execute")) { |
if (!strcmp(data, "allow_execute")) { |
805 |
head->read_execute_only = true; |
head->read_execute_only = true; |
806 |
return true; |
return true; |
807 |
} |
} |
808 |
if (sscanf(data, "pid=%u", &pid) == 1) { |
if (sscanf(data, "pid=%u", &pid) == 1 || |
809 |
|
(global_pid = true, sscanf(data, "global-pid=%u", &pid) == 1)) { |
810 |
struct task_struct *p; |
struct task_struct *p; |
811 |
read_lock(&tasklist_lock); |
read_lock(&tasklist_lock); |
812 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
813 |
|
if (global_pid) |
814 |
|
p = find_task_by_pid_ns(pid, &init_pid_ns); |
815 |
|
else |
816 |
|
p = find_task_by_vpid(pid); |
817 |
|
#else |
818 |
p = find_task_by_pid(pid); |
p = find_task_by_pid(pid); |
819 |
|
#endif |
820 |
if (p) |
if (p) |
821 |
domain = ccs_task_domain(p); |
domain = ccs_task_domain(p); |
822 |
read_unlock(&tasklist_lock); |
read_unlock(&tasklist_lock); |
1849 |
{ |
{ |
1850 |
char *buf = head->write_buf; |
char *buf = head->write_buf; |
1851 |
bool task_info = false; |
bool task_info = false; |
1852 |
|
bool global_pid = false; |
1853 |
unsigned int pid; |
unsigned int pid; |
1854 |
struct task_struct *p; |
struct task_struct *p; |
1855 |
struct ccs_domain_info *domain = NULL; |
struct ccs_domain_info *domain = NULL; |
1862 |
head->read_eof = true; |
head->read_eof = true; |
1863 |
if (ccs_str_starts(&buf, "info ")) |
if (ccs_str_starts(&buf, "info ")) |
1864 |
task_info = true; |
task_info = true; |
1865 |
|
if (ccs_str_starts(&buf, "global-pid ")) |
1866 |
|
global_pid = true; |
1867 |
pid = (unsigned int) simple_strtoul(buf, NULL, 10); |
pid = (unsigned int) simple_strtoul(buf, NULL, 10); |
1868 |
read_lock(&tasklist_lock); |
read_lock(&tasklist_lock); |
1869 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
1870 |
|
if (global_pid) |
1871 |
|
p = find_task_by_pid_ns(pid, &init_pid_ns); |
1872 |
|
else |
1873 |
|
p = find_task_by_vpid(pid); |
1874 |
|
#else |
1875 |
p = find_task_by_pid(pid); |
p = find_task_by_pid(pid); |
1876 |
|
#endif |
1877 |
if (p) { |
if (p) { |
1878 |
domain = ccs_task_domain(p); |
domain = ccs_task_domain(p); |
1879 |
ccs_flags = p->ccs_flags; |
ccs_flags = p->ccs_flags; |
2081 |
char *realpath = NULL; |
char *realpath = NULL; |
2082 |
char *argv0 = NULL; |
char *argv0 = NULL; |
2083 |
const struct ccs_profile *profile = ccs_profile(ee->r.domain->profile); |
const struct ccs_profile *profile = ccs_profile(ee->r.domain->profile); |
2084 |
if (profile->learning_exec_realpath) { |
if (profile->learning->learning_exec_realpath) { |
2085 |
struct file *file = ee->bprm->file; |
struct file *file = ee->bprm->file; |
2086 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) |
2087 |
struct path path = { file->f_vfsmnt, file->f_dentry }; |
struct path path = { file->f_vfsmnt, file->f_dentry }; |
2092 |
if (realpath) |
if (realpath) |
2093 |
len += strlen(realpath) + 17; |
len += strlen(realpath) + 17; |
2094 |
} |
} |
2095 |
if (profile->learning_exec_argv0) { |
if (profile->learning->learning_exec_argv0) { |
2096 |
if (ccs_get_argv0(ee)) { |
if (ccs_get_argv0(ee)) { |
2097 |
argv0 = ee->tmp; |
argv0 = ee->tmp; |
2098 |
len += strlen(argv0) + 16; |
len += strlen(argv0) + 16; |
2125 |
return cond; |
return cond; |
2126 |
} |
} |
2127 |
|
|
2128 |
|
/** |
2129 |
|
* ccs_get_symlink_condition - Get condition part for symlink requests. |
2130 |
|
* |
2131 |
|
* @r: Pointer to "struct ccs_request_info". |
2132 |
|
* |
2133 |
|
* Returns pointer to "struct ccs_condition" on success, NULL otherwise. |
2134 |
|
*/ |
2135 |
|
static struct ccs_condition *ccs_get_symlink_condition(struct ccs_request_info |
2136 |
|
*r) |
2137 |
|
{ |
2138 |
|
struct ccs_condition *cond; |
2139 |
|
char *buf; |
2140 |
|
int len = 256; |
2141 |
|
const char *symlink = NULL; |
2142 |
|
const struct ccs_profile *profile = ccs_profile(r->profile); |
2143 |
|
if (profile->learning->learning_symlink_target) { |
2144 |
|
symlink = r->obj->symlink_target->name; |
2145 |
|
len += strlen(symlink) + 18; |
2146 |
|
} |
2147 |
|
buf = kmalloc(len, GFP_KERNEL); |
2148 |
|
if (!buf) |
2149 |
|
return NULL; |
2150 |
|
snprintf(buf, len - 1, "if"); |
2151 |
|
if (current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER) { |
2152 |
|
const int pos = strlen(buf); |
2153 |
|
snprintf(buf + pos, len - pos - 1, |
2154 |
|
" task.type=execute_handler"); |
2155 |
|
} |
2156 |
|
if (symlink) { |
2157 |
|
const int pos = strlen(buf); |
2158 |
|
snprintf(buf + pos, len - pos - 1, " symlink.target=\"%s\"", |
2159 |
|
symlink); |
2160 |
|
} |
2161 |
|
cond = ccs_get_condition(buf); |
2162 |
|
kfree(buf); |
2163 |
|
return cond; |
2164 |
|
} |
2165 |
|
|
2166 |
/* Wait queue for ccs_query_list. */ |
/* Wait queue for ccs_query_list. */ |
2167 |
static DECLARE_WAIT_QUEUE_HEAD(ccs_query_wait); |
static DECLARE_WAIT_QUEUE_HEAD(ccs_query_wait); |
2168 |
|
|
2226 |
ccs_normalize_line(buffer); |
ccs_normalize_line(buffer); |
2227 |
if (r->ee && !strncmp(buffer, "allow_execute ", 14)) |
if (r->ee && !strncmp(buffer, "allow_execute ", 14)) |
2228 |
cond = ccs_get_execute_condition(r->ee); |
cond = ccs_get_execute_condition(r->ee); |
2229 |
|
else if (r->obj && r->obj->symlink_target) |
2230 |
|
cond = ccs_get_symlink_condition(r); |
2231 |
else if ((current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER)) { |
else if ((current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER)) { |
2232 |
char str[] = "if task.type=execute_handler"; |
char str[] = "if task.type=execute_handler"; |
2233 |
cond = ccs_get_condition(str); |
cond = ccs_get_condition(str); |
2244 |
int i; |
int i; |
2245 |
if (current->ccs_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR) |
if (current->ccs_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR) |
2246 |
return -EPERM; |
return -EPERM; |
2247 |
for (i = 0; i < ccs_profile(r->domain->profile)-> |
for (i = 0; i < ccs_profile(r->domain->profile)->enforcing-> |
2248 |
enforcing_penalty; i++) { |
enforcing_penalty; i++) { |
2249 |
set_current_state(TASK_INTERRUPTIBLE); |
set_current_state(TASK_INTERRUPTIBLE); |
2250 |
schedule_timeout(HZ / 10); |
schedule_timeout(HZ / 10); |
2470 |
{ |
{ |
2471 |
if (head->read_eof) |
if (head->read_eof) |
2472 |
return; |
return; |
2473 |
ccs_io_printf(head, "1.7.0-pre"); |
ccs_io_printf(head, "1.7.0-rc"); |
2474 |
head->read_eof = true; |
head->read_eof = true; |
2475 |
} |
} |
2476 |
|
|