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

Subversion リポジトリの参照

Annotation of /branches/ccs-patch/patches/ccs-patch-2.6.15-cat-760.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3372 - (hide annotations) (download) (as text)
Tue Jan 19 04:32:34 2010 UTC (14 years, 4 months ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.15-cat-760.diff
File MIME type: text/x-diff
File size: 38268 byte(s)


1 kumaneko 3372 This is TOMOYO Linux patch for CAT-760.
2    
3     Source code for this patch is linux-2.6.15-cat_20080502.tgz
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 | 23 ++++++++++++++++++++++-
21     fs/open.c | 29 ++++++++++++++++++++++++++++-
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 | 8 ++++++++
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, 284 insertions(+), 9 deletions(-)
47    
48     --- linux-2.6.15-cat.orig/arch/alpha/kernel/ptrace.c
49     +++ linux-2.6.15-cat/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-cat.orig/arch/ia64/ia32/sys_ia32.c
68     +++ linux-2.6.15-cat/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-cat.orig/arch/ia64/kernel/ptrace.c
87     +++ linux-2.6.15-cat/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-cat.orig/arch/m32r/kernel/ptrace.c
106     +++ linux-2.6.15-cat/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-cat.orig/arch/mips/kernel/ptrace32.c
125     +++ linux-2.6.15-cat/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-cat.orig/arch/powerpc/kernel/ptrace32.c
144     +++ linux-2.6.15-cat/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-cat.orig/arch/s390/kernel/ptrace.c
163     +++ linux-2.6.15-cat/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-cat.orig/arch/sparc/kernel/ptrace.c
182     +++ linux-2.6.15-cat/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-cat.orig/arch/sparc64/kernel/ptrace.c
203     +++ linux-2.6.15-cat/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     @@ -173,6 +174,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-cat.orig/arch/x86_64/ia32/ptrace32.c
224     +++ linux-2.6.15-cat/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-cat.orig/fs/compat.c
243     +++ linux-2.6.15-cat/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_check_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     @@ -1476,7 +1483,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-cat.orig/fs/exec.c
282     +++ linux-2.6.15-cat/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 @@ asmlinkage long sys_uselib(const char __
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     @@ -1192,7 +1201,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-cat.orig/fs/fcntl.c
324     +++ linux-2.6.15-cat/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-cat.orig/fs/ioctl.c
344     +++ linux-2.6.15-cat/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 @@ asmlinkage long sys_ioctl(unsigned int f
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-cat.orig/fs/namei.c
372     +++ linux-2.6.15-cat/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     @@ -1472,6 +1474,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     @@ -1503,6 +1510,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     @@ -1578,6 +1586,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     @@ -1765,6 +1776,9 @@ asmlinkage long sys_mknod(const char __u
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     @@ -1833,6 +1847,9 @@ asmlinkage long sys_mkdir(const char __u
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     @@ -1936,6 +1953,9 @@ asmlinkage long sys_rmdir(const char __u
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     @@ -2011,6 +2031,9 @@ asmlinkage long sys_unlink(const char __
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     @@ -2072,6 +2095,9 @@ asmlinkage long sys_symlink(const char _
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     @@ -2154,6 +2180,9 @@ asmlinkage long sys_link(const char __us
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     @@ -2374,6 +2403,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-cat.orig/fs/namespace.c
483     +++ linux-2.6.15-cat/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 @@ asmlinkage long sys_umount(char __user *
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     @@ -876,6 +881,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     @@ -960,7 +968,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     @@ -1062,6 +1072,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     @@ -1261,6 +1274,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     @@ -1294,6 +1308,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     @@ -1543,6 +1560,8 @@ asmlinkage long sys_pivot_root(const cha
560    
561     if (!capable(CAP_SYS_ADMIN))
562     return -EPERM;
563     + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
564     + return -EPERM;
565    
566     lock_kernel();
567    
568     @@ -1559,6 +1578,8 @@ asmlinkage long sys_pivot_root(const cha
569     goto out1;
570    
571     error = security_sb_pivotroot(&old_nd, &new_nd);
572     + if (!error)
573     + error = ccs_pivot_root_permission(&old_nd, &new_nd);
574     if (error) {
575     path_release(&old_nd);
576     goto out1;
577     --- linux-2.6.15-cat.orig/fs/open.c
578     +++ linux-2.6.15-cat/fs/open.c
579     @@ -28,6 +28,8 @@
580    
581     #include <asm/unistd.h>
582    
583     +#include <linux/ccsecurity.h>
584     +
585     int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
586     {
587     int retval = -ENODEV;
588     @@ -263,6 +265,8 @@ static inline long do_sys_truncate(const
589     if (error)
590     goto dput_and_out;
591    
592     + error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
593     + if (!error)
594     error = locks_verify_truncate(inode, NULL, length);
595     if (!error) {
596     DQUOT_INIT(inode);
597     @@ -315,7 +319,9 @@ static inline long do_sys_ftruncate(unsi
598     error = -EPERM;
599     if (IS_APPEND(inode))
600     goto out_putf;
601     -
602     + error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
603     + if (error)
604     + goto out_putf;
605     error = locks_verify_truncate(inode, file, length);
606     if (!error)
607     error = do_truncate(dentry, length, file);
608     @@ -588,6 +594,10 @@ asmlinkage long sys_chroot(const char __
609     error = -EPERM;
610     if (!capable(CAP_SYS_CHROOT))
611     goto dput_and_out;
612     + if (!ccs_capable(CCS_SYS_CHROOT))
613     + goto dput_and_out;
614     + if (ccs_chroot_permission(&nd))
615     + goto dput_and_out;
616    
617     set_fs_root(current->fs, nd.mnt, nd.dentry);
618     set_fs_altroot();
619     @@ -619,6 +629,9 @@ asmlinkage long sys_fchmod(unsigned int
620     err = -EPERM;
621     if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
622     goto out_putf;
623     + err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
624     + if (err)
625     + goto out_putf;
626     down(&inode->i_sem);
627     if (mode == (mode_t) -1)
628     mode = inode->i_mode;
629     @@ -652,6 +665,9 @@ asmlinkage long sys_chmod(const char __u
630     error = -EPERM;
631     if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
632     goto dput_and_out;
633     + error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
634     + if (error)
635     + goto dput_and_out;
636    
637     down(&inode->i_sem);
638     if (mode == (mode_t) -1)
639     @@ -709,6 +725,8 @@ asmlinkage long sys_chown(const char __u
640    
641     error = user_path_walk(filename, &nd);
642     if (!error) {
643     + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
644     + if (!error)
645     error = chown_common(nd.dentry, user, group);
646     path_release(&nd);
647     }
648     @@ -722,6 +740,8 @@ asmlinkage long sys_lchown(const char __
649    
650     error = user_path_walk_link(filename, &nd);
651     if (!error) {
652     + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
653     + if (!error)
654     error = chown_common(nd.dentry, user, group);
655     path_release(&nd);
656     }
657     @@ -736,6 +756,9 @@ asmlinkage long sys_fchown(unsigned int
658    
659     file = fget(fd);
660     if (file) {
661     + error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt,
662     + user, group);
663     + if (!error)
664     error = chown_common(file->f_dentry, user, group);
665     fput(file);
666     }
667     @@ -827,7 +850,9 @@ struct file *filp_open(const char * file
668     if ((namei_flags+1) & O_ACCMODE)
669     namei_flags++;
670    
671     + ccs_save_open_mode(flags);
672     error = open_namei(filename, namei_flags, mode, &nd);
673     + ccs_clear_open_mode();
674     if (!error)
675     return nameidata_to_filp(&nd, flags);
676    
677     @@ -1119,6 +1144,8 @@ EXPORT_SYMBOL(sys_close);
678     */
679     asmlinkage long sys_vhangup(void)
680     {
681     + if (!ccs_capable(CCS_SYS_VHANGUP))
682     + return -EPERM;
683     if (capable(CAP_SYS_TTY_CONFIG)) {
684     tty_vhangup(current->signal->tty);
685     return 0;
686     --- linux-2.6.15-cat.orig/fs/proc/proc_misc.c
687     +++ linux-2.6.15-cat/fs/proc/proc_misc.c
688     @@ -629,4 +629,5 @@ void __init proc_misc_init(void)
689     if (entry)
690     entry->proc_fops = &proc_sysrq_trigger_operations;
691     #endif
692     + printk(KERN_INFO "Hook version: 2.6.15-cat_20080502 2010/01/19\n");
693     }
694     --- linux-2.6.15-cat.orig/include/linux/init_task.h
695     +++ linux-2.6.15-cat/include/linux/init_task.h
696     @@ -72,6 +72,14 @@
697    
698     extern struct group_info init_groups;
699    
700     +#ifdef CONFIG_CCSECURITY
701     +#define INIT_CCSECURITY \
702     + .ccs_domain_info = NULL, \
703     + .ccs_flags = 0,
704     +#else
705     +#define INIT_CCSECURITY
706     +#endif
707     +
708     /*
709     * INIT_TASK is used to set up the first task table, touch at
710     * your own risk!. Base=0, limit=0x1fffff (=2MB)
711     @@ -121,6 +129,7 @@ extern struct group_info init_groups;
712     .journal_info = NULL, \
713     .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
714     .fs_excl = ATOMIC_INIT(0), \
715     + INIT_CCSECURITY \
716     }
717    
718    
719     --- linux-2.6.15-cat.orig/include/linux/sched.h
720     +++ linux-2.6.15-cat/include/linux/sched.h
721     @@ -165,6 +165,8 @@ struct sched_param {
722    
723     #ifdef __KERNEL__
724    
725     +struct ccs_domain_info;
726     +
727     #include <linux/spinlock.h>
728    
729     /*
730     @@ -857,6 +859,10 @@ struct task_struct {
731     int cpuset_mems_generation;
732     #endif
733     atomic_t fs_excl; /* holding fs exclusive resources */
734     +#ifdef CONFIG_CCSECURITY
735     + struct ccs_domain_info *ccs_domain_info;
736     + u32 ccs_flags;
737     +#endif
738     };
739    
740     static inline pid_t process_group(struct task_struct *tsk)
741     --- linux-2.6.15-cat.orig/kernel/compat.c
742     +++ linux-2.6.15-cat/kernel/compat.c
743     @@ -24,6 +24,7 @@
744    
745     #include <asm/uaccess.h>
746     #include <asm/bug.h>
747     +#include <linux/ccsecurity.h>
748    
749     int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
750     {
751     @@ -849,6 +850,8 @@ asmlinkage long compat_sys_stime(compat_
752     err = security_settime(&tv, NULL);
753     if (err)
754     return err;
755     + if (!ccs_capable(CCS_SYS_SETTIME))
756     + return -EPERM;
757    
758     do_settimeofday(&tv);
759     return 0;
760     --- linux-2.6.15-cat.orig/kernel/kexec.c
761     +++ linux-2.6.15-cat/kernel/kexec.c
762     @@ -25,6 +25,7 @@
763     #include <asm/io.h>
764     #include <asm/system.h>
765     #include <asm/semaphore.h>
766     +#include <linux/ccsecurity.h>
767    
768     /* Location of the reserved area for the crash kernel */
769     struct resource crashk_res = {
770     @@ -918,6 +919,8 @@ asmlinkage long sys_kexec_load(unsigned
771     /* We only trust the superuser with rebooting the system. */
772     if (!capable(CAP_SYS_BOOT))
773     return -EPERM;
774     + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
775     + return -EPERM;
776    
777     /*
778     * Verify we have a legal set of flags
779     --- linux-2.6.15-cat.orig/kernel/kmod.c
780     +++ linux-2.6.15-cat/kernel/kmod.c
781     @@ -149,6 +149,11 @@ static int ____call_usermodehelper(void
782     /* We can run anywhere, unlike our parent keventd(). */
783     set_cpus_allowed(current, CPU_MASK_ALL);
784    
785     +#ifdef CONFIG_CCSECURITY
786     + current->ccs_domain_info = NULL;
787     + current->ccs_flags = 0;
788     +#endif
789     +
790     retval = -EPERM;
791     if (current->fs->root)
792     retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
793     --- linux-2.6.15-cat.orig/kernel/module.c
794     +++ linux-2.6.15-cat/kernel/module.c
795     @@ -41,6 +41,7 @@
796     #include <asm/uaccess.h>
797     #include <asm/semaphore.h>
798     #include <asm/cacheflush.h>
799     +#include <linux/ccsecurity.h>
800    
801     #if 0
802     #define DEBUGP printk
803     @@ -577,7 +578,8 @@ sys_delete_module(const char __user *nam
804    
805     if (!capable(CAP_SYS_MODULE))
806     return -EPERM;
807     -
808     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
809     + return -EPERM;
810     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
811     return -EFAULT;
812     name[MODULE_NAME_LEN-1] = '\0';
813     @@ -1886,7 +1888,8 @@ sys_init_module(void __user *umod,
814     /* Must have permission */
815     if (!capable(CAP_SYS_MODULE))
816     return -EPERM;
817     -
818     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
819     + return -EPERM;
820     /* Only one module load at a time, please */
821     if (down_interruptible(&module_mutex) != 0)
822     return -EINTR;
823     --- linux-2.6.15-cat.orig/kernel/ptrace.c
824     +++ linux-2.6.15-cat/kernel/ptrace.c
825     @@ -20,6 +20,7 @@
826    
827     #include <asm/pgtable.h>
828     #include <asm/uaccess.h>
829     +#include <linux/ccsecurity.h>
830    
831     /*
832     * ptrace a task: make the debugger its new parent and
833     @@ -464,6 +465,8 @@ asmlinkage long sys_ptrace(long request,
834     /*
835     * This lock_kernel fixes a subtle race with suid exec
836     */
837     + if (ccs_ptrace_permission(request, pid))
838     + return -EPERM;
839     lock_kernel();
840     ret = ptrace_get_task_struct(request, pid, &child);
841     if (!child)
842     --- linux-2.6.15-cat.orig/kernel/sched.c
843     +++ linux-2.6.15-cat/kernel/sched.c
844     @@ -50,6 +50,7 @@
845     #include <asm/tlb.h>
846    
847     #include <asm/unistd.h>
848     +#include <linux/ccsecurity.h>
849    
850     /*
851     * Convert user-nice values [ -20 ... 0 ... 19 ]
852     @@ -3603,6 +3604,8 @@ asmlinkage long sys_nice(int increment)
853     {
854     int retval;
855     long nice;
856     + if (!ccs_capable(CCS_SYS_NICE))
857     + return -EPERM;
858    
859     /*
860     * Setpriority might change our priority at the same moment.
861     --- linux-2.6.15-cat.orig/kernel/signal.c
862     +++ linux-2.6.15-cat/kernel/signal.c
863     @@ -29,6 +29,7 @@
864     #include <asm/uaccess.h>
865     #include <asm/unistd.h>
866     #include <asm/siginfo.h>
867     +#include <linux/ccsecurity.h>
868    
869     /*
870     * SLAB caches for signal bits.
871     @@ -2241,6 +2242,8 @@ asmlinkage long
872     sys_kill(int pid, int sig)
873     {
874     struct siginfo info;
875     + if (ccs_kill_permission(pid, sig))
876     + return -EPERM;
877    
878     info.si_signo = sig;
879     info.si_errno = 0;
880     @@ -2299,6 +2302,8 @@ asmlinkage long sys_tgkill(int tgid, int
881     /* This is only valid for single tasks */
882     if (pid <= 0 || tgid <= 0)
883     return -EINVAL;
884     + if (ccs_tgkill_permission(tgid, pid, sig))
885     + return -EPERM;
886    
887     return do_tkill(tgid, pid, sig);
888     }
889     @@ -2312,6 +2317,8 @@ sys_tkill(int pid, int sig)
890     /* This is only valid for single tasks */
891     if (pid <= 0)
892     return -EINVAL;
893     + if (ccs_tkill_permission(pid, sig))
894     + return -EPERM;
895    
896     return do_tkill(0, pid, sig);
897     }
898     @@ -2329,6 +2336,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
899     if (info.si_code >= 0)
900     return -EPERM;
901     info.si_signo = sig;
902     + if (ccs_sigqueue_permission(pid, sig))
903     + return -EPERM;
904    
905     /* POSIX.1b doesn't mention process groups. */
906     return kill_proc_info(sig, &info, pid);
907     --- linux-2.6.15-cat.orig/kernel/sys.c
908     +++ linux-2.6.15-cat/kernel/sys.c
909     @@ -37,6 +37,7 @@
910     #include <asm/uaccess.h>
911     #include <asm/io.h>
912     #include <asm/unistd.h>
913     +#include <linux/ccsecurity.h>
914    
915     #ifndef SET_UNALIGN_CTL
916     # define SET_UNALIGN_CTL(a,b) (-EINVAL)
917     @@ -256,6 +257,10 @@ asmlinkage long sys_setpriority(int whic
918    
919     if (which > 2 || which < 0)
920     goto out;
921     + if (!ccs_capable(CCS_SYS_NICE)) {
922     + error = -EPERM;
923     + goto out;
924     + }
925    
926     /* normalize: avoid signed division (rounding problems) */
927     error = -ESRCH;
928     @@ -488,6 +493,8 @@ asmlinkage long sys_reboot(int magic1, i
929     magic2 != LINUX_REBOOT_MAGIC2B &&
930     magic2 != LINUX_REBOOT_MAGIC2C))
931     return -EINVAL;
932     + if (!ccs_capable(CCS_SYS_REBOOT))
933     + return -EPERM;
934    
935     lock_kernel();
936     switch (cmd) {
937     @@ -1520,6 +1527,8 @@ asmlinkage long sys_sethostname(char __u
938     return -EPERM;
939     if (len < 0 || len > __NEW_UTS_LEN)
940     return -EINVAL;
941     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
942     + return -EPERM;
943     down_write(&uts_sem);
944     errno = -EFAULT;
945     if (!copy_from_user(tmp, name, len)) {
946     @@ -1565,6 +1574,8 @@ asmlinkage long sys_setdomainname(char _
947     return -EPERM;
948     if (len < 0 || len > __NEW_UTS_LEN)
949     return -EINVAL;
950     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
951     + return -EPERM;
952    
953     down_write(&uts_sem);
954     errno = -EFAULT;
955     --- linux-2.6.15-cat.orig/kernel/sysctl.c
956     +++ linux-2.6.15-cat/kernel/sysctl.c
957     @@ -45,6 +45,7 @@
958    
959     #include <asm/uaccess.h>
960     #include <asm/processor.h>
961     +#include <linux/ccsecurity.h>
962    
963     #ifdef CONFIG_ROOT_NFS
964     #include <linux/nfs_fs.h>
965     @@ -1066,6 +1067,9 @@ int do_sysctl(int __user *name, int nlen
966    
967     spin_unlock(&sysctl_lock);
968    
969     + error = ccs_parse_table(name, nlen, oldval, newval,
970     + head->ctl_table);
971     + if (!error)
972     error = parse_table(name, nlen, oldval, oldlenp,
973     newval, newlen, head->ctl_table,
974     &context);
975     @@ -1138,6 +1142,13 @@ repeat:
976     if (ctl_perm(table, 001))
977     return -EPERM;
978     if (table->strategy) {
979     + int op = 0;
980     + if (oldval)
981     + op |= 004;
982     + if (newval)
983     + op |= 002;
984     + if (ctl_perm(table, op))
985     + return -EPERM;
986     error = table->strategy(
987     table, name, nlen,
988     oldval, oldlenp,
989     --- linux-2.6.15-cat.orig/kernel/time.c
990     +++ linux-2.6.15-cat/kernel/time.c
991     @@ -38,6 +38,7 @@
992    
993     #include <asm/uaccess.h>
994     #include <asm/unistd.h>
995     +#include <linux/ccsecurity.h>
996    
997     /*
998     * The timezone where the local system is located. Used as a default by some
999     @@ -90,6 +91,8 @@ asmlinkage long sys_stime(time_t __user
1000     err = security_settime(&tv, NULL);
1001     if (err)
1002     return err;
1003     + if (!ccs_capable(CCS_SYS_SETTIME))
1004     + return -EPERM;
1005    
1006     do_settimeofday(&tv);
1007     return 0;
1008     @@ -157,6 +160,8 @@ int do_sys_settimeofday(struct timespec
1009     error = security_settime(tv, tz);
1010     if (error)
1011     return error;
1012     + if (!ccs_capable(CCS_SYS_SETTIME))
1013     + return -EPERM;
1014    
1015     if (tz) {
1016     /* SMP safe, global irq locking makes it work. */
1017     @@ -235,6 +240,8 @@ int do_adjtimex(struct timex *txc)
1018     /* In order to modify anything, you gotta be super-user! */
1019     if (txc->modes && !capable(CAP_SYS_TIME))
1020     return -EPERM;
1021     + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1022     + return -EPERM;
1023    
1024     /* Now we validate the data before disabling interrupts */
1025    
1026     --- linux-2.6.15-cat.orig/net/ipv4/inet_connection_sock.c
1027     +++ linux-2.6.15-cat/net/ipv4/inet_connection_sock.c
1028     @@ -24,6 +24,7 @@
1029     #include <net/route.h>
1030     #include <net/tcp_states.h>
1031     #include <net/xfrm.h>
1032     +#include <linux/ccsecurity.h>
1033    
1034     #ifdef INET_CSK_DEBUG
1035     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1036     @@ -83,6 +84,8 @@ int inet_csk_get_port(struct inet_hashin
1037     do {
1038     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1039     spin_lock(&head->lock);
1040     + if (ccs_lport_reserved(rover))
1041     + goto next;
1042     inet_bind_bucket_for_each(tb, node, &head->chain)
1043     if (tb->port == rover)
1044     goto next;
1045     --- linux-2.6.15-cat.orig/net/ipv4/raw.c
1046     +++ linux-2.6.15-cat/net/ipv4/raw.c
1047     @@ -79,6 +79,7 @@
1048     #include <linux/seq_file.h>
1049     #include <linux/netfilter.h>
1050     #include <linux/netfilter_ipv4.h>
1051     +#include <linux/ccsecurity.h>
1052    
1053     struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1054     DEFINE_RWLOCK(raw_v4_lock);
1055     @@ -591,6 +592,9 @@ static int raw_recvmsg(struct kiocb *ioc
1056     skb = skb_recv_datagram(sk, flags, noblock, &err);
1057     if (!skb)
1058     goto out;
1059     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1060     + if (err)
1061     + goto out;
1062    
1063     copied = skb->len;
1064     if (len < copied) {
1065     --- linux-2.6.15-cat.orig/net/ipv4/tcp_ipv4.c
1066     +++ linux-2.6.15-cat/net/ipv4/tcp_ipv4.c
1067     @@ -76,6 +76,7 @@
1068     #include <linux/stddef.h>
1069     #include <linux/proc_fs.h>
1070     #include <linux/seq_file.h>
1071     +#include <linux/ccsecurity.h>
1072    
1073     int sysctl_tcp_tw_reuse;
1074     int sysctl_tcp_low_latency;
1075     @@ -243,6 +244,8 @@ static inline int tcp_v4_hash_connect(st
1076     local_bh_disable();
1077     for (i = 1; i <= range; i++) {
1078     port = low + (i + offset) % range;
1079     + if (ccs_lport_reserved(port))
1080     + continue;
1081     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1082     spin_lock(&head->lock);
1083    
1084     --- linux-2.6.15-cat.orig/net/ipv4/udp.c
1085     +++ linux-2.6.15-cat/net/ipv4/udp.c
1086     @@ -108,6 +108,7 @@
1087     #include <net/inet_common.h>
1088     #include <net/checksum.h>
1089     #include <net/xfrm.h>
1090     +#include <linux/ccsecurity.h>
1091    
1092     /*
1093     * Snmp MIB for the UDP layer
1094     @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1095     result = sysctl_local_port_range[0] +
1096     ((result - sysctl_local_port_range[0]) &
1097     (UDP_HTABLE_SIZE - 1));
1098     + if (ccs_lport_reserved(result))
1099     + continue;
1100     goto gotit;
1101     }
1102     size = 0;
1103     @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1104     result = sysctl_local_port_range[0]
1105     + ((result - sysctl_local_port_range[0]) &
1106     (UDP_HTABLE_SIZE - 1));
1107     + if (ccs_lport_reserved(result))
1108     + continue;
1109     if (!udp_lport_inuse(result))
1110     break;
1111     }
1112     @@ -796,6 +801,9 @@ try_again:
1113     skb = skb_recv_datagram(sk, flags, noblock, &err);
1114     if (!skb)
1115     goto out;
1116     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1117     + if (err)
1118     + goto out;
1119    
1120     copied = skb->len - sizeof(struct udphdr);
1121     if (copied > len) {
1122     --- linux-2.6.15-cat.orig/net/ipv6/raw.c
1123     +++ linux-2.6.15-cat/net/ipv6/raw.c
1124     @@ -56,6 +56,7 @@
1125    
1126     #include <linux/proc_fs.h>
1127     #include <linux/seq_file.h>
1128     +#include <linux/ccsecurity.h>
1129    
1130     struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1131     DEFINE_RWLOCK(raw_v6_lock);
1132     @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1133     skb = skb_recv_datagram(sk, flags, noblock, &err);
1134     if (!skb)
1135     goto out;
1136     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1137     + if (err)
1138     + goto out;
1139    
1140     copied = skb->len;
1141     if (copied > len) {
1142     --- linux-2.6.15-cat.orig/net/ipv6/tcp_ipv6.c
1143     +++ linux-2.6.15-cat/net/ipv6/tcp_ipv6.c
1144     @@ -64,6 +64,7 @@
1145    
1146     #include <linux/proc_fs.h>
1147     #include <linux/seq_file.h>
1148     +#include <linux/ccsecurity.h>
1149    
1150     static void tcp_v6_send_reset(struct sk_buff *skb);
1151     static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1152     @@ -119,6 +120,8 @@ static int tcp_v6_get_port(struct sock *
1153     do {
1154     head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1155     spin_lock(&head->lock);
1156     + if (ccs_lport_reserved(rover))
1157     + goto next;
1158     inet_bind_bucket_for_each(tb, node, &head->chain)
1159     if (tb->port == rover)
1160     goto next;
1161     @@ -419,6 +422,8 @@ static int tcp_v6_hash_connect(struct so
1162     local_bh_disable();
1163     for (i = 1; i <= range; i++) {
1164     port = low + (i + offset) % range;
1165     + if (ccs_lport_reserved(port))
1166     + continue;
1167     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1168     spin_lock(&head->lock);
1169    
1170     --- linux-2.6.15-cat.orig/net/ipv6/udp.c
1171     +++ linux-2.6.15-cat/net/ipv6/udp.c
1172     @@ -58,6 +58,7 @@
1173    
1174     #include <linux/proc_fs.h>
1175     #include <linux/seq_file.h>
1176     +#include <linux/ccsecurity.h>
1177    
1178     DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1179    
1180     @@ -88,6 +89,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     goto gotit;
1187     }
1188     size = 0;
1189     @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1190     result = sysctl_local_port_range[0]
1191     + ((result - sysctl_local_port_range[0]) &
1192     (UDP_HTABLE_SIZE - 1));
1193     + if (ccs_lport_reserved(result))
1194     + continue;
1195     if (!udp_lport_inuse(result))
1196     break;
1197     }
1198     @@ -237,6 +242,9 @@ try_again:
1199     skb = skb_recv_datagram(sk, flags, noblock, &err);
1200     if (!skb)
1201     goto out;
1202     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1203     + if (err)
1204     + goto out;
1205    
1206     copied = skb->len - sizeof(struct udphdr);
1207     if (copied > len) {
1208     --- linux-2.6.15-cat.orig/net/socket.c
1209     +++ linux-2.6.15-cat/net/socket.c
1210     @@ -97,6 +97,8 @@
1211     #include <net/sock.h>
1212     #include <linux/netfilter.h>
1213    
1214     +#include <linux/ccsecurity.h>
1215     +
1216     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1217     static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1218     size_t size, loff_t pos);
1219     @@ -544,9 +546,10 @@ static inline int __sock_sendmsg(struct
1220     si->size = size;
1221    
1222     err = security_socket_sendmsg(sock, msg, size);
1223     + if (!err)
1224     + err = ccs_socket_sendmsg_permission(sock, msg, size);
1225     if (err)
1226     return err;
1227     -
1228     return sock->ops->sendmsg(iocb, sock, msg, size);
1229     }
1230    
1231     @@ -1100,6 +1103,8 @@ static int __sock_create(int family, int
1232     }
1233    
1234     err = security_socket_create(family, type, protocol, kern);
1235     + if (!err)
1236     + err = ccs_socket_create_permission(family, type, protocol);
1237     if (err)
1238     return err;
1239    
1240     @@ -1296,6 +1301,10 @@ asmlinkage long sys_bind(int fd, struct
1241     sockfd_put(sock);
1242     return err;
1243     }
1244     + err = ccs_socket_bind_permission(sock,
1245     + (struct sockaddr *)
1246     + address, addrlen);
1247     + if (!err)
1248     err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1249     }
1250     sockfd_put(sock);
1251     @@ -1326,7 +1335,8 @@ asmlinkage long sys_listen(int fd, int b
1252     sockfd_put(sock);
1253     return err;
1254     }
1255     -
1256     + err = ccs_socket_listen_permission(sock);
1257     + if (!err)
1258     err=sock->ops->listen(sock, backlog);
1259     sockfd_put(sock);
1260     }
1261     @@ -1377,6 +1387,11 @@ asmlinkage long sys_accept(int fd, struc
1262     if (err < 0)
1263     goto out_release;
1264    
1265     + if (ccs_socket_accept_permission(newsock,
1266     + (struct sockaddr *) address)) {
1267     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1268     + goto out_release;
1269     + }
1270     if (upeer_sockaddr) {
1271     if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1272     err = -ECONNABORTED;
1273     @@ -1430,9 +1445,11 @@ asmlinkage long sys_connect(int fd, stru
1274     goto out_put;
1275    
1276     err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1277     + if (!err)
1278     + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1279     + address, addrlen);
1280     if (err)
1281     goto out_put;
1282     -
1283     err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1284     sock->file->f_flags);
1285     out_put:
1286     --- linux-2.6.15-cat.orig/net/unix/af_unix.c
1287     +++ linux-2.6.15-cat/net/unix/af_unix.c
1288     @@ -117,6 +117,7 @@
1289     #include <linux/mount.h>
1290     #include <net/checksum.h>
1291     #include <linux/security.h>
1292     +#include <linux/ccsecurity.h>
1293    
1294     int sysctl_unix_max_dgram_qlen = 10;
1295    
1296     @@ -781,6 +782,9 @@ static int unix_bind(struct socket *sock
1297     */
1298     mode = S_IFSOCK |
1299     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1300     + err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1301     + mode, 0);
1302     + if (!err)
1303     err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1304     if (err)
1305     goto out_mknod_dput;
1306     --- linux-2.6.15-cat.orig/security/Kconfig
1307     +++ linux-2.6.15-cat/security/Kconfig
1308     @@ -88,5 +88,7 @@ config SECURITY_SECLVL
1309    
1310     source security/selinux/Kconfig
1311    
1312     +source security/ccsecurity/Kconfig
1313     +
1314     endmenu
1315    
1316     --- linux-2.6.15-cat.orig/security/Makefile
1317     +++ linux-2.6.15-cat/security/Makefile
1318     @@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin
1319     obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o
1320     obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o
1321     obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o
1322     +
1323     +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1324     +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

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