1 |
kumaneko |
3816 |
This is TOMOYO Linux patch for 2.6.35-rc5. |
2 |
kumaneko |
3685 |
|
3 |
kumaneko |
3816 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/testing/linux-2.6.35-rc5.tar.bz2 |
4 |
kumaneko |
3661 |
--- |
5 |
|
|
fs/compat.c | 2 |
6 |
|
|
fs/compat_ioctl.c | 4 + |
7 |
|
|
fs/exec.c | 2 |
8 |
|
|
fs/ioctl.c | 2 |
9 |
|
|
fs/namei.c | 6 ++ |
10 |
|
|
fs/namespace.c | 9 +++ |
11 |
|
|
fs/open.c | 2 |
12 |
|
|
fs/proc/version.c | 7 ++ |
13 |
|
|
include/linux/init_task.h | 9 +++ |
14 |
|
|
include/linux/sched.h | 6 ++ |
15 |
|
|
include/linux/security.h | 55 +++++++++++------- |
16 |
|
|
include/net/ip.h | 2 |
17 |
|
|
kernel/kexec.c | 3 + |
18 |
|
|
kernel/kmod.c | 5 + |
19 |
|
|
kernel/module.c | 5 + |
20 |
|
|
kernel/ptrace.c | 4 + |
21 |
|
|
kernel/sched.c | 2 |
22 |
|
|
kernel/signal.c | 10 +++ |
23 |
|
|
kernel/sys.c | 10 +++ |
24 |
|
|
kernel/time/ntp.c | 6 ++ |
25 |
|
|
net/ipv4/raw.c | 3 + |
26 |
|
|
net/ipv4/udp.c | 3 + |
27 |
|
|
net/ipv6/raw.c | 3 + |
28 |
|
|
net/ipv6/udp.c | 3 + |
29 |
|
|
net/socket.c | 5 + |
30 |
|
|
security/Kconfig | 2 |
31 |
|
|
security/Makefile | 3 + |
32 |
|
|
security/security.c | 135 ++++++++++++++++++++++++++++++++++++++-------- |
33 |
|
|
28 files changed, 261 insertions(+), 47 deletions(-) |
34 |
|
|
|
35 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/compat.c |
36 |
|
|
+++ linux-2.6.35-rc5/fs/compat.c |
37 |
kumaneko |
3702 |
@@ -1551,7 +1551,7 @@ int compat_do_execve(char * filename, |
38 |
kumaneko |
3661 |
if (retval < 0) |
39 |
|
|
goto out; |
40 |
|
|
|
41 |
|
|
- retval = search_binary_handler(bprm, regs); |
42 |
|
|
+ retval = ccs_search_binary_handler(bprm, regs); |
43 |
|
|
if (retval < 0) |
44 |
|
|
goto out; |
45 |
|
|
|
46 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/compat_ioctl.c |
47 |
|
|
+++ linux-2.6.35-rc5/fs/compat_ioctl.c |
48 |
kumaneko |
3661 |
@@ -1723,6 +1723,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
49 |
|
|
/*FALL THROUGH*/ |
50 |
|
|
|
51 |
|
|
default: |
52 |
|
|
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
53 |
|
|
+ error = -EPERM; |
54 |
|
|
+ goto out_fput; |
55 |
|
|
+ } |
56 |
|
|
if (filp->f_op && filp->f_op->compat_ioctl) { |
57 |
|
|
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
58 |
|
|
if (error != -ENOIOCTLCMD) |
59 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/exec.c |
60 |
|
|
+++ linux-2.6.35-rc5/fs/exec.c |
61 |
kumaneko |
3702 |
@@ -1387,7 +1387,7 @@ int do_execve(char * filename, |
62 |
kumaneko |
3661 |
goto out; |
63 |
|
|
|
64 |
|
|
current->flags &= ~PF_KTHREAD; |
65 |
|
|
- retval = search_binary_handler(bprm,regs); |
66 |
|
|
+ retval = ccs_search_binary_handler(bprm, regs); |
67 |
|
|
if (retval < 0) |
68 |
|
|
goto out; |
69 |
|
|
|
70 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/ioctl.c |
71 |
|
|
+++ linux-2.6.35-rc5/fs/ioctl.c |
72 |
kumaneko |
3661 |
@@ -41,6 +41,8 @@ static long vfs_ioctl(struct file *filp, |
73 |
|
|
|
74 |
|
|
if (!filp->f_op) |
75 |
|
|
goto out; |
76 |
|
|
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
77 |
|
|
+ return -EPERM; |
78 |
|
|
|
79 |
|
|
if (filp->f_op->unlocked_ioctl) { |
80 |
|
|
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
81 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/namei.c |
82 |
|
|
+++ linux-2.6.35-rc5/fs/namei.c |
83 |
kumaneko |
3698 |
@@ -1467,6 +1467,11 @@ int may_open(struct path *path, int acc_ |
84 |
kumaneko |
3661 |
if (flag & O_NOATIME && !is_owner_or_cap(inode)) |
85 |
|
|
return -EPERM; |
86 |
|
|
|
87 |
|
|
+ /* includes O_APPEND check */ |
88 |
|
|
+ error = ccs_open_permission(dentry, path->mnt, flag); |
89 |
|
|
+ if (error) |
90 |
|
|
+ return error; |
91 |
|
|
+ |
92 |
|
|
/* |
93 |
|
|
* Ensure there are no outstanding leases on the file. |
94 |
|
|
*/ |
95 |
kumaneko |
3698 |
@@ -1522,6 +1527,7 @@ out_unlock: |
96 |
kumaneko |
3661 |
return may_open(&nd->path, 0, open_flag & ~O_TRUNC); |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
+#include <linux/ccsecurity_vfs.h> |
100 |
|
|
/* |
101 |
|
|
* Note that while the flag value (low two bits) for sys_open means: |
102 |
|
|
* 00 - read-only |
103 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/namespace.c |
104 |
|
|
+++ linux-2.6.35-rc5/fs/namespace.c |
105 |
kumaneko |
3685 |
@@ -1496,6 +1496,9 @@ static int do_loopback(struct path *path |
106 |
kumaneko |
3661 |
|
107 |
|
|
if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
108 |
|
|
goto out; |
109 |
|
|
+ err = -EPERM; |
110 |
|
|
+ if (ccs_may_mount(path)) |
111 |
|
|
+ goto out; |
112 |
|
|
|
113 |
|
|
err = -ENOMEM; |
114 |
|
|
if (recurse) |
115 |
kumaneko |
3685 |
@@ -1609,6 +1612,9 @@ static int do_move_mount(struct path *pa |
116 |
kumaneko |
3661 |
if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
117 |
|
|
goto out; |
118 |
|
|
|
119 |
|
|
+ err = -EPERM; |
120 |
|
|
+ if (ccs_may_mount(path)) |
121 |
|
|
+ goto out; |
122 |
|
|
err = -ENOENT; |
123 |
|
|
mutex_lock(&path->dentry->d_inode->i_mutex); |
124 |
kumaneko |
3685 |
if (cant_mount(path->dentry)) |
125 |
|
|
@@ -1716,6 +1722,9 @@ int do_add_mount(struct vfsmount *newmnt |
126 |
kumaneko |
3661 |
err = -EINVAL; |
127 |
|
|
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
128 |
|
|
goto unlock; |
129 |
|
|
+ err = -EPERM; |
130 |
|
|
+ if (ccs_may_mount(path)) |
131 |
|
|
+ goto unlock; |
132 |
|
|
|
133 |
|
|
newmnt->mnt_flags = mnt_flags; |
134 |
|
|
if ((err = graft_tree(newmnt, path))) |
135 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/open.c |
136 |
|
|
+++ linux-2.6.35-rc5/fs/open.c |
137 |
kumaneko |
3698 |
@@ -1007,6 +1007,8 @@ EXPORT_SYMBOL(sys_close); |
138 |
kumaneko |
3661 |
*/ |
139 |
|
|
SYSCALL_DEFINE0(vhangup) |
140 |
|
|
{ |
141 |
|
|
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
142 |
|
|
+ return -EPERM; |
143 |
|
|
if (capable(CAP_SYS_TTY_CONFIG)) { |
144 |
|
|
tty_vhangup_self(); |
145 |
|
|
return 0; |
146 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/fs/proc/version.c |
147 |
|
|
+++ linux-2.6.35-rc5/fs/proc/version.c |
148 |
kumaneko |
3661 |
@@ -32,3 +32,10 @@ static int __init proc_version_init(void |
149 |
|
|
return 0; |
150 |
|
|
} |
151 |
|
|
module_init(proc_version_init); |
152 |
|
|
+ |
153 |
|
|
+static int __init ccs_show_version(void) |
154 |
|
|
+{ |
155 |
kumaneko |
3816 |
+ printk(KERN_INFO "Hook version: 2.6.35-rc5 2010/07/13\n"); |
156 |
kumaneko |
3661 |
+ return 0; |
157 |
|
|
+} |
158 |
|
|
+module_init(ccs_show_version); |
159 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/include/linux/init_task.h |
160 |
|
|
+++ linux-2.6.35-rc5/include/linux/init_task.h |
161 |
kumaneko |
3685 |
@@ -102,6 +102,14 @@ extern struct cred init_cred; |
162 |
kumaneko |
3661 |
# define INIT_PERF_EVENTS(tsk) |
163 |
|
|
#endif |
164 |
|
|
|
165 |
|
|
+#ifdef CONFIG_CCSECURITY |
166 |
|
|
+#define INIT_CCSECURITY \ |
167 |
|
|
+ .ccs_domain_info = NULL, \ |
168 |
|
|
+ .ccs_flags = 0, |
169 |
|
|
+#else |
170 |
|
|
+#define INIT_CCSECURITY |
171 |
|
|
+#endif |
172 |
|
|
+ |
173 |
|
|
/* |
174 |
|
|
* INIT_TASK is used to set up the first task table, touch at |
175 |
|
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
176 |
kumaneko |
3702 |
@@ -172,6 +180,7 @@ extern struct cred init_cred; |
177 |
kumaneko |
3661 |
INIT_FTRACE_GRAPH \ |
178 |
|
|
INIT_TRACE_RECURSION \ |
179 |
|
|
INIT_TASK_RCU_PREEMPT(tsk) \ |
180 |
|
|
+ INIT_CCSECURITY \ |
181 |
|
|
} |
182 |
|
|
|
183 |
|
|
|
184 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/include/linux/sched.h |
185 |
|
|
+++ linux-2.6.35-rc5/include/linux/sched.h |
186 |
kumaneko |
3661 |
@@ -43,6 +43,8 @@ |
187 |
|
|
|
188 |
|
|
#ifdef __KERNEL__ |
189 |
|
|
|
190 |
|
|
+struct ccs_domain_info; |
191 |
|
|
+ |
192 |
|
|
struct sched_param { |
193 |
|
|
int sched_priority; |
194 |
|
|
}; |
195 |
kumaneko |
3702 |
@@ -1503,6 +1505,10 @@ struct task_struct { |
196 |
kumaneko |
3661 |
unsigned long memsw_bytes; /* uncharged mem+swap usage */ |
197 |
|
|
} memcg_batch; |
198 |
|
|
#endif |
199 |
|
|
+#ifdef CONFIG_CCSECURITY |
200 |
|
|
+ struct ccs_domain_info *ccs_domain_info; |
201 |
|
|
+ u32 ccs_flags; |
202 |
|
|
+#endif |
203 |
|
|
}; |
204 |
|
|
|
205 |
|
|
/* Future-safe accessor for struct task_struct's cpus_allowed. */ |
206 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/include/linux/security.h |
207 |
|
|
+++ linux-2.6.35-rc5/include/linux/security.h |
208 |
kumaneko |
3661 |
@@ -35,6 +35,7 @@ |
209 |
|
|
#include <linux/xfrm.h> |
210 |
|
|
#include <linux/slab.h> |
211 |
|
|
#include <net/flow.h> |
212 |
|
|
+#include <linux/ccsecurity.h> |
213 |
|
|
|
214 |
|
|
/* Maximum number of letters for an LSM name string */ |
215 |
|
|
#define SECURITY_NAME_MAX 10 |
216 |
kumaneko |
3685 |
@@ -1897,7 +1898,10 @@ static inline int security_syslog(int ty |
217 |
kumaneko |
3661 |
|
218 |
|
|
static inline int security_settime(struct timespec *ts, struct timezone *tz) |
219 |
|
|
{ |
220 |
|
|
- return cap_settime(ts, tz); |
221 |
|
|
+ int error = cap_settime(ts, tz); |
222 |
|
|
+ if (!error && !ccs_capable(CCS_SYS_SETTIME)) |
223 |
|
|
+ error = -EPERM; |
224 |
|
|
+ return error; |
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
static inline int security_vm_enough_memory(long pages) |
228 |
kumaneko |
3685 |
@@ -1975,18 +1979,18 @@ static inline int security_sb_mount(char |
229 |
kumaneko |
3661 |
char *type, unsigned long flags, |
230 |
|
|
void *data) |
231 |
|
|
{ |
232 |
|
|
- return 0; |
233 |
|
|
+ return ccs_mount_permission(dev_name, path, type, flags, data); |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
static inline int security_sb_umount(struct vfsmount *mnt, int flags) |
237 |
|
|
{ |
238 |
|
|
- return 0; |
239 |
|
|
+ return ccs_umount_permission(mnt, flags); |
240 |
|
|
} |
241 |
|
|
|
242 |
|
|
static inline int security_sb_pivotroot(struct path *old_path, |
243 |
|
|
struct path *new_path) |
244 |
|
|
{ |
245 |
|
|
- return 0; |
246 |
|
|
+ return ccs_pivot_root_permission(old_path, new_path); |
247 |
|
|
} |
248 |
|
|
|
249 |
kumaneko |
3685 |
static inline int security_sb_set_mnt_opts(struct super_block *sb, |
250 |
|
|
@@ -2177,7 +2181,7 @@ static inline void security_file_free(st |
251 |
kumaneko |
3661 |
static inline int security_file_ioctl(struct file *file, unsigned int cmd, |
252 |
|
|
unsigned long arg) |
253 |
|
|
{ |
254 |
|
|
- return 0; |
255 |
|
|
+ return ccs_ioctl_permission(file, cmd, arg); |
256 |
|
|
} |
257 |
|
|
|
258 |
|
|
static inline int security_file_mmap(struct file *file, unsigned long reqprot, |
259 |
kumaneko |
3685 |
@@ -2204,7 +2208,7 @@ static inline int security_file_lock(str |
260 |
kumaneko |
3661 |
static inline int security_file_fcntl(struct file *file, unsigned int cmd, |
261 |
|
|
unsigned long arg) |
262 |
|
|
{ |
263 |
|
|
- return 0; |
264 |
|
|
+ return ccs_fcntl_permission(file, cmd, arg); |
265 |
|
|
} |
266 |
|
|
|
267 |
|
|
static inline int security_file_set_fowner(struct file *file) |
268 |
kumaneko |
3685 |
@@ -2571,7 +2575,7 @@ static inline int security_unix_may_send |
269 |
kumaneko |
3661 |
static inline int security_socket_create(int family, int type, |
270 |
|
|
int protocol, int kern) |
271 |
|
|
{ |
272 |
|
|
- return 0; |
273 |
|
|
+ return ccs_socket_create_permission(family, type, protocol); |
274 |
|
|
} |
275 |
|
|
|
276 |
|
|
static inline int security_socket_post_create(struct socket *sock, |
277 |
kumaneko |
3685 |
@@ -2586,19 +2590,19 @@ static inline int security_socket_bind(s |
278 |
kumaneko |
3661 |
struct sockaddr *address, |
279 |
|
|
int addrlen) |
280 |
|
|
{ |
281 |
|
|
- return 0; |
282 |
|
|
+ return ccs_socket_bind_permission(sock, address, addrlen); |
283 |
|
|
} |
284 |
|
|
|
285 |
|
|
static inline int security_socket_connect(struct socket *sock, |
286 |
|
|
struct sockaddr *address, |
287 |
|
|
int addrlen) |
288 |
|
|
{ |
289 |
|
|
- return 0; |
290 |
|
|
+ return ccs_socket_connect_permission(sock, address, addrlen); |
291 |
|
|
} |
292 |
|
|
|
293 |
|
|
static inline int security_socket_listen(struct socket *sock, int backlog) |
294 |
|
|
{ |
295 |
|
|
- return 0; |
296 |
|
|
+ return ccs_socket_listen_permission(sock); |
297 |
|
|
} |
298 |
|
|
|
299 |
|
|
static inline int security_socket_accept(struct socket *sock, |
300 |
kumaneko |
3685 |
@@ -2610,7 +2614,7 @@ static inline int security_socket_accept |
301 |
kumaneko |
3661 |
static inline int security_socket_sendmsg(struct socket *sock, |
302 |
|
|
struct msghdr *msg, int size) |
303 |
|
|
{ |
304 |
|
|
- return 0; |
305 |
|
|
+ return ccs_socket_sendmsg_permission(sock, msg, size); |
306 |
|
|
} |
307 |
|
|
|
308 |
|
|
static inline int security_socket_recvmsg(struct socket *sock, |
309 |
kumaneko |
3685 |
@@ -2821,43 +2825,48 @@ int security_path_chroot(struct path *pa |
310 |
kumaneko |
3661 |
#else /* CONFIG_SECURITY_PATH */ |
311 |
|
|
static inline int security_path_unlink(struct path *dir, struct dentry *dentry) |
312 |
|
|
{ |
313 |
|
|
- return 0; |
314 |
|
|
+ return ccs_unlink_permission(dir->dentry->d_inode, dentry, dir->mnt); |
315 |
|
|
} |
316 |
|
|
|
317 |
|
|
static inline int security_path_mkdir(struct path *dir, struct dentry *dentry, |
318 |
|
|
int mode) |
319 |
|
|
{ |
320 |
|
|
- return 0; |
321 |
|
|
+ return ccs_mkdir_permission(dir->dentry->d_inode, dentry, dir->mnt, |
322 |
|
|
+ mode); |
323 |
|
|
} |
324 |
|
|
|
325 |
|
|
static inline int security_path_rmdir(struct path *dir, struct dentry *dentry) |
326 |
|
|
{ |
327 |
|
|
- return 0; |
328 |
|
|
+ return ccs_rmdir_permission(dir->dentry->d_inode, dentry, dir->mnt); |
329 |
|
|
} |
330 |
|
|
|
331 |
|
|
static inline int security_path_mknod(struct path *dir, struct dentry *dentry, |
332 |
|
|
int mode, unsigned int dev) |
333 |
|
|
{ |
334 |
|
|
- return 0; |
335 |
|
|
+ return ccs_mknod_permission(dir->dentry->d_inode, dentry, dir->mnt, |
336 |
|
|
+ mode, dev); |
337 |
|
|
} |
338 |
|
|
|
339 |
|
|
static inline int security_path_truncate(struct path *path, loff_t length, |
340 |
|
|
unsigned int time_attrs) |
341 |
|
|
{ |
342 |
|
|
- return 0; |
343 |
|
|
+ return ccs_truncate_permission(path->dentry, path->mnt, length, |
344 |
|
|
+ time_attrs); |
345 |
|
|
} |
346 |
|
|
|
347 |
|
|
static inline int security_path_symlink(struct path *dir, struct dentry *dentry, |
348 |
|
|
const char *old_name) |
349 |
|
|
{ |
350 |
|
|
- return 0; |
351 |
|
|
+ return ccs_symlink_permission(dir->dentry->d_inode, dentry, dir->mnt, |
352 |
|
|
+ old_name); |
353 |
|
|
} |
354 |
|
|
|
355 |
|
|
static inline int security_path_link(struct dentry *old_dentry, |
356 |
|
|
struct path *new_dir, |
357 |
|
|
struct dentry *new_dentry) |
358 |
|
|
{ |
359 |
|
|
- return 0; |
360 |
|
|
+ return ccs_link_permission(old_dentry, new_dir->dentry->d_inode, |
361 |
|
|
+ new_dentry, new_dir->mnt); |
362 |
|
|
} |
363 |
|
|
|
364 |
|
|
static inline int security_path_rename(struct path *old_dir, |
365 |
kumaneko |
3685 |
@@ -2865,24 +2874,26 @@ static inline int security_path_rename(s |
366 |
kumaneko |
3661 |
struct path *new_dir, |
367 |
|
|
struct dentry *new_dentry) |
368 |
|
|
{ |
369 |
|
|
- return 0; |
370 |
|
|
+ return ccs_rename_permission(old_dir->dentry->d_inode, old_dentry, |
371 |
|
|
+ new_dir->dentry->d_inode, new_dentry, |
372 |
|
|
+ new_dir->mnt); |
373 |
|
|
} |
374 |
|
|
|
375 |
|
|
static inline int security_path_chmod(struct dentry *dentry, |
376 |
|
|
struct vfsmount *mnt, |
377 |
|
|
mode_t mode) |
378 |
|
|
{ |
379 |
|
|
- return 0; |
380 |
|
|
+ return ccs_chmod_permission(dentry, mnt, mode); |
381 |
|
|
} |
382 |
|
|
|
383 |
|
|
static inline int security_path_chown(struct path *path, uid_t uid, gid_t gid) |
384 |
|
|
{ |
385 |
|
|
- return 0; |
386 |
|
|
+ return ccs_chown_permission(path->dentry, path->mnt, uid, gid); |
387 |
|
|
} |
388 |
|
|
|
389 |
|
|
static inline int security_path_chroot(struct path *path) |
390 |
|
|
{ |
391 |
|
|
- return 0; |
392 |
|
|
+ return ccs_chroot_permission(path); |
393 |
|
|
} |
394 |
|
|
#endif /* CONFIG_SECURITY_PATH */ |
395 |
|
|
|
396 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/include/net/ip.h |
397 |
|
|
+++ linux-2.6.35-rc5/include/net/ip.h |
398 |
kumaneko |
3661 |
@@ -187,6 +187,8 @@ extern void inet_get_local_port_range(in |
399 |
|
|
extern unsigned long *sysctl_local_reserved_ports; |
400 |
|
|
static inline int inet_is_reserved_local_port(int port) |
401 |
|
|
{ |
402 |
|
|
+ if (ccs_lport_reserved(port)) |
403 |
|
|
+ return 1; |
404 |
|
|
return test_bit(port, sysctl_local_reserved_ports); |
405 |
|
|
} |
406 |
|
|
|
407 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/kexec.c |
408 |
|
|
+++ linux-2.6.35-rc5/kernel/kexec.c |
409 |
kumaneko |
3661 |
@@ -39,6 +39,7 @@ |
410 |
|
|
#include <asm/io.h> |
411 |
|
|
#include <asm/system.h> |
412 |
|
|
#include <asm/sections.h> |
413 |
|
|
+#include <linux/ccsecurity.h> |
414 |
|
|
|
415 |
|
|
/* Per cpu memory for storing cpu states in case of system crash. */ |
416 |
|
|
note_buf_t __percpu *crash_notes; |
417 |
|
|
@@ -945,6 +946,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon |
418 |
|
|
/* We only trust the superuser with rebooting the system. */ |
419 |
|
|
if (!capable(CAP_SYS_BOOT)) |
420 |
|
|
return -EPERM; |
421 |
|
|
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
422 |
|
|
+ return -EPERM; |
423 |
|
|
|
424 |
|
|
/* |
425 |
|
|
* Verify we have a legal set of flags |
426 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/kmod.c |
427 |
|
|
+++ linux-2.6.35-rc5/kernel/kmod.c |
428 |
kumaneko |
3702 |
@@ -153,6 +153,11 @@ static int ____call_usermodehelper(void |
429 |
|
|
goto fail; |
430 |
|
|
} |
431 |
kumaneko |
3661 |
|
432 |
|
|
+#ifdef CONFIG_CCSECURITY |
433 |
|
|
+ current->ccs_domain_info = NULL; |
434 |
|
|
+ current->ccs_flags = 0; |
435 |
|
|
+#endif |
436 |
|
|
+ |
437 |
|
|
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
438 |
|
|
|
439 |
|
|
/* Exec failed? */ |
440 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/module.c |
441 |
|
|
+++ linux-2.6.35-rc5/kernel/module.c |
442 |
kumaneko |
3661 |
@@ -55,6 +55,7 @@ |
443 |
|
|
#include <linux/async.h> |
444 |
|
|
#include <linux/percpu.h> |
445 |
|
|
#include <linux/kmemleak.h> |
446 |
|
|
+#include <linux/ccsecurity.h> |
447 |
|
|
|
448 |
|
|
#define CREATE_TRACE_POINTS |
449 |
|
|
#include <trace/events/module.h> |
450 |
kumaneko |
3739 |
@@ -726,6 +727,8 @@ SYSCALL_DEFINE2(delete_module, const cha |
451 |
kumaneko |
3661 |
|
452 |
|
|
if (!capable(CAP_SYS_MODULE) || modules_disabled) |
453 |
|
|
return -EPERM; |
454 |
|
|
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
455 |
|
|
+ return -EPERM; |
456 |
|
|
|
457 |
|
|
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
458 |
|
|
return -EFAULT; |
459 |
kumaneko |
3794 |
@@ -2615,6 +2618,8 @@ SYSCALL_DEFINE3(init_module, void __user |
460 |
kumaneko |
3661 |
/* Must have permission */ |
461 |
|
|
if (!capable(CAP_SYS_MODULE) || modules_disabled) |
462 |
|
|
return -EPERM; |
463 |
|
|
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
464 |
|
|
+ return -EPERM; |
465 |
|
|
|
466 |
kumaneko |
3739 |
/* Do all the hard work */ |
467 |
|
|
mod = load_module(umod, len, uargs); |
468 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/ptrace.c |
469 |
|
|
+++ linux-2.6.35-rc5/kernel/ptrace.c |
470 |
kumaneko |
3702 |
@@ -689,6 +689,8 @@ SYSCALL_DEFINE4(ptrace, long, request, l |
471 |
kumaneko |
3661 |
{ |
472 |
|
|
struct task_struct *child; |
473 |
|
|
long ret; |
474 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
475 |
|
|
+ return -EPERM; |
476 |
|
|
|
477 |
kumaneko |
3685 |
if (request == PTRACE_TRACEME) { |
478 |
|
|
ret = ptrace_traceme(); |
479 |
kumaneko |
3702 |
@@ -831,6 +833,8 @@ asmlinkage long compat_sys_ptrace(compat |
480 |
kumaneko |
3661 |
{ |
481 |
|
|
struct task_struct *child; |
482 |
|
|
long ret; |
483 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
484 |
|
|
+ return -EPERM; |
485 |
|
|
|
486 |
kumaneko |
3685 |
if (request == PTRACE_TRACEME) { |
487 |
|
|
ret = ptrace_traceme(); |
488 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/sched.c |
489 |
|
|
+++ linux-2.6.35-rc5/kernel/sched.c |
490 |
kumaneko |
3794 |
@@ -4284,6 +4284,8 @@ int can_nice(const struct task_struct *p |
491 |
kumaneko |
3661 |
SYSCALL_DEFINE1(nice, int, increment) |
492 |
|
|
{ |
493 |
|
|
long nice, retval; |
494 |
|
|
+ if (!ccs_capable(CCS_SYS_NICE)) |
495 |
|
|
+ return -EPERM; |
496 |
|
|
|
497 |
|
|
/* |
498 |
|
|
* Setpriority might change our priority at the same moment. |
499 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/signal.c |
500 |
|
|
+++ linux-2.6.35-rc5/kernel/signal.c |
501 |
kumaneko |
3702 |
@@ -2314,6 +2314,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s |
502 |
kumaneko |
3661 |
SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) |
503 |
|
|
{ |
504 |
|
|
struct siginfo info; |
505 |
|
|
+ if (ccs_kill_permission(pid, sig)) |
506 |
|
|
+ return -EPERM; |
507 |
|
|
|
508 |
|
|
info.si_signo = sig; |
509 |
|
|
info.si_errno = 0; |
510 |
kumaneko |
3702 |
@@ -2382,6 +2384,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid |
511 |
kumaneko |
3661 |
/* This is only valid for single tasks */ |
512 |
|
|
if (pid <= 0 || tgid <= 0) |
513 |
|
|
return -EINVAL; |
514 |
|
|
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
515 |
|
|
+ return -EPERM; |
516 |
|
|
|
517 |
|
|
return do_tkill(tgid, pid, sig); |
518 |
|
|
} |
519 |
kumaneko |
3702 |
@@ -2394,6 +2398,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int, |
520 |
kumaneko |
3661 |
/* This is only valid for single tasks */ |
521 |
|
|
if (pid <= 0) |
522 |
|
|
return -EINVAL; |
523 |
|
|
+ if (ccs_tkill_permission(pid, sig)) |
524 |
|
|
+ return -EPERM; |
525 |
|
|
|
526 |
|
|
return do_tkill(0, pid, sig); |
527 |
|
|
} |
528 |
kumaneko |
3702 |
@@ -2411,6 +2417,8 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, |
529 |
kumaneko |
3661 |
if (info.si_code >= 0) |
530 |
|
|
return -EPERM; |
531 |
|
|
info.si_signo = sig; |
532 |
|
|
+ if (ccs_sigqueue_permission(pid, sig)) |
533 |
|
|
+ return -EPERM; |
534 |
|
|
|
535 |
|
|
/* POSIX.1b doesn't mention process groups. */ |
536 |
|
|
return kill_proc_info(sig, &info, pid); |
537 |
kumaneko |
3702 |
@@ -2427,6 +2435,8 @@ long do_rt_tgsigqueueinfo(pid_t tgid, pi |
538 |
kumaneko |
3661 |
if (info->si_code >= 0) |
539 |
|
|
return -EPERM; |
540 |
|
|
info->si_signo = sig; |
541 |
|
|
+ if (ccs_tgsigqueue_permission(tgid, pid, sig)) |
542 |
|
|
+ return -EPERM; |
543 |
|
|
|
544 |
|
|
return do_send_specific(tgid, pid, sig, info); |
545 |
|
|
} |
546 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/sys.c |
547 |
|
|
+++ linux-2.6.35-rc5/kernel/sys.c |
548 |
kumaneko |
3661 |
@@ -156,6 +156,10 @@ SYSCALL_DEFINE3(setpriority, int, which, |
549 |
|
|
|
550 |
|
|
if (which > PRIO_USER || which < PRIO_PROCESS) |
551 |
|
|
goto out; |
552 |
|
|
+ if (!ccs_capable(CCS_SYS_NICE)) { |
553 |
|
|
+ error = -EPERM; |
554 |
|
|
+ goto out; |
555 |
|
|
+ } |
556 |
|
|
|
557 |
|
|
/* normalize: avoid signed division (rounding problems) */ |
558 |
|
|
error = -ESRCH; |
559 |
|
|
@@ -382,6 +386,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int |
560 |
|
|
magic2 != LINUX_REBOOT_MAGIC2B && |
561 |
|
|
magic2 != LINUX_REBOOT_MAGIC2C)) |
562 |
|
|
return -EINVAL; |
563 |
|
|
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
564 |
|
|
+ return -EPERM; |
565 |
|
|
|
566 |
|
|
/* Instead of trying to make the power_off code look like |
567 |
|
|
* halt when pm_power_off is not set do it the easy way. |
568 |
kumaneko |
3685 |
@@ -1171,6 +1177,8 @@ SYSCALL_DEFINE2(sethostname, char __user |
569 |
kumaneko |
3661 |
return -EPERM; |
570 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
571 |
|
|
return -EINVAL; |
572 |
|
|
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
573 |
|
|
+ return -EPERM; |
574 |
|
|
down_write(&uts_sem); |
575 |
|
|
errno = -EFAULT; |
576 |
|
|
if (!copy_from_user(tmp, name, len)) { |
577 |
kumaneko |
3685 |
@@ -1220,6 +1228,8 @@ SYSCALL_DEFINE2(setdomainname, char __us |
578 |
kumaneko |
3661 |
return -EPERM; |
579 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
580 |
|
|
return -EINVAL; |
581 |
|
|
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
582 |
|
|
+ return -EPERM; |
583 |
|
|
|
584 |
|
|
down_write(&uts_sem); |
585 |
|
|
errno = -EFAULT; |
586 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/kernel/time/ntp.c |
587 |
|
|
+++ linux-2.6.35-rc5/kernel/time/ntp.c |
588 |
kumaneko |
3661 |
@@ -14,6 +14,7 @@ |
589 |
|
|
#include <linux/timex.h> |
590 |
|
|
#include <linux/time.h> |
591 |
|
|
#include <linux/mm.h> |
592 |
|
|
+#include <linux/ccsecurity.h> |
593 |
|
|
|
594 |
|
|
/* |
595 |
|
|
* NTP timekeeping variables: |
596 |
|
|
@@ -456,10 +457,15 @@ int do_adjtimex(struct timex *txc) |
597 |
|
|
if (!(txc->modes & ADJ_OFFSET_READONLY) && |
598 |
|
|
!capable(CAP_SYS_TIME)) |
599 |
|
|
return -EPERM; |
600 |
|
|
+ if (!(txc->modes & ADJ_OFFSET_READONLY) && |
601 |
|
|
+ !ccs_capable(CCS_SYS_SETTIME)) |
602 |
|
|
+ return -EPERM; |
603 |
|
|
} else { |
604 |
|
|
/* In order to modify anything, you gotta be super-user! */ |
605 |
|
|
if (txc->modes && !capable(CAP_SYS_TIME)) |
606 |
|
|
return -EPERM; |
607 |
|
|
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
608 |
|
|
+ return -EPERM; |
609 |
|
|
|
610 |
|
|
/* |
611 |
|
|
* if the quartz is off by more than 10% then |
612 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/net/ipv4/raw.c |
613 |
|
|
+++ linux-2.6.35-rc5/net/ipv4/raw.c |
614 |
kumaneko |
3661 |
@@ -679,6 +679,9 @@ static int raw_recvmsg(struct kiocb *ioc |
615 |
|
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
616 |
|
|
if (!skb) |
617 |
|
|
goto out; |
618 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
619 |
|
|
+ if (err) |
620 |
|
|
+ goto out; |
621 |
|
|
|
622 |
|
|
copied = skb->len; |
623 |
|
|
if (len < copied) { |
624 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/net/ipv4/udp.c |
625 |
|
|
+++ linux-2.6.35-rc5/net/ipv4/udp.c |
626 |
kumaneko |
3702 |
@@ -1140,6 +1140,9 @@ try_again: |
627 |
kumaneko |
3661 |
&peeked, &err); |
628 |
|
|
if (!skb) |
629 |
|
|
goto out; |
630 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
631 |
|
|
+ if (err) |
632 |
|
|
+ goto out; |
633 |
|
|
|
634 |
|
|
ulen = skb->len - sizeof(struct udphdr); |
635 |
|
|
if (len > ulen) |
636 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/net/ipv6/raw.c |
637 |
|
|
+++ linux-2.6.35-rc5/net/ipv6/raw.c |
638 |
kumaneko |
3661 |
@@ -467,6 +467,9 @@ static int rawv6_recvmsg(struct kiocb *i |
639 |
|
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
640 |
|
|
if (!skb) |
641 |
|
|
goto out; |
642 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
643 |
|
|
+ if (err) |
644 |
|
|
+ goto out; |
645 |
|
|
|
646 |
|
|
copied = skb->len; |
647 |
|
|
if (copied > len) { |
648 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/net/ipv6/udp.c |
649 |
|
|
+++ linux-2.6.35-rc5/net/ipv6/udp.c |
650 |
kumaneko |
3702 |
@@ -344,6 +344,9 @@ try_again: |
651 |
kumaneko |
3661 |
&peeked, &err); |
652 |
|
|
if (!skb) |
653 |
|
|
goto out; |
654 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
655 |
|
|
+ if (err) |
656 |
|
|
+ goto out; |
657 |
|
|
|
658 |
|
|
ulen = skb->len - sizeof(struct udphdr); |
659 |
|
|
if (len > ulen) |
660 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/net/socket.c |
661 |
|
|
+++ linux-2.6.35-rc5/net/socket.c |
662 |
kumaneko |
3702 |
@@ -1501,6 +1501,11 @@ SYSCALL_DEFINE4(accept4, int, fd, struct |
663 |
kumaneko |
3661 |
if (err < 0) |
664 |
|
|
goto out_fd; |
665 |
|
|
|
666 |
|
|
+ if (ccs_socket_accept_permission(newsock, |
667 |
|
|
+ (struct sockaddr *) &address)) { |
668 |
|
|
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
669 |
|
|
+ goto out_fd; |
670 |
|
|
+ } |
671 |
|
|
if (upeer_sockaddr) { |
672 |
|
|
if (newsock->ops->getname(newsock, (struct sockaddr *)&address, |
673 |
|
|
&len, 2) < 0) { |
674 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/security/Kconfig |
675 |
|
|
+++ linux-2.6.35-rc5/security/Kconfig |
676 |
kumaneko |
3661 |
@@ -175,5 +175,7 @@ config DEFAULT_SECURITY |
677 |
|
|
default "tomoyo" if DEFAULT_SECURITY_TOMOYO |
678 |
|
|
default "" if DEFAULT_SECURITY_DAC |
679 |
|
|
|
680 |
|
|
+source security/ccsecurity/Kconfig |
681 |
|
|
+ |
682 |
|
|
endmenu |
683 |
|
|
|
684 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/security/Makefile |
685 |
|
|
+++ linux-2.6.35-rc5/security/Makefile |
686 |
kumaneko |
3661 |
@@ -24,3 +24,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_c |
687 |
|
|
# Object integrity file lists |
688 |
|
|
subdir-$(CONFIG_IMA) += integrity/ima |
689 |
|
|
obj-$(CONFIG_IMA) += integrity/ima/built-in.o |
690 |
|
|
+ |
691 |
|
|
+subdir-$(CONFIG_CCSECURITY) += ccsecurity |
692 |
|
|
+obj-$(CONFIG_CCSECURITY) += ccsecurity/built-in.o |
693 |
kumaneko |
3816 |
--- linux-2.6.35-rc5.orig/security/security.c |
694 |
|
|
+++ linux-2.6.35-rc5/security/security.c |
695 |
kumaneko |
3685 |
@@ -212,7 +212,10 @@ int security_syslog(int type, bool from_ |
696 |
kumaneko |
3661 |
|
697 |
|
|
int security_settime(struct timespec *ts, struct timezone *tz) |
698 |
|
|
{ |
699 |
|
|
- return security_ops->settime(ts, tz); |
700 |
|
|
+ int error = security_ops->settime(ts, tz); |
701 |
|
|
+ if (!error && !ccs_capable(CCS_SYS_SETTIME)) |
702 |
|
|
+ error = -EPERM; |
703 |
|
|
+ return error; |
704 |
|
|
} |
705 |
|
|
|
706 |
|
|
int security_vm_enough_memory(long pages) |
707 |
kumaneko |
3685 |
@@ -298,17 +301,27 @@ int security_sb_statfs(struct dentry *de |
708 |
kumaneko |
3661 |
int security_sb_mount(char *dev_name, struct path *path, |
709 |
|
|
char *type, unsigned long flags, void *data) |
710 |
|
|
{ |
711 |
|
|
- return security_ops->sb_mount(dev_name, path, type, flags, data); |
712 |
|
|
+ int error = security_ops->sb_mount(dev_name, path, type, flags, data); |
713 |
|
|
+ if (!error) |
714 |
|
|
+ error = ccs_mount_permission(dev_name, path, type, flags, |
715 |
|
|
+ data); |
716 |
|
|
+ return error; |
717 |
|
|
} |
718 |
|
|
|
719 |
|
|
int security_sb_umount(struct vfsmount *mnt, int flags) |
720 |
|
|
{ |
721 |
|
|
- return security_ops->sb_umount(mnt, flags); |
722 |
|
|
+ int error = security_ops->sb_umount(mnt, flags); |
723 |
|
|
+ if (!error) |
724 |
|
|
+ error = ccs_umount_permission(mnt, flags); |
725 |
|
|
+ return error; |
726 |
|
|
} |
727 |
|
|
|
728 |
|
|
int security_sb_pivotroot(struct path *old_path, struct path *new_path) |
729 |
|
|
{ |
730 |
|
|
- return security_ops->sb_pivotroot(old_path, new_path); |
731 |
|
|
+ int error = security_ops->sb_pivotroot(old_path, new_path); |
732 |
|
|
+ if (!error) |
733 |
|
|
+ error = ccs_pivot_root_permission(old_path, new_path); |
734 |
|
|
+ return error; |
735 |
|
|
} |
736 |
|
|
|
737 |
kumaneko |
3685 |
int security_sb_set_mnt_opts(struct super_block *sb, |
738 |
|
|
@@ -364,85 +377,140 @@ EXPORT_SYMBOL(security_inode_init_securi |
739 |
kumaneko |
3661 |
int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, |
740 |
|
|
unsigned int dev) |
741 |
|
|
{ |
742 |
|
|
+ int error; |
743 |
|
|
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
744 |
|
|
return 0; |
745 |
|
|
- return security_ops->path_mknod(dir, dentry, mode, dev); |
746 |
|
|
+ error = security_ops->path_mknod(dir, dentry, mode, dev); |
747 |
|
|
+ if (!error) |
748 |
|
|
+ error = ccs_mknod_permission(dir->dentry->d_inode, dentry, |
749 |
|
|
+ dir->mnt, mode, dev); |
750 |
|
|
+ return error; |
751 |
|
|
} |
752 |
|
|
EXPORT_SYMBOL(security_path_mknod); |
753 |
|
|
|
754 |
|
|
int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode) |
755 |
|
|
{ |
756 |
|
|
+ int error; |
757 |
|
|
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
758 |
|
|
return 0; |
759 |
|
|
- return security_ops->path_mkdir(dir, dentry, mode); |
760 |
|
|
+ error = security_ops->path_mkdir(dir, dentry, mode); |
761 |
|
|
+ if (!error) |
762 |
|
|
+ error = ccs_mkdir_permission(dir->dentry->d_inode, dentry, |
763 |
|
|
+ dir->mnt, mode); |
764 |
|
|
+ return error; |
765 |
|
|
} |
766 |
|
|
|
767 |
|
|
int security_path_rmdir(struct path *dir, struct dentry *dentry) |
768 |
|
|
{ |
769 |
|
|
+ int error; |
770 |
|
|
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
771 |
|
|
return 0; |
772 |
|
|
- return security_ops->path_rmdir(dir, dentry); |
773 |
|
|
+ error = security_ops->path_rmdir(dir, dentry); |
774 |
|
|
+ if (!error) |
775 |
|
|
+ error = ccs_rmdir_permission(dir->dentry->d_inode, dentry, |
776 |
|
|
+ dir->mnt); |
777 |
|
|
+ return error; |
778 |
|
|
} |
779 |
|
|
|
780 |
|
|
int security_path_unlink(struct path *dir, struct dentry *dentry) |
781 |
|
|
{ |
782 |
|
|
+ int error; |
783 |
|
|
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
784 |
|
|
return 0; |
785 |
|
|
- return security_ops->path_unlink(dir, dentry); |
786 |
|
|
+ error = security_ops->path_unlink(dir, dentry); |
787 |
|
|
+ if (!error) |
788 |
|
|
+ error = ccs_unlink_permission(dir->dentry->d_inode, dentry, |
789 |
|
|
+ dir->mnt); |
790 |
|
|
+ return error; |
791 |
|
|
} |
792 |
|
|
|
793 |
|
|
int security_path_symlink(struct path *dir, struct dentry *dentry, |
794 |
|
|
const char *old_name) |
795 |
|
|
{ |
796 |
|
|
+ int error; |
797 |
|
|
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
798 |
|
|
return 0; |
799 |
|
|
- return security_ops->path_symlink(dir, dentry, old_name); |
800 |
|
|
+ error = security_ops->path_symlink(dir, dentry, old_name); |
801 |
|
|
+ if (!error) |
802 |
|
|
+ error = ccs_symlink_permission(dir->dentry->d_inode, dentry, |
803 |
|
|
+ dir->mnt, old_name); |
804 |
|
|
+ return error; |
805 |
|
|
} |
806 |
|
|
|
807 |
|
|
int security_path_link(struct dentry *old_dentry, struct path *new_dir, |
808 |
|
|
struct dentry *new_dentry) |
809 |
|
|
{ |
810 |
|
|
+ int error; |
811 |
|
|
if (unlikely(IS_PRIVATE(old_dentry->d_inode))) |
812 |
|
|
return 0; |
813 |
|
|
- return security_ops->path_link(old_dentry, new_dir, new_dentry); |
814 |
|
|
+ error = security_ops->path_link(old_dentry, new_dir, new_dentry); |
815 |
|
|
+ if (!error) |
816 |
|
|
+ error = ccs_link_permission(old_dentry, |
817 |
|
|
+ new_dir->dentry->d_inode, |
818 |
|
|
+ new_dentry, new_dir->mnt); |
819 |
|
|
+ return error; |
820 |
|
|
} |
821 |
|
|
|
822 |
|
|
int security_path_rename(struct path *old_dir, struct dentry *old_dentry, |
823 |
|
|
struct path *new_dir, struct dentry *new_dentry) |
824 |
|
|
{ |
825 |
|
|
+ int error; |
826 |
|
|
if (unlikely(IS_PRIVATE(old_dentry->d_inode) || |
827 |
|
|
(new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode)))) |
828 |
|
|
return 0; |
829 |
|
|
- return security_ops->path_rename(old_dir, old_dentry, new_dir, |
830 |
|
|
- new_dentry); |
831 |
|
|
+ error = security_ops->path_rename(old_dir, old_dentry, new_dir, |
832 |
|
|
+ new_dentry); |
833 |
|
|
+ if (!error) |
834 |
|
|
+ error = ccs_rename_permission(old_dir->dentry->d_inode, |
835 |
|
|
+ old_dentry, |
836 |
|
|
+ new_dir->dentry->d_inode, |
837 |
|
|
+ new_dentry, new_dir->mnt); |
838 |
|
|
+ return error; |
839 |
|
|
} |
840 |
|
|
|
841 |
|
|
int security_path_truncate(struct path *path, loff_t length, |
842 |
|
|
unsigned int time_attrs) |
843 |
|
|
{ |
844 |
|
|
+ int error; |
845 |
|
|
if (unlikely(IS_PRIVATE(path->dentry->d_inode))) |
846 |
|
|
return 0; |
847 |
|
|
- return security_ops->path_truncate(path, length, time_attrs); |
848 |
|
|
+ error = security_ops->path_truncate(path, length, time_attrs); |
849 |
|
|
+ if (!error) |
850 |
|
|
+ error = ccs_truncate_permission(path->dentry, path->mnt, |
851 |
|
|
+ length, time_attrs); |
852 |
|
|
+ return error; |
853 |
|
|
} |
854 |
|
|
|
855 |
|
|
int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, |
856 |
|
|
mode_t mode) |
857 |
|
|
{ |
858 |
|
|
+ int error; |
859 |
|
|
if (unlikely(IS_PRIVATE(dentry->d_inode))) |
860 |
|
|
return 0; |
861 |
|
|
- return security_ops->path_chmod(dentry, mnt, mode); |
862 |
|
|
+ error = security_ops->path_chmod(dentry, mnt, mode); |
863 |
|
|
+ if (!error) |
864 |
|
|
+ error = ccs_chmod_permission(dentry, mnt, mode); |
865 |
|
|
+ return error; |
866 |
|
|
} |
867 |
|
|
|
868 |
|
|
int security_path_chown(struct path *path, uid_t uid, gid_t gid) |
869 |
|
|
{ |
870 |
|
|
+ int error; |
871 |
|
|
if (unlikely(IS_PRIVATE(path->dentry->d_inode))) |
872 |
|
|
return 0; |
873 |
|
|
- return security_ops->path_chown(path, uid, gid); |
874 |
|
|
+ error = security_ops->path_chown(path, uid, gid); |
875 |
|
|
+ if (!error) |
876 |
|
|
+ error = ccs_chown_permission(path->dentry, path->mnt, uid, |
877 |
|
|
+ gid); |
878 |
|
|
+ return error; |
879 |
|
|
} |
880 |
|
|
|
881 |
|
|
int security_path_chroot(struct path *path) |
882 |
|
|
{ |
883 |
|
|
- return security_ops->path_chroot(path); |
884 |
|
|
+ int error = security_ops->path_chroot(path); |
885 |
|
|
+ if (!error) |
886 |
|
|
+ error = ccs_chroot_permission(path); |
887 |
|
|
+ return error; |
888 |
|
|
} |
889 |
|
|
#endif |
890 |
|
|
|
891 |
kumaneko |
3685 |
@@ -635,7 +703,10 @@ void security_file_free(struct file *fil |
892 |
kumaneko |
3661 |
|
893 |
|
|
int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
894 |
|
|
{ |
895 |
|
|
- return security_ops->file_ioctl(file, cmd, arg); |
896 |
|
|
+ int error = security_ops->file_ioctl(file, cmd, arg); |
897 |
|
|
+ if (!error) |
898 |
|
|
+ error = ccs_ioctl_permission(file, cmd, arg); |
899 |
|
|
+ return error; |
900 |
|
|
} |
901 |
|
|
|
902 |
|
|
int security_file_mmap(struct file *file, unsigned long reqprot, |
903 |
kumaneko |
3685 |
@@ -663,7 +734,10 @@ int security_file_lock(struct file *file |
904 |
kumaneko |
3661 |
|
905 |
|
|
int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg) |
906 |
|
|
{ |
907 |
|
|
- return security_ops->file_fcntl(file, cmd, arg); |
908 |
|
|
+ int error = security_ops->file_fcntl(file, cmd, arg); |
909 |
|
|
+ if (!error) |
910 |
|
|
+ error = ccs_fcntl_permission(file, cmd, arg); |
911 |
|
|
+ return error; |
912 |
|
|
} |
913 |
|
|
|
914 |
|
|
int security_file_set_fowner(struct file *file) |
915 |
kumaneko |
3685 |
@@ -997,7 +1071,10 @@ EXPORT_SYMBOL(security_unix_may_send); |
916 |
kumaneko |
3661 |
|
917 |
|
|
int security_socket_create(int family, int type, int protocol, int kern) |
918 |
|
|
{ |
919 |
|
|
- return security_ops->socket_create(family, type, protocol, kern); |
920 |
|
|
+ int error = security_ops->socket_create(family, type, protocol, kern); |
921 |
|
|
+ if (!error) |
922 |
|
|
+ error = ccs_socket_create_permission(family, type, protocol); |
923 |
|
|
+ return error; |
924 |
|
|
} |
925 |
|
|
|
926 |
|
|
int security_socket_post_create(struct socket *sock, int family, |
927 |
kumaneko |
3685 |
@@ -1009,17 +1086,26 @@ int security_socket_post_create(struct s |
928 |
kumaneko |
3661 |
|
929 |
|
|
int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen) |
930 |
|
|
{ |
931 |
|
|
- return security_ops->socket_bind(sock, address, addrlen); |
932 |
|
|
+ int error = security_ops->socket_bind(sock, address, addrlen); |
933 |
|
|
+ if (!error) |
934 |
|
|
+ error = ccs_socket_bind_permission(sock, address, addrlen); |
935 |
|
|
+ return error; |
936 |
|
|
} |
937 |
|
|
|
938 |
|
|
int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen) |
939 |
|
|
{ |
940 |
|
|
- return security_ops->socket_connect(sock, address, addrlen); |
941 |
|
|
+ int error = security_ops->socket_connect(sock, address, addrlen); |
942 |
|
|
+ if (!error) |
943 |
|
|
+ error = ccs_socket_connect_permission(sock, address, addrlen); |
944 |
|
|
+ return error; |
945 |
|
|
} |
946 |
|
|
|
947 |
|
|
int security_socket_listen(struct socket *sock, int backlog) |
948 |
|
|
{ |
949 |
|
|
- return security_ops->socket_listen(sock, backlog); |
950 |
|
|
+ int error = security_ops->socket_listen(sock, backlog); |
951 |
|
|
+ if (!error) |
952 |
|
|
+ error = ccs_socket_listen_permission(sock); |
953 |
|
|
+ return error; |
954 |
|
|
} |
955 |
|
|
|
956 |
|
|
int security_socket_accept(struct socket *sock, struct socket *newsock) |
957 |
kumaneko |
3685 |
@@ -1029,7 +1115,10 @@ int security_socket_accept(struct socket |
958 |
kumaneko |
3661 |
|
959 |
|
|
int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size) |
960 |
|
|
{ |
961 |
|
|
- return security_ops->socket_sendmsg(sock, msg, size); |
962 |
|
|
+ int error = security_ops->socket_sendmsg(sock, msg, size); |
963 |
|
|
+ if (!error) |
964 |
|
|
+ error = ccs_socket_sendmsg_permission(sock, msg, size); |
965 |
|
|
+ return error; |
966 |
|
|
} |
967 |
|
|
|
968 |
|
|
int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, |