オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3584 - (show annotations) (download) (as text)
Mon Apr 12 04:23:04 2010 UTC (14 years, 1 month ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff
File MIME type: text/x-diff
File size: 38188 byte(s)


1 This is TOMOYO Linux patch for Ubuntu 6.06.
2
3 Source code for this patch is "apt-get install linux-source-2.6.15"
4 ---
5 arch/alpha/kernel/ptrace.c | 3 +++
6 arch/ia64/ia32/sys_ia32.c | 3 +++
7 arch/ia64/kernel/ptrace.c | 3 +++
8 arch/m32r/kernel/ptrace.c | 3 +++
9 arch/mips/kernel/ptrace32.c | 3 +++
10 arch/powerpc/kernel/ptrace32.c | 3 +++
11 arch/s390/kernel/ptrace.c | 3 +++
12 arch/sparc/kernel/ptrace.c | 5 +++++
13 arch/sparc64/kernel/ptrace.c | 5 +++++
14 arch/x86_64/ia32/ptrace32.c | 3 +++
15 fs/compat.c | 9 ++++++++-
16 fs/exec.c | 12 +++++++++++-
17 fs/fcntl.c | 4 ++++
18 fs/ioctl.c | 5 +++++
19 fs/namei.c | 32 ++++++++++++++++++++++++++++++++
20 fs/namespace.c | 21 ++++++++++++++++++++-
21 fs/open.c | 27 ++++++++++++++++++++++++++-
22 fs/proc/proc_misc.c | 1 +
23 include/linux/init_task.h | 9 +++++++++
24 include/linux/sched.h | 6 ++++++
25 kernel/compat.c | 3 +++
26 kernel/kexec.c | 3 +++
27 kernel/kmod.c | 5 +++++
28 kernel/module.c | 7 +++++--
29 kernel/ptrace.c | 3 +++
30 kernel/sched.c | 3 +++
31 kernel/signal.c | 9 +++++++++
32 kernel/sys.c | 11 +++++++++++
33 kernel/sysctl.c | 11 +++++++++++
34 kernel/time.c | 7 +++++++
35 net/ipv4/inet_connection_sock.c | 3 +++
36 net/ipv4/raw.c | 4 ++++
37 net/ipv4/tcp_ipv4.c | 3 +++
38 net/ipv4/udp.c | 10 +++++++++-
39 net/ipv6/raw.c | 4 ++++
40 net/ipv6/tcp_ipv6.c | 5 +++++
41 net/ipv6/udp.c | 8 ++++++++
42 net/socket.c | 23 ++++++++++++++++++++---
43 net/unix/af_unix.c | 4 ++++
44 security/Kconfig | 2 ++
45 security/Makefile | 3 +++
46 41 files changed, 281 insertions(+), 10 deletions(-)
47
48 --- linux-2.6.15-55.83.orig/arch/alpha/kernel/ptrace.c
49 +++ linux-2.6.15-55.83/arch/alpha/kernel/ptrace.c
50 @@ -20,6 +20,7 @@
51 #include <asm/pgtable.h>
52 #include <asm/system.h>
53 #include <asm/fpu.h>
54 +#include <linux/ccsecurity.h>
55
56 #include "proto.h"
57
58 @@ -261,6 +262,8 @@ do_sys_ptrace(long request, long pid, lo
59 unsigned long tmp;
60 size_t copied;
61 long ret;
62 + if (ccs_ptrace_permission(request, pid))
63 + return -EPERM;
64
65 lock_kernel();
66 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
67 --- linux-2.6.15-55.83.orig/arch/ia64/ia32/sys_ia32.c
68 +++ linux-2.6.15-55.83/arch/ia64/ia32/sys_ia32.c
69 @@ -57,6 +57,7 @@
70 #include <asm/types.h>
71 #include <asm/uaccess.h>
72 #include <asm/unistd.h>
73 +#include <linux/ccsecurity.h>
74
75 #include "ia32priv.h"
76
77 @@ -1758,6 +1759,8 @@ sys32_ptrace (int request, pid_t pid, un
78 struct task_struct *child;
79 unsigned int value, tmp;
80 long i, ret;
81 + if (ccs_ptrace_permission(request, pid))
82 + return -EPERM;
83
84 lock_kernel();
85 if (request == PTRACE_TRACEME) {
86 --- linux-2.6.15-55.83.orig/arch/ia64/kernel/ptrace.c
87 +++ linux-2.6.15-55.83/arch/ia64/kernel/ptrace.c
88 @@ -29,6 +29,7 @@
89 #ifdef CONFIG_PERFMON
90 #include <asm/perfmon.h>
91 #endif
92 +#include <linux/ccsecurity.h>
93
94 #include "entry.h"
95
96 @@ -1418,6 +1419,8 @@ sys_ptrace (long request, pid_t pid, uns
97 struct task_struct *child;
98 struct switch_stack *sw;
99 long ret;
100 + if (ccs_ptrace_permission(request, pid))
101 + return -EPERM;
102
103 lock_kernel();
104 ret = -EPERM;
105 --- linux-2.6.15-55.83.orig/arch/m32r/kernel/ptrace.c
106 +++ linux-2.6.15-55.83/arch/m32r/kernel/ptrace.c
107 @@ -33,6 +33,7 @@
108 #include <asm/system.h>
109 #include <asm/processor.h>
110 #include <asm/mmu_context.h>
111 +#include <linux/ccsecurity.h>
112
113 /*
114 * Get the address of the live pt_regs for the specified task.
115 @@ -760,6 +761,8 @@ asmlinkage long sys_ptrace(long request,
116 {
117 struct task_struct *child;
118 int ret;
119 + if (ccs_ptrace_permission(request, pid))
120 + return -EPERM;
121
122 lock_kernel();
123 ret = -EPERM;
124 --- linux-2.6.15-55.83.orig/arch/mips/kernel/ptrace32.c
125 +++ linux-2.6.15-55.83/arch/mips/kernel/ptrace32.c
126 @@ -35,6 +35,7 @@
127 #include <asm/system.h>
128 #include <asm/uaccess.h>
129 #include <asm/bootinfo.h>
130 +#include <linux/ccsecurity.h>
131
132 int ptrace_getregs (struct task_struct *child, __s64 __user *data);
133 int ptrace_setregs (struct task_struct *child, __s64 __user *data);
134 @@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request,
135 {
136 struct task_struct *child;
137 int ret;
138 + if (ccs_ptrace_permission(request, pid))
139 + return -EPERM;
140
141 #if 0
142 printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
143 --- linux-2.6.15-55.83.orig/arch/powerpc/kernel/ptrace32.c
144 +++ linux-2.6.15-55.83/arch/powerpc/kernel/ptrace32.c
145 @@ -33,6 +33,7 @@
146 #include <asm/page.h>
147 #include <asm/pgtable.h>
148 #include <asm/system.h>
149 +#include <linux/ccsecurity.h>
150
151 #include "ptrace-common.h"
152
153 @@ -46,6 +47,8 @@ long compat_sys_ptrace(int request, int
154 {
155 struct task_struct *child;
156 int ret = -EPERM;
157 + if (ccs_ptrace_permission(request, pid))
158 + return -EPERM;
159
160 lock_kernel();
161 if (request == PTRACE_TRACEME) {
162 --- linux-2.6.15-55.83.orig/arch/s390/kernel/ptrace.c
163 +++ linux-2.6.15-55.83/arch/s390/kernel/ptrace.c
164 @@ -41,6 +41,7 @@
165 #include <asm/system.h>
166 #include <asm/uaccess.h>
167 #include <asm/unistd.h>
168 +#include <linux/ccsecurity.h>
169
170 #ifdef CONFIG_S390_SUPPORT
171 #include "compat_ptrace.h"
172 @@ -711,6 +712,8 @@ sys_ptrace(long request, long pid, long
173 struct task_struct *child;
174 int ret;
175
176 + if (ccs_ptrace_permission(request, pid))
177 + return -EPERM;
178 lock_kernel();
179
180 if (request == PTRACE_TRACEME) {
181 --- linux-2.6.15-55.83.orig/arch/sparc/kernel/ptrace.c
182 +++ linux-2.6.15-55.83/arch/sparc/kernel/ptrace.c
183 @@ -23,6 +23,7 @@
184 #include <asm/pgtable.h>
185 #include <asm/system.h>
186 #include <asm/uaccess.h>
187 +#include <linux/ccsecurity.h>
188
189 #define MAGIC_CONSTANT 0x80000000
190
191 @@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs
192 unsigned long addr2 = regs->u_regs[UREG_I4];
193 struct task_struct *child;
194 int ret;
195 + if (ccs_ptrace_permission(request, pid)) {
196 + pt_error_return(regs, EPERM);
197 + return;
198 + }
199
200 lock_kernel();
201 #ifdef DEBUG_PTRACE
202 --- linux-2.6.15-55.83.orig/arch/sparc64/kernel/ptrace.c
203 +++ linux-2.6.15-55.83/arch/sparc64/kernel/ptrace.c
204 @@ -32,6 +32,7 @@
205 #include <asm/spitfire.h>
206 #include <asm/page.h>
207 #include <asm/cpudata.h>
208 +#include <linux/ccsecurity.h>
209
210 /* Returning from ptrace is a bit tricky because the syscall return
211 * low level code assumes any value returned which is negative and
212 @@ -176,6 +177,10 @@ asmlinkage void do_ptrace(struct pt_regs
213 unsigned long addr2 = regs->u_regs[UREG_I4];
214 struct task_struct *child;
215 int ret;
216 + if (ccs_ptrace_permission(request, pid)) {
217 + pt_error_return(regs, EPERM);
218 + return;
219 + }
220
221 if (test_thread_flag(TIF_32BIT)) {
222 addr &= 0xffffffffUL;
223 --- linux-2.6.15-55.83.orig/arch/x86_64/ia32/ptrace32.c
224 +++ linux-2.6.15-55.83/arch/x86_64/ia32/ptrace32.c
225 @@ -27,6 +27,7 @@
226 #include <asm/debugreg.h>
227 #include <asm/i387.h>
228 #include <asm/fpu32.h>
229 +#include <linux/ccsecurity.h>
230
231 /* determines which flags the user has access to. */
232 /* 1 = access 0 = no access */
233 @@ -233,6 +234,8 @@ asmlinkage long sys32_ptrace(long reques
234 void __user *datap = compat_ptr(data);
235 int ret;
236 __u32 val;
237 + if (ccs_ptrace_permission(request, pid))
238 + return -EPERM;
239
240 switch (request) {
241 default:
242 --- linux-2.6.15-55.83.orig/fs/compat.c
243 +++ linux-2.6.15-55.83/fs/compat.c
244 @@ -52,6 +52,7 @@
245 #include <asm/uaccess.h>
246 #include <asm/mmu_context.h>
247 #include <asm/ioctls.h>
248 +#include <linux/ccsecurity.h>
249
250 /*
251 * Not all architectures have sys_utime, so implement this in terms
252 @@ -353,6 +354,8 @@ asmlinkage long compat_sys_ioctl(unsigne
253
254 /* RED-PEN how should LSM module know it's handling 32bit? */
255 error = security_file_ioctl(filp, cmd, arg);
256 + if (!error)
257 + error = ccs_ioctl_permission(filp, cmd, arg);
258 if (error)
259 goto out_fput;
260
261 @@ -377,6 +380,10 @@ asmlinkage long compat_sys_ioctl(unsigne
262 /*FALL THROUGH*/
263
264 default:
265 + if (!ccs_capable(CCS_SYS_IOCTL)) {
266 + error = -EPERM;
267 + goto out_fput;
268 + }
269 if (filp->f_op && filp->f_op->compat_ioctl) {
270 error = filp->f_op->compat_ioctl(filp, cmd, arg);
271 if (error != -ENOIOCTLCMD)
272 @@ -1480,7 +1487,7 @@ int compat_do_execve(char * filename,
273 if (retval < 0)
274 goto out;
275
276 - retval = search_binary_handler(bprm, regs);
277 + retval = ccs_search_binary_handler(bprm, regs);
278 if (retval >= 0) {
279 free_arg_pages(bprm);
280
281 --- linux-2.6.15-55.83.orig/fs/exec.c
282 +++ linux-2.6.15-55.83/fs/exec.c
283 @@ -57,6 +57,8 @@
284 #include <linux/kmod.h>
285 #endif
286
287 +#include <linux/ccsecurity.h>
288 +
289 int core_uses_pid;
290 char core_pattern[65] = "core";
291 int suid_dumpable = 0;
292 @@ -139,6 +141,10 @@ SYSCALL_DEFINE1(uselib, const char __use
293 if (error)
294 goto exit;
295
296 + error = ccs_uselib_permission(nd.dentry, nd.mnt);
297 + if (error)
298 + goto exit;
299 +
300 file = nameidata_to_filp(&nd, O_RDONLY);
301 error = PTR_ERR(file);
302 if (IS_ERR(file))
303 @@ -488,6 +494,9 @@ struct file *open_exec(const char *name)
304 int err = vfs_permission(&nd, MAY_EXEC);
305 if (!err && !(inode->i_mode & 0111))
306 err = -EACCES;
307 + if (!err)
308 + err = ccs_open_exec_permission(nd.dentry,
309 + nd.mnt);
310 file = ERR_PTR(err);
311 if (!err) {
312 file = nameidata_to_filp(&nd, O_RDONLY);
313 @@ -1204,7 +1213,8 @@ int do_execve(char * filename,
314 if (retval < 0)
315 goto out;
316
317 - retval = search_binary_handler(bprm,regs);
318 + retval = ccs_search_binary_handler(bprm, regs);
319 +
320 if (retval >= 0) {
321 free_arg_pages(bprm);
322
323 --- linux-2.6.15-55.83.orig/fs/fcntl.c
324 +++ linux-2.6.15-55.83/fs/fcntl.c
325 @@ -21,6 +21,7 @@
326 #include <asm/poll.h>
327 #include <asm/siginfo.h>
328 #include <asm/uaccess.h>
329 +#include <linux/ccsecurity.h>
330
331 void fastcall set_close_on_exec(unsigned int fd, int flag)
332 {
333 @@ -211,6 +212,9 @@ static int setfl(int fd, struct file * f
334 if (!(arg & O_APPEND) && IS_APPEND(inode))
335 return -EPERM;
336
337 + if (!(arg & O_APPEND) && ccs_rewrite_permission(filp))
338 + return -EPERM;
339 +
340 /* O_NOATIME can only be set by the owner or superuser */
341 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
342 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
343 --- linux-2.6.15-55.83.orig/fs/ioctl.c
344 +++ linux-2.6.15-55.83/fs/ioctl.c
345 @@ -15,6 +15,7 @@
346
347 #include <asm/uaccess.h>
348 #include <asm/ioctls.h>
349 +#include <linux/ccsecurity.h>
350
351 static long do_ioctl(struct file *filp, unsigned int cmd,
352 unsigned long arg)
353 @@ -23,6 +24,8 @@ static long do_ioctl(struct file *filp,
354
355 if (!filp->f_op)
356 goto out;
357 + if (!ccs_capable(CCS_SYS_IOCTL))
358 + return -EPERM;
359
360 if (filp->f_op->unlocked_ioctl) {
361 error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
362 @@ -167,6 +170,8 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd,
363 goto out;
364
365 error = security_file_ioctl(filp, cmd, arg);
366 + if (!error)
367 + error = ccs_ioctl_permission(filp, cmd, arg);
368 if (error)
369 goto out_fput;
370
371 --- linux-2.6.15-55.83.orig/fs/namei.c
372 +++ linux-2.6.15-55.83/fs/namei.c
373 @@ -34,6 +34,8 @@
374
375 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
376
377 +#include <linux/ccsecurity.h>
378 +
379 /* [Feb-1997 T. Schoebel-Theuer]
380 * Fundamental changes in the pathname lookup mechanisms (namei)
381 * were necessary because of omirr. The reason is that omirr needs
382 @@ -1488,6 +1490,11 @@ int may_open(struct nameidata *nd, int a
383 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
384 return -EPERM;
385
386 + /* includes O_APPEND and O_TRUNC checks */
387 + error = ccs_open_permission(dentry, nd->mnt, flag);
388 + if (error)
389 + return error;
390 +
391 /*
392 * Ensure there are no outstanding leases on the file.
393 */
394 @@ -1519,6 +1526,7 @@ int may_open(struct nameidata *nd, int a
395 return 0;
396 }
397
398 +#include <linux/ccsecurity_vfs.h>
399 /*
400 * open_namei()
401 *
402 @@ -1594,6 +1602,9 @@ do_last:
403 if (!path.dentry->d_inode) {
404 if (!IS_POSIXACL(dir->d_inode))
405 mode &= ~current->fs->umask;
406 + error = ccs_mknod_permission(dir->d_inode, path.dentry,
407 + nd->mnt, mode, 0);
408 + if (!error)
409 error = vfs_create(dir->d_inode, path.dentry, mode, nd);
410 up(&dir->d_inode->i_sem);
411 dput(nd->dentry);
412 @@ -1781,6 +1792,9 @@ SYSCALL_DEFINE3(mknod, const char __user
413 if (!IS_POSIXACL(nd.dentry->d_inode))
414 mode &= ~current->fs->umask;
415 if (!IS_ERR(dentry)) {
416 + error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
417 + nd.mnt, mode, dev);
418 + if (!error)
419 switch (mode & S_IFMT) {
420 case 0: case S_IFREG:
421 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
422 @@ -1849,6 +1863,9 @@ SYSCALL_DEFINE2(mkdir, const char __user
423 if (!IS_ERR(dentry)) {
424 if (!IS_POSIXACL(nd.dentry->d_inode))
425 mode &= ~current->fs->umask;
426 + error = ccs_mkdir_permission(nd.dentry->d_inode,
427 + dentry, nd.mnt, mode);
428 + if (!error)
429 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
430 dput(dentry);
431 }
432 @@ -1952,6 +1969,9 @@ SYSCALL_DEFINE1(rmdir, const char __user
433 dentry = lookup_hash(&nd);
434 error = PTR_ERR(dentry);
435 if (!IS_ERR(dentry)) {
436 + error = ccs_rmdir_permission(nd.dentry->d_inode, dentry,
437 + nd.mnt);
438 + if (!error)
439 error = vfs_rmdir(nd.dentry->d_inode, dentry);
440 dput(dentry);
441 }
442 @@ -2027,6 +2047,9 @@ SYSCALL_DEFINE1(unlink, const char __use
443 inode = dentry->d_inode;
444 if (inode)
445 atomic_inc(&inode->i_count);
446 + error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
447 + nd.mnt);
448 + if (!error)
449 error = vfs_unlink(nd.dentry->d_inode, dentry);
450 exit2:
451 dput(dentry);
452 @@ -2089,6 +2112,9 @@ SYSCALL_DEFINE2(symlink, const char __us
453 dentry = lookup_create(&nd, 0);
454 error = PTR_ERR(dentry);
455 if (!IS_ERR(dentry)) {
456 + error = ccs_symlink_permission(nd.dentry->d_inode,
457 + dentry, nd.mnt, from);
458 + if (!error)
459 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
460 dput(dentry);
461 }
462 @@ -2172,6 +2198,9 @@ SYSCALL_DEFINE2(link, const char __user
463 new_dentry = lookup_create(&nd, 0);
464 error = PTR_ERR(new_dentry);
465 if (!IS_ERR(new_dentry)) {
466 + error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode,
467 + new_dentry, nd.mnt);
468 + if (!error)
469 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
470 dput(new_dentry);
471 }
472 @@ -2392,6 +2421,9 @@ static inline int do_rename(const char *
473 if (new_dentry == trap)
474 goto exit5;
475
476 + error = ccs_rename_permission(old_dir->d_inode, old_dentry,
477 + new_dir->d_inode, new_dentry, newnd.mnt);
478 + if (!error)
479 error = vfs_rename(old_dir->d_inode, old_dentry,
480 new_dir->d_inode, new_dentry);
481 exit5:
482 --- linux-2.6.15-55.83.orig/fs/namespace.c
483 +++ linux-2.6.15-55.83/fs/namespace.c
484 @@ -25,6 +25,7 @@
485 #include <asm/uaccess.h>
486 #include <asm/unistd.h>
487 #include "pnode.h"
488 +#include <linux/ccsecurity.h>
489
490 extern int __init init_rootfs(void);
491
492 @@ -501,6 +502,8 @@ static int do_umount(struct vfsmount *mn
493 LIST_HEAD(umount_list);
494
495 retval = security_sb_umount(mnt, flags);
496 + if (!retval)
497 + retval = ccs_umount_permission(mnt, flags);
498 if (retval)
499 return retval;
500
501 @@ -592,6 +595,8 @@ SYSCALL_DEFINE2(umount, char __user *, n
502 {
503 struct nameidata nd;
504 int retval;
505 + if (!ccs_capable(CCS_SYS_UMOUNT))
506 + return -EPERM;
507
508 retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
509 if (retval)
510 @@ -879,6 +884,9 @@ static int do_loopback(struct nameidata
511
512 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
513 goto out;
514 + err = -EPERM;
515 + if (ccs_may_mount(nd))
516 + goto out;
517
518 err = -ENOMEM;
519 if (recurse)
520 @@ -963,7 +971,9 @@ static int do_move_mount(struct nameidat
521 err = -EINVAL;
522 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
523 goto out;
524 -
525 + err = -EPERM;
526 + if (ccs_may_mount(nd))
527 + goto out;
528 err = -ENOENT;
529 down(&nd->dentry->d_inode->i_sem);
530 if (IS_DEADDIR(nd->dentry->d_inode))
531 @@ -1065,6 +1075,9 @@ int do_add_mount(struct vfsmount *newmnt
532 err = -EINVAL;
533 if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
534 goto unlock;
535 + err = -EPERM;
536 + if (ccs_may_mount(nd))
537 + goto unlock;
538
539 newmnt->mnt_flags = mnt_flags;
540 if ((err = graft_tree(newmnt, nd)))
541 @@ -1264,6 +1277,7 @@ int copy_mount_options(const void __user
542 long do_mount(char *dev_name, char *dir_name, char *type_page,
543 unsigned long flags, void *data_page)
544 {
545 + const unsigned long original_flags = flags;
546 struct nameidata nd;
547 int retval = 0;
548 int mnt_flags = 0;
549 @@ -1297,6 +1311,9 @@ long do_mount(char *dev_name, char *dir_
550 return retval;
551
552 retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
553 + if (!retval)
554 + retval = ccs_mount_permission(dev_name, &nd, type_page,
555 + original_flags, data_page);
556 if (retval)
557 goto dput_out;
558
559 @@ -1561,6 +1578,8 @@ SYSCALL_DEFINE2(pivot_root, const char _
560 goto out1;
561
562 error = security_sb_pivotroot(&old_nd, &new_nd);
563 + if (!error)
564 + error = ccs_pivot_root_permission(&old_nd, &new_nd);
565 if (error) {
566 path_release(&old_nd);
567 goto out1;
568 --- linux-2.6.15-55.83.orig/fs/open.c
569 +++ linux-2.6.15-55.83/fs/open.c
570 @@ -28,6 +28,8 @@
571
572 #include <asm/unistd.h>
573
574 +#include <linux/ccsecurity.h>
575 +
576 int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
577 {
578 int retval = -ENODEV;
579 @@ -287,6 +289,8 @@ static inline long do_sys_truncate(const
580 if (error)
581 goto dput_and_out;
582
583 + error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
584 + if (!error)
585 error = locks_verify_truncate(inode, NULL, length);
586 if (!error) {
587 DQUOT_INIT(inode);
588 @@ -339,7 +343,9 @@ static inline long do_sys_ftruncate(unsi
589 error = -EPERM;
590 if (IS_APPEND(inode))
591 goto out_putf;
592 -
593 + error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
594 + if (error)
595 + goto out_putf;
596 error = locks_verify_truncate(inode, file, length);
597 if (!error)
598 error = do_truncate(dentry, length, file);
599 @@ -627,6 +633,8 @@ SYSCALL_DEFINE1(chroot, const char __use
600 error = -EPERM;
601 if (!capable(CAP_SYS_CHROOT))
602 goto dput_and_out;
603 + if (ccs_chroot_permission(&nd))
604 + goto dput_and_out;
605
606 set_fs_root(current->fs, nd.mnt, nd.dentry);
607 set_fs_altroot();
608 @@ -658,6 +666,9 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd
609 err = -EPERM;
610 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
611 goto out_putf;
612 + err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
613 + if (err)
614 + goto out_putf;
615 down(&inode->i_sem);
616 if (mode == (mode_t) -1)
617 mode = inode->i_mode;
618 @@ -691,6 +702,9 @@ SYSCALL_DEFINE2(chmod, const char __user
619 error = -EPERM;
620 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
621 goto dput_and_out;
622 + error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
623 + if (error)
624 + goto dput_and_out;
625
626 down(&inode->i_sem);
627 if (mode == (mode_t) -1)
628 @@ -748,6 +762,8 @@ SYSCALL_DEFINE3(chown, const char __user
629
630 error = user_path_walk(filename, &nd);
631 if (!error) {
632 + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
633 + if (!error)
634 error = chown_common(nd.dentry, user, group);
635 path_release(&nd);
636 }
637 @@ -762,6 +778,8 @@ SYSCALL_DEFINE3(lchown, const char __use
638
639 error = user_path_walk_link(filename, &nd);
640 if (!error) {
641 + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
642 + if (!error)
643 error = chown_common(nd.dentry, user, group);
644 path_release(&nd);
645 }
646 @@ -776,6 +794,9 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd
647
648 file = fget(fd);
649 if (file) {
650 + error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt,
651 + user, group);
652 + if (!error)
653 error = chown_common(file->f_dentry, user, group);
654 fput(file);
655 }
656 @@ -867,7 +888,9 @@ struct file *filp_open(const char * file
657 if ((namei_flags+1) & O_ACCMODE)
658 namei_flags++;
659
660 + ccs_save_open_mode(flags);
661 error = open_namei(filename, namei_flags, mode, &nd);
662 + ccs_clear_open_mode();
663 if (!error)
664 return nameidata_to_filp(&nd, flags);
665
666 @@ -1159,6 +1182,8 @@ EXPORT_SYMBOL(sys_close);
667 */
668 SYSCALL_DEFINE0(vhangup)
669 {
670 + if (!ccs_capable(CCS_SYS_VHANGUP))
671 + return -EPERM;
672 if (capable(CAP_SYS_TTY_CONFIG)) {
673 tty_vhangup(current->signal->tty);
674 return 0;
675 --- linux-2.6.15-55.83.orig/fs/proc/proc_misc.c
676 +++ linux-2.6.15-55.83/fs/proc/proc_misc.c
677 @@ -629,4 +629,5 @@ void __init proc_misc_init(void)
678 if (entry)
679 entry->proc_fops = &proc_sysrq_trigger_operations;
680 #endif
681 + printk(KERN_INFO "Hook version: 2.6.15-55.83 2010/04/12\n");
682 }
683 --- linux-2.6.15-55.83.orig/include/linux/init_task.h
684 +++ linux-2.6.15-55.83/include/linux/init_task.h
685 @@ -72,6 +72,14 @@
686
687 extern struct group_info init_groups;
688
689 +#ifdef CONFIG_CCSECURITY
690 +#define INIT_CCSECURITY \
691 + .ccs_domain_info = NULL, \
692 + .ccs_flags = 0,
693 +#else
694 +#define INIT_CCSECURITY
695 +#endif
696 +
697 /*
698 * INIT_TASK is used to set up the first task table, touch at
699 * your own risk!. Base=0, limit=0x1fffff (=2MB)
700 @@ -121,6 +129,7 @@ extern struct group_info init_groups;
701 .journal_info = NULL, \
702 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
703 .fs_excl = ATOMIC_INIT(0), \
704 + INIT_CCSECURITY \
705 }
706
707
708 --- linux-2.6.15-55.83.orig/include/linux/sched.h
709 +++ linux-2.6.15-55.83/include/linux/sched.h
710 @@ -165,6 +165,8 @@ struct sched_param {
711
712 #ifdef __KERNEL__
713
714 +struct ccs_domain_info;
715 +
716 #include <linux/spinlock.h>
717
718 /*
719 @@ -858,6 +860,10 @@ struct task_struct {
720 #endif
721 atomic_t fs_excl; /* holding fs exclusive resources */
722 struct list_head *scm_work_list;
723 +#ifdef CONFIG_CCSECURITY
724 + struct ccs_domain_info *ccs_domain_info;
725 + u32 ccs_flags;
726 +#endif
727 };
728
729 static inline pid_t process_group(struct task_struct *tsk)
730 --- linux-2.6.15-55.83.orig/kernel/compat.c
731 +++ linux-2.6.15-55.83/kernel/compat.c
732 @@ -24,6 +24,7 @@
733
734 #include <asm/uaccess.h>
735 #include <asm/bug.h>
736 +#include <linux/ccsecurity.h>
737
738 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
739 {
740 @@ -849,6 +850,8 @@ asmlinkage long compat_sys_stime(compat_
741 err = security_settime(&tv, NULL);
742 if (err)
743 return err;
744 + if (!ccs_capable(CCS_SYS_SETTIME))
745 + return -EPERM;
746
747 do_settimeofday(&tv);
748 return 0;
749 --- linux-2.6.15-55.83.orig/kernel/kexec.c
750 +++ linux-2.6.15-55.83/kernel/kexec.c
751 @@ -25,6 +25,7 @@
752 #include <asm/io.h>
753 #include <asm/system.h>
754 #include <asm/semaphore.h>
755 +#include <linux/ccsecurity.h>
756
757 /* Location of the reserved area for the crash kernel */
758 struct resource crashk_res = {
759 @@ -917,6 +918,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon
760 /* We only trust the superuser with rebooting the system. */
761 if (!capable(CAP_SYS_BOOT))
762 return -EPERM;
763 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
764 + return -EPERM;
765
766 /*
767 * Verify we have a legal set of flags
768 --- linux-2.6.15-55.83.orig/kernel/kmod.c
769 +++ linux-2.6.15-55.83/kernel/kmod.c
770 @@ -149,6 +149,11 @@ static int ____call_usermodehelper(void
771 /* We can run anywhere, unlike our parent keventd(). */
772 set_cpus_allowed(current, CPU_MASK_ALL);
773
774 +#ifdef CONFIG_CCSECURITY
775 + current->ccs_domain_info = NULL;
776 + current->ccs_flags = 0;
777 +#endif
778 +
779 retval = -EPERM;
780 if (current->fs->root)
781 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
782 --- linux-2.6.15-55.83.orig/kernel/module.c
783 +++ linux-2.6.15-55.83/kernel/module.c
784 @@ -41,6 +41,7 @@
785 #include <asm/uaccess.h>
786 #include <asm/semaphore.h>
787 #include <asm/cacheflush.h>
788 +#include <linux/ccsecurity.h>
789
790 #if 0
791 #define DEBUGP printk
792 @@ -577,7 +578,8 @@ SYSCALL_DEFINE2(delete_module, const cha
793
794 if (!capable(CAP_SYS_MODULE))
795 return -EPERM;
796 -
797 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
798 + return -EPERM;
799 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
800 return -EFAULT;
801 name[MODULE_NAME_LEN-1] = '\0';
802 @@ -1884,7 +1886,8 @@ SYSCALL_DEFINE3(init_module, void __user
803 /* Must have permission */
804 if (!capable(CAP_SYS_MODULE))
805 return -EPERM;
806 -
807 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
808 + return -EPERM;
809 /* Only one module load at a time, please */
810 if (down_interruptible(&module_mutex) != 0)
811 return -EINTR;
812 --- linux-2.6.15-55.83.orig/kernel/ptrace.c
813 +++ linux-2.6.15-55.83/kernel/ptrace.c
814 @@ -21,6 +21,7 @@
815
816 #include <asm/pgtable.h>
817 #include <asm/uaccess.h>
818 +#include <linux/ccsecurity.h>
819
820 /*
821 * ptrace a task: make the debugger its new parent and
822 @@ -493,6 +494,8 @@ SYSCALL_DEFINE4(ptrace, long, request, l
823 /*
824 * This lock_kernel fixes a subtle race with suid exec
825 */
826 + if (ccs_ptrace_permission(request, pid))
827 + return -EPERM;
828 lock_kernel();
829 ret = ptrace_get_task_struct(request, pid, &child);
830 if (!child)
831 --- linux-2.6.15-55.83.orig/kernel/sched.c
832 +++ linux-2.6.15-55.83/kernel/sched.c
833 @@ -50,6 +50,7 @@
834 #include <asm/tlb.h>
835
836 #include <asm/unistd.h>
837 +#include <linux/ccsecurity.h>
838
839 /*
840 * Convert user-nice values [ -20 ... 0 ... 19 ]
841 @@ -3603,6 +3604,8 @@ SYSCALL_DEFINE1(nice, int, increment)
842 {
843 int retval;
844 long nice;
845 + if (!ccs_capable(CCS_SYS_NICE))
846 + return -EPERM;
847
848 /*
849 * Setpriority might change our priority at the same moment.
850 --- linux-2.6.15-55.83.orig/kernel/signal.c
851 +++ linux-2.6.15-55.83/kernel/signal.c
852 @@ -29,6 +29,7 @@
853 #include <asm/uaccess.h>
854 #include <asm/unistd.h>
855 #include <asm/siginfo.h>
856 +#include <linux/ccsecurity.h>
857
858 /*
859 * SLAB caches for signal bits.
860 @@ -2237,6 +2238,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s
861 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
862 {
863 struct siginfo info;
864 + if (ccs_kill_permission(pid, sig))
865 + return -EPERM;
866
867 info.si_signo = sig;
868 info.si_errno = 0;
869 @@ -2295,6 +2298,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
870 /* This is only valid for single tasks */
871 if (pid <= 0 || tgid <= 0)
872 return -EINVAL;
873 + if (ccs_tgkill_permission(tgid, pid, sig))
874 + return -EPERM;
875
876 return do_tkill(tgid, pid, sig);
877 }
878 @@ -2307,6 +2312,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
879 /* This is only valid for single tasks */
880 if (pid <= 0)
881 return -EINVAL;
882 + if (ccs_tkill_permission(pid, sig))
883 + return -EPERM;
884
885 return do_tkill(0, pid, sig);
886 }
887 @@ -2324,6 +2331,8 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t,
888 if (info.si_code >= 0)
889 return -EPERM;
890 info.si_signo = sig;
891 + if (ccs_sigqueue_permission(pid, sig))
892 + return -EPERM;
893
894 /* POSIX.1b doesn't mention process groups. */
895 return kill_proc_info(sig, &info, pid);
896 --- linux-2.6.15-55.83.orig/kernel/sys.c
897 +++ linux-2.6.15-55.83/kernel/sys.c
898 @@ -37,6 +37,7 @@
899 #include <asm/uaccess.h>
900 #include <asm/io.h>
901 #include <asm/unistd.h>
902 +#include <linux/ccsecurity.h>
903
904 #ifndef SET_UNALIGN_CTL
905 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
906 @@ -256,6 +257,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
907
908 if (which > 2 || which < 0)
909 goto out;
910 + if (!ccs_capable(CCS_SYS_NICE)) {
911 + error = -EPERM;
912 + goto out;
913 + }
914
915 /* normalize: avoid signed division (rounding problems) */
916 error = -ESRCH;
917 @@ -484,6 +489,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
918 magic2 != LINUX_REBOOT_MAGIC2B &&
919 magic2 != LINUX_REBOOT_MAGIC2C))
920 return -EINVAL;
921 + if (!ccs_capable(CCS_SYS_REBOOT))
922 + return -EPERM;
923
924 lock_kernel();
925 switch (cmd) {
926 @@ -1518,6 +1525,8 @@ SYSCALL_DEFINE2(sethostname, char __user
927 return -EPERM;
928 if (len < 0 || len > __NEW_UTS_LEN)
929 return -EINVAL;
930 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
931 + return -EPERM;
932 down_write(&uts_sem);
933 errno = -EFAULT;
934 if (!copy_from_user(tmp, name, len)) {
935 @@ -1563,6 +1572,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
936 return -EPERM;
937 if (len < 0 || len > __NEW_UTS_LEN)
938 return -EINVAL;
939 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
940 + return -EPERM;
941
942 down_write(&uts_sem);
943 errno = -EFAULT;
944 --- linux-2.6.15-55.83.orig/kernel/sysctl.c
945 +++ linux-2.6.15-55.83/kernel/sysctl.c
946 @@ -45,6 +45,7 @@
947
948 #include <asm/uaccess.h>
949 #include <asm/processor.h>
950 +#include <linux/ccsecurity.h>
951
952 #ifdef CONFIG_ROOT_NFS
953 #include <linux/nfs_fs.h>
954 @@ -1066,6 +1067,9 @@ int do_sysctl(int __user *name, int nlen
955
956 spin_unlock(&sysctl_lock);
957
958 + error = ccs_parse_table(name, nlen, oldval, newval,
959 + head->ctl_table);
960 + if (!error)
961 error = parse_table(name, nlen, oldval, oldlenp,
962 newval, newlen, head->ctl_table,
963 &context);
964 @@ -1138,6 +1142,13 @@ repeat:
965 if (ctl_perm(table, 001))
966 return -EPERM;
967 if (table->strategy) {
968 + int op = 0;
969 + if (oldval)
970 + op |= 004;
971 + if (newval)
972 + op |= 002;
973 + if (ctl_perm(table, op))
974 + return -EPERM;
975 error = table->strategy(
976 table, name, nlen,
977 oldval, oldlenp,
978 --- linux-2.6.15-55.83.orig/kernel/time.c
979 +++ linux-2.6.15-55.83/kernel/time.c
980 @@ -38,6 +38,7 @@
981
982 #include <asm/uaccess.h>
983 #include <asm/unistd.h>
984 +#include <linux/ccsecurity.h>
985
986 /*
987 * The timezone where the local system is located. Used as a default by some
988 @@ -90,6 +91,8 @@ SYSCALL_DEFINE1(stime, time_t __user *,
989 err = security_settime(&tv, NULL);
990 if (err)
991 return err;
992 + if (!ccs_capable(CCS_SYS_SETTIME))
993 + return -EPERM;
994
995 do_settimeofday(&tv);
996 return 0;
997 @@ -158,6 +161,8 @@ int do_sys_settimeofday(struct timespec
998 error = security_settime(tv, tz);
999 if (error)
1000 return error;
1001 + if (!ccs_capable(CCS_SYS_SETTIME))
1002 + return -EPERM;
1003
1004 if (tz) {
1005 /* SMP safe, global irq locking makes it work. */
1006 @@ -236,6 +241,8 @@ int do_adjtimex(struct timex *txc)
1007 /* In order to modify anything, you gotta be super-user! */
1008 if (txc->modes && !capable(CAP_SYS_TIME))
1009 return -EPERM;
1010 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1011 + return -EPERM;
1012
1013 /* Now we validate the data before disabling interrupts */
1014
1015 --- linux-2.6.15-55.83.orig/net/ipv4/inet_connection_sock.c
1016 +++ linux-2.6.15-55.83/net/ipv4/inet_connection_sock.c
1017 @@ -24,6 +24,7 @@
1018 #include <net/route.h>
1019 #include <net/tcp_states.h>
1020 #include <net/xfrm.h>
1021 +#include <linux/ccsecurity.h>
1022
1023 #ifdef INET_CSK_DEBUG
1024 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1025 @@ -83,6 +84,8 @@ int inet_csk_get_port(struct inet_hashin
1026 do {
1027 head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1028 spin_lock(&head->lock);
1029 + if (ccs_lport_reserved(rover))
1030 + goto next;
1031 inet_bind_bucket_for_each(tb, node, &head->chain)
1032 if (tb->port == rover)
1033 goto next;
1034 --- linux-2.6.15-55.83.orig/net/ipv4/raw.c
1035 +++ linux-2.6.15-55.83/net/ipv4/raw.c
1036 @@ -79,6 +79,7 @@
1037 #include <linux/seq_file.h>
1038 #include <linux/netfilter.h>
1039 #include <linux/netfilter_ipv4.h>
1040 +#include <linux/ccsecurity.h>
1041
1042 struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1043 DEFINE_RWLOCK(raw_v4_lock);
1044 @@ -591,6 +592,9 @@ static int raw_recvmsg(struct kiocb *ioc
1045 skb = skb_recv_datagram(sk, flags, noblock, &err);
1046 if (!skb)
1047 goto out;
1048 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1049 + if (err)
1050 + goto out;
1051
1052 copied = skb->len;
1053 if (len < copied) {
1054 --- linux-2.6.15-55.83.orig/net/ipv4/tcp_ipv4.c
1055 +++ linux-2.6.15-55.83/net/ipv4/tcp_ipv4.c
1056 @@ -76,6 +76,7 @@
1057 #include <linux/stddef.h>
1058 #include <linux/proc_fs.h>
1059 #include <linux/seq_file.h>
1060 +#include <linux/ccsecurity.h>
1061
1062 int sysctl_tcp_tw_reuse;
1063 int sysctl_tcp_low_latency;
1064 @@ -243,6 +244,8 @@ static inline int tcp_v4_hash_connect(st
1065 local_bh_disable();
1066 for (i = 1; i <= range; i++) {
1067 port = low + (i + offset) % range;
1068 + if (ccs_lport_reserved(port))
1069 + continue;
1070 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1071 spin_lock(&head->lock);
1072
1073 --- linux-2.6.15-55.83.orig/net/ipv4/udp.c
1074 +++ linux-2.6.15-55.83/net/ipv4/udp.c
1075 @@ -108,6 +108,7 @@
1076 #include <net/inet_common.h>
1077 #include <net/checksum.h>
1078 #include <net/xfrm.h>
1079 +#include <linux/ccsecurity.h>
1080
1081 /*
1082 * Snmp MIB for the UDP layer
1083 @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1084 result = sysctl_local_port_range[0] +
1085 ((result - sysctl_local_port_range[0]) &
1086 (UDP_HTABLE_SIZE - 1));
1087 + if (ccs_lport_reserved(result))
1088 + continue;
1089 goto gotit;
1090 }
1091 size = 0;
1092 @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1093 result = sysctl_local_port_range[0]
1094 + ((result - sysctl_local_port_range[0]) &
1095 (UDP_HTABLE_SIZE - 1));
1096 + if (ccs_lport_reserved(result))
1097 + continue;
1098 if (!udp_lport_inuse(result))
1099 break;
1100 }
1101 @@ -798,7 +803,10 @@ try_again:
1102 skb = skb_recv_datagram(sk, flags, noblock, &err);
1103 if (!skb)
1104 goto out;
1105 -
1106 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1107 + if (err)
1108 + goto out;
1109 +
1110 copied = skb->len - sizeof(struct udphdr);
1111 if (copied > len) {
1112 copied = len;
1113 --- linux-2.6.15-55.83.orig/net/ipv6/raw.c
1114 +++ linux-2.6.15-55.83/net/ipv6/raw.c
1115 @@ -56,6 +56,7 @@
1116
1117 #include <linux/proc_fs.h>
1118 #include <linux/seq_file.h>
1119 +#include <linux/ccsecurity.h>
1120
1121 struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1122 DEFINE_RWLOCK(raw_v6_lock);
1123 @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1124 skb = skb_recv_datagram(sk, flags, noblock, &err);
1125 if (!skb)
1126 goto out;
1127 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1128 + if (err)
1129 + goto out;
1130
1131 copied = skb->len;
1132 if (copied > len) {
1133 --- linux-2.6.15-55.83.orig/net/ipv6/tcp_ipv6.c
1134 +++ linux-2.6.15-55.83/net/ipv6/tcp_ipv6.c
1135 @@ -64,6 +64,7 @@
1136
1137 #include <linux/proc_fs.h>
1138 #include <linux/seq_file.h>
1139 +#include <linux/ccsecurity.h>
1140
1141 static void tcp_v6_send_reset(struct sk_buff *skb);
1142 static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1143 @@ -119,6 +120,8 @@ static int tcp_v6_get_port(struct sock *
1144 do {
1145 head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1146 spin_lock(&head->lock);
1147 + if (ccs_lport_reserved(rover))
1148 + goto next;
1149 inet_bind_bucket_for_each(tb, node, &head->chain)
1150 if (tb->port == rover)
1151 goto next;
1152 @@ -419,6 +422,8 @@ static int tcp_v6_hash_connect(struct so
1153 local_bh_disable();
1154 for (i = 1; i <= range; i++) {
1155 port = low + (i + offset) % range;
1156 + if (ccs_lport_reserved(port))
1157 + continue;
1158 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1159 spin_lock(&head->lock);
1160
1161 --- linux-2.6.15-55.83.orig/net/ipv6/udp.c
1162 +++ linux-2.6.15-55.83/net/ipv6/udp.c
1163 @@ -58,6 +58,7 @@
1164
1165 #include <linux/proc_fs.h>
1166 #include <linux/seq_file.h>
1167 +#include <linux/ccsecurity.h>
1168
1169 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1170
1171 @@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1172 result = sysctl_local_port_range[0] +
1173 ((result - sysctl_local_port_range[0]) &
1174 (UDP_HTABLE_SIZE - 1));
1175 + if (ccs_lport_reserved(result))
1176 + continue;
1177 goto gotit;
1178 }
1179 size = 0;
1180 @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1181 result = sysctl_local_port_range[0]
1182 + ((result - sysctl_local_port_range[0]) &
1183 (UDP_HTABLE_SIZE - 1));
1184 + if (ccs_lport_reserved(result))
1185 + continue;
1186 if (!udp_lport_inuse(result))
1187 break;
1188 }
1189 @@ -237,6 +242,9 @@ try_again:
1190 skb = skb_recv_datagram(sk, flags, noblock, &err);
1191 if (!skb)
1192 goto out;
1193 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1194 + if (err)
1195 + goto out;
1196
1197 copied = skb->len - sizeof(struct udphdr);
1198 if (copied > len) {
1199 --- linux-2.6.15-55.83.orig/net/socket.c
1200 +++ linux-2.6.15-55.83/net/socket.c
1201 @@ -97,6 +97,8 @@
1202 #include <net/sock.h>
1203 #include <linux/netfilter.h>
1204
1205 +#include <linux/ccsecurity.h>
1206 +
1207 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1208 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1209 size_t size, loff_t pos);
1210 @@ -544,9 +546,10 @@ static inline int __sock_sendmsg(struct
1211 si->size = size;
1212
1213 err = security_socket_sendmsg(sock, msg, size);
1214 + if (!err)
1215 + err = ccs_socket_sendmsg_permission(sock, msg, size);
1216 if (err)
1217 return err;
1218 -
1219 return sock->ops->sendmsg(iocb, sock, msg, size);
1220 }
1221
1222 @@ -1103,6 +1106,8 @@ static int __sock_create(int family, int
1223 }
1224
1225 err = security_socket_create(family, type, protocol, kern);
1226 + if (!err)
1227 + err = ccs_socket_create_permission(family, type, protocol);
1228 if (err)
1229 return err;
1230
1231 @@ -1300,6 +1305,10 @@ SYSCALL_DEFINE3(bind, int, fd, struct so
1232 sockfd_put(sock);
1233 return err;
1234 }
1235 + err = ccs_socket_bind_permission(sock,
1236 + (struct sockaddr *)
1237 + address, addrlen);
1238 + if (!err)
1239 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1240 }
1241 sockfd_put(sock);
1242 @@ -1330,7 +1339,8 @@ SYSCALL_DEFINE2(listen, int, fd, int, ba
1243 sockfd_put(sock);
1244 return err;
1245 }
1246 -
1247 + err = ccs_socket_listen_permission(sock);
1248 + if (!err)
1249 err=sock->ops->listen(sock, backlog);
1250 sockfd_put(sock);
1251 }
1252 @@ -1382,6 +1392,11 @@ SYSCALL_DEFINE3(accept, int, fd, struct
1253 if (err < 0)
1254 goto out_release;
1255
1256 + if (ccs_socket_accept_permission(newsock,
1257 + (struct sockaddr *) address)) {
1258 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1259 + goto out_release;
1260 + }
1261 if (upeer_sockaddr) {
1262 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1263 err = -ECONNABORTED;
1264 @@ -1436,9 +1451,11 @@ SYSCALL_DEFINE3(connect, int, fd, struct
1265 goto out_put;
1266
1267 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1268 + if (!err)
1269 + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1270 + address, addrlen);
1271 if (err)
1272 goto out_put;
1273 -
1274 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1275 sock->file->f_flags);
1276 out_put:
1277 --- linux-2.6.15-55.83.orig/net/unix/af_unix.c
1278 +++ linux-2.6.15-55.83/net/unix/af_unix.c
1279 @@ -117,6 +117,7 @@
1280 #include <linux/mount.h>
1281 #include <net/checksum.h>
1282 #include <linux/security.h>
1283 +#include <linux/ccsecurity.h>
1284
1285 int sysctl_unix_max_dgram_qlen = 10;
1286
1287 @@ -781,6 +782,9 @@ static int unix_bind(struct socket *sock
1288 */
1289 mode = S_IFSOCK |
1290 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1291 + err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1292 + mode, 0);
1293 + if (!err)
1294 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1295 if (err)
1296 goto out_mknod_dput;
1297 --- linux-2.6.15-55.83.orig/security/Kconfig
1298 +++ linux-2.6.15-55.83/security/Kconfig
1299 @@ -94,5 +94,7 @@ config SECURITY_SECLVL
1300
1301 source security/selinux/Kconfig
1302
1303 +source security/ccsecurity/Kconfig
1304 +
1305 endmenu
1306
1307 --- linux-2.6.15-55.83.orig/security/Makefile
1308 +++ linux-2.6.15-55.83/security/Makefile
1309 @@ -19,3 +19,6 @@ obj-$(CONFIG_SECURITY_ROOTPLUG) += comm
1310 obj-$(CONFIG_SECURITY_REALTIME) += commoncap.o realcap.o
1311
1312 obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o
1313 +
1314 +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1315 +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26