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

Subversion リポジトリの参照

Diff of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.diff

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.diff revision 2855 by kumaneko, Thu Aug 6 03:24:41 2009 UTC trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.diff revision 3150 by kumaneko, Sat Nov 7 01:15:23 2009 UTC
# Line 12  Source code for this patch is "apt-get i Line 12  Source code for this patch is "apt-get i
12   arch/sparc/kernel/ptrace.c      |    5 +++++   arch/sparc/kernel/ptrace.c      |    5 +++++
13   arch/sparc64/kernel/ptrace.c    |    5 +++++   arch/sparc64/kernel/ptrace.c    |    5 +++++
14   arch/x86_64/ia32/ptrace32.c     |    3 +++   arch/x86_64/ia32/ptrace32.c     |    3 +++
  fs/Kconfig                      |    2 ++  
  fs/Makefile                     |    2 ++  
  fs/attr.c                       |    5 +++++  
15   fs/compat.c                     |    9 ++++++++-   fs/compat.c                     |    9 ++++++++-
16   fs/exec.c                       |   12 +++++++++++-   fs/exec.c                       |   12 +++++++++++-
17   fs/fcntl.c                      |    5 +++++   fs/fcntl.c                      |    4 ++++
18   fs/ioctl.c                      |    5 +++++   fs/ioctl.c                      |    5 +++++
19   fs/namei.c                      |   38 ++++++++++++++++++++++++++++++++++++++   fs/namei.c                      |   32 ++++++++++++++++++++++++++++++++
20   fs/namespace.c                  |   28 +++++++++++++++++++++++++++-   fs/namespace.c                  |   23 ++++++++++++++++++++++-
21   fs/open.c                       |   14 ++++++++++++++   fs/open.c                       |   29 +++++++++++++++++++++++++++++
  fs/proc/Makefile                |    3 +++  
