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

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

revision 894 by kumaneko, Tue Jan 15 03:00:17 2008 UTC revision 2306 by kumaneko, Tue Mar 24 05:35:12 2009 UTC
# Line 1  Line 1 
1  This is TOMOYO Linux patch for kernel 2.6.21.  This is TOMOYO Linux patch for kernel 2.6.21.7.
2    
3  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.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   Makefile                        |    2   arch/alpha/kernel/ptrace.c      |    7 +++++
6   arch/alpha/kernel/ptrace.c      |    8 +++   arch/ia64/ia32/sys_ia32.c       |    7 +++++
7   arch/ia64/ia32/sys_ia32.c       |    8 +++   arch/ia64/kernel/ptrace.c       |    7 +++++
8   arch/ia64/kernel/ptrace.c       |    8 +++   arch/m32r/kernel/ptrace.c       |    7 +++++
9   arch/m32r/kernel/ptrace.c       |    8 +++   arch/mips/kernel/ptrace32.c     |    7 +++++
10   arch/mips/kernel/ptrace32.c     |    8 +++   arch/powerpc/kernel/ptrace32.c  |    7 +++++
11   arch/powerpc/kernel/ptrace32.c  |    8 +++   arch/s390/kernel/ptrace.c       |    7 +++++
12   arch/s390/kernel/ptrace.c       |    8 +++   arch/sparc/kernel/ptrace.c      |    9 ++++++
13   arch/sh64/kernel/ptrace.c       |    8 +++   arch/sparc64/kernel/ptrace.c    |    9 ++++++
14   arch/sparc/kernel/ptrace.c      |   11 +++++   arch/x86_64/ia32/ptrace32.c     |    7 +++++
15   arch/sparc64/kernel/ptrace.c    |   11 +++++   fs/Kconfig                      |    2 +
16   arch/x86_64/ia32/ptrace32.c     |    8 +++   fs/Makefile                     |    2 +
17   fs/Kconfig                      |    2   fs/attr.c                       |   19 +++++++++++++
18   fs/Makefile                     |    2   fs/compat.c                     |   15 ++++++++++
19   fs/attr.c                       |   11 +++++   fs/exec.c                       |   17 +++++++++++-
20   fs/compat.c                     |    8 +++   fs/fcntl.c                      |    9 ++++++
21   fs/exec.c                       |   14 ++++++   fs/ioctl.c                      |   11 ++++++++
22   fs/fcntl.c                      |    7 +++   fs/namei.c                      |   55 ++++++++++++++++++++++++++++++++++++++++
23   fs/ioctl.c                      |    6 ++   fs/namespace.c                  |   49 +++++++++++++++++++++++++++++++++++
24   fs/namei.c                      |   60 +++++++++++++++++++++++++++++   fs/open.c                       |   28 ++++++++++++++++++++
25   fs/namespace.c                  |   38 ++++++++++++++++++   fs/proc/Makefile                |    3 ++
26   fs/open.c                       |   21 ++++++++++   fs/proc/proc_misc.c             |    5 +++
27   fs/proc/Makefile                |    3 +   include/linux/init_task.h       |    4 ++
28   fs/proc/proc_misc.c             |    9 ++++   include/linux/sched.h           |    8 +++++
29   include/linux/init_task.h       |    4 +   kernel/compat.c                 |    7 +++++
30   include/linux/sched.h           |    9 ++++   kernel/kexec.c                  |    7 +++++
31   kernel/compat.c                 |    6 ++   kernel/kmod.c                   |    5 +++
32   kernel/kexec.c                  |    6 ++   kernel/module.c                 |   11 ++++++++
33   kernel/kmod.c                   |    5 ++   kernel/ptrace.c                 |    7 +++++
34   kernel/module.c                 |    9 ++++   kernel/sched.c                  |    7 +++++
35   kernel/ptrace.c                 |    8 +++   kernel/signal.c                 |   21 +++++++++++++++
36   kernel/sched.c                  |    6 ++   kernel/sys.c                    |   21 +++++++++++++++
37   kernel/signal.c                 |   15 +++++++   kernel/sysctl.c                 |    9 ++++++
38   kernel/sys.c                    |   15 +++++++   kernel/time.c                   |   11 ++++++++
39   kernel/sysctl.c                 |   81 ++++++++++++++++++++++++++++++++++++++++   kernel/time/ntp.c               |    7 +++++
40   kernel/time.c                   |    9 ++++   net/core/datagram.c             |   11 ++++++++
41   kernel/time/ntp.c               |    6 ++   net/ipv4/inet_connection_sock.c |    7 +++++
42   net/core/datagram.c             |    9 ++++   net/ipv4/inet_hashtables.c      |    7 +++++
43   net/ipv4/inet_connection_sock.c |    6 ++   net/ipv4/udp.c                  |   11 ++++++++
44   net/ipv4/inet_hashtables.c      |    6 ++   net/ipv6/inet6_hashtables.c     |    7 +++++
45   net/ipv4/udp.c                  |    9 ++++   net/socket.c                    |   41 +++++++++++++++++++++++++++++
46   net/ipv6/inet6_hashtables.c     |    6 ++   net/unix/af_unix.c              |    8 +++++
47   net/socket.c                    |   28 +++++++++++++   42 files changed, 504 insertions(+), 2 deletions(-)
  net/unix/af_unix.c              |   10 ++++  
  44 files changed, 527 insertions(+), 3 deletions(-)  
48    
49  --- linux-2.6.21.orig/Makefile  --- linux-2.6.21.7.orig/arch/alpha/kernel/ptrace.c
50  +++ linux-2.6.21/Makefile  +++ linux-2.6.21.7/arch/alpha/kernel/ptrace.c
 @@ -1,7 +1,7 @@  
  VERSION = 2  
  PATCHLEVEL = 6  
  SUBLEVEL = 21  
 -EXTRAVERSION =  
 +EXTRAVERSION = -ccs  
  NAME = Nocturnal Monster Puppy  
   
  # *DOCUMENTATION*  
 --- linux-2.6.21.orig/arch/alpha/kernel/ptrace.c  
 +++ linux-2.6.21/arch/alpha/kernel/ptrace.c  
