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

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 3054 by kumaneko, Fri Sep 18 04:30:43 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 ++  
15   fs/attr.c                       |    5 +++++   fs/attr.c                       |    5 +++++
16   fs/compat.c                     |    9 ++++++++-   fs/compat.c                     |    9 ++++++++-
17   fs/exec.c                       |   12 +++++++++++-   fs/exec.c                       |   12 +++++++++++-
18   fs/fcntl.c                      |    5 +++++   fs/fcntl.c                      |    4 ++++
19   fs/ioctl.c                      |    5 +++++   fs/ioctl.c                      |    5 +++++
20   fs/namei.c                      |   38 ++++++++++++++++++++++++++++++++++++++   fs/namei.c                      |   32 ++++++++++++++++++++++++++++++++
21   fs/namespace.c                  |   28 +++++++++++++++++++++++++++-   fs/namespace.c                  |   23 ++++++++++++++++++++++-
22   fs/open.c                       |   14 ++++++++++++++   fs/open.c                       |   29 +++++++++++++++++++++++++++++
  fs/proc/Makefile                |    3 +++  
23   fs/proc/proc_misc.c             |    1 +   fs/proc/proc_misc.c             |    1 +
24   include/linux/init_task.h       |    2 ++   include/linux/init_task.h       |    9 +++++++++
25   include/linux/sched.h           |    4 ++++   include/linux/sched.h           |    6 ++++++
26   kernel/compat.c                 |    3 +++   kernel/compat.c                 |    3 +++
27   kernel/kexec.c                  |    3 +++   kernel/kexec.c                  |    3 +++
28   kernel/kmod.c                   |    3 +++   kernel/kmod.c                   |    5 +++++
29   kernel/module.c                 |    7 +++++--   kernel/module.c                 |    7 +++++--
30   kernel/ptrace.c                 |    3 +++   kernel/ptrace.c                 |    3 +++
31   kernel/sched.c                  |    3 +++   kernel/sched.c                  |    3 +++
32   kernel/signal.c                 |    7 +++++++   kernel/signal.c                 |    9 +++++++++
33   kernel/sys.c                    |   11 +++++++++++   kernel/sys.c                    |   11 +++++++++++
34   kernel/sysctl.c                 |   11 +++++++++++   kernel/sysctl.c                 |   11 +++++++++++
35   kernel/time.c                   |    7 +++++++   kernel/time.c                   |    7 +++++++
36   net/ipv4/inet_connection_sock.c |    3 +++   net/ipv4/inet_connection_sock.c |    3 +++
37   net/ipv4/inet_hashtables.c      |    3 +++   net/ipv4/inet_hashtables.c      |    3 +++
38   net/ipv4/raw.c                  |    4 ++++   net/ipv4/raw.c                  |    4 ++++
39   net/ipv4/udp.c                  |   11 ++++++++++-   net/ipv4/udp.c                  |   10 +++++++++-
40   net/ipv6/inet6_hashtables.c     |    5 ++++-   net/ipv6/inet6_hashtables.c     |    5 ++++-
41   net/ipv6/raw.c                  |    4 ++++   net/ipv6/raw.c                  |    4 ++++
42   net/ipv6/udp.c                  |    9 +++++++++   net/ipv6/udp.c                  |    8 ++++++++
43   net/socket.c                    |   26 ++++++++++++++++++++++++--   net/socket.c                    |   25 +++++++++++++++++++++++--
44   net/unix/af_unix.c              |    4 ++++   net/unix/af_unix.c              |    4 ++++
45   43 files changed, 282 insertions(+), 9 deletions(-)   security/Kconfig                |    2 ++
46     security/Makefile               |    3 +++
47     42 files changed, 293 insertions(+), 9 deletions(-)
48    
49  --- linux-2.6.18-24etch2.orig/arch/alpha/kernel/ptrace.c  --- linux-2.6.18-24etch4.orig/arch/alpha/kernel/ptrace.c
50  +++ linux-2.6.18-24etch2/arch/alpha/kernel/ptrace.c  +++ linux-2.6.18-24etch4/arch/alpha/kernel/ptrace.c
51  @@ -20,6 +20,7 @@  @@ -20,6 +20,7 @@
52   #include <asm/pgtable.h>   #include <asm/pgtable.h>
53   #include <asm/system.h>   #include <asm/system.h>
54   #include <asm/fpu.h>   #include <asm/fpu.h>
55  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
56    
57   #include "proto.h"   #include "proto.h"
58    
# Line 66  Source code for this patch is "apt-get i Line 65  Source code for this patch is "apt-get i
65    
66          lock_kernel();          lock_kernel();
67          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",
68  --- linux-2.6.18-24etch2.orig/arch/ia64/ia32/sys_ia32.c  --- linux-2.6.18-24etch4.orig/arch/ia64/ia32/sys_ia32.c
69  +++ linux-2.6.18-24etch2/arch/ia64/ia32/sys_ia32.c  +++ linux-2.6.18-24etch4/arch/ia64/ia32/sys_ia32.c
70  @@ -56,6 +56,7 @@  @@ -56,6 +56,7 @@
71   #include <asm/types.h>   #include <asm/types.h>
72   #include <asm/uaccess.h>   #include <asm/uaccess.h>
73   #include <asm/unistd.h>   #include <asm/unistd.h>
74  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
75    
76   #include "ia32priv.h"   #include "ia32priv.h"
77    
# Line 85  Source code for this patch is "apt-get i Line 84  Source code for this patch is "apt-get i
84    
85          lock_kernel();          lock_kernel();
86          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
87  --- linux-2.6.18-24etch2.orig/arch/ia64/kernel/ptrace.c  --- linux-2.6.18-24etch4.orig/arch/ia64/kernel/ptrace.c
88  +++ linux-2.6.18-24etch2/arch/ia64/kernel/ptrace.c  +++ linux-2.6.18-24etch4/arch/ia64/kernel/ptrace.c
89  @@ -28,6 +28,7 @@  @@ -28,6 +28,7 @@
90   #ifdef CONFIG_PERFMON   #ifdef CONFIG_PERFMON
91   #include <asm/perfmon.h>   #include <asm/perfmon.h>
92   #endif   #endif
93  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
94    
95   #include "entry.h"   #include "entry.h"
96    
# Line 104  Source code for this patch is "apt-get i Line 103  Source code for this patch is "apt-get i
103    
104          lock_kernel();          lock_kernel();
105          ret = -EPERM;          ret = -EPERM;
106  --- linux-2.6.18-24etch2.orig/arch/m32r/kernel/ptrace.c  --- linux-2.6.18-24etch4.orig/arch/m32r/kernel/ptrace.c
107  +++ linux-2.6.18-24etch2/arch/m32r/kernel/ptrace.c  +++ linux-2.6.18-24etch4/arch/m32r/kernel/ptrace.c
108  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
109   #include <asm/system.h>   #include <asm/system.h>
110   #include <asm/processor.h>   #include <asm/processor.h>
111   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
112  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
113    
114   /*   /*
115    * 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 123  Source code for this patch is "apt-get i Line 122  Source code for this patch is "apt-get i
122    
123          lock_kernel();          lock_kernel();
124          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
125  --- linux-2.6.18-24etch2.orig/arch/mips/kernel/ptrace32.c  --- linux-2.6.18-24etch4.orig/arch/mips/kernel/ptrace32.c
126  +++ linux-2.6.18-24etch2/arch/mips/kernel/ptrace32.c  +++ linux-2.6.18-24etch4/arch/mips/kernel/ptrace32.c
127  @@ -35,6 +35,7 @@  @@ -35,6 +35,7 @@
128   #include <asm/system.h>   #include <asm/system.h>
129   #include <asm/uaccess.h>   #include <asm/uaccess.h>
130   #include <asm/bootinfo.h>   #include <asm/bootinfo.h>
131  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
132    
133   int ptrace_getregs (struct task_struct *child, __s64 __user *data);   int ptrace_getregs (struct task_struct *child, __s64 __user *data);
134   int ptrace_setregs (struct task_struct *child, __s64 __user *data);   int ptrace_setregs (struct task_struct *child, __s64 __user *data);
# Line 142  Source code for this patch is "apt-get i Line 141  Source code for this patch is "apt-get i
141    
142   #if 0   #if 0
143          printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",          printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
144  --- linux-2.6.18-24etch2.orig/arch/powerpc/kernel/ptrace32.c  --- linux-2.6.18-24etch4.orig/arch/powerpc/kernel/ptrace32.c
145  +++ linux-2.6.18-24etch2/arch/powerpc/kernel/ptrace32.c  +++ linux-2.6.18-24etch4/arch/powerpc/kernel/ptrace32.c
146  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
147   #include <asm/page.h>   #include <asm/page.h>
148   #include <asm/pgtable.h>   #include <asm/pgtable.h>
149   #include <asm/system.h>   #include <asm/system.h>
150  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
151    
152   #include "ptrace-common.h"   #include "ptrace-common.h"
153    
# Line 161  Source code for this patch is "apt-get i Line 160  Source code for this patch is "apt-get i
160    
161          lock_kernel();          lock_kernel();
162          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
163  --- linux-2.6.18-24etch2.orig/arch/s390/kernel/ptrace.c  --- linux-2.6.18-24etch4.orig/arch/s390/kernel/ptrace.c
164  +++ linux-2.6.18-24etch2/arch/s390/kernel/ptrace.c  +++ linux-2.6.18-24etch4/arch/s390/kernel/ptrace.c
165  @@ -41,6 +41,7 @@  @@ -41,6 +41,7 @@
166   #include <asm/system.h>   #include <asm/system.h>
167   #include <asm/uaccess.h>   #include <asm/uaccess.h>
168   #include <asm/unistd.h>   #include <asm/unistd.h>
169  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
170    
171   #ifdef CONFIG_COMPAT   #ifdef CONFIG_COMPAT
172   #include "compat_ptrace.h"   #include "compat_ptrace.h"
# Line 180  Source code for this patch is "apt-get i Line 179  Source code for this patch is "apt-get i
179          lock_kernel();          lock_kernel();
180          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
181                   ret = ptrace_traceme();                   ret = ptrace_traceme();
182  --- linux-2.6.18-24etch2.orig/arch/sparc/kernel/ptrace.c  --- linux-2.6.18-24etch4.orig/arch/sparc/kernel/ptrace.c
183  +++ linux-2.6.18-24etch2/arch/sparc/kernel/ptrace.c  +++ linux-2.6.18-24etch4/arch/sparc/kernel/ptrace.c
184  @@ -23,6 +23,7 @@  @@ -23,6 +23,7 @@
185   #include <asm/pgtable.h>   #include <asm/pgtable.h>
186   #include <asm/system.h>   #include <asm/system.h>
187   #include <asm/uaccess.h>   #include <asm/uaccess.h>
188  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
189    
190   #define MAGIC_CONSTANT 0x80000000   #define MAGIC_CONSTANT 0x80000000
191    
# Line 201  Source code for this patch is "apt-get i Line 200  Source code for this patch is "apt-get i
200    
201          lock_kernel();          lock_kernel();
202   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
203  --- linux-2.6.18-24etch2.orig/arch/sparc64/kernel/ptrace.c  --- linux-2.6.18-24etch4.orig/arch/sparc64/kernel/ptrace.c
204  +++ linux-2.6.18-24etch2/arch/sparc64/kernel/ptrace.c  +++ linux-2.6.18-24etch4/arch/sparc64/kernel/ptrace.c
205  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
206   #include <asm/spitfire.h>   #include <asm/spitfire.h>
207   #include <asm/page.h>   #include <asm/page.h>
208   #include <asm/cpudata.h>   #include <asm/cpudata.h>
209  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
210    
211   /* Returning from ptrace is a bit tricky because the syscall return   /* Returning from ptrace is a bit tricky because the syscall return
212    * low level code assumes any value returned which is negative and    * low level code assumes any value returned which is negative and
# Line 222  Source code for this patch is "apt-get i Line 221  Source code for this patch is "apt-get i
221    
222          if (test_thread_flag(TIF_32BIT)) {          if (test_thread_flag(TIF_32BIT)) {
223                  addr &= 0xffffffffUL;                  addr &= 0xffffffffUL;
224  --- linux-2.6.18-24etch2.orig/arch/x86_64/ia32/ptrace32.c  --- linux-2.6.18-24etch4.orig/arch/x86_64/ia32/ptrace32.c
225  +++ linux-2.6.18-24etch2/arch/x86_64/ia32/ptrace32.c  +++ linux-2.6.18-24etch4/arch/x86_64/ia32/ptrace32.c
226  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
227   #include <asm/i387.h>   #include <asm/i387.h>
228   #include <asm/fpu32.h>   #include <asm/fpu32.h>
229   #include <asm/ia32.h>   #include <asm/ia32.h>
230  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
231    
232   /*   /*
233    * 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 241  Source code for this patch is "apt-get i Line 240  Source code for this patch is "apt-get i
240    
241          switch (request) {          switch (request) {
242          case PTRACE_TRACEME:          case PTRACE_TRACEME:
243  --- linux-2.6.18-24etch2.orig/fs/Kconfig  --- linux-2.6.18-24etch4.orig/fs/attr.c
244  +++ linux-2.6.18-24etch2/fs/Kconfig  +++ linux-2.6.18-24etch4/fs/attr.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  
245  @@ -15,6 +15,7 @@  @@ -15,6 +15,7 @@
246   #include <linux/fcntl.h>   #include <linux/fcntl.h>
247   #include <linux/quotaops.h>   #include <linux/quotaops.h>
248   #include <linux/security.h>   #include <linux/security.h>
249  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
250    
251   /* Taken over from the old code... */   /* Taken over from the old code... */
252    
# Line 273  Source code for this patch is "apt-get i Line 254  Source code for this patch is "apt-get i
254          if (inode->i_op && inode->i_op->setattr) {          if (inode->i_op && inode->i_op->setattr) {
255                  error = security_inode_setattr(dentry, attr);                  error = security_inode_setattr(dentry, attr);
256                  if (!error)                  if (!error)
257  +                       error = ccs_check_setattr_permission(dentry, attr);  +                       error = ccs_setattr_permission(dentry, attr);
258  +               if (!error)  +               if (!error)
259                          error = inode->i_op->setattr(dentry, attr);                          error = inode->i_op->setattr(dentry, attr);
260          } else {          } else {
# Line 281  Source code for this patch is "apt-get i Line 262  Source code for this patch is "apt-get i
262                  if (!error)                  if (!error)
263                          error = security_inode_setattr(dentry, attr);                          error = security_inode_setattr(dentry, attr);
264  +               if (!error)  +               if (!error)
265  +                       error = ccs_check_setattr_permission(dentry, attr);  +                       error = ccs_setattr_permission(dentry, attr);
266                  if (!error) {                  if (!error) {
267                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
268                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
269  --- linux-2.6.18-24etch2.orig/fs/compat.c  --- linux-2.6.18-24etch4.orig/fs/compat.c
270  +++ linux-2.6.18-24etch2/fs/compat.c  +++ linux-2.6.18-24etch4/fs/compat.c
271  @@ -52,6 +52,7 @@  @@ -52,6 +52,7 @@
272   #include <asm/uaccess.h>   #include <asm/uaccess.h>
273   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
274   #include <asm/ioctls.h>   #include <asm/ioctls.h>
275  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
276    
277   extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);   extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
278    
# Line 324  Source code for this patch is "apt-get i Line 305  Source code for this patch is "apt-get i
305          if (retval >= 0) {          if (retval >= 0) {
306                  free_arg_pages(bprm);                  free_arg_pages(bprm);
307    
308  --- linux-2.6.18-24etch2.orig/fs/exec.c  --- linux-2.6.18-24etch4.orig/fs/exec.c
309  +++ linux-2.6.18-24etch2/fs/exec.c  +++ linux-2.6.18-24etch4/fs/exec.c
310  @@ -57,6 +57,8 @@  @@ -57,6 +57,8 @@
311   #include <linux/kmod.h>   #include <linux/kmod.h>
312   #endif   #endif
313    
314  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
315  +  +
316   int core_uses_pid;   int core_uses_pid;
317   char core_pattern[65] = "core";   char core_pattern[65] = "core";
# Line 339  Source code for this patch is "apt-get i Line 320  Source code for this patch is "apt-get i
320          if (error)          if (error)
321                  goto exit;                  goto exit;
322    
323  +       error = ccs_check_uselib_permission(nd.dentry, nd.mnt);  +       error = ccs_uselib_permission(nd.dentry, nd.mnt);
324  +       if (error)  +       if (error)
325  +               goto exit;  +               goto exit;
326  +  +
# Line 351  Source code for this patch is "apt-get i Line 332  Source code for this patch is "apt-get i
332                      S_ISREG(inode->i_mode)) {                      S_ISREG(inode->i_mode)) {
333                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
334  +                       if (!err)  +                       if (!err)
335  +                               err = ccs_check_open_exec_permission(nd.dentry,  +                               err = ccs_open_exec_permission(nd.dentry,
336  +                                                                    nd.mnt);  +                                                                    nd.mnt);
337                          file = ERR_PTR(err);                          file = ERR_PTR(err);
338                          if (!err) {                          if (!err) {
# Line 366  Source code for this patch is "apt-get i Line 347  Source code for this patch is "apt-get i
347          if (retval >= 0) {          if (retval >= 0) {
348                  free_arg_pages(bprm);                  free_arg_pages(bprm);
349    
350  --- linux-2.6.18-24etch2.orig/fs/fcntl.c  --- linux-2.6.18-24etch4.orig/fs/fcntl.c
351  +++ linux-2.6.18-24etch2/fs/fcntl.c  +++ linux-2.6.18-24etch4/fs/fcntl.c
352  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
353   #include <asm/poll.h>   #include <asm/poll.h>
354   #include <asm/siginfo.h>   #include <asm/siginfo.h>
355   #include <asm/uaccess.h>   #include <asm/uaccess.h>
356  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
357    
358   void fastcall set_close_on_exec(unsigned int fd, int flag)   void fastcall set_close_on_exec(unsigned int fd, int flag)
359   {   {
360  @@ -214,6 +215,10 @@ static int setfl(int fd, struct file * f  @@ -214,6 +215,9 @@ static int setfl(int fd, struct file * f
361          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
362                  return -EPERM;                  return -EPERM;
363    
364  +       if (((arg ^ filp->f_flags) & O_APPEND) &&  +       if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp))
 +           ccs_check_rewrite_permission(filp))  
365  +               return -EPERM;  +               return -EPERM;
366  +  +
367          /* O_NOATIME can only be set by the owner or superuser */          /* O_NOATIME can only be set by the owner or superuser */
368          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
369                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
370  --- linux-2.6.18-24etch2.orig/fs/ioctl.c  --- linux-2.6.18-24etch4.orig/fs/ioctl.c
371  +++ linux-2.6.18-24etch2/fs/ioctl.c  +++ linux-2.6.18-24etch4/fs/ioctl.c
372  @@ -15,6 +15,7 @@  @@ -15,6 +15,7 @@
373    
374   #include <asm/uaccess.h>   #include <asm/uaccess.h>
375   #include <asm/ioctls.h>   #include <asm/ioctls.h>
376  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
377    
378   static long do_ioctl(struct file *filp, unsigned int cmd,   static long do_ioctl(struct file *filp, unsigned int cmd,
379                  unsigned long arg)                  unsigned long arg)
# Line 411  Source code for this patch is "apt-get i Line 391  Source code for this patch is "apt-get i
391    
392          error = security_file_ioctl(filp, cmd, arg);          error = security_file_ioctl(filp, cmd, arg);
393  +       if (!error)  +       if (!error)
394  +               error = ccs_check_ioctl_permission(filp, cmd, arg);  +               error = ccs_ioctl_permission(filp, cmd, arg);
395          if (error)          if (error)
396                  goto out_fput;                  goto out_fput;
397    
398  --- linux-2.6.18-24etch2.orig/fs/namei.c  --- linux-2.6.18-24etch4.orig/fs/namei.c
399  +++ linux-2.6.18-24etch2/fs/namei.c  +++ linux-2.6.18-24etch4/fs/namei.c
400  @@ -37,6 +37,8 @@  @@ -37,6 +37,8 @@
401    
402   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
403    
404  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
405  +  +
406   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
407    * 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 411  Source code for this patch is "apt-get i
411                          return -EPERM;                          return -EPERM;
412    
413  +       /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
414  +       error = ccs_check_open_permission(dentry, nd->mnt, flag);  +       error = ccs_open_permission(dentry, nd->mnt, flag);
415  +       if (error)  +       if (error)
416  +               return error;  +               return error;
417  +  +
# Line 442  Source code for this patch is "apt-get i Line 422  Source code for this patch is "apt-get i
422          return 0;          return 0;
423   }   }
424    
425  +#include <linux/tomoyo_vfs.h>  +#include <linux/ccsecurity_vfs.h>
426   /*   /*
427    *     open_namei()    *     open_namei()
428    *    *
# Line 450  Source code for this patch is "apt-get i Line 430  Source code for this patch is "apt-get i
430          if (!path.dentry->d_inode) {          if (!path.dentry->d_inode) {
431                  if (!IS_POSIXACL(dir->d_inode))                  if (!IS_POSIXACL(dir->d_inode))
432                          mode &= ~current->fs->umask;                          mode &= ~current->fs->umask;
433  +               error = ccs_check_mknod_permission(dir->d_inode, path.dentry,  +               error = ccs_mknod_permission(dir->d_inode, path.dentry,
434  +                                                  nd->mnt, mode, 0);  +                                            nd->mnt, mode, 0);
435  +               if (!error)  +               if (!error)
436                  error = vfs_create(dir->d_inode, path.dentry, mode, nd);                  error = vfs_create(dir->d_inode, path.dentry, mode, nd);
437                  mutex_unlock(&dir->d_inode->i_mutex);                  mutex_unlock(&dir->d_inode->i_mutex);
438                  dput(nd->dentry);                  dput(nd->dentry);
439  @@ -1848,6 +1859,10 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1848,6 +1859,9 @@ asmlinkage long sys_mknodat(int dfd, con
440          if (!IS_POSIXACL(nd.dentry->d_inode))          if (!IS_POSIXACL(nd.dentry->d_inode))
441                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
442          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
443  +               error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
444  +                                                  nd.mnt, mode,  +                                            nd.mnt, mode, dev);
 +                                                  new_decode_dev(dev));  
445  +               if (!error)  +               if (!error)
446                  switch (mode & S_IFMT) {                  switch (mode & S_IFMT) {
447                  case 0: case S_IFREG:                  case 0: case S_IFREG:
448                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
449  @@ -1921,6 +1936,10 @@ asmlinkage long sys_mkdirat(int dfd, con  @@ -1921,6 +1935,9 @@ asmlinkage long sys_mkdirat(int dfd, con
450                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
451                          if (!IS_POSIXACL(nd.dentry->d_inode))                          if (!IS_POSIXACL(nd.dentry->d_inode))
452                                  mode &= ~current->fs->umask;                                  mode &= ~current->fs->umask;
453  +                       error = ccs_check_mkdir_permission(nd.dentry->d_inode,  +                       error = ccs_mkdir_permission(nd.dentry->d_inode,
454  +                                                          dentry, nd.mnt,  +                                                    dentry, nd.mnt, mode);
 +                                                          mode);  
455  +                       if (!error)  +                       if (!error)
456                          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);                          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
457                          dput(dentry);                          dput(dentry);
458                  }                  }
459  @@ -2029,6 +2048,9 @@ static long do_rmdir(int dfd, const char  @@ -2029,6 +2046,9 @@ static long do_rmdir(int dfd, const char
460          dentry = lookup_hash(&nd);          dentry = lookup_hash(&nd);
461          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
462          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
463  +               error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,  +               error = ccs_rmdir_permission(nd.dentry->d_inode, dentry,
464  +                                                  nd.mnt);  +                                            nd.mnt);
465  +               if (!error)  +               if (!error)
466                  error = vfs_rmdir(nd.dentry->d_inode, dentry);                  error = vfs_rmdir(nd.dentry->d_inode, dentry);
467                  dput(dentry);                  dput(dentry);
468          }          }
469  @@ -2109,6 +2131,9 @@ static long do_unlinkat(int dfd, const c  @@ -2109,6 +2129,9 @@ static long do_unlinkat(int dfd, const c
470                  inode = dentry->d_inode;                  inode = dentry->d_inode;
471                  if (inode)                  if (inode)
472                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
473  +               error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,  +               error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
474  +                                                   nd.mnt);  +                                             nd.mnt);
475  +               if (!error)  +               if (!error)
476                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
477          exit2:          exit2:
478                  dput(dentry);                  dput(dentry);
479  @@ -2187,6 +2212,10 @@ asmlinkage long sys_symlinkat(const char  @@ -2187,6 +2210,9 @@ asmlinkage long sys_symlinkat(const char
480                  dentry = lookup_create(&nd, 0);                  dentry = lookup_create(&nd, 0);
481                  error = PTR_ERR(dentry);                  error = PTR_ERR(dentry);
482                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
483  +                       error = ccs_check_symlink_permission(nd.dentry->d_inode,  +                       error = ccs_symlink_permission(nd.dentry->d_inode,
484  +                                                            dentry, nd.mnt,  +                                                      dentry, nd.mnt, from);
 +                                                            from);  
485  +                       if (!error)  +                       if (!error)
486                          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);                          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
487                          dput(dentry);                          dput(dentry);
488                  }                  }
489  @@ -2281,6 +2310,10 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2281,6 +2307,9 @@ asmlinkage long sys_linkat(int olddfd, c
490          new_dentry = lookup_create(&nd, 0);          new_dentry = lookup_create(&nd, 0);
491          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
492          if (!IS_ERR(new_dentry)) {          if (!IS_ERR(new_dentry)) {
493  +               error = ccs_check_link_permission(old_nd.dentry,  +               error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode,
494  +                                                 nd.dentry->d_inode,  +                                           new_dentry, nd.mnt);
 +                                                 new_dentry, nd.mnt);  
495  +               if (!error)  +               if (!error)
496                  error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);                  error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
497                  dput(new_dentry);                  dput(new_dentry);
498          }          }
499  @@ -2507,6 +2540,11 @@ static int do_rename(int olddfd, const c  @@ -2507,6 +2536,9 @@ static int do_rename(int olddfd, const c
500          if (new_dentry == trap)          if (new_dentry == trap)
501                  goto exit5;                  goto exit5;
502    
503  +       error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,  +       error = ccs_rename_permission(old_dir->d_inode, old_dentry,
504  +                                           new_dir->d_inode, new_dentry,  +                                     new_dir->d_inode, new_dentry, newnd.mnt);
 +                                           newnd.mnt);  
505  +       if (!error)  +       if (!error)
 +  
506          error = vfs_rename(old_dir->d_inode, old_dentry,          error = vfs_rename(old_dir->d_inode, old_dentry,
507                                     new_dir->d_inode, new_dentry);                                     new_dir->d_inode, new_dentry);
508   exit5:   exit5:
509  --- linux-2.6.18-24etch2.orig/fs/namespace.c  --- linux-2.6.18-24etch4.orig/fs/namespace.c
510  +++ linux-2.6.18-24etch2/fs/namespace.c  +++ linux-2.6.18-24etch4/fs/namespace.c
511  @@ -25,6 +25,8 @@  @@ -25,6 +25,7 @@
512   #include <asm/uaccess.h>   #include <asm/uaccess.h>
513   #include <asm/unistd.h>   #include <asm/unistd.h>
514   #include "pnode.h"   #include "pnode.h"
515  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
516    
517   extern int __init init_rootfs(void);   extern int __init init_rootfs(void);
518    
519  @@ -553,6 +555,9 @@ static int do_umount(struct vfsmount *mn  @@ -550,6 +551,8 @@ static int do_umount(struct vfsmount *mn
520            LIST_HEAD(umount_list);
521    
522            retval = security_sb_umount(mnt, flags);
523    +       if (!retval)
524    +               retval = ccs_umount_permission(mnt, flags);
525          if (retval)          if (retval)
526                  return retval;                  return retval;
527    
528  +       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 *  
529   {   {
530          struct nameidata nd;          struct nameidata nd;
531          int retval;          int retval;
# Line 562  Source code for this patch is "apt-get i Line 534  Source code for this patch is "apt-get i
534    
535          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
536          if (retval)          if (retval)
537  @@ -925,6 +932,9 @@ static int do_loopback(struct nameidata  @@ -925,6 +930,9 @@ static int do_loopback(struct nameidata
538    
539          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
540                  goto out;                  goto out;
# Line 572  Source code for this patch is "apt-get i Line 544  Source code for this patch is "apt-get i
544    
545          err = -ENOMEM;          err = -ENOMEM;
546          if (recurse)          if (recurse)
547  @@ -1009,7 +1019,9 @@ static int do_move_mount(struct nameidat  @@ -1009,7 +1017,9 @@ static int do_move_mount(struct nameidat
548          err = -EINVAL;          err = -EINVAL;
549          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
550                  goto out;                  goto out;
551  -  -
552  +       err = -EPERM;  +       err = -EPERM;
553  +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
554  +               goto out;  +               goto out;
555          err = -ENOENT;          err = -ENOENT;
556          mutex_lock(&nd->dentry->d_inode->i_mutex);          mutex_lock(&nd->dentry->d_inode->i_mutex);
557          if (IS_DEADDIR(nd->dentry->d_inode))          if (IS_DEADDIR(nd->dentry->d_inode))
558  @@ -1111,6 +1123,9 @@ int do_add_mount(struct vfsmount *newmnt  @@ -1111,6 +1121,9 @@ int do_add_mount(struct vfsmount *newmnt
559          err = -EINVAL;          err = -EINVAL;
560          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
561                  goto unlock;                  goto unlock;
# Line 593  Source code for this patch is "apt-get i Line 565  Source code for this patch is "apt-get i
565    
566          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
567          if ((err = graft_tree(newmnt, nd)))          if ((err = graft_tree(newmnt, nd)))
568  @@ -1402,6 +1417,13 @@ long do_mount(char *dev_name, char *dir_  @@ -1384,6 +1397,7 @@ int copy_mount_options(const void __user
569          if (data_page)   long do_mount(char *dev_name, char *dir_name, char *type_page,
570                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                    unsigned long flags, void *data_page)
571     {
572  +       if (!ccs_capable(CCS_SYS_MOUNT))  +       const unsigned long original_flags = flags;
573  +               return -EPERM;          struct nameidata nd;
574  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,          int retval = 0;
575  +                                           &flags);          int mnt_flags = 0;
576  +       if (retval)  @@ -1423,6 +1437,9 @@ long do_mount(char *dev_name, char *dir_
577  +               return retval;                  return retval;
578  +  
579          /* Separate the per-mountpoint flags */          retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
580          if (flags & MS_NOSUID)  +       if (!retval)
581                  mnt_flags |= MNT_NOSUID;  +               retval = ccs_mount_permission(dev_name, &nd, type_page,
582  @@ -1691,6 +1713,8 @@ asmlinkage long sys_pivot_root(const cha  +                                             original_flags, data_page);
583            if (retval)
584                    goto dput_out;
585    
586    @@ -1691,6 +1708,8 @@ asmlinkage long sys_pivot_root(const cha
587    
588          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
589                  return -EPERM;                  return -EPERM;
# Line 616  Source code for this patch is "apt-get i Line 592  Source code for this patch is "apt-get i
592    
593          lock_kernel();          lock_kernel();
594    
595  @@ -1707,6 +1731,8 @@ asmlinkage long sys_pivot_root(const cha  @@ -1707,6 +1726,8 @@ asmlinkage long sys_pivot_root(const cha
596                  goto out1;                  goto out1;
597    
598          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
599  +       if (!error)  +       if (!error)
600  +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);  +               error = ccs_pivot_root_permission(&old_nd, &new_nd);
601          if (error) {          if (error) {
602                  path_release(&old_nd);                  path_release(&old_nd);
603                  goto out1;                  goto out1;
604  --- linux-2.6.18-24etch2.orig/fs/open.c  --- linux-2.6.18-24etch4.orig/fs/open.c
605  +++ linux-2.6.18-24etch2/fs/open.c  +++ linux-2.6.18-24etch4/fs/open.c
606  @@ -30,6 +30,8 @@  @@ -30,6 +30,7 @@
607   #include <linux/audit.h>   #include <linux/audit.h>
608    
609   #include <asm/unistd.h>   #include <asm/unistd.h>
610  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
611    
612   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
613   {   {
614  @@ -267,6 +269,8 @@ static long do_sys_truncate(const char _  @@ -267,6 +268,8 @@ static long do_sys_truncate(const char _
615          if (error)          if (error)
616                  goto dput_and_out;                  goto dput_and_out;
617    
618  +       error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);  +       error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
619  +       if (!error)  +       if (!error)
620          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
621          if (!error) {          if (!error) {
622                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
623  @@ -320,6 +324,10 @@ static long do_sys_ftruncate(unsigned in  @@ -320,6 +323,9 @@ static long do_sys_ftruncate(unsigned in
624          if (IS_APPEND(inode))          if (IS_APPEND(inode))
625                  goto out_putf;                  goto out_putf;
626    
627  +       error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,  +       error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
 +                                             0);  
628  +       if (error)  +       if (error)
629  +               goto out_putf;  +               goto out_putf;
630          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
631          if (!error)          if (!error)
632                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
633  @@ -608,6 +616,10 @@ asmlinkage long sys_chroot(const char __  @@ -608,6 +614,10 @@ asmlinkage long sys_chroot(const char __
634          error = -EPERM;          error = -EPERM;
635          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
636                  goto dput_and_out;                  goto dput_and_out;
637  +       if (!ccs_capable(CCS_SYS_CHROOT))  +       if (!ccs_capable(CCS_SYS_CHROOT))
638  +               goto dput_and_out;  +               goto dput_and_out;
639  +       if (ccs_check_chroot_permission(&nd))  +       if (ccs_chroot_permission(&nd))
640  +               goto dput_and_out;  +               goto dput_and_out;
641    
642          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
643          set_fs_altroot();          set_fs_altroot();
644  @@ -1199,6 +1211,8 @@ EXPORT_SYMBOL(sys_close);  @@ -641,6 +651,9 @@ asmlinkage long sys_fchmod(unsigned int
645            err = -EPERM;
646            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
647                    goto out_putf;
648    +       err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
649    +       if (err)
650    +               goto out_putf;
651            mutex_lock(&inode->i_mutex);
652            if (mode == (mode_t) -1)
653                    mode = inode->i_mode;
654    @@ -675,6 +688,9 @@ asmlinkage long sys_fchmodat(int dfd, co
655            error = -EPERM;
656            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
657                    goto dput_and_out;
658    +       error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
659    +       if (error)
660    +               goto dput_and_out;
661    
662            mutex_lock(&inode->i_mutex);
663            if (mode == (mode_t) -1)
664    @@ -737,6 +753,8 @@ asmlinkage long sys_chown(const char __u
665    
666            error = user_path_walk(filename, &nd);
667            if (!error) {
668    +               error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
669    +               if (!error)
670                    error = chown_common(nd.dentry, user, group);
671                    path_release(&nd);
672            }
673    @@ -756,6 +774,8 @@ asmlinkage long sys_fchownat(int dfd, co
674            follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
675            error = __user_walk_fd(dfd, filename, follow, &nd);
676            if (!error) {
677    +               error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
678    +               if (!error)
679                    error = chown_common(nd.dentry, user, group);
680                    path_release(&nd);
681            }
682    @@ -770,6 +790,8 @@ asmlinkage long sys_lchown(const char __
683    
684            error = user_path_walk_link(filename, &nd);
685            if (!error) {
686    +               error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
687    +               if (!error)
688                    error = chown_common(nd.dentry, user, group);
689                    path_release(&nd);
690            }
691    @@ -787,6 +809,9 @@ asmlinkage long sys_fchown(unsigned int
692                    struct dentry * dentry;
693                    dentry = file->f_dentry;
694                    audit_inode(NULL, dentry->d_inode);
695    +               error = ccs_chown_permission(dentry, file->f_vfsmnt, user,
696    +                                            group);
697    +               if (!error)
698                    error = chown_common(dentry, user, group);
699                    fput(file);
700            }
701    @@ -879,7 +904,9 @@ static struct file *do_filp_open(int dfd
702            if ((namei_flags+1) & O_ACCMODE)
703                    namei_flags++;
704    
705    +       ccs_save_open_mode(flags);
706            error = open_namei(dfd, filename, namei_flags, mode, &nd);
707    +       ccs_clear_open_mode();
708            if (!error)
709                    return nameidata_to_filp(&nd, flags);
710    
711    @@ -1199,6 +1226,8 @@ EXPORT_SYMBOL(sys_close);
712    */    */
713   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
714   {   {
# Line 676  Source code for this patch is "apt-get i Line 717  Source code for this patch is "apt-get i
717          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
718                  tty_vhangup(current->signal->tty);                  tty_vhangup(current->signal->tty);
719                  return 0;                  return 0;
720  --- linux-2.6.18-24etch2.orig/fs/proc/Makefile  --- linux-2.6.18-24etch4.orig/fs/proc/proc_misc.c
721  +++ linux-2.6.18-24etch2/fs/proc/Makefile  +++ linux-2.6.18-24etch4/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  
722  @@ -723,4 +723,5 @@ void __init proc_misc_init(void)  @@ -723,4 +723,5 @@ void __init proc_misc_init(void)
723          if (entry)          if (entry)
724                  entry->proc_fops = &proc_sysrq_trigger_operations;                  entry->proc_fops = &proc_sysrq_trigger_operations;
725   #endif   #endif
726  +       printk(KERN_INFO "Hook version: 2.6.18-24etch2 2009/08/05\n");  +       printk(KERN_INFO "Hook version: 2.6.18-24etch4 2009/09/17\n");
727   }   }
728  --- linux-2.6.18-24etch2.orig/include/linux/init_task.h  --- linux-2.6.18-24etch4.orig/include/linux/init_task.h
729  +++ linux-2.6.18-24etch2/include/linux/init_task.h  +++ linux-2.6.18-24etch4/include/linux/init_task.h
730  @@ -128,6 +128,8 @@ extern struct group_info init_groups;  @@ -76,6 +76,14 @@
731    
732     extern struct group_info init_groups;
733    
734    +#ifdef CONFIG_CCSECURITY
735    +#define INIT_CCSECURITY          \
736    +       .ccs_domain_info = NULL, \
737    +       .ccs_flags = 0,
738    +#else
739    +#define INIT_CCSECURITY
740    +#endif
741    +
742     /*
743      *  INIT_TASK is used to set up the first task table, touch at
744      * your own risk!. Base=0, limit=0x1fffff (=2MB)
745    @@ -128,6 +136,7 @@ extern struct group_info init_groups;
746          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \
747          INIT_TRACE_IRQFLAGS                                             \          INIT_TRACE_IRQFLAGS                                             \
748          INIT_LOCKDEP                                                    \          INIT_LOCKDEP                                                    \
749  +       .ccs_domain_info = NULL,                 \  +       INIT_CCSECURITY                                                 \
 +       .ccs_flags = 0,                          \  
750   }   }
751    
752    
753  --- linux-2.6.18-24etch2.orig/include/linux/sched.h  --- linux-2.6.18-24etch4.orig/include/linux/sched.h
754  +++ linux-2.6.18-24etch2/include/linux/sched.h  +++ linux-2.6.18-24etch4/include/linux/sched.h
755  @@ -25,6 +25,8 @@  @@ -25,6 +25,8 @@
756   #define CLONE_CHILD_SETTID     0x01000000      /* set the TID in the child */   #define CLONE_CHILD_SETTID     0x01000000      /* set the TID in the child */
757   #define CLONE_STOPPED          0x02000000      /* Start in stopped state */   #define CLONE_STOPPED          0x02000000      /* Start in stopped state */
# Line 715  Source code for this patch is "apt-get i Line 761  Source code for this patch is "apt-get i
761   /*   /*
762    * Scheduling policies    * Scheduling policies
763    */    */
764  @@ -996,6 +998,8 @@ struct task_struct {  @@ -996,6 +998,10 @@ struct task_struct {
765   #ifdef CONFIG_TASK_DELAY_ACCT   #ifdef CONFIG_TASK_DELAY_ACCT
766          struct task_delay_info *delays;          struct task_delay_info *delays;
767   #endif   #endif
768    +#ifdef CONFIG_CCSECURITY
769  +       struct ccs_domain_info *ccs_domain_info;  +       struct ccs_domain_info *ccs_domain_info;
770  +       u32 ccs_flags;  +       u32 ccs_flags;
771    +#endif
772   };   };
773    
774   static inline pid_t process_group(struct task_struct *tsk)   static inline pid_t process_group(struct task_struct *tsk)
775  --- linux-2.6.18-24etch2.orig/kernel/compat.c  --- linux-2.6.18-24etch4.orig/kernel/compat.c
776  +++ linux-2.6.18-24etch2/kernel/compat.c  +++ linux-2.6.18-24etch4/kernel/compat.c
777  @@ -24,6 +24,7 @@  @@ -24,6 +24,7 @@
778   #include <linux/migrate.h>   #include <linux/migrate.h>
779    
780   #include <asm/uaccess.h>   #include <asm/uaccess.h>
781  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
782    
783   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)
784   {   {
# Line 743  Source code for this patch is "apt-get i Line 791  Source code for this patch is "apt-get i
791    
792          do_settimeofday(&tv);          do_settimeofday(&tv);
793          return 0;          return 0;
794  --- linux-2.6.18-24etch2.orig/kernel/kexec.c  --- linux-2.6.18-24etch4.orig/kernel/kexec.c
795  +++ linux-2.6.18-24etch2/kernel/kexec.c  +++ linux-2.6.18-24etch4/kernel/kexec.c
796  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
797   #include <asm/io.h>   #include <asm/io.h>
798   #include <asm/system.h>   #include <asm/system.h>
799   #include <asm/semaphore.h>   #include <asm/semaphore.h>
800  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
801    
802   /* Per cpu memory for storing cpu states in case of system crash. */   /* Per cpu memory for storing cpu states in case of system crash. */
803   note_buf_t* crash_notes;   note_buf_t* crash_notes;
# Line 762  Source code for this patch is "apt-get i Line 810  Source code for this patch is "apt-get i
810    
811          /*          /*
812           * Verify we have a legal set of flags           * Verify we have a legal set of flags
813  --- linux-2.6.18-24etch2.orig/kernel/kmod.c  --- linux-2.6.18-24etch4.orig/kernel/kmod.c
814  +++ linux-2.6.18-24etch2/kernel/kmod.c  +++ linux-2.6.18-24etch4/kernel/kmod.c
815  @@ -148,6 +148,9 @@ static int ____call_usermodehelper(void  @@ -148,6 +148,11 @@ static int ____call_usermodehelper(void
816          /* We can run anywhere, unlike our parent keventd(). */          /* We can run anywhere, unlike our parent keventd(). */
817          set_cpus_allowed(current, CPU_MASK_ALL);          set_cpus_allowed(current, CPU_MASK_ALL);
818    
819    +#ifdef CONFIG_CCSECURITY
820  +       current->ccs_domain_info = NULL;  +       current->ccs_domain_info = NULL;
821  +       current->ccs_flags = 0;  +       current->ccs_flags = 0;
822    +#endif
823  +  +
824          retval = -EPERM;          retval = -EPERM;
825          if (current->fs->root)          if (current->fs->root)
826                  retval = execve(sub_info->path, sub_info->argv,sub_info->envp);                  retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
827  --- linux-2.6.18-24etch2.orig/kernel/module.c  --- linux-2.6.18-24etch4.orig/kernel/module.c
828  +++ linux-2.6.18-24etch2/kernel/module.c  +++ linux-2.6.18-24etch4/kernel/module.c
829  @@ -44,6 +44,7 @@  @@ -44,6 +44,7 @@
830   #include <asm/semaphore.h>   #include <asm/semaphore.h>
831   #include <asm/cacheflush.h>   #include <asm/cacheflush.h>
832   #include <linux/license.h>   #include <linux/license.h>
833  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
834    
835   #if 0   #if 0
836   #define DEBUGP printk   #define DEBUGP printk
# Line 804  Source code for this patch is "apt-get i Line 854  Source code for this patch is "apt-get i
854          /* Only one module load at a time, please */          /* Only one module load at a time, please */
855          if (mutex_lock_interruptible(&module_mutex) != 0)          if (mutex_lock_interruptible(&module_mutex) != 0)
856                  return -EINTR;                  return -EINTR;
857  --- linux-2.6.18-24etch2.orig/kernel/ptrace.c  --- linux-2.6.18-24etch4.orig/kernel/ptrace.c
858  +++ linux-2.6.18-24etch2/kernel/ptrace.c  +++ linux-2.6.18-24etch4/kernel/ptrace.c
859  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
860    
861   #include <asm/pgtable.h>   #include <asm/pgtable.h>
862   #include <asm/uaccess.h>   #include <asm/uaccess.h>
863  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
864    
865   /*   /*
866    * ptrace a task: make the debugger its new parent and    * ptrace a task: make the debugger its new parent and
# Line 823  Source code for this patch is "apt-get i Line 873  Source code for this patch is "apt-get i
873          lock_kernel();          lock_kernel();
874          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
875                  ret = ptrace_traceme();                  ret = ptrace_traceme();
876  --- linux-2.6.18-24etch2.orig/kernel/sched.c  --- linux-2.6.18-24etch4.orig/kernel/sched.c
877  +++ linux-2.6.18-24etch2/kernel/sched.c  +++ linux-2.6.18-24etch4/kernel/sched.c
878  @@ -55,6 +55,7 @@  @@ -55,6 +55,7 @@
879   #include <asm/tlb.h>   #include <asm/tlb.h>
880    
881   #include <asm/unistd.h>   #include <asm/unistd.h>
882  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
883    
884   /*   /*
885    * 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 892  Source code for this patch is "apt-get i
892    
893          /*          /*
894           * Setpriority might change our priority at the same moment.           * Setpriority might change our priority at the same moment.
895  --- linux-2.6.18-24etch2.orig/kernel/signal.c  --- linux-2.6.18-24etch4.orig/kernel/signal.c
896  +++ linux-2.6.18-24etch2/kernel/signal.c  +++ linux-2.6.18-24etch4/kernel/signal.c
897  @@ -28,6 +28,7 @@  @@ -28,6 +28,7 @@
898   #include <asm/unistd.h>   #include <asm/unistd.h>
899   #include <asm/siginfo.h>   #include <asm/siginfo.h>
900   #include "audit.h"     /* audit_signal_info() */   #include "audit.h"     /* audit_signal_info() */
901  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
902    
903   /*   /*
904    * SLAB caches for signal bits.    * SLAB caches for signal bits.
# Line 879  Source code for this patch is "apt-get i Line 929  Source code for this patch is "apt-get i
929    
930          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
931   }   }
932  --- linux-2.6.18-24etch2.orig/kernel/sys.c  @@ -2271,6 +2278,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
933  +++ linux-2.6.18-24etch2/kernel/sys.c          if (info.si_code >= 0)
934                    return -EPERM;
935            info.si_signo = sig;
936    +       if (ccs_sigqueue_permission(pid, sig))
937    +               return -EPERM;
938    
939            /* POSIX.1b doesn't mention process groups.  */
940            return kill_proc_info(sig, &info, pid);
941    --- linux-2.6.18-24etch4.orig/kernel/sys.c
942    +++ linux-2.6.18-24etch4/kernel/sys.c
943  @@ -36,6 +36,7 @@  @@ -36,6 +36,7 @@
944   #include <asm/uaccess.h>   #include <asm/uaccess.h>
945   #include <asm/io.h>   #include <asm/io.h>
946   #include <asm/unistd.h>   #include <asm/unistd.h>
947  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
948    
949   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
950   # 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 986  Source code for this patch is "apt-get i
986    
987          down_write(&uts_sem);          down_write(&uts_sem);
988          errno = -EFAULT;          errno = -EFAULT;
989  --- linux-2.6.18-24etch2.orig/kernel/sysctl.c  --- linux-2.6.18-24etch4.orig/kernel/sysctl.c
990  +++ linux-2.6.18-24etch2/kernel/sysctl.c  +++ linux-2.6.18-24etch4/kernel/sysctl.c
991  @@ -48,6 +48,7 @@  @@ -48,6 +48,7 @@
992    
993   #include <asm/uaccess.h>   #include <asm/uaccess.h>
994   #include <asm/processor.h>   #include <asm/processor.h>
995  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
996    
997   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,
998                        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 1020  Source code for this patch is "apt-get i
1020                                          error = table->strategy(                                          error = table->strategy(
1021                                                  table, name, nlen,                                                  table, name, nlen,
1022                                                  oldval, oldlenp,                                                  oldval, oldlenp,
1023  --- linux-2.6.18-24etch2.orig/kernel/time.c  --- linux-2.6.18-24etch4.orig/kernel/time.c
1024  +++ linux-2.6.18-24etch2/kernel/time.c  +++ linux-2.6.18-24etch4/kernel/time.c
1025  @@ -39,6 +39,7 @@  @@ -39,6 +39,7 @@
1026    
1027   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1028   #include <asm/unistd.h>   #include <asm/unistd.h>
1029  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1030    
1031   /*   /*
1032    * 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 1057  Source code for this patch is "apt-get i
1057                                    
1058          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
1059    
1060  --- linux-2.6.18-24etch2.orig/net/ipv4/inet_connection_sock.c  --- linux-2.6.18-24etch4.orig/net/ipv4/inet_connection_sock.c
1061  +++ linux-2.6.18-24etch2/net/ipv4/inet_connection_sock.c  +++ linux-2.6.18-24etch4/net/ipv4/inet_connection_sock.c
1062  @@ -23,6 +23,7 @@  @@ -23,6 +23,7 @@
1063   #include <net/route.h>   #include <net/route.h>
1064   #include <net/tcp_states.h>   #include <net/tcp_states.h>
1065   #include <net/xfrm.h>   #include <net/xfrm.h>
1066  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1067    
1068   #ifdef INET_CSK_DEBUG   #ifdef INET_CSK_DEBUG
1069   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 1076  Source code for this patch is "apt-get i
1076                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
1077                                  if (tb->port == rover)                                  if (tb->port == rover)
1078                                          goto next;                                          goto next;
1079  --- linux-2.6.18-24etch2.orig/net/ipv4/inet_hashtables.c  --- linux-2.6.18-24etch4.orig/net/ipv4/inet_hashtables.c
1080  +++ linux-2.6.18-24etch2/net/ipv4/inet_hashtables.c  +++ linux-2.6.18-24etch4/net/ipv4/inet_hashtables.c
1081  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
1082   #include <net/inet_connection_sock.h>   #include <net/inet_connection_sock.h>
1083   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1084   #include <net/ip.h>   #include <net/ip.h>
1085  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1086    
1087   /*   /*
1088    * 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 1095  Source code for this patch is "apt-get i
1095                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1096                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1097    
1098  --- linux-2.6.18-24etch2.orig/net/ipv4/raw.c  --- linux-2.6.18-24etch4.orig/net/ipv4/raw.c
1099  +++ linux-2.6.18-24etch2/net/ipv4/raw.c  +++ linux-2.6.18-24etch4/net/ipv4/raw.c
1100  @@ -79,6 +79,7 @@  @@ -79,6 +79,7 @@
1101   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1102   #include <linux/netfilter.h>   #include <linux/netfilter.h>
1103   #include <linux/netfilter_ipv4.h>   #include <linux/netfilter_ipv4.h>
1104  +#include <linux/tomoyo_socket.h>  +#include <linux/ccsecurity.h>
1105    
1106   struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];   struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1107   DEFINE_RWLOCK(raw_v4_lock);   DEFINE_RWLOCK(raw_v4_lock);
# Line 1056  Source code for this patch is "apt-get i Line 1115  Source code for this patch is "apt-get i
1115    
1116          copied = skb->len;          copied = skb->len;
1117          if (len < copied) {          if (len < copied) {
1118  --- linux-2.6.18-24etch2.orig/net/ipv4/udp.c  --- linux-2.6.18-24etch4.orig/net/ipv4/udp.c
1119  +++ linux-2.6.18-24etch2/net/ipv4/udp.c  +++ linux-2.6.18-24etch4/net/ipv4/udp.c
1120  @@ -108,6 +108,8 @@  @@ -108,6 +108,7 @@
1121   #include <net/inet_common.h>   #include <net/inet_common.h>
1122   #include <net/checksum.h>   #include <net/checksum.h>
1123   #include <net/xfrm.h>   #include <net/xfrm.h>
1124  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1125    
1126   /*   /*
1127    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
1128  @@ -146,6 +148,8 @@ static int udp_v4_get_port(struct sock *  @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1129                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1130                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1131                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
# Line 1076  Source code for this patch is "apt-get i Line 1134  Source code for this patch is "apt-get i
1134                                  goto gotit;                                  goto gotit;
1135                          }                          }
1136                          size = 0;                          size = 0;
1137  @@ -162,6 +166,8 @@ static int udp_v4_get_port(struct sock *  @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1138                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1139                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1140                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
# Line 1085  Source code for this patch is "apt-get i Line 1143  Source code for this patch is "apt-get i
1143                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1144                                  break;                                  break;
1145                  }                  }
1146  @@ -796,7 +802,10 @@ try_again:  @@ -796,7 +801,10 @@ try_again:
1147          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1148          if (!skb)          if (!skb)
1149                  goto out;                  goto out;
# Line 1097  Source code for this patch is "apt-get i Line 1155  Source code for this patch is "apt-get i
1155          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1156          if (copied > len) {          if (copied > len) {
1157                  copied = len;                  copied = len;
1158  --- linux-2.6.18-24etch2.orig/net/ipv6/inet6_hashtables.c  --- linux-2.6.18-24etch4.orig/net/ipv6/inet6_hashtables.c
1159  +++ linux-2.6.18-24etch2/net/ipv6/inet6_hashtables.c  +++ linux-2.6.18-24etch4/net/ipv6/inet6_hashtables.c
1160  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
1161   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1162   #include <net/inet6_hashtables.h>   #include <net/inet6_hashtables.h>
1163   #include <net/ip.h>   #include <net/ip.h>
1164  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1165    
1166   void __inet6_hash(struct inet_hashinfo *hashinfo,   void __inet6_hash(struct inet_hashinfo *hashinfo,
1167                                  struct sock *sk)                                  struct sock *sk)
# Line 1125  Source code for this patch is "apt-get i Line 1183  Source code for this patch is "apt-get i
1183                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1184                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1185    
1186  --- linux-2.6.18-24etch2.orig/net/ipv6/raw.c  --- linux-2.6.18-24etch4.orig/net/ipv6/raw.c
1187  +++ linux-2.6.18-24etch2/net/ipv6/raw.c  +++ linux-2.6.18-24etch4/net/ipv6/raw.c
1188  @@ -56,6 +56,7 @@  @@ -56,6 +56,7 @@
1189    
1190   #include <linux/proc_fs.h>   #include <linux/proc_fs.h>
1191   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1192  +#include <linux/tomoyo_socket.h>  +#include <linux/ccsecurity.h>
1193    
1194   struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];   struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1195   DEFINE_RWLOCK(raw_v6_lock);   DEFINE_RWLOCK(raw_v6_lock);
# Line 1145  Source code for this patch is "apt-get i Line 1203  Source code for this patch is "apt-get i
1203    
1204          copied = skb->len;          copied = skb->len;
1205          if (copied > len) {          if (copied > len) {
1206  --- linux-2.6.18-24etch2.orig/net/ipv6/udp.c  --- linux-2.6.18-24etch4.orig/net/ipv6/udp.c
1207  +++ linux-2.6.18-24etch2/net/ipv6/udp.c  +++ linux-2.6.18-24etch4/net/ipv6/udp.c
1208  @@ -58,6 +58,8 @@  @@ -58,6 +58,7 @@
1209    
1210   #include <linux/proc_fs.h>   #include <linux/proc_fs.h>
1211   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1212  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1213    
1214   DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;   DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1215    
1216  @@ -88,6 +90,8 @@ static int udp_v6_get_port(struct sock *  @@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1217                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1218                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1219                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
# Line 1165  Source code for this patch is "apt-get i Line 1222  Source code for this patch is "apt-get i
1222                                  goto gotit;                                  goto gotit;
1223                          }                          }
1224                          size = 0;                          size = 0;
1225  @@ -104,6 +108,8 @@ static int udp_v6_get_port(struct sock *  @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1226                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1227                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1228                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
# Line 1174  Source code for this patch is "apt-get i Line 1231  Source code for this patch is "apt-get i
1231                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1232                                  break;                                  break;
1233                  }                  }
1234  @@ -237,6 +243,9 @@ try_again:  @@ -237,6 +242,9 @@ try_again:
1235          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1236          if (!skb)          if (!skb)
1237                  goto out;                  goto out;
# Line 1184  Source code for this patch is "apt-get i Line 1241  Source code for this patch is "apt-get i
1241    
1242          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1243          if (copied > len) {          if (copied > len) {
1244  --- linux-2.6.18-24etch2.orig/net/socket.c  --- linux-2.6.18-24etch4.orig/net/socket.c
1245  +++ linux-2.6.18-24etch2/net/socket.c  +++ linux-2.6.18-24etch4/net/socket.c
1246  @@ -94,6 +94,9 @@  @@ -94,6 +94,8 @@
1247   #include <net/sock.h>   #include <net/sock.h>
1248   #include <linux/netfilter.h>   #include <linux/netfilter.h>
1249    
1250  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1251  +  +
1252   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1253   static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,   static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1254                           size_t size, loff_t pos);                           size_t size, loff_t pos);
1255  @@ -590,9 +593,12 @@ static inline int __sock_sendmsg(struct  @@ -590,9 +592,12 @@ static inline int __sock_sendmsg(struct
1256          si->size = size;          si->size = size;
1257    
1258          err = security_socket_sendmsg(sock, msg, size);          err = security_socket_sendmsg(sock, msg, size);
# Line 1210  Source code for this patch is "apt-get i Line 1266  Source code for this patch is "apt-get i
1266          return sock->ops->sendmsg(iocb, sock, msg, size);          return sock->ops->sendmsg(iocb, sock, msg, size);
1267   }   }
1268    
1269  @@ -1149,6 +1155,8 @@ static int __sock_create(int family, int  @@ -1149,6 +1154,8 @@ static int __sock_create(int family, int
1270          }          }
1271    
1272          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 1275  Source code for this patch is "apt-get i
1275          if (err)          if (err)
1276                  return err;                  return err;
1277                                    
1278  @@ -1343,6 +1351,11 @@ asmlinkage long sys_bind(int fd, struct  @@ -1343,6 +1350,11 @@ asmlinkage long sys_bind(int fd, struct
1279                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
1280                          err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);                          err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);
1281                          if (!err)                          if (!err)
# Line 1231  Source code for this patch is "apt-get i Line 1287  Source code for this patch is "apt-get i
1287                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
1288                                          (struct sockaddr *)address, addrlen);                                          (struct sockaddr *)address, addrlen);
1289                  }                  }
1290  @@ -1371,6 +1384,8 @@ asmlinkage long sys_listen(int fd, int b  @@ -1371,6 +1383,8 @@ asmlinkage long sys_listen(int fd, int b
1291    
1292                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
1293                  if (!err)                  if (!err)
# Line 1240  Source code for this patch is "apt-get i Line 1296  Source code for this patch is "apt-get i
1296                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
1297    
1298                  fput_light(sock->file, fput_needed);                  fput_light(sock->file, fput_needed);
1299  @@ -1434,6 +1449,11 @@ asmlinkage long sys_accept(int fd, struc  @@ -1434,6 +1448,11 @@ asmlinkage long sys_accept(int fd, struc
1300          if (err < 0)          if (err < 0)
1301                  goto out_fd;                  goto out_fd;
1302    
# Line 1252  Source code for this patch is "apt-get i Line 1308  Source code for this patch is "apt-get i
1308          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1309                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1310                          err = -ECONNABORTED;                          err = -ECONNABORTED;
1311  @@ -1488,9 +1508,11 @@ asmlinkage long sys_connect(int fd, stru  @@ -1488,9 +1507,11 @@ asmlinkage long sys_connect(int fd, stru
1312                  goto out_put;                  goto out_put;
1313    
1314          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 1321  Source code for this patch is "apt-get i
1321          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1322                                   sock->file->f_flags);                                   sock->file->f_flags);
1323   out_put:   out_put:
1324  --- linux-2.6.18-24etch2.orig/net/unix/af_unix.c  --- linux-2.6.18-24etch4.orig/net/unix/af_unix.c
1325  +++ linux-2.6.18-24etch2/net/unix/af_unix.c  +++ linux-2.6.18-24etch4/net/unix/af_unix.c
1326  @@ -116,6 +116,7 @@  @@ -116,6 +116,7 @@
1327   #include <linux/mount.h>   #include <linux/mount.h>
1328   #include <net/checksum.h>   #include <net/checksum.h>
1329   #include <linux/security.h>   #include <linux/security.h>
1330  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1331    
1332   int sysctl_unix_max_dgram_qlen = 10;   int sysctl_unix_max_dgram_qlen = 10;
1333    
# Line 1279  Source code for this patch is "apt-get i Line 1335  Source code for this patch is "apt-get i
1335                   */                   */
1336                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1337                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1338  +               err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1339  +                                                nd.mnt, mode, 0);  +                                          mode, 0);
1340  +               if (!err)  +               if (!err)
1341                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1342                  if (err)                  if (err)
1343                          goto out_mknod_dput;                          goto out_mknod_dput;
1344    --- linux-2.6.18-24etch4.orig/security/Kconfig
1345    +++ linux-2.6.18-24etch4/security/Kconfig
1346    @@ -107,5 +107,7 @@ config SECURITY_SECLVL
1347    
1348     source security/selinux/Kconfig
1349    
1350    +source security/ccsecurity/Kconfig
1351    +
1352     endmenu
1353    
1354    --- linux-2.6.18-24etch4.orig/security/Makefile
1355    +++ linux-2.6.18-24etch4/security/Makefile
1356    @@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX)                += selin
1357     obj-$(CONFIG_SECURITY_CAPABILITIES)    += commoncap.o capability.o
1358     obj-$(CONFIG_SECURITY_ROOTPLUG)                += commoncap.o root_plug.o
1359     obj-$(CONFIG_SECURITY_SECLVL)          += seclvl.o
1360    +
1361    +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1362    +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

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

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