22   fs/proc/proc_misc.c             |    1 +   fs/proc/proc_misc.c             |    1 +
23   include/linux/init_task.h       |    2 ++   include/linux/init_task.h       |    9 +++++++++
24   include/linux/sched.h           |    4 ++++   include/linux/sched.h           |    6 ++++++
25   kernel/compat.c                 |    3 +++   kernel/compat.c                 |    3 +++
26   kernel/kexec.c                  |    3 +++   kernel/kexec.c                  |    3 +++
27   kernel/kmod.c                   |    3 +++   kernel/kmod.c                   |    5 +++++
28   kernel/module.c                 |    7 +++++--   kernel/module.c                 |    7 +++++--
29   kernel/ptrace.c                 |    3 +++   kernel/ptrace.c                 |    3 +++
30   kernel/sched.c                  |    3 +++   kernel/sched.c                  |    3 +++
31   kernel/signal.c                 |    7 +++++++   kernel/signal.c                 |    9 +++++++++
32   kernel/sys.c                    |   11 +++++++++++   kernel/sys.c                    |   11 +++++++++++
33   kernel/sysctl.c                 |   11 +++++++++++   kernel/sysctl.c                 |   11 +++++++++++
34   kernel/time.c                   |    7 +++++++   kernel/time.c                   |    7 +++++++
35   net/ipv4/inet_connection_sock.c |    3 +++   net/ipv4/inet_connection_sock.c |    3 +++
36   net/ipv4/inet_hashtables.c      |    3 +++   net/ipv4/inet_hashtables.c      |    3 +++
37   net/ipv4/raw.c                  |    4 ++++   net/ipv4/raw.c                  |    4 ++++
38   net/ipv4/udp.c                  |   11 ++++++++++-   net/ipv4/udp.c                  |   10 +++++++++-
39   net/ipv6/inet6_hashtables.c     |    5 ++++-   net/ipv6/inet6_hashtables.c     |    5 ++++-
40   net/ipv6/raw.c                  |    4 ++++   net/ipv6/raw.c                  |    4 ++++
41   net/ipv6/udp.c                  |    9 +++++++++   net/ipv6/udp.c                  |    8 ++++++++
42   net/socket.c                    |   26 ++++++++++++++++++++++++--   net/socket.c                    |   23 +++++++++++++++++++++--
43   net/unix/af_unix.c              |    4 ++++   net/unix/af_unix.c              |    4 ++++
44   43 files changed, 282 insertions(+), 9 deletions(-)   security/Kconfig                |    2 ++
45     security/Makefile               |    3 +++
46     41 files changed, 286 insertions(+), 9 deletions(-)
47    
48  --- linux-2.6.18-24etch2.orig/arch/alpha/kernel/ptrace.c  --- linux-2.6.18-26etch1.orig/arch/alpha/kernel/ptrace.c
49  +++ linux-2.6.18-24etch2/arch/alpha/kernel/ptrace.c  +++ linux-2.6.18-26etch1/arch/alpha/kernel/ptrace.c
50  @@ -20,6 +20,7 @@  @@ -20,6 +20,7 @@
51   #include <asm/pgtable.h>   #include <asm/pgtable.h>
52   #include <asm/system.h>   #include <asm/system.h>
53   #include <asm/fpu.h>   #include <asm/fpu.h>
54  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
55    
56   #include "proto.h"   #include "proto.h"
57    
# Line 61  Source code for this patch is "apt-get i Line 59  Source code for this patch is "apt-get i
59          unsigned long tmp;          unsigned long tmp;
60          size_t copied;          size_t copied;
61          long ret;          long ret;
62  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
63  +               return -EPERM;  +               return -EPERM;
64    
65          lock_kernel();          lock_kernel();
66          DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",          DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
67  --- linux-2.6.18-24etch2.orig/arch/ia64/ia32/sys_ia32.c  --- linux-2.6.18-26etch1.orig/arch/ia64/ia32/sys_ia32.c
68  +++ linux-2.6.18-24etch2/arch/ia64/ia32/sys_ia32.c  +++ linux-2.6.18-26etch1/arch/ia64/ia32/sys_ia32.c
69  @@ -56,6 +56,7 @@  @@ -56,6 +56,7 @@
70   #include <asm/types.h>   #include <asm/types.h>
71   #include <asm/uaccess.h>   #include <asm/uaccess.h>
72   #include <asm/unistd.h>   #include <asm/unistd.h>
73  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
74    
75   #include "ia32priv.h"   #include "ia32priv.h"
76    
# Line 80  Source code for this patch is "apt-get i Line 78  Source code for this patch is "apt-get i
78          struct task_struct *child;          struct task_struct *child;
79          unsigned int value, tmp;          unsigned int value, tmp;
80          long i, ret;          long i, ret;
81  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
82  +               return -EPERM;  +               return -EPERM;
83    
84          lock_kernel();          lock_kernel();
85          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
86  --- linux-2.6.18-24etch2.orig/arch/ia64/kernel/ptrace.c  --- linux-2.6.18-26etch1.orig/arch/ia64/kernel/ptrace.c
87  +++ linux-2.6.18-24etch2/arch/ia64/kernel/ptrace.c  +++ linux-2.6.18-26etch1/arch/ia64/kernel/ptrace.c
88  @@ -28,6 +28,7 @@  @@ -28,6 +28,7 @@
89   #ifdef CONFIG_PERFMON   #ifdef CONFIG_PERFMON
90   #include <asm/perfmon.h>   #include <asm/perfmon.h>
91   #endif   #endif
92  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
93    
94   #include "entry.h"   #include "entry.h"
95    
# Line 99  Source code for this patch is "apt-get i Line 97  Source code for this patch is "apt-get i
97          struct task_struct *child;          struct task_struct *child;
98          struct switch_stack *sw;          struct switch_stack *sw;
99          long ret;          long ret;
100  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
101  +               return -EPERM;  +               return -EPERM;
102    
103          lock_kernel();          lock_kernel();
104          ret = -EPERM;          ret = -EPERM;
105  --- linux-2.6.18-24etch2.orig/arch/m32r/kernel/ptrace.c  --- linux-2.6.18-26etch1.orig/arch/m32r/kernel/ptrace.c
106  +++ linux-2.6.18-24etch2/arch/m32r/kernel/ptrace.c  +++ linux-2.6.18-26etch1/arch/m32r/kernel/ptrace.c
107  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
108   #include <asm/system.h>   #include <asm/system.h>
109   #include <asm/processor.h>   #include <asm/processor.h>
110   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
111  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
112    
113   /*   /*
114    * This routine will get a word off of the process kernel stack.    * This routine will get a word off of the process kernel stack.
# Line 118  Source code for this patch is "apt-get i Line 116  Source code for this patch is "apt-get i
116   {   {
117          struct task_struct *child;          struct task_struct *child;
118          int ret;          int ret;
119  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
120  +               return -EPERM;  +               return -EPERM;
121    
122          lock_kernel();          lock_kernel();
123          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
124  --- linux-2.6.18-24etch2.orig/arch/mips/kernel/ptrace32.c  --- linux-2.6.18-26etch1.orig/arch/mips/kernel/ptrace32.c
125  +++ linux-2.6.18-24etch2/arch/mips/kernel/ptrace32.c  +++ linux-2.6.18-26etch1/arch/mips/kernel/ptrace32.c
126  @@ -35,6 +35,7 @@  @@ -35,6 +35,7 @@
127   #include <asm/system.h>   #include <asm/system.h>
128   #include <asm/uaccess.h>   #include <asm/uaccess.h>
129   #include <asm/bootinfo.h>   #include <asm/bootinfo.h>
130  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
131    
132   int ptrace_getregs (struct task_struct *child, __s64 __user *data);   int ptrace_getregs (struct task_struct *child, __s64 __user *data);
133   int ptrace_setregs (struct task_struct *child, __s64 __user *data);   int ptrace_setregs (struct task_struct *child, __s64 __user *data);
# Line 137  Source code for this patch is "apt-get i Line 135  Source code for this patch is "apt-get i
135   {   {
136          struct task_struct *child;          struct task_struct *child;
137          int ret;          int ret;
138  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
139  +               return -EPERM;  +               return -EPERM;
140    
141   #if 0   #if 0
142          printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",          printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
143  --- linux-2.6.18-24etch2.orig/arch/powerpc/kernel/ptrace32.c  --- linux-2.6.18-26etch1.orig/arch/powerpc/kernel/ptrace32.c
144  +++ linux-2.6.18-24etch2/arch/powerpc/kernel/ptrace32.c  +++ linux-2.6.18-26etch1/arch/powerpc/kernel/ptrace32.c
145  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
146   #include <asm/page.h>   #include <asm/page.h>
147   #include <asm/pgtable.h>   #include <asm/pgtable.h>
148   #include <asm/system.h>   #include <asm/system.h>
149  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
150    
151   #include "ptrace-common.h"   #include "ptrace-common.h"
152    
# Line 156  Source code for this patch is "apt-get i Line 154  Source code for this patch is "apt-get i
154   {   {
155          struct task_struct *child;          struct task_struct *child;
156          int ret;          int ret;
157  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
158  +               return -EPERM;  +               return -EPERM;
159    
160          lock_kernel();          lock_kernel();
161          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
162  --- linux-2.6.18-24etch2.orig/arch/s390/kernel/ptrace.c  --- linux-2.6.18-26etch1.orig/arch/s390/kernel/ptrace.c
163  +++ linux-2.6.18-24etch2/arch/s390/kernel/ptrace.c  +++ linux-2.6.18-26etch1/arch/s390/kernel/ptrace.c
164  @@ -41,6 +41,7 @@  @@ -41,6 +41,7 @@
165   #include <asm/system.h>   #include <asm/system.h>
166   #include <asm/uaccess.h>   #include <asm/uaccess.h>
167   #include <asm/unistd.h>   #include <asm/unistd.h>
168  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
169    
170   #ifdef CONFIG_COMPAT   #ifdef CONFIG_COMPAT
171   #include "compat_ptrace.h"   #include "compat_ptrace.h"
# Line 175  Source code for this patch is "apt-get i Line 173  Source code for this patch is "apt-get i
173          struct task_struct *child;          struct task_struct *child;
174          int ret;          int ret;
175    
176  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
177  +               return -EPERM;  +               return -EPERM;
178          lock_kernel();          lock_kernel();
179          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
180                   ret = ptrace_traceme();                   ret = ptrace_traceme();
181  --- linux-2.6.18-24etch2.orig/arch/sparc/kernel/ptrace.c  --- linux-2.6.18-26etch1.orig/arch/sparc/kernel/ptrace.c
182  +++ linux-2.6.18-24etch2/arch/sparc/kernel/ptrace.c  +++ linux-2.6.18-26etch1/arch/sparc/kernel/ptrace.c
183  @@ -23,6 +23,7 @@  @@ -23,6 +23,7 @@
184   #include <asm/pgtable.h>   #include <asm/pgtable.h>
185   #include <asm/system.h>   #include <asm/system.h>
186   #include <asm/uaccess.h>   #include <asm/uaccess.h>
187  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
188    
189   #define MAGIC_CONSTANT 0x80000000   #define MAGIC_CONSTANT 0x80000000
190    
# Line 194  Source code for this patch is "apt-get i Line 192  Source code for this patch is "apt-get i
192          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
193          struct task_struct *child;          struct task_struct *child;
194          int ret;          int ret;
195  +       if (!ccs_capable(CCS_SYS_PTRACE)) {  +       if (ccs_ptrace_permission(request, pid)) {
196  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
197  +               return;  +               return;
198  +       }  +       }
199    
200          lock_kernel();          lock_kernel();
201   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
202  --- linux-2.6.18-24etch2.orig/arch/sparc64/kernel/ptrace.c  --- linux-2.6.18-26etch1.orig/arch/sparc64/kernel/ptrace.c
203  +++ linux-2.6.18-24etch2/arch/sparc64/kernel/ptrace.c  +++ linux-2.6.18-26etch1/arch/sparc64/kernel/ptrace.c
204  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
205   #include <asm/spitfire.h>   #include <asm/spitfire.h>
206   #include <asm/page.h>   #include <asm/page.h>
207   #include <asm/cpudata.h>   #include <asm/cpudata.h>
208  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
209    
210   /* Returning from ptrace is a bit tricky because the syscall return   /* Returning from ptrace is a bit tricky because the syscall return
211    * low level code assumes any value returned which is negative and    * low level code assumes any value returned which is negative and
# Line 215  Source code for this patch is "apt-get i Line 213  Source code for this patch is "apt-get i
213          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
214          struct task_struct *child;          struct task_struct *child;
215          int ret;          int ret;
216  +       if (!ccs_capable(CCS_SYS_PTRACE)) {  +       if (ccs_ptrace_permission(request, pid)) {
217  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
218  +               return;  +               return;
219  +       }  +       }
220    
221          if (test_thread_flag(TIF_32BIT)) {          if (test_thread_flag(TIF_32BIT)) {
222                  addr &= 0xffffffffUL;                  addr &= 0xffffffffUL;
223  --- linux-2.6.18-24etch2.orig/arch/x86_64/ia32/ptrace32.c  --- linux-2.6.18-26etch1.orig/arch/x86_64/ia32/ptrace32.c
224  +++ linux-2.6.18-24etch2/arch/x86_64/ia32/ptrace32.c  +++ linux-2.6.18-26etch1/arch/x86_64/ia32/ptrace32.c
225  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
226   #include <asm/i387.h>   #include <asm/i387.h>
227   #include <asm/fpu32.h>   #include <asm/fpu32.h>
228   #include <asm/ia32.h>   #include <asm/ia32.h>
229  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
230    
231   /*   /*
232    * Determines which flags the user has access to [1 = access, 0 = no access].    * Determines which flags the user has access to [1 = access, 0 = no access].
# Line 236  Source code for this patch is "apt-get i Line 234  Source code for this patch is "apt-get i
234          void __user *datap = compat_ptr(data);          void __user *datap = compat_ptr(data);
235          int ret;          int ret;
236          __u32 val;          __u32 val;
237  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
238  +               return -EPERM;  +               return -EPERM;
239    
240          switch (request) {          switch (request) {
241          case PTRACE_TRACEME:          case PTRACE_TRACEME:
242  --- linux-2.6.18-24etch2.orig/fs/Kconfig  --- linux-2.6.18-26etch1.orig/fs/compat.c
243  +++ linux-2.6.18-24etch2/fs/Kconfig  +++ linux-2.6.18-26etch1/fs/compat.c
 @@ -1931,5 +1931,7 @@ endmenu  
   
  source "fs/nls/Kconfig"  
   
 +source "fs/Kconfig.ccs"  
 +  
  endmenu  
   
 --- linux-2.6.18-24etch2.orig/fs/Makefile  
 +++ linux-2.6.18-24etch2/fs/Makefile  
 @@ -102,3 +102,5 @@ obj-$(CONFIG_HOSTFS)                += hostfs/  
  obj-$(CONFIG_HPPFS)            += hppfs/  
  obj-$(CONFIG_DEBUG_FS)         += debugfs/  
  obj-$(CONFIG_OCFS2_FS)         += ocfs2/  
 +  
 +include $(srctree)/fs/Makefile-2.6.ccs  
 --- linux-2.6.18-24etch2.orig/fs/attr.c  
 +++ linux-2.6.18-24etch2/fs/attr.c  
 @@ -15,6 +15,7 @@  
  #include <linux/fcntl.h>  
  #include <linux/quotaops.h>  
  #include <linux/security.h>  
 +#include <linux/tomoyo.h>  
   
  /* Taken over from the old code... */  
   
 @@ -146,11 +147,15 @@ int notify_change(struct dentry * dentry  
         if (inode->i_op && inode->i_op->setattr) {  
                 error = security_inode_setattr(dentry, attr);  
                 if (!error)  
 +                       error = ccs_check_setattr_permission(dentry, attr);  
 +               if (!error)  
                         error = inode->i_op->setattr(dentry, attr);  
         } else {  
                 error = inode_change_ok(inode, attr);  
                 if (!error)  
                         error = security_inode_setattr(dentry, attr);  
 +               if (!error)  
 +                       error = ccs_check_setattr_permission(dentry, attr);  
                 if (!error) {  
                         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||  
                             (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))  
 --- linux-2.6.18-24etch2.orig/fs/compat.c  
 +++ linux-2.6.18-24etch2/fs/compat.c  
244  @@ -52,6 +52,7 @@  @@ -52,6 +52,7 @@
245   #include <asm/uaccess.h>   #include <asm/uaccess.h>
246   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
247   #include <asm/ioctls.h>   #include <asm/ioctls.h>
248  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
249    
250   extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);   extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
251    
# Line 324  Source code for this patch is "apt-get i Line 278  Source code for this patch is "apt-get i
278          if (retval >= 0) {          if (retval >= 0) {
279                  free_arg_pages(bprm);                  free_arg_pages(bprm);
280    
281  --- linux-2.6.18-24etch2.orig/fs/exec.c  --- linux-2.6.18-26etch1.orig/fs/exec.c
282  +++ linux-2.6.18-24etch2/fs/exec.c  +++ linux-2.6.18-26etch1/fs/exec.c
283  @@ -57,6 +57,8 @@  @@ -57,6 +57,8 @@
284   #include <linux/kmod.h>   #include <linux/kmod.h>
285   #endif   #endif
286    
287  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
288  +  +
289   int core_uses_pid;   int core_uses_pid;
290   char core_pattern[65] = "core";   char core_pattern[65] = "core";
# Line 339  Source code for this patch is "apt-get i Line 293  Source code for this patch is "apt-get i
293          if (error)          if (error)
294                  goto exit;                  goto exit;
295    
296  +       error = ccs_check_uselib_permission(nd.dentry, nd.mnt);  +       error = ccs_uselib_permission(nd.dentry, nd.mnt);
297  +       if (error)  +       if (error)
298  +               goto exit;  +               goto exit;
299  +  +
# Line 351  Source code for this patch is "apt-get i Line 305  Source code for this patch is "apt-get i
305                      S_ISREG(inode->i_mode)) {                      S_ISREG(inode->i_mode)) {
306                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
307  +                       if (!err)  +                       if (!err)
308  +                               err = ccs_check_open_exec_permission(nd.dentry,  +                               err = ccs_open_exec_permission(nd.dentry,
309  +                                                                    nd.mnt);  +                                                                    nd.mnt);
310                          file = ERR_PTR(err);                          file = ERR_PTR(err);
311                          if (!err) {                          if (!err) {
# Line 366  Source code for this patch is "apt-get i Line 320  Source code for this patch is "apt-get i
320          if (retval >= 0) {          if (retval >= 0) {
321                  free_arg_pages(bprm);                  free_arg_pages(bprm);
322    
323  --- linux-2.6.18-24etch2.orig/fs/fcntl.c  --- linux-2.6.18-26etch1.orig/fs/fcntl.c
324  +++ linux-2.6.18-24etch2/fs/fcntl.c  +++ linux-2.6.18-26etch1/fs/fcntl.c
325  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
326   #include <asm/poll.h>   #include <asm/poll.h>
327   #include <asm/siginfo.h>   #include <asm/siginfo.h>
328   #include <asm/uaccess.h>   #include <asm/uaccess.h>
329  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
330    
331   void fastcall set_close_on_exec(unsigned int fd, int flag)   void fastcall set_close_on_exec(unsigned int fd, int flag)
332   {   {
333  @@ -214,6 +215,10 @@ static int setfl(int fd, struct file * f  @@ -214,6 +215,9 @@ static int setfl(int fd, struct file * f
334          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
335                  return -EPERM;                  return -EPERM;
336    
337  +       if (((arg ^ filp->f_flags) & O_APPEND) &&  +       if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp))
 +           ccs_check_rewrite_permission(filp))  
338  +               return -EPERM;  +               return -EPERM;
339  +  +
340          /* O_NOATIME can only be set by the owner or superuser */          /* O_NOATIME can only be set by the owner or superuser */
341          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
342                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
343  --- linux-2.6.18-24etch2.orig/fs/ioctl.c  --- linux-2.6.18-26etch1.orig/fs/ioctl.c
344  +++ linux-2.6.18-24etch2/fs/ioctl.c  +++ linux-2.6.18-26etch1/fs/ioctl.c
345  @@ -15,6 +15,7 @@  @@ -15,6 +15,7 @@
346    
347   #include <asm/uaccess.h>   #include <asm/uaccess.h>
348   #include <asm/ioctls.h>   #include <asm/ioctls.h>
349  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
350    
351   static long do_ioctl(struct file *filp, unsigned int cmd,   static long do_ioctl(struct file *filp, unsigned int cmd,
352                  unsigned long arg)                  unsigned long arg)
# Line 411  Source code for this patch is "apt-get i Line 364  Source code for this patch is "apt-get i
364    
365          error = security_file_ioctl(filp, cmd, arg);          error = security_file_ioctl(filp, cmd, arg);
366  +       if (!error)  +       if (!error)
367  +               error = ccs_check_ioctl_permission(filp, cmd, arg);  +               error = ccs_ioctl_permission(filp, cmd, arg);
368          if (error)          if (error)
369                  goto out_fput;                  goto out_fput;
370    
371  --- linux-2.6.18-24etch2.orig/fs/namei.c  --- linux-2.6.18-26etch1.orig/fs/namei.c
372  +++ linux-2.6.18-24etch2/fs/namei.c  +++ linux-2.6.18-26etch1/fs/namei.c
373  @@ -37,6 +37,8 @@  @@ -37,6 +37,8 @@
374    
375   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
376    
377  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
378  +  +
379   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
380    * Fundamental changes in the pathname lookup mechanisms (namei)    * Fundamental changes in the pathname lookup mechanisms (namei)
# Line 431  Source code for this patch is "apt-get i Line 384  Source code for this patch is "apt-get i
384                          return -EPERM;                          return -EPERM;
385    
386  +       /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
387  +       error = ccs_check_open_permission(dentry, nd->mnt, flag);  +       error = ccs_open_permission(dentry, nd->mnt, flag);
388  +       if (error)  +       if (error)
389  +               return error;  +               return error;
390  +  +
# Line 442  Source code for this patch is "apt-get i Line 395  Source code for this patch is "apt-get i
395          return 0;          return 0;
396   }   }
397    
398  +#include <linux/tomoyo_vfs.h>  +#include <linux/ccsecurity_vfs.h>
399   /*   /*
400    *     open_namei()    *     open_namei()
401    *    *
# Line 450  Source code for this patch is "apt-get i Line 403  Source code for this patch is "apt-get i
403          if (!path.dentry->d_inode) {          if (!path.dentry->d_inode) {
404                  if (!IS_POSIXACL(dir->d_inode))                  if (!IS_POSIXACL(dir->d_inode))
405                          mode &= ~current->fs->umask;                          mode &= ~current->fs->umask;
406  +               error = ccs_check_mknod_permission(dir->d_inode, path.dentry,  +               error = ccs_mknod_permission(dir->d_inode, path.dentry,
407  +                                                  nd->mnt, mode, 0);  +                                            nd->mnt, mode, 0);
408  +               if (!error)  +               if (!error)
409                  error = vfs_create(dir->d_inode, path.dentry, mode, nd);                  error = vfs_create(dir->d_inode, path.dentry, mode, nd);
410                  mutex_unlock(&dir->d_inode->i_mutex);                  mutex_unlock(&dir->d_inode->i_mutex);
411                  dput(nd->dentry);                  dput(nd->dentry);
412  @@ -1848,6 +1859,10 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1848,6 +1859,9 @@ asmlinkage long sys_mknodat(int dfd, con
413          if (!IS_POSIXACL(nd.dentry->d_inode))          if (!IS_POSIXACL(nd.dentry->d_inode))
414                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
415          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
416  +               error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
417  +                                                  nd.mnt, mode,  +                                            nd.mnt, mode, dev);
 +                                                  new_decode_dev(dev));  
418  +               if (!error)  +               if (!error)
419                  switch (mode & S_IFMT) {                  switch (mode & S_IFMT) {
420                  case 0: case S_IFREG:                  case 0: case S_IFREG:
421                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
422  @@ -1921,6 +1936,10 @@ asmlinkage long sys_mkdirat(int dfd, con  @@ -1921,6 +1935,9 @@ asmlinkage long sys_mkdirat(int dfd, con
423                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
424                          if (!IS_POSIXACL(nd.dentry->d_inode))                          if (!IS_POSIXACL(nd.dentry->d_inode))
425                                  mode &= ~current->fs->umask;                                  mode &= ~current->fs->umask;
426  +                       error = ccs_check_mkdir_permission(nd.dentry->d_inode,  +                       error = ccs_mkdir_permission(nd.dentry->d_inode,
427  +                                                          dentry, nd.mnt,  +                                                    dentry, nd.mnt, mode);
 +                                                          mode);  
428  +                       if (!error)  +                       if (!error)
429                          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);                          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
430                          dput(dentry);                          dput(dentry);
431                  }                  }
432  @@ -2029,6 +2048,9 @@ static long do_rmdir(int dfd, const char  @@ -2029,6 +2046,9 @@ static long do_rmdir(int dfd, const char
433          dentry = lookup_hash(&nd);          dentry = lookup_hash(&nd);
434          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
435          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
436  +               error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,  +               error = ccs_rmdir_permission(nd.dentry->d_inode, dentry,
437  +                                                  nd.mnt);  +                                            nd.mnt);
438  +               if (!error)  +               if (!error)
439                  error = vfs_rmdir(nd.dentry->d_inode, dentry);                  error = vfs_rmdir(nd.dentry->d_inode, dentry);
440                  dput(dentry);                  dput(dentry);
441          }          }
442  @@ -2109,6 +2131,9 @@ static long do_unlinkat(int dfd, const c  @@ -2109,6 +2129,9 @@ static long do_unlinkat(int dfd, const c
443                  inode = dentry->d_inode;                  inode = dentry->d_inode;
444                  if (inode)                  if (inode)
445                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
446  +               error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,  +               error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
447  +                                                   nd.mnt);  +                                             nd.mnt);
448  +               if (!error)  +               if (!error)
449                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
450          exit2:          exit2:
451                  dput(dentry);                  dput(dentry);
452  @@ -2187,6 +2212,10 @@ asmlinkage long sys_symlinkat(const char  @@ -2187,6 +2210,9 @@ asmlinkage long sys_symlinkat(const char
453                  dentry = lookup_create(&nd, 0);                  dentry = lookup_create(&nd, 0);
454                  error = PTR_ERR(dentry);                  error = PTR_ERR(dentry);
455                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
456  +                       error = ccs_check_symlink_permission(nd.dentry->d_inode,  +                       error = ccs_symlink_permission(nd.dentry->d_inode,
457  +                                                            dentry, nd.mnt,  +                                                      dentry, nd.mnt, from);
 +                                                            from);  
458  +                       if (!error)  +                       if (!error)
459                          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);                          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
460                          dput(dentry);                          dput(dentry);
461                  }                  }
462  @@ -2281,6 +2310,10 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2281,6 +2307,9 @@ asmlinkage long sys_linkat(int olddfd, c
463          new_dentry = lookup_create(&nd, 0);          new_dentry = lookup_create(&nd, 0);
464          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
465          if (!IS_ERR(new_dentry)) {          if (!IS_ERR(new_dentry)) {
466  +               error = ccs_check_link_permission(old_nd.dentry,  +               error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode,
467  +                                                 nd.dentry->d_inode,  +                                           new_dentry, nd.mnt);
 +                                                 new_dentry, nd.mnt);  
468  +               if (!error)  +               if (!error)
469                  error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);                  error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
470                  dput(new_dentry);                  dput(new_dentry);
471          }          }
472  @@ -2507,6 +2540,11 @@ static int do_rename(int olddfd, const c  @@ -2507,6 +2536,9 @@ static int do_rename(int olddfd, const c
473          if (new_dentry == trap)          if (new_dentry == trap)
474                  goto exit5;                  goto exit5;
475    
476  +       error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,  +       error = ccs_rename_permission(old_dir->d_inode, old_dentry,
477  +                                           new_dir->d_inode, new_dentry,  +                                     new_dir->d_inode, new_dentry, newnd.mnt);
 +                                           newnd.mnt);  
478  +       if (!error)  +       if (!error)
 +  
479          error = vfs_rename(old_dir->d_inode, old_dentry,          error = vfs_rename(old_dir->d_inode, old_dentry,
480                                     new_dir->d_inode, new_dentry);                                     new_dir->d_inode, new_dentry);
481   exit5:   exit5:
482  --- linux-2.6.18-24etch2.orig/fs/namespace.c  --- linux-2.6.18-26etch1.orig/fs/namespace.c
483  +++ linux-2.6.18-24etch2/fs/namespace.c  +++ linux-2.6.18-26etch1/fs/namespace.c
484  @@ -25,6 +25,8 @@  @@ -25,6 +25,7 @@
485   #include <asm/uaccess.h>   #include <asm/uaccess.h>
486   #include <asm/unistd.h>   #include <asm/unistd.h>
487   #include "pnode.h"   #include "pnode.h"
488  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
489    
490   extern int __init init_rootfs(void);   extern int __init init_rootfs(void);
491    
492  @@ -553,6 +555,9 @@ static int do_umount(struct vfsmount *mn  @@ -550,6 +551,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)          if (retval)
499                  return retval;                  return retval;
500    
501  +       if (ccs_may_umount(mnt))  @@ -641,6 +644,8 @@ asmlinkage long sys_umount(char __user *
 +               return -EPERM;  
 +  
         /*  
          * Allow userspace to request a mountpoint be expired rather than  
          * unmounting unconditionally. Unmount only happens if:  
 @@ -641,6 +646,8 @@ asmlinkage long sys_umount(char __user *  
502   {   {
503          struct nameidata nd;          struct nameidata nd;
504          int retval;          int retval;
# Line 562  Source code for this patch is "apt-get i Line 507  Source code for this patch is "apt-get i
507    
508          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
509          if (retval)          if (retval)
510  @@ -925,6 +932,9 @@ static int do_loopback(struct nameidata  @@ -925,6 +930,9 @@ static int do_loopback(struct nameidata
511    
512          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
513                  goto out;                  goto out;
# Line 572  Source code for this patch is "apt-get i Line 517  Source code for this patch is "apt-get i
517    
518          err = -ENOMEM;          err = -ENOMEM;
519          if (recurse)          if (recurse)
520  @@ -1009,7 +1019,9 @@ static int do_move_mount(struct nameidat  @@ -1009,7 +1017,9 @@ static int do_move_mount(struct nameidat
521          err = -EINVAL;          err = -EINVAL;
522          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
523                  goto out;                  goto out;
524  -  -
525  +       err = -EPERM;  +       err = -EPERM;
526  +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
527  +               goto out;  +               goto out;
528          err = -ENOENT;          err = -ENOENT;
529          mutex_lock(&nd->dentry->d_inode->i_mutex);          mutex_lock(&nd->dentry->d_inode->i_mutex);
530          if (IS_DEADDIR(nd->dentry->d_inode))          if (IS_DEADDIR(nd->dentry->d_inode))
531  @@ -1111,6 +1123,9 @@ int do_add_mount(struct vfsmount *newmnt  @@ -1111,6 +1121,9 @@ int do_add_mount(struct vfsmount *newmnt
532          err = -EINVAL;          err = -EINVAL;
533          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
534                  goto unlock;                  goto unlock;
# Line 593  Source code for this patch is "apt-get i Line 538  Source code for this patch is "apt-get i
538    
539          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
540          if ((err = graft_tree(newmnt, nd)))          if ((err = graft_tree(newmnt, nd)))
541  @@ -1402,6 +1417,13 @@ long do_mount(char *dev_name, char *dir_  @@ -1384,6 +1397,7 @@ int copy_mount_options(const void __user
542          if (data_page)   long do_mount(char *dev_name, char *dir_name, char *type_page,
543                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                    unsigned long flags, void *data_page)
544     {
545  +       if (!ccs_capable(CCS_SYS_MOUNT))  +       const unsigned long original_flags = flags;
546  +               return -EPERM;          struct nameidata nd;
547  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,          int retval = 0;
548  +                                           &flags);          int mnt_flags = 0;
549  +       if (retval)  @@ -1423,6 +1437,9 @@ long do_mount(char *dev_name, char *dir_
550  +               return retval;                  return retval;
551  +  
552          /* Separate the per-mountpoint flags */          retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
553          if (flags & MS_NOSUID)  +       if (!retval)
554                  mnt_flags |= MNT_NOSUID;  +               retval = ccs_mount_permission(dev_name, &nd, type_page,
555  @@ -1691,6 +1713,8 @@ asmlinkage long sys_pivot_root(const cha  +                                             original_flags, data_page);
556            if (retval)
557                    goto dput_out;
558    
559    @@ -1691,6 +1708,8 @@ asmlinkage long sys_pivot_root(const cha
560    
561          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
562                  return -EPERM;                  return -EPERM;
# Line 616  Source code for this patch is "apt-get i Line 565  Source code for this patch is "apt-get i
565    
566          lock_kernel();          lock_kernel();
567    
568  @@ -1707,6 +1731,8 @@ asmlinkage long sys_pivot_root(const cha  @@ -1707,6 +1726,8 @@ asmlinkage long sys_pivot_root(const cha
569                  goto out1;                  goto out1;
570    
571          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
572  +       if (!error)  +       if (!error)
573  +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);  +               error = ccs_pivot_root_permission(&old_nd, &new_nd);
574          if (error) {          if (error) {
575                  path_release(&old_nd);                  path_release(&old_nd);
576                  goto out1;                  goto out1;
577  --- linux-2.6.18-24etch2.orig/fs/open.c  --- linux-2.6.18-26etch1.orig/fs/open.c
578  +++ linux-2.6.18-24etch2/fs/open.c  +++ linux-2.6.18-26etch1/fs/open.c
579  @@ -30,6 +30,8 @@  @@ -30,6 +30,7 @@
580   #include <linux/audit.h>   #include <linux/audit.h>
581    
582   #include <asm/unistd.h>   #include <asm/unistd.h>
583  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
584    
585   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
586   {   {
587  @@ -267,6 +269,8 @@ static long do_sys_truncate(const char _  @@ -267,6 +268,8 @@ static long do_sys_truncate(const char _
588          if (error)          if (error)
589                  goto dput_and_out;                  goto dput_and_out;
590    
591  +       error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);  +       error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
592  +       if (!error)  +       if (!error)
593          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
594          if (!error) {          if (!error) {
595                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
596  @@ -320,6 +324,10 @@ static long do_sys_ftruncate(unsigned in  @@ -320,6 +323,9 @@ static long do_sys_ftruncate(unsigned in
597          if (IS_APPEND(inode))          if (IS_APPEND(inode))
598                  goto out_putf;                  goto out_putf;
599    
600  +       error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,  +       error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
 +                                             0);  
601  +       if (error)  +       if (error)
602  +               goto out_putf;  +               goto out_putf;
603          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
604          if (!error)          if (!error)
605                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
606  @@ -608,6 +616,10 @@ asmlinkage long sys_chroot(const char __  @@ -608,6 +614,10 @@ asmlinkage long sys_chroot(const char __
607          error = -EPERM;          error = -EPERM;
608          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
609                  goto dput_and_out;                  goto dput_and_out;
610  +       if (!ccs_capable(CCS_SYS_CHROOT))  +       if (!ccs_capable(CCS_SYS_CHROOT))
611  +               goto dput_and_out;  +               goto dput_and_out;
612  +       if (ccs_check_chroot_permission(&nd))  +       if (ccs_chroot_permission(&nd))
613  +               goto dput_and_out;  +               goto dput_and_out;
614    
615          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
616          set_fs_altroot();          set_fs_altroot();
617  @@ -1199,6 +1211,8 @@ EXPORT_SYMBOL(sys_close);  @@ -641,6 +651,9 @@ asmlinkage long sys_fchmod(unsigned int
618            err = -EPERM;
619            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
620                    goto out_putf;
621    +       err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
622    +       if (err)
623    +               goto out_putf;
624            mutex_lock(&inode->i_mutex);
625            if (mode == (mode_t) -1)
626                    mode = inode->i_mode;
627    @@ -675,6 +688,9 @@ asmlinkage long sys_fchmodat(int dfd, co
628            error = -EPERM;
629            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
630                    goto dput_and_out;
631    +       error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
632    +       if (error)
633    +               goto dput_and_out;
634    
635            mutex_lock(&inode->i_mutex);
636            if (mode == (mode_t) -1)
637    @@ -737,6 +753,8 @@ asmlinkage long sys_chown(const char __u
638    
639            error = user_path_walk(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    @@ -756,6 +774,8 @@ asmlinkage long sys_fchownat(int dfd, co
647            follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
648            error = __user_walk_fd(dfd, filename, follow, &nd);
649            if (!error) {
650    +               error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
651    +               if (!error)
652                    error = chown_common(nd.dentry, user, group);
653                    path_release(&nd);
654            }
655    @@ -770,6 +790,8 @@ asmlinkage long sys_lchown(const char __
656    
657            error = user_path_walk_link(filename, &nd);
658            if (!error) {
659    +               error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
660    +               if (!error)
661                    error = chown_common(nd.dentry, user, group);
662                    path_release(&nd);
663            }
664    @@ -787,6 +809,9 @@ asmlinkage long sys_fchown(unsigned int
665                    struct dentry * dentry;
666                    dentry = file->f_dentry;
667                    audit_inode(NULL, dentry->d_inode);
668    +               error = ccs_chown_permission(dentry, file->f_vfsmnt, user,
669    +                                            group);
670    +               if (!error)
671                    error = chown_common(dentry, user, group);
672                    fput(file);
673            }
674    @@ -879,7 +904,9 @@ static struct file *do_filp_open(int dfd
675            if ((namei_flags+1) & O_ACCMODE)
676                    namei_flags++;
677    
678    +       ccs_save_open_mode(flags);
679            error = open_namei(dfd, filename, namei_flags, mode, &nd);
680    +       ccs_clear_open_mode();
681            if (!error)
682                    return nameidata_to_filp(&nd, flags);
683    
684    @@ -1199,6 +1226,8 @@ EXPORT_SYMBOL(sys_close);
685    */    */
686   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
687   {   {
# Line 676  Source code for this patch is "apt-get i Line 690  Source code for this patch is "apt-get i
690          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
691                  tty_vhangup(current->signal->tty);                  tty_vhangup(current->signal->tty);
692                  return 0;                  return 0;
693  --- linux-2.6.18-24etch2.orig/fs/proc/Makefile  --- linux-2.6.18-26etch1.orig/fs/proc/proc_misc.c
694  +++ linux-2.6.18-24etch2/fs/proc/Makefile  +++ linux-2.6.18-26etch1/fs/proc/proc_misc.c
 @@ -13,3 +13,6 @@ proc-y       += inode.o root.o base.o ge  
  proc-$(CONFIG_PROC_KCORE)      += kcore.o  
  proc-$(CONFIG_PROC_VMCORE)     += vmcore.o  
  proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o  
 +  
 +proc-$(CONFIG_SAKURA) += ccs_proc.o  
 +proc-$(CONFIG_TOMOYO) += ccs_proc.o  
 --- linux-2.6.18-24etch2.orig/fs/proc/proc_misc.c  
 +++ linux-2.6.18-24etch2/fs/proc/proc_misc.c  
695  @@ -723,4 +723,5 @@ void __init proc_misc_init(void)  @@ -723,4 +723,5 @@ void __init proc_misc_init(void)
696          if (entry)          if (entry)
697                  entry->proc_fops = &proc_sysrq_trigger_operations;                  entry->proc_fops = &proc_sysrq_trigger_operations;
698   #endif   #endif
699  +       printk(KERN_INFO "Hook version: 2.6.18-24etch2 2009/08/05\n");  +       printk(KERN_INFO "Hook version: 2.6.18-26etch1 2009/11/07\n");
700   }   }
701  --- linux-2.6.18-24etch2.orig/include/linux/init_task.h  --- linux-2.6.18-26etch1.orig/include/linux/init_task.h
702  +++ linux-2.6.18-24etch2/include/linux/init_task.h  +++ linux-2.6.18-26etch1/include/linux/init_task.h
703  @@ -128,6 +128,8 @@ extern struct group_info init_groups;  @@ -76,6 +76,14 @@
704    
705     extern struct group_info init_groups;
706    
707    +#ifdef CONFIG_CCSECURITY
708    +#define INIT_CCSECURITY          \
709    +       .ccs_domain_info = NULL, \
710    +       .ccs_flags = 0,
711    +#else
712    +#define INIT_CCSECURITY
713    +#endif
714    +
715     /*
716      *  INIT_TASK is used to set up the first task table, touch at
717      * your own risk!. Base=0, limit=0x1fffff (=2MB)
718    @@ -128,6 +136,7 @@ extern struct group_info init_groups;
719          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \
720          INIT_TRACE_IRQFLAGS                                             \          INIT_TRACE_IRQFLAGS                                             \
721          INIT_LOCKDEP                                                    \          INIT_LOCKDEP                                                    \
722  +       .ccs_domain_info = NULL,                 \  +       INIT_CCSECURITY                                                 \
 +       .ccs_flags = 0,                          \  
723   }   }
724    
725    
726  --- linux-2.6.18-24etch2.orig/include/linux/sched.h  --- linux-2.6.18-26etch1.orig/include/linux/sched.h
727  +++ linux-2.6.18-24etch2/include/linux/sched.h  +++ linux-2.6.18-26etch1/include/linux/sched.h
728  @@ -25,6 +25,8 @@  @@ -35,6 +35,8 @@
729   #define CLONE_CHILD_SETTID     0x01000000      /* set the TID in the child */  
730   #define CLONE_STOPPED          0x02000000      /* Start in stopped state */   #ifdef __KERNEL__
731    
732  +struct ccs_domain_info;  +struct ccs_domain_info;
733  +  +
734   /*   struct sched_param {
735    * Scheduling policies          int sched_priority;
736    */   };
737  @@ -996,6 +998,8 @@ struct task_struct {  @@ -996,6 +998,10 @@ struct task_struct {
738   #ifdef CONFIG_TASK_DELAY_ACCT   #ifdef CONFIG_TASK_DELAY_ACCT
739          struct task_delay_info *delays;          struct task_delay_info *delays;
740   #endif   #endif
741    +#ifdef CONFIG_CCSECURITY
742  +       struct ccs_domain_info *ccs_domain_info;  +       struct ccs_domain_info *ccs_domain_info;
743  +       u32 ccs_flags;  +       u32 ccs_flags;
744    +#endif
745   };   };
746    
747   static inline pid_t process_group(struct task_struct *tsk)   static inline pid_t process_group(struct task_struct *tsk)
748  --- linux-2.6.18-24etch2.orig/kernel/compat.c  --- linux-2.6.18-26etch1.orig/kernel/compat.c
749  +++ linux-2.6.18-24etch2/kernel/compat.c  +++ linux-2.6.18-26etch1/kernel/compat.c
750  @@ -24,6 +24,7 @@  @@ -24,6 +24,7 @@
751   #include <linux/migrate.h>   #include <linux/migrate.h>
752    
753   #include <asm/uaccess.h>   #include <asm/uaccess.h>
754  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
755    
756   int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)   int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
757   {   {
# Line 743  Source code for this patch is "apt-get i Line 764  Source code for this patch is "apt-get i
764    
765          do_settimeofday(&tv);          do_settimeofday(&tv);
766          return 0;          return 0;
767  --- linux-2.6.18-24etch2.orig/kernel/kexec.c  --- linux-2.6.18-26etch1.orig/kernel/kexec.c
768  +++ linux-2.6.18-24etch2/kernel/kexec.c  +++ linux-2.6.18-26etch1/kernel/kexec.c
769  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
770   #include <asm/io.h>   #include <asm/io.h>
771   #include <asm/system.h>   #include <asm/system.h>
772   #include <asm/semaphore.h>   #include <asm/semaphore.h>
773  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
774    
775   /* Per cpu memory for storing cpu states in case of system crash. */   /* Per cpu memory for storing cpu states in case of system crash. */
776   note_buf_t* crash_notes;   note_buf_t* crash_notes;
# Line 762  Source code for this patch is "apt-get i Line 783  Source code for this patch is "apt-get i
783    
784          /*          /*
785           * Verify we have a legal set of flags           * Verify we have a legal set of flags
786  --- linux-2.6.18-24etch2.orig/kernel/kmod.c  --- linux-2.6.18-26etch1.orig/kernel/kmod.c
787  +++ linux-2.6.18-24etch2/kernel/kmod.c  +++ linux-2.6.18-26etch1/kernel/kmod.c
788  @@ -148,6 +148,9 @@ static int ____call_usermodehelper(void  @@ -148,6 +148,11 @@ static int ____call_usermodehelper(void
789          /* We can run anywhere, unlike our parent keventd(). */          /* We can run anywhere, unlike our parent keventd(). */
790          set_cpus_allowed(current, CPU_MASK_ALL);          set_cpus_allowed(current, CPU_MASK_ALL);
791    
792    +#ifdef CONFIG_CCSECURITY
793  +       current->ccs_domain_info = NULL;  +       current->ccs_domain_info = NULL;
794  +       current->ccs_flags = 0;  +       current->ccs_flags = 0;
795    +#endif
796  +  +
797          retval = -EPERM;          retval = -EPERM;
798          if (current->fs->root)          if (current->fs->root)
799                  retval = execve(sub_info->path, sub_info->argv,sub_info->envp);                  retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
800  --- linux-2.6.18-24etch2.orig/kernel/module.c  --- linux-2.6.18-26etch1.orig/kernel/module.c
801  +++ linux-2.6.18-24etch2/kernel/module.c  +++ linux-2.6.18-26etch1/kernel/module.c
802  @@ -44,6 +44,7 @@  @@ -44,6 +44,7 @@
803   #include <asm/semaphore.h>   #include <asm/semaphore.h>
804   #include <asm/cacheflush.h>   #include <asm/cacheflush.h>
805   #include <linux/license.h>   #include <linux/license.h>
806  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
807    
808   #if 0   #if 0
809   #define DEBUGP printk   #define DEBUGP printk
# Line 804  Source code for this patch is "apt-get i Line 827  Source code for this patch is "apt-get i
827          /* Only one module load at a time, please */          /* Only one module load at a time, please */
828          if (mutex_lock_interruptible(&module_mutex) != 0)          if (mutex_lock_interruptible(&module_mutex) != 0)
829                  return -EINTR;                  return -EINTR;
830  --- linux-2.6.18-24etch2.orig/kernel/ptrace.c  --- linux-2.6.18-26etch1.orig/kernel/ptrace.c
831  +++ linux-2.6.18-24etch2/kernel/ptrace.c  +++ linux-2.6.18-26etch1/kernel/ptrace.c
832  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
833    
834   #include <asm/pgtable.h>   #include <asm/pgtable.h>
835   #include <asm/uaccess.h>   #include <asm/uaccess.h>
836  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
837    
838   /*   /*
839    * ptrace a task: make the debugger its new parent and    * ptrace a task: make the debugger its new parent and
# Line 818  Source code for this patch is "apt-get i Line 841  Source code for this patch is "apt-get i
841          /*          /*
842           * This lock_kernel fixes a subtle race with suid exec           * This lock_kernel fixes a subtle race with suid exec
843           */           */
844  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
845  +               return -EPERM;  +               return -EPERM;
846          lock_kernel();          lock_kernel();
847          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
848                  ret = ptrace_traceme();                  ret = ptrace_traceme();
849  --- linux-2.6.18-24etch2.orig/kernel/sched.c  --- linux-2.6.18-26etch1.orig/kernel/sched.c
850  +++ linux-2.6.18-24etch2/kernel/sched.c  +++ linux-2.6.18-26etch1/kernel/sched.c
851  @@ -55,6 +55,7 @@  @@ -55,6 +55,7 @@
852   #include <asm/tlb.h>   #include <asm/tlb.h>
853    
854   #include <asm/unistd.h>   #include <asm/unistd.h>
855  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
856    
857   /*   /*
858    * Convert user-nice values [ -20 ... 0 ... 19 ]    * Convert user-nice values [ -20 ... 0 ... 19 ]
# Line 842  Source code for this patch is "apt-get i Line 865  Source code for this patch is "apt-get i
865    
866          /*          /*
867           * Setpriority might change our priority at the same moment.           * Setpriority might change our priority at the same moment.
868  --- linux-2.6.18-24etch2.orig/kernel/signal.c  --- linux-2.6.18-26etch1.orig/kernel/signal.c
869  +++ linux-2.6.18-24etch2/kernel/signal.c  +++ linux-2.6.18-26etch1/kernel/signal.c
870  @@ -28,6 +28,7 @@  @@ -28,6 +28,7 @@
871   #include <asm/unistd.h>   #include <asm/unistd.h>
872   #include <asm/siginfo.h>   #include <asm/siginfo.h>
873   #include "audit.h"     /* audit_signal_info() */   #include "audit.h"     /* audit_signal_info() */
874  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
875    
876   /*   /*
877    * SLAB caches for signal bits.    * SLAB caches for signal bits.
# Line 879  Source code for this patch is "apt-get i Line 902  Source code for this patch is "apt-get i
902    
903          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
904   }   }
905  --- linux-2.6.18-24etch2.orig/kernel/sys.c  @@ -2271,6 +2278,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
906  +++ linux-2.6.18-24etch2/kernel/sys.c          if (info.si_code >= 0)
907                    return -EPERM;
908            info.si_signo = sig;
909    +       if (ccs_sigqueue_permission(pid, sig))
910    +               return -EPERM;
911    
912            /* POSIX.1b doesn't mention process groups.  */
913            return kill_proc_info(sig, &info, pid);
914    --- linux-2.6.18-26etch1.orig/kernel/sys.c
915    +++ linux-2.6.18-26etch1/kernel/sys.c
916  @@ -36,6 +36,7 @@  @@ -36,6 +36,7 @@
917   #include <asm/uaccess.h>   #include <asm/uaccess.h>
918   #include <asm/io.h>   #include <asm/io.h>
919   #include <asm/unistd.h>   #include <asm/unistd.h>
920  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
921    
922   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
923   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
# Line 927  Source code for this patch is "apt-get i Line 959  Source code for this patch is "apt-get i
959    
960          down_write(&uts_sem);          down_write(&uts_sem);
961          errno = -EFAULT;          errno = -EFAULT;
962  --- linux-2.6.18-24etch2.orig/kernel/sysctl.c  --- linux-2.6.18-26etch1.orig/kernel/sysctl.c
963  +++ linux-2.6.18-24etch2/kernel/sysctl.c  +++ linux-2.6.18-26etch1/kernel/sysctl.c
964  @@ -48,6 +48,7 @@  @@ -48,6 +48,7 @@
965    
966   #include <asm/uaccess.h>   #include <asm/uaccess.h>
967   #include <asm/processor.h>   #include <asm/processor.h>
968  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
969    
970   extern int proc_nr_files(ctl_table *table, int write, struct file *filp,   extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
971                        void __user *buffer, size_t *lenp, loff_t *ppos);                        void __user *buffer, size_t *lenp, loff_t *ppos);
# Line 961  Source code for this patch is "apt-get i Line 993  Source code for this patch is "apt-get i
993                                          error = table->strategy(                                          error = table->strategy(
994                                                  table, name, nlen,                                                  table, name, nlen,
995                                                  oldval, oldlenp,                                                  oldval, oldlenp,
996  --- linux-2.6.18-24etch2.orig/kernel/time.c  --- linux-2.6.18-26etch1.orig/kernel/time.c
997  +++ linux-2.6.18-24etch2/kernel/time.c  +++ linux-2.6.18-26etch1/kernel/time.c
998  @@ -39,6 +39,7 @@  @@ -39,6 +39,7 @@
999    
1000   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1001   #include <asm/unistd.h>   #include <asm/unistd.h>
1002  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1003    
1004   /*   /*
1005    * The timezone where the local system is located.  Used as a default by some    * The timezone where the local system is located.  Used as a default by some
# Line 998  Source code for this patch is "apt-get i Line 1030  Source code for this patch is "apt-get i
1030                                    
1031          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
1032    
1033  --- linux-2.6.18-24etch2.orig/net/ipv4/inet_connection_sock.c  --- linux-2.6.18-26etch1.orig/net/ipv4/inet_connection_sock.c
1034  +++ linux-2.6.18-24etch2/net/ipv4/inet_connection_sock.c  +++ linux-2.6.18-26etch1/net/ipv4/inet_connection_sock.c
1035  @@ -23,6 +23,7 @@  @@ -23,6 +23,7 @@
1036   #include <net/route.h>   #include <net/route.h>
1037   #include <net/tcp_states.h>   #include <net/tcp_states.h>
1038   #include <net/xfrm.h>   #include <net/xfrm.h>
1039  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1040    
1041   #ifdef INET_CSK_DEBUG   #ifdef INET_CSK_DEBUG
1042   const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";   const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
# Line 1017  Source code for this patch is "apt-get i Line 1049  Source code for this patch is "apt-get i
1049                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
1050                                  if (tb->port == rover)                                  if (tb->port == rover)
1051                                          goto next;                                          goto next;
1052  --- linux-2.6.18-24etch2.orig/net/ipv4/inet_hashtables.c  --- linux-2.6.18-26etch1.orig/net/ipv4/inet_hashtables.c
1053  +++ linux-2.6.18-24etch2/net/ipv4/inet_hashtables.c  +++ linux-2.6.18-26etch1/net/ipv4/inet_hashtables.c
1054  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
1055   #include <net/inet_connection_sock.h>   #include <net/inet_connection_sock.h>
1056   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1057   #include <net/ip.h>   #include <net/ip.h>
1058  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1059    
1060   /*   /*
1061    * Allocate and initialize a new local port bind bucket.    * Allocate and initialize a new local port bind bucket.
# Line 1036  Source code for this patch is "apt-get i Line 1068  Source code for this patch is "apt-get i
1068                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1069                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1070    
1071  --- linux-2.6.18-24etch2.orig/net/ipv4/raw.c  --- linux-2.6.18-26etch1.orig/net/ipv4/raw.c
1072  +++ linux-2.6.18-24etch2/net/ipv4/raw.c  +++ linux-2.6.18-26etch1/net/ipv4/raw.c
1073  @@ -79,6 +79,7 @@  @@ -79,6 +79,7 @@
1074   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1075   #include <linux/netfilter.h>   #include <linux/netfilter.h>
1076   #include <linux/netfilter_ipv4.h>   #include <linux/netfilter_ipv4.h>
1077  +#include <linux/tomoyo_socket.h>  +#include <linux/ccsecurity.h>
1078    
1079   struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];   struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1080   DEFINE_RWLOCK(raw_v4_lock);   DEFINE_RWLOCK(raw_v4_lock);
# Line 1056  Source code for this patch is "apt-get i Line 1088  Source code for this patch is "apt-get i
1088    
1089          copied = skb->len;          copied = skb->len;
1090          if (len < copied) {          if (len < copied) {
1091  --- linux-2.6.18-24etch2.orig/net/ipv4/udp.c  --- linux-2.6.18-26etch1.orig/net/ipv4/udp.c
1092  +++ linux-2.6.18-24etch2/net/ipv4/udp.c  +++ linux-2.6.18-26etch1/net/ipv4/udp.c
1093  @@ -108,6 +108,8 @@  @@ -108,6 +108,7 @@
1094   #include <net/inet_common.h>   #include <net/inet_common.h>
1095   #include <net/checksum.h>   #include <net/checksum.h>
1096   #include <net/xfrm.h>   #include <net/xfrm.h>
1097  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1098    
1099   /*   /*
1100    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
1101  @@ -146,6 +148,8 @@ static int udp_v4_get_port(struct sock *  @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1102                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1103                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1104                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
# Line 1076  Source code for this patch is "apt-get i Line 1107  Source code for this patch is "apt-get i
1107                                  goto gotit;                                  goto gotit;
1108                          }                          }
1109                          size = 0;                          size = 0;
1110  @@ -162,6 +166,8 @@ static int udp_v4_get_port(struct sock *  @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1111                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1112                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1113                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
# Line 1085  Source code for this patch is "apt-get i Line 1116  Source code for this patch is "apt-get i
1116                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1117                                  break;                                  break;
1118                  }                  }
1119  @@ -796,7 +802,10 @@ try_again:  @@ -796,7 +801,10 @@ try_again:
1120          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1121          if (!skb)          if (!skb)
1122                  goto out;                  goto out;
# Line 1097  Source code for this patch is "apt-get i Line 1128  Source code for this patch is "apt-get i
1128          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1129          if (copied > len) {          if (copied > len) {
1130                  copied = len;                  copied = len;
1131  --- linux-2.6.18-24etch2.orig/net/ipv6/inet6_hashtables.c  --- linux-2.6.18-26etch1.orig/net/ipv6/inet6_hashtables.c
1132  +++ linux-2.6.18-24etch2/net/ipv6/inet6_hashtables.c  +++ linux-2.6.18-26etch1/net/ipv6/inet6_hashtables.c
1133  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
1134   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1135   #include <net/inet6_hashtables.h>   #include <net/inet6_hashtables.h>
1136   #include <net/ip.h>   #include <net/ip.h>
1137  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1138    
1139   void __inet6_hash(struct inet_hashinfo *hashinfo,   void __inet6_hash(struct inet_hashinfo *hashinfo,
1140                                  struct sock *sk)                                  struct sock *sk)
# Line 1125  Source code for this patch is "apt-get i Line 1156  Source code for this patch is "apt-get i
1156                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1157                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1158    
1159  --- linux-2.6.18-24etch2.orig/net/ipv6/raw.c  --- linux-2.6.18-26etch1.orig/net/ipv6/raw.c
1160  +++ linux-2.6.18-24etch2/net/ipv6/raw.c  +++ linux-2.6.18-26etch1/net/ipv6/raw.c
1161  @@ -56,6 +56,7 @@  @@ -56,6 +56,7 @@
1162    
1163   #include <linux/proc_fs.h>   #include <linux/proc_fs.h>
1164   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1165  +#include <linux/tomoyo_socket.h>  +#include <linux/ccsecurity.h>
1166    
1167   struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];   struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1168   DEFINE_RWLOCK(raw_v6_lock);   DEFINE_RWLOCK(raw_v6_lock);
# Line 1145  Source code for this patch is "apt-get i Line 1176  Source code for this patch is "apt-get i
1176    
1177          copied = skb->len;          copied = skb->len;
1178          if (copied > len) {          if (copied > len) {
1179  --- linux-2.6.18-24etch2.orig/net/ipv6/udp.c  --- linux-2.6.18-26etch1.orig/net/ipv6/udp.c
1180  +++ linux-2.6.18-24etch2/net/ipv6/udp.c  +++ linux-2.6.18-26etch1/net/ipv6/udp.c
1181  @@ -58,6 +58,8 @@  @@ -58,6 +58,7 @@
1182    
1183   #include <linux/proc_fs.h>   #include <linux/proc_fs.h>
1184   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1185  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1186    
1187   DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;   DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1188    
1189  @@ -88,6 +90,8 @@ static int udp_v6_get_port(struct sock *  @@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1190                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1191                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1192                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
# Line 1165  Source code for this patch is "apt-get i Line 1195  Source code for this patch is "apt-get i
1195                                  goto gotit;                                  goto gotit;
1196                          }                          }
1197                          size = 0;                          size = 0;
1198  @@ -104,6 +108,8 @@ static int udp_v6_get_port(struct sock *  @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1199                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1200                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1201                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
# Line 1174  Source code for this patch is "apt-get i Line 1204  Source code for this patch is "apt-get i
1204                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1205                                  break;                                  break;
1206                  }                  }
1207  @@ -237,6 +243,9 @@ try_again:  @@ -237,6 +242,9 @@ try_again:
1208          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1209          if (!skb)          if (!skb)
1210                  goto out;                  goto out;
# Line 1184  Source code for this patch is "apt-get i Line 1214  Source code for this patch is "apt-get i
1214    
1215          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1216          if (copied > len) {          if (copied > len) {
1217  --- linux-2.6.18-24etch2.orig/net/socket.c  --- linux-2.6.18-26etch1.orig/net/socket.c
1218  +++ linux-2.6.18-24etch2/net/socket.c  +++ linux-2.6.18-26etch1/net/socket.c
1219  @@ -94,6 +94,9 @@  @@ -94,6 +94,8 @@
1220   #include <net/sock.h>   #include <net/sock.h>
1221   #include <linux/netfilter.h>   #include <linux/netfilter.h>
1222    
1223  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1224  +  +
1225   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1226   static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,   static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1227                           size_t size, loff_t pos);                           size_t size, loff_t pos);
1228  @@ -590,9 +593,12 @@ static inline int __sock_sendmsg(struct  @@ -590,9 +592,10 @@ static inline int __sock_sendmsg(struct
1229          si->size = size;          si->size = size;
1230    
1231          err = security_socket_sendmsg(sock, msg, size);          err = security_socket_sendmsg(sock, msg, size);
1232  +       if (!err)  +       if (!err)
1233  +               err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)  +               err = ccs_socket_sendmsg_permission(sock, msg, size);
 +                                                   msg->msg_name,  
 +                                                   msg->msg_namelen);  
1234          if (err)          if (err)
1235                  return err;                  return err;
1236  -  -
1237          return sock->ops->sendmsg(iocb, sock, msg, size);          return sock->ops->sendmsg(iocb, sock, msg, size);
1238   }   }
1239    
1240  @@ -1149,6 +1155,8 @@ static int __sock_create(int family, int  @@ -1149,6 +1152,8 @@ static int __sock_create(int family, int
1241          }          }
1242    
1243          err = security_socket_create(family, type, protocol, kern);          err = security_socket_create(family, type, protocol, kern);
# Line 1219  Source code for this patch is "apt-get i Line 1246  Source code for this patch is "apt-get i
1246          if (err)          if (err)
1247                  return err;                  return err;
1248                                    
1249  @@ -1343,6 +1351,11 @@ asmlinkage long sys_bind(int fd, struct  @@ -1343,6 +1348,11 @@ asmlinkage long sys_bind(int fd, struct
1250                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
1251                          err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);                          err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);
1252                          if (!err)                          if (!err)
# Line 1231  Source code for this patch is "apt-get i Line 1258  Source code for this patch is "apt-get i
1258                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
1259                                          (struct sockaddr *)address, addrlen);                                          (struct sockaddr *)address, addrlen);
1260                  }                  }
1261  @@ -1371,6 +1384,8 @@ asmlinkage long sys_listen(int fd, int b  @@ -1371,6 +1381,8 @@ asmlinkage long sys_listen(int fd, int b
1262    
1263                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
1264                  if (!err)                  if (!err)
# Line 1240  Source code for this patch is "apt-get i Line 1267  Source code for this patch is "apt-get i
1267                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
1268    
1269                  fput_light(sock->file, fput_needed);                  fput_light(sock->file, fput_needed);
1270  @@ -1434,6 +1449,11 @@ asmlinkage long sys_accept(int fd, struc  @@ -1434,6 +1446,11 @@ asmlinkage long sys_accept(int fd, struc
1271          if (err < 0)          if (err < 0)
1272                  goto out_fd;                  goto out_fd;
1273    
# Line 1252  Source code for this patch is "apt-get i Line 1279  Source code for this patch is "apt-get i
1279          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1280                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1281                          err = -ECONNABORTED;                          err = -ECONNABORTED;
1282  @@ -1488,9 +1508,11 @@ asmlinkage long sys_connect(int fd, stru  @@ -1488,9 +1505,11 @@ asmlinkage long sys_connect(int fd, stru
1283                  goto out_put;                  goto out_put;
1284    
1285          err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);          err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
# Line 1265  Source code for this patch is "apt-get i Line 1292  Source code for this patch is "apt-get i
1292          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1293                                   sock->file->f_flags);                                   sock->file->f_flags);
1294   out_put:   out_put:
1295  --- linux-2.6.18-24etch2.orig/net/unix/af_unix.c  --- linux-2.6.18-26etch1.orig/net/unix/af_unix.c
1296  +++ linux-2.6.18-24etch2/net/unix/af_unix.c  +++ linux-2.6.18-26etch1/net/unix/af_unix.c
1297  @@ -116,6 +116,7 @@  @@ -116,6 +116,7 @@
1298   #include <linux/mount.h>   #include <linux/mount.h>
1299   #include <net/checksum.h>   #include <net/checksum.h>
1300   #include <linux/security.h>   #include <linux/security.h>
1301  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1302    
1303   int sysctl_unix_max_dgram_qlen = 10;   int sysctl_unix_max_dgram_qlen = 10;
1304    
# Line 1279  Source code for this patch is "apt-get i Line 1306  Source code for this patch is "apt-get i
1306                   */                   */
1307                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1308                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1309  +               err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1310  +                                                nd.mnt, mode, 0);  +                                          mode, 0);
1311  +               if (!err)  +               if (!err)
1312                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1313                  if (err)                  if (err)
1314                          goto out_mknod_dput;                          goto out_mknod_dput;
1315    --- linux-2.6.18-26etch1.orig/security/Kconfig
1316    +++ linux-2.6.18-26etch1/security/Kconfig
1317    @@ -107,5 +107,7 @@ config SECURITY_SECLVL
1318    
1319     source security/selinux/Kconfig
1320    
1321    +source security/ccsecurity/Kconfig
1322    +
1323     endmenu
1324    
1325    --- linux-2.6.18-26etch1.orig/security/Makefile
1326    +++ linux-2.6.18-26etch1/security/Makefile
1327    @@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX)                += selin
1328     obj-$(CONFIG_SECURITY_CAPABILITIES)    += commoncap.o capability.o
1329     obj-$(CONFIG_SECURITY_ROOTPLUG)                += commoncap.o root_plug.o
1330     obj-$(CONFIG_SECURITY_SECLVL)          += seclvl.o
1331    +
1332    +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1333    +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

Legend:
Removed from v.2855  
changed lines
  Added in v.3150

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