51  @@ -20,6 +20,9 @@  @@ -20,6 +20,9 @@
52   #include <asm/pgtable.h>   #include <asm/pgtable.h>
53   #include <asm/system.h>   #include <asm/system.h>
# Line 71  Source code for this patch is http://www Line 58  Source code for this patch is http://www
58    
59   #include "proto.h"   #include "proto.h"
60    
61  @@ -268,6 +271,11 @@ do_sys_ptrace(long request, long pid, lo  @@ -268,6 +271,10 @@ do_sys_ptrace(long request, long pid, lo
62          unsigned long tmp;          unsigned long tmp;
63          size_t copied;          size_t copied;
64          long ret;          long ret;
65  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
66  +#ifdef TOMOYO_SYS_PTRACE  +       if (!ccs_capable(CCS_SYS_PTRACE))
67  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +               return -EPERM;
 +#endif  
68  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
69    
70          lock_kernel();          lock_kernel();
71          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",
72  --- linux-2.6.21.orig/arch/ia64/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/ia64/ia32/sys_ia32.c
73  +++ linux-2.6.21/arch/ia64/kernel/ptrace.c  +++ linux-2.6.21.7/arch/ia64/ia32/sys_ia32.c
74    @@ -56,6 +56,9 @@
75     #include <asm/types.h>
76     #include <asm/uaccess.h>
77     #include <asm/unistd.h>
78    +/***** TOMOYO Linux start. *****/
79    +#include <linux/tomoyo.h>
80    +/***** TOMOYO Linux end. *****/
81    
82     #include "ia32priv.h"
83    
84    @@ -1758,6 +1761,10 @@ sys32_ptrace (int request, pid_t pid, un
85            struct task_struct *child;
86            unsigned int value, tmp;
87            long i, ret;
88    +       /***** TOMOYO Linux start. *****/
89    +       if (!ccs_capable(CCS_SYS_PTRACE))
90    +               return -EPERM;
91    +       /***** TOMOYO Linux end. *****/
92    
93            lock_kernel();
94            if (request == PTRACE_TRACEME) {
95    --- linux-2.6.21.7.orig/arch/ia64/kernel/ptrace.c
96    +++ linux-2.6.21.7/arch/ia64/kernel/ptrace.c
97  @@ -28,6 +28,9 @@  @@ -28,6 +28,9 @@
98   #ifdef CONFIG_PERFMON   #ifdef CONFIG_PERFMON
99   #include <asm/perfmon.h>   #include <asm/perfmon.h>
# Line 95  Source code for this patch is http://www Line 104  Source code for this patch is http://www
104    
105   #include "entry.h"   #include "entry.h"
106    
107  @@ -1418,6 +1421,11 @@ sys_ptrace (long request, pid_t pid, uns  @@ -1418,6 +1421,10 @@ sys_ptrace (long request, pid_t pid, uns
108          struct task_struct *child;          struct task_struct *child;
109          struct switch_stack *sw;          struct switch_stack *sw;
110          long ret;          long ret;
111  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
112  +#ifdef TOMOYO_SYS_PTRACE  +       if (!ccs_capable(CCS_SYS_PTRACE))
113  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +               return -EPERM;
 +#endif  
114  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
115    
116          lock_kernel();          lock_kernel();
117          ret = -EPERM;          ret = -EPERM;
118  --- linux-2.6.21.orig/arch/m32r/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/m32r/kernel/ptrace.c
119  +++ linux-2.6.21/arch/m32r/kernel/ptrace.c  +++ linux-2.6.21.7/arch/m32r/kernel/ptrace.c
120  @@ -32,6 +32,9 @@  @@ -32,6 +32,9 @@
121   #include <asm/system.h>   #include <asm/system.h>
122   #include <asm/processor.h>   #include <asm/processor.h>
# Line 119  Source code for this patch is http://www Line 127  Source code for this patch is http://www
127    
128   /*   /*
129    * This routine will get a word off of the process kernel stack.    * This routine will get a word off of the process kernel stack.
130  @@ -742,6 +745,11 @@ asmlinkage long sys_ptrace(long request,  @@ -742,6 +745,10 @@ asmlinkage long sys_ptrace(long request,
131   {   {
132          struct task_struct *child;          struct task_struct *child;
133          int ret;          int ret;
134  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
135  +#ifdef TOMOYO_SYS_PTRACE  +       if (!ccs_capable(CCS_SYS_PTRACE))
136  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +               return -EPERM;
 +#endif  
137  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
138    
139          lock_kernel();          lock_kernel();
140          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
141  --- linux-2.6.21.orig/arch/s390/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/mips/kernel/ptrace32.c
142  +++ linux-2.6.21/arch/s390/kernel/ptrace.c  +++ linux-2.6.21.7/arch/mips/kernel/ptrace32.c
143    @@ -35,6 +35,9 @@
144     #include <asm/system.h>
145     #include <asm/uaccess.h>
146     #include <asm/bootinfo.h>
147    +/***** TOMOYO Linux start. *****/
148    +#include <linux/tomoyo.h>
149    +/***** TOMOYO Linux end. *****/
150    
151     int ptrace_getregs (struct task_struct *child, __s64 __user *data);
152     int ptrace_setregs (struct task_struct *child, __s64 __user *data);
153    @@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request,
154     {
155            struct task_struct *child;
156            int ret;
157    +       /***** TOMOYO Linux start. *****/
158    +       if (!ccs_capable(CCS_SYS_PTRACE))
159    +               return -EPERM;
160    +       /***** TOMOYO Linux end. *****/
161    
162     #if 0
163            printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
164    --- linux-2.6.21.7.orig/arch/powerpc/kernel/ptrace32.c
165    +++ linux-2.6.21.7/arch/powerpc/kernel/ptrace32.c
166    @@ -32,6 +32,9 @@
167     #include <asm/page.h>
168     #include <asm/pgtable.h>
169     #include <asm/system.h>
170    +/***** TOMOYO Linux start. *****/
171    +#include <linux/tomoyo.h>
172    +/***** TOMOYO Linux end. *****/
173    
174     #include "ptrace-common.h"
175    
176    @@ -45,6 +48,10 @@ long compat_sys_ptrace(int request, int
177     {
178            struct task_struct *child;
179            int ret;
180    +       /***** TOMOYO Linux start. *****/
181    +       if (!ccs_capable(CCS_SYS_PTRACE))
182    +               return -EPERM;
183    +       /***** TOMOYO Linux end. *****/
184    
185            lock_kernel();
186            if (request == PTRACE_TRACEME) {
187    --- linux-2.6.21.7.orig/arch/s390/kernel/ptrace.c
188    +++ linux-2.6.21.7/arch/s390/kernel/ptrace.c
189  @@ -41,6 +41,9 @@  @@ -41,6 +41,9 @@
190   #include <asm/system.h>   #include <asm/system.h>
191   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 143  Source code for this patch is http://www Line 196  Source code for this patch is http://www
196    
197   #ifdef CONFIG_COMPAT   #ifdef CONFIG_COMPAT
198   #include "compat_ptrace.h"   #include "compat_ptrace.h"
199  @@ -713,6 +716,11 @@ sys_ptrace(long request, long pid, long  @@ -713,6 +716,10 @@ sys_ptrace(long request, long pid, long
200          struct task_struct *child;          struct task_struct *child;
201          int ret;          int ret;
202    
203  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
204  +#ifdef TOMOYO_SYS_PTRACE  +       if (!ccs_capable(CCS_SYS_PTRACE))
205  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +               return -EPERM;
 +#endif  
206  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
207          lock_kernel();          lock_kernel();
208          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
209                   ret = ptrace_traceme();                   ret = ptrace_traceme();
210  --- linux-2.6.21.orig/arch/sparc/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/sparc/kernel/ptrace.c
211  +++ linux-2.6.21/arch/sparc/kernel/ptrace.c  +++ linux-2.6.21.7/arch/sparc/kernel/ptrace.c
212  @@ -23,6 +23,9 @@  @@ -23,6 +23,9 @@
213   #include <asm/pgtable.h>   #include <asm/pgtable.h>
214   #include <asm/system.h>   #include <asm/system.h>
# Line 167  Source code for this patch is http://www Line 219  Source code for this patch is http://www
219    
220   #define MAGIC_CONSTANT 0x80000000   #define MAGIC_CONSTANT 0x80000000
221    
222  @@ -267,6 +270,14 @@ asmlinkage void do_ptrace(struct pt_regs  @@ -267,6 +270,12 @@ asmlinkage void do_ptrace(struct pt_regs
223          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
224          struct task_struct *child;          struct task_struct *child;
225          int ret;          int ret;
226  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
227  +#ifdef TOMOYO_SYS_PTRACE  +       if (!ccs_capable(CCS_SYS_PTRACE)) {
 +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) {  
228  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
229  +               return;  +               return;
230  +       }  +       }
 +#endif  
231  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
232    
233          lock_kernel();          lock_kernel();
234   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
235  --- linux-2.6.21.orig/arch/sparc64/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/sparc64/kernel/ptrace.c
236  +++ linux-2.6.21/arch/sparc64/kernel/ptrace.c  +++ linux-2.6.21.7/arch/sparc64/kernel/ptrace.c
237  @@ -32,6 +32,9 @@  @@ -32,6 +32,9 @@
238   #include <asm/spitfire.h>   #include <asm/spitfire.h>
239   #include <asm/page.h>   #include <asm/page.h>
# Line 194  Source code for this patch is http://www Line 244  Source code for this patch is http://www
244    
245   /* Returning from ptrace is a bit tricky because the syscall return   /* Returning from ptrace is a bit tricky because the syscall return
246    * low level code assumes any value returned which is negative and    * low level code assumes any value returned which is negative and
247  @@ -176,6 +179,14 @@ asmlinkage void do_ptrace(struct pt_regs  @@ -176,6 +179,12 @@ asmlinkage void do_ptrace(struct pt_regs
248          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
249          struct task_struct *child;          struct task_struct *child;
250          int ret;          int ret;
251  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
252  +#ifdef TOMOYO_SYS_PTRACE  +       if (!ccs_capable(CCS_SYS_PTRACE)) {
 +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) {  
253  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
254  +               return;  +               return;
255  +       }  +       }
 +#endif  
256  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
257    
258          if (test_thread_flag(TIF_32BIT)) {          if (test_thread_flag(TIF_32BIT)) {
259                  addr &= 0xffffffffUL;                  addr &= 0xffffffffUL;
260  --- linux-2.6.21.orig/fs/Kconfig  --- linux-2.6.21.7.orig/arch/x86_64/ia32/ptrace32.c
261  +++ linux-2.6.21/fs/Kconfig  +++ linux-2.6.21.7/arch/x86_64/ia32/ptrace32.c
262    @@ -26,6 +26,9 @@
263     #include <asm/i387.h>
264     #include <asm/fpu32.h>
265     #include <asm/ia32.h>
266    +/***** TOMOYO Linux start. *****/
267    +#include <linux/tomoyo.h>
268    +/***** TOMOYO Linux end. *****/
269    
270     /*
271      * Determines which flags the user has access to [1 = access, 0 = no access].
272    @@ -234,6 +237,10 @@ asmlinkage long sys32_ptrace(long reques
273            void __user *datap = compat_ptr(data);
274            int ret;
275            __u32 val;
276    +       /***** TOMOYO Linux start. *****/
277    +       if (!ccs_capable(CCS_SYS_PTRACE))
278    +               return -EPERM;
279    +       /***** TOMOYO Linux end. *****/
280    
281            switch (request) {
282            case PTRACE_TRACEME:
283    --- linux-2.6.21.7.orig/fs/Kconfig
284    +++ linux-2.6.21.7/fs/Kconfig
285  @@ -2055,5 +2055,7 @@ endif  @@ -2055,5 +2055,7 @@ endif
286   source "fs/nls/Kconfig"   source "fs/nls/Kconfig"
287   source "fs/dlm/Kconfig"   source "fs/dlm/Kconfig"
# Line 219  Source code for this patch is http://www Line 290  Source code for this patch is http://www
290  +  +
291   endmenu   endmenu
292    
293  --- linux-2.6.21.orig/fs/Makefile  --- linux-2.6.21.7.orig/fs/Makefile
294  +++ linux-2.6.21/fs/Makefile  +++ linux-2.6.21.7/fs/Makefile
295  @@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS)         += hppfs/  @@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS)         += hppfs/
296   obj-$(CONFIG_DEBUG_FS)         += debugfs/   obj-$(CONFIG_DEBUG_FS)         += debugfs/
297   obj-$(CONFIG_OCFS2_FS)         += ocfs2/   obj-$(CONFIG_OCFS2_FS)         += ocfs2/
298   obj-$(CONFIG_GFS2_FS)           += gfs2/   obj-$(CONFIG_GFS2_FS)           += gfs2/
299  +  +
300  +include $(srctree)/fs/Makefile-2.6.ccs  +include $(srctree)/fs/Makefile-2.6.ccs
301  --- linux-2.6.21.orig/fs/attr.c  --- linux-2.6.21.7.orig/fs/attr.c
302  +++ linux-2.6.21/fs/attr.c  +++ linux-2.6.21.7/fs/attr.c
303  @@ -15,6 +15,9 @@  @@ -15,6 +15,9 @@
304   #include <linux/fcntl.h>   #include <linux/fcntl.h>
305   #include <linux/quotaops.h>   #include <linux/quotaops.h>
# Line 239  Source code for this patch is http://www Line 310  Source code for this patch is http://www
310    
311   /* Taken over from the old code... */   /* Taken over from the old code... */
312    
313  @@ -145,12 +148,20 @@ int notify_change(struct dentry * dentry  @@ -145,12 +148,28 @@ int notify_change(struct dentry * dentry
314    
315          if (inode->i_op && inode->i_op->setattr) {          if (inode->i_op && inode->i_op->setattr) {
316                  error = security_inode_setattr(dentry, attr);                  error = security_inode_setattr(dentry, attr);
317  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
318  +               if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);  +               if (!error && (ia_valid & ATTR_MODE) &&
319  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);  +                   !ccs_capable(CCS_SYS_CHMOD))
320    +                       error = -EPERM;
321    +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
322    +                   !ccs_capable(CCS_SYS_CHOWN))
323    +                       error = -EPERM;
324  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
325                  if (!error)                  if (!error)
326                          error = inode->i_op->setattr(dentry, attr);                          error = inode->i_op->setattr(dentry, attr);
# Line 254  Source code for this patch is http://www Line 329  Source code for this patch is http://www
329                  if (!error)                  if (!error)
330                          error = security_inode_setattr(dentry, attr);                          error = security_inode_setattr(dentry, attr);
331  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
332  +               if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);  +               if (!error && (ia_valid & ATTR_MODE) &&
333  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);  +                   !ccs_capable(CCS_SYS_CHMOD))
334    +                       error = -EPERM;
335    +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
336    +                   !ccs_capable(CCS_SYS_CHOWN))
337    +                       error = -EPERM;
338  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
339                  if (!error) {                  if (!error) {
340                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
341                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
342  --- linux-2.6.21.orig/fs/compat.c  --- linux-2.6.21.7.orig/fs/compat.c
343  +++ linux-2.6.21/fs/compat.c  +++ linux-2.6.21.7/fs/compat.c
344  @@ -56,6 +56,9 @@  @@ -56,6 +56,9 @@
345   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
346   #include <asm/ioctls.h>   #include <asm/ioctls.h>
# Line 272  Source code for this patch is http://www Line 351  Source code for this patch is http://www
351    
352   int compat_log = 1;   int compat_log = 1;
353    
354  @@ -422,6 +425,9 @@ asmlinkage long compat_sys_ioctl(unsigne  @@ -398,6 +401,10 @@ asmlinkage long compat_sys_ioctl(unsigne
355    
356            /* RED-PEN how should LSM module know it's handling 32bit? */
357            error = security_file_ioctl(filp, cmd, arg);
358    +       /***** TOMOYO Linux start. *****/
359    +       if (!error)
360    +               error = ccs_check_ioctl_permission(filp, cmd, arg);
361    +       /***** TOMOYO Linux end. *****/
362            if (error)
363                    goto out_fput;
364    
365    @@ -422,6 +429,12 @@ asmlinkage long compat_sys_ioctl(unsigne
366                  /*FALL THROUGH*/                  /*FALL THROUGH*/
367    
368          default:          default:
369  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
370  +               if ((error = CheckCapabilityACL(TOMOYO_SYS_IOCTL)) < 0) goto out_fput;  +               if (!ccs_capable(CCS_SYS_IOCTL)) {
371    +                       error = -EPERM;
372    +                       goto out_fput;
373    +               }
374  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
375                  if (filp->f_op && filp->f_op->compat_ioctl) {                  if (filp->f_op && filp->f_op->compat_ioctl) {
376                          error = filp->f_op->compat_ioctl(filp, cmd, arg);                          error = filp->f_op->compat_ioctl(filp, cmd, arg);
377                          if (error != -ENOIOCTLCMD)                          if (error != -ENOIOCTLCMD)
378  @@ -1552,7 +1558,7 @@ int compat_do_execve(char * filename,  @@ -1552,7 +1565,7 @@ int compat_do_execve(char * filename,
379          if (retval < 0)          if (retval < 0)
380                  goto out;                  goto out;
381    
382  -       retval = search_binary_handler(bprm, regs);  -       retval = search_binary_handler(bprm, regs);
383  +       retval = search_binary_handler_with_transition(bprm, regs);  +       retval = ccs_search_binary_handler(bprm, regs);
384          if (retval >= 0) {          if (retval >= 0) {
385                  free_arg_pages(bprm);                  free_arg_pages(bprm);
386    
387  --- linux-2.6.21.orig/fs/exec.c  --- linux-2.6.21.7.orig/fs/exec.c
388  +++ linux-2.6.21/fs/exec.c  +++ linux-2.6.21.7/fs/exec.c
389  @@ -58,6 +58,10 @@  @@ -58,6 +58,10 @@
390   #include <linux/kmod.h>   #include <linux/kmod.h>
391   #endif   #endif
# Line 304  Source code for this patch is http://www Line 397  Source code for this patch is http://www
397   int core_uses_pid;   int core_uses_pid;
398   char core_pattern[128] = "core";   char core_pattern[128] = "core";
399   int suid_dumpable = 0;   int suid_dumpable = 0;
400  @@ -140,6 +144,11 @@ asmlinkage long sys_uselib(const char __  @@ -140,6 +144,12 @@ asmlinkage long sys_uselib(const char __
401          if (error)          if (error)
402                  goto exit;                  goto exit;
403    
404  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
405  +       error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */  +       error = ccs_check_uselib_permission(nd.dentry, nd.mnt);
406  +       if (error) goto exit;  +       if (error)
407    +               goto exit;
408  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
409  +  +
410          file = nameidata_to_filp(&nd, O_RDONLY);          file = nameidata_to_filp(&nd, O_RDONLY);
411          error = PTR_ERR(file);          error = PTR_ERR(file);
412          if (IS_ERR(file))          if (IS_ERR(file))
413  @@ -485,6 +494,9 @@ struct file *open_exec(const char *name)  @@ -485,6 +495,11 @@ struct file *open_exec(const char *name)
414                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
415                      S_ISREG(inode->i_mode)) {                      S_ISREG(inode->i_mode)) {
416                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
417  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
418  +                       if (!err && (current->tomoyo_flags & TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) err = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */  +                       if (!err)
419    +                               err = ccs_check_open_exec_permission(nd.dentry,
420    +                                                                    nd.mnt);
421  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
422                          file = ERR_PTR(err);                          file = ERR_PTR(err);
423                          if (!err) {                          if (!err) {
424                                  file = nameidata_to_filp(&nd, O_RDONLY);                                  file = nameidata_to_filp(&nd, O_RDONLY);
425  @@ -1183,7 +1195,7 @@ int do_execve(char * filename,  @@ -1183,7 +1198,7 @@ int do_execve(char * filename,
426          if (retval < 0)          if (retval < 0)
427                  goto out;                  goto out;
428    
429  -       retval = search_binary_handler(bprm,regs);  -       retval = search_binary_handler(bprm,regs);
430  +       retval = search_binary_handler_with_transition(bprm,regs);  +       retval = ccs_search_binary_handler(bprm, regs);
431          if (retval >= 0) {          if (retval >= 0) {
432                  free_arg_pages(bprm);                  free_arg_pages(bprm);
433    
434  --- linux-2.6.21.orig/fs/fcntl.c  --- linux-2.6.21.7.orig/fs/fcntl.c
435  +++ linux-2.6.21/fs/fcntl.c  +++ linux-2.6.21.7/fs/fcntl.c
436  @@ -22,6 +22,9 @@  @@ -22,6 +22,9 @@
437   #include <asm/poll.h>   #include <asm/poll.h>
438   #include <asm/siginfo.h>   #include <asm/siginfo.h>
# Line 347  Source code for this patch is http://www Line 443  Source code for this patch is http://www
443    
444   void fastcall set_close_on_exec(unsigned int fd, int flag)   void fastcall set_close_on_exec(unsigned int fd, int flag)
445   {   {
446  @@ -213,6 +216,10 @@ static int setfl(int fd, struct file * f  @@ -213,6 +216,12 @@ static int setfl(int fd, struct file * f
447          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
448                  return -EPERM;                  return -EPERM;
449    
450  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
451  +       if (((arg ^ filp->f_flags) & O_APPEND) && CheckReWritePermission(filp)) return -EPERM;  +       if (((arg ^ filp->f_flags) & O_APPEND) &&
452    +           ccs_check_rewrite_permission(filp))
453    +               return -EPERM;
454  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
455  +  +
456          /* O_NOATIME can only be set by the owner or superuser */          /* O_NOATIME can only be set by the owner or superuser */
457          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
458                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
459  --- linux-2.6.21.orig/fs/ioctl.c  --- linux-2.6.21.7.orig/fs/ioctl.c
460  +++ linux-2.6.21/fs/ioctl.c  +++ linux-2.6.21.7/fs/ioctl.c
461  @@ -15,6 +15,9 @@  @@ -15,6 +15,9 @@
462    
463   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 370  Source code for this patch is http://www Line 468  Source code for this patch is http://www
468    
469   static long do_ioctl(struct file *filp, unsigned int cmd,   static long do_ioctl(struct file *filp, unsigned int cmd,
470                  unsigned long arg)                  unsigned long arg)
471  @@ -23,6 +26,9 @@ static long do_ioctl(struct file *filp,  @@ -23,6 +26,10 @@ static long do_ioctl(struct file *filp,
472    
473          if (!filp->f_op)          if (!filp->f_op)
474                  goto out;                  goto out;
475  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
476  +       if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM;  +       if (!ccs_capable(CCS_SYS_IOCTL))
477    +               return -EPERM;
478  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
479    
480          if (filp->f_op->unlocked_ioctl) {          if (filp->f_op->unlocked_ioctl) {
481                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
482  --- linux-2.6.21.orig/fs/namei.c  @@ -167,6 +174,10 @@ asmlinkage long sys_ioctl(unsigned int f
483  +++ linux-2.6.21/fs/namei.c                  goto out;
484    
485            error = security_file_ioctl(filp, cmd, arg);
486    +       /***** TOMOYO Linux start. *****/
487    +       if (!error)
488    +               error = ccs_check_ioctl_permission(filp, cmd, arg);
489    +       /***** TOMOYO Linux end. *****/
490            if (error)
491                    goto out_fput;
492    
493    --- linux-2.6.21.7.orig/fs/namei.c
494    +++ linux-2.6.21.7/fs/namei.c
495  @@ -37,6 +37,10 @@  @@ -37,6 +37,10 @@
496    
497   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
# Line 393  Source code for this patch is http://www Line 503  Source code for this patch is http://www
503   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
504    * Fundamental changes in the pathname lookup mechanisms (namei)    * Fundamental changes in the pathname lookup mechanisms (namei)
505    * were necessary because of omirr.  The reason is that omirr needs    * were necessary because of omirr.  The reason is that omirr needs
506  @@ -1506,6 +1510,9 @@ int vfs_create(struct inode *dir, struct  @@ -1561,6 +1565,13 @@ 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 = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;  
 +       /***** TOMOYO Linux end. *****/  
         DQUOT_INIT(dir);  
         error = dir->i_op->create(dir, dentry, mode, nd);  
         if (!error)  
 @@ -1561,6 +1568,11 @@ int may_open(struct nameidata *nd, int a  
507                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
508                          return -EPERM;                          return -EPERM;
509    
510  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
511  +       error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
512  +       if (error) return error;  +       error = ccs_check_open_permission(dentry, nd->mnt, flag);
513    +       if (error)
514    +               return error;
515  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
516  +  +
517          /*          /*
518           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
519           */           */
520  @@ -1610,6 +1622,9 @@ static int open_namei_create(struct name  @@ -1600,6 +1611,11 @@ static int open_namei_create(struct name
521    
522            if (!IS_POSIXACL(dir->d_inode))
523                    mode &= ~current->fs->umask;
524    +       /***** TOMOYO Linux start. *****/
525    +       error = ccs_check_mknod_permission(dir->d_inode, path->dentry, nd->mnt,
526    +                                          mode, 0);
527    +       if (!error)
528    +       /***** TOMOYO Linux end. *****/
529            error = vfs_create(dir->d_inode, path->dentry, mode, nd);
530            mutex_unlock(&dir->d_inode->i_mutex);
531            dput(nd->dentry);
532    @@ -1610,6 +1626,9 @@ static int open_namei_create(struct name
533          return may_open(nd, 0, flag & ~O_TRUNC);          return may_open(nd, 0, flag & ~O_TRUNC);
534   }   }
535    
# Line 425  Source code for this patch is http://www Line 539  Source code for this patch is http://www
539   /*   /*
540    *     open_namei()    *     open_namei()
541    *    *
542  @@ -1870,6 +1885,12 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1883,6 +1902,12 @@ asmlinkage long sys_mknodat(int dfd, con
543            if (!IS_POSIXACL(nd.dentry->d_inode))
544          if (S_ISDIR(mode))                  mode &= ~current->fs->umask;
545                  return -EPERM;          if (!IS_ERR(dentry)) {
546  +       /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
547  +       if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;  +               error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
548  +       if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;  +                                                  nd.mnt, mode,
549  +       if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM;  +                                                  new_decode_dev(dev));
550  +       if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;  +               if (!error)
551  +       /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
552          tmp = getname(filename);                  switch (mode & S_IFMT) {
553          if (IS_ERR(tmp))                  case 0: case S_IFREG:
                 return PTR_ERR(tmp);  
 @@ -1888,10 +1909,16 @@ asmlinkage long sys_mknodat(int dfd, con  
554                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
555                          break;  @@ -1959,6 +1984,11 @@ asmlinkage long sys_mkdirat(int dfd, con
                 case S_IFCHR: case S_IFBLK:  
 +                       /***** TOMOYO Linux start. *****/  
 +                       if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISCHR(mode) ? TYPE_MKCHAR_ACL : TYPE_MKBLOCK_ACL, dentry, nd.mnt)) == 0)  
 +                       /***** 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. *****/  
 +                       if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISFIFO(mode) ? TYPE_MKFIFO_ACL : TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)  
 +                       /***** TOMOYO Linux end. *****/  
                         error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);  
                         break;  
                 case S_IFDIR:  
 @@ -1959,6 +1986,9 @@ asmlinkage long sys_mkdirat(int dfd, con  
556    
557          if (!IS_POSIXACL(nd.dentry->d_inode))          if (!IS_POSIXACL(nd.dentry->d_inode))
558                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
559  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
560  +       if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)  +       error = ccs_check_mkdir_permission(nd.dentry->d_inode, dentry, nd.mnt,
561    +                                          mode);
562    +       if (!error)
563  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
564          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
565          dput(dentry);          dput(dentry);
566   out_unlock:   out_unlock:
567  @@ -2066,6 +2096,9 @@ static long do_rmdir(int dfd, const char  @@ -2066,6 +2096,10 @@ static long do_rmdir(int dfd, const char
568          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
569          if (IS_ERR(dentry))          if (IS_ERR(dentry))
570                  goto exit2;                  goto exit2;
571  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
572  +       if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)  +       error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry, nd.mnt);
573    +       if (!error)
574  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
575          error = vfs_rmdir(nd.dentry->d_inode, dentry);          error = vfs_rmdir(nd.dentry->d_inode, dentry);
576          dput(dentry);          dput(dentry);
577   exit2:   exit2:
578  @@ -2125,6 +2158,9 @@ static long do_unlinkat(int dfd, const c  @@ -2146,6 +2180,11 @@ static long do_unlinkat(int dfd, const c
         struct dentry *dentry;  
         struct nameidata nd;  
         struct inode *inode = NULL;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         name = getname(pathname);  
         if(IS_ERR(name))  
 @@ -2146,6 +2182,9 @@ static long do_unlinkat(int dfd, const c  
579                  inode = dentry->d_inode;                  inode = dentry->d_inode;
580                  if (inode)                  if (inode)
581                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
582  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
583  +               if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)  +               error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,
584  +               /***** TOMOYO Linux end. *****/  +                                                   nd.mnt);
585    +               if (!error)
586    +               /***** TOMOYO Linux end. *****/
587                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
588          exit2:          exit2:
589                  dput(dentry);                  dput(dentry);
590  @@ -2210,6 +2249,9 @@ asmlinkage long sys_symlinkat(const char  @@ -2227,6 +2266,11 @@ asmlinkage long sys_symlinkat(const char
         char * to;  
         struct dentry *dentry;  
         struct nameidata nd;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         from = getname(oldname);  
         if(IS_ERR(from))  
 @@ -2227,6 +2269,9 @@ asmlinkage long sys_symlinkat(const char  
591          if (IS_ERR(dentry))          if (IS_ERR(dentry))
592                  goto out_unlock;                  goto out_unlock;
593    
594  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
595  +       if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)  +       error = ccs_check_symlink_permission(nd.dentry->d_inode, dentry,
596    +                                            nd.mnt, from);
597    +       if (!error)
598  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
599          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
600          dput(dentry);          dput(dentry);
601   out_unlock:   out_unlock:
602  @@ -2299,6 +2344,9 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2322,6 +2366,11 @@ asmlinkage long sys_linkat(int olddfd, c
         struct nameidata nd, old_nd;  
         int error;  
         char * to;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         if ((flags & ~AT_SYMLINK_FOLLOW) != 0)  
                 return -EINVAL;  
 @@ -2322,6 +2370,9 @@ asmlinkage long sys_linkat(int olddfd, c  
603          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
604          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
605                  goto out_unlock;                  goto out_unlock;
606  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
607  +       if ((error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry)) == 0 && (error = CheckDoubleWritePermission(TYPE_LINK_ACL, old_nd.dentry, old_nd.mnt, new_dentry, nd.mnt)) == 0)  +       error = ccs_check_link_permission(old_nd.dentry, nd.dentry->d_inode,
608    +                                         new_dentry, nd.mnt);
609    +       if (!error)
610  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
611          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
612          dput(new_dentry);          dput(new_dentry);
613   out_unlock:   out_unlock:
614  @@ -2547,6 +2598,12 @@ static int do_rename(int olddfd, const c  @@ -2547,6 +2596,12 @@ static int do_rename(int olddfd, const c
615          error = -ENOTEMPTY;          error = -ENOTEMPTY;
616          if (new_dentry == trap)          if (new_dentry == trap)
617                  goto exit5;                  goto exit5;
618  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
619  +       if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||  +       error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,
620  +               (error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {  +                                           new_dir->d_inode, new_dentry,
621  +               goto exit5;  +                                           newnd.mnt);
622  +       }  +       if (!error)
623  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
624    
625          error = vfs_rename(old_dir->d_inode, old_dentry,          error = vfs_rename(old_dir->d_inode, old_dentry,
626                                     new_dir->d_inode, new_dentry);                                     new_dir->d_inode, new_dentry);
627  @@ -2570,6 +2627,9 @@ asmlinkage long sys_renameat(int olddfd,  --- linux-2.6.21.7.orig/fs/namespace.c
628          int error;  +++ linux-2.6.21.7/fs/namespace.c
         char * from;  
         char * to;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         from = getname(oldname);  
         if(IS_ERR(from))  
 --- linux-2.6.21.orig/fs/namespace.c  
 +++ linux-2.6.21/fs/namespace.c  
629  @@ -28,6 +28,12 @@  @@ -28,6 +28,12 @@
630   #include <asm/uaccess.h>   #include <asm/uaccess.h>
631   #include <asm/unistd.h>   #include <asm/unistd.h>
# Line 573  Source code for this patch is http://www Line 639  Source code for this patch is http://www
639    
640   /* spinlock for vfsmount related operations, inplace of dcache_lock */   /* spinlock for vfsmount related operations, inplace of dcache_lock */
641   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
642  @@ -545,6 +551,10 @@ static int do_umount(struct vfsmount *mn  @@ -545,6 +551,11 @@ static int do_umount(struct vfsmount *mn
643          if (retval)          if (retval)
644                  return retval;                  return retval;
645    
646  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
647  +       if (SAKURA_MayUmount(mnt) < 0) return -EPERM;  +       if (ccs_may_umount(mnt))
648    +               return -EPERM;
649  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
650  +  +
651          /*          /*
652           * Allow userspace to request a mountpoint be expired rather than           * Allow userspace to request a mountpoint be expired rather than
653           * unmounting unconditionally. Unmount only happens if:           * unmounting unconditionally. Unmount only happens if:
654  @@ -633,6 +643,9 @@ asmlinkage long sys_umount(char __user *  @@ -633,6 +644,10 @@ asmlinkage long sys_umount(char __user *
655   {   {
656          struct nameidata nd;          struct nameidata nd;
657          int retval;          int retval;
658  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
659  +       if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_UMOUNT))
660    +               return -EPERM;
661  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
662    
663          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
664          if (retval)          if (retval)
665  @@ -917,6 +930,10 @@ static int do_loopback(struct nameidata  @@ -917,6 +932,11 @@ static int do_loopback(struct nameidata
666    
667          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
668                  goto out;                  goto out;
669  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
670  +       err = -EPERM;  +       err = -EPERM;
671  +       if (SAKURA_MayMount(nd) < 0) goto out;  +       if (ccs_may_mount(nd))
672    +               goto out;
673  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
674    
675          err = -ENOMEM;          err = -ENOMEM;
676          if (recurse)          if (recurse)
677  @@ -1002,6 +1019,10 @@ static int do_move_mount(struct nameidat  @@ -1002,6 +1022,11 @@ static int do_move_mount(struct nameidat
678          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
679                  goto out;                  goto out;
680    
681  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
682  +       err = -EPERM;  +       err = -EPERM;
683  +       if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0) goto out;  +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
684    +               goto out;
685  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
686          err = -ENOENT;          err = -ENOENT;
687          mutex_lock(&nd->dentry->d_inode->i_mutex);          mutex_lock(&nd->dentry->d_inode->i_mutex);
688          if (IS_DEADDIR(nd->dentry->d_inode))          if (IS_DEADDIR(nd->dentry->d_inode))
689  @@ -1103,6 +1124,10 @@ int do_add_mount(struct vfsmount *newmnt  @@ -1103,6 +1128,11 @@ int do_add_mount(struct vfsmount *newmnt
690          err = -EINVAL;          err = -EINVAL;
691          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
692                  goto unlock;                  goto unlock;
693  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
694  +       err = -EPERM;  +       err = -EPERM;
695  +       if (SAKURA_MayMount(nd) < 0) goto unlock;  +       if (ccs_may_mount(nd))
696    +               goto unlock;
697  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
698    
699          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
700          if ((err = graft_tree(newmnt, nd)))          if ((err = graft_tree(newmnt, nd)))
701  @@ -1394,6 +1419,13 @@ long do_mount(char *dev_name, char *dir_  @@ -1394,6 +1424,17 @@ long do_mount(char *dev_name, char *dir_
702          if (data_page)          if (data_page)
703                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                  ((char *)data_page)[PAGE_SIZE - 1] = 0;
704    
705  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
706  +       if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_MOUNT))
707    +               return -EPERM;
708  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
709  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
710  +       if ((retval = CheckMountPermission(dev_name, dir_name, type_page, &flags)) < 0) return retval;  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
711    +                                           &flags);
712    +       if (retval)
713    +               return retval;
714  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
715  +  +
716          /* Separate the per-mountpoint flags */          /* Separate the per-mountpoint flags */
717          if (flags & MS_NOSUID)          if (flags & MS_NOSUID)
718                  mnt_flags |= MNT_NOSUID;                  mnt_flags |= MNT_NOSUID;
719  @@ -1686,6 +1718,9 @@ asmlinkage long sys_pivot_root(const cha  @@ -1686,6 +1727,10 @@ asmlinkage long sys_pivot_root(const cha
720    
721          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
722                  return -EPERM;                  return -EPERM;
723  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
724  +       if (CheckCapabilityACL(TOMOYO_SYS_PIVOT_ROOT)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
725    +               return -EPERM;
726  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
727    
728          lock_kernel();          lock_kernel();
729    
730  @@ -1702,6 +1737,9 @@ asmlinkage long sys_pivot_root(const cha  @@ -1702,6 +1747,10 @@ asmlinkage long sys_pivot_root(const cha
731                  goto out1;                  goto out1;
732    
733          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
734  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
735  +       if (!error) error = CheckPivotRootPermission(&old_nd, &new_nd);  +       if (!error)
736    +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
737  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
738          if (error) {          if (error) {
739                  path_release(&old_nd);                  path_release(&old_nd);
740                  goto out1;                  goto out1;
741  --- linux-2.6.21.orig/fs/open.c  --- linux-2.6.21.7.orig/fs/open.c
742  +++ linux-2.6.21/fs/open.c  +++ linux-2.6.21.7/fs/open.c
743  @@ -27,6 +27,12 @@  @@ -27,6 +27,12 @@
744   #include <linux/syscalls.h>   #include <linux/syscalls.h>
745   #include <linux/rcupdate.h>   #include <linux/rcupdate.h>
# Line 676  Source code for this patch is http://www Line 753  Source code for this patch is http://www
753    
754   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
755   {   {
756  @@ -264,6 +270,9 @@ static long do_sys_truncate(const char _  @@ -264,6 +270,10 @@ static long do_sys_truncate(const char _
757          if (error)          if (error)
758                  goto dput_and_out;                  goto dput_and_out;
759    
760  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
761  +       if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)  +       error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);
762    +       if (!error)
763  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
764          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
765          if (!error) {          if (!error) {
766                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
767  @@ -317,6 +326,9 @@ static long do_sys_ftruncate(unsigned in  @@ -317,6 +327,12 @@ static long do_sys_ftruncate(unsigned in
768          if (IS_APPEND(inode))          if (IS_APPEND(inode))
769                  goto out_putf;                  goto out_putf;
770    
771  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
772  +       if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)  +       error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
773    +                                             0);
774    +       if (error)
775    +               goto out_putf;
776  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
777          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
778          if (!error)          if (!error)
779                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
780  @@ -481,6 +493,12 @@ asmlinkage long sys_chroot(const char __  @@ -481,6 +497,14 @@ asmlinkage long sys_chroot(const char __
781          error = -EPERM;          error = -EPERM;
782          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
783                  goto dput_and_out;                  goto dput_and_out;
784  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
785  +       if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) goto dput_and_out;  +       if (!ccs_capable(CCS_SYS_CHROOT))
786    +               goto dput_and_out;
787  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
788  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
789  +       if (CheckChRootPermission(&nd)) goto dput_and_out;  +       if (ccs_check_chroot_permission(&nd))
790    +               goto dput_and_out;
791  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
792    
793          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
794          set_fs_altroot();          set_fs_altroot();
795  @@ -1085,6 +1103,9 @@ EXPORT_SYMBOL(sys_close);  @@ -1085,6 +1109,10 @@ EXPORT_SYMBOL(sys_close);
796    */    */
797   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
798   {   {
799  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
800  +       if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0)  +       if (!ccs_capable(CCS_SYS_VHANGUP))
801    +               return -EPERM;
802  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
803          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
804                  /* XXX: this needs locking */                  /* XXX: this needs locking */
805                  tty_vhangup(current->signal->tty);                  tty_vhangup(current->signal->tty);
806  --- linux-2.6.21.orig/fs/proc/Makefile  --- linux-2.6.21.7.orig/fs/proc/Makefile
807  +++ linux-2.6.21/fs/proc/Makefile  +++ linux-2.6.21.7/fs/proc/Makefile
808  @@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE)     += kcore.o  @@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE)     += kcore.o
809   proc-$(CONFIG_PROC_VMCORE)     += vmcore.o   proc-$(CONFIG_PROC_VMCORE)     += vmcore.o
810   proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o   proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
# Line 728  Source code for this patch is http://www Line 812  Source code for this patch is http://www
812  +  +
813  +proc-$(CONFIG_SAKURA) += ccs_proc.o  +proc-$(CONFIG_SAKURA) += ccs_proc.o
814  +proc-$(CONFIG_TOMOYO) += ccs_proc.o  +proc-$(CONFIG_TOMOYO) += ccs_proc.o
815  --- linux-2.6.21.orig/fs/proc/proc_misc.c  --- linux-2.6.21.7.orig/fs/proc/proc_misc.c
816  +++ linux-2.6.21/fs/proc/proc_misc.c  +++ linux-2.6.21.7/fs/proc/proc_misc.c
817  @@ -747,4 +747,13 @@ void __init proc_misc_init(void)  @@ -747,4 +747,9 @@ void __init proc_misc_init(void)
818                          entry->proc_fops = &proc_sysrq_trigger_operations;                          entry->proc_fops = &proc_sysrq_trigger_operations;
819          }          }
820   #endif   #endif
821  +       /***** CCS start. *****/  +       /***** CCS start. *****/
822  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
823  +       {  +       printk(KERN_INFO "Hook version: 2.6.21.7 2009/03/24\n");
 +               extern void __init CCSProc_Init(void);  
 +               CCSProc_Init();  
 +               printk("Hook version: 2.6.21 2008/01/05\n");  
 +       }  
824  +#endif  +#endif
825  +       /***** CCS end. *****/  +       /***** CCS end. *****/
826   }   }
827  --- linux-2.6.21.orig/include/linux/init_task.h  --- linux-2.6.21.7.orig/include/linux/init_task.h
828  +++ linux-2.6.21/include/linux/init_task.h  +++ linux-2.6.21.7/include/linux/init_task.h
829  @@ -141,6 +141,10 @@ extern struct group_info init_groups;  @@ -141,6 +141,10 @@ extern struct group_info init_groups;
830          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \
831          INIT_TRACE_IRQFLAGS                                             \          INIT_TRACE_IRQFLAGS                                             \
832          INIT_LOCKDEP                                                    \          INIT_LOCKDEP                                                    \
833  +       /***** TOMOYO Linux start. *****/        \  +       /***** TOMOYO Linux start. *****/        \
834  +       .domain_info = &KERNEL_DOMAIN,           \  +       .ccs_domain_info = NULL,                 \
835  +       .tomoyo_flags = 0,                       \  +       .ccs_flags = 0,                          \
836  +       /***** TOMOYO Linux end. *****/          \  +       /***** TOMOYO Linux end. *****/          \
837   }   }
838    
839    
840  --- linux-2.6.21.orig/include/linux/sched.h  --- linux-2.6.21.7.orig/include/linux/sched.h
841  +++ linux-2.6.21/include/linux/sched.h  +++ linux-2.6.21.7/include/linux/sched.h
842  @@ -27,6 +27,11 @@  @@ -27,6 +27,10 @@
843   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */
844   #define CLONE_NEWIPC           0x08000000      /* New ipcs */   #define CLONE_NEWIPC           0x08000000      /* New ipcs */
845    
846  +/***** TOMOYO Linux start. *****/  +/***** TOMOYO Linux start. *****/
847  +struct domain_info;  +struct ccs_domain_info;
 +extern struct domain_info KERNEL_DOMAIN;  
848  +/***** TOMOYO Linux end. *****/  +/***** TOMOYO Linux end. *****/
849  +  +
850   /*   /*
851    * Scheduling policies    * Scheduling policies
852    */    */
853  @@ -1052,6 +1057,10 @@ struct task_struct {  @@ -1052,6 +1056,10 @@ struct task_struct {
854   #ifdef CONFIG_FAULT_INJECTION   #ifdef CONFIG_FAULT_INJECTION
855          int make_it_fail;          int make_it_fail;
856   #endif   #endif
857  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
858  +       struct domain_info *domain_info;  +       struct ccs_domain_info *ccs_domain_info;
859  +       u32 tomoyo_flags;  +       u32 ccs_flags;
860  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
861   };   };
862    
863   static inline pid_t process_group(struct task_struct *tsk)   static inline pid_t process_group(struct task_struct *tsk)
864  --- linux-2.6.21.orig/kernel/compat.c  --- linux-2.6.21.7.orig/kernel/compat.c
865  +++ linux-2.6.21/kernel/compat.c  +++ linux-2.6.21.7/kernel/compat.c
866  @@ -25,6 +25,9 @@  @@ -25,6 +25,9 @@
867   #include <linux/posix-timers.h>   #include <linux/posix-timers.h>
868    
# Line 794  Source code for this patch is http://www Line 873  Source code for this patch is http://www
873    
874   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)
875   {   {
876  @@ -869,6 +872,9 @@ asmlinkage long compat_sys_stime(compat_  @@ -869,6 +872,10 @@ asmlinkage long compat_sys_stime(compat_
877          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
878          if (err)          if (err)
879                  return err;                  return err;
880  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
881  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_SETTIME))
882    +               return -EPERM;
883  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
884    
885          do_settimeofday(&tv);          do_settimeofday(&tv);
886          return 0;          return 0;
887  --- linux-2.6.21.orig/kernel/kexec.c  --- linux-2.6.21.7.orig/kernel/kexec.c
888  +++ linux-2.6.21/kernel/kexec.c  +++ linux-2.6.21.7/kernel/kexec.c
889  @@ -28,6 +28,9 @@  @@ -28,6 +28,9 @@
890   #include <asm/io.h>   #include <asm/io.h>
891   #include <asm/system.h>   #include <asm/system.h>
# Line 816  Source code for this patch is http://www Line 896  Source code for this patch is http://www
896    
897   /* Per cpu memory for storing cpu states in case of system crash. */   /* Per cpu memory for storing cpu states in case of system crash. */
898   note_buf_t* crash_notes;   note_buf_t* crash_notes;
899  @@ -924,6 +927,9 @@ asmlinkage long sys_kexec_load(unsigned  @@ -924,6 +927,10 @@ asmlinkage long sys_kexec_load(unsigned
900          /* We only trust the superuser with rebooting the system. */          /* We only trust the superuser with rebooting the system. */
901          if (!capable(CAP_SYS_BOOT))          if (!capable(CAP_SYS_BOOT))
902                  return -EPERM;                  return -EPERM;
903  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
904  +       if (CheckCapabilityACL(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
905    +               return -EPERM;
906  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
907    
908          /*          /*
909           * Verify we have a legal set of flags           * Verify we have a legal set of flags
910  --- linux-2.6.21.orig/kernel/kmod.c  --- linux-2.6.21.7.orig/kernel/kmod.c
911  +++ linux-2.6.21/kernel/kmod.c  +++ linux-2.6.21.7/kernel/kmod.c
912  @@ -166,6 +166,11 @@ static int ____call_usermodehelper(void  @@ -166,6 +166,11 @@ static int ____call_usermodehelper(void
913          /* We can run anywhere, unlike our parent keventd(). */          /* We can run anywhere, unlike our parent keventd(). */
914          set_cpus_allowed(current, CPU_MASK_ALL);          set_cpus_allowed(current, CPU_MASK_ALL);
915    
916  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
917  +       current->domain_info = &KERNEL_DOMAIN;  +       current->ccs_domain_info = NULL;
918  +       current->tomoyo_flags = 0;  +       current->ccs_flags = 0;
919  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
920  +  +
921          retval = -EPERM;          retval = -EPERM;
922          if (current->fs->root)          if (current->fs->root)
923                  retval = kernel_execve(sub_info->path,                  retval = kernel_execve(sub_info->path,
924  --- linux-2.6.21.orig/kernel/module.c  --- linux-2.6.21.7.orig/kernel/module.c
925  +++ linux-2.6.21/kernel/module.c  +++ linux-2.6.21.7/kernel/module.c
926  @@ -44,6 +44,9 @@  @@ -44,6 +44,9 @@
927   #include <asm/semaphore.h>   #include <asm/semaphore.h>
928   #include <asm/cacheflush.h>   #include <asm/cacheflush.h>
# Line 852  Source code for this patch is http://www Line 933  Source code for this patch is http://www
933    
934   #if 0   #if 0
935   #define DEBUGP printk   #define DEBUGP printk
936  @@ -662,6 +665,9 @@ sys_delete_module(const char __user *nam  @@ -662,6 +665,10 @@ sys_delete_module(const char __user *nam
937    
938          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
939                  return -EPERM;                  return -EPERM;
940  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
941  +       if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))
942    +               return -EPERM;
943  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
944    
945          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
946                  return -EFAULT;                  return -EFAULT;
947  @@ -1983,6 +1989,9 @@ sys_init_module(void __user *umod,  @@ -1983,6 +1990,10 @@ sys_init_module(void __user *umod,
948          /* Must have permission */          /* Must have permission */
949          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
950                  return -EPERM;                  return -EPERM;
951  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
952  +       if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))
953    +               return -EPERM;
954  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
955    
956          /* Only one module load at a time, please */          /* Only one module load at a time, please */
957          if (mutex_lock_interruptible(&module_mutex) != 0)          if (mutex_lock_interruptible(&module_mutex) != 0)
958  --- linux-2.6.21.orig/kernel/ptrace.c  --- linux-2.6.21.7.orig/kernel/ptrace.c
959  +++ linux-2.6.21/kernel/ptrace.c  +++ linux-2.6.21.7/kernel/ptrace.c
960  @@ -21,6 +21,9 @@  @@ -21,6 +21,9 @@
961    
962   #include <asm/pgtable.h>   #include <asm/pgtable.h>
# Line 884  Source code for this patch is http://www Line 967  Source code for this patch is http://www
967    
968   /*   /*
969    * ptrace a task: make the debugger its new parent and    * ptrace a task: make the debugger its new parent and
970  @@ -456,6 +459,11 @@ asmlinkage long sys_ptrace(long request,  @@ -456,6 +459,10 @@ asmlinkage long sys_ptrace(long request,
971          /*          /*
972           * This lock_kernel fixes a subtle race with suid exec           * This lock_kernel fixes a subtle race with suid exec
973           */           */
974  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
975  +#ifdef TOMOYO_SYS_PTRACE  +       if (!ccs_capable(CCS_SYS_PTRACE))
976  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +               return -EPERM;
 +#endif  
977  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
978          lock_kernel();          lock_kernel();
979          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
980                  ret = ptrace_traceme();                  ret = ptrace_traceme();
981  --- linux-2.6.21.orig/kernel/sched.c  --- linux-2.6.21.7.orig/kernel/sched.c
982  +++ linux-2.6.21/kernel/sched.c  +++ linux-2.6.21.7/kernel/sched.c
983  @@ -55,6 +55,9 @@  @@ -55,6 +55,9 @@
984   #include <asm/tlb.h>   #include <asm/tlb.h>
985    
# Line 908  Source code for this patch is http://www Line 990  Source code for this patch is http://www
990    
991   /*   /*
992    * Scheduler clock - returns current time in nanosec units.    * Scheduler clock - returns current time in nanosec units.
993  @@ -3960,6 +3963,9 @@ int can_nice(const struct task_struct *p  @@ -3964,6 +3967,10 @@ int can_nice(const struct task_struct *p
994   asmlinkage long sys_nice(int increment)   asmlinkage long sys_nice(int increment)
995   {   {
996          long nice, retval;          long nice, retval;
997  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
998  +       if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_NICE))
999    +               return -EPERM;
1000  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1001    
1002          /*          /*
1003           * Setpriority might change our priority at the same moment.           * Setpriority might change our priority at the same moment.
1004  --- linux-2.6.21.orig/kernel/signal.c  --- linux-2.6.21.7.orig/kernel/signal.c
1005  +++ linux-2.6.21/kernel/signal.c  +++ linux-2.6.21.7/kernel/signal.c
1006  @@ -32,6 +32,9 @@  @@ -32,6 +32,9 @@
1007   #include <asm/unistd.h>   #include <asm/unistd.h>
1008   #include <asm/siginfo.h>   #include <asm/siginfo.h>
# Line 930  Source code for this patch is http://www Line 1013  Source code for this patch is http://www
1013    
1014   /*   /*
1015    * SLAB caches for signal bits.    * SLAB caches for signal bits.
1016  @@ -2235,6 +2238,10 @@ asmlinkage long  @@ -2235,6 +2238,12 @@ asmlinkage long
1017   sys_kill(int pid, int sig)   sys_kill(int pid, int sig)
1018   {   {
1019          struct siginfo info;          struct siginfo info;
1020  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1021  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(CCS_SYS_KILL))
1022  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1023    +       if (sig && ccs_check_signal_acl(sig, pid))
1024    +               return -EPERM;
1025  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1026    
1027          info.si_signo = sig;          info.si_signo = sig;
1028          info.si_errno = 0;          info.si_errno = 0;
1029  @@ -2293,6 +2300,10 @@ asmlinkage long sys_tgkill(int tgid, int  @@ -2293,6 +2302,12 @@ asmlinkage long sys_tgkill(int tgid, int
1030          /* This is only valid for single tasks */          /* This is only valid for single tasks */
1031          if (pid <= 0 || tgid <= 0)          if (pid <= 0 || tgid <= 0)
1032                  return -EINVAL;                  return -EINVAL;
1033  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1034  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(CCS_SYS_KILL))
1035  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1036    +       if (sig && ccs_check_signal_acl(sig, pid))
1037    +               return -EPERM;
1038  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1039    
1040          return do_tkill(tgid, pid, sig);          return do_tkill(tgid, pid, sig);
1041   }   }
1042  @@ -2306,6 +2317,10 @@ sys_tkill(int pid, int sig)  @@ -2306,6 +2321,12 @@ sys_tkill(int pid, int sig)
1043          /* This is only valid for single tasks */          /* This is only valid for single tasks */
1044          if (pid <= 0)          if (pid <= 0)
1045                  return -EINVAL;                  return -EINVAL;
1046  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1047  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(CCS_SYS_KILL))
1048  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1049    +       if (sig && ccs_check_signal_acl(sig, pid))
1050    +               return -EPERM;
1051  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1052    
1053          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
1054   }   }
1055  --- linux-2.6.21.orig/kernel/sys.c  --- linux-2.6.21.7.orig/kernel/sys.c
1056  +++ linux-2.6.21/kernel/sys.c  +++ linux-2.6.21.7/kernel/sys.c
1057  @@ -37,6 +37,9 @@  @@ -37,6 +37,9 @@
1058   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1059   #include <asm/io.h>   #include <asm/io.h>
# Line 975  Source code for this patch is http://www Line 1064  Source code for this patch is http://www
1064    
1065   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
1066   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
1067  @@ -600,6 +603,9 @@ asmlinkage long sys_setpriority(int whic  @@ -600,6 +603,12 @@ asmlinkage long sys_setpriority(int whic
1068    
1069          if (which > 2 || which < 0)          if (which > 2 || which < 0)
1070                  goto out;                  goto out;
1071  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1072  +       if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_NICE)) {
1073    +               error = -EPERM;
1074    +               goto out;
1075    +       }
1076  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1077    
1078          /* normalize: avoid signed division (rounding problems) */          /* normalize: avoid signed division (rounding problems) */
1079          error = -ESRCH;          error = -ESRCH;
1080  @@ -830,6 +836,9 @@ asmlinkage long sys_reboot(int magic1, i  @@ -830,6 +839,10 @@ asmlinkage long sys_reboot(int magic1, i
1081                          magic2 != LINUX_REBOOT_MAGIC2B &&                          magic2 != LINUX_REBOOT_MAGIC2B &&
1082                          magic2 != LINUX_REBOOT_MAGIC2C))                          magic2 != LINUX_REBOOT_MAGIC2C))
1083                  return -EINVAL;                  return -EINVAL;
1084  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1085  +       if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_REBOOT))
1086    +               return -EPERM;
1087  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1088    
1089          /* Instead of trying to make the power_off code look like          /* Instead of trying to make the power_off code look like
1090           * 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.
1091  @@ -1806,6 +1815,9 @@ asmlinkage long sys_sethostname(char __u  @@ -1806,6 +1819,10 @@ asmlinkage long sys_sethostname(char __u
1092                  return -EPERM;                  return -EPERM;
1093          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
1094                  return -EINVAL;                  return -EINVAL;
1095  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1096  +       if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1097    +               return -EPERM;
1098  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1099          down_write(&uts_sem);          down_write(&uts_sem);
1100          errno = -EFAULT;          errno = -EFAULT;
1101          if (!copy_from_user(tmp, name, len)) {          if (!copy_from_user(tmp, name, len)) {
1102  @@ -1851,6 +1863,9 @@ asmlinkage long sys_setdomainname(char _  @@ -1851,6 +1868,10 @@ asmlinkage long sys_setdomainname(char _
1103                  return -EPERM;                  return -EPERM;
1104          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
1105                  return -EINVAL;                  return -EINVAL;
1106  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1107  +       if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1108    +               return -EPERM;
1109  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1110    
1111          down_write(&uts_sem);          down_write(&uts_sem);
1112          errno = -EFAULT;          errno = -EFAULT;
1113  --- linux-2.6.21.orig/kernel/sysctl.c  --- linux-2.6.21.7.orig/kernel/sysctl.c
1114  +++ linux-2.6.21/kernel/sysctl.c  +++ linux-2.6.21.7/kernel/sysctl.c
1115  @@ -48,6 +48,9 @@  @@ -48,6 +48,9 @@
1116    
1117   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 1027  Source code for this patch is http://www Line 1122  Source code for this patch is http://www
1122    
1123   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,
1124                        void __user *buffer, size_t *lenp, loff_t *ppos);                        void __user *buffer, size_t *lenp, loff_t *ppos);
1125  @@ -1088,6 +1091,81 @@ struct ctl_table_header *sysctl_head_nex  @@ -1088,6 +1091,7 @@ struct ctl_table_header *sysctl_head_nex
1126   }   }
1127    
1128   #ifdef CONFIG_SYSCTL_SYSCALL   #ifdef CONFIG_SYSCTL_SYSCALL
1129  +  +
 +/***** 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) == NULL) goto out;  
 +                       }  
 +                       if (table->child) {  
 +                               name++;  
 +                               nlen--;  
 +                               table = table->child;  
 +                               goto repeat;  
 +                       }  
 +                       /* printk("sysctl='%s'\n", buffer); */  
 +                       error = CheckFilePerm(buffer, op, "sysctl");  
 +                       goto out;  
 +               }  
 +       }  
 +       error = -ENOTDIR;  
 + out:  
 +       kfree(buffer);  
 +       return error;  
 +}  
 +/***** TOMOYO Linux end. *****/  
 +  
1130   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,
1131                 void __user *newval, size_t newlen)                 void __user *newval, size_t newlen)
1132   {   {
1133  @@ -1104,6 +1182,9 @@ int do_sysctl(int __user *name, int nlen  @@ -1104,6 +1108,11 @@ int do_sysctl(int __user *name, int nlen
1134    
1135          for (head = sysctl_head_next(NULL); head;          for (head = sysctl_head_next(NULL); head;
1136                          head = sysctl_head_next(head)) {                          head = sysctl_head_next(head)) {
1137  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1138  +               if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0)  +               error = ccs_parse_table(name, nlen, oldval, newval,
1139    +                                       head->ctl_table);
1140    +               if (!error)
1141  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1142                  error = parse_table(name, nlen, oldval, oldlenp,                  error = parse_table(name, nlen, oldval, oldlenp,
1143                                          newval, newlen, head->ctl_table);                                          newval, newlen, head->ctl_table);
1144                  if (error != -ENOTDIR) {                  if (error != -ENOTDIR) {
1145  --- linux-2.6.21.orig/kernel/time.c  --- linux-2.6.21.7.orig/kernel/time.c
1146  +++ linux-2.6.21/kernel/time.c  +++ linux-2.6.21.7/kernel/time.c
1147  @@ -39,6 +39,9 @@  @@ -39,6 +39,9 @@
1148    
1149   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 1131  Source code for this patch is http://www Line 1154  Source code for this patch is http://www
1154    
1155   /*   /*
1156    * 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
1157  @@ -91,6 +94,9 @@ asmlinkage long sys_stime(time_t __user  @@ -91,6 +94,10 @@ asmlinkage long sys_stime(time_t __user
1158          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
1159          if (err)          if (err)
1160                  return err;                  return err;
1161  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1162  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_SETTIME))
1163    +               return -EPERM;
1164  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1165    
1166          do_settimeofday(&tv);          do_settimeofday(&tv);
1167          return 0;          return 0;
1168  @@ -161,6 +167,9 @@ int do_sys_settimeofday(struct timespec  @@ -161,6 +168,10 @@ int do_sys_settimeofday(struct timespec
1169          error = security_settime(tv, tz);          error = security_settime(tv, tz);
1170          if (error)          if (error)
1171                  return error;                  return error;
1172  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1173  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(CCS_SYS_SETTIME))
1174    +               return -EPERM;
1175  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1176    
1177          if (tz) {          if (tz) {
1178                  /* SMP safe, global irq locking makes it work. */                  /* SMP safe, global irq locking makes it work. */
1179  --- linux-2.6.21.orig/kernel/time/ntp.c  --- linux-2.6.21.7.orig/kernel/time/ntp.c
1180  +++ linux-2.6.21/kernel/time/ntp.c  +++ linux-2.6.21.7/kernel/time/ntp.c
1181  @@ -14,6 +14,9 @@  @@ -14,6 +14,9 @@
1182    
1183   #include <asm/div64.h>   #include <asm/div64.h>
# Line 1163  Source code for this patch is http://www Line 1188  Source code for this patch is http://www
1188    
1189   /*   /*
1190    * Timekeeping variables    * Timekeeping variables
1191  @@ -203,6 +206,9 @@ int do_adjtimex(struct timex *txc)  @@ -201,6 +204,10 @@ int do_adjtimex(struct timex *txc)
1192          /* In order to modify anything, you gotta be super-user! */          /* In order to modify anything, you gotta be super-user! */
1193          if (txc->modes && !capable(CAP_SYS_TIME))          if (txc->modes && !capable(CAP_SYS_TIME))
1194                  return -EPERM;                  return -EPERM;
1195  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1196  +       if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1197    +               return -EPERM;
1198  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1199    
1200          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
1201    
1202  --- linux-2.6.21.orig/net/core/datagram.c  --- linux-2.6.21.7.orig/net/core/datagram.c
1203  +++ linux-2.6.21/net/core/datagram.c  +++ linux-2.6.21.7/net/core/datagram.c
1204  @@ -56,6 +56,11 @@  @@ -56,6 +56,11 @@
1205   #include <net/sock.h>   #include <net/sock.h>
1206   #include <net/tcp_states.h>   #include <net/tcp_states.h>
# Line 1187  Source code for this patch is http://www Line 1213  Source code for this patch is http://www
1213   /*   /*
1214    *     Is a socket 'connection oriented' ?    *     Is a socket 'connection oriented' ?
1215    */    */
1216  @@ -178,6 +183,10 @@ struct sk_buff *skb_recv_datagram(struct  @@ -178,6 +183,12 @@ struct sk_buff *skb_recv_datagram(struct
1217                  } else                  } else
1218                          skb = skb_dequeue(&sk->sk_receive_queue);                          skb = skb_dequeue(&sk->sk_receive_queue);
1219    
1220  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1221  +               if ((error = CheckSocketRecvDatagramPermission(sk, skb, flags)) < 0) goto no_packet;  +               error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1222    +               if (error)
1223    +                       goto no_packet;
1224  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1225  +  +
1226                  if (skb)                  if (skb)
1227                          return skb;                          return skb;
1228    
1229  --- linux-2.6.21.orig/net/ipv4/inet_connection_sock.c  --- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c
1230  +++ linux-2.6.21/net/ipv4/inet_connection_sock.c  +++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c
1231  @@ -23,6 +23,9 @@  @@ -23,6 +23,9 @@
1232   #include <net/route.h>   #include <net/route.h>
1233   #include <net/tcp_states.h>   #include <net/tcp_states.h>
# Line 1210  Source code for this patch is http://www Line 1238  Source code for this patch is http://www
1238    
1239   #ifdef INET_CSK_DEBUG   #ifdef INET_CSK_DEBUG
1240   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";
1241  @@ -87,6 +90,9 @@ int inet_csk_get_port(struct inet_hashin  @@ -85,6 +88,10 @@ int inet_csk_get_port(struct inet_hashin
1242                  do {                  do {
1243                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1244                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1245  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1246  +                       if (SAKURA_MayAutobind(rover) < 0) goto next;  +                       if (ccs_lport_reserved(rover))
1247    +                               goto next;
1248  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1249                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
1250                                  if (tb->port == rover)                                  if (tb->port == rover)
1251                                          goto next;                                          goto next;
1252  --- linux-2.6.21.orig/net/ipv4/inet_hashtables.c  --- linux-2.6.21.7.orig/net/ipv4/inet_hashtables.c
1253  +++ linux-2.6.21/net/ipv4/inet_hashtables.c  +++ linux-2.6.21.7/net/ipv4/inet_hashtables.c
1254  @@ -22,6 +22,9 @@  @@ -22,6 +22,9 @@
1255   #include <net/inet_connection_sock.h>   #include <net/inet_connection_sock.h>
1256   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
# Line 1232  Source code for this patch is http://www Line 1261  Source code for this patch is http://www
1261    
1262   /*   /*
1263    * Allocate and initialize a new local port bind bucket.    * Allocate and initialize a new local port bind bucket.
1264  @@ -292,6 +295,9 @@ int inet_hash_connect(struct inet_timewa  @@ -292,6 +295,10 @@ int inet_hash_connect(struct inet_timewa
1265                  local_bh_disable();                  local_bh_disable();
1266                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1267                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1268  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1269  +                       if (SAKURA_MayAutobind(port) < 0) continue;  +                       if (ccs_lport_reserved(port))
1270    +                               continue;
1271  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1272                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1273                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1274    
1275  --- linux-2.6.21.orig/net/ipv4/udp.c  --- linux-2.6.21.7.orig/net/ipv4/udp.c
1276  +++ linux-2.6.21/net/ipv4/udp.c  +++ linux-2.6.21.7/net/ipv4/udp.c
1277  @@ -102,6 +102,9 @@  @@ -102,6 +102,9 @@
1278   #include <net/checksum.h>   #include <net/checksum.h>
1279   #include <net/xfrm.h>   #include <net/xfrm.h>
# Line 1254  Source code for this patch is http://www Line 1284  Source code for this patch is http://www
1284    
1285   /*   /*
1286    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
1287  @@ -162,6 +165,9 @@ int __udp_lib_get_port(struct sock *sk,  @@ -162,6 +165,10 @@ int __udp_lib_get_port(struct sock *sk,
1288                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1289                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1290                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
1291  +                               /***** SAKURA Linux start. *****/  +                               /***** SAKURA Linux start. *****/
1292  +                               if (SAKURA_MayAutobind(result) < 0) continue;  +                               if (ccs_lport_reserved(result))
1293    +                                       continue;
1294  +                               /***** SAKURA Linux end. *****/  +                               /***** SAKURA Linux end. *****/
1295                                  goto gotit;                                  goto gotit;
1296                          }                          }
1297                          size = 0;                          size = 0;
1298  @@ -180,6 +186,9 @@ int __udp_lib_get_port(struct sock *sk,  @@ -180,6 +187,10 @@ int __udp_lib_get_port(struct sock *sk,
1299                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1300                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1301                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
1302  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1303  +                       if (SAKURA_MayAutobind(result) < 0) continue;  +                       if (ccs_lport_reserved(result))
1304    +                               continue;
1305  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1306                          if (! __udp_lib_lport_inuse(result, udptable))                          if (! __udp_lib_lport_inuse(result, udptable))
1307                                  break;                                  break;
1308                  }                  }
1309  --- linux-2.6.21.orig/net/ipv6/inet6_hashtables.c  --- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c
1310  +++ linux-2.6.21/net/ipv6/inet6_hashtables.c  +++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c
1311  @@ -21,6 +21,9 @@  @@ -21,6 +21,9 @@
1312   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1313   #include <net/inet6_hashtables.h>   #include <net/inet6_hashtables.h>
# Line 1286  Source code for this patch is http://www Line 1318  Source code for this patch is http://www
1318    
1319   void __inet6_hash(struct inet_hashinfo *hashinfo,   void __inet6_hash(struct inet_hashinfo *hashinfo,
1320                                  struct sock *sk)                                  struct sock *sk)
1321  @@ -266,6 +269,9 @@ int inet6_hash_connect(struct inet_timew  @@ -266,6 +269,10 @@ int inet6_hash_connect(struct inet_timew
1322                  local_bh_disable();                  local_bh_disable();
1323                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1324                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1325  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1326  +                       if (SAKURA_MayAutobind(port) < 0) continue;  +                       if (ccs_lport_reserved(port))
1327    +                               continue;
1328  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1329                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1330                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1331    
1332  --- linux-2.6.21.orig/net/socket.c  --- linux-2.6.21.7.orig/net/socket.c
1333  +++ linux-2.6.21/net/socket.c  +++ linux-2.6.21.7/net/socket.c
1334  @@ -93,6 +93,11 @@  @@ -93,6 +93,11 @@
1335   #include <net/sock.h>   #include <net/sock.h>
1336   #include <linux/netfilter.h>   #include <linux/netfilter.h>
# Line 1310  Source code for this patch is http://www Line 1343  Source code for this patch is http://www
1343   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1344   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,
1345                           unsigned long nr_segs, loff_t pos);                           unsigned long nr_segs, loff_t pos);
1346  @@ -549,6 +554,9 @@ static inline int __sock_sendmsg(struct  @@ -549,6 +554,12 @@ static inline int __sock_sendmsg(struct
1347          err = security_socket_sendmsg(sock, msg, size);          err = security_socket_sendmsg(sock, msg, size);
1348          if (err)          if (err)
1349                  return err;                  return err;
1350  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1351  +       if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;  +       if (ccs_socket_sendmsg_permission(sock,
1352    +                                         (struct sockaddr *) msg->msg_name,
1353    +                                         msg->msg_namelen))
1354    +               return -EPERM;
1355  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1356    
1357          return sock->ops->sendmsg(iocb, sock, msg, size);          return sock->ops->sendmsg(iocb, sock, msg, size);
1358   }   }
1359  @@ -1070,6 +1078,10 @@ static int __sock_create(int family, int  @@ -1070,6 +1081,12 @@ static int __sock_create(int family, int
1360                  family = PF_PACKET;                  family = PF_PACKET;
1361          }          }
1362    
1363  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1364  +       if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err;  +       err = ccs_socket_create_permission(family, type, protocol);
1365    +       if (err)
1366    +               return err;
1367  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1368  +  +
1369          err = security_socket_create(family, type, protocol, kern);          err = security_socket_create(family, type, protocol, kern);
1370          if (err)          if (err)
1371                  return err;                  return err;
1372  @@ -1298,6 +1310,9 @@ asmlinkage long sys_bind(int fd, struct  @@ -1298,6 +1315,13 @@ asmlinkage long sys_bind(int fd, struct
1373                          err = security_socket_bind(sock,                          err = security_socket_bind(sock,
1374                                                     (struct sockaddr *)address,                                                     (struct sockaddr *)address,
1375                                                     addrlen);                                                     addrlen);
1376  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
1377  +                       if (!err) err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen);  +                       if (!err)
1378    +                               err = ccs_socket_bind_permission(sock,
1379    +                                                        (struct sockaddr *)
1380    +                                                                address,
1381    +                                                                addrlen);
1382  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
1383                          if (!err)                          if (!err)
1384                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
1385                                                        (struct sockaddr *)                                                        (struct sockaddr *)
1386  @@ -1327,6 +1342,9 @@ asmlinkage long sys_listen(int fd, int b  @@ -1327,6 +1351,10 @@ asmlinkage long sys_listen(int fd, int b
1387                          backlog = sysctl_somaxconn;                          backlog = sysctl_somaxconn;
1388    
1389                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
1390  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1391  +               if (!err) err = CheckSocketListenPermission(sock);  +               if (!err)
1392    +                       err = ccs_socket_listen_permission(sock);
1393  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1394                  if (!err)                  if (!err)
1395                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
1396    
1397  @@ -1391,6 +1409,12 @@ asmlinkage long sys_accept(int fd, struc  @@ -1391,6 +1419,13 @@ asmlinkage long sys_accept(int fd, struc
1398          if (err < 0)          if (err < 0)
1399                  goto out_fd;                  goto out_fd;
1400    
1401  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1402  +       if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) {  +       if (ccs_socket_accept_permission(newsock,
1403    +                                        (struct sockaddr *) address)) {
1404  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1405  +               goto out_fd;  +               goto out_fd;
1406  +       }  +       }
# Line 1364  Source code for this patch is http://www Line 1408  Source code for this patch is http://www
1408          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1409                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1410                                            &len, 2) < 0) {                                            &len, 2) < 0) {
1411  @@ -1455,6 +1479,10 @@ asmlinkage long sys_connect(int fd, stru  @@ -1455,6 +1490,12 @@ asmlinkage long sys_connect(int fd, stru
1412              security_socket_connect(sock, (struct sockaddr *)address, addrlen);              security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1413          if (err)          if (err)
1414                  goto out_put;                  goto out_put;
1415  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1416  +       err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen);  +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1417  +       if (err) goto out_put;  +                                           addrlen);
1418    +       if (err)
1419    +               goto out_put;
1420  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1421    
1422          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
1423                                   sock->file->f_flags);                                   sock->file->f_flags);
1424  --- linux-2.6.21.orig/net/unix/af_unix.c  --- linux-2.6.21.7.orig/net/unix/af_unix.c
1425  +++ linux-2.6.21/net/unix/af_unix.c  +++ linux-2.6.21.7/net/unix/af_unix.c
1426  @@ -116,6 +116,9 @@  @@ -116,6 +116,9 @@
1427   #include <linux/mount.h>   #include <linux/mount.h>
1428   #include <net/checksum.h>   #include <net/checksum.h>
# Line 1387  Source code for this patch is http://www Line 1433  Source code for this patch is http://www
1433    
1434   int sysctl_unix_max_dgram_qlen __read_mostly = 10;   int sysctl_unix_max_dgram_qlen __read_mostly = 10;
1435    
1436  @@ -765,6 +768,10 @@ static int unix_bind(struct socket *sock  @@ -808,6 +811,11 @@ static int unix_bind(struct socket *sock
                 err = unix_autobind(sock);  
                 goto out;  
         }  
 +       /***** TOMOYO Linux start. *****/  
 +       err = -EPERM;  
 +       if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out;  
 +       /***** TOMOYO Linux end. *****/  
   
         err = unix_mkname(sunaddr, addr_len, &hash);  
         if (err < 0)  
 @@ -808,6 +815,9 @@ static int unix_bind(struct socket *sock  
1437                   */                   */
1438                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1439                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1440  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1441  +               if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)  +               err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
1442    +                                                nd.mnt, mode, 0);
1443    +               if (!err)
1444  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1445                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1446                  if (err)                  if (err)
1447                          goto out_mknod_dput;                          goto out_mknod_dput;
 --- linux-2.6.21.orig/arch/powerpc/kernel/ptrace32.c  
 +++ linux-2.6.21/arch/powerpc/kernel/ptrace32.c  
 @@ -32,6 +32,9 @@  
  #include <asm/page.h>  
  #include <asm/pgtable.h>  
  #include <asm/system.h>  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
   
  #include "ptrace-common.h"  
   
 @@ -45,6 +48,11 @@ long compat_sys_ptrace(int request, int  
  {  
         struct task_struct *child;  
         int ret;  
 +       /***** TOMOYO Linux start. *****/  
 +#ifdef TOMOYO_SYS_PTRACE  
 +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  
 +#endif  
 +       /***** TOMOYO Linux end. *****/  
   
         lock_kernel();  
         if (request == PTRACE_TRACEME) {  
 --- linux-2.6.21.orig/arch/sh64/kernel/ptrace.c  
 +++ linux-2.6.21/arch/sh64/kernel/ptrace.c  
 @@ -35,6 +35,9 @@  
  #include <asm/system.h>  
  #include <asm/processor.h>  
  #include <asm/mmu_context.h>  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
   
  /* This mask defines the bits of the SR which the user is not allowed to  
     change, which are everything except S, Q, M, PR, SZ, FR. */  
 @@ -271,6 +274,11 @@ asmlinkage int sh64_ptrace(long request,  
         extern void poke_real_address_q(unsigned long long addr, unsigned long long data);  
  #define WPC_DBRMODE 0x0d104008  
         static int first_call = 1;  
 +       /***** TOMOYO Linux start. *****/  
 +#ifdef TOMOYO_SYS_PTRACE  
 +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  
 +#endif  
 +       /***** TOMOYO Linux end. *****/  
   
         lock_kernel();  
         if (first_call) {  
 --- linux-2.6.21.orig/arch/x86_64/ia32/ptrace32.c  
 +++ linux-2.6.21/arch/x86_64/ia32/ptrace32.c  
 @@ -26,6 +26,9 @@  
  #include <asm/i387.h>  
  #include <asm/fpu32.h>  
  #include <asm/ia32.h>  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
   
  /*  
   * Determines which flags the user has access to [1 = access, 0 = no access].  
 @@ -234,6 +237,11 @@ asmlinkage long sys32_ptrace(long reques  
         void __user *datap = compat_ptr(data);  
         int ret;  
         __u32 val;  
 +       /***** TOMOYO Linux start. *****/  
 +#ifdef TOMOYO_SYS_PTRACE  
 +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  
 +#endif  
 +       /***** TOMOYO Linux end. *****/  
   
         switch (request) {  
         case PTRACE_TRACEME:  
 --- linux-2.6.21.orig/arch/ia64/ia32/sys_ia32.c  
 +++ linux-2.6.21/arch/ia64/ia32/sys_ia32.c  
 @@ -56,6 +56,9 @@  
  #include <asm/types.h>  
  #include <asm/uaccess.h>  
  #include <asm/unistd.h>  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
   
  #include "ia32priv.h"  
   
 @@ -1758,6 +1761,11 @@ sys32_ptrace (int request, pid_t pid, un  
         struct task_struct *child;  
         unsigned int value, tmp;  
         long i, ret;  
 +       /***** TOMOYO Linux start. *****/  
 +#ifdef TOMOYO_SYS_PTRACE  
 +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  
 +#endif  
 +       /***** TOMOYO Linux end. *****/  
   
         lock_kernel();  
         if (request == PTRACE_TRACEME) {  
 --- linux-2.6.21.orig/arch/mips/kernel/ptrace32.c  
 +++ linux-2.6.21/arch/mips/kernel/ptrace32.c  
 @@ -35,6 +35,9 @@  
  #include <asm/system.h>  
  #include <asm/uaccess.h>  
  #include <asm/bootinfo.h>  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
   
  int ptrace_getregs (struct task_struct *child, __s64 __user *data);  
  int ptrace_setregs (struct task_struct *child, __s64 __user *data);  
 @@ -50,6 +53,11 @@ asmlinkage int sys32_ptrace(int request,  
  {  
         struct task_struct *child;  
         int ret;  
 +       /***** TOMOYO Linux start. *****/  
 +#ifdef TOMOYO_SYS_PTRACE  
 +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  
 +#endif  
 +       /***** TOMOYO Linux end. *****/  
   
  #if 0  
         printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",  

Legend:
Removed from v.894  
changed lines
  Added in v.2306

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