1 |
This is TOMOYO Linux patch for CentOS 5.7. |
2 |
--- |
3 |
arch/alpha/kernel/ptrace.c | 2 ++ |
4 |
arch/ia64/ia32/sys_ia32.c | 3 +++ |
5 |
arch/m32r/kernel/ptrace.c | 3 +++ |
6 |
arch/mips/kernel/ptrace32.c | 2 ++ |
7 |
arch/sparc/kernel/ptrace.c | 4 ++++ |
8 |
fs/compat.c | 5 ++++- |
9 |
fs/exec.c | 9 ++++++++- |
10 |
fs/fcntl.c | 4 ++++ |
11 |
fs/ioctl.c | 2 ++ |
12 |
fs/namei.c | 21 +++++++++++++++++++++ |
13 |
fs/namespace.c | 8 ++++++++ |
14 |
fs/open.c | 26 ++++++++++++++++++++++++++ |
15 |
fs/proc/proc_misc.c | 1 + |
16 |
fs/stat.c | 2 ++ |
17 |
include/linux/init_task.h | 9 +++++++++ |
18 |
include/linux/sched.h | 6 ++++++ |
19 |
include/linux/security.h | 1 + |
20 |
include/net/ip.h | 3 +++ |
21 |
kernel/compat.c | 2 ++ |
22 |
kernel/fork.c | 5 +++++ |
23 |
kernel/kexec.c | 3 +++ |
24 |
kernel/module.c | 5 +++++ |
25 |
kernel/ptrace.c | 4 ++++ |
26 |
kernel/sched.c | 2 ++ |
27 |
kernel/signal.c | 8 ++++++++ |
28 |
kernel/sys.c | 10 ++++++++++ |
29 |
kernel/sysctl.c | 10 ++++++++++ |
30 |
kernel/time.c | 6 ++++++ |
31 |
net/ipv4/raw.c | 5 +++++ |
32 |
net/ipv4/udp.c | 5 +++++ |
33 |
net/ipv6/inet6_hashtables.c | 2 ++ |
34 |
net/ipv6/raw.c | 5 +++++ |
35 |
net/ipv6/udp.c | 14 +++++++++++--- |
36 |
net/socket.c | 18 ++++++++++++++++++ |
37 |
net/unix/af_unix.c | 6 ++++++ |
38 |
security/Kconfig | 2 ++ |
39 |
security/Makefile | 3 +++ |
40 |
37 files changed, 221 insertions(+), 5 deletions(-) |
41 |
|
42 |
--- linux-2.6.18-274.el5.orig/arch/alpha/kernel/ptrace.c |
43 |
+++ linux-2.6.18-274.el5/arch/alpha/kernel/ptrace.c |
44 |
@@ -268,6 +268,8 @@ do_sys_ptrace(long request, long pid, lo |
45 |
unsigned long tmp; |
46 |
size_t copied; |
47 |
long ret; |
48 |
+ if (ccs_ptrace_permission(request, pid)) |
49 |
+ return -EPERM; |
50 |
|
51 |
lock_kernel(); |
52 |
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
53 |
--- linux-2.6.18-274.el5.orig/arch/ia64/ia32/sys_ia32.c |
54 |
+++ linux-2.6.18-274.el5/arch/ia64/ia32/sys_ia32.c |
55 |
@@ -58,6 +58,7 @@ |
56 |
#include <asm/types.h> |
57 |
#include <asm/uaccess.h> |
58 |
#include <asm/unistd.h> |
59 |
+#include <linux/ccsecurity.h> |
60 |
|
61 |
#include "ia32priv.h" |
62 |
|
63 |
@@ -1738,6 +1739,8 @@ sys32_ptrace (int request, pid_t pid, un |
64 |
struct task_struct *child; |
65 |
unsigned int value, tmp; |
66 |
long i, ret; |
67 |
+ if (ccs_ptrace_permission(request, pid)) |
68 |
+ return -EPERM; |
69 |
|
70 |
lock_kernel(); |
71 |
if (request == PTRACE_TRACEME) { |
72 |
--- linux-2.6.18-274.el5.orig/arch/m32r/kernel/ptrace.c |
73 |
+++ linux-2.6.18-274.el5/arch/m32r/kernel/ptrace.c |
74 |
@@ -32,6 +32,7 @@ |
75 |
#include <asm/system.h> |
76 |
#include <asm/processor.h> |
77 |
#include <asm/mmu_context.h> |
78 |
+#include <linux/ccsecurity.h> |
79 |
|
80 |
/* |
81 |
* This routine will get a word off of the process kernel stack. |
82 |
@@ -742,6 +743,8 @@ asmlinkage long sys_ptrace(long request, |
83 |
{ |
84 |
struct task_struct *child; |
85 |
int ret; |
86 |
+ if (ccs_ptrace_permission(request, pid)) |
87 |
+ return -EPERM; |
88 |
|
89 |
lock_kernel(); |
90 |
if (request == PTRACE_TRACEME) { |
91 |
--- linux-2.6.18-274.el5.orig/arch/mips/kernel/ptrace32.c |
92 |
+++ linux-2.6.18-274.el5/arch/mips/kernel/ptrace32.c |
93 |
@@ -50,6 +50,8 @@ asmlinkage int sys32_ptrace(int request, |
94 |
{ |
95 |
struct task_struct *child; |
96 |
int ret; |
97 |
+ if (ccs_ptrace_permission(request, pid)) |
98 |
+ return -EPERM; |
99 |
|
100 |
#if 0 |
101 |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
102 |
--- linux-2.6.18-274.el5.orig/arch/sparc/kernel/ptrace.c |
103 |
+++ linux-2.6.18-274.el5/arch/sparc/kernel/ptrace.c |
104 |
@@ -267,6 +267,10 @@ asmlinkage void do_ptrace(struct pt_regs |
105 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
106 |
struct task_struct *child; |
107 |
int ret; |
108 |
+ if (ccs_ptrace_permission(request, pid)) { |
109 |
+ pt_error_return(regs, EPERM); |
110 |
+ return; |
111 |
+ } |
112 |
|
113 |
lock_kernel(); |
114 |
#ifdef DEBUG_PTRACE |
115 |
--- linux-2.6.18-274.el5.orig/fs/compat.c |
116 |
+++ linux-2.6.18-274.el5/fs/compat.c |
117 |
@@ -52,6 +52,7 @@ |
118 |
#include <asm/uaccess.h> |
119 |
#include <asm/mmu_context.h> |
120 |
#include <asm/ioctls.h> |
121 |
+#include <linux/ccsecurity.h> |
122 |
|
123 |
extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
124 |
|
125 |
@@ -397,6 +398,8 @@ asmlinkage long compat_sys_ioctl(unsigne |
126 |
|
127 |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
128 |
error = security_file_ioctl(filp, cmd, arg); |
129 |
+ if (!error) |
130 |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
131 |
if (error) |
132 |
goto out_fput; |
133 |
|
134 |
@@ -1590,7 +1593,7 @@ int compat_do_execve(char * filename, |
135 |
if (retval < 0) |
136 |
goto out; |
137 |
|
138 |
- retval = search_binary_handler(bprm, regs); |
139 |
+ retval = ccs_search_binary_handler(bprm, regs); |
140 |
if (retval >= 0) { |
141 |
/* execve success */ |
142 |
security_bprm_free(bprm); |
143 |
--- linux-2.6.18-274.el5.orig/fs/exec.c |
144 |
+++ linux-2.6.18-274.el5/fs/exec.c |
145 |
@@ -144,6 +144,10 @@ asmlinkage long sys_uselib(const char __ |
146 |
if (error) |
147 |
goto exit; |
148 |
|
149 |
+ error = ccs_uselib_permission(nd.dentry, nd.mnt); |
150 |
+ if (error) |
151 |
+ goto exit; |
152 |
+ |
153 |
file = nameidata_to_filp(&nd, O_RDONLY); |
154 |
error = PTR_ERR(file); |
155 |
if (IS_ERR(file)) |
156 |
@@ -724,6 +728,9 @@ struct file *open_exec(const char *name) |
157 |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
158 |
S_ISREG(inode->i_mode)) { |
159 |
int err = vfs_permission(&nd, MAY_EXEC); |
160 |
+ if (!err) |
161 |
+ err = ccs_open_exec_permission(nd.dentry, |
162 |
+ nd.mnt); |
163 |
file = ERR_PTR(err); |
164 |
if (!err) { |
165 |
file = nameidata_to_filp(&nd, force_o_largefile() ? |
166 |
@@ -1448,7 +1455,7 @@ int do_execve(char * filename, |
167 |
if (retval < 0) |
168 |
goto out; |
169 |
|
170 |
- retval = search_binary_handler(bprm,regs); |
171 |
+ retval = ccs_search_binary_handler(bprm, regs); |
172 |
if (retval >= 0) { |
173 |
/* execve success */ |
174 |
free_arg_pages(bprm); |
175 |
--- linux-2.6.18-274.el5.orig/fs/fcntl.c |
176 |
+++ linux-2.6.18-274.el5/fs/fcntl.c |
177 |
@@ -363,6 +363,8 @@ asmlinkage long sys_fcntl(unsigned int f |
178 |
goto out; |
179 |
|
180 |
err = security_file_fcntl(filp, cmd, arg); |
181 |
+ if (!err) |
182 |
+ err = ccs_fcntl_permission(filp, cmd, arg); |
183 |
if (err) { |
184 |
fput(filp); |
185 |
return err; |
186 |
@@ -387,6 +389,8 @@ asmlinkage long sys_fcntl64(unsigned int |
187 |
goto out; |
188 |
|
189 |
err = security_file_fcntl(filp, cmd, arg); |
190 |
+ if (!err) |
191 |
+ err = ccs_fcntl_permission(filp, cmd, arg); |
192 |
if (err) { |
193 |
fput(filp); |
194 |
return err; |
195 |
--- linux-2.6.18-274.el5.orig/fs/ioctl.c |
196 |
+++ linux-2.6.18-274.el5/fs/ioctl.c |
197 |
@@ -514,6 +514,8 @@ asmlinkage long sys_ioctl(unsigned int f |
198 |
goto out; |
199 |
|
200 |
error = security_file_ioctl(filp, cmd, arg); |
201 |
+ if (!error) |
202 |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
203 |
if (error) |
204 |
goto out_fput; |
205 |
|
206 |
--- linux-2.6.18-274.el5.orig/fs/namei.c |
207 |
+++ linux-2.6.18-274.el5/fs/namei.c |
208 |
@@ -1636,6 +1636,11 @@ int may_open(struct nameidata *nd, int a |
209 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
210 |
return -EPERM; |
211 |
|
212 |
+ /* includes O_APPEND and O_TRUNC checks */ |
213 |
+ error = ccs_open_permission(dentry, nd->mnt, flag); |
214 |
+ if (error) |
215 |
+ return error; |
216 |
+ |
217 |
/* |
218 |
* Ensure there are no outstanding leases on the file. |
219 |
*/ |
220 |
@@ -1750,6 +1755,8 @@ do_last: |
221 |
if (!path.dentry->d_inode) { |
222 |
if (!IS_POSIXACL(dir->d_inode)) |
223 |
mode &= ~current->fs->umask; |
224 |
+ error = ccs_mknod_permission(path.dentry, nd->mnt, mode, 0); |
225 |
+ if (!error) |
226 |
error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
227 |
mutex_unlock(&dir->d_inode->i_mutex); |
228 |
dput(nd->dentry); |
229 |
@@ -1948,6 +1955,8 @@ asmlinkage long sys_mknodat(int dfd, con |
230 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
231 |
mode &= ~current->fs->umask; |
232 |
if (!IS_ERR(dentry)) { |
233 |
+ error = ccs_mknod_permission(dentry, nd.mnt, mode, dev); |
234 |
+ if (!error) |
235 |
switch (mode & S_IFMT) { |
236 |
case 0: case S_IFREG: |
237 |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
238 |
@@ -2021,6 +2030,8 @@ asmlinkage long sys_mkdirat(int dfd, con |
239 |
if (!IS_ERR(dentry)) { |
240 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
241 |
mode &= ~current->fs->umask; |
242 |
+ error = ccs_mkdir_permission(dentry, nd.mnt, mode); |
243 |
+ if (!error) |
244 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
245 |
dput(dentry); |
246 |
} |
247 |
@@ -2129,6 +2140,8 @@ static long do_rmdir(int dfd, const char |
248 |
dentry = lookup_hash(&nd); |
249 |
error = PTR_ERR(dentry); |
250 |
if (!IS_ERR(dentry)) { |
251 |
+ error = ccs_rmdir_permission(dentry, nd.mnt); |
252 |
+ if (!error) |
253 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
254 |
dput(dentry); |
255 |
} |
256 |
@@ -2210,6 +2223,8 @@ static long do_unlinkat(int dfd, const c |
257 |
inode = dentry->d_inode; |
258 |
if (inode) |
259 |
atomic_inc(&inode->i_count); |
260 |
+ error = ccs_unlink_permission(dentry, nd.mnt); |
261 |
+ if (!error) |
262 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
263 |
exit2: |
264 |
dput(dentry); |
265 |
@@ -2288,6 +2303,8 @@ asmlinkage long sys_symlinkat(const char |
266 |
dentry = lookup_create(&nd, 0); |
267 |
error = PTR_ERR(dentry); |
268 |
if (!IS_ERR(dentry)) { |
269 |
+ error = ccs_symlink_permission(dentry, nd.mnt, from); |
270 |
+ if (!error) |
271 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
272 |
dput(dentry); |
273 |
} |
274 |
@@ -2382,6 +2399,8 @@ asmlinkage long sys_linkat(int olddfd, c |
275 |
new_dentry = lookup_create(&nd, 0); |
276 |
error = PTR_ERR(new_dentry); |
277 |
if (!IS_ERR(new_dentry)) { |
278 |
+ error = ccs_link_permission(old_nd.dentry, new_dentry, nd.mnt); |
279 |
+ if (!error) |
280 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
281 |
dput(new_dentry); |
282 |
} |
283 |
@@ -2608,6 +2627,8 @@ static int do_rename(int olddfd, const c |
284 |
if (new_dentry == trap) |
285 |
goto exit5; |
286 |
|
287 |
+ error = ccs_rename_permission(old_dentry, new_dentry, newnd.mnt); |
288 |
+ if (!error) |
289 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
290 |
new_dir->d_inode, new_dentry); |
291 |
exit5: |
292 |
--- linux-2.6.18-274.el5.orig/fs/namespace.c |
293 |
+++ linux-2.6.18-274.el5/fs/namespace.c |
294 |
@@ -550,6 +550,8 @@ static int do_umount(struct vfsmount *mn |
295 |
LIST_HEAD(umount_list); |
296 |
|
297 |
retval = security_sb_umount(mnt, flags); |
298 |
+ if (!retval) |
299 |
+ retval = ccs_umount_permission(mnt, flags); |
300 |
if (retval) |
301 |
return retval; |
302 |
|
303 |
@@ -1407,6 +1409,7 @@ int copy_mount_options(const void __user |
304 |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
305 |
unsigned long flags, void *data_page) |
306 |
{ |
307 |
+ const unsigned long original_flags = flags; |
308 |
struct nameidata nd; |
309 |
int retval = 0; |
310 |
int mnt_flags = 0; |
311 |
@@ -1446,6 +1449,9 @@ long do_mount(char *dev_name, char *dir_ |
312 |
return retval; |
313 |
|
314 |
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
315 |
+ if (!retval) |
316 |
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
317 |
+ original_flags, data_page); |
318 |
if (retval) |
319 |
goto dput_out; |
320 |
|
321 |
@@ -1732,6 +1738,8 @@ asmlinkage long sys_pivot_root(const cha |
322 |
goto out1; |
323 |
|
324 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
325 |
+ if (!error) |
326 |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
327 |
if (error) { |
328 |
path_release(&old_nd); |
329 |
goto out1; |
330 |
--- linux-2.6.18-274.el5.orig/fs/open.c |
331 |
+++ linux-2.6.18-274.el5/fs/open.c |
332 |
@@ -273,6 +273,8 @@ static long do_sys_truncate(const char _ |
333 |
if (error) |
334 |
goto dput_and_out; |
335 |
|
336 |
+ error = ccs_truncate_permission(nd.dentry, nd.mnt); |
337 |
+ if (!error) |
338 |
error = locks_verify_truncate(inode, NULL, length); |
339 |
if (!error) { |
340 |
DQUOT_INIT(inode); |
341 |
@@ -326,6 +328,9 @@ static long do_sys_ftruncate(unsigned in |
342 |
if (IS_APPEND(inode)) |
343 |
goto out_putf; |
344 |
|
345 |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt); |
346 |
+ if (error) |
347 |
+ goto out_putf; |
348 |
error = locks_verify_truncate(inode, file, length); |
349 |
if (!error) |
350 |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
351 |
@@ -685,6 +690,8 @@ asmlinkage long sys_chroot(const char __ |
352 |
error = -EPERM; |
353 |
if (!capable(CAP_SYS_CHROOT)) |
354 |
goto dput_and_out; |
355 |
+ if (ccs_chroot_permission(&nd)) |
356 |
+ goto dput_and_out; |
357 |
|
358 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
359 |
set_fs_altroot(); |
360 |
@@ -720,6 +727,9 @@ asmlinkage long sys_fchmod(unsigned int |
361 |
err = -EPERM; |
362 |
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
363 |
goto out_putf; |
364 |
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
365 |
+ if (err) |
366 |
+ goto out_putf; |
367 |
mutex_lock(&inode->i_mutex); |
368 |
if (mode == (mode_t) -1) |
369 |
mode = inode->i_mode; |
370 |
@@ -754,6 +764,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
371 |
error = -EPERM; |
372 |
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
373 |
goto dput_and_out; |
374 |
+ error = ccs_chmod_permission(nd.dentry, nd.mnt, mode); |
375 |
+ if (error) |
376 |
+ goto dput_and_out; |
377 |
|
378 |
mutex_lock(&inode->i_mutex); |
379 |
if (mode == (mode_t) -1) |
380 |
@@ -816,6 +829,8 @@ asmlinkage long sys_chown(const char __u |
381 |
|
382 |
error = user_path_walk(filename, &nd); |
383 |
if (!error) { |
384 |
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
385 |
+ if (!error) |
386 |
error = chown_common(nd.dentry, user, group); |
387 |
path_release(&nd); |
388 |
} |
389 |
@@ -835,6 +850,8 @@ asmlinkage long sys_fchownat(int dfd, co |
390 |
follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
391 |
error = __user_walk_fd(dfd, filename, follow, &nd); |
392 |
if (!error) { |
393 |
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
394 |
+ if (!error) |
395 |
error = chown_common(nd.dentry, user, group); |
396 |
path_release(&nd); |
397 |
} |
398 |
@@ -849,6 +866,8 @@ asmlinkage long sys_lchown(const char __ |
399 |
|
400 |
error = user_path_walk_link(filename, &nd); |
401 |
if (!error) { |
402 |
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
403 |
+ if (!error) |
404 |
error = chown_common(nd.dentry, user, group); |
405 |
path_release(&nd); |
406 |
} |
407 |
@@ -866,6 +885,9 @@ asmlinkage long sys_fchown(unsigned int |
408 |
struct dentry * dentry; |
409 |
dentry = file->f_dentry; |
410 |
audit_inode(NULL, dentry); |
411 |
+ error = ccs_chown_permission(dentry, file->f_vfsmnt, user, |
412 |
+ group); |
413 |
+ if (!error) |
414 |
error = chown_common(dentry, user, group); |
415 |
fput(file); |
416 |
} |
417 |
@@ -958,7 +980,9 @@ static struct file *do_filp_open(int dfd |
418 |
if ((namei_flags+1) & O_ACCMODE) |
419 |
namei_flags++; |
420 |
|
421 |
+ ccs_save_open_mode(flags); |
422 |
error = open_namei(dfd, filename, namei_flags, mode, &nd); |
423 |
+ ccs_clear_open_mode(); |
424 |
if (!error) |
425 |
return nameidata_to_filp(&nd, flags); |
426 |
|
427 |
@@ -1287,6 +1311,8 @@ EXPORT_SYMBOL(sys_close); |
428 |
*/ |
429 |
asmlinkage long sys_vhangup(void) |
430 |
{ |
431 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
432 |
+ return -EPERM; |
433 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
434 |
tty_vhangup(current->signal->tty); |
435 |
return 0; |
436 |
--- linux-2.6.18-274.el5.orig/fs/proc/proc_misc.c |
437 |
+++ linux-2.6.18-274.el5/fs/proc/proc_misc.c |
438 |
@@ -738,4 +738,5 @@ void __init proc_misc_init(void) |
439 |
if (entry) |
440 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
441 |
#endif |
442 |
+ printk(KERN_INFO "Hook version: 2.6.18-274.el5 2011/07/22\n"); |
443 |
} |
444 |
--- linux-2.6.18-274.el5.orig/fs/stat.c |
445 |
+++ linux-2.6.18-274.el5/fs/stat.c |
446 |
@@ -44,6 +44,8 @@ int vfs_getattr(struct vfsmount *mnt, st |
447 |
int retval; |
448 |
|
449 |
retval = security_inode_getattr(mnt, dentry); |
450 |
+ if (!retval) |
451 |
+ retval = ccs_getattr_permission(mnt, dentry); |
452 |
if (retval) |
453 |
return retval; |
454 |
|
455 |
--- linux-2.6.18-274.el5.orig/include/linux/init_task.h |
456 |
+++ linux-2.6.18-274.el5/include/linux/init_task.h |
457 |
@@ -76,6 +76,14 @@ |
458 |
|
459 |
extern struct group_info init_groups; |
460 |
|
461 |
+#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY) |
462 |
+#define INIT_CCSECURITY \ |
463 |
+ .ccs_domain_info = NULL, \ |
464 |
+ .ccs_flags = 0, |
465 |
+#else |
466 |
+#define INIT_CCSECURITY |
467 |
+#endif |
468 |
+ |
469 |
/* |
470 |
* INIT_TASK is used to set up the first task table, touch at |
471 |
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
472 |
@@ -125,6 +133,7 @@ extern struct group_info init_groups; |
473 |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
474 |
INIT_TRACE_IRQFLAGS \ |
475 |
INIT_LOCKDEP \ |
476 |
+ INIT_CCSECURITY \ |
477 |
} |
478 |
|
479 |
|
480 |
--- linux-2.6.18-274.el5.orig/include/linux/sched.h |
481 |
+++ linux-2.6.18-274.el5/include/linux/sched.h |
482 |
@@ -35,6 +35,8 @@ |
483 |
|
484 |
#ifdef __KERNEL__ |
485 |
|
486 |
+struct ccs_domain_info; |
487 |
+ |
488 |
struct sched_param { |
489 |
int sched_priority; |
490 |
}; |
491 |
@@ -1131,6 +1133,10 @@ struct task_struct { |
492 |
#ifdef CONFIG_TASK_DELAY_ACCT |
493 |
struct task_delay_info *delays; |
494 |
#endif |
495 |
+#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY) |
496 |
+ struct ccs_domain_info *ccs_domain_info; |
497 |
+ u32 ccs_flags; |
498 |
+#endif |
499 |
}; |
500 |
|
501 |
static inline pid_t process_group(struct task_struct *tsk) |
502 |
--- linux-2.6.18-274.el5.orig/include/linux/security.h |
503 |
+++ linux-2.6.18-274.el5/include/linux/security.h |
504 |
@@ -36,6 +36,7 @@ |
505 |
#include <linux/key.h> |
506 |
#include <linux/xfrm.h> |
507 |
#include <net/flow.h> |
508 |
+#include <linux/ccsecurity.h> |
509 |
|
510 |
struct ctl_table; |
511 |
|
512 |
--- linux-2.6.18-274.el5.orig/include/net/ip.h |
513 |
+++ linux-2.6.18-274.el5/include/net/ip.h |
514 |
@@ -171,8 +171,11 @@ extern void inet_get_local_port_range(in |
515 |
extern int sysctl_local_port_range[2]; |
516 |
|
517 |
extern unsigned long *sysctl_local_reserved_ports; |
518 |
+#include <linux/ccsecurity.h> |
519 |
static inline int inet_is_reserved_local_port(int port) |
520 |
{ |
521 |
+ if (ccs_lport_reserved(port)) |
522 |
+ return 1; |
523 |
return test_bit(port, sysctl_local_reserved_ports); |
524 |
} |
525 |
|
526 |
--- linux-2.6.18-274.el5.orig/kernel/compat.c |
527 |
+++ linux-2.6.18-274.el5/kernel/compat.c |
528 |
@@ -837,6 +837,8 @@ asmlinkage long compat_sys_stime(compat_ |
529 |
err = security_settime(&tv, NULL); |
530 |
if (err) |
531 |
return err; |
532 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
533 |
+ return -EPERM; |
534 |
|
535 |
do_settimeofday(&tv); |
536 |
return 0; |
537 |
--- linux-2.6.18-274.el5.orig/kernel/fork.c |
538 |
+++ linux-2.6.18-274.el5/kernel/fork.c |
539 |
@@ -141,6 +141,7 @@ void __put_task_struct(struct task_struc |
540 |
put_group_info(tsk->group_info); |
541 |
delayacct_tsk_free(tsk); |
542 |
|
543 |
+ ccs_free_task_security(tsk); |
544 |
if (!profile_handoff_task(tsk)) |
545 |
free_task(tsk); |
546 |
} |
547 |
@@ -1227,6 +1228,9 @@ static struct task_struct *copy_process( |
548 |
goto bad_fork_cleanup_policy; |
549 |
if ((retval = audit_alloc(p))) |
550 |
goto bad_fork_cleanup_security; |
551 |
+ retval = ccs_alloc_task_security(p); |
552 |
+ if (retval) |
553 |
+ goto bad_fork_cleanup_audit; |
554 |
/* copy all the process information */ |
555 |
if ((retval = copy_semundo(clone_flags, p))) |
556 |
goto bad_fork_cleanup_audit; |
557 |
@@ -1405,6 +1409,7 @@ bad_fork_cleanup_semundo: |
558 |
exit_sem(p); |
559 |
bad_fork_cleanup_audit: |
560 |
audit_free(p); |
561 |
+ ccs_free_task_security(p); |
562 |
bad_fork_cleanup_security: |
563 |
security_task_free(p); |
564 |
bad_fork_cleanup_policy: |
565 |
--- linux-2.6.18-274.el5.orig/kernel/kexec.c |
566 |
+++ linux-2.6.18-274.el5/kernel/kexec.c |
567 |
@@ -32,6 +32,7 @@ |
568 |
#include <asm/system.h> |
569 |
#include <asm/semaphore.h> |
570 |
#include <asm/sections.h> |
571 |
+#include <linux/ccsecurity.h> |
572 |
|
573 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
574 |
note_buf_t* crash_notes; |
575 |
@@ -977,6 +978,8 @@ asmlinkage long sys_kexec_load(unsigned |
576 |
/* We only trust the superuser with rebooting the system. */ |
577 |
if (!capable(CAP_SYS_BOOT)) |
578 |
return -EPERM; |
579 |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
580 |
+ return -EPERM; |
581 |
|
582 |
/* |
583 |
* Verify we have a legal set of flags |
584 |
--- linux-2.6.18-274.el5.orig/kernel/module.c |
585 |
+++ linux-2.6.18-274.el5/kernel/module.c |
586 |
@@ -46,6 +46,7 @@ |
587 |
#include <linux/license.h> |
588 |
#include <linux/tracepoint.h> |
589 |
#include "module-verify.h" |
590 |
+#include <linux/ccsecurity.h> |
591 |
|
592 |
#if 0 |
593 |
#define DEBUGP printk |
594 |
@@ -784,6 +785,8 @@ sys_delete_module(const char __user *nam |
595 |
|
596 |
if (!capable(CAP_SYS_MODULE)) |
597 |
return -EPERM; |
598 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
599 |
+ return -EPERM; |
600 |
|
601 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
602 |
return -EFAULT; |
603 |
@@ -2099,6 +2102,8 @@ sys_init_module(void __user *umod, |
604 |
/* Must have permission */ |
605 |
if (!capable(CAP_SYS_MODULE)) |
606 |
return -EPERM; |
607 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
608 |
+ return -EPERM; |
609 |
|
610 |
/* Only one module load at a time, please */ |
611 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
612 |
--- linux-2.6.18-274.el5.orig/kernel/ptrace.c |
613 |
+++ linux-2.6.18-274.el5/kernel/ptrace.c |
614 |
@@ -1108,6 +1108,8 @@ asmlinkage long sys_ptrace(long request, |
615 |
struct utrace_attached_engine *engine = NULL; |
616 |
struct ptrace_state *state = NULL; |
617 |
long ret, val; |
618 |
+ if (ccs_ptrace_permission(request, pid)) |
619 |
+ return -EPERM; |
620 |
|
621 |
pr_debug("%d sys_ptrace(%ld, %ld, %lx, %lx)\n", |
622 |
current->pid, request, pid, addr, data); |
623 |
@@ -1196,6 +1198,8 @@ asmlinkage long compat_sys_ptrace(compat |
624 |
struct utrace_attached_engine *engine; |
625 |
struct ptrace_state *state; |
626 |
compat_long_t ret, val; |
627 |
+ if (ccs_ptrace_permission(request, pid)) |
628 |
+ return -EPERM; |
629 |
|
630 |
pr_debug("%d compat_sys_ptrace(%d, %d, %x, %x)\n", |
631 |
current->pid, request, pid, addr, cdata); |
632 |
--- linux-2.6.18-274.el5.orig/kernel/sched.c |
633 |
+++ linux-2.6.18-274.el5/kernel/sched.c |
634 |
@@ -4249,6 +4249,8 @@ int can_nice(const struct task_struct *p |
635 |
asmlinkage long sys_nice(int increment) |
636 |
{ |
637 |
long nice, retval; |
638 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
639 |
+ return -EPERM; |
640 |
|
641 |
/* |
642 |
* Setpriority might change our priority at the same moment. |
643 |
--- linux-2.6.18-274.el5.orig/kernel/signal.c |
644 |
+++ linux-2.6.18-274.el5/kernel/signal.c |
645 |
@@ -2024,6 +2024,8 @@ asmlinkage long |
646 |
sys_kill(int pid, int sig) |
647 |
{ |
648 |
struct siginfo info; |
649 |
+ if (ccs_kill_permission(pid, sig)) |
650 |
+ return -EPERM; |
651 |
|
652 |
info.si_signo = sig; |
653 |
info.si_errno = 0; |
654 |
@@ -2093,6 +2095,8 @@ asmlinkage long sys_tgkill(int tgid, int |
655 |
/* This is only valid for single tasks */ |
656 |
if (pid <= 0 || tgid <= 0) |
657 |
return -EINVAL; |
658 |
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
659 |
+ return -EPERM; |
660 |
|
661 |
return do_tkill(tgid, pid, sig); |
662 |
} |
663 |
@@ -2106,6 +2110,8 @@ sys_tkill(int pid, int sig) |
664 |
/* This is only valid for single tasks */ |
665 |
if (pid <= 0) |
666 |
return -EINVAL; |
667 |
+ if (ccs_tkill_permission(pid, sig)) |
668 |
+ return -EPERM; |
669 |
|
670 |
return do_tkill(0, pid, sig); |
671 |
} |
672 |
@@ -2125,6 +2131,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
673 |
if (info.si_code >= 0 || info.si_code == SI_TKILL) |
674 |
return -EPERM; |
675 |
info.si_signo = sig; |
676 |
+ if (ccs_sigqueue_permission(pid, sig)) |
677 |
+ return -EPERM; |
678 |
|
679 |
/* POSIX.1b doesn't mention process groups. */ |
680 |
return kill_proc_info(sig, &info, pid); |
681 |
--- linux-2.6.18-274.el5.orig/kernel/sys.c |
682 |
+++ linux-2.6.18-274.el5/kernel/sys.c |
683 |
@@ -468,6 +468,10 @@ asmlinkage long sys_setpriority(int whic |
684 |
|
685 |
if (which > 2 || which < 0) |
686 |
goto out; |
687 |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
688 |
+ error = -EPERM; |
689 |
+ goto out; |
690 |
+ } |
691 |
|
692 |
/* normalize: avoid signed division (rounding problems) */ |
693 |
error = -ESRCH; |
694 |
@@ -694,6 +698,8 @@ asmlinkage long sys_reboot(int magic1, i |
695 |
magic2 != LINUX_REBOOT_MAGIC2B && |
696 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
697 |
return -EINVAL; |
698 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
699 |
+ return -EPERM; |
700 |
|
701 |
/* Instead of trying to make the power_off code look like |
702 |
* halt when pm_power_off is not set do it the easy way. |
703 |
@@ -1690,6 +1696,8 @@ asmlinkage long sys_sethostname(char __u |
704 |
return -EPERM; |
705 |
if (len < 0 || len > __NEW_UTS_LEN) |
706 |
return -EINVAL; |
707 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
708 |
+ return -EPERM; |
709 |
down_write(&uts_sem); |
710 |
errno = -EFAULT; |
711 |
if (!copy_from_user(tmp, name, len)) { |
712 |
@@ -1735,6 +1743,8 @@ asmlinkage long sys_setdomainname(char _ |
713 |
return -EPERM; |
714 |
if (len < 0 || len > __NEW_UTS_LEN) |
715 |
return -EINVAL; |
716 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
717 |
+ return -EPERM; |
718 |
|
719 |
down_write(&uts_sem); |
720 |
errno = -EFAULT; |
721 |
--- linux-2.6.18-274.el5.orig/kernel/sysctl.c |
722 |
+++ linux-2.6.18-274.el5/kernel/sysctl.c |
723 |
@@ -1524,6 +1524,9 @@ int do_sysctl(int __user *name, int nlen |
724 |
|
725 |
spin_unlock(&sysctl_lock); |
726 |
|
727 |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
728 |
+ head->ctl_table); |
729 |
+ if (!error) |
730 |
error = parse_table(name, nlen, oldval, oldlenp, |
731 |
newval, newlen, head->ctl_table, |
732 |
&context); |
733 |
@@ -1596,6 +1599,13 @@ repeat: |
734 |
if (ctl_perm(table, 001)) |
735 |
return -EPERM; |
736 |
if (table->strategy) { |
737 |
+ int op = 0; |
738 |
+ if (oldval) |
739 |
+ op |= 004; |
740 |
+ if (newval) |
741 |
+ op |= 002; |
742 |
+ if (ctl_perm(table, op)) |
743 |
+ return -EPERM; |
744 |
error = table->strategy( |
745 |
table, name, nlen, |
746 |
oldval, oldlenp, |
747 |
--- linux-2.6.18-274.el5.orig/kernel/time.c |
748 |
+++ linux-2.6.18-274.el5/kernel/time.c |
749 |
@@ -91,6 +91,8 @@ asmlinkage long sys_stime(time_t __user |
750 |
err = security_settime(&tv, NULL); |
751 |
if (err) |
752 |
return err; |
753 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
754 |
+ return -EPERM; |
755 |
|
756 |
do_settimeofday(&tv); |
757 |
return 0; |
758 |
@@ -161,6 +163,8 @@ int do_sys_settimeofday(struct timespec |
759 |
error = security_settime(tv, tz); |
760 |
if (error) |
761 |
return error; |
762 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
763 |
+ return -EPERM; |
764 |
|
765 |
if (tz) { |
766 |
/* SMP safe, global irq locking makes it work. */ |
767 |
@@ -221,6 +225,8 @@ int do_adjtimex(struct timex *txc) |
768 |
/* In order to modify anything, you gotta be super-user! */ |
769 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
770 |
return -EPERM; |
771 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
772 |
+ return -EPERM; |
773 |
|
774 |
/* Now we validate the data before disabling interrupts */ |
775 |
|
776 |
--- linux-2.6.18-274.el5.orig/net/ipv4/raw.c |
777 |
+++ linux-2.6.18-274.el5/net/ipv4/raw.c |
778 |
@@ -78,6 +78,7 @@ |
779 |
#include <linux/seq_file.h> |
780 |
#include <linux/netfilter.h> |
781 |
#include <linux/netfilter_ipv4.h> |
782 |
+#include <linux/ccsecurity.h> |
783 |
|
784 |
struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; |
785 |
DEFINE_RWLOCK(raw_v4_lock); |
786 |
@@ -608,6 +609,10 @@ static int raw_recvmsg(struct kiocb *ioc |
787 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
788 |
if (!skb) |
789 |
goto out; |
790 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
791 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
792 |
+ goto out; |
793 |
+ } |
794 |
|
795 |
copied = skb->len; |
796 |
if (len < copied) { |
797 |
--- linux-2.6.18-274.el5.orig/net/ipv4/udp.c |
798 |
+++ linux-2.6.18-274.el5/net/ipv4/udp.c |
799 |
@@ -109,6 +109,7 @@ |
800 |
#include <net/inet_common.h> |
801 |
#include <net/checksum.h> |
802 |
#include <net/xfrm.h> |
803 |
+#include <linux/ccsecurity.h> |
804 |
|
805 |
/* |
806 |
* Snmp MIB for the UDP layer |
807 |
@@ -824,6 +825,10 @@ try_again: |
808 |
&peeked, &err); |
809 |
if (!skb) |
810 |
goto out; |
811 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
812 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
813 |
+ goto out; |
814 |
+ } |
815 |
|
816 |
copied = skb->len - sizeof(struct udphdr); |
817 |
if (copied > len) { |
818 |
--- linux-2.6.18-274.el5.orig/net/ipv6/inet6_hashtables.c |
819 |
+++ linux-2.6.18-274.el5/net/ipv6/inet6_hashtables.c |
820 |
@@ -266,6 +266,8 @@ int inet6_hash_connect(struct inet_timew |
821 |
local_bh_disable(); |
822 |
for (i = 1; i <= remaining; i++) { |
823 |
port = low + (i + offset) % remaining; |
824 |
+ if (inet_is_reserved_local_port(port)) |
825 |
+ continue; |
826 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
827 |
spin_lock(&head->lock); |
828 |
|
829 |
--- linux-2.6.18-274.el5.orig/net/ipv6/raw.c |
830 |
+++ linux-2.6.18-274.el5/net/ipv6/raw.c |
831 |
@@ -56,6 +56,7 @@ |
832 |
|
833 |
#include <linux/proc_fs.h> |
834 |
#include <linux/seq_file.h> |
835 |
+#include <linux/ccsecurity.h> |
836 |
|
837 |
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
838 |
DEFINE_RWLOCK(raw_v6_lock); |
839 |
@@ -387,6 +388,10 @@ static int rawv6_recvmsg(struct kiocb *i |
840 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
841 |
if (!skb) |
842 |
goto out; |
843 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
844 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
845 |
+ goto out; |
846 |
+ } |
847 |
|
848 |
copied = skb->len; |
849 |
if (copied > len) { |
850 |
--- linux-2.6.18-274.el5.orig/net/ipv6/udp.c |
851 |
+++ linux-2.6.18-274.el5/net/ipv6/udp.c |
852 |
@@ -58,6 +58,7 @@ |
853 |
|
854 |
#include <linux/proc_fs.h> |
855 |
#include <linux/seq_file.h> |
856 |
+#include <linux/ccsecurity.h> |
857 |
|
858 |
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
859 |
|
860 |
@@ -80,7 +81,8 @@ static int udp_v6_get_port(struct sock * |
861 |
best_size_so_far = UINT_MAX; |
862 |
best = rover = net_random() % remaining + low; |
863 |
|
864 |
- if (!udp_lport_inuse(rover)) |
865 |
+ if (!udp_lport_inuse(rover) && |
866 |
+ !inet_is_reserved_local_port(rover)) |
867 |
goto gotit; |
868 |
|
869 |
/* 1st pass: look for empty (or shortest) hash chain */ |
870 |
@@ -89,7 +91,8 @@ static int udp_v6_get_port(struct sock * |
871 |
struct hlist_head *list; |
872 |
|
873 |
list = &udp_hash[rover & (UDP_HTABLE_SIZE - 1)]; |
874 |
- if (hlist_empty(list)) |
875 |
+ if (hlist_empty(list) && |
876 |
+ !inet_is_reserved_local_port(rover)) |
877 |
goto gotit; |
878 |
|
879 |
sk_for_each(sk2, node, list) |
880 |
@@ -106,7 +109,8 @@ static int udp_v6_get_port(struct sock * |
881 |
/* 2nd pass: find hole in shortest hash chain */ |
882 |
rover = best; |
883 |
for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) { |
884 |
- if (!udp_lport_inuse(rover)) |
885 |
+ if (!udp_lport_inuse(rover) && |
886 |
+ !inet_is_reserved_local_port(rover)) |
887 |
goto gotit; |
888 |
rover += UDP_HTABLE_SIZE; |
889 |
if (rover > high) |
890 |
@@ -247,6 +251,10 @@ try_again: |
891 |
&peeked, &err); |
892 |
if (!skb) |
893 |
goto out; |
894 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
895 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
896 |
+ goto out; |
897 |
+ } |
898 |
|
899 |
copied = skb->len - sizeof(struct udphdr); |
900 |
if (copied > len) { |
901 |
--- linux-2.6.18-274.el5.orig/net/socket.c |
902 |
+++ linux-2.6.18-274.el5/net/socket.c |
903 |
@@ -594,6 +594,8 @@ static inline int __sock_sendmsg(struct |
904 |
si->size = size; |
905 |
|
906 |
err = security_socket_sendmsg(sock, msg, size); |
907 |
+ if (!err) |
908 |
+ err = ccs_socket_sendmsg_permission(sock, msg, size); |
909 |
if (err) |
910 |
return err; |
911 |
|
912 |
@@ -1167,6 +1169,8 @@ static int __sock_create(int family, int |
913 |
} |
914 |
|
915 |
err = security_socket_create(family, type, protocol, kern); |
916 |
+ if (!err) |
917 |
+ err = ccs_socket_create_permission(family, type, protocol); |
918 |
if (err) |
919 |
return err; |
920 |
|
921 |
@@ -1398,6 +1402,11 @@ asmlinkage long sys_bind(int fd, struct |
922 |
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) { |
923 |
err = security_socket_bind(sock, (struct sockaddr *)address, addrlen); |
924 |
if (!err) |
925 |
+ err = ccs_socket_bind_permission(sock, |
926 |
+ (struct sockaddr *) |
927 |
+ address, |
928 |
+ addrlen); |
929 |
+ if (!err) |
930 |
err = sock->ops->bind(sock, |
931 |
(struct sockaddr *)address, addrlen); |
932 |
} |
933 |
@@ -1426,6 +1435,8 @@ asmlinkage long sys_listen(int fd, int b |
934 |
|
935 |
err = security_socket_listen(sock, backlog); |
936 |
if (!err) |
937 |
+ err = ccs_socket_listen_permission(sock); |
938 |
+ if (!err) |
939 |
err = sock->ops->listen(sock, backlog); |
940 |
|
941 |
fput_light(sock->file, fput_needed); |
942 |
@@ -1489,6 +1500,10 @@ asmlinkage long sys_accept(int fd, struc |
943 |
if (err < 0) |
944 |
goto out_fd; |
945 |
|
946 |
+ if (ccs_socket_post_accept_permission(sock, newsock)) { |
947 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
948 |
+ goto out_fd; |
949 |
+ } |
950 |
if (upeer_sockaddr) { |
951 |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
952 |
err = -ECONNABORTED; |
953 |
@@ -1543,6 +1558,9 @@ asmlinkage long sys_connect(int fd, stru |
954 |
goto out_put; |
955 |
|
956 |
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
957 |
+ if (!err) |
958 |
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) |
959 |
+ address, addrlen); |
960 |
if (err) |
961 |
goto out_put; |
962 |
|
963 |
--- linux-2.6.18-274.el5.orig/net/unix/af_unix.c |
964 |
+++ linux-2.6.18-274.el5/net/unix/af_unix.c |
965 |
@@ -808,6 +808,8 @@ static int unix_bind(struct socket *sock |
966 |
*/ |
967 |
mode = S_IFSOCK | |
968 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
969 |
+ err = ccs_mknod_permission(dentry, nd.mnt, mode, 0); |
970 |
+ if (!err) |
971 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
972 |
if (err) |
973 |
goto out_mknod_dput; |
974 |
@@ -1628,6 +1630,10 @@ static int unix_dgram_recvmsg(struct kio |
975 |
|
976 |
wake_up_interruptible(&u->peer_wait); |
977 |
|
978 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
979 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
980 |
+ goto out_unlock; |
981 |
+ } |
982 |
if (msg->msg_name) |
983 |
unix_copy_addr(msg, skb->sk); |
984 |
|
985 |
--- linux-2.6.18-274.el5.orig/security/Kconfig |
986 |
+++ linux-2.6.18-274.el5/security/Kconfig |
987 |
@@ -135,5 +135,7 @@ config LSM_MMAP_MIN_ADDR |
988 |
|
989 |
source security/selinux/Kconfig |
990 |
|
991 |
+source security/ccsecurity/Kconfig |
992 |
+ |
993 |
endmenu |
994 |
|
995 |
--- linux-2.6.18-274.el5.orig/security/Makefile |
996 |
+++ linux-2.6.18-274.el5/security/Makefile |
997 |
@@ -19,3 +19,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin |
998 |
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |
999 |
obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o |
1000 |
obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o |
1001 |
+ |
1002 |
+subdir-$(CONFIG_CCSECURITY)+= ccsecurity |
1003 |
+obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o |