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

Subversion リポジトリの参照

Diff of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.21.diff

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

trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.21.diff revision 2282 by kumaneko, Thu Mar 19 04:46:42 2009 UTC trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.21.diff revision 3111 by kumaneko, Tue Oct 20 03:12:41 2009 UTC
# Line 2  This is TOMOYO Linux patch for kernel 2. Line 2  This is TOMOYO Linux patch for kernel 2.
2    
3  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.7.tar.bz2  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.7.tar.bz2
4  ---  ---
5   arch/alpha/kernel/ptrace.c      |    7 ++   arch/alpha/kernel/ptrace.c      |    3 +++
6   arch/ia64/ia32/sys_ia32.c       |    7 ++   arch/ia64/ia32/sys_ia32.c       |    3 +++
7   arch/ia64/kernel/ptrace.c       |    7 ++   arch/ia64/kernel/ptrace.c       |    3 +++
8   arch/m32r/kernel/ptrace.c       |    7 ++   arch/m32r/kernel/ptrace.c       |    3 +++
9   arch/mips/kernel/ptrace32.c     |    7 ++   arch/mips/kernel/ptrace32.c     |    3 +++
10   arch/powerpc/kernel/ptrace32.c  |    7 ++   arch/powerpc/kernel/ptrace32.c  |    3 +++
11   arch/s390/kernel/ptrace.c       |    7 ++   arch/s390/kernel/ptrace.c       |    3 +++
12   arch/sparc/kernel/ptrace.c      |    9 +++   arch/sparc/kernel/ptrace.c      |    5 +++++
13   arch/sparc64/kernel/ptrace.c    |    9 +++   arch/sparc64/kernel/ptrace.c    |    5 +++++
14   arch/x86_64/ia32/ptrace32.c     |    7 ++   arch/x86_64/ia32/ptrace32.c     |    3 +++
15   fs/Kconfig                      |    2   fs/compat.c                     |    9 ++++++++-
16   fs/Makefile                     |    2   fs/exec.c                       |   11 ++++++++++-
17   fs/attr.c                       |   19 ++++++   fs/fcntl.c                      |    4 ++++
18   fs/compat.c                     |   15 +++++   fs/ioctl.c                      |    5 +++++
19   fs/exec.c                       |   20 ++++++-   fs/namei.c                      |   31 ++++++++++++++++++++++++++++++-
20   fs/fcntl.c                      |    9 +++   fs/namespace.c                  |   22 ++++++++++++++++++++++
21   fs/ioctl.c                      |   11 +++   fs/open.c                       |   28 ++++++++++++++++++++++++++++
22   fs/namei.c                      |  112 ++++++++++++++++++++++++++++++++++++++++   fs/proc/proc_misc.c             |    1 +
23   fs/namespace.c                  |   49 +++++++++++++++++   include/linux/init_task.h       |    9 +++++++++
24   fs/open.c                       |   27 +++++++++   include/linux/sched.h           |    6 ++++++
25   fs/proc/Makefile                |    3 +   kernel/compat.c                 |    3 +++
26   fs/proc/proc_misc.c             |    5 +   kernel/kexec.c                  |    3 +++
27   include/linux/init_task.h       |    4 +   kernel/kmod.c                   |    5 +++++
28   include/linux/sched.h           |    8 ++   kernel/module.c                 |    5 +++++
29   kernel/compat.c                 |    7 ++   kernel/ptrace.c                 |    3 +++
30   kernel/kexec.c                  |    7 ++   kernel/sched.c                  |    3 +++
31   kernel/kmod.c                   |    5 +   kernel/signal.c                 |    9 +++++++++
32   kernel/module.c                 |   11 +++   kernel/sys.c                    |   11 +++++++++++
33   kernel/ptrace.c                 |    7 ++   kernel/sysctl.c                 |    5 +++++
34   kernel/sched.c                  |    7 ++   kernel/time.c                   |    5 +++++
35   kernel/signal.c                 |   21 +++++++   kernel/time/ntp.c               |    3 +++
36   kernel/sys.c                    |   21 +++++++   net/ipv4/inet_connection_sock.c |    3 +++
37   kernel/sysctl.c                 |   95 +++++++++++++++++++++++++++++++++   net/ipv4/inet_hashtables.c      |    3 +++
38   kernel/time.c                   |   11 +++   net/ipv4/raw.c                  |    4 ++++
39   kernel/time/ntp.c               |    7 ++   net/ipv4/udp.c                  |    8 ++++++++
40   net/core/datagram.c             |   11 +++   net/ipv6/inet6_hashtables.c     |    3 +++
41   net/ipv4/inet_connection_sock.c |    7 ++   net/ipv6/raw.c                  |    4 ++++
42   net/ipv4/inet_hashtables.c      |    7 ++   net/ipv6/udp.c                  |    4 ++++
43   net/ipv4/udp.c                  |   11 +++   net/socket.c                    |   21 +++++++++++++++++++++
44   net/ipv6/inet6_hashtables.c     |    7 ++   net/unix/af_unix.c              |    4 ++++
45   net/socket.c                    |   41 ++++++++++++++   security/Kconfig                |    2 ++
46   net/unix/af_unix.c              |   15 +++++   security/Makefile               |    3 +++
47   42 files changed, 656 insertions(+), 2 deletions(-)   42 files changed, 271 insertions(+), 3 deletions(-)
48    
49  --- linux-2.6.21.7.orig/arch/alpha/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/alpha/kernel/ptrace.c
50  +++ linux-2.6.21.7/arch/alpha/kernel/ptrace.c  +++ linux-2.6.21.7/arch/alpha/kernel/ptrace.c
51  @@ -20,6 +20,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
56    
57   #include "proto.h"   #include "proto.h"
58    
59  @@ -268,6 +271,10 @@ do_sys_ptrace(long request, long pid, lo  @@ -268,6 +269,8 @@ do_sys_ptrace(long request, long pid, lo
60          unsigned long tmp;          unsigned long tmp;
61          size_t copied;          size_t copied;
62          long ret;          long ret;
63  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
64  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
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.21.7.orig/arch/ia64/ia32/sys_ia32.c  --- linux-2.6.21.7.orig/arch/ia64/ia32/sys_ia32.c
69  +++ linux-2.6.21.7/arch/ia64/ia32/sys_ia32.c  +++ linux-2.6.21.7/arch/ia64/ia32/sys_ia32.c
70  @@ -56,6 +56,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
75    
76   #include "ia32priv.h"   #include "ia32priv.h"
77    
78  @@ -1758,6 +1761,10 @@ sys32_ptrace (int request, pid_t pid, un  @@ -1758,6 +1759,8 @@ sys32_ptrace (int request, pid_t pid, un
79          struct task_struct *child;          struct task_struct *child;
80          unsigned int value, tmp;          unsigned int value, tmp;
81          long i, ret;          long i, ret;
82  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
83  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
84    
85          lock_kernel();          lock_kernel();
86          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
87  --- linux-2.6.21.7.orig/arch/ia64/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/ia64/kernel/ptrace.c
88  +++ linux-2.6.21.7/arch/ia64/kernel/ptrace.c  +++ linux-2.6.21.7/arch/ia64/kernel/ptrace.c
89  @@ -28,6 +28,9 @@  @@ -28,6 +28,7 @@
90   #ifdef CONFIG_PERFMON   #ifdef CONFIG_PERFMON
91   #include <asm/perfmon.h>   #include <asm/perfmon.h>
92   #endif   #endif
93  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
94    
95   #include "entry.h"   #include "entry.h"
96    
97  @@ -1418,6 +1421,10 @@ sys_ptrace (long request, pid_t pid, uns  @@ -1418,6 +1419,8 @@ sys_ptrace (long request, pid_t pid, uns
98          struct task_struct *child;          struct task_struct *child;
99          struct switch_stack *sw;          struct switch_stack *sw;
100          long ret;          long ret;
101  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
102  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
103    
104          lock_kernel();          lock_kernel();
105          ret = -EPERM;          ret = -EPERM;
106  --- linux-2.6.21.7.orig/arch/m32r/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/m32r/kernel/ptrace.c
107  +++ linux-2.6.21.7/arch/m32r/kernel/ptrace.c  +++ linux-2.6.21.7/arch/m32r/kernel/ptrace.c
108  @@ -32,6 +32,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
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.
116  @@ -742,6 +745,10 @@ asmlinkage long sys_ptrace(long request,  @@ -742,6 +743,8 @@ asmlinkage long sys_ptrace(long request,
117   {   {
118          struct task_struct *child;          struct task_struct *child;
119          int ret;          int ret;
120  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
121  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
122    
123          lock_kernel();          lock_kernel();
124          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
125  --- linux-2.6.21.7.orig/arch/mips/kernel/ptrace32.c  --- linux-2.6.21.7.orig/arch/mips/kernel/ptrace32.c
126  +++ linux-2.6.21.7/arch/mips/kernel/ptrace32.c  +++ linux-2.6.21.7/arch/mips/kernel/ptrace32.c
127  @@ -35,6 +35,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
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);
135  @@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request,  @@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request,
136   {   {
137          struct task_struct *child;          struct task_struct *child;
138          int ret;          int ret;
139  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
140  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
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.21.7.orig/arch/powerpc/kernel/ptrace32.c  --- linux-2.6.21.7.orig/arch/powerpc/kernel/ptrace32.c
145  +++ linux-2.6.21.7/arch/powerpc/kernel/ptrace32.c  +++ linux-2.6.21.7/arch/powerpc/kernel/ptrace32.c
146  @@ -32,6 +32,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
151    
152   #include "ptrace-common.h"   #include "ptrace-common.h"
153    
154  @@ -45,6 +48,10 @@ long compat_sys_ptrace(int request, int  @@ -45,6 +46,8 @@ long compat_sys_ptrace(int request, int
155   {   {
156          struct task_struct *child;          struct task_struct *child;
157          int ret;          int ret;
158  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
159  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
160    
161          lock_kernel();          lock_kernel();
162          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
163  --- linux-2.6.21.7.orig/arch/s390/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/s390/kernel/ptrace.c
164  +++ linux-2.6.21.7/arch/s390/kernel/ptrace.c  +++ linux-2.6.21.7/arch/s390/kernel/ptrace.c
165  @@ -41,6 +41,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
170    
171   #ifdef CONFIG_COMPAT   #ifdef CONFIG_COMPAT
172   #include "compat_ptrace.h"   #include "compat_ptrace.h"
173  @@ -713,6 +716,10 @@ sys_ptrace(long request, long pid, long  @@ -713,6 +714,8 @@ sys_ptrace(long request, long pid, long
174          struct task_struct *child;          struct task_struct *child;
175          int ret;          int ret;
176    
177  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
178  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
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.21.7.orig/arch/sparc/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/sparc/kernel/ptrace.c
183  +++ linux-2.6.21.7/arch/sparc/kernel/ptrace.c  +++ linux-2.6.21.7/arch/sparc/kernel/ptrace.c
184  @@ -23,6 +23,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
189    
190   #define MAGIC_CONSTANT 0x80000000   #define MAGIC_CONSTANT 0x80000000
191    
192  @@ -267,6 +270,12 @@ asmlinkage void do_ptrace(struct pt_regs  @@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs
193          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
194          struct task_struct *child;          struct task_struct *child;
195          int ret;          int ret;
196  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid)) {
 +       if (!ccs_capable(CCS_SYS_PTRACE)) {  
197  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
198  +               return;  +               return;
199  +       }  +       }
 +       /***** TOMOYO Linux end. *****/  
200    
201          lock_kernel();          lock_kernel();
202   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
203  --- linux-2.6.21.7.orig/arch/sparc64/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/sparc64/kernel/ptrace.c
204  +++ linux-2.6.21.7/arch/sparc64/kernel/ptrace.c  +++ linux-2.6.21.7/arch/sparc64/kernel/ptrace.c
205  @@ -32,6 +32,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
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
213  @@ -176,6 +179,12 @@ asmlinkage void do_ptrace(struct pt_regs  @@ -176,6 +177,10 @@ asmlinkage void do_ptrace(struct pt_regs
214          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
215          struct task_struct *child;          struct task_struct *child;
216          int ret;          int ret;
217  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid)) {
 +       if (!ccs_capable(CCS_SYS_PTRACE)) {  
218  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
219  +               return;  +               return;
220  +       }  +       }
 +       /***** TOMOYO Linux end. *****/  
221    
222          if (test_thread_flag(TIF_32BIT)) {          if (test_thread_flag(TIF_32BIT)) {
223                  addr &= 0xffffffffUL;                  addr &= 0xffffffffUL;
224  --- linux-2.6.21.7.orig/arch/x86_64/ia32/ptrace32.c  --- linux-2.6.21.7.orig/arch/x86_64/ia32/ptrace32.c
225  +++ linux-2.6.21.7/arch/x86_64/ia32/ptrace32.c  +++ linux-2.6.21.7/arch/x86_64/ia32/ptrace32.c
226  @@ -26,6 +26,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
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].
234  @@ -234,6 +237,10 @@ asmlinkage long sys32_ptrace(long reques  @@ -234,6 +235,8 @@ asmlinkage long sys32_ptrace(long reques
235          void __user *datap = compat_ptr(data);          void __user *datap = compat_ptr(data);
236          int ret;          int ret;
237          __u32 val;          __u32 val;
238  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
239  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
240    
241          switch (request) {          switch (request) {
242          case PTRACE_TRACEME:          case PTRACE_TRACEME:
 --- linux-2.6.21.7.orig/fs/Kconfig  
 +++ linux-2.6.21.7/fs/Kconfig  
 @@ -2055,5 +2055,7 @@ endif  
  source "fs/nls/Kconfig"  
  source "fs/dlm/Kconfig"  
   
 +source "fs/Kconfig.ccs"  
 +  
  endmenu  
   
 --- linux-2.6.21.7.orig/fs/Makefile  
 +++ linux-2.6.21.7/fs/Makefile  
 @@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS)         += hppfs/  
  obj-$(CONFIG_DEBUG_FS)         += debugfs/  
  obj-$(CONFIG_OCFS2_FS)         += ocfs2/  
  obj-$(CONFIG_GFS2_FS)           += gfs2/  
 +  
 +include $(srctree)/fs/Makefile-2.6.ccs  
 --- linux-2.6.21.7.orig/fs/attr.c  
 +++ linux-2.6.21.7/fs/attr.c  
 @@ -15,6 +15,9 @@  
  #include <linux/fcntl.h>  
  #include <linux/quotaops.h>  
  #include <linux/security.h>  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
   
  /* Taken over from the old code... */  
   
 @@ -145,12 +148,28 @@ int notify_change(struct dentry * dentry  
   
         if (inode->i_op && inode->i_op->setattr) {  
                 error = security_inode_setattr(dentry, attr);  
 +               /***** TOMOYO Linux start. *****/  
 +               if (!error && (ia_valid & ATTR_MODE) &&  
 +                   !ccs_capable(CCS_SYS_CHMOD))  
 +                       error = -EPERM;  
 +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&  
 +                   !ccs_capable(CCS_SYS_CHOWN))  
 +                       error = -EPERM;  
 +               /***** TOMOYO Linux end. *****/  
                 if (!error)  
                         error = inode->i_op->setattr(dentry, attr);  
         } else {  
                 error = inode_change_ok(inode, attr);  
                 if (!error)  
                         error = security_inode_setattr(dentry, attr);  
 +               /***** TOMOYO Linux start. *****/  
 +               if (!error && (ia_valid & ATTR_MODE) &&  
 +                   !ccs_capable(CCS_SYS_CHMOD))  
 +                       error = -EPERM;  
 +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&  
 +                   !ccs_capable(CCS_SYS_CHOWN))  
 +                       error = -EPERM;  
 +               /***** TOMOYO Linux end. *****/  
                 if (!error) {  
                         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||  
                             (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))  
243  --- linux-2.6.21.7.orig/fs/compat.c  --- linux-2.6.21.7.orig/fs/compat.c
244  +++ linux-2.6.21.7/fs/compat.c  +++ linux-2.6.21.7/fs/compat.c
245  @@ -56,6 +56,9 @@  @@ -56,6 +56,7 @@
246   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
247   #include <asm/ioctls.h>   #include <asm/ioctls.h>
248   #include "internal.h"   #include "internal.h"
249  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
250    
251   int compat_log = 1;   int compat_log = 1;
252    
253  @@ -398,6 +401,10 @@ asmlinkage long compat_sys_ioctl(unsigne  @@ -398,6 +399,8 @@ asmlinkage long compat_sys_ioctl(unsigne
254    
255          /* RED-PEN how should LSM module know it's handling 32bit? */          /* RED-PEN how should LSM module know it's handling 32bit? */
256          error = security_file_ioctl(filp, cmd, arg);          error = security_file_ioctl(filp, cmd, arg);
 +       /***** TOMOYO Linux start. *****/  
257  +       if (!error)  +       if (!error)
258  +               error = ccs_check_ioctl_permission(filp, cmd, arg);  +               error = ccs_check_ioctl_permission(filp, cmd, arg);
 +       /***** TOMOYO Linux end. *****/  
259          if (error)          if (error)
260                  goto out_fput;                  goto out_fput;
261    
262  @@ -422,6 +429,12 @@ asmlinkage long compat_sys_ioctl(unsigne  @@ -422,6 +425,10 @@ asmlinkage long compat_sys_ioctl(unsigne
263                  /*FALL THROUGH*/                  /*FALL THROUGH*/
264    
265          default:          default:
 +               /***** TOMOYO Linux start. *****/  
266  +               if (!ccs_capable(CCS_SYS_IOCTL)) {  +               if (!ccs_capable(CCS_SYS_IOCTL)) {
267  +                       error = -EPERM;  +                       error = -EPERM;
268  +                       goto out_fput;  +                       goto out_fput;
269  +               }  +               }
 +               /***** TOMOYO Linux end. *****/  
270                  if (filp->f_op && filp->f_op->compat_ioctl) {                  if (filp->f_op && filp->f_op->compat_ioctl) {
271                          error = filp->f_op->compat_ioctl(filp, cmd, arg);                          error = filp->f_op->compat_ioctl(filp, cmd, arg);
272                          if (error != -ENOIOCTLCMD)                          if (error != -ENOIOCTLCMD)
273  @@ -1552,7 +1565,7 @@ int compat_do_execve(char * filename,  @@ -1552,7 +1559,7 @@ int compat_do_execve(char * filename,
274          if (retval < 0)          if (retval < 0)
275                  goto out;                  goto out;
276    
277  -       retval = search_binary_handler(bprm, regs);  -       retval = search_binary_handler(bprm, regs);
278  +       retval = search_binary_handler_with_transition(bprm, regs);  +       retval = ccs_search_binary_handler(bprm, regs);
279          if (retval >= 0) {          if (retval >= 0) {
280                  free_arg_pages(bprm);                  free_arg_pages(bprm);
281    
282  --- linux-2.6.21.7.orig/fs/exec.c  --- linux-2.6.21.7.orig/fs/exec.c
283  +++ linux-2.6.21.7/fs/exec.c  +++ linux-2.6.21.7/fs/exec.c
284  @@ -58,6 +58,10 @@  @@ -58,6 +58,8 @@
285   #include <linux/kmod.h>   #include <linux/kmod.h>
286   #endif   #endif
287    
288  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
289  +  +
290   int core_uses_pid;   int core_uses_pid;
291   char core_pattern[128] = "core";   char core_pattern[128] = "core";
292   int suid_dumpable = 0;   int suid_dumpable = 0;
293  @@ -140,6 +144,13 @@ asmlinkage long sys_uselib(const char __  @@ -140,6 +142,10 @@ asmlinkage long sys_uselib(const char __
294          if (error)          if (error)
295                  goto exit;                  goto exit;
296    
297  +       /***** TOMOYO Linux start. *****/  +       error = ccs_uselib_permission(nd.dentry, nd.mnt);
 +       /* 01 means "read". */  
 +       error = ccs_check_open_permission(nd.dentry, nd.mnt, 01);  
298  +       if (error)  +       if (error)
299  +               goto exit;  +               goto exit;
 +       /***** TOMOYO Linux end. *****/  
300  +  +
301          file = nameidata_to_filp(&nd, O_RDONLY);          file = nameidata_to_filp(&nd, O_RDONLY);
302          error = PTR_ERR(file);          error = PTR_ERR(file);
303          if (IS_ERR(file))          if (IS_ERR(file))
304  @@ -485,6 +496,13 @@ struct file *open_exec(const char *name)  @@ -485,6 +491,9 @@ struct file *open_exec(const char *name)
305                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
306                      S_ISREG(inode->i_mode)) {                      S_ISREG(inode->i_mode)) {
307                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
308  +                       /***** TOMOYO Linux start. *****/  +                       if (!err)
309  +                       if (!err && (current->ccs_flags &  +                               err = ccs_open_exec_permission(nd.dentry,
310  +                                    CCS_CHECK_READ_FOR_OPEN_EXEC))  +                                                                    nd.mnt);
 +                               /* 01 means "read". */  
 +                               err = ccs_check_open_permission(nd.dentry,  
 +                                                               nd.mnt, 01);  
 +                       /***** TOMOYO Linux end. *****/  
311                          file = ERR_PTR(err);                          file = ERR_PTR(err);
312                          if (!err) {                          if (!err) {
313                                  file = nameidata_to_filp(&nd, O_RDONLY);                                  file = nameidata_to_filp(&nd, O_RDONLY);
314  @@ -1183,7 +1201,7 @@ int do_execve(char * filename,  @@ -1183,7 +1192,7 @@ int do_execve(char * filename,
315          if (retval < 0)          if (retval < 0)
316                  goto out;                  goto out;
317    
318  -       retval = search_binary_handler(bprm,regs);  -       retval = search_binary_handler(bprm,regs);
319  +       retval = search_binary_handler_with_transition(bprm, regs);  +       retval = ccs_search_binary_handler(bprm, regs);
320          if (retval >= 0) {          if (retval >= 0) {
321                  free_arg_pages(bprm);                  free_arg_pages(bprm);
322    
323  --- linux-2.6.21.7.orig/fs/fcntl.c  --- linux-2.6.21.7.orig/fs/fcntl.c
324  +++ linux-2.6.21.7/fs/fcntl.c  +++ linux-2.6.21.7/fs/fcntl.c
325  @@ -22,6 +22,9 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
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  @@ -213,6 +216,12 @@ static int setfl(int fd, struct file * f  @@ -213,6 +214,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  +       /***** TOMOYO Linux start. *****/  +       if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp))
 +       if (((arg ^ filp->f_flags) & O_APPEND) &&  
 +           ccs_check_rewrite_permission(filp))  
338  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
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.21.7.orig/fs/ioctl.c  --- linux-2.6.21.7.orig/fs/ioctl.c
344  +++ linux-2.6.21.7/fs/ioctl.c  +++ linux-2.6.21.7/fs/ioctl.c
345  @@ -15,6 +15,9 @@  @@ -15,6 +15,7 @@
346    
347   #include <asm/uaccess.h>   #include <asm/uaccess.h>
348   #include <asm/ioctls.h>   #include <asm/ioctls.h>
349  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
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)
353  @@ -23,6 +26,10 @@ static long do_ioctl(struct file *filp,  @@ -23,6 +24,8 @@ static long do_ioctl(struct file *filp,
354    
355          if (!filp->f_op)          if (!filp->f_op)
356                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
357  +       if (!ccs_capable(CCS_SYS_IOCTL))  +       if (!ccs_capable(CCS_SYS_IOCTL))
358  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
359    
360          if (filp->f_op->unlocked_ioctl) {          if (filp->f_op->unlocked_ioctl) {
361                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
362  @@ -167,6 +174,10 @@ asmlinkage long sys_ioctl(unsigned int f  @@ -167,6 +170,8 @@ asmlinkage long sys_ioctl(unsigned int f
363                  goto out;                  goto out;
364    
365          error = security_file_ioctl(filp, cmd, arg);          error = security_file_ioctl(filp, cmd, arg);
 +       /***** TOMOYO Linux start. *****/  
366  +       if (!error)  +       if (!error)
367  +               error = ccs_check_ioctl_permission(filp, cmd, arg);  +               error = ccs_ioctl_permission(filp, cmd, arg);
 +       /***** TOMOYO Linux end. *****/  
368          if (error)          if (error)
369                  goto out_fput;                  goto out_fput;
370    
371  --- linux-2.6.21.7.orig/fs/namei.c  --- linux-2.6.21.7.orig/fs/namei.c
372  +++ linux-2.6.21.7/fs/namei.c  +++ linux-2.6.21.7/fs/namei.c
373  @@ -37,6 +37,10 @@  @@ -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  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
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)
381    * were necessary because of omirr.  The reason is that omirr needs    * were necessary because of omirr.  The reason is that omirr needs
382  @@ -1506,6 +1510,13 @@ int vfs_create(struct inode *dir, struct  @@ -1561,6 +1563,11 @@ int may_open(struct nameidata *nd, int a
         error = security_inode_create(dir, dentry, mode);  
         if (error)  
                 return error;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (nd) {  
 +               error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt);  
 +               if (error)  
 +                       return error;  
 +       }  
 +       /***** TOMOYO Linux end. *****/  
         DQUOT_INIT(dir);  
         error = dir->i_op->create(dir, dentry, mode, nd);  
         if (!error)  
 @@ -1561,6 +1572,13 @@ int may_open(struct nameidata *nd, int a  
383                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
384                          return -EPERM;                          return -EPERM;
385    
 +       /***** TOMOYO Linux start. *****/  
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;
 +       /***** TOMOYO Linux end. *****/  
390  +  +
391          /*          /*
392           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
393           */           */
394  @@ -1610,6 +1628,9 @@ static int open_namei_create(struct name  @@ -1600,6 +1607,9 @@ static int open_namei_create(struct name
395    
396            if (!IS_POSIXACL(dir->d_inode))
397                    mode &= ~current->fs->umask;
398    +       error = ccs_mknod_permission(dir->d_inode, path->dentry, nd->mnt, mode,
399    +                                    0);
400    +       if (!error)
401            error = vfs_create(dir->d_inode, path->dentry, mode, nd);
402            mutex_unlock(&dir->d_inode->i_mutex);
403            dput(nd->dentry);
404    @@ -1610,6 +1620,7 @@ static int open_namei_create(struct name
405          return may_open(nd, 0, flag & ~O_TRUNC);          return may_open(nd, 0, flag & ~O_TRUNC);
406   }   }
407    
408  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity_vfs.h>
 +#include <linux/tomoyo_vfs.h>  
 +/***** TOMOYO Linux end. *****/  
409   /*   /*
410    *     open_namei()    *     open_namei()
411    *    *
412  @@ -1870,6 +1891,16 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1883,6 +1894,9 @@ asmlinkage long sys_mknodat(int dfd, con
413            if (!IS_POSIXACL(nd.dentry->d_inode))
414          if (S_ISDIR(mode))                  mode &= ~current->fs->umask;
415                  return -EPERM;          if (!IS_ERR(dentry)) {
416  +       /***** TOMOYO Linux start. *****/  +               error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
417  +       if (S_ISCHR(mode) && !ccs_capable(CCS_CREATE_CHAR_DEV))  +                                            nd.mnt, mode, dev);
418  +               return -EPERM;  +               if (!error)
419  +       if (S_ISBLK(mode) && !ccs_capable(CCS_CREATE_BLOCK_DEV))                  switch (mode & S_IFMT) {
420  +               return -EPERM;                  case 0: case S_IFREG:
 +       if (S_ISFIFO(mode) && !ccs_capable(CCS_CREATE_FIFO))  
 +               return -EPERM;  
 +       if (S_ISSOCK(mode) && !ccs_capable(CCS_CREATE_UNIX_SOCKET))  
 +               return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
         tmp = getname(filename);  
         if (IS_ERR(tmp))  
                 return PTR_ERR(tmp);  
 @@ -1888,10 +1919,32 @@ asmlinkage long sys_mknodat(int dfd, con  
421                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
422                          break;  @@ -1959,6 +1973,8 @@ asmlinkage long sys_mkdirat(int dfd, con
                 case S_IFCHR: case S_IFBLK:  
 +                       /***** TOMOYO Linux start. *****/  
 +                       error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);  
 +                       if (error)  
 +                               break;  
 +                       error = ccs_check_1path_perm(S_ISCHR(mode) ?  
 +                                                    TYPE_MKCHAR_ACL :  
 +                                                    TYPE_MKBLOCK_ACL,  
 +                                                    dentry, nd.mnt);  
 +                       if (error)  
 +                               break;  
 +                       /***** TOMOYO Linux end. *****/  
                         error = vfs_mknod(nd.dentry->d_inode,dentry,mode,  
                                         new_decode_dev(dev));  
                         break;  
                 case S_IFIFO: case S_IFSOCK:  
 +                       /***** TOMOYO Linux start. *****/  
 +                       error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);  
 +                       if (error)  
 +                               break;  
 +                       error = ccs_check_1path_perm(S_ISFIFO(mode) ?  
 +                                                    TYPE_MKFIFO_ACL :  
 +                                                    TYPE_MKSOCK_ACL,  
 +                                                    dentry, nd.mnt);  
 +                       if (error)  
 +                               break;  
 +                       /***** TOMOYO Linux end. *****/  
                         error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);  
                         break;  
                 case S_IFDIR:  
 @@ -1959,6 +2012,12 @@ asmlinkage long sys_mkdirat(int dfd, con  
423    
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  +       /***** TOMOYO Linux start. *****/  +       error = ccs_mkdir_permission(nd.dentry->d_inode, dentry, nd.mnt, mode);
 +       error = pre_vfs_mkdir(nd.dentry->d_inode, dentry);  
 +       if (!error)  
 +               error = ccs_check_1path_perm(TYPE_MKDIR_ACL, dentry, nd.mnt);  
427  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
428          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
429          dput(dentry);          dput(dentry);
430   out_unlock:   out_unlock:
431  @@ -2066,6 +2125,12 @@ static long do_rmdir(int dfd, const char  @@ -2066,6 +2082,8 @@ static long do_rmdir(int dfd, const char
432          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
433          if (IS_ERR(dentry))          if (IS_ERR(dentry))
434                  goto exit2;                  goto exit2;
435  +       /***** TOMOYO Linux start. *****/  +       error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, nd.mnt);
 +       error = pre_vfs_rmdir(nd.dentry->d_inode, dentry);  
436  +       if (!error)  +       if (!error)
 +               error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, nd.mnt);  
 +       if (!error)  
 +       /***** TOMOYO Linux end. *****/  
437          error = vfs_rmdir(nd.dentry->d_inode, dentry);          error = vfs_rmdir(nd.dentry->d_inode, dentry);
438          dput(dentry);          dput(dentry);
439   exit2:   exit2:
440  @@ -2125,6 +2190,10 @@ static long do_unlinkat(int dfd, const c  @@ -2146,6 +2164,9 @@ static long do_unlinkat(int dfd, const c
         struct dentry *dentry;  
         struct nameidata nd;  
         struct inode *inode = NULL;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (!ccs_capable(CCS_SYS_UNLINK))  
 +               return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         name = getname(pathname);  
         if(IS_ERR(name))  
 @@ -2146,6 +2215,14 @@ static long do_unlinkat(int dfd, const c  
441                  inode = dentry->d_inode;                  inode = dentry->d_inode;
442                  if (inode)                  if (inode)
443                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
444  +               /***** TOMOYO Linux start. *****/  +               error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
445  +               error = pre_vfs_unlink(nd.dentry->d_inode, dentry);  +                                             nd.mnt);
446  +               if (error)  +               if (!error)
 +                       goto exit2;  
 +               error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt);  
 +               if (error)  
 +                       goto exit2;  
 +               /***** TOMOYO Linux end. *****/  
447                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
448          exit2:          exit2:
449                  dput(dentry);                  dput(dentry);
450  @@ -2210,6 +2287,10 @@ asmlinkage long sys_symlinkat(const char  @@ -2227,6 +2248,9 @@ asmlinkage long sys_symlinkat(const char
         char * to;  
         struct dentry *dentry;  
         struct nameidata nd;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (!ccs_capable(CCS_SYS_SYMLINK))  
 +               return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         from = getname(oldname);  
         if(IS_ERR(from))  
 @@ -2227,6 +2308,12 @@ asmlinkage long sys_symlinkat(const char  
451          if (IS_ERR(dentry))          if (IS_ERR(dentry))
452                  goto out_unlock;                  goto out_unlock;
453    
454  +       /***** TOMOYO Linux start. *****/  +       error = ccs_symlink_permission(nd.dentry->d_inode, dentry, nd.mnt,
455  +       error = pre_vfs_symlink(nd.dentry->d_inode, dentry);  +                                      from);
 +       if (!error)  
 +               error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, dentry, nd.mnt);  
456  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
457          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
458          dput(dentry);          dput(dentry);
459   out_unlock:   out_unlock:
460  @@ -2299,6 +2386,10 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2322,6 +2346,9 @@ asmlinkage long sys_linkat(int olddfd, c
         struct nameidata nd, old_nd;  
         int error;  
         char * to;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (!ccs_capable(CCS_SYS_LINK))  
 +               return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         if ((flags & ~AT_SYMLINK_FOLLOW) != 0)  
                 return -EINVAL;  
 @@ -2322,6 +2413,13 @@ asmlinkage long sys_linkat(int olddfd, c  
461          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
462          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
463                  goto out_unlock;                  goto out_unlock;
464  +       /***** TOMOYO Linux start. *****/  +       error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode,
465  +       error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);  +                                   new_dentry, nd.mnt);
466  +       if (!error)  +       if (!error)
 +               error = ccs_check_2path_perm(TYPE_LINK_ACL, old_nd.dentry,  
 +                                            old_nd.mnt, new_dentry, nd.mnt);  
 +       if (!error)  
 +       /***** TOMOYO Linux end. *****/  
467          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
468          dput(new_dentry);          dput(new_dentry);
469   out_unlock:   out_unlock:
470  @@ -2547,6 +2645,16 @@ static int do_rename(int olddfd, const c  @@ -2547,7 +2574,9 @@ static int do_rename(int olddfd, const c
471          error = -ENOTEMPTY;          error = -ENOTEMPTY;
472          if (new_dentry == trap)          if (new_dentry == trap)
473                  goto exit5;                  goto exit5;
474  +       /***** TOMOYO Linux start. *****/  -
475  +       error = pre_vfs_rename(old_dir->d_inode, old_dentry,  +       error = ccs_rename_permission(old_dir->d_inode, old_dentry,
476  +                              new_dir->d_inode, new_dentry);  +                                     new_dir->d_inode, new_dentry, newnd.mnt);
477  +       if (error)  +       if (!error)
 +               goto exit5;  
 +       error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt,  
 +                                    new_dentry, newnd.mnt);  
 +       if (error)  
 +               goto exit5;  
 +       /***** TOMOYO Linux end. *****/  
   
478          error = vfs_rename(old_dir->d_inode, old_dentry,          error = vfs_rename(old_dir->d_inode, old_dentry,
479                                     new_dir->d_inode, new_dentry);                                     new_dir->d_inode, new_dentry);
480  @@ -2570,6 +2678,10 @@ asmlinkage long sys_renameat(int olddfd,   exit5:
         int error;  
         char * from;  
         char * to;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (!ccs_capable(CCS_SYS_RENAME))  
 +               return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         from = getname(oldname);  
         if(IS_ERR(from))  
481  --- linux-2.6.21.7.orig/fs/namespace.c  --- linux-2.6.21.7.orig/fs/namespace.c
482  +++ linux-2.6.21.7/fs/namespace.c  +++ linux-2.6.21.7/fs/namespace.c
483  @@ -28,6 +28,12 @@  @@ -28,6 +28,7 @@
484   #include <asm/uaccess.h>   #include <asm/uaccess.h>
485   #include <asm/unistd.h>   #include <asm/unistd.h>
486   #include "pnode.h"   #include "pnode.h"
487  +/***** SAKURA Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/sakura.h>  
 +/***** SAKURA Linux end. *****/  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
488    
489   /* spinlock for vfsmount related operations, inplace of dcache_lock */   /* spinlock for vfsmount related operations, inplace of dcache_lock */
490   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
491  @@ -545,6 +551,11 @@ static int do_umount(struct vfsmount *mn  @@ -542,6 +543,8 @@ static int do_umount(struct vfsmount *mn
492            LIST_HEAD(umount_list);
493    
494            retval = security_sb_umount(mnt, flags);
495    +       if (!retval)
496    +               retval = ccs_umount_permission(mnt, flags);
497          if (retval)          if (retval)
498                  return retval;                  return retval;
499    
500  +       /***** SAKURA Linux start. *****/  @@ -633,6 +636,8 @@ asmlinkage long sys_umount(char __user *
 +       if (ccs_may_umount(mnt))  
 +               return -EPERM;  
 +       /***** SAKURA Linux end. *****/  
 +  
         /*  
          * Allow userspace to request a mountpoint be expired rather than  
          * unmounting unconditionally. Unmount only happens if:  
 @@ -633,6 +644,10 @@ asmlinkage long sys_umount(char __user *  
501   {   {
502          struct nameidata nd;          struct nameidata nd;
503          int retval;          int retval;
 +       /***** TOMOYO Linux start. *****/  
504  +       if (!ccs_capable(CCS_SYS_UMOUNT))  +       if (!ccs_capable(CCS_SYS_UMOUNT))
505  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
506    
507          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
508          if (retval)          if (retval)
509  @@ -917,6 +932,11 @@ static int do_loopback(struct nameidata  @@ -917,6 +922,9 @@ static int do_loopback(struct nameidata
510    
511          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
512                  goto out;                  goto out;
 +       /***** SAKURA Linux start. *****/  
513  +       err = -EPERM;  +       err = -EPERM;
514  +       if (ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
515  +               goto out;  +               goto out;
 +       /***** SAKURA Linux end. *****/  
516    
517          err = -ENOMEM;          err = -ENOMEM;
518          if (recurse)          if (recurse)
519  @@ -1002,6 +1022,11 @@ static int do_move_mount(struct nameidat  @@ -1002,6 +1010,9 @@ static int do_move_mount(struct nameidat
520          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
521                  goto out;                  goto out;
522    
 +       /***** SAKURA Linux start. *****/  
523  +       err = -EPERM;  +       err = -EPERM;
524  +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
525  +               goto out;  +               goto out;
 +       /***** SAKURA Linux end. *****/  
526          err = -ENOENT;          err = -ENOENT;
527          mutex_lock(&nd->dentry->d_inode->i_mutex);          mutex_lock(&nd->dentry->d_inode->i_mutex);
528          if (IS_DEADDIR(nd->dentry->d_inode))          if (IS_DEADDIR(nd->dentry->d_inode))
529  @@ -1103,6 +1128,11 @@ int do_add_mount(struct vfsmount *newmnt  @@ -1103,6 +1114,9 @@ int do_add_mount(struct vfsmount *newmnt
530          err = -EINVAL;          err = -EINVAL;
531          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
532                  goto unlock;                  goto unlock;
 +       /***** SAKURA Linux start. *****/  
533  +       err = -EPERM;  +       err = -EPERM;
534  +       if (ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
535  +               goto unlock;  +               goto unlock;
 +       /***** SAKURA Linux end. *****/  
536    
537          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
538          if ((err = graft_tree(newmnt, nd)))          if ((err = graft_tree(newmnt, nd)))
539  @@ -1394,6 +1424,17 @@ long do_mount(char *dev_name, char *dir_  @@ -1376,6 +1390,7 @@ int copy_mount_options(const void __user
540          if (data_page)   long do_mount(char *dev_name, char *dir_name, char *type_page,
541                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                    unsigned long flags, void *data_page)
542     {
543  +       /***** TOMOYO Linux start. *****/  +       const unsigned long original_flags = flags;
544  +       if (!ccs_capable(CCS_SYS_MOUNT))          struct nameidata nd;
545  +               return -EPERM;          int retval = 0;
546  +       /***** TOMOYO Linux end. *****/          int mnt_flags = 0;
547  +       /***** SAKURA Linux start. *****/  @@ -1417,6 +1432,9 @@ long do_mount(char *dev_name, char *dir_
548  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,                  return retval;
549  +                                           &flags);  
550  +       if (retval)          retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
551  +               return retval;  +       if (!retval)
552  +       /***** SAKURA Linux end. *****/  +               retval = ccs_mount_permission(dev_name, &nd, type_page,
553  +  +                                             original_flags, data_page);
554          /* Separate the per-mountpoint flags */          if (retval)
555          if (flags & MS_NOSUID)                  goto dput_out;
556                  mnt_flags |= MNT_NOSUID;  
557  @@ -1686,6 +1727,10 @@ asmlinkage long sys_pivot_root(const cha  @@ -1686,6 +1704,8 @@ asmlinkage long sys_pivot_root(const cha
558    
559          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
560                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
561  +       if (!ccs_capable(CCS_SYS_PIVOT_ROOT))  +       if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
562  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
563    
564          lock_kernel();          lock_kernel();
565    
566  @@ -1702,6 +1747,10 @@ asmlinkage long sys_pivot_root(const cha  @@ -1702,6 +1722,8 @@ asmlinkage long sys_pivot_root(const cha
567                  goto out1;                  goto out1;
568    
569          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
 +       /***** SAKURA Linux start. *****/  
570  +       if (!error)  +       if (!error)
571  +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);  +               error = ccs_pivot_root_permission(&old_nd, &new_nd);
 +       /***** SAKURA Linux end. *****/  
572          if (error) {          if (error) {
573                  path_release(&old_nd);                  path_release(&old_nd);
574                  goto out1;                  goto out1;
575  --- linux-2.6.21.7.orig/fs/open.c  --- linux-2.6.21.7.orig/fs/open.c
576  +++ linux-2.6.21.7/fs/open.c  +++ linux-2.6.21.7/fs/open.c
577  @@ -27,6 +27,12 @@  @@ -27,6 +27,7 @@
578   #include <linux/syscalls.h>   #include <linux/syscalls.h>
579   #include <linux/rcupdate.h>   #include <linux/rcupdate.h>
580   #include <linux/audit.h>   #include <linux/audit.h>
581  +/***** SAKURA Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/sakura.h>  
 +/***** SAKURA Linux end. *****/  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
582    
583   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
584   {   {
585  @@ -264,6 +270,10 @@ static long do_sys_truncate(const char _  @@ -264,6 +265,8 @@ static long do_sys_truncate(const char _
586          if (error)          if (error)
587                  goto dput_and_out;                  goto dput_and_out;
588    
589  +       /***** TOMOYO Linux start. *****/  +       error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
 +       error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt);  
590  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
591          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
592          if (!error) {          if (!error) {
593                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
594  @@ -317,6 +327,11 @@ static long do_sys_ftruncate(unsigned in  @@ -317,6 +320,9 @@ static long do_sys_ftruncate(unsigned in
595          if (IS_APPEND(inode))          if (IS_APPEND(inode))
596                  goto out_putf;                  goto out_putf;
597    
598  +       /***** TOMOYO Linux start. *****/  +       error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
 +       error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt);  
599  +       if (error)  +       if (error)
600  +               goto out_putf;  +               goto out_putf;
 +       /***** TOMOYO Linux end. *****/  
601          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
602          if (!error)          if (!error)
603                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
604  @@ -481,6 +496,14 @@ asmlinkage long sys_chroot(const char __  @@ -481,6 +487,10 @@ asmlinkage long sys_chroot(const char __
605          error = -EPERM;          error = -EPERM;
606          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
607                  goto dput_and_out;                  goto dput_and_out;
 +       /***** TOMOYO Linux start. *****/  
608  +       if (!ccs_capable(CCS_SYS_CHROOT))  +       if (!ccs_capable(CCS_SYS_CHROOT))
609  +               goto dput_and_out;  +               goto dput_and_out;
610  +       /***** TOMOYO Linux end. *****/  +       if (ccs_chroot_permission(&nd))
 +       /***** SAKURA Linux start. *****/  
 +       if (ccs_check_chroot_permission(&nd))  
611  +               goto dput_and_out;  +               goto dput_and_out;
 +       /***** SAKURA Linux end. *****/  
612    
613          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
614          set_fs_altroot();          set_fs_altroot();
615  @@ -1085,6 +1108,10 @@ EXPORT_SYMBOL(sys_close);  @@ -514,6 +524,9 @@ asmlinkage long sys_fchmod(unsigned int
616            err = -EPERM;
617            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
618                    goto out_putf;
619    +       err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
620    +       if (err)
621    +               goto out_putf;
622            mutex_lock(&inode->i_mutex);
623            if (mode == (mode_t) -1)
624                    mode = inode->i_mode;
625    @@ -548,6 +561,9 @@ asmlinkage long sys_fchmodat(int dfd, co
626            error = -EPERM;
627            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
628                    goto dput_and_out;
629    +       error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
630    +       if (error)
631    +               goto dput_and_out;
632    
633            mutex_lock(&inode->i_mutex);
634            if (mode == (mode_t) -1)
635    @@ -611,6 +627,8 @@ asmlinkage long sys_chown(const char __u
636            error = user_path_walk(filename, &nd);
637            if (error)
638                    goto out;
639    +       error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
640    +       if (!error)
641            error = chown_common(nd.dentry, user, group);
642            path_release(&nd);
643     out:
644    @@ -631,6 +649,8 @@ asmlinkage long sys_fchownat(int dfd, co
645            error = __user_walk_fd(dfd, filename, follow, &nd);
646            if (error)
647                    goto out;
648    +       error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
649    +       if (!error)
650            error = chown_common(nd.dentry, user, group);
651            path_release(&nd);
652     out:
653    @@ -645,6 +665,8 @@ asmlinkage long sys_lchown(const char __
654            error = user_path_walk_link(filename, &nd);
655            if (error)
656                    goto out;
657    +       error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
658    +       if (!error)
659            error = chown_common(nd.dentry, user, group);
660            path_release(&nd);
661     out:
662    @@ -664,6 +686,8 @@ asmlinkage long sys_fchown(unsigned int
663    
664            dentry = file->f_path.dentry;
665            audit_inode(NULL, dentry->d_inode);
666    +       error = ccs_chown_permission(dentry, file->f_vfsmnt, user, group);
667    +       if (!error)
668            error = chown_common(dentry, user, group);
669            fput(file);
670     out:
671    @@ -756,7 +780,9 @@ static struct file *do_filp_open(int dfd
672            if ((namei_flags+1) & O_ACCMODE)
673                    namei_flags++;
674    
675    +       ccs_save_open_mode(flags);
676            error = open_namei(dfd, filename, namei_flags, mode, &nd);
677    +       ccs_clear_open_mode();
678            if (!error)
679                    return nameidata_to_filp(&nd, flags);
680    
681    @@ -1085,6 +1111,8 @@ EXPORT_SYMBOL(sys_close);
682    */    */
683   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
684   {   {
 +       /***** TOMOYO Linux start. *****/  
685  +       if (!ccs_capable(CCS_SYS_VHANGUP))  +       if (!ccs_capable(CCS_SYS_VHANGUP))
686  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
687          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
688                  /* XXX: this needs locking */                  /* XXX: this needs locking */
689                  tty_vhangup(current->signal->tty);                  tty_vhangup(current->signal->tty);
 --- linux-2.6.21.7.orig/fs/proc/Makefile  
 +++ linux-2.6.21.7/fs/proc/Makefile  
 @@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE)     += kcore.o  
  proc-$(CONFIG_PROC_VMCORE)     += vmcore.o  
  proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o  
  proc-$(CONFIG_PRINTK)  += kmsg.o  
 +  
 +proc-$(CONFIG_SAKURA) += ccs_proc.o  
 +proc-$(CONFIG_TOMOYO) += ccs_proc.o  
690  --- linux-2.6.21.7.orig/fs/proc/proc_misc.c  --- linux-2.6.21.7.orig/fs/proc/proc_misc.c
691  +++ linux-2.6.21.7/fs/proc/proc_misc.c  +++ linux-2.6.21.7/fs/proc/proc_misc.c
692  @@ -747,4 +747,9 @@ void __init proc_misc_init(void)  @@ -747,4 +747,5 @@ void __init proc_misc_init(void)
693                          entry->proc_fops = &proc_sysrq_trigger_operations;                          entry->proc_fops = &proc_sysrq_trigger_operations;
694          }          }
695   #endif   #endif
696  +       /***** CCS start. *****/  +       printk(KERN_INFO "Hook version: 2.6.21.7 2009/10/20\n");
 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)  
 +       printk(KERN_INFO "Hook version: 2.6.21.7 2009/03/18\n");  
 +#endif  
 +       /***** CCS end. *****/  
697   }   }
698  --- linux-2.6.21.7.orig/include/linux/init_task.h  --- linux-2.6.21.7.orig/include/linux/init_task.h
699  +++ linux-2.6.21.7/include/linux/init_task.h  +++ linux-2.6.21.7/include/linux/init_task.h
700  @@ -141,6 +141,10 @@ extern struct group_info init_groups;  @@ -88,6 +88,14 @@ extern struct nsproxy init_nsproxy;
701    
702     extern struct group_info init_groups;
703    
704    +#ifdef CONFIG_CCSECURITY
705    +#define INIT_CCSECURITY          \
706    +       .ccs_domain_info = NULL, \
707    +       .ccs_flags = 0,
708    +#else
709    +#define INIT_CCSECURITY
710    +#endif
711    +
712     /*
713      *  INIT_TASK is used to set up the first task table, touch at
714      * your own risk!. Base=0, limit=0x1fffff (=2MB)
715    @@ -141,6 +149,7 @@ extern struct group_info init_groups;
716          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \
717          INIT_TRACE_IRQFLAGS                                             \          INIT_TRACE_IRQFLAGS                                             \
718          INIT_LOCKDEP                                                    \          INIT_LOCKDEP                                                    \
719  +       /***** TOMOYO Linux start. *****/        \  +       INIT_CCSECURITY                                                 \
 +       .ccs_domain_info = NULL,                 \  
 +       .ccs_flags = 0,                          \  
 +       /***** TOMOYO Linux end. *****/          \  
720   }   }
721    
722    
723  --- linux-2.6.21.7.orig/include/linux/sched.h  --- linux-2.6.21.7.orig/include/linux/sched.h
724  +++ linux-2.6.21.7/include/linux/sched.h  +++ linux-2.6.21.7/include/linux/sched.h
725  @@ -27,6 +27,10 @@  @@ -27,6 +27,8 @@
726   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */
727   #define CLONE_NEWIPC           0x08000000      /* New ipcs */   #define CLONE_NEWIPC           0x08000000      /* New ipcs */
728    
 +/***** TOMOYO Linux start. *****/  
729  +struct ccs_domain_info;  +struct ccs_domain_info;
 +/***** TOMOYO Linux end. *****/  
730  +  +
731   /*   /*
732    * Scheduling policies    * Scheduling policies
733    */    */
734  @@ -1052,6 +1056,10 @@ struct task_struct {  @@ -1052,6 +1054,10 @@ struct task_struct {
735   #ifdef CONFIG_FAULT_INJECTION   #ifdef CONFIG_FAULT_INJECTION
736          int make_it_fail;          int make_it_fail;
737   #endif   #endif
738  +       /***** TOMOYO Linux start. *****/  +#ifdef CONFIG_CCSECURITY
739  +       struct ccs_domain_info *ccs_domain_info;  +       struct ccs_domain_info *ccs_domain_info;
740  +       u32 ccs_flags;  +       u32 ccs_flags;
741  +       /***** TOMOYO Linux end. *****/  +#endif
742   };   };
743    
744   static inline pid_t process_group(struct task_struct *tsk)   static inline pid_t process_group(struct task_struct *tsk)
745  --- linux-2.6.21.7.orig/kernel/compat.c  --- linux-2.6.21.7.orig/kernel/compat.c
746  +++ linux-2.6.21.7/kernel/compat.c  +++ linux-2.6.21.7/kernel/compat.c
747  @@ -25,6 +25,9 @@  @@ -25,6 +25,7 @@
748   #include <linux/posix-timers.h>   #include <linux/posix-timers.h>
749    
750   #include <asm/uaccess.h>   #include <asm/uaccess.h>
751  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
752    
753   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)
754   {   {
755  @@ -869,6 +872,10 @@ asmlinkage long compat_sys_stime(compat_  @@ -869,6 +870,8 @@ asmlinkage long compat_sys_stime(compat_
756          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
757          if (err)          if (err)
758                  return err;                  return err;
 +       /***** TOMOYO Linux start. *****/  
759  +       if (!ccs_capable(CCS_SYS_SETTIME))  +       if (!ccs_capable(CCS_SYS_SETTIME))
760  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
761    
762          do_settimeofday(&tv);          do_settimeofday(&tv);
763          return 0;          return 0;
764  --- linux-2.6.21.7.orig/kernel/kexec.c  --- linux-2.6.21.7.orig/kernel/kexec.c
765  +++ linux-2.6.21.7/kernel/kexec.c  +++ linux-2.6.21.7/kernel/kexec.c
766  @@ -28,6 +28,9 @@  @@ -28,6 +28,7 @@
767   #include <asm/io.h>   #include <asm/io.h>
768   #include <asm/system.h>   #include <asm/system.h>
769   #include <asm/semaphore.h>   #include <asm/semaphore.h>
770  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
771    
772   /* Per cpu memory for storing cpu states in case of system crash. */   /* Per cpu memory for storing cpu states in case of system crash. */
773   note_buf_t* crash_notes;   note_buf_t* crash_notes;
774  @@ -924,6 +927,10 @@ asmlinkage long sys_kexec_load(unsigned  @@ -924,6 +925,8 @@ asmlinkage long sys_kexec_load(unsigned
775          /* We only trust the superuser with rebooting the system. */          /* We only trust the superuser with rebooting the system. */
776          if (!capable(CAP_SYS_BOOT))          if (!capable(CAP_SYS_BOOT))
777                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
778  +       if (!ccs_capable(CCS_SYS_KEXEC_LOAD))  +       if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
779  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
780    
781          /*          /*
782           * Verify we have a legal set of flags           * Verify we have a legal set of flags
# Line 1011  Source code for this patch is http://www Line 786  Source code for this patch is http://www
786          /* We can run anywhere, unlike our parent keventd(). */          /* We can run anywhere, unlike our parent keventd(). */
787          set_cpus_allowed(current, CPU_MASK_ALL);          set_cpus_allowed(current, CPU_MASK_ALL);
788    
789  +       /***** TOMOYO Linux start. *****/  +#ifdef CONFIG_CCSECURITY
790  +       current->ccs_domain_info = NULL;  +       current->ccs_domain_info = NULL;
791  +       current->ccs_flags = 0;  +       current->ccs_flags = 0;
792  +       /***** TOMOYO Linux end. *****/  +#endif
793  +  +
794          retval = -EPERM;          retval = -EPERM;
795          if (current->fs->root)          if (current->fs->root)
796                  retval = kernel_execve(sub_info->path,                  retval = kernel_execve(sub_info->path,
797  --- linux-2.6.21.7.orig/kernel/module.c  --- linux-2.6.21.7.orig/kernel/module.c
798  +++ linux-2.6.21.7/kernel/module.c  +++ linux-2.6.21.7/kernel/module.c
799  @@ -44,6 +44,9 @@  @@ -44,6 +44,7 @@
800   #include <asm/semaphore.h>   #include <asm/semaphore.h>
801   #include <asm/cacheflush.h>   #include <asm/cacheflush.h>
802   #include <linux/license.h>   #include <linux/license.h>
803  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
804    
805   #if 0   #if 0
806   #define DEBUGP printk   #define DEBUGP printk
807  @@ -662,6 +665,10 @@ sys_delete_module(const char __user *nam  @@ -662,6 +663,8 @@ sys_delete_module(const char __user *nam
808    
809          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
810                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
811  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))
812  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
813    
814          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
815                  return -EFAULT;                  return -EFAULT;
816  @@ -1983,6 +1990,10 @@ sys_init_module(void __user *umod,  @@ -1983,6 +1986,8 @@ sys_init_module(void __user *umod,
817          /* Must have permission */          /* Must have permission */
818          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
819                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
820  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))
821  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
822    
823          /* Only one module load at a time, please */          /* Only one module load at a time, please */
824          if (mutex_lock_interruptible(&module_mutex) != 0)          if (mutex_lock_interruptible(&module_mutex) != 0)
825  --- linux-2.6.21.7.orig/kernel/ptrace.c  --- linux-2.6.21.7.orig/kernel/ptrace.c
826  +++ linux-2.6.21.7/kernel/ptrace.c  +++ linux-2.6.21.7/kernel/ptrace.c
827  @@ -21,6 +21,9 @@  @@ -21,6 +21,7 @@
828    
829   #include <asm/pgtable.h>   #include <asm/pgtable.h>
830   #include <asm/uaccess.h>   #include <asm/uaccess.h>
831  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
832    
833   /*   /*
834    * ptrace a task: make the debugger its new parent and    * ptrace a task: make the debugger its new parent and
835  @@ -456,6 +459,10 @@ asmlinkage long sys_ptrace(long request,  @@ -456,6 +457,8 @@ asmlinkage long sys_ptrace(long request,
836          /*          /*
837           * This lock_kernel fixes a subtle race with suid exec           * This lock_kernel fixes a subtle race with suid exec
838           */           */
839  +       /***** TOMOYO Linux start. *****/  +       if (ccs_ptrace_permission(request, pid))
 +       if (!ccs_capable(CCS_SYS_PTRACE))  
840  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
841          lock_kernel();          lock_kernel();
842          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
843                  ret = ptrace_traceme();                  ret = ptrace_traceme();
844  --- linux-2.6.21.7.orig/kernel/sched.c  --- linux-2.6.21.7.orig/kernel/sched.c
845  +++ linux-2.6.21.7/kernel/sched.c  +++ linux-2.6.21.7/kernel/sched.c
846  @@ -55,6 +55,9 @@  @@ -55,6 +55,7 @@
847   #include <asm/tlb.h>   #include <asm/tlb.h>
848    
849   #include <asm/unistd.h>   #include <asm/unistd.h>
850  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
851    
852   /*   /*
853    * Scheduler clock - returns current time in nanosec units.    * Scheduler clock - returns current time in nanosec units.
854  @@ -3964,6 +3967,10 @@ int can_nice(const struct task_struct *p  @@ -3964,6 +3965,8 @@ int can_nice(const struct task_struct *p
855   asmlinkage long sys_nice(int increment)   asmlinkage long sys_nice(int increment)
856   {   {
857          long nice, retval;          long nice, retval;
 +       /***** TOMOYO Linux start. *****/  
858  +       if (!ccs_capable(CCS_SYS_NICE))  +       if (!ccs_capable(CCS_SYS_NICE))
859  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
860    
861          /*          /*
862           * Setpriority might change our priority at the same moment.           * Setpriority might change our priority at the same moment.
863  --- linux-2.6.21.7.orig/kernel/signal.c  --- linux-2.6.21.7.orig/kernel/signal.c
864  +++ linux-2.6.21.7/kernel/signal.c  +++ linux-2.6.21.7/kernel/signal.c
865  @@ -32,6 +32,9 @@  @@ -32,6 +32,7 @@
866   #include <asm/unistd.h>   #include <asm/unistd.h>
867   #include <asm/siginfo.h>   #include <asm/siginfo.h>
868   #include "audit.h"     /* audit_signal_info() */   #include "audit.h"     /* audit_signal_info() */
869  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
870    
871   /*   /*
872    * SLAB caches for signal bits.    * SLAB caches for signal bits.
873  @@ -2235,6 +2238,12 @@ asmlinkage long  @@ -2235,6 +2236,8 @@ asmlinkage long
874   sys_kill(int pid, int sig)   sys_kill(int pid, int sig)
875   {   {
876          struct siginfo info;          struct siginfo info;
877  +       /***** TOMOYO Linux start. *****/  +       if (ccs_kill_permission(pid, sig))
 +       if (sig && !ccs_capable(CCS_SYS_KILL))  
878  +               return -EPERM;  +               return -EPERM;
 +       if (sig && ccs_check_signal_acl(sig, pid))  
 +               return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
879    
880          info.si_signo = sig;          info.si_signo = sig;
881          info.si_errno = 0;          info.si_errno = 0;
882  @@ -2293,6 +2302,12 @@ asmlinkage long sys_tgkill(int tgid, int  @@ -2293,6 +2296,8 @@ asmlinkage long sys_tgkill(int tgid, int
883          /* This is only valid for single tasks */          /* This is only valid for single tasks */
884          if (pid <= 0 || tgid <= 0)          if (pid <= 0 || tgid <= 0)
885                  return -EINVAL;                  return -EINVAL;
886  +       /***** TOMOYO Linux start. *****/  +       if (ccs_tgkill_permission(tgid, pid, sig))
 +       if (sig && !ccs_capable(CCS_SYS_KILL))  
 +               return -EPERM;  
 +       if (sig && ccs_check_signal_acl(sig, pid))  
887  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
888    
889          return do_tkill(tgid, pid, sig);          return do_tkill(tgid, pid, sig);
890   }   }
891  @@ -2306,6 +2321,12 @@ sys_tkill(int pid, int sig)  @@ -2306,6 +2311,8 @@ sys_tkill(int pid, int sig)
892          /* This is only valid for single tasks */          /* This is only valid for single tasks */
893          if (pid <= 0)          if (pid <= 0)
894                  return -EINVAL;                  return -EINVAL;
895  +       /***** TOMOYO Linux start. *****/  +       if (ccs_tkill_permission(pid, sig))
 +       if (sig && !ccs_capable(CCS_SYS_KILL))  
 +               return -EPERM;  
 +       if (sig && ccs_check_signal_acl(sig, pid))  
896  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
897    
898          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
899   }   }
900    @@ -2323,6 +2330,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
901            if (info.si_code >= 0)
902                    return -EPERM;
903            info.si_signo = sig;
904    +       if (ccs_sigqueue_permission(pid, sig))
905    +               return -EPERM;
906    
907            /* POSIX.1b doesn't mention process groups.  */
908            return kill_proc_info(sig, &info, pid);
909  --- linux-2.6.21.7.orig/kernel/sys.c  --- linux-2.6.21.7.orig/kernel/sys.c
910  +++ linux-2.6.21.7/kernel/sys.c  +++ linux-2.6.21.7/kernel/sys.c
911  @@ -37,6 +37,9 @@  @@ -37,6 +37,7 @@
912   #include <asm/uaccess.h>   #include <asm/uaccess.h>
913   #include <asm/io.h>   #include <asm/io.h>
914   #include <asm/unistd.h>   #include <asm/unistd.h>
915  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
916    
917   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
918   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
919  @@ -600,6 +603,12 @@ asmlinkage long sys_setpriority(int whic  @@ -600,6 +601,10 @@ asmlinkage long sys_setpriority(int whic
920    
921          if (which > 2 || which < 0)          if (which > 2 || which < 0)
922                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
923  +       if (!ccs_capable(CCS_SYS_NICE)) {  +       if (!ccs_capable(CCS_SYS_NICE)) {
924  +               error = -EPERM;  +               error = -EPERM;
925  +               goto out;  +               goto out;
926  +       }  +       }
 +       /***** TOMOYO Linux end. *****/  
927    
928          /* normalize: avoid signed division (rounding problems) */          /* normalize: avoid signed division (rounding problems) */
929          error = -ESRCH;          error = -ESRCH;
930  @@ -830,6 +839,10 @@ asmlinkage long sys_reboot(int magic1, i  @@ -830,6 +835,8 @@ asmlinkage long sys_reboot(int magic1, i
931                          magic2 != LINUX_REBOOT_MAGIC2B &&                          magic2 != LINUX_REBOOT_MAGIC2B &&
932                          magic2 != LINUX_REBOOT_MAGIC2C))                          magic2 != LINUX_REBOOT_MAGIC2C))
933                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
934  +       if (!ccs_capable(CCS_SYS_REBOOT))  +       if (!ccs_capable(CCS_SYS_REBOOT))
935  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
936    
937          /* Instead of trying to make the power_off code look like          /* Instead of trying to make the power_off code look like
938           * halt when pm_power_off is not set do it the easy way.           * halt when pm_power_off is not set do it the easy way.
939  @@ -1806,6 +1819,10 @@ asmlinkage long sys_sethostname(char __u  @@ -1806,6 +1813,8 @@ asmlinkage long sys_sethostname(char __u
940                  return -EPERM;                  return -EPERM;
941          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
942                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
943  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))
944  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
945          down_write(&uts_sem);          down_write(&uts_sem);
946          errno = -EFAULT;          errno = -EFAULT;
947          if (!copy_from_user(tmp, name, len)) {          if (!copy_from_user(tmp, name, len)) {
948  @@ -1851,6 +1868,10 @@ asmlinkage long sys_setdomainname(char _  @@ -1851,6 +1860,8 @@ asmlinkage long sys_setdomainname(char _
949                  return -EPERM;                  return -EPERM;
950          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
951                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
952  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))
953  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
954    
955          down_write(&uts_sem);          down_write(&uts_sem);
956          errno = -EFAULT;          errno = -EFAULT;
957  --- linux-2.6.21.7.orig/kernel/sysctl.c  --- linux-2.6.21.7.orig/kernel/sysctl.c
958  +++ linux-2.6.21.7/kernel/sysctl.c  +++ linux-2.6.21.7/kernel/sysctl.c
959  @@ -48,6 +48,9 @@  @@ -48,6 +48,7 @@
960    
961   #include <asm/uaccess.h>   #include <asm/uaccess.h>
962   #include <asm/processor.h>   #include <asm/processor.h>
963  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
964    
965   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,
966                        void __user *buffer, size_t *lenp, loff_t *ppos);                        void __user *buffer, size_t *lenp, loff_t *ppos);
967  @@ -1088,6 +1091,93 @@ struct ctl_table_header *sysctl_head_nex  @@ -1088,6 +1089,7 @@ struct ctl_table_header *sysctl_head_nex
968   }   }
969    
970   #ifdef CONFIG_SYSCTL_SYSCALL   #ifdef CONFIG_SYSCTL_SYSCALL
971  +  +
 +/***** TOMOYO Linux start. *****/  
 +static int try_parse_table(int __user *name, int nlen, void __user *oldval,  
 +                          void __user *newval, ctl_table *table)  
 +{  
 +       int n;  
 +       int error = -ENOMEM;  
 +       int op = 0;  
 +       char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);  
 +       if (oldval)  
 +               op |= 004;  
 +       if (newval)  
 +               op |= 002;  
 +       if (!op) { /* Neither read nor write */  
 +               error = 0;  
 +               goto out;  
 +       }  
 +       if (!buffer)  
 +               goto out;  
 +       memset(buffer, 0, PAGE_SIZE);  
 +       snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");  
 + repeat:  
 +       if (!nlen) {  
 +               error = -ENOTDIR;  
 +               goto out;  
 +       }  
 +       if (get_user(n, name)) {  
 +               error = -EFAULT;  
 +               goto out;  
 +       }  
 +       for ( ; table->ctl_name || table->procname; table++) {  
 +               if (n == table->ctl_name && n) {  
 +                       int pos = strlen(buffer);  
 +                       const char *cp = table->procname;  
 +                       error = -ENOMEM;  
 +                       if (cp) {  
 +                               if (pos + 1 >= PAGE_SIZE - 1)  
 +                                       goto out;  
 +                               buffer[pos++] = '/';  
 +                               while (*cp) {  
 +                                       const unsigned char c  
 +                                               = *(const unsigned char *) cp;  
 +                                       if (c == '\\') {  
 +                                               if (pos + 2 >= PAGE_SIZE - 1)  
 +                                                       goto out;  
 +                                               buffer[pos++] = '\\';  
 +                                               buffer[pos++] = '\\';  
 +                                       } else if (c > ' ' && c < 127) {  
 +                                               if (pos + 1 >= PAGE_SIZE - 1)  
 +                                                       goto out;  
 +                                               buffer[pos++] = c;  
 +                                       } else {  
 +                                               if (pos + 4 >= PAGE_SIZE - 1)  
 +                                                       goto out;  
 +                                               buffer[pos++] = '\\';  
 +                                               buffer[pos++] = (c >> 6) + '0';  
 +                                               buffer[pos++] = ((c >> 3) & 7)  
 +                                                       + '0';  
 +                                               buffer[pos++] = (c & 7) + '0';  
 +                                       }  
 +                                       cp++;  
 +                               }  
 +                       } else {  
 +                               /* Assume nobody assigns "=\$=" for procname. */  
 +                               snprintf(buffer + pos, PAGE_SIZE - pos - 1,  
 +                                        "/=%d=", n);  
 +                               if (!memchr(buffer, '\0', PAGE_SIZE - 2))  
 +                                       goto out;  
 +                       }  
 +                       if (table->child) {  
 +                               name++;  
 +                               nlen--;  
 +                               table = table->child;  
 +                               goto repeat;  
 +                       }  
 +                       /* printk("sysctl='%s'\n", buffer); */  
 +                       error = ccs_check_file_perm(buffer, op, "sysctl");  
 +                       goto out;  
 +               }  
 +       }  
 +       error = -ENOTDIR;  
 + out:  
 +       kfree(buffer);  
 +       return error;  
 +}  
 +/***** TOMOYO Linux end. *****/  
 +  
972   int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,   int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
973                 void __user *newval, size_t newlen)                 void __user *newval, size_t newlen)
974   {   {
975  @@ -1104,6 +1194,11 @@ int do_sysctl(int __user *name, int nlen  @@ -1104,6 +1106,9 @@ int do_sysctl(int __user *name, int nlen
976    
977          for (head = sysctl_head_next(NULL); head;          for (head = sysctl_head_next(NULL); head;
978                          head = sysctl_head_next(head)) {                          head = sysctl_head_next(head)) {
979  +               /***** TOMOYO Linux start. *****/  +               error = ccs_parse_table(name, nlen, oldval, newval,
 +               error = try_parse_table(name, nlen, oldval, newval,  
980  +                                       head->ctl_table);  +                                       head->ctl_table);
981  +               if (!error)  +               if (!error)
 +               /***** TOMOYO Linux end. *****/  
982                  error = parse_table(name, nlen, oldval, oldlenp,                  error = parse_table(name, nlen, oldval, oldlenp,
983                                          newval, newlen, head->ctl_table);                                          newval, newlen, head->ctl_table);
984                  if (error != -ENOTDIR) {                  if (error != -ENOTDIR) {
985  --- linux-2.6.21.7.orig/kernel/time.c  --- linux-2.6.21.7.orig/kernel/time.c
986  +++ linux-2.6.21.7/kernel/time.c  +++ linux-2.6.21.7/kernel/time.c
987  @@ -39,6 +39,9 @@  @@ -39,6 +39,7 @@
988    
989   #include <asm/uaccess.h>   #include <asm/uaccess.h>
990   #include <asm/unistd.h>   #include <asm/unistd.h>
991  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
992    
993   /*   /*
994    * 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
995  @@ -91,6 +94,10 @@ asmlinkage long sys_stime(time_t __user  @@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user
996          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
997          if (err)          if (err)
998                  return err;                  return err;
 +       /***** TOMOYO Linux start. *****/  
999  +       if (!ccs_capable(CCS_SYS_SETTIME))  +       if (!ccs_capable(CCS_SYS_SETTIME))
1000  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
1001    
1002          do_settimeofday(&tv);          do_settimeofday(&tv);
1003          return 0;          return 0;
1004  @@ -161,6 +168,10 @@ int do_sys_settimeofday(struct timespec  @@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec
1005          error = security_settime(tv, tz);          error = security_settime(tv, tz);
1006          if (error)          if (error)
1007                  return error;                  return error;
 +       /***** TOMOYO Linux start. *****/  
1008  +       if (!ccs_capable(CCS_SYS_SETTIME))  +       if (!ccs_capable(CCS_SYS_SETTIME))
1009  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
1010    
1011          if (tz) {          if (tz) {
1012                  /* SMP safe, global irq locking makes it work. */                  /* SMP safe, global irq locking makes it work. */
1013  --- linux-2.6.21.7.orig/kernel/time/ntp.c  --- linux-2.6.21.7.orig/kernel/time/ntp.c
1014  +++ linux-2.6.21.7/kernel/time/ntp.c  +++ linux-2.6.21.7/kernel/time/ntp.c
1015  @@ -14,6 +14,9 @@  @@ -14,6 +14,7 @@
1016    
1017   #include <asm/div64.h>   #include <asm/div64.h>
1018   #include <asm/timex.h>   #include <asm/timex.h>
1019  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
1020    
1021   /*   /*
1022    * Timekeeping variables    * Timekeeping variables
1023  @@ -201,6 +204,10 @@ int do_adjtimex(struct timex *txc)  @@ -201,6 +202,8 @@ int do_adjtimex(struct timex *txc)
1024          /* In order to modify anything, you gotta be super-user! */          /* In order to modify anything, you gotta be super-user! */
1025          if (txc->modes && !capable(CAP_SYS_TIME))          if (txc->modes && !capable(CAP_SYS_TIME))
1026                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
1027  +       if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))  +       if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1028  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
1029    
1030          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
1031    
 --- linux-2.6.21.7.orig/net/core/datagram.c  
 +++ linux-2.6.21.7/net/core/datagram.c  
 @@ -56,6 +56,11 @@  
  #include <net/sock.h>  
  #include <net/tcp_states.h>  
   
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +#include <linux/tomoyo_socket.h>  
 +/***** TOMOYO Linux end. *****/  
 +  
  /*  
   *     Is a socket 'connection oriented' ?  
   */  
 @@ -178,6 +183,12 @@ struct sk_buff *skb_recv_datagram(struct  
                 } else  
                         skb = skb_dequeue(&sk->sk_receive_queue);  
   
 +               /***** TOMOYO Linux start. *****/  
 +               error = ccs_socket_recv_datagram_permission(sk, skb, flags);  
 +               if (error)  
 +                       goto no_packet;  
 +               /***** TOMOYO Linux end. *****/  
 +  
                 if (skb)  
                         return skb;  
   
1032  --- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c  --- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c
1033  +++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c  +++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c
1034  @@ -23,6 +23,9 @@  @@ -23,6 +23,7 @@
1035   #include <net/route.h>   #include <net/route.h>
1036   #include <net/tcp_states.h>   #include <net/tcp_states.h>
1037   #include <net/xfrm.h>   #include <net/xfrm.h>
1038  +/***** SAKURA Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/sakura.h>  
 +/***** SAKURA Linux end. *****/  
1039    
1040   #ifdef INET_CSK_DEBUG   #ifdef INET_CSK_DEBUG
1041   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";
1042  @@ -85,6 +88,10 @@ int inet_csk_get_port(struct inet_hashin  @@ -85,6 +86,8 @@ int inet_csk_get_port(struct inet_hashin
1043                  do {                  do {
1044                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1045                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1046  +                       /***** SAKURA Linux start. *****/  +                       if (ccs_lport_reserved(rover))
 +                       if (ccs_may_autobind(rover))  
1047  +                               goto next;  +                               goto next;
 +                       /***** SAKURA Linux end. *****/  
1048                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
1049                                  if (tb->port == rover)                                  if (tb->port == rover)
1050                                          goto next;                                          goto next;
1051  --- linux-2.6.21.7.orig/net/ipv4/inet_hashtables.c  --- linux-2.6.21.7.orig/net/ipv4/inet_hashtables.c
1052  +++ linux-2.6.21.7/net/ipv4/inet_hashtables.c  +++ linux-2.6.21.7/net/ipv4/inet_hashtables.c
1053  @@ -22,6 +22,9 @@  @@ -22,6 +22,7 @@
1054   #include <net/inet_connection_sock.h>   #include <net/inet_connection_sock.h>
1055   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1056   #include <net/ip.h>   #include <net/ip.h>
1057  +/***** SAKURA Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/sakura.h>  
 +/***** SAKURA Linux end. *****/  
1058    
1059   /*   /*
1060    * Allocate and initialize a new local port bind bucket.    * Allocate and initialize a new local port bind bucket.
1061  @@ -292,6 +295,10 @@ int inet_hash_connect(struct inet_timewa  @@ -292,6 +293,8 @@ int inet_hash_connect(struct inet_timewa
1062                  local_bh_disable();                  local_bh_disable();
1063                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1064                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1065  +                       /***** SAKURA Linux start. *****/  +                       if (ccs_lport_reserved(port))
 +                       if (ccs_may_autobind(port))  
1066  +                               continue;  +                               continue;
 +                       /***** SAKURA Linux end. *****/  
1067                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1068                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1069    
1070    --- linux-2.6.21.7.orig/net/ipv4/raw.c
1071    +++ linux-2.6.21.7/net/ipv4/raw.c
1072    @@ -78,6 +78,7 @@
1073     #include <linux/seq_file.h>
1074     #include <linux/netfilter.h>
1075     #include <linux/netfilter_ipv4.h>
1076    +#include <linux/ccsecurity.h>
1077    
1078     struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1079     DEFINE_RWLOCK(raw_v4_lock);
1080    @@ -597,6 +598,9 @@ static int raw_recvmsg(struct kiocb *ioc
1081            skb = skb_recv_datagram(sk, flags, noblock, &err);
1082            if (!skb)
1083                    goto out;
1084    +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
1085    +       if (err)
1086    +               goto out;
1087    
1088            copied = skb->len;
1089            if (len < copied) {
1090  --- linux-2.6.21.7.orig/net/ipv4/udp.c  --- linux-2.6.21.7.orig/net/ipv4/udp.c
1091  +++ linux-2.6.21.7/net/ipv4/udp.c  +++ linux-2.6.21.7/net/ipv4/udp.c
1092  @@ -102,6 +102,9 @@  @@ -102,6 +102,7 @@
1093   #include <net/checksum.h>   #include <net/checksum.h>
1094   #include <net/xfrm.h>   #include <net/xfrm.h>
1095   #include "udp_impl.h"   #include "udp_impl.h"
1096  +/***** SAKURA Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/sakura.h>  
 +/***** SAKURA Linux end. *****/  
1097    
1098   /*   /*
1099    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
1100  @@ -162,6 +165,10 @@ int __udp_lib_get_port(struct sock *sk,  @@ -162,6 +163,8 @@ int __udp_lib_get_port(struct sock *sk,
1101                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1102                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1103                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
1104  +                               /***** SAKURA Linux start. *****/  +                               if (ccs_lport_reserved(result))
 +                               if (ccs_may_autobind(result))  
1105  +                                       continue;  +                                       continue;
 +                               /***** SAKURA Linux end. *****/  
1106                                  goto gotit;                                  goto gotit;
1107                          }                          }
1108                          size = 0;                          size = 0;
1109  @@ -180,6 +187,10 @@ int __udp_lib_get_port(struct sock *sk,  @@ -180,6 +183,8 @@ int __udp_lib_get_port(struct sock *sk,
1110                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1111                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1112                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
1113  +                       /***** SAKURA Linux start. *****/  +                       if (ccs_lport_reserved(result))
 +                       if (ccs_may_autobind(result))  
1114  +                               continue;  +                               continue;
 +                       /***** SAKURA Linux end. *****/  
1115                          if (! __udp_lib_lport_inuse(result, udptable))                          if (! __udp_lib_lport_inuse(result, udptable))
1116                                  break;                                  break;
1117                  }                  }
1118    @@ -825,6 +830,9 @@ try_again:
1119            skb = skb_recv_datagram(sk, flags, noblock, &err);
1120            if (!skb)
1121                    goto out;
1122    +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
1123    +       if (err)
1124    +               goto out;
1125    
1126            copied = skb->len - sizeof(struct udphdr);
1127            if (copied > len) {
1128  --- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c  --- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c
1129  +++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c  +++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c
1130  @@ -21,6 +21,9 @@  @@ -21,6 +21,7 @@
1131   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1132   #include <net/inet6_hashtables.h>   #include <net/inet6_hashtables.h>
1133   #include <net/ip.h>   #include <net/ip.h>
1134  +/***** SAKURA Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/sakura.h>  
 +/***** SAKURA Linux end. *****/  
1135    
1136   void __inet6_hash(struct inet_hashinfo *hashinfo,   void __inet6_hash(struct inet_hashinfo *hashinfo,
1137                                  struct sock *sk)                                  struct sock *sk)
1138  @@ -266,6 +269,10 @@ int inet6_hash_connect(struct inet_timew  @@ -266,6 +267,8 @@ int inet6_hash_connect(struct inet_timew
1139                  local_bh_disable();                  local_bh_disable();
1140                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1141                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1142  +                       /***** SAKURA Linux start. *****/  +                       if (ccs_lport_reserved(port))
 +                       if (ccs_may_autobind(port))  
1143  +                               continue;  +                               continue;
 +                       /***** SAKURA Linux end. *****/  
1144                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1145                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1146    
1147    --- linux-2.6.21.7.orig/net/ipv6/raw.c
1148    +++ linux-2.6.21.7/net/ipv6/raw.c
1149    @@ -58,6 +58,7 @@
1150    
1151     #include <linux/proc_fs.h>
1152     #include <linux/seq_file.h>
1153    +#include <linux/ccsecurity.h>
1154    
1155     struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1156     DEFINE_RWLOCK(raw_v6_lock);
1157    @@ -413,6 +414,9 @@ static int rawv6_recvmsg(struct kiocb *i
1158            skb = skb_recv_datagram(sk, flags, noblock, &err);
1159            if (!skb)
1160                    goto out;
1161    +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
1162    +       if (err)
1163    +               goto out;
1164    
1165            copied = skb->len;
1166            if (copied > len) {
1167    --- linux-2.6.21.7.orig/net/ipv6/udp.c
1168    +++ linux-2.6.21.7/net/ipv6/udp.c
1169    @@ -49,6 +49,7 @@
1170     #include <linux/proc_fs.h>
1171     #include <linux/seq_file.h>
1172     #include "udp_impl.h"
1173    +#include <linux/ccsecurity.h>
1174    
1175     DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1176    
1177    @@ -133,6 +134,9 @@ try_again:
1178            skb = skb_recv_datagram(sk, flags, noblock, &err);
1179            if (!skb)
1180                    goto out;
1181    +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
1182    +       if (err)
1183    +               goto out;
1184    
1185            copied = skb->len - sizeof(struct udphdr);
1186            if (copied > len) {
1187  --- linux-2.6.21.7.orig/net/socket.c  --- linux-2.6.21.7.orig/net/socket.c
1188  +++ linux-2.6.21.7/net/socket.c  +++ linux-2.6.21.7/net/socket.c
1189  @@ -93,6 +93,11 @@  @@ -93,6 +93,8 @@
1190   #include <net/sock.h>   #include <net/sock.h>
1191   #include <linux/netfilter.h>   #include <linux/netfilter.h>
1192    
1193  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +#include <linux/tomoyo_socket.h>  
 +/***** TOMOYO Linux end. *****/  
1194  +  +
1195   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1196   static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,   static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
1197                           unsigned long nr_segs, loff_t pos);                           unsigned long nr_segs, loff_t pos);
1198  @@ -549,6 +554,12 @@ static inline int __sock_sendmsg(struct  @@ -547,6 +549,8 @@ static inline int __sock_sendmsg(struct
1199            si->size = size;
1200    
1201          err = security_socket_sendmsg(sock, msg, size);          err = security_socket_sendmsg(sock, msg, size);
1202    +       if (!err)
1203    +               err = ccs_socket_sendmsg_permission(sock, msg, size);
1204          if (err)          if (err)
1205                  return err;                  return err;
 +       /***** TOMOYO Linux start. *****/  
 +       if (ccs_socket_sendmsg_permission(sock,  
 +                                         (struct sockaddr *) msg->msg_name,  
 +                                         msg->msg_namelen))  
 +               return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
1206    
1207          return sock->ops->sendmsg(iocb, sock, msg, size);  @@ -1071,6 +1075,8 @@ static int __sock_create(int family, int
  }  
 @@ -1070,6 +1081,12 @@ static int __sock_create(int family, int  
                 family = PF_PACKET;  
1208          }          }
1209    
 +       /***** TOMOYO Linux start. *****/  
 +       err = ccs_socket_create_permission(family, type, protocol);  
 +       if (err)  
 +               return err;  
 +       /***** TOMOYO Linux end. *****/  
 +  
1210          err = security_socket_create(family, type, protocol, kern);          err = security_socket_create(family, type, protocol, kern);
1211    +       if (!err)
1212    +               err = ccs_socket_create_permission(family, type, protocol);
1213          if (err)          if (err)
1214                  return err;                  return err;
1215  @@ -1298,6 +1315,13 @@ asmlinkage long sys_bind(int fd, struct  
1216                          err = security_socket_bind(sock,  @@ -1299,6 +1305,11 @@ asmlinkage long sys_bind(int fd, struct
1217                                                     (struct sockaddr *)address,                                                     (struct sockaddr *)address,
1218                                                     addrlen);                                                     addrlen);
1219  +                       /***** TOMOYO Linux start. *****/                          if (!err)
 +                       if (!err)  
1220  +                               err = ccs_socket_bind_permission(sock,  +                               err = ccs_socket_bind_permission(sock,
1221  +                                                        (struct sockaddr *)  +                                                        (struct sockaddr *)
1222  +                                                                address,  +                                                                address,
1223  +                                                                addrlen);  +                                                                addrlen);
1224  +                       /***** TOMOYO Linux end. *****/  +                       if (!err)
                         if (!err)  
1225                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
1226                                                        (struct sockaddr *)                                                        (struct sockaddr *)
1227  @@ -1327,6 +1351,10 @@ asmlinkage long sys_listen(int fd, int b                                                        address, addrlen);
1228                          backlog = sysctl_somaxconn;  @@ -1328,6 +1339,8 @@ asmlinkage long sys_listen(int fd, int b
1229    
1230                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
 +               /***** TOMOYO Linux start. *****/  
 +               if (!err)  
 +                       err = ccs_socket_listen_permission(sock);  
 +               /***** TOMOYO Linux end. *****/  
1231                  if (!err)                  if (!err)
1232    +                       err = ccs_socket_listen_permission(sock);
1233    +               if (!err)
1234                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
1235    
1236  @@ -1391,6 +1419,13 @@ asmlinkage long sys_accept(int fd, struc                  fput_light(sock->file, fput_needed);
1237    @@ -1391,6 +1404,11 @@ asmlinkage long sys_accept(int fd, struc
1238          if (err < 0)          if (err < 0)
1239                  goto out_fd;                  goto out_fd;
1240    
 +       /***** TOMOYO Linux start. *****/  
1241  +       if (ccs_socket_accept_permission(newsock,  +       if (ccs_socket_accept_permission(newsock,
1242  +                                        (struct sockaddr *) address)) {  +                                        (struct sockaddr *) address)) {
1243  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1244  +               goto out_fd;  +               goto out_fd;
1245  +       }  +       }
 +       /***** TOMOYO Linux end. *****/  
1246          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1247                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1248                                            &len, 2) < 0) {                                            &len, 2) < 0) {
1249  @@ -1455,6 +1490,12 @@ asmlinkage long sys_connect(int fd, stru  @@ -1453,6 +1471,9 @@ asmlinkage long sys_connect(int fd, stru
1250    
1251            err =
1252              security_socket_connect(sock, (struct sockaddr *)address, addrlen);              security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1253    +       if (!err)
1254    +               err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1255    +                                                   address, addrlen);
1256          if (err)          if (err)
1257                  goto out_put;                  goto out_put;
 +       /***** TOMOYO Linux start. *****/  
 +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,  
 +                                           addrlen);  
 +       if (err)  
 +               goto out_put;  
 +       /***** TOMOYO Linux end. *****/  
1258    
         err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,  
                                  sock->file->f_flags);  
1259  --- linux-2.6.21.7.orig/net/unix/af_unix.c  --- linux-2.6.21.7.orig/net/unix/af_unix.c
1260  +++ linux-2.6.21.7/net/unix/af_unix.c  +++ linux-2.6.21.7/net/unix/af_unix.c
1261  @@ -116,6 +116,9 @@  @@ -116,6 +116,7 @@
1262   #include <linux/mount.h>   #include <linux/mount.h>
1263   #include <net/checksum.h>   #include <net/checksum.h>
1264   #include <linux/security.h>   #include <linux/security.h>
1265  +/***** TOMOYO Linux start. *****/  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
1266    
1267   int sysctl_unix_max_dgram_qlen __read_mostly = 10;   int sysctl_unix_max_dgram_qlen __read_mostly = 10;
1268    
1269  @@ -765,6 +768,11 @@ static int unix_bind(struct socket *sock  @@ -808,6 +809,9 @@ static int unix_bind(struct socket *sock
                 err = unix_autobind(sock);  
                 goto out;  
         }  
 +       /***** TOMOYO Linux start. *****/  
 +       err = -EPERM;  
 +       if (sunaddr->sun_path[0] && !ccs_capable(CCS_CREATE_UNIX_SOCKET))  
 +               goto out;  
 +       /***** TOMOYO Linux end. *****/  
   
         err = unix_mkname(sunaddr, addr_len, &hash);  
         if (err < 0)  
 @@ -808,6 +816,13 @@ static int unix_bind(struct socket *sock  
1270                   */                   */
1271                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1272                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1273  +               /***** TOMOYO Linux start. *****/  +               err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1274  +               err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);  +                                          mode, 0);
1275  +               if (!err)  +               if (!err)
 +                       err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry,  
 +                                                  nd.mnt);  
 +               if (!err)  
 +               /***** TOMOYO Linux end. *****/  
1276                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1277                  if (err)                  if (err)
1278                          goto out_mknod_dput;                          goto out_mknod_dput;
1279    --- linux-2.6.21.7.orig/security/Kconfig
1280    +++ linux-2.6.21.7/security/Kconfig
1281    @@ -95,5 +95,7 @@ config SECURITY_ROOTPLUG
1282    
1283     source security/selinux/Kconfig
1284    
1285    +source security/ccsecurity/Kconfig
1286    +
1287     endmenu
1288    
1289    --- linux-2.6.21.7.orig/security/Makefile
1290    +++ linux-2.6.21.7/security/Makefile
1291    @@ -16,3 +16,6 @@ obj-$(CONFIG_SECURITY)                        += security.o d
1292     obj-$(CONFIG_SECURITY_SELINUX)         += selinux/built-in.o
1293     obj-$(CONFIG_SECURITY_CAPABILITIES)    += commoncap.o capability.o
1294     obj-$(CONFIG_SECURITY_ROOTPLUG)                += commoncap.o root_plug.o
1295    +
1296    +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1297    +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

Legend:
Removed from v.2282  
changed lines
  Added in v.3111

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