1 |
/* |
/* |
2 |
* fs/tomoyo_network.c |
* security/ccsecurity/network.c |
3 |
* |
* |
4 |
* Implementation of the Domain-Based Mandatory Access Control. |
* Copyright (C) 2005-2010 NTT DATA CORPORATION |
5 |
* |
* |
6 |
* Copyright (C) 2005-2007 NTT DATA CORPORATION |
* Version: 1.7.2 2010/04/01 |
|
* |
|
|
* Version: 1.5.3-pre 2007/12/17 |
|
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. |
10 |
* |
* |
11 |
*/ |
*/ |
|
/***** TOMOYO Linux start. *****/ |
|
12 |
|
|
13 |
#include <linux/ccs_common.h> |
#include <linux/net.h> |
14 |
#include <linux/tomoyo.h> |
#include <linux/inet.h> |
15 |
#include <linux/realpath.h> |
#include <linux/in.h> |
16 |
|
#include <linux/in6.h> |
17 |
#include <net/ip.h> |
#include <net/ip.h> |
18 |
|
#include <net/ipv6.h> |
19 |
|
#include <net/udp.h> |
20 |
|
#include "internal.h" |
21 |
|
|
22 |
/************************* VARIABLES *************************/ |
/** |
23 |
|
* ccs_audit_network_log - Audit network log. |
24 |
extern struct mutex domain_acl_lock; |
* |
25 |
|
* @r: Pointer to "struct ccs_request_info". |
26 |
/************************* AUDIT FUNCTIONS *************************/ |
* @operation: The name of operation. |
27 |
|
* @address: An IPv4 or IPv6 address. |
28 |
static int AuditNetworkLog(const bool is_ipv6, const char *operation, const u32 *address, const u16 port, const bool is_granted) |
* @port: Port number. |
29 |
{ |
* @is_granted: True if this is a granted log. |
30 |
char *buf; |
* |
31 |
int len = 256; |
* Returns 0 on success, negative value otherwise. |
32 |
if (CanSaveAuditLog(is_granted) < 0) return -ENOMEM; |
*/ |
33 |
if ((buf = InitAuditLog(&len)) == NULL) return -ENOMEM; |
static int ccs_audit_network_log(struct ccs_request_info *r, |
34 |
snprintf(buf + strlen(buf), len - strlen(buf) - 1, KEYWORD_ALLOW_NETWORK "%s ", operation); |
const char *operation, const char *address, |
35 |
if (is_ipv6) { |
const u16 port, const bool is_granted) |
36 |
print_ipv6(buf + strlen(buf), len - strlen(buf), (const struct in6_addr *) address); |
{ |
37 |
} else { |
if (!is_granted) |
38 |
u32 ip = *address; |
ccs_warn_log(r, "%s %s %u", operation, address, port); |
39 |
snprintf(buf + strlen(buf), len - strlen(buf) - 1, "%u.%u.%u.%u", NIPQUAD(ip)); |
return ccs_write_audit_log(is_granted, r, CCS_KEYWORD_ALLOW_NETWORK |
40 |
} |
"%s %s %u\n", operation, address, port); |
|
snprintf(buf + strlen(buf), len - strlen(buf) - 1, " %u\n", port); |
|
|
return WriteAuditLog(buf, is_granted); |
|
|
} |
|
|
|
|
|
/************************* UTILITY FUNCTIONS *************************/ |
|
|
|
|
|
/* Keep the given IPv6 address on the RAM. The RAM is shared, so NEVER try to modify or kfree() the returned address. */ |
|
|
static const struct in6_addr *SaveIPv6Address(const struct in6_addr *addr) |
|
|
{ |
|
|
static const int block_size = 16; |
|
|
struct addr_list { |
|
|
struct in6_addr addr[block_size]; |
|
|
struct list1_head list; |
|
|
u32 in_use_count; |
|
|
}; |
|
|
static LIST1_HEAD(address_list); |
|
|
struct addr_list *ptr; |
|
|
static DEFINE_MUTEX(lock); |
|
|
int i = block_size; |
|
|
if (!addr) return NULL; |
|
|
mutex_lock(&lock); |
|
|
list1_for_each_entry(ptr, &address_list, list) { |
|
|
for (i = 0; i < ptr->in_use_count; i++) { |
|
|
if (memcmp(&ptr->addr[i], addr, sizeof(*addr)) == 0) goto ok; |
|
|
} |
|
|
if (i < block_size) break; |
|
|
} |
|
|
if (i == block_size) { |
|
|
ptr = alloc_element(sizeof(*ptr)); |
|
|
if (!ptr) goto ok; |
|
|
list1_add_tail_mb(&ptr->list, &address_list); |
|
|
i = 0; |
|
|
} |
|
|
ptr->addr[ptr->in_use_count++] = *addr; |
|
|
ok: |
|
|
mutex_unlock(&lock); |
|
|
return ptr ? &ptr->addr[i] : NULL; |
|
|
} |
|
|
|
|
|
/************************* ADDRESS GROUP HANDLER *************************/ |
|
|
|
|
|
static LIST1_HEAD(address_group_list); |
|
|
|
|
|
static int AddAddressGroupEntry(const char *group_name, const bool is_ipv6, const u16 *min_address, const u16 *max_address, const bool is_delete) |
|
|
{ |
|
|
static DEFINE_MUTEX(lock); |
|
|
struct address_group_entry *new_group, *group; |
|
|
struct address_group_member *new_member, *member; |
|
|
const struct path_info *saved_group_name; |
|
|
const struct in6_addr *saved_min_address = NULL, *saved_max_address = NULL; |
|
|
int error = -ENOMEM; |
|
|
bool found = 0; |
|
|
if (!IsCorrectPath(group_name, 0, 0, 0, __FUNCTION__) || !group_name[0]) return -EINVAL; |
|
|
if ((saved_group_name = SaveName(group_name)) == NULL) return -ENOMEM; |
|
|
if (is_ipv6) { |
|
|
if ((saved_min_address = SaveIPv6Address((struct in6_addr *) min_address)) == NULL |
|
|
|| (saved_max_address = SaveIPv6Address((struct in6_addr *) max_address)) == NULL) return -ENOMEM; |
|
|
} |
|
|
mutex_lock(&lock); |
|
|
list1_for_each_entry(group, &address_group_list, list) { |
|
|
if (saved_group_name != group->group_name) continue; |
|
|
list1_for_each_entry(member, &group->address_group_member_list, list) { |
|
|
if (member->is_ipv6 != is_ipv6) continue; |
|
|
if (is_ipv6) { |
|
|
if (member->min.ipv6 != saved_min_address || member->max.ipv6 != saved_max_address) continue; |
|
|
} else { |
|
|
if (member->min.ipv4 != * (u32 *) min_address || member->max.ipv4 != * (u32 *) max_address) continue; |
|
|
} |
|
|
member->is_deleted = is_delete; |
|
|
error = 0; |
|
|
goto out; |
|
|
} |
|
|
found = 1; |
|
|
break; |
|
|
} |
|
|
if (is_delete) { |
|
|
error = -ENOENT; |
|
|
goto out; |
|
|
} |
|
|
if (!found) { |
|
|
if ((new_group = alloc_element(sizeof(*new_group))) == NULL) goto out; |
|
|
INIT_LIST1_HEAD(&new_group->address_group_member_list); |
|
|
new_group->group_name = saved_group_name; |
|
|
list1_add_tail_mb(&new_group->list, &address_group_list); |
|
|
group = new_group; |
|
|
} |
|
|
if ((new_member = alloc_element(sizeof(*new_member))) == NULL) goto out; |
|
|
new_member->is_ipv6 = is_ipv6; |
|
|
if (is_ipv6) { |
|
|
new_member->min.ipv6 = saved_min_address; |
|
|
new_member->max.ipv6 = saved_max_address; |
|
|
} else { |
|
|
new_member->min.ipv4 = * (u32 *) min_address; |
|
|
new_member->max.ipv4 = * (u32 *) max_address; |
|
|
} |
|
|
list1_add_tail_mb(&new_member->list, &group->address_group_member_list); |
|
|
error = 0; |
|
|
out: |
|
|
mutex_unlock(&lock); |
|
|
return error; |
|
41 |
} |
} |
42 |
|
|
43 |
int AddAddressGroupPolicy(char *data, const bool is_delete) |
/** |
44 |
|
* ccs_parse_ip_address - Parse an IP address. |
45 |
|
* |
46 |
|
* @address: String to parse. |
47 |
|
* @min: Pointer to store min address. |
48 |
|
* @max: Pointer to store max address. |
49 |
|
* |
50 |
|
* Returns CCS_IP_ADDRESS_TYPE_IPv6 if @address is an IPv6, |
51 |
|
* CCS_IP_ADDRESS_TYPE_IPv4 if @address is an IPv4, |
52 |
|
* CCS_IP_ADDRESS_TYPE_ADDRESS_GROUP otherwise. |
53 |
|
*/ |
54 |
|
int ccs_parse_ip_address(char *address, u16 *min, u16 *max) |
55 |
{ |
{ |
56 |
int count, is_ipv6; |
int count = sscanf(address, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx" |
57 |
u16 min_address[8], max_address[8]; |
"-%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", |
58 |
char *cp = strchr(data, ' '); |
&min[0], &min[1], &min[2], &min[3], |
59 |
if (!cp) return -EINVAL; |
&min[4], &min[5], &min[6], &min[7], |
60 |
*cp++ = '\0'; |
&max[0], &max[1], &max[2], &max[3], |
61 |
if ((count = sscanf(cp, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx-%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", |
&max[4], &max[5], &max[6], &max[7]); |
62 |
&min_address[0], &min_address[1], &min_address[2], &min_address[3], |
if (count == 8 || count == 16) { |
63 |
&min_address[4], &min_address[5], &min_address[6], &min_address[7], |
u8 i; |
64 |
&max_address[0], &max_address[1], &max_address[2], &max_address[3], |
if (count == 8) |
65 |
&max_address[4], &max_address[5], &max_address[6], &max_address[7])) == 8 || count == 16) { |
memmove(max, min, sizeof(u16) * 8); |
|
int i; |
|
66 |
for (i = 0; i < 8; i++) { |
for (i = 0; i < 8; i++) { |
67 |
min_address[i] = htons(min_address[i]); |
min[i] = htons(min[i]); |
68 |
max_address[i] = htons(max_address[i]); |
max[i] = htons(max[i]); |
69 |
} |
} |
70 |
if (count == 8) memmove(max_address, min_address, sizeof(min_address)); |
return CCS_IP_ADDRESS_TYPE_IPv6; |
|
is_ipv6 = 1; |
|
|
} else if ((count = sscanf(cp, "%hu.%hu.%hu.%hu-%hu.%hu.%hu.%hu", |
|
|
&min_address[0], &min_address[1], &min_address[2], &min_address[3], |
|
|
&max_address[0], &max_address[1], &max_address[2], &max_address[3])) == 4 || count == 8) { |
|
|
u32 ip = ((((u8) min_address[0]) << 24) + (((u8) min_address[1]) << 16) + (((u8) min_address[2]) << 8) + (u8) min_address[3]); |
|
|
* (u32 *) min_address = ip; |
|
|
if (count == 8) ip = ((((u8) max_address[0]) << 24) + (((u8) max_address[1]) << 16) + (((u8) max_address[2]) << 8) + (u8) max_address[3]); |
|
|
* (u32 *) max_address = ip; |
|
|
is_ipv6 = 0; |
|
|
} else { |
|
|
return -EINVAL; |
|
71 |
} |
} |
72 |
return AddAddressGroupEntry(data, is_ipv6, min_address, max_address, is_delete); |
count = sscanf(address, "%hu.%hu.%hu.%hu-%hu.%hu.%hu.%hu", |
73 |
} |
&min[0], &min[1], &min[2], &min[3], |
74 |
|
&max[0], &max[1], &max[2], &max[3]); |
75 |
static struct address_group_entry *FindOrAssignNewAddressGroup(const char *group_name) |
if (count == 4 || count == 8) { |
76 |
{ |
u32 ip = htonl((((u8) min[0]) << 24) + (((u8) min[1]) << 16) |
77 |
int i; |
+ (((u8) min[2]) << 8) + (u8) min[3]); |
78 |
struct address_group_entry *group; |
memmove(min, &ip, sizeof(ip)); |
79 |
for (i = 0; i <= 1; i++) { |
if (count == 8) |
80 |
list1_for_each_entry(group, &address_group_list, list) { |
ip = htonl((((u8) max[0]) << 24) |
81 |
if (strcmp(group_name, group->group_name->name) == 0) return group; |
+ (((u8) max[1]) << 16) |
82 |
} |
+ (((u8) max[2]) << 8) + (u8) max[3]); |
83 |
if (i == 0) { |
memmove(max, &ip, sizeof(ip)); |
84 |
const u16 dummy[2] = { 0, 0 }; |
return CCS_IP_ADDRESS_TYPE_IPv4; |
|
AddAddressGroupEntry(group_name, 0, dummy, dummy, 0); |
|
|
AddAddressGroupEntry(group_name, 0, dummy, dummy, 1); |
|
|
} |
|
|
} |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
static int AddressMatchesToGroup(const bool is_ipv6, const u32 *address, const struct address_group_entry *group) |
|
|
{ |
|
|
struct address_group_member *member; |
|
|
const u32 ip = ntohl(*address); |
|
|
list1_for_each_entry(member, &group->address_group_member_list, list) { |
|
|
if (member->is_deleted) continue; |
|
|
if (member->is_ipv6) { |
|
|
if (is_ipv6 && memcmp(member->min.ipv6, address, 16) <= 0 && memcmp(address, member->max.ipv6, 16) <= 0) return 1; |
|
|
} else { |
|
|
if (!is_ipv6 && member->min.ipv4 <= ip && ip <= member->max.ipv4) return 1; |
|
|
} |
|
85 |
} |
} |
86 |
return 0; |
return CCS_IP_ADDRESS_TYPE_ADDRESS_GROUP; |
87 |
} |
} |
88 |
|
|
89 |
int ReadAddressGroupPolicy(struct io_buffer *head) |
/** |
90 |
|
* ccs_print_ipv4 - Print an IPv4 address. |
91 |
|
* |
92 |
|
* @buffer: Buffer to write to. |
93 |
|
* @buffer_len: Size of @buffer. |
94 |
|
* @min_ip: Min address in host byte order. |
95 |
|
* @max_ip: Max address in host byte order. |
96 |
|
* |
97 |
|
* Returns nothing. |
98 |
|
*/ |
99 |
|
void ccs_print_ipv4(char *buffer, const int buffer_len, |
100 |
|
const u32 min_ip, const u32 max_ip) |
101 |
{ |
{ |
102 |
struct list1_head *gpos; |
memset(buffer, 0, buffer_len); |
103 |
struct list1_head *mpos; |
snprintf(buffer, buffer_len - 1, "%u.%u.%u.%u%c%u.%u.%u.%u", |
104 |
list1_for_each_cookie(gpos, head->read_var1, &address_group_list) { |
HIPQUAD(min_ip), min_ip == max_ip ? '\0' : '-', |
105 |
struct address_group_entry *group; |
HIPQUAD(max_ip)); |
|
group = list1_entry(gpos, struct address_group_entry, list); |
|
|
list1_for_each_cookie(mpos, head->read_var2, &group->address_group_member_list) { |
|
|
char buf[128]; |
|
|
struct address_group_member *member; |
|
|
member = list1_entry(mpos, struct address_group_member, list); |
|
|
if (member->is_deleted) continue; |
|
|
if (member->is_ipv6) { |
|
|
const struct in6_addr *min_address = member->min.ipv6, *max_address = member->max.ipv6; |
|
|
print_ipv6(buf, sizeof(buf), min_address); |
|
|
if (min_address != max_address) { |
|
|
char *cp = strchr(buf, '\0'); |
|
|
*cp++ = '-'; |
|
|
print_ipv6(cp, sizeof(buf) - strlen(buf), max_address); |
|
|
} |
|
|
} else { |
|
|
const u32 min_address = member->min.ipv4, max_address = member->max.ipv4; |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
snprintf(buf, sizeof(buf) - 1, "%u.%u.%u.%u", HIPQUAD(min_address)); |
|
|
if (min_address != max_address) { |
|
|
const int len = strlen(buf); |
|
|
snprintf(buf + len, sizeof(buf) - 1 - len, "-%u.%u.%u.%u", HIPQUAD(max_address)); |
|
|
} |
|
|
} |
|
|
if (io_printf(head, KEYWORD_ADDRESS_GROUP "%s %s\n", group->group_name->name, buf)) return -ENOMEM; |
|
|
} |
|
|
} |
|
|
return 0; |
|
106 |
} |
} |
107 |
|
|
|
/************************* NETWORK NETWORK ACL HANDLER *************************/ |
|
|
|
|
108 |
#if !defined(NIP6) |
#if !defined(NIP6) |
109 |
#define NIP6(addr) \ |
#define NIP6(addr) \ |
110 |
ntohs((addr).s6_addr16[0]), \ |
ntohs((addr).s6_addr16[0]), ntohs((addr).s6_addr16[1]), \ |
111 |
ntohs((addr).s6_addr16[1]), \ |
ntohs((addr).s6_addr16[2]), ntohs((addr).s6_addr16[3]), \ |
112 |
ntohs((addr).s6_addr16[2]), \ |
ntohs((addr).s6_addr16[4]), ntohs((addr).s6_addr16[5]), \ |
113 |
ntohs((addr).s6_addr16[3]), \ |
ntohs((addr).s6_addr16[6]), ntohs((addr).s6_addr16[7]) |
|
ntohs((addr).s6_addr16[4]), \ |
|
|
ntohs((addr).s6_addr16[5]), \ |
|
|
ntohs((addr).s6_addr16[6]), \ |
|
|
ntohs((addr).s6_addr16[7]) |
|
114 |
#endif |
#endif |
115 |
|
|
116 |
char *print_ipv6(char *buffer, const int buffer_len, const struct in6_addr *ip) |
/** |
117 |
|
* ccs_print_ipv6 - Print an IPv6 address. |
118 |
|
* |
119 |
|
* @buffer: Buffer to write to. |
120 |
|
* @buffer_len: Size of @buffer. |
121 |
|
* @min_ip: Pointer to "struct in6_addr". |
122 |
|
* @max_ip: Pointer to "struct in6_addr". |
123 |
|
* |
124 |
|
* Returns nothing. |
125 |
|
*/ |
126 |
|
void ccs_print_ipv6(char *buffer, const int buffer_len, |
127 |
|
const struct in6_addr *min_ip, |
128 |
|
const struct in6_addr *max_ip) |
129 |
{ |
{ |
130 |
memset(buffer, 0, buffer_len); |
memset(buffer, 0, buffer_len); |
131 |
snprintf(buffer, buffer_len - 1, "%x:%x:%x:%x:%x:%x:%x:%x", NIP6(*ip)); |
snprintf(buffer, buffer_len - 1, |
132 |
return buffer; |
"%x:%x:%x:%x:%x:%x:%x:%x%c%x:%x:%x:%x:%x:%x:%x:%x", |
133 |
|
NIP6(*min_ip), min_ip == max_ip ? '\0' : '-', |
134 |
|
NIP6(*max_ip)); |
135 |
} |
} |
136 |
|
|
137 |
const char *network2keyword(const unsigned int operation) |
/** |
138 |
|
* ccs_net2keyword - Convert network operation index to network operation name. |
139 |
|
* |
140 |
|
* @operation: Type of operation. |
141 |
|
* |
142 |
|
* Returns the name of operation. |
143 |
|
*/ |
144 |
|
const char *ccs_net2keyword(const u8 operation) |
145 |
{ |
{ |
146 |
const char *keyword = "unknown"; |
const char *keyword = "unknown"; |
147 |
switch (operation) { |
switch (operation) { |
148 |
case NETWORK_ACL_UDP_BIND: |
case CCS_NETWORK_UDP_BIND: |
149 |
keyword = "UDP bind"; |
keyword = "UDP bind"; |
150 |
break; |
break; |
151 |
case NETWORK_ACL_UDP_CONNECT: |
case CCS_NETWORK_UDP_CONNECT: |
152 |
keyword = "UDP connect"; |
keyword = "UDP connect"; |
153 |
break; |
break; |
154 |
case NETWORK_ACL_TCP_BIND: |
case CCS_NETWORK_TCP_BIND: |
155 |
keyword = "TCP bind"; |
keyword = "TCP bind"; |
156 |
break; |
break; |
157 |
case NETWORK_ACL_TCP_LISTEN: |
case CCS_NETWORK_TCP_LISTEN: |
158 |
keyword = "TCP listen"; |
keyword = "TCP listen"; |
159 |
break; |
break; |
160 |
case NETWORK_ACL_TCP_CONNECT: |
case CCS_NETWORK_TCP_CONNECT: |
161 |
keyword = "TCP connect"; |
keyword = "TCP connect"; |
162 |
break; |
break; |
163 |
case NETWORK_ACL_TCP_ACCEPT: |
case CCS_NETWORK_TCP_ACCEPT: |
164 |
keyword = "TCP accept"; |
keyword = "TCP accept"; |
165 |
break; |
break; |
166 |
case NETWORK_ACL_RAW_BIND: |
case CCS_NETWORK_RAW_BIND: |
167 |
keyword = "RAW bind"; |
keyword = "RAW bind"; |
168 |
break; |
break; |
169 |
case NETWORK_ACL_RAW_CONNECT: |
case CCS_NETWORK_RAW_CONNECT: |
170 |
keyword = "RAW connect"; |
keyword = "RAW connect"; |
171 |
break; |
break; |
172 |
} |
} |
173 |
return keyword; |
return keyword; |
174 |
} |
} |
175 |
|
|
176 |
static int AddNetworkEntry(const u8 operation, const u8 record_type, const struct address_group_entry *group, const u32 *min_address, const u32 *max_address, const u16 min_port, const u16 max_port, struct domain_info *domain, const struct condition_list *condition, const bool is_delete) |
/** |
177 |
|
* ccs_network_entry2 - Check permission for network operation. |
178 |
|
* |
179 |
|
* @is_ipv6: True if @address is an IPv6 address. |
180 |
|
* @operation: Type of operation. |
181 |
|
* @address: An IPv4 or IPv6 address. |
182 |
|
* @port: Port number. |
183 |
|
* |
184 |
|
* Returns 0 on success, negative value otherwise. |
185 |
|
* |
186 |
|
* Caller holds ccs_read_lock(). |
187 |
|
*/ |
188 |
|
static int ccs_network_entry2(const bool is_ipv6, const u8 operation, |
189 |
|
const u32 *address, const u16 port) |
190 |
{ |
{ |
191 |
struct acl_info *ptr; |
struct ccs_request_info r; |
192 |
struct ip_network_acl_record *acl; |
struct ccs_acl_info *ptr; |
193 |
int error = -ENOMEM; |
const char *keyword = ccs_net2keyword(operation); |
194 |
const u32 min_ip = ntohl(*min_address), max_ip = ntohl(*max_address); /* using host byte order to allow u32 comparison than memcmp().*/ |
const u16 perm = 1 << operation; |
195 |
const struct in6_addr *saved_min_address = NULL, *saved_max_address = NULL; |
/* using host byte order to allow u32 comparison than memcmp().*/ |
196 |
if (!domain) return -EINVAL; |
const u32 ip = ntohl(*address); |
197 |
if (record_type == IP_RECORD_TYPE_IPv6) { |
int error; |
198 |
if ((saved_min_address = SaveIPv6Address((struct in6_addr *) min_address)) == NULL |
char buf[128]; |
199 |
|| (saved_max_address = SaveIPv6Address((struct in6_addr *) max_address)) == NULL) return -ENOMEM; |
const struct ccs_domain_info * const domain = ccs_current_domain(); |
200 |
} |
if (ccs_init_request_info(&r, CCS_MAC_NETWORK_UDP_BIND + operation) |
201 |
mutex_lock(&domain_acl_lock); |
== CCS_CONFIG_DISABLED) |
202 |
if (!is_delete) { |
return 0; |
203 |
list1_for_each_entry(ptr, &domain->acl_info_list, list) { |
if (is_ipv6) |
204 |
acl = container_of(ptr, struct ip_network_acl_record, head); |
ccs_print_ipv6(buf, sizeof(buf), (const struct in6_addr *) |
205 |
if (ptr->type == TYPE_IP_NETWORK_ACL && acl->operation_type == operation && acl->record_type == record_type && ptr->cond == condition && acl->min_port == min_port && max_port == acl->max_port) { |
address, (const struct in6_addr *) address); |
206 |
if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) { |
else |
207 |
if (acl->u.group == group) { |
ccs_print_ipv4(buf, sizeof(buf), ip, ip); |
208 |
ptr->is_deleted = 0; |
do { |
209 |
/* Found. Nothing to do. */ |
error = -EPERM; |
210 |
error = 0; |
list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { |
211 |
goto out; |
struct ccs_ip_network_acl *acl; |
212 |
} |
if (ptr->is_deleted || |
213 |
} else if (record_type == IP_RECORD_TYPE_IPv4) { |
ptr->type != CCS_TYPE_IP_NETWORK_ACL) |
214 |
if (acl->u.ipv4.min == min_ip && max_ip == acl->u.ipv4.max) { |
continue; |
215 |
ptr->is_deleted = 0; |
acl = container_of(ptr, struct ccs_ip_network_acl, |
216 |
/* Found. Nothing to do. */ |
head); |
217 |
error = 0; |
if (!(acl->perm & perm)) |
218 |
goto out; |
continue; |
219 |
} |
if (!ccs_compare_number_union(port, &acl->port) || |
220 |
} else if (record_type == IP_RECORD_TYPE_IPv6) { |
!ccs_condition(&r, ptr)) |
221 |
if (acl->u.ipv6.min == saved_min_address && saved_max_address == acl->u.ipv6.max) { |
continue; |
222 |
ptr->is_deleted = 0; |
switch (acl->address_type) { |
223 |
/* Found. Nothing to do. */ |
case CCS_IP_ADDRESS_TYPE_ADDRESS_GROUP: |
224 |
error = 0; |
if (!ccs_address_matches_group(is_ipv6, |
225 |
goto out; |
address, |
226 |
} |
acl->address. |
227 |
} |
group)) |
228 |
} |
continue; |
229 |
} |
break; |
230 |
/* Not found. Append it to the tail. */ |
case CCS_IP_ADDRESS_TYPE_IPv4: |
231 |
if ((acl = alloc_element(sizeof(*acl))) == NULL) goto out; |
if (is_ipv6 || ip < acl->address.ipv4.min || |
232 |
acl->head.type = TYPE_IP_NETWORK_ACL; |
acl->address.ipv4.max < ip) |
233 |
acl->operation_type = operation; |
continue; |
234 |
acl->record_type = record_type; |
break; |
235 |
acl->head.cond = condition; |
default: |
236 |
if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) { |
if (!is_ipv6 || |
237 |
acl->u.group = group; |
memcmp(acl->address.ipv6.min, address, 16) |
238 |
} else if (record_type == IP_RECORD_TYPE_IPv4) { |
> 0 || |
239 |
acl->u.ipv4.min = min_ip; |
memcmp(address, acl->address.ipv6.max, 16) |
240 |
acl->u.ipv4.max = max_ip; |
> 0) |
241 |
} else { |
continue; |
242 |
acl->u.ipv6.min = saved_min_address; |
break; |
|
acl->u.ipv6.max = saved_max_address; |
|
|
} |
|
|
acl->min_port = min_port; |
|
|
acl->max_port = max_port; |
|
|
error = AddDomainACL(domain, &acl->head); |
|
|
} else { |
|
|
error = -ENOENT; |
|
|
list1_for_each_entry(ptr, &domain->acl_info_list, list) { |
|
|
acl = container_of(ptr, struct ip_network_acl_record, head); |
|
|
if (ptr->type != TYPE_IP_NETWORK_ACL || ptr->is_deleted || acl->operation_type != operation || acl->record_type != record_type || ptr->cond != condition || acl->min_port != min_port || acl->max_port != max_port) continue; |
|
|
if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) { |
|
|
if (acl->u.group != group) continue; |
|
|
} else if (record_type == IP_RECORD_TYPE_IPv4) { |
|
|
if (acl->u.ipv4.min != min_ip || max_ip != acl->u.ipv4.max) continue; |
|
|
} else if (record_type == IP_RECORD_TYPE_IPv6) { |
|
|
if (acl->u.ipv6.min != saved_min_address || saved_max_address != acl->u.ipv6.max) continue; |
|
243 |
} |
} |
244 |
error = DelDomainACL(ptr); |
r.cond = ptr->cond; |
245 |
|
error = 0; |
246 |
break; |
break; |
247 |
} |
} |
248 |
} |
ccs_audit_network_log(&r, keyword, buf, port, !error); |
249 |
out: ; |
if (!error) |
250 |
mutex_unlock(&domain_acl_lock); |
break; |
251 |
|
error = ccs_supervisor(&r, CCS_KEYWORD_ALLOW_NETWORK |
252 |
|
"%s %s %u\n", keyword, buf, port); |
253 |
|
} while (error == CCS_RETRY_REQUEST); |
254 |
|
if (r.mode != CCS_CONFIG_ENFORCING) |
255 |
|
error = 0; |
256 |
return error; |
return error; |
257 |
} |
} |
258 |
|
|
259 |
static int CheckNetworkEntry(const bool is_ipv6, const int operation, const u32 *address, const u16 port) |
/** |
260 |
|
* ccs_network_entry - Check permission for network operation. |
261 |
|
* |
262 |
|
* @is_ipv6: True if @address is an IPv6 address. |
263 |
|
* @operation: Type of operation. |
264 |
|
* @address: An IPv4 or IPv6 address. |
265 |
|
* @port: Port number. |
266 |
|
* |
267 |
|
* Returns 0 on success, negative value otherwise. |
268 |
|
*/ |
269 |
|
static int ccs_network_entry(const bool is_ipv6, const u8 operation, |
270 |
|
const u32 *address, const u16 port) |
271 |
{ |
{ |
272 |
struct domain_info * const domain = current->domain_info; |
const int idx = ccs_read_lock(); |
273 |
struct acl_info *ptr; |
const int error = ccs_network_entry2(is_ipv6, operation, address, |
274 |
const char *keyword = network2keyword(operation); |
port); |
275 |
const bool is_enforce = CheckCCSEnforce(CCS_TOMOYO_MAC_FOR_NETWORK); |
ccs_read_unlock(idx); |
276 |
const u32 ip = ntohl(*address); /* using host byte order to allow u32 comparison than memcmp().*/ |
return error; |
|
bool found = 0; |
|
|
if (!CheckCCSFlags(CCS_TOMOYO_MAC_FOR_NETWORK)) return 0; |
|
|
list1_for_each_entry(ptr, &domain->acl_info_list, list) { |
|
|
struct ip_network_acl_record *acl; |
|
|
acl = container_of(ptr, struct ip_network_acl_record, head); |
|
|
if (ptr->type != TYPE_IP_NETWORK_ACL || ptr->is_deleted || acl->operation_type != operation || port < acl->min_port || acl->max_port < port || CheckCondition(ptr->cond, NULL)) continue; |
|
|
if (acl->record_type == IP_RECORD_TYPE_ADDRESS_GROUP) { |
|
|
if (!AddressMatchesToGroup(is_ipv6, address, acl->u.group)) continue; |
|
|
} else if (acl->record_type == IP_RECORD_TYPE_IPv4) { |
|
|
if (is_ipv6 || ip < acl->u.ipv4.min || acl->u.ipv4.max < ip) continue; |
|
|
} else { |
|
|
if (!is_ipv6 || memcmp(acl->u.ipv6.min, address, 16) > 0 || memcmp(address, acl->u.ipv6.max, 16) > 0) continue; |
|
|
} |
|
|
found = 1; |
|
|
break; |
|
|
|
|
|
} |
|
|
AuditNetworkLog(is_ipv6, keyword, address, port, found); |
|
|
if (found) return 0; |
|
|
if (TomoyoVerboseMode()) { |
|
|
if (is_ipv6) { |
|
|
char buf[64]; |
|
|
print_ipv6(buf, sizeof(buf), (const struct in6_addr *) address); |
|
|
printk("TOMOYO-%s: %s to %s %u denied for %s\n", GetMSG(is_enforce), keyword, buf, port, GetLastName(domain)); |
|
|
} else { |
|
|
printk("TOMOYO-%s: %s to %u.%u.%u.%u %u denied for %s\n", GetMSG(is_enforce), keyword, HIPQUAD(ip), port, GetLastName(domain)); |
|
|
} |
|
|
} |
|
|
AuditNetworkLog(is_ipv6, keyword, address, port, 0); |
|
|
if (is_enforce) { |
|
|
if (is_ipv6) { |
|
|
char buf[64]; |
|
|
print_ipv6(buf, sizeof(buf), (const struct in6_addr *) address); |
|
|
return CheckSupervisor("%s\n" KEYWORD_ALLOW_NETWORK "%s %s %u\n", domain->domainname->name, keyword, buf, port); |
|
|
} |
|
|
return CheckSupervisor("%s\n" KEYWORD_ALLOW_NETWORK "%s %u.%u.%u.%u %u\n", domain->domainname->name, keyword, HIPQUAD(ip), port); |
|
|
} |
|
|
if (CheckCCSAccept(CCS_TOMOYO_MAC_FOR_NETWORK, domain)) AddNetworkEntry(operation, is_ipv6 ? IP_RECORD_TYPE_IPv6 : IP_RECORD_TYPE_IPv4, NULL, address, address, port, port, domain, NULL, 0); |
|
|
return 0; |
|
277 |
} |
} |
278 |
|
|
279 |
int AddNetworkPolicy(char *data, struct domain_info *domain, const struct condition_list *condition, const bool is_delete) |
static bool ccs_is_same_ip_network_acl(const struct ccs_acl_info *a, |
280 |
|
const struct ccs_acl_info *b) |
281 |
{ |
{ |
282 |
u8 sock_type, operation, record_type; |
const struct ccs_ip_network_acl *p1 = container_of(a, typeof(*p1), |
283 |
u16 min_address[8], max_address[8]; |
head); |
284 |
struct address_group_entry *group = NULL; |
const struct ccs_ip_network_acl *p2 = container_of(b, typeof(*p2), |
285 |
u16 min_port, max_port; |
head); |
286 |
int count; |
return ccs_is_same_acl_head(&p1->head, &p2->head) |
287 |
char *cp1 = NULL, *cp2 = NULL; |
&& p1->address_type == p2->address_type && |
288 |
if ((cp1 = strchr(data, ' ')) == NULL) goto out; cp1++; |
p1->address.ipv4.min == p2->address.ipv4.min && |
289 |
if (strncmp(data, "TCP ", 4) == 0) sock_type = SOCK_STREAM; |
p1->address.ipv6.min == p2->address.ipv6.min && |
290 |
else if (strncmp(data, "UDP ", 4) == 0) sock_type = SOCK_DGRAM; |
p1->address.ipv4.max == p2->address.ipv4.max && |
291 |
else if (strncmp(data, "RAW ", 4) == 0) sock_type = SOCK_RAW; |
p1->address.ipv6.max == p2->address.ipv6.max && |
292 |
else goto out; |
p1->address.group == p2->address.group && |
293 |
if ((cp2 = strchr(cp1, ' ')) == NULL) goto out; cp2++; |
ccs_is_same_number_union(&p1->port, &p2->port); |
294 |
if (strncmp(cp1, "bind ", 5) == 0) { |
} |
295 |
operation = (sock_type == SOCK_STREAM) ? NETWORK_ACL_TCP_BIND : (sock_type == SOCK_DGRAM) ? NETWORK_ACL_UDP_BIND : NETWORK_ACL_RAW_BIND; |
|
296 |
} else if (strncmp(cp1, "connect ", 8) == 0) { |
static bool ccs_merge_ip_network_acl(struct ccs_acl_info *a, |
297 |
operation = (sock_type == SOCK_STREAM) ? NETWORK_ACL_TCP_CONNECT : (sock_type == SOCK_DGRAM) ? NETWORK_ACL_UDP_CONNECT : NETWORK_ACL_RAW_CONNECT; |
struct ccs_acl_info *b, |
298 |
} else if (sock_type == SOCK_STREAM && strncmp(cp1, "listen ", 7) == 0) { |
const bool is_delete) |
299 |
operation = NETWORK_ACL_TCP_LISTEN; |
{ |
300 |
} else if (sock_type == SOCK_STREAM && strncmp(cp1, "accept ", 7) == 0) { |
struct ccs_ip_network_acl *p1 = container_of(a, typeof(*p1), head); |
301 |
operation = NETWORK_ACL_TCP_ACCEPT; |
const u16 perm = container_of(b, typeof(*p1), head)->perm; |
302 |
|
if (is_delete) { |
303 |
|
p1->perm &= ~perm; |
304 |
} else { |
} else { |
305 |
goto out; |
if (p1->head.is_deleted) |
306 |
|
p1->perm = 0; |
307 |
|
p1->perm |= perm; |
308 |
} |
} |
309 |
if ((cp1 = strchr(cp2, ' ')) == NULL) goto out; *cp1++ = '\0'; |
return !p1->perm; |
310 |
if ((count = sscanf(cp2, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx-%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", |
} |
311 |
&min_address[0], &min_address[1], &min_address[2], &min_address[3], |
|
312 |
&min_address[4], &min_address[5], &min_address[6], &min_address[7], |
/** |
313 |
&max_address[0], &max_address[1], &max_address[2], &max_address[3], |
* ccs_write_network_policy - Write "struct ccs_ip_network_acl" list. |
314 |
&max_address[4], &max_address[5], &max_address[6], &max_address[7])) == 8 || count == 16) { |
* |
315 |
int i; |
* @data: String to parse. |
316 |
for (i = 0; i < 8; i++) { |
* @domain: Pointer to "struct ccs_domain_info". |
317 |
min_address[i] = htons(min_address[i]); |
* @condition: Pointer to "struct ccs_condition". May be NULL. |
318 |
max_address[i] = htons(max_address[i]); |
* @is_delete: True if it is a delete request. |
319 |
|
* |
320 |
|
* Returns 0 on success, negative value otherwise. |
321 |
|
*/ |
322 |
|
int ccs_write_network_policy(char *data, struct ccs_domain_info *domain, |
323 |
|
struct ccs_condition *condition, |
324 |
|
const bool is_delete) |
325 |
|
{ |
326 |
|
struct ccs_ip_network_acl e = { |
327 |
|
.head.type = CCS_TYPE_IP_NETWORK_ACL, |
328 |
|
.head.cond = condition, |
329 |
|
}; |
330 |
|
u16 min_address[8]; |
331 |
|
u16 max_address[8]; |
332 |
|
int error = is_delete ? -ENOENT : -ENOMEM; |
333 |
|
u8 sock_type; |
334 |
|
char *w[4]; |
335 |
|
if (!ccs_tokenize(data, w, sizeof(w)) || !w[3][0]) |
336 |
|
return -EINVAL; |
337 |
|
if (!strcmp(w[0], "TCP")) |
338 |
|
sock_type = SOCK_STREAM; |
339 |
|
else if (!strcmp(w[0], "UDP")) |
340 |
|
sock_type = SOCK_DGRAM; |
341 |
|
else if (!strcmp(w[0], "RAW")) |
342 |
|
sock_type = SOCK_RAW; |
343 |
|
else |
344 |
|
return -EINVAL; |
345 |
|
if (!strcmp(w[1], "bind")) |
346 |
|
switch (sock_type) { |
347 |
|
case SOCK_STREAM: |
348 |
|
e.perm = 1 << CCS_NETWORK_TCP_BIND; |
349 |
|
break; |
350 |
|
case SOCK_DGRAM: |
351 |
|
e.perm = 1 << CCS_NETWORK_UDP_BIND; |
352 |
|
break; |
353 |
|
default: |
354 |
|
e.perm = 1 << CCS_NETWORK_RAW_BIND; |
355 |
|
break; |
356 |
} |
} |
357 |
if (count == 8) memmove(max_address, min_address, sizeof(min_address)); |
else if (!strcmp(w[1], "connect")) |
358 |
record_type = IP_RECORD_TYPE_IPv6; |
switch (sock_type) { |
359 |
} else if ((count = sscanf(cp2, "%hu.%hu.%hu.%hu-%hu.%hu.%hu.%hu", |
case SOCK_STREAM: |
360 |
&min_address[0], &min_address[1], &min_address[2], &min_address[3], |
e.perm = 1 << CCS_NETWORK_TCP_CONNECT; |
361 |
&max_address[0], &max_address[1], &max_address[2], &max_address[3])) == 4 || count == 8) { |
break; |
362 |
u32 ip = htonl((((u8) min_address[0]) << 24) + (((u8) min_address[1]) << 16) + (((u8) min_address[2]) << 8) + (u8) min_address[3]); |
case SOCK_DGRAM: |
363 |
* (u32 *) min_address = ip; |
e.perm = 1 << CCS_NETWORK_UDP_CONNECT; |
364 |
if (count == 8) ip = htonl((((u8) max_address[0]) << 24) + (((u8) max_address[1]) << 16) + (((u8) max_address[2]) << 8) + (u8) max_address[3]); |
break; |
365 |
* (u32 *) max_address = ip; |
default: |
366 |
record_type = IP_RECORD_TYPE_IPv4; |
e.perm = 1 << CCS_NETWORK_RAW_CONNECT; |
367 |
} else if (*cp2 == '@') { |
break; |
368 |
if ((group = FindOrAssignNewAddressGroup(cp2 + 1)) == NULL) return -ENOMEM; |
} |
369 |
record_type = IP_RECORD_TYPE_ADDRESS_GROUP; |
else if (sock_type == SOCK_STREAM && !strcmp(w[1], "listen")) |
370 |
} else { |
e.perm = 1 << CCS_NETWORK_TCP_LISTEN; |
371 |
goto out; |
else if (sock_type == SOCK_STREAM && !strcmp(w[1], "accept")) |
372 |
|
e.perm = 1 << CCS_NETWORK_TCP_ACCEPT; |
373 |
|
else |
374 |
|
return -EINVAL; |
375 |
|
switch (ccs_parse_ip_address(w[2], min_address, max_address)) { |
376 |
|
case CCS_IP_ADDRESS_TYPE_IPv6: |
377 |
|
e.address_type = CCS_IP_ADDRESS_TYPE_IPv6; |
378 |
|
e.address.ipv6.min = ccs_get_ipv6_address((struct in6_addr *) |
379 |
|
min_address); |
380 |
|
e.address.ipv6.max = ccs_get_ipv6_address((struct in6_addr *) |
381 |
|
max_address); |
382 |
|
if (!e.address.ipv6.min || !e.address.ipv6.max) |
383 |
|
goto out; |
384 |
|
break; |
385 |
|
case CCS_IP_ADDRESS_TYPE_IPv4: |
386 |
|
e.address_type = CCS_IP_ADDRESS_TYPE_IPv4; |
387 |
|
/* use host byte order to allow u32 comparison.*/ |
388 |
|
e.address.ipv4.min = ntohl(*(u32 *) min_address); |
389 |
|
e.address.ipv4.max = ntohl(*(u32 *) max_address); |
390 |
|
break; |
391 |
|
default: |
392 |
|
if (w[2][0] != '@') |
393 |
|
return -EINVAL; |
394 |
|
e.address_type = CCS_IP_ADDRESS_TYPE_ADDRESS_GROUP; |
395 |
|
e.address.group = ccs_get_address_group(w[2] + 1); |
396 |
|
if (!e.address.group) |
397 |
|
return -ENOMEM; |
398 |
|
break; |
399 |
} |
} |
400 |
if (strchr(cp1, ' ')) goto out; |
if (!ccs_parse_number_union(w[3], &e.port)) |
401 |
if ((count = sscanf(cp1, "%hu-%hu", &min_port, &max_port)) == 1 || count == 2) { |
goto out; |
402 |
if (count == 1) max_port = min_port; |
error = ccs_update_domain_policy(&e.head, sizeof(e), is_delete, domain, |
403 |
return AddNetworkEntry(operation, record_type, group, (u32 *) min_address, (u32 *) max_address, min_port, max_port, domain, condition, is_delete); |
ccs_is_same_ip_network_acl, |
404 |
|
ccs_merge_ip_network_acl); |
405 |
|
out: |
406 |
|
if (w[2][0] == '@') |
407 |
|
ccs_put_group(e.address.group); |
408 |
|
else if (e.address_type == CCS_IP_ADDRESS_TYPE_IPv6) { |
409 |
|
ccs_put_ipv6_address(e.address.ipv6.min); |
410 |
|
ccs_put_ipv6_address(e.address.ipv6.max); |
411 |
} |
} |
412 |
out: ; |
ccs_put_number_union(&e.port); |
413 |
return -EINVAL; |
return error; |
414 |
} |
} |
415 |
|
|
416 |
int CheckNetworkListenACL(const _Bool is_ipv6, const u8 *address, const u16 port) |
/** |
417 |
|
* ccs_network_listen_acl - Check permission for listen() operation. |
418 |
|
* |
419 |
|
* @is_ipv6: True if @address is an IPv6 address. |
420 |
|
* @address: An IPv4 or IPv6 address. |
421 |
|
* @port: Port number. |
422 |
|
* |
423 |
|
* Returns 0 on success, negative value otherwise. |
424 |
|
*/ |
425 |
|
static int ccs_network_listen_acl(const bool is_ipv6, const u8 *address, |
426 |
|
const u16 port) |
427 |
{ |
{ |
428 |
return CheckNetworkEntry(is_ipv6, NETWORK_ACL_TCP_LISTEN, (const u32 *) address, ntohs(port)); |
return ccs_network_entry(is_ipv6, CCS_NETWORK_TCP_LISTEN, |
429 |
|
(const u32 *) address, ntohs(port)); |
430 |
} |
} |
431 |
|
|
432 |
int CheckNetworkConnectACL(const _Bool is_ipv6, const int sock_type, const u8 *address, const u16 port) |
/** |
433 |
|
* ccs_network_connect_acl - Check permission for connect() operation. |
434 |
|
* |
435 |
|
* @is_ipv6: True if @address is an IPv6 address. |
436 |
|
* @sock_type: Type of socket. (TCP or UDP or RAW) |
437 |
|
* @address: An IPv4 or IPv6 address. |
438 |
|
* @port: Port number. |
439 |
|
* |
440 |
|
* Returns 0 on success, negative value otherwise. |
441 |
|
*/ |
442 |
|
static int ccs_network_connect_acl(const bool is_ipv6, const int sock_type, |
443 |
|
const u8 *address, const u16 port) |
444 |
{ |
{ |
445 |
return CheckNetworkEntry(is_ipv6, sock_type == SOCK_STREAM ? NETWORK_ACL_TCP_CONNECT : (sock_type == SOCK_DGRAM ? NETWORK_ACL_UDP_CONNECT : NETWORK_ACL_RAW_CONNECT), (const u32 *) address, ntohs(port)); |
u8 operation; |
446 |
|
switch (sock_type) { |
447 |
|
case SOCK_STREAM: |
448 |
|
operation = CCS_NETWORK_TCP_CONNECT; |
449 |
|
break; |
450 |
|
case SOCK_DGRAM: |
451 |
|
operation = CCS_NETWORK_UDP_CONNECT; |
452 |
|
break; |
453 |
|
default: |
454 |
|
operation = CCS_NETWORK_RAW_CONNECT; |
455 |
|
} |
456 |
|
return ccs_network_entry(is_ipv6, operation, |
457 |
|
(const u32 *) address, ntohs(port)); |
458 |
} |
} |
459 |
|
|
460 |
int CheckNetworkBindACL(const _Bool is_ipv6, const int sock_type, const u8 *address, const u16 port) |
/** |
461 |
|
* ccs_network_bind_acl - Check permission for bind() operation. |
462 |
|
* |
463 |
|
* @is_ipv6: True if @address is an IPv6 address. |
464 |
|
* @sock_type: Type of socket. (TCP or UDP or RAW) |
465 |
|
* @address: An IPv4 or IPv6 address. |
466 |
|
* @port: Port number. |
467 |
|
* |
468 |
|
* Returns 0 on success, negative value otherwise. |
469 |
|
*/ |
470 |
|
static int ccs_network_bind_acl(const bool is_ipv6, const int sock_type, |
471 |
|
const u8 *address, const u16 port) |
472 |
{ |
{ |
473 |
return CheckNetworkEntry(is_ipv6, sock_type == SOCK_STREAM ? NETWORK_ACL_TCP_BIND : (sock_type == SOCK_DGRAM ? NETWORK_ACL_UDP_BIND : NETWORK_ACL_RAW_BIND), (const u32 *) address, ntohs(port)); |
u8 operation; |
474 |
|
switch (sock_type) { |
475 |
|
case SOCK_STREAM: |
476 |
|
operation = CCS_NETWORK_TCP_BIND; |
477 |
|
break; |
478 |
|
case SOCK_DGRAM: |
479 |
|
operation = CCS_NETWORK_UDP_BIND; |
480 |
|
break; |
481 |
|
default: |
482 |
|
operation = CCS_NETWORK_RAW_BIND; |
483 |
|
} |
484 |
|
return ccs_network_entry(is_ipv6, operation, |
485 |
|
(const u32 *) address, ntohs(port)); |
486 |
} |
} |
487 |
|
|
488 |
int CheckNetworkAcceptACL(const _Bool is_ipv6, const u8 *address, const u16 port) |
/** |
489 |
|
* ccs_network_accept_acl - Check permission for accept() operation. |
490 |
|
* |
491 |
|
* @is_ipv6: True if @address is an IPv6 address. |
492 |
|
* @address: An IPv4 or IPv6 address. |
493 |
|
* @port: Port number. |
494 |
|
* |
495 |
|
* Returns 0 on success, negative value otherwise. |
496 |
|
*/ |
497 |
|
static int ccs_network_accept_acl(const bool is_ipv6, const u8 *address, |
498 |
|
const u16 port) |
499 |
{ |
{ |
500 |
int retval; |
int retval; |
501 |
current->tomoyo_flags |= CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
current->ccs_flags |= CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
502 |
retval = CheckNetworkEntry(is_ipv6, NETWORK_ACL_TCP_ACCEPT, (const u32 *) address, ntohs(port)); |
retval = ccs_network_entry(is_ipv6, CCS_NETWORK_TCP_ACCEPT, |
503 |
current->tomoyo_flags &= ~CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
(const u32 *) address, ntohs(port)); |
504 |
|
current->ccs_flags &= ~CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
505 |
return retval; |
return retval; |
506 |
} |
} |
507 |
|
|
508 |
int CheckNetworkSendMsgACL(const _Bool is_ipv6, const int sock_type, const u8 *address, const u16 port) |
/** |
509 |
|
* ccs_network_sendmsg_acl - Check permission for sendmsg() operation. |
510 |
|
* |
511 |
|
* @is_ipv6: True if @address is an IPv6 address. |
512 |
|
* @sock_type: Type of socket. (UDP or RAW) |
513 |
|
* @address: An IPv4 or IPv6 address. |
514 |
|
* @port: Port number. |
515 |
|
* |
516 |
|
* Returns 0 on success, negative value otherwise. |
517 |
|
*/ |
518 |
|
static int ccs_network_sendmsg_acl(const bool is_ipv6, const int sock_type, |
519 |
|
const u8 *address, const u16 port) |
520 |
{ |
{ |
521 |
return CheckNetworkEntry(is_ipv6, sock_type == SOCK_DGRAM ? NETWORK_ACL_UDP_CONNECT : NETWORK_ACL_RAW_CONNECT, (const u32 *) address, ntohs(port)); |
u8 operation; |
522 |
|
if (sock_type == SOCK_DGRAM) |
523 |
|
operation = CCS_NETWORK_UDP_CONNECT; |
524 |
|
else |
525 |
|
operation = CCS_NETWORK_RAW_CONNECT; |
526 |
|
return ccs_network_entry(is_ipv6, operation, |
527 |
|
(const u32 *) address, ntohs(port)); |
528 |
} |
} |
529 |
|
|
530 |
int CheckNetworkRecvMsgACL(const _Bool is_ipv6, const int sock_type, const u8 *address, const u16 port) |
/** |
531 |
|
* ccs_network_recvmsg_acl - Check permission for recvmsg() operation. |
532 |
|
* |
533 |
|
* @is_ipv6: True if @address is an IPv6 address. |
534 |
|
* @sock_type: Type of socket. (UDP or RAW) |
535 |
|
* @address: An IPv4 or IPv6 address. |
536 |
|
* @port: Port number. |
537 |
|
* |
538 |
|
* Returns 0 on success, negative value otherwise. |
539 |
|
*/ |
540 |
|
static int ccs_network_recvmsg_acl(const bool is_ipv6, const int sock_type, |
541 |
|
const u8 *address, const u16 port) |
542 |
{ |
{ |
543 |
int retval; |
int retval; |
544 |
current->tomoyo_flags |= CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
const u8 operation |
545 |
retval = CheckNetworkEntry(is_ipv6, sock_type == SOCK_DGRAM ? NETWORK_ACL_UDP_CONNECT : NETWORK_ACL_RAW_CONNECT, (const u32 *) address, ntohs(port)); |
= (sock_type == SOCK_DGRAM) ? |
546 |
current->tomoyo_flags &= ~CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
CCS_NETWORK_UDP_CONNECT : CCS_NETWORK_RAW_CONNECT; |
547 |
|
current->ccs_flags |= CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
548 |
|
retval = ccs_network_entry(is_ipv6, operation, |
549 |
|
(const u32 *) address, ntohs(port)); |
550 |
|
current->ccs_flags &= ~CCS_DONT_SLEEP_ON_ENFORCE_ERROR; |
551 |
return retval; |
return retval; |
552 |
} |
} |
553 |
|
|
554 |
/***** TOMOYO Linux end. *****/ |
#ifndef CONFIG_NET |
555 |
|
|
556 |
|
void __init ccs_network_init(void) |
557 |
|
{ |
558 |
|
} |
559 |
|
|
560 |
|
#else |
561 |
|
|
562 |
|
#define MAX_SOCK_ADDR 128 /* net/socket.c */ |
563 |
|
|
564 |
|
/* Check permission for creating a socket. */ |
565 |
|
static int __ccs_socket_create_permission(int family, int type, int protocol) |
566 |
|
{ |
567 |
|
int error = 0; |
568 |
|
/* Nothing to do if I am a kernel service. */ |
569 |
|
if (segment_eq(get_fs(), KERNEL_DS)) |
570 |
|
return 0; |
571 |
|
if (family == PF_PACKET && !ccs_capable(CCS_USE_PACKET_SOCKET)) |
572 |
|
return -EPERM; |
573 |
|
if (family == PF_ROUTE && !ccs_capable(CCS_USE_ROUTE_SOCKET)) |
574 |
|
return -EPERM; |
575 |
|
if (family != PF_INET && family != PF_INET6) |
576 |
|
return 0; |
577 |
|
switch (type) { |
578 |
|
case SOCK_STREAM: |
579 |
|
if (!ccs_capable(CCS_INET_STREAM_SOCKET_CREATE)) |
580 |
|
error = -EPERM; |
581 |
|
break; |
582 |
|
case SOCK_DGRAM: |
583 |
|
if (!ccs_capable(CCS_USE_INET_DGRAM_SOCKET)) |
584 |
|
error = -EPERM; |
585 |
|
break; |
586 |
|
case SOCK_RAW: |
587 |
|
if (!ccs_capable(CCS_USE_INET_RAW_SOCKET)) |
588 |
|
error = -EPERM; |
589 |
|
break; |
590 |
|
} |
591 |
|
return error; |
592 |
|
} |
593 |
|
|
594 |
|
/* Check permission for listening a TCP socket. */ |
595 |
|
static int __ccs_socket_listen_permission(struct socket *sock) |
596 |
|
{ |
597 |
|
int error = 0; |
598 |
|
char addr[MAX_SOCK_ADDR]; |
599 |
|
int addr_len; |
600 |
|
/* Nothing to do if I am a kernel service. */ |
601 |
|
if (segment_eq(get_fs(), KERNEL_DS)) |
602 |
|
return 0; |
603 |
|
if (sock->type != SOCK_STREAM) |
604 |
|
return 0; |
605 |
|
switch (sock->sk->sk_family) { |
606 |
|
case PF_INET: |
607 |
|
case PF_INET6: |
608 |
|
break; |
609 |
|
default: |
610 |
|
return 0; |
611 |
|
} |
612 |
|
if (!ccs_capable(CCS_INET_STREAM_SOCKET_LISTEN)) |
613 |
|
return -EPERM; |
614 |
|
if (sock->ops->getname(sock, (struct sockaddr *) addr, &addr_len, 0)) |
615 |
|
return -EPERM; |
616 |
|
switch (((struct sockaddr *) addr)->sa_family) { |
617 |
|
struct sockaddr_in6 *addr6; |
618 |
|
struct sockaddr_in *addr4; |
619 |
|
case AF_INET6: |
620 |
|
addr6 = (struct sockaddr_in6 *) addr; |
621 |
|
error = ccs_network_listen_acl(true, |
622 |
|
addr6->sin6_addr.s6_addr, |
623 |
|
addr6->sin6_port); |
624 |
|
break; |
625 |
|
case AF_INET: |
626 |
|
addr4 = (struct sockaddr_in *) addr; |
627 |
|
error = ccs_network_listen_acl(false, |
628 |
|
(u8 *) &addr4->sin_addr, |
629 |
|
addr4->sin_port); |
630 |
|
break; |
631 |
|
} |
632 |
|
return error; |
633 |
|
} |
634 |
|
|
635 |
|
/* Check permission for setting the remote IP address/port pair of a socket. */ |
636 |
|
static int __ccs_socket_connect_permission(struct socket *sock, |
637 |
|
struct sockaddr *addr, int addr_len) |
638 |
|
{ |
639 |
|
int error = 0; |
640 |
|
const unsigned int type = sock->type; |
641 |
|
/* Nothing to do if I am a kernel service. */ |
642 |
|
if (segment_eq(get_fs(), KERNEL_DS)) |
643 |
|
return 0; |
644 |
|
switch (type) { |
645 |
|
case SOCK_STREAM: |
646 |
|
case SOCK_DGRAM: |
647 |
|
case SOCK_RAW: |
648 |
|
break; |
649 |
|
default: |
650 |
|
return 0; |
651 |
|
} |
652 |
|
switch (addr->sa_family) { |
653 |
|
struct sockaddr_in6 *addr6; |
654 |
|
struct sockaddr_in *addr4; |
655 |
|
u16 port; |
656 |
|
case AF_INET6: |
657 |
|
if (addr_len < SIN6_LEN_RFC2133) |
658 |
|
break; |
659 |
|
addr6 = (struct sockaddr_in6 *) addr; |
660 |
|
if (type != SOCK_RAW) |
661 |
|
port = addr6->sin6_port; |
662 |
|
else |
663 |
|
port = htons(sock->sk->sk_protocol); |
664 |
|
error = ccs_network_connect_acl(true, type, |
665 |
|
addr6->sin6_addr.s6_addr, |
666 |
|
port); |
667 |
|
break; |
668 |
|
case AF_INET: |
669 |
|
if (addr_len < sizeof(struct sockaddr_in)) |
670 |
|
break; |
671 |
|
addr4 = (struct sockaddr_in *) addr; |
672 |
|
if (type != SOCK_RAW) |
673 |
|
port = addr4->sin_port; |
674 |
|
else |
675 |
|
port = htons(sock->sk->sk_protocol); |
676 |
|
error = ccs_network_connect_acl(false, type, |
677 |
|
(u8 *) &addr4->sin_addr, |
678 |
|
port); |
679 |
|
break; |
680 |
|
} |
681 |
|
if (type != SOCK_STREAM) |
682 |
|
return error; |
683 |
|
switch (sock->sk->sk_family) { |
684 |
|
case PF_INET: |
685 |
|
case PF_INET6: |
686 |
|
if (!ccs_capable(CCS_INET_STREAM_SOCKET_CONNECT)) |
687 |
|
error = -EPERM; |
688 |
|
break; |
689 |
|
} |
690 |
|
return error; |
691 |
|
} |
692 |
|
|
693 |
|
/* Check permission for setting the local IP address/port pair of a socket. */ |
694 |
|
static int __ccs_socket_bind_permission(struct socket *sock, |
695 |
|
struct sockaddr *addr, int addr_len) |
696 |
|
{ |
697 |
|
int error = 0; |
698 |
|
const unsigned int type = sock->type; |
699 |
|
/* Nothing to do if I am a kernel service. */ |
700 |
|
if (segment_eq(get_fs(), KERNEL_DS)) |
701 |
|
return 0; |
702 |
|
switch (type) { |
703 |
|
case SOCK_STREAM: |
704 |
|
case SOCK_DGRAM: |
705 |
|
case SOCK_RAW: |
706 |
|
break; |
707 |
|
default: |
708 |
|
return 0; |
709 |
|
} |
710 |
|
switch (addr->sa_family) { |
711 |
|
struct sockaddr_in6 *addr6; |
712 |
|
struct sockaddr_in *addr4; |
713 |
|
u16 port; |
714 |
|
case AF_INET6: |
715 |
|
if (addr_len < SIN6_LEN_RFC2133) |
716 |
|
break; |
717 |
|
addr6 = (struct sockaddr_in6 *) addr; |
718 |
|
if (type != SOCK_RAW) |
719 |
|
port = addr6->sin6_port; |
720 |
|
else |
721 |
|
port = htons(sock->sk->sk_protocol); |
722 |
|
error = ccs_network_bind_acl(true, type, |
723 |
|
addr6->sin6_addr.s6_addr, |
724 |
|
port); |
725 |
|
break; |
726 |
|
case AF_INET: |
727 |
|
if (addr_len < sizeof(struct sockaddr_in)) |
728 |
|
break; |
729 |
|
addr4 = (struct sockaddr_in *) addr; |
730 |
|
if (type != SOCK_RAW) |
731 |
|
port = addr4->sin_port; |
732 |
|
else |
733 |
|
port = htons(sock->sk->sk_protocol); |
734 |
|
error = ccs_network_bind_acl(false, type, |
735 |
|
(u8 *) &addr4->sin_addr, |
736 |
|
port); |
737 |
|
break; |
738 |
|
} |
739 |
|
return error; |
740 |
|
} |
741 |
|
|
742 |
|
/* |
743 |
|
* Check permission for accepting a TCP socket. |
744 |
|
* |
745 |
|
* Currently, the LSM hook for this purpose is not provided. |
746 |
|
*/ |
747 |
|
static int __ccs_socket_accept_permission(struct socket *sock, |
748 |
|
struct sockaddr *addr) |
749 |
|
{ |
750 |
|
int error = 0; |
751 |
|
int addr_len; |
752 |
|
/* Nothing to do if I am a kernel service. */ |
753 |
|
if (segment_eq(get_fs(), KERNEL_DS)) |
754 |
|
return 0; |
755 |
|
switch (sock->sk->sk_family) { |
756 |
|
case PF_INET: |
757 |
|
case PF_INET6: |
758 |
|
break; |
759 |
|
default: |
760 |
|
return 0; |
761 |
|
} |
762 |
|
error = sock->ops->getname(sock, addr, &addr_len, 2); |
763 |
|
if (error) |
764 |
|
return error; |
765 |
|
switch (addr->sa_family) { |
766 |
|
struct sockaddr_in6 *addr6; |
767 |
|
struct sockaddr_in *addr4; |
768 |
|
case AF_INET6: |
769 |
|
addr6 = (struct sockaddr_in6 *) addr; |
770 |
|
error = ccs_network_accept_acl(true, |
771 |
|
addr6->sin6_addr.s6_addr, |
772 |
|
addr6->sin6_port); |
773 |
|
break; |
774 |
|
case AF_INET: |
775 |
|
addr4 = (struct sockaddr_in *) addr; |
776 |
|
error = ccs_network_accept_acl(false, |
777 |
|
(u8 *) &addr4->sin_addr, |
778 |
|
addr4->sin_port); |
779 |
|
break; |
780 |
|
} |
781 |
|
return error; |
782 |
|
} |
783 |
|
|
784 |
|
/* Check permission for sending a datagram via a UDP or RAW socket. */ |
785 |
|
static int __ccs_socket_sendmsg_permission(struct socket *sock, |
786 |
|
struct msghdr *msg, int size) |
787 |
|
{ |
788 |
|
struct sockaddr *addr = (struct sockaddr *) msg->msg_name; |
789 |
|
const int addr_len = msg->msg_namelen; |
790 |
|
int error = 0; |
791 |
|
const int type = sock->type; |
792 |
|
/* Nothing to do if I am a kernel service. */ |
793 |
|
if (segment_eq(get_fs(), KERNEL_DS)) |
794 |
|
return 0; |
795 |
|
if (!addr || (type != SOCK_DGRAM && type != SOCK_RAW)) |
796 |
|
return 0; |
797 |
|
switch (addr->sa_family) { |
798 |
|
struct sockaddr_in6 *addr6; |
799 |
|
struct sockaddr_in *addr4; |
800 |
|
u16 port; |
801 |
|
case AF_INET6: |
802 |
|
if (addr_len < SIN6_LEN_RFC2133) |
803 |
|
break; |
804 |
|
addr6 = (struct sockaddr_in6 *) addr; |
805 |
|
if (type == SOCK_DGRAM) |
806 |
|
port = addr6->sin6_port; |
807 |
|
else |
808 |
|
port = htons(sock->sk->sk_protocol); |
809 |
|
error = ccs_network_sendmsg_acl(true, type, |
810 |
|
addr6->sin6_addr.s6_addr, |
811 |
|
port); |
812 |
|
break; |
813 |
|
case AF_INET: |
814 |
|
if (addr_len < sizeof(struct sockaddr_in)) |
815 |
|
break; |
816 |
|
addr4 = (struct sockaddr_in *) addr; |
817 |
|
if (type == SOCK_DGRAM) |
818 |
|
port = addr4->sin_port; |
819 |
|
else |
820 |
|
port = htons(sock->sk->sk_protocol); |
821 |
|
error = ccs_network_sendmsg_acl(false, type, |
822 |
|
(u8 *) &addr4->sin_addr, port); |
823 |
|
break; |
824 |
|
} |
825 |
|
return error; |
826 |
|
} |
827 |
|
|
828 |
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) |
829 |
|
#if !defined(RHEL_MAJOR) || RHEL_MAJOR != 5 |
830 |
|
#if !defined(AX_MAJOR) || AX_MAJOR != 3 || !defined(AX_MINOR) || AX_MINOR < 2 |
831 |
|
|
832 |
|
static inline struct iphdr *ip_hdr(const struct sk_buff *skb) |
833 |
|
{ |
834 |
|
return skb->nh.iph; |
835 |
|
} |
836 |
|
|
837 |
|
static inline struct udphdr *udp_hdr(const struct sk_buff *skb) |
838 |
|
{ |
839 |
|
return skb->h.uh; |
840 |
|
} |
841 |
|
|
842 |
|
static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb) |
843 |
|
{ |
844 |
|
return skb->nh.ipv6h; |
845 |
|
} |
846 |
|
|
847 |
|
#endif |
848 |
|
#endif |
849 |
|
#endif |
850 |
|
|
851 |
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12) |
852 |
|
static void skb_kill_datagram(struct sock *sk, struct sk_buff *skb, |
853 |
|
unsigned int flags) |
854 |
|
{ |
855 |
|
/* Clear queue. */ |
856 |
|
if (flags & MSG_PEEK) { |
857 |
|
int clear = 0; |
858 |
|
spin_lock_irq(&sk->sk_receive_queue.lock); |
859 |
|
if (skb == skb_peek(&sk->sk_receive_queue)) { |
860 |
|
__skb_unlink(skb, &sk->sk_receive_queue); |
861 |
|
clear = 1; |
862 |
|
} |
863 |
|
spin_unlock_irq(&sk->sk_receive_queue.lock); |
864 |
|
if (clear) |
865 |
|
kfree_skb(skb); |
866 |
|
} |
867 |
|
skb_free_datagram(sk, skb); |
868 |
|
} |
869 |
|
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) |
870 |
|
static void skb_kill_datagram(struct sock *sk, struct sk_buff *skb, |
871 |
|
unsigned int flags) |
872 |
|
{ |
873 |
|
/* Clear queue. */ |
874 |
|
if (flags & MSG_PEEK) { |
875 |
|
int clear = 0; |
876 |
|
spin_lock_bh(&sk->sk_receive_queue.lock); |
877 |
|
if (skb == skb_peek(&sk->sk_receive_queue)) { |
878 |
|
__skb_unlink(skb, &sk->sk_receive_queue); |
879 |
|
clear = 1; |
880 |
|
} |
881 |
|
spin_unlock_bh(&sk->sk_receive_queue.lock); |
882 |
|
if (clear) |
883 |
|
kfree_skb(skb); |
884 |
|
} |
885 |
|
skb_free_datagram(sk, skb); |
886 |
|
} |
887 |
|
#endif |
888 |
|
|
889 |
|
/* |
890 |
|
* Check permission for receiving a datagram via a UDP or RAW socket. |
891 |
|
* |
892 |
|
* Currently, the LSM hook for this purpose is not provided. |
893 |
|
*/ |
894 |
|
static int __ccs_socket_recvmsg_permission(struct sock *sk, |
895 |
|
struct sk_buff *skb, |
896 |
|
const unsigned int flags) |
897 |
|
{ |
898 |
|
int error = 0; |
899 |
|
const unsigned int type = sk->sk_type; |
900 |
|
if (type != SOCK_DGRAM && type != SOCK_RAW) |
901 |
|
return 0; |
902 |
|
/* Nothing to do if I am a kernel service. */ |
903 |
|
if (segment_eq(get_fs(), KERNEL_DS)) |
904 |
|
return 0; |
905 |
|
|
906 |
|
switch (sk->sk_family) { |
907 |
|
struct in6_addr sin6; |
908 |
|
struct in_addr sin4; |
909 |
|
u16 port; |
910 |
|
case PF_INET6: |
911 |
|
if (type == SOCK_DGRAM) { /* UDP IPv6 */ |
912 |
|
if (skb->protocol == htons(ETH_P_IP)) { |
913 |
|
ipv6_addr_set(&sin6, 0, 0, htonl(0xffff), |
914 |
|
ip_hdr(skb)->saddr); |
915 |
|
} else { |
916 |
|
ipv6_addr_copy(&sin6, &ipv6_hdr(skb)->saddr); |
917 |
|
} |
918 |
|
port = udp_hdr(skb)->source; |
919 |
|
} else { /* RAW IPv6 */ |
920 |
|
ipv6_addr_copy(&sin6, &ipv6_hdr(skb)->saddr); |
921 |
|
port = htons(sk->sk_protocol); |
922 |
|
} |
923 |
|
error = ccs_network_recvmsg_acl(true, type, |
924 |
|
(u8 *) &sin6, port); |
925 |
|
break; |
926 |
|
case PF_INET: |
927 |
|
if (type == SOCK_DGRAM) { /* UDP IPv4 */ |
928 |
|
sin4.s_addr = ip_hdr(skb)->saddr; |
929 |
|
port = udp_hdr(skb)->source; |
930 |
|
} else { /* RAW IPv4 */ |
931 |
|
sin4.s_addr = ip_hdr(skb)->saddr; |
932 |
|
port = htons(sk->sk_protocol); |
933 |
|
} |
934 |
|
error = ccs_network_recvmsg_acl(false, type, |
935 |
|
(u8 *) &sin4, port); |
936 |
|
break; |
937 |
|
} |
938 |
|
if (!error) |
939 |
|
return 0; |
940 |
|
/* |
941 |
|
* Remove from queue if MSG_PEEK is used so that |
942 |
|
* the head message from unwanted source in receive queue will not |
943 |
|
* prevent the caller from picking up next message from wanted source |
944 |
|
* when the caller is using MSG_PEEK flag for picking up. |
945 |
|
*/ |
946 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) |
947 |
|
if (type == SOCK_DGRAM) |
948 |
|
lock_sock(sk); |
949 |
|
#endif |
950 |
|
skb_kill_datagram(sk, skb, flags); |
951 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) |
952 |
|
if (type == SOCK_DGRAM) |
953 |
|
release_sock(sk); |
954 |
|
#endif |
955 |
|
/* Hope less harmful than -EPERM. */ |
956 |
|
return -ENOMEM; |
957 |
|
} |
958 |
|
|
959 |
|
void __init ccs_network_init(void) |
960 |
|
{ |
961 |
|
ccsecurity_ops.socket_create_permission = |
962 |
|
__ccs_socket_create_permission; |
963 |
|
ccsecurity_ops.socket_listen_permission = |
964 |
|
__ccs_socket_listen_permission; |
965 |
|
ccsecurity_ops.socket_connect_permission = |
966 |
|
__ccs_socket_connect_permission; |
967 |
|
ccsecurity_ops.socket_bind_permission = __ccs_socket_bind_permission; |
968 |
|
ccsecurity_ops.socket_accept_permission = |
969 |
|
__ccs_socket_accept_permission; |
970 |
|
ccsecurity_ops.socket_sendmsg_permission = |
971 |
|
__ccs_socket_sendmsg_permission; |
972 |
|
ccsecurity_ops.socket_recvmsg_permission = |
973 |
|
__ccs_socket_recvmsg_permission; |
974 |
|
} |
975 |
|
|
976 |
|
#endif |