3 |
* |
* |
4 |
* Copyright (C) 2005-2010 NTT DATA CORPORATION |
* Copyright (C) 2005-2010 NTT DATA CORPORATION |
5 |
* |
* |
6 |
* Version: 1.7.2+ 2010/07/21 |
* Version: 1.8.0-pre 2010/08/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. |
13 |
#include "internal.h" |
#include "internal.h" |
14 |
|
|
15 |
static struct ccs_profile ccs_default_profile = { |
static struct ccs_profile ccs_default_profile = { |
|
.learning = &ccs_default_profile.preference, |
|
|
.permissive = &ccs_default_profile.preference, |
|
|
.enforcing = &ccs_default_profile.preference, |
|
|
.audit = &ccs_default_profile.preference, |
|
16 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
17 |
.preference.audit_max_grant_log = CONFIG_CCSECURITY_MAX_GRANT_LOG, |
.preference.audit_max_grant_log = CONFIG_CCSECURITY_MAX_GRANT_LOG, |
18 |
.preference.audit_max_reject_log = CONFIG_CCSECURITY_MAX_REJECT_LOG, |
.preference.audit_max_reject_log = CONFIG_CCSECURITY_MAX_REJECT_LOG, |
20 |
.preference.audit_task_info = true, |
.preference.audit_task_info = true, |
21 |
.preference.audit_path_info = true, |
.preference.audit_path_info = true, |
22 |
.preference.enforcing_penalty = 0, |
.preference.enforcing_penalty = 0, |
|
.preference.enforcing_verbose = true, |
|
23 |
.preference.learning_max_entry = CONFIG_CCSECURITY_MAX_ACCEPT_ENTRY, |
.preference.learning_max_entry = CONFIG_CCSECURITY_MAX_ACCEPT_ENTRY, |
|
.preference.learning_verbose = false, |
|
24 |
.preference.learning_exec_realpath = true, |
.preference.learning_exec_realpath = true, |
25 |
.preference.learning_exec_argv0 = true, |
.preference.learning_exec_argv0 = true, |
26 |
.preference.learning_symlink_target = true, |
.preference.learning_symlink_target = true, |
|
.preference.permissive_verbose = true |
|
27 |
}; |
}; |
28 |
|
|
29 |
/* Profile version. Currently only 20090903 is defined. */ |
/* Profile version. Currently only 20090903 is defined. */ |
92 |
= "file::transit", |
= "file::transit", |
93 |
[CCS_MAC_ENVIRON] |
[CCS_MAC_ENVIRON] |
94 |
= "misc::env", |
= "misc::env", |
95 |
[CCS_MAC_NETWORK_TCP_BIND] |
[CCS_MAC_NETWORK_INET_TCP_BIND] |
96 |
= "network::inet_tcp_bind", |
= "network::inet_tcp_bind", |
97 |
[CCS_MAC_NETWORK_TCP_LISTEN] |
[CCS_MAC_NETWORK_INET_TCP_LISTEN] |
98 |
= "network::inet_tcp_listen", |
= "network::inet_tcp_listen", |
99 |
[CCS_MAC_NETWORK_TCP_CONNECT] |
[CCS_MAC_NETWORK_INET_TCP_CONNECT] |
100 |
= "network::inet_tcp_connect", |
= "network::inet_tcp_connect", |
101 |
[CCS_MAC_NETWORK_TCP_ACCEPT] |
[CCS_MAC_NETWORK_INET_TCP_ACCEPT] |
102 |
= "network::inet_tcp_accept", |
= "network::inet_tcp_accept", |
103 |
[CCS_MAC_NETWORK_UDP_BIND] |
[CCS_MAC_NETWORK_INET_UDP_BIND] |
104 |
= "network::inet_udp_bind", |
= "network::inet_udp_bind", |
105 |
[CCS_MAC_NETWORK_UDP_SEND] |
[CCS_MAC_NETWORK_INET_UDP_SEND] |
106 |
= "network::inet_udp_send", |
= "network::inet_udp_send", |
107 |
[CCS_MAC_NETWORK_UDP_RECV] |
[CCS_MAC_NETWORK_INET_UDP_RECV] |
108 |
= "network::inet_udp_recv", |
= "network::inet_udp_recv", |
109 |
[CCS_MAC_NETWORK_RAW_BIND] |
[CCS_MAC_NETWORK_INET_RAW_BIND] |
110 |
= "network::inet_raw_bind", |
= "network::inet_raw_bind", |
111 |
[CCS_MAC_NETWORK_RAW_SEND] |
[CCS_MAC_NETWORK_INET_RAW_SEND] |
112 |
= "network::inet_raw_send", |
= "network::inet_raw_send", |
113 |
[CCS_MAC_NETWORK_RAW_RECV] |
[CCS_MAC_NETWORK_INET_RAW_RECV] |
114 |
= "network::inet_raw_recv", |
= "network::inet_raw_recv", |
115 |
|
[CCS_MAC_NETWORK_UNIX_STREAM_BIND] |
116 |
|
= "network::unix_stream_bind", |
117 |
|
[CCS_MAC_NETWORK_UNIX_STREAM_LISTEN] |
118 |
|
= "network::unix_stream_listen", |
119 |
|
[CCS_MAC_NETWORK_UNIX_STREAM_CONNECT] |
120 |
|
= "network::unix_stream_connect", |
121 |
|
[CCS_MAC_NETWORK_UNIX_STREAM_ACCEPT] |
122 |
|
= "network::unix_stream_accept", |
123 |
|
[CCS_MAC_NETWORK_UNIX_DGRAM_BIND] |
124 |
|
= "network::unix_dgram_bind", |
125 |
|
[CCS_MAC_NETWORK_UNIX_DGRAM_SEND] |
126 |
|
= "network::unix_dgram_send", |
127 |
|
[CCS_MAC_NETWORK_UNIX_DGRAM_RECV] |
128 |
|
= "network::unix_dgram_recv", |
129 |
|
[CCS_MAC_NETWORK_UNIX_SEQPACKET_BIND] |
130 |
|
= "network::unix_seqpacket_bind", |
131 |
|
[CCS_MAC_NETWORK_UNIX_SEQPACKET_LISTEN] |
132 |
|
= "network::unix_seqpacket_listen", |
133 |
|
[CCS_MAC_NETWORK_UNIX_SEQPACKET_CONNECT] |
134 |
|
= "network::unix_seqpacket_connect", |
135 |
|
[CCS_MAC_NETWORK_UNIX_SEQPACKET_ACCEPT] |
136 |
|
= "network::unix_seqpacket_accept", |
137 |
[CCS_MAC_SIGNAL] |
[CCS_MAC_SIGNAL] |
138 |
= "ipc::signal", |
= "ipc::signal", |
|
[CCS_MAX_MAC_INDEX + CCS_INET_STREAM_SOCKET_CREATE] |
|
|
= "capability::inet_tcp_create", |
|
|
[CCS_MAX_MAC_INDEX + CCS_INET_STREAM_SOCKET_LISTEN] |
|
|
= "capability::inet_tcp_listen", |
|
|
[CCS_MAX_MAC_INDEX + CCS_INET_STREAM_SOCKET_CONNECT] |
|
|
= "capability::inet_tcp_connect", |
|
|
[CCS_MAX_MAC_INDEX + CCS_USE_INET_DGRAM_SOCKET] |
|
|
= "capability::use_inet_udp", |
|
|
[CCS_MAX_MAC_INDEX + CCS_USE_INET_RAW_SOCKET] |
|
|
= "capability::use_inet_ip", |
|
139 |
[CCS_MAX_MAC_INDEX + CCS_USE_ROUTE_SOCKET] |
[CCS_MAX_MAC_INDEX + CCS_USE_ROUTE_SOCKET] |
140 |
= "capability::use_route", |
= "capability::use_route", |
141 |
[CCS_MAX_MAC_INDEX + CCS_USE_PACKET_SOCKET] |
[CCS_MAX_MAC_INDEX + CCS_USE_PACKET_SOCKET] |
142 |
= "capability::use_packet", |
= "capability::use_packet", |
|
[CCS_MAX_MAC_INDEX + CCS_SYS_MOUNT] |
|
|
= "capability::SYS_MOUNT", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_UMOUNT] |
|
|
= "capability::SYS_UMOUNT", |
|
143 |
[CCS_MAX_MAC_INDEX + CCS_SYS_REBOOT] |
[CCS_MAX_MAC_INDEX + CCS_SYS_REBOOT] |
144 |
= "capability::SYS_REBOOT", |
= "capability::SYS_REBOOT", |
|
[CCS_MAX_MAC_INDEX + CCS_SYS_CHROOT] |
|
|
= "capability::SYS_CHROOT", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_KILL] |
|
|
= "capability::SYS_KILL", |
|
145 |
[CCS_MAX_MAC_INDEX + CCS_SYS_VHANGUP] |
[CCS_MAX_MAC_INDEX + CCS_SYS_VHANGUP] |
146 |
= "capability::SYS_VHANGUP", |
= "capability::SYS_VHANGUP", |
147 |
[CCS_MAX_MAC_INDEX + CCS_SYS_SETTIME] |
[CCS_MAX_MAC_INDEX + CCS_SYS_SETTIME] |
152 |
= "capability::SYS_SETHOSTNAME", |
= "capability::SYS_SETHOSTNAME", |
153 |
[CCS_MAX_MAC_INDEX + CCS_USE_KERNEL_MODULE] |
[CCS_MAX_MAC_INDEX + CCS_USE_KERNEL_MODULE] |
154 |
= "capability::use_kernel_module", |
= "capability::use_kernel_module", |
|
[CCS_MAX_MAC_INDEX + CCS_CREATE_FIFO] |
|
|
= "capability::create_fifo", |
|
|
[CCS_MAX_MAC_INDEX + CCS_CREATE_BLOCK_DEV] |
|
|
= "capability::create_block_dev", |
|
|
[CCS_MAX_MAC_INDEX + CCS_CREATE_CHAR_DEV] |
|
|
= "capability::create_char_dev", |
|
|
[CCS_MAX_MAC_INDEX + CCS_CREATE_UNIX_SOCKET] |
|
|
= "capability::create_unix_socket", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_LINK] |
|
|
= "capability::SYS_LINK", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_SYMLINK] |
|
|
= "capability::SYS_SYMLINK", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_RENAME] |
|
|
= "capability::SYS_RENAME", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_UNLINK] |
|
|
= "capability::SYS_UNLINK", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_CHMOD] |
|
|
= "capability::SYS_CHMOD", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_CHOWN] |
|
|
= "capability::SYS_CHOWN", |
|
|
[CCS_MAX_MAC_INDEX + CCS_SYS_IOCTL] |
|
|
= "capability::SYS_IOCTL", |
|
155 |
[CCS_MAX_MAC_INDEX + CCS_SYS_KEXEC_LOAD] |
[CCS_MAX_MAC_INDEX + CCS_SYS_KEXEC_LOAD] |
156 |
= "capability::SYS_KEXEC_LOAD", |
= "capability::SYS_KEXEC_LOAD", |
|
[CCS_MAX_MAC_INDEX + CCS_SYS_PIVOT_ROOT] |
|
|
= "capability::SYS_PIVOT_ROOT", |
|
157 |
[CCS_MAX_MAC_INDEX + CCS_SYS_PTRACE] |
[CCS_MAX_MAC_INDEX + CCS_SYS_PTRACE] |
158 |
= "capability::SYS_PTRACE", |
= "capability::SYS_PTRACE", |
|
[CCS_MAX_MAC_INDEX + CCS_CONCEAL_MOUNT] |
|
|
= "capability::conceal_mount", |
|
159 |
[CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX |
[CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX |
160 |
+ CCS_MAC_CATEGORY_FILE] = "file", |
+ CCS_MAC_CATEGORY_FILE] = "file", |
161 |
[CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX |
[CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX |
323 |
ptr = ccs_profile_ptr[profile]; |
ptr = ccs_profile_ptr[profile]; |
324 |
if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) { |
if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) { |
325 |
ptr = entry; |
ptr = entry; |
|
ptr->audit = &ccs_default_profile.preference; |
|
|
ptr->learning = &ccs_default_profile.preference; |
|
|
ptr->permissive = &ccs_default_profile.preference; |
|
|
ptr->enforcing = &ccs_default_profile.preference; |
|
326 |
ptr->default_config = CCS_CONFIG_DISABLED | |
ptr->default_config = CCS_CONFIG_DISABLED | |
327 |
|
CCS_CONFIG_VERBOSE | |
328 |
CCS_CONFIG_WANT_GRANT_LOG | CCS_CONFIG_WANT_REJECT_LOG; |
CCS_CONFIG_WANT_GRANT_LOG | CCS_CONFIG_WANT_REJECT_LOG; |
329 |
memset(ptr->config, CCS_CONFIG_USE_DEFAULT, |
memset(ptr->config, CCS_CONFIG_USE_DEFAULT, |
330 |
sizeof(ptr->config)); |
sizeof(ptr->config)); |
357 |
if (ccs_profile_version != 20090903) |
if (ccs_profile_version != 20090903) |
358 |
panic("Profile version %u is not supported.\n", |
panic("Profile version %u is not supported.\n", |
359 |
ccs_profile_version); |
ccs_profile_version); |
360 |
printk(KERN_INFO "CCSecurity: 1.7.2+ 2010/07/21\n"); |
printk(KERN_INFO "CCSecurity: 1.8.0-pre 2010/08/01\n"); |
361 |
printk(KERN_INFO "Mandatory Access Control activated.\n"); |
printk(KERN_INFO "Mandatory Access Control activated.\n"); |
362 |
} |
} |
363 |
|
|
410 |
} |
} |
411 |
|
|
412 |
static void ccs_set_pref(const char *name, const char *value, |
static void ccs_set_pref(const char *name, const char *value, |
413 |
const bool use_default, struct ccs_profile *profile) |
struct ccs_profile *profile) |
414 |
{ |
{ |
|
struct ccs_preference **pref; |
|
|
bool *verbose; |
|
415 |
if (!strcmp(name, "audit")) { |
if (!strcmp(name, "audit")) { |
|
if (use_default) { |
|
|
pref = &profile->audit; |
|
|
goto set_default; |
|
|
} |
|
|
profile->audit = &profile->preference; |
|
416 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
417 |
ccs_set_uint(&profile->preference.audit_max_grant_log, value, |
ccs_set_uint(&profile->preference.audit_max_grant_log, value, |
418 |
"max_grant_log"); |
"max_grant_log"); |
426 |
return; |
return; |
427 |
} |
} |
428 |
if (!strcmp(name, "enforcing")) { |
if (!strcmp(name, "enforcing")) { |
|
if (use_default) { |
|
|
pref = &profile->enforcing; |
|
|
goto set_default; |
|
|
} |
|
|
profile->enforcing = &profile->preference; |
|
429 |
ccs_set_uint(&profile->preference.enforcing_penalty, value, |
ccs_set_uint(&profile->preference.enforcing_penalty, value, |
430 |
"penalty"); |
"penalty"); |
431 |
verbose = &profile->preference.enforcing_verbose; |
return; |
|
goto set_verbose; |
|
|
} |
|
|
if (!strcmp(name, "permissive")) { |
|
|
if (use_default) { |
|
|
pref = &profile->permissive; |
|
|
goto set_default; |
|
|
} |
|
|
profile->permissive = &profile->preference; |
|
|
verbose = &profile->preference.permissive_verbose; |
|
|
goto set_verbose; |
|
432 |
} |
} |
433 |
if (!strcmp(name, "learning")) { |
if (!strcmp(name, "learning")) { |
|
if (use_default) { |
|
|
pref = &profile->learning; |
|
|
goto set_default; |
|
|
} |
|
|
profile->learning = &profile->preference; |
|
434 |
ccs_set_uint(&profile->preference.learning_max_entry, value, |
ccs_set_uint(&profile->preference.learning_max_entry, value, |
435 |
"max_entry"); |
"max_entry"); |
436 |
ccs_set_bool(&profile->preference.learning_exec_realpath, |
ccs_set_bool(&profile->preference.learning_exec_realpath, |
439 |
"exec.argv0"); |
"exec.argv0"); |
440 |
ccs_set_bool(&profile->preference.learning_symlink_target, |
ccs_set_bool(&profile->preference.learning_symlink_target, |
441 |
value, "symlink.target"); |
value, "symlink.target"); |
442 |
verbose = &profile->preference.learning_verbose; |
return; |
|
goto set_verbose; |
|
443 |
} |
} |
|
return; |
|
|
set_default: |
|
|
*pref = &ccs_default_profile.preference; |
|
|
return; |
|
|
set_verbose: |
|
|
ccs_set_bool(verbose, value, "verbose"); |
|
444 |
} |
} |
445 |
|
|
446 |
static int ccs_set_mode(char *name, const char *value, const bool use_default, |
static int ccs_set_mode(char *name, const char *value, |
447 |
struct ccs_profile *profile) |
struct ccs_profile *profile) |
448 |
{ |
{ |
449 |
u8 i; |
u8 i; |
467 |
} else { |
} else { |
468 |
return -EINVAL; |
return -EINVAL; |
469 |
} |
} |
470 |
if (use_default) { |
if (strstr(value, "use_default")) { |
471 |
config = CCS_CONFIG_USE_DEFAULT; |
config = CCS_CONFIG_USE_DEFAULT; |
472 |
} else { |
} else { |
473 |
u8 mode; |
u8 mode; |
478 |
* 'config' from 'CCS_CONFIG_USE_DEAFULT'. |
* 'config' from 'CCS_CONFIG_USE_DEAFULT'. |
479 |
*/ |
*/ |
480 |
config = (config & ~7) | mode; |
config = (config & ~7) | mode; |
|
#ifdef CONFIG_CCSECURITY_AUDIT |
|
481 |
if (config != CCS_CONFIG_USE_DEFAULT) { |
if (config != CCS_CONFIG_USE_DEFAULT) { |
482 |
|
switch (ccs_find_yesno(value, "verbose")) { |
483 |
|
case 1: |
484 |
|
config |= CCS_CONFIG_VERBOSE; |
485 |
|
break; |
486 |
|
case 0: |
487 |
|
config &= ~CCS_CONFIG_VERBOSE; |
488 |
|
break; |
489 |
|
} |
490 |
|
#ifdef CONFIG_CCSECURITY_AUDIT |
491 |
switch (ccs_find_yesno(value, "grant_log")) { |
switch (ccs_find_yesno(value, "grant_log")) { |
492 |
case 1: |
case 1: |
493 |
config |= CCS_CONFIG_WANT_GRANT_LOG; |
config |= CCS_CONFIG_WANT_GRANT_LOG; |
504 |
config &= ~CCS_CONFIG_WANT_REJECT_LOG; |
config &= ~CCS_CONFIG_WANT_REJECT_LOG; |
505 |
break; |
break; |
506 |
} |
} |
|
} |
|
507 |
#endif |
#endif |
508 |
|
} |
509 |
} |
} |
510 |
if (i < CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX |
if (i < CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX |
511 |
+ CCS_MAX_MAC_CATEGORY_INDEX) |
+ CCS_MAX_MAC_CATEGORY_INDEX) |
526 |
{ |
{ |
527 |
char *data = head->write_buf; |
char *data = head->write_buf; |
528 |
unsigned int i; |
unsigned int i; |
|
bool use_default = false; |
|
529 |
char *cp; |
char *cp; |
530 |
struct ccs_profile *profile; |
struct ccs_profile *profile; |
531 |
if (sscanf(data, "PROFILE_VERSION=%u", &ccs_profile_version) == 1) |
if (sscanf(data, "PROFILE_VERSION=%u", &ccs_profile_version) == 1) |
532 |
return 0; |
return 0; |
533 |
i = simple_strtoul(data, &cp, 10); |
i = simple_strtoul(data, &cp, 10); |
534 |
if (data == cp) { |
if (*cp != '-') |
535 |
profile = &ccs_default_profile; |
return -EINVAL; |
536 |
} else { |
data = cp + 1; |
537 |
if (*cp != '-') |
profile = ccs_assign_profile(i); |
538 |
return -EINVAL; |
if (!profile) |
539 |
data = cp + 1; |
return -EINVAL; |
|
profile = ccs_assign_profile(i); |
|
|
if (!profile) |
|
|
return -EINVAL; |
|
|
} |
|
540 |
cp = strchr(data, '='); |
cp = strchr(data, '='); |
541 |
if (!cp) |
if (!cp) |
542 |
return -EINVAL; |
return -EINVAL; |
543 |
*cp++ = '\0'; |
*cp++ = '\0'; |
|
if (profile != &ccs_default_profile) |
|
|
use_default = strstr(cp, "use_default") != NULL; |
|
544 |
if (ccs_str_starts(&data, "PREFERENCE::")) { |
if (ccs_str_starts(&data, "PREFERENCE::")) { |
545 |
ccs_set_pref(data, cp, use_default, profile); |
ccs_set_pref(data, cp, profile); |
546 |
return 0; |
return 0; |
547 |
} |
} |
|
if (profile == &ccs_default_profile) |
|
|
return -EINVAL; |
|
548 |
if (!strcmp(data, "COMMENT")) { |
if (!strcmp(data, "COMMENT")) { |
549 |
const struct ccs_path_info *old_comment = profile->comment; |
const struct ccs_path_info *old_comment = profile->comment; |
550 |
profile->comment = ccs_get_name(cp); |
profile->comment = ccs_get_name(cp); |
551 |
ccs_put_name(old_comment); |
ccs_put_name(old_comment); |
552 |
return 0; |
return 0; |
553 |
} |
} |
554 |
return ccs_set_mode(data, cp, use_default, profile); |
return ccs_set_mode(data, cp, profile); |
555 |
} |
} |
556 |
|
|
557 |
static void ccs_print_preference(struct ccs_io_buffer *head, const int idx) |
static void ccs_print_preference(struct ccs_io_buffer *head, const int index) |
558 |
{ |
{ |
559 |
struct ccs_preference *pref = &ccs_default_profile.preference; |
struct ccs_profile *profile = ccs_profile_ptr[index]; |
560 |
const struct ccs_profile *profile = idx >= 0 ? |
struct ccs_preference *pref = &profile->preference; |
561 |
ccs_profile_ptr[idx] : NULL; |
ccs_io_printf(head, "%u-PREFERENCE::%s={ " |
|
char buffer[16] = ""; |
|
|
if (profile) { |
|
|
buffer[sizeof(buffer) - 1] = '\0'; |
|
|
snprintf(buffer, sizeof(buffer) - 1, "%u-", idx); |
|
|
} |
|
|
if (profile) { |
|
|
pref = profile->audit; |
|
|
if (pref == &ccs_default_profile.preference) |
|
|
goto skip0; |
|
|
} |
|
|
ccs_io_printf(head, "%sPREFERENCE::%s={ " |
|
562 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
563 |
"max_grant_log=%u max_reject_log=%u " |
"max_grant_log=%u max_reject_log=%u " |
564 |
#endif |
#endif |
565 |
"task_info=%s path_info=%s }\n", buffer, |
"task_info=%s path_info=%s }\n", index, |
566 |
"audit", |
"audit", |
567 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
568 |
pref->audit_max_grant_log, |
pref->audit_max_grant_log, |
570 |
#endif |
#endif |
571 |
ccs_yesno(pref->audit_task_info), |
ccs_yesno(pref->audit_task_info), |
572 |
ccs_yesno(pref->audit_path_info)); |
ccs_yesno(pref->audit_path_info)); |
573 |
skip0: |
ccs_io_printf(head, "%u-PREFERENCE::%s={ " |
574 |
if (profile) { |
"max_entry=%u exec.realpath=%s " |
|
pref = profile->learning; |
|
|
if (pref == &ccs_default_profile.preference) |
|
|
goto skip1; |
|
|
} |
|
|
ccs_io_printf(head, "%sPREFERENCE::%s={ " |
|
|
"verbose=%s max_entry=%u exec.realpath=%s " |
|
575 |
"exec.argv0=%s symlink.target=%s }\n", |
"exec.argv0=%s symlink.target=%s }\n", |
576 |
buffer, "learning", |
index, "learning", |
|
ccs_yesno(pref->learning_verbose), |
|
577 |
pref->learning_max_entry, |
pref->learning_max_entry, |
578 |
ccs_yesno(pref->learning_exec_realpath), |
ccs_yesno(pref->learning_exec_realpath), |
579 |
ccs_yesno(pref->learning_exec_argv0), |
ccs_yesno(pref->learning_exec_argv0), |
580 |
ccs_yesno(pref->learning_symlink_target)); |
ccs_yesno(pref->learning_symlink_target)); |
581 |
skip1: |
ccs_io_printf(head, "%u-PREFERENCE::%s={ penalty=%u }\n", index, |
582 |
if (profile) { |
"enforcing", pref->enforcing_penalty); |
|
pref = profile->permissive; |
|
|
if (pref == &ccs_default_profile.preference) |
|
|
goto skip2; |
|
|
} |
|
|
ccs_io_printf(head, "%sPREFERENCE::%s={ verbose=%s }\n", |
|
|
buffer, "permissive", |
|
|
ccs_yesno(pref->permissive_verbose)); |
|
|
skip2: |
|
|
if (profile) { |
|
|
pref = profile->enforcing; |
|
|
if (pref == &ccs_default_profile.preference) |
|
|
return; |
|
|
} |
|
|
ccs_io_printf(head, "%sPREFERENCE::%s={ verbose=%s " |
|
|
"penalty=%u }\n", buffer, "enforcing", |
|
|
ccs_yesno(pref->enforcing_verbose), |
|
|
pref->enforcing_penalty); |
|
583 |
} |
} |
584 |
|
|
585 |
static void ccs_print_config(struct ccs_io_buffer *head, const u8 config) |
static void ccs_print_config(struct ccs_io_buffer *head, const u8 config) |
586 |
{ |
{ |
587 |
ccs_io_printf(head, "={ mode=%s", ccs_mode[config & 3]); |
ccs_io_printf(head, "={ mode=%s verbose=%s", ccs_mode[config & 3], |
588 |
|
ccs_yesno(config & CCS_CONFIG_VERBOSE)); |
589 |
#ifdef CONFIG_CCSECURITY_AUDIT |
#ifdef CONFIG_CCSECURITY_AUDIT |
590 |
ccs_io_printf(head, " grant_log=%s reject_log=%s", |
ccs_io_printf(head, " grant_log=%s reject_log=%s", |
591 |
ccs_yesno(config & CCS_CONFIG_WANT_GRANT_LOG), |
ccs_yesno(config & CCS_CONFIG_WANT_GRANT_LOG), |
609 |
switch (head->r.step) { |
switch (head->r.step) { |
610 |
case 0: |
case 0: |
611 |
ccs_io_printf(head, "PROFILE_VERSION=%s\n", "20090903"); |
ccs_io_printf(head, "PROFILE_VERSION=%s\n", "20090903"); |
|
ccs_print_preference(head, -1); |
|
612 |
head->r.step++; |
head->r.step++; |
613 |
break; |
break; |
614 |
case 1: |
case 1: |
859 |
return true; /* Do nothing if open(O_WRONLY). */ |
return true; /* Do nothing if open(O_WRONLY). */ |
860 |
memset(&head->r, 0, sizeof(head->r)); |
memset(&head->r, 0, sizeof(head->r)); |
861 |
head->r.print_this_domain_only = true; |
head->r.print_this_domain_only = true; |
862 |
head->r.eof = !domain; |
if (domain) |
863 |
head->r.domain = &domain->list; |
head->r.domain = &domain->list; |
864 |
|
else |
865 |
|
head->r.eof = true; |
866 |
ccs_io_printf(head, "# select %s\n", data); |
ccs_io_printf(head, "# select %s\n", data); |
867 |
if (domain && domain->is_deleted) |
if (domain && domain->is_deleted) |
868 |
ccs_set_string(head, "# This is a deleted domain.\n"); |
ccs_set_string(head, "# This is a deleted domain.\n"); |
876 |
const char *keyword; |
const char *keyword; |
877 |
int (*write) (char *, struct ccs_domain_info *, |
int (*write) (char *, struct ccs_domain_info *, |
878 |
struct ccs_condition *, const bool); |
struct ccs_condition *, const bool); |
879 |
} ccs_callback[4] = { |
} ccs_callback[5] = { |
880 |
{ "network ", ccs_write_network }, |
{ "network inet ", ccs_write_inet_network }, |
881 |
|
{ "network unix ", ccs_write_unix_network }, |
882 |
{ "misc ", ccs_write_misc }, |
{ "misc ", ccs_write_misc }, |
883 |
{ "capability ", ccs_write_capability }, |
{ "capability ", ccs_write_capability }, |
884 |
{ "ipc ", ccs_write_ipc }, |
{ "ipc ", ccs_write_ipc }, |
894 |
if (!cond) |
if (!cond) |
895 |
return -EINVAL; |
return -EINVAL; |
896 |
} |
} |
897 |
for (i = 0; i < 4; i++) { |
for (i = 0; i < 5; i++) { |
898 |
if (!ccs_str_starts(&data, ccs_callback[i].keyword)) |
if (!ccs_str_starts(&data, ccs_callback[i].keyword)) |
899 |
continue; |
continue; |
900 |
write = ccs_callback[i].write; |
write = ccs_callback[i].write; |
941 |
else if (is_select) |
else if (is_select) |
942 |
domain = ccs_find_domain(data); |
domain = ccs_find_domain(data); |
943 |
else |
else |
944 |
domain = ccs_assign_domain(data, 0, 0); |
domain = ccs_assign_domain(data, 0, 0, false); |
945 |
head->w.domain = domain; |
head->w.domain = domain; |
946 |
return 0; |
return 0; |
947 |
} |
} |
1307 |
ccs_set_group(head); |
ccs_set_group(head); |
1308 |
ccs_set_string(head, "capability "); |
ccs_set_string(head, "capability "); |
1309 |
ccs_set_string(head, ccs_cap2keyword(ptr->operation)); |
ccs_set_string(head, ccs_cap2keyword(ptr->operation)); |
1310 |
} else if (acl_type == CCS_TYPE_IP_NETWORK_ACL) { |
} else if (acl_type == CCS_TYPE_INET_ACL) { |
1311 |
struct ccs_ip_network_acl *ptr = |
struct ccs_inet_acl *ptr = |
1312 |
container_of(acl, typeof(*ptr), head); |
container_of(acl, typeof(*ptr), head); |
1313 |
bit = ccs_fns(ptr->perm, bit); |
bit = ccs_fns(ptr->perm, bit); |
1314 |
if (bit >= CCS_MAX_NETWORK_OPERATION) |
if (bit >= CCS_MAX_NETWORK_OPERATION) |
1315 |
goto done; |
goto done; |
1316 |
ccs_set_group(head); |
ccs_set_group(head); |
1317 |
ccs_set_string(head, "network "); |
ccs_set_string(head, "network inet "); |
1318 |
ccs_set_string(head, ccs_net_protocol_keyword[ptr->protocol]); |
ccs_set_string(head, ccs_inet_keyword[ptr->protocol]); |
1319 |
ccs_set_space(head); |
ccs_set_space(head); |
1320 |
ccs_set_string(head, ccs_net_keyword[bit]); |
ccs_set_string(head, ccs_net_keyword[bit]); |
1321 |
ccs_set_space(head); |
ccs_set_space(head); |
1338 |
break; |
break; |
1339 |
} |
} |
1340 |
ccs_print_number_union(head, &ptr->port); |
ccs_print_number_union(head, &ptr->port); |
1341 |
|
} else if (acl_type == CCS_TYPE_UNIX_ACL) { |
1342 |
|
struct ccs_unix_acl *ptr = |
1343 |
|
container_of(acl, typeof(*ptr), head); |
1344 |
|
bit = ccs_fns(ptr->perm, bit); |
1345 |
|
if (bit >= CCS_MAX_NETWORK_OPERATION) |
1346 |
|
goto done; |
1347 |
|
ccs_set_group(head); |
1348 |
|
ccs_set_string(head, "network unix "); |
1349 |
|
ccs_set_string(head, ccs_unix_keyword[ptr->protocol]); |
1350 |
|
ccs_set_space(head); |
1351 |
|
ccs_set_string(head, ccs_net_keyword[bit]); |
1352 |
|
ccs_print_name_union(head, &ptr->name); |
1353 |
} else if (acl_type == CCS_TYPE_SIGNAL_ACL) { |
} else if (acl_type == CCS_TYPE_SIGNAL_ACL) { |
1354 |
struct ccs_signal_acl *ptr = |
struct ccs_signal_acl *ptr = |
1355 |
container_of(acl, typeof(*ptr), head); |
container_of(acl, typeof(*ptr), head); |
1385 |
case CCS_TYPE_MKDEV_ACL: |
case CCS_TYPE_MKDEV_ACL: |
1386 |
case CCS_TYPE_PATH2_ACL: |
case CCS_TYPE_PATH2_ACL: |
1387 |
case CCS_TYPE_PATH_NUMBER_ACL: |
case CCS_TYPE_PATH_NUMBER_ACL: |
1388 |
case CCS_TYPE_IP_NETWORK_ACL: |
case CCS_TYPE_INET_ACL: |
1389 |
|
case CCS_TYPE_UNIX_ACL: |
1390 |
goto next; |
goto next; |
1391 |
} |
} |
1392 |
done: |
done: |
1896 |
header = ccs_init_log(&len, r); |
header = ccs_init_log(&len, r); |
1897 |
if (!header) |
if (!header) |
1898 |
return 0; |
return 0; |
1899 |
pref = ccs_profile(r->profile)->learning; |
pref = &ccs_profile(r->profile)->preference; |
1900 |
/* strstr() will return NULL if ordering is wrong. */ |
/* strstr() will return NULL if ordering is wrong. */ |
1901 |
if (r->param_type == CCS_TYPE_PATH_ACL && |
if (r->param_type == CCS_TYPE_PATH_ACL && |
1902 |
r->param.path.operation == CCS_TYPE_EXECUTE) { |
r->param.path.operation == CCS_TYPE_EXECUTE) { |
1959 |
int i; |
int i; |
1960 |
if (current->ccs_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR) |
if (current->ccs_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR) |
1961 |
return -EPERM; |
return -EPERM; |
1962 |
for (i = 0; i < ccs_profile(domain->profile)->enforcing-> |
for (i = 0; i < ccs_profile(domain->profile)->preference. |
1963 |
enforcing_penalty; i++) { |
enforcing_penalty; i++) { |
1964 |
set_current_state(TASK_INTERRUPTIBLE); |
set_current_state(TASK_INTERRUPTIBLE); |
1965 |
schedule_timeout(HZ / 10); |
schedule_timeout(HZ / 10); |
2175 |
{ |
{ |
2176 |
if (head->r.eof) |
if (head->r.eof) |
2177 |
return; |
return; |
2178 |
ccs_set_string(head, "1.7.2"); |
ccs_set_string(head, "1.8.0-pre"); |
2179 |
head->r.eof = true; |
head->r.eof = true; |
2180 |
} |
} |
2181 |
|
|