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

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 1769 by kumaneko, Thu Oct 30 08:38:46 2008 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      |    9 +++
6   arch/alpha/kernel/ptrace.c      |    8 +++   arch/ia64/ia32/sys_ia32.c       |    9 +++
7   arch/ia64/ia32/sys_ia32.c       |    8 +++   arch/ia64/kernel/ptrace.c       |    9 +++
8   arch/ia64/kernel/ptrace.c       |    8 +++   arch/m32r/kernel/ptrace.c       |    9 +++
9   arch/m32r/kernel/ptrace.c       |    8 +++   arch/mips/kernel/ptrace32.c     |    9 +++
10   arch/mips/kernel/ptrace32.c     |    8 +++   arch/powerpc/kernel/ptrace32.c  |    9 +++
11   arch/powerpc/kernel/ptrace32.c  |    8 +++   arch/s390/kernel/ptrace.c       |    9 +++
12   arch/s390/kernel/ptrace.c       |    8 +++   arch/sparc/kernel/ptrace.c      |   11 +++
13   arch/sh64/kernel/ptrace.c       |    8 +++   arch/sparc64/kernel/ptrace.c    |   11 +++
14   arch/sparc/kernel/ptrace.c      |   11 +++++   arch/x86_64/ia32/ptrace32.c     |    9 +++
  arch/sparc64/kernel/ptrace.c    |   11 +++++  
  arch/x86_64/ia32/ptrace32.c     |    8 +++  
15   fs/Kconfig                      |    2   fs/Kconfig                      |    2
16   fs/Makefile                     |    2   fs/Makefile                     |    2
17   fs/attr.c                       |   11 +++++   fs/attr.c                       |   19 ++++++
18   fs/compat.c                     |    8 +++   fs/compat.c                     |   11 +++
19   fs/exec.c                       |   14 ++++++   fs/exec.c                       |   20 ++++++-
20   fs/fcntl.c                      |    7 +++   fs/fcntl.c                      |    9 +++
21   fs/ioctl.c                      |    6 ++   fs/ioctl.c                      |    7 ++
22   fs/namei.c                      |   60 +++++++++++++++++++++++++++++   fs/namei.c                      |  112 ++++++++++++++++++++++++++++++++++++++++
23   fs/namespace.c                  |   38 ++++++++++++++++++   fs/namespace.c                  |   49 +++++++++++++++++
24   fs/open.c                       |   21 ++++++++++   fs/open.c                       |   27 +++++++++
25   fs/proc/Makefile                |    3 +   fs/proc/Makefile                |    3 +
26   fs/proc/proc_misc.c             |    9 ++++   fs/proc/proc_misc.c             |    5 +
27   include/linux/init_task.h       |    4 +   include/linux/init_task.h       |    4 +
28   include/linux/sched.h           |    9 ++++   include/linux/sched.h           |    9 +++
29   kernel/compat.c                 |    6 ++   kernel/compat.c                 |    7 ++
30   kernel/kexec.c                  |    6 ++   kernel/kexec.c                  |    7 ++
31   kernel/kmod.c                   |    5 ++   kernel/kmod.c                   |    5 +
32   kernel/module.c                 |    9 ++++   kernel/module.c                 |   11 +++
33   kernel/ptrace.c                 |    8 +++   kernel/ptrace.c                 |    9 +++
34   kernel/sched.c                  |    6 ++   kernel/sched.c                  |    7 ++
35   kernel/signal.c                 |   15 +++++++   kernel/signal.c                 |   21 +++++++
36   kernel/sys.c                    |   15 +++++++   kernel/sys.c                    |   21 +++++++
37   kernel/sysctl.c                 |   81 ++++++++++++++++++++++++++++++++++++++++   kernel/sysctl.c                 |   95 +++++++++++++++++++++++++++++++++
38   kernel/time.c                   |    9 ++++   kernel/time.c                   |   11 +++
39   kernel/time/ntp.c               |    6 ++   kernel/time/ntp.c               |    7 ++
40   net/core/datagram.c             |    9 ++++   net/core/datagram.c             |   11 +++
41   net/ipv4/inet_connection_sock.c |    6 ++   net/ipv4/inet_connection_sock.c |    7 ++
42   net/ipv4/inet_hashtables.c      |    6 ++   net/ipv4/inet_hashtables.c      |    7 ++
43   net/ipv4/udp.c                  |    9 ++++   net/ipv4/udp.c                  |   11 +++
44   net/ipv6/inet6_hashtables.c     |    6 ++   net/ipv6/inet6_hashtables.c     |    7 ++
45   net/socket.c                    |   28 +++++++++++++   net/socket.c                    |   41 ++++++++++++++
46   net/unix/af_unix.c              |   10 ++++   net/unix/af_unix.c              |   15 +++++
47   44 files changed, 527 insertions(+), 3 deletions(-)   42 files changed, 671 insertions(+), 2 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,12 @@ 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  +#ifdef TOMOYO_SYS_PTRACE
67  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
68    +               return -EPERM;
69  +#endif  +#endif
70  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
71    
72          lock_kernel();          lock_kernel();
73          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",
74  --- linux-2.6.21.orig/arch/ia64/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/ia64/ia32/sys_ia32.c
75  +++ linux-2.6.21/arch/ia64/kernel/ptrace.c  +++ linux-2.6.21.7/arch/ia64/ia32/sys_ia32.c
76    @@ -56,6 +56,9 @@
77     #include <asm/types.h>
78     #include <asm/uaccess.h>
79     #include <asm/unistd.h>
80    +/***** TOMOYO Linux start. *****/
81    +#include <linux/tomoyo.h>
82    +/***** TOMOYO Linux end. *****/
83    
84     #include "ia32priv.h"
85    
86    @@ -1758,6 +1761,12 @@ sys32_ptrace (int request, pid_t pid, un
87            struct task_struct *child;
88            unsigned int value, tmp;
89            long i, ret;
90    +       /***** TOMOYO Linux start. *****/
91    +#ifdef TOMOYO_SYS_PTRACE
92    +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
93    +               return -EPERM;
94    +#endif
95    +       /***** TOMOYO Linux end. *****/
96    
97            lock_kernel();
98            if (request == PTRACE_TRACEME) {
99    --- linux-2.6.21.7.orig/arch/ia64/kernel/ptrace.c
100    +++ linux-2.6.21.7/arch/ia64/kernel/ptrace.c
101  @@ -28,6 +28,9 @@  @@ -28,6 +28,9 @@
102   #ifdef CONFIG_PERFMON   #ifdef CONFIG_PERFMON
103   #include <asm/perfmon.h>   #include <asm/perfmon.h>
# Line 95  Source code for this patch is http://www Line 108  Source code for this patch is http://www
108    
109   #include "entry.h"   #include "entry.h"
110    
111  @@ -1418,6 +1421,11 @@ sys_ptrace (long request, pid_t pid, uns  @@ -1418,6 +1421,12 @@ sys_ptrace (long request, pid_t pid, uns
112          struct task_struct *child;          struct task_struct *child;
113          struct switch_stack *sw;          struct switch_stack *sw;
114          long ret;          long ret;
115  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
116  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
117  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
118    +               return -EPERM;
119  +#endif  +#endif
120  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
121    
122          lock_kernel();          lock_kernel();
123          ret = -EPERM;          ret = -EPERM;
124  --- linux-2.6.21.orig/arch/m32r/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/m32r/kernel/ptrace.c
125  +++ linux-2.6.21/arch/m32r/kernel/ptrace.c  +++ linux-2.6.21.7/arch/m32r/kernel/ptrace.c
126  @@ -32,6 +32,9 @@  @@ -32,6 +32,9 @@
127   #include <asm/system.h>   #include <asm/system.h>
128   #include <asm/processor.h>   #include <asm/processor.h>
# Line 119  Source code for this patch is http://www Line 133  Source code for this patch is http://www
133    
134   /*   /*
135    * This routine will get a word off of the process kernel stack.    * This routine will get a word off of the process kernel stack.
136  @@ -742,6 +745,11 @@ asmlinkage long sys_ptrace(long request,  @@ -742,6 +745,12 @@ asmlinkage long sys_ptrace(long request,
137   {   {
138          struct task_struct *child;          struct task_struct *child;
139          int ret;          int ret;
140  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
141  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
142  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
143    +               return -EPERM;
144  +#endif  +#endif
145  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
146    
147          lock_kernel();          lock_kernel();
148          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
149  --- linux-2.6.21.orig/arch/s390/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/mips/kernel/ptrace32.c
150  +++ linux-2.6.21/arch/s390/kernel/ptrace.c  +++ linux-2.6.21.7/arch/mips/kernel/ptrace32.c
151    @@ -35,6 +35,9 @@
152     #include <asm/system.h>
153     #include <asm/uaccess.h>
154     #include <asm/bootinfo.h>
155    +/***** TOMOYO Linux start. *****/
156    +#include <linux/tomoyo.h>
157    +/***** TOMOYO Linux end. *****/
158    
159     int ptrace_getregs (struct task_struct *child, __s64 __user *data);
160     int ptrace_setregs (struct task_struct *child, __s64 __user *data);
161    @@ -50,6 +53,12 @@ asmlinkage int sys32_ptrace(int request,
162     {
163            struct task_struct *child;
164            int ret;
165    +       /***** TOMOYO Linux start. *****/
166    +#ifdef TOMOYO_SYS_PTRACE
167    +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
168    +               return -EPERM;
169    +#endif
170    +       /***** TOMOYO Linux end. *****/
171    
172     #if 0
173            printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
174    --- linux-2.6.21.7.orig/arch/powerpc/kernel/ptrace32.c
175    +++ linux-2.6.21.7/arch/powerpc/kernel/ptrace32.c
176    @@ -32,6 +32,9 @@
177     #include <asm/page.h>
178     #include <asm/pgtable.h>
179     #include <asm/system.h>
180    +/***** TOMOYO Linux start. *****/
181    +#include <linux/tomoyo.h>
182    +/***** TOMOYO Linux end. *****/
183    
184     #include "ptrace-common.h"
185    
186    @@ -45,6 +48,12 @@ long compat_sys_ptrace(int request, int
187     {
188            struct task_struct *child;
189            int ret;
190    +       /***** TOMOYO Linux start. *****/
191    +#ifdef TOMOYO_SYS_PTRACE
192    +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
193    +               return -EPERM;
194    +#endif
195    +       /***** TOMOYO Linux end. *****/
196    
197            lock_kernel();
198            if (request == PTRACE_TRACEME) {
199    --- linux-2.6.21.7.orig/arch/s390/kernel/ptrace.c
200    +++ linux-2.6.21.7/arch/s390/kernel/ptrace.c
201  @@ -41,6 +41,9 @@  @@ -41,6 +41,9 @@
202   #include <asm/system.h>   #include <asm/system.h>
203   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 143  Source code for this patch is http://www Line 208  Source code for this patch is http://www
208    
209   #ifdef CONFIG_COMPAT   #ifdef CONFIG_COMPAT
210   #include "compat_ptrace.h"   #include "compat_ptrace.h"
211  @@ -713,6 +716,11 @@ sys_ptrace(long request, long pid, long  @@ -713,6 +716,12 @@ sys_ptrace(long request, long pid, long
212          struct task_struct *child;          struct task_struct *child;
213          int ret;          int ret;
214    
215  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
216  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
217  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
218    +               return -EPERM;
219  +#endif  +#endif
220  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
221          lock_kernel();          lock_kernel();
222          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
223                   ret = ptrace_traceme();                   ret = ptrace_traceme();
224  --- linux-2.6.21.orig/arch/sparc/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/sparc/kernel/ptrace.c
225  +++ linux-2.6.21/arch/sparc/kernel/ptrace.c  +++ linux-2.6.21.7/arch/sparc/kernel/ptrace.c
226  @@ -23,6 +23,9 @@  @@ -23,6 +23,9 @@
227   #include <asm/pgtable.h>   #include <asm/pgtable.h>
228   #include <asm/system.h>   #include <asm/system.h>
# Line 173  Source code for this patch is http://www Line 239  Source code for this patch is http://www
239          int ret;          int ret;
240  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
241  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
242  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) {  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) {
243  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
244  +               return;  +               return;
245  +       }  +       }
# Line 182  Source code for this patch is http://www Line 248  Source code for this patch is http://www
248    
249          lock_kernel();          lock_kernel();
250   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
251  --- linux-2.6.21.orig/arch/sparc64/kernel/ptrace.c  --- linux-2.6.21.7.orig/arch/sparc64/kernel/ptrace.c
252  +++ linux-2.6.21/arch/sparc64/kernel/ptrace.c  +++ linux-2.6.21.7/arch/sparc64/kernel/ptrace.c
253  @@ -32,6 +32,9 @@  @@ -32,6 +32,9 @@
254   #include <asm/spitfire.h>   #include <asm/spitfire.h>
255   #include <asm/page.h>   #include <asm/page.h>
# Line 200  Source code for this patch is http://www Line 266  Source code for this patch is http://www
266          int ret;          int ret;
267  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
268  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
269  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) {  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) {
270  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
271  +               return;  +               return;
272  +       }  +       }
# Line 209  Source code for this patch is http://www Line 275  Source code for this patch is http://www
275    
276          if (test_thread_flag(TIF_32BIT)) {          if (test_thread_flag(TIF_32BIT)) {
277                  addr &= 0xffffffffUL;                  addr &= 0xffffffffUL;
278  --- linux-2.6.21.orig/fs/Kconfig  --- linux-2.6.21.7.orig/arch/x86_64/ia32/ptrace32.c
279  +++ linux-2.6.21/fs/Kconfig  +++ linux-2.6.21.7/arch/x86_64/ia32/ptrace32.c
280    @@ -26,6 +26,9 @@
281     #include <asm/i387.h>
282     #include <asm/fpu32.h>
283     #include <asm/ia32.h>
284    +/***** TOMOYO Linux start. *****/
285    +#include <linux/tomoyo.h>
286    +/***** TOMOYO Linux end. *****/
287    
288     /*
289      * Determines which flags the user has access to [1 = access, 0 = no access].
290    @@ -234,6 +237,12 @@ asmlinkage long sys32_ptrace(long reques
291            void __user *datap = compat_ptr(data);
292            int ret;
293            __u32 val;
294    +       /***** TOMOYO Linux start. *****/
295    +#ifdef TOMOYO_SYS_PTRACE
296    +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
297    +               return -EPERM;
298    +#endif
299    +       /***** TOMOYO Linux end. *****/
300    
301            switch (request) {
302            case PTRACE_TRACEME:
303    --- linux-2.6.21.7.orig/fs/Kconfig
304    +++ linux-2.6.21.7/fs/Kconfig
305  @@ -2055,5 +2055,7 @@ endif  @@ -2055,5 +2055,7 @@ endif
306   source "fs/nls/Kconfig"   source "fs/nls/Kconfig"
307   source "fs/dlm/Kconfig"   source "fs/dlm/Kconfig"
# Line 219  Source code for this patch is http://www Line 310  Source code for this patch is http://www
310  +  +
311   endmenu   endmenu
312    
313  --- linux-2.6.21.orig/fs/Makefile  --- linux-2.6.21.7.orig/fs/Makefile
314  +++ linux-2.6.21/fs/Makefile  +++ linux-2.6.21.7/fs/Makefile
315  @@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS)         += hppfs/  @@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS)         += hppfs/
316   obj-$(CONFIG_DEBUG_FS)         += debugfs/   obj-$(CONFIG_DEBUG_FS)         += debugfs/
317   obj-$(CONFIG_OCFS2_FS)         += ocfs2/   obj-$(CONFIG_OCFS2_FS)         += ocfs2/
318   obj-$(CONFIG_GFS2_FS)           += gfs2/   obj-$(CONFIG_GFS2_FS)           += gfs2/
319  +  +
320  +include $(srctree)/fs/Makefile-2.6.ccs  +include $(srctree)/fs/Makefile-2.6.ccs
321  --- linux-2.6.21.orig/fs/attr.c  --- linux-2.6.21.7.orig/fs/attr.c
322  +++ linux-2.6.21/fs/attr.c  +++ linux-2.6.21.7/fs/attr.c
323  @@ -15,6 +15,9 @@  @@ -15,6 +15,9 @@
324   #include <linux/fcntl.h>   #include <linux/fcntl.h>
325   #include <linux/quotaops.h>   #include <linux/quotaops.h>
# Line 239  Source code for this patch is http://www Line 330  Source code for this patch is http://www
330    
331   /* Taken over from the old code... */   /* Taken over from the old code... */
332    
333  @@ -145,12 +148,20 @@ int notify_change(struct dentry * dentry  @@ -145,12 +148,28 @@ int notify_change(struct dentry * dentry
334    
335          if (inode->i_op && inode->i_op->setattr) {          if (inode->i_op && inode->i_op->setattr) {
336                  error = security_inode_setattr(dentry, attr);                  error = security_inode_setattr(dentry, attr);
337  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
338  +               if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);  +               if (!error && (ia_valid & ATTR_MODE) &&
339  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);  +                   !ccs_capable(TOMOYO_SYS_CHMOD))
340    +                       error = -EPERM;
341    +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
342    +                   !ccs_capable(TOMOYO_SYS_CHOWN))
343    +                       error = -EPERM;
344  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
345                  if (!error)                  if (!error)
346                          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 349  Source code for this patch is http://www
349                  if (!error)                  if (!error)
350                          error = security_inode_setattr(dentry, attr);                          error = security_inode_setattr(dentry, attr);
351  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
352  +               if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);  +               if (!error && (ia_valid & ATTR_MODE) &&
353  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);  +                   !ccs_capable(TOMOYO_SYS_CHMOD))
354    +                       error = -EPERM;
355    +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
356    +                   !ccs_capable(TOMOYO_SYS_CHOWN))
357    +                       error = -EPERM;
358  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
359                  if (!error) {                  if (!error) {
360                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
361                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
362  --- linux-2.6.21.orig/fs/compat.c  --- linux-2.6.21.7.orig/fs/compat.c
363  +++ linux-2.6.21/fs/compat.c  +++ linux-2.6.21.7/fs/compat.c
364  @@ -56,6 +56,9 @@  @@ -56,6 +56,9 @@
365   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
366   #include <asm/ioctls.h>   #include <asm/ioctls.h>
# Line 272  Source code for this patch is http://www Line 371  Source code for this patch is http://www
371    
372   int compat_log = 1;   int compat_log = 1;
373    
374  @@ -422,6 +425,9 @@ asmlinkage long compat_sys_ioctl(unsigne  @@ -422,6 +425,12 @@ asmlinkage long compat_sys_ioctl(unsigne
375                  /*FALL THROUGH*/                  /*FALL THROUGH*/
376    
377          default:          default:
378  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
379  +               if ((error = CheckCapabilityACL(TOMOYO_SYS_IOCTL)) < 0) goto out_fput;  +               if (!ccs_capable(TOMOYO_SYS_IOCTL)) {
380    +                       error = -EPERM;
381    +                       goto out_fput;
382    +               }
383  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
384                  if (filp->f_op && filp->f_op->compat_ioctl) {                  if (filp->f_op && filp->f_op->compat_ioctl) {
385                          error = filp->f_op->compat_ioctl(filp, cmd, arg);                          error = filp->f_op->compat_ioctl(filp, cmd, arg);
386                          if (error != -ENOIOCTLCMD)                          if (error != -ENOIOCTLCMD)
387  @@ -1552,7 +1558,7 @@ int compat_do_execve(char * filename,  @@ -1552,7 +1561,7 @@ int compat_do_execve(char * filename,
388          if (retval < 0)          if (retval < 0)
389                  goto out;                  goto out;
390    
# Line 291  Source code for this patch is http://www Line 393  Source code for this patch is http://www
393          if (retval >= 0) {          if (retval >= 0) {
394                  free_arg_pages(bprm);                  free_arg_pages(bprm);
395    
396  --- linux-2.6.21.orig/fs/exec.c  --- linux-2.6.21.7.orig/fs/exec.c
397  +++ linux-2.6.21/fs/exec.c  +++ linux-2.6.21.7/fs/exec.c
398  @@ -58,6 +58,10 @@  @@ -58,6 +58,10 @@
399   #include <linux/kmod.h>   #include <linux/kmod.h>
400   #endif   #endif
# Line 304  Source code for this patch is http://www Line 406  Source code for this patch is http://www
406   int core_uses_pid;   int core_uses_pid;
407   char core_pattern[128] = "core";   char core_pattern[128] = "core";
408   int suid_dumpable = 0;   int suid_dumpable = 0;
409  @@ -140,6 +144,11 @@ asmlinkage long sys_uselib(const char __  @@ -140,6 +144,13 @@ asmlinkage long sys_uselib(const char __
410          if (error)          if (error)
411                  goto exit;                  goto exit;
412    
413  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
414  +       error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */  +       /* 01 means "read". */
415  +       if (error) goto exit;  +       error = ccs_check_open_permission(nd.dentry, nd.mnt, 01);
416    +       if (error)
417    +               goto exit;
418  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
419  +  +
420          file = nameidata_to_filp(&nd, O_RDONLY);          file = nameidata_to_filp(&nd, O_RDONLY);
421          error = PTR_ERR(file);          error = PTR_ERR(file);
422          if (IS_ERR(file))          if (IS_ERR(file))
423  @@ -485,6 +494,9 @@ struct file *open_exec(const char *name)  @@ -485,6 +496,13 @@ struct file *open_exec(const char *name)
424                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
425                      S_ISREG(inode->i_mode)) {                      S_ISREG(inode->i_mode)) {
426                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
427  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
428  +                       if (!err && (current->tomoyo_flags & TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) err = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */  +                       if (!err && (current->tomoyo_flags &
429    +                                    TOMOYO_CHECK_READ_FOR_OPEN_EXEC))
430    +                               /* 01 means "read". */
431    +                               err = ccs_check_open_permission(nd.dentry,
432    +                                                               nd.mnt, 01);
433  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
434                          file = ERR_PTR(err);                          file = ERR_PTR(err);
435                          if (!err) {                          if (!err) {
436                                  file = nameidata_to_filp(&nd, O_RDONLY);                                  file = nameidata_to_filp(&nd, O_RDONLY);
437  @@ -1183,7 +1195,7 @@ int do_execve(char * filename,  @@ -1183,7 +1201,7 @@ int do_execve(char * filename,
438          if (retval < 0)          if (retval < 0)
439                  goto out;                  goto out;
440    
441  -       retval = search_binary_handler(bprm,regs);  -       retval = search_binary_handler(bprm,regs);
442  +       retval = search_binary_handler_with_transition(bprm,regs);  +       retval = search_binary_handler_with_transition(bprm, regs);
443          if (retval >= 0) {          if (retval >= 0) {
444                  free_arg_pages(bprm);                  free_arg_pages(bprm);
445    
446  --- linux-2.6.21.orig/fs/fcntl.c  --- linux-2.6.21.7.orig/fs/fcntl.c
447  +++ linux-2.6.21/fs/fcntl.c  +++ linux-2.6.21.7/fs/fcntl.c
448  @@ -22,6 +22,9 @@  @@ -22,6 +22,9 @@
449   #include <asm/poll.h>   #include <asm/poll.h>
450   #include <asm/siginfo.h>   #include <asm/siginfo.h>
# Line 347  Source code for this patch is http://www Line 455  Source code for this patch is http://www
455    
456   void fastcall set_close_on_exec(unsigned int fd, int flag)   void fastcall set_close_on_exec(unsigned int fd, int flag)
457   {   {
458  @@ -213,6 +216,10 @@ static int setfl(int fd, struct file * f  @@ -213,6 +216,12 @@ static int setfl(int fd, struct file * f
459          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
460                  return -EPERM;                  return -EPERM;
461    
462  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
463  +       if (((arg ^ filp->f_flags) & O_APPEND) && CheckReWritePermission(filp)) return -EPERM;  +       if (((arg ^ filp->f_flags) & O_APPEND) &&
464    +           ccs_check_rewrite_permission(filp))
465    +               return -EPERM;
466  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
467  +  +
468          /* O_NOATIME can only be set by the owner or superuser */          /* O_NOATIME can only be set by the owner or superuser */
469          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
470                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
471  --- linux-2.6.21.orig/fs/ioctl.c  --- linux-2.6.21.7.orig/fs/ioctl.c
472  +++ linux-2.6.21/fs/ioctl.c  +++ linux-2.6.21.7/fs/ioctl.c
473  @@ -15,6 +15,9 @@  @@ -15,6 +15,9 @@
474    
475   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 370  Source code for this patch is http://www Line 480  Source code for this patch is http://www
480    
481   static long do_ioctl(struct file *filp, unsigned int cmd,   static long do_ioctl(struct file *filp, unsigned int cmd,
482                  unsigned long arg)                  unsigned long arg)
483  @@ -23,6 +26,9 @@ static long do_ioctl(struct file *filp,  @@ -23,6 +26,10 @@ static long do_ioctl(struct file *filp,
484    
485          if (!filp->f_op)          if (!filp->f_op)
486                  goto out;                  goto out;
487  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
488  +       if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_IOCTL))
489    +               return -EPERM;
490  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
491    
492          if (filp->f_op->unlocked_ioctl) {          if (filp->f_op->unlocked_ioctl) {
493                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
494  --- linux-2.6.21.orig/fs/namei.c  --- linux-2.6.21.7.orig/fs/namei.c
495  +++ linux-2.6.21/fs/namei.c  +++ linux-2.6.21.7/fs/namei.c
496  @@ -37,6 +37,10 @@  @@ -37,6 +37,10 @@
497    
498   #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 504  Source code for this patch is http://www
504   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
505    * Fundamental changes in the pathname lookup mechanisms (namei)    * Fundamental changes in the pathname lookup mechanisms (namei)
506    * were necessary because of omirr.  The reason is that omirr needs    * were necessary because of omirr.  The reason is that omirr needs
507  @@ -1506,6 +1510,9 @@ int vfs_create(struct inode *dir, struct  @@ -1506,6 +1510,13 @@ int vfs_create(struct inode *dir, struct
508          error = security_inode_create(dir, dentry, mode);          error = security_inode_create(dir, dentry, mode);
509          if (error)          if (error)
510                  return error;                  return error;
511  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
512  +       if (nd && (error = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;  +       if (nd) {
513    +               error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt);
514    +               if (error)
515    +                       return error;
516    +       }
517  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
518          DQUOT_INIT(dir);          DQUOT_INIT(dir);
519          error = dir->i_op->create(dir, dentry, mode, nd);          error = dir->i_op->create(dir, dentry, mode, nd);
520          if (!error)          if (!error)
521  @@ -1561,6 +1568,11 @@ int may_open(struct nameidata *nd, int a  @@ -1561,6 +1572,13 @@ int may_open(struct nameidata *nd, int a
522                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
523                          return -EPERM;                          return -EPERM;
524    
525  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
526  +       error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
527  +       if (error) return error;  +       error = ccs_check_open_permission(dentry, nd->mnt, flag);
528    +       if (error)
529    +               return error;
530  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
531  +  +
532          /*          /*
533           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
534           */           */
535  @@ -1610,6 +1622,9 @@ static int open_namei_create(struct name  @@ -1610,6 +1628,9 @@ static int open_namei_create(struct name
536          return may_open(nd, 0, flag & ~O_TRUNC);          return may_open(nd, 0, flag & ~O_TRUNC);
537   }   }
538    
# Line 425  Source code for this patch is http://www Line 542  Source code for this patch is http://www
542   /*   /*
543    *     open_namei()    *     open_namei()
544    *    *
545  @@ -1870,6 +1885,12 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1870,6 +1891,16 @@ asmlinkage long sys_mknodat(int dfd, con
546    
547          if (S_ISDIR(mode))          if (S_ISDIR(mode))
548                  return -EPERM;                  return -EPERM;
549  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
550  +       if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;  +       if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV))
551  +       if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;  +               return -EPERM;
552  +       if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM;  +       if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV))
553  +       if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;  +               return -EPERM;
554    +       if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO))
555    +               return -EPERM;
556    +       if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
557    +               return -EPERM;
558  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
559          tmp = getname(filename);          tmp = getname(filename);
560          if (IS_ERR(tmp))          if (IS_ERR(tmp))
561                  return PTR_ERR(tmp);                  return PTR_ERR(tmp);
562  @@ -1888,10 +1909,16 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1888,10 +1919,32 @@ asmlinkage long sys_mknodat(int dfd, con
563                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
564                          break;                          break;
565                  case S_IFCHR: case S_IFBLK:                  case S_IFCHR: case S_IFBLK:
566  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
567  +                       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)  +                       error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
568  +                       /***** TOMOYO Linux end. *****/  +                       if (error)
569    +                               break;
570    +                       error = ccs_check_1path_perm(S_ISCHR(mode) ?
571    +                                                    TYPE_MKCHAR_ACL :
572    +                                                    TYPE_MKBLOCK_ACL,
573    +                                                    dentry, nd.mnt);
574    +                       if (error)
575    +                               break;
576    +                       /***** TOMOYO Linux end. *****/
577                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
578                                          new_decode_dev(dev));                                          new_decode_dev(dev));
579                          break;                          break;
580                  case S_IFIFO: case S_IFSOCK:                  case S_IFIFO: case S_IFSOCK:
581  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
582  +                       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)  +                       error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
583  +                       /***** TOMOYO Linux end. *****/  +                       if (error)
584    +                               break;
585    +                       error = ccs_check_1path_perm(S_ISFIFO(mode) ?
586    +                                                    TYPE_MKFIFO_ACL :
587    +                                                    TYPE_MKSOCK_ACL,
588    +                                                    dentry, nd.mnt);
589    +                       if (error)
590    +                               break;
591    +                       /***** TOMOYO Linux end. *****/
592                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
593                          break;                          break;
594                  case S_IFDIR:                  case S_IFDIR:
595  @@ -1959,6 +1986,9 @@ asmlinkage long sys_mkdirat(int dfd, con  @@ -1959,6 +2012,12 @@ asmlinkage long sys_mkdirat(int dfd, con
596    
597          if (!IS_POSIXACL(nd.dentry->d_inode))          if (!IS_POSIXACL(nd.dentry->d_inode))
598                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
599  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
600  +       if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)  +       error = pre_vfs_mkdir(nd.dentry->d_inode, dentry);
601    +       if (!error)
602    +               error = ccs_check_1path_perm(TYPE_MKDIR_ACL, dentry, nd.mnt);
603    +       if (!error)
604  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
605          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
606          dput(dentry);          dput(dentry);
607   out_unlock:   out_unlock:
608  @@ -2066,6 +2096,9 @@ static long do_rmdir(int dfd, const char  @@ -2066,6 +2125,12 @@ static long do_rmdir(int dfd, const char
609          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
610          if (IS_ERR(dentry))          if (IS_ERR(dentry))
611                  goto exit2;                  goto exit2;
612  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
613  +       if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)  +       error = pre_vfs_rmdir(nd.dentry->d_inode, dentry);
614    +       if (!error)
615    +               error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, nd.mnt);
616    +       if (!error)
617  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
618          error = vfs_rmdir(nd.dentry->d_inode, dentry);          error = vfs_rmdir(nd.dentry->d_inode, dentry);
619          dput(dentry);          dput(dentry);
620   exit2:   exit2:
621  @@ -2125,6 +2158,9 @@ static long do_unlinkat(int dfd, const c  @@ -2125,6 +2190,10 @@ static long do_unlinkat(int dfd, const c
622          struct dentry *dentry;          struct dentry *dentry;
623          struct nameidata nd;          struct nameidata nd;
624          struct inode *inode = NULL;          struct inode *inode = NULL;
625  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
626  +       if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_UNLINK))
627    +               return -EPERM;
628  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
629    
630          name = getname(pathname);          name = getname(pathname);
631          if(IS_ERR(name))          if(IS_ERR(name))
632  @@ -2146,6 +2182,9 @@ static long do_unlinkat(int dfd, const c  @@ -2146,6 +2215,14 @@ static long do_unlinkat(int dfd, const c
633                  inode = dentry->d_inode;                  inode = dentry->d_inode;
634                  if (inode)                  if (inode)
635                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
636  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
637  +               if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)  +               error = pre_vfs_unlink(nd.dentry->d_inode, dentry);
638  +               /***** TOMOYO Linux end. *****/  +               if (error)
639    +                       goto exit2;
640    +               error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt);
641    +               if (error)
642    +                       goto exit2;
643    +               /***** TOMOYO Linux end. *****/
644                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
645          exit2:          exit2:
646                  dput(dentry);                  dput(dentry);
647  @@ -2210,6 +2249,9 @@ asmlinkage long sys_symlinkat(const char  @@ -2210,6 +2287,10 @@ asmlinkage long sys_symlinkat(const char
648          char * to;          char * to;
649          struct dentry *dentry;          struct dentry *dentry;
650          struct nameidata nd;          struct nameidata nd;
651  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
652  +       if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SYMLINK))
653    +               return -EPERM;
654  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
655    
656          from = getname(oldname);          from = getname(oldname);
657          if(IS_ERR(from))          if(IS_ERR(from))
658  @@ -2227,6 +2269,9 @@ asmlinkage long sys_symlinkat(const char  @@ -2227,6 +2308,12 @@ asmlinkage long sys_symlinkat(const char
659          if (IS_ERR(dentry))          if (IS_ERR(dentry))
660                  goto out_unlock;                  goto out_unlock;
661    
662  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
663  +       if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)  +       error = pre_vfs_symlink(nd.dentry->d_inode, dentry);
664    +       if (!error)
665    +               error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, dentry, nd.mnt);
666    +       if (!error)
667  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
668          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
669          dput(dentry);          dput(dentry);
670   out_unlock:   out_unlock:
671  @@ -2299,6 +2344,9 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2299,6 +2386,10 @@ asmlinkage long sys_linkat(int olddfd, c
672          struct nameidata nd, old_nd;          struct nameidata nd, old_nd;
673          int error;          int error;
674          char * to;          char * to;
675  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
676  +       if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_LINK))
677    +               return -EPERM;
678  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
679    
680          if ((flags & ~AT_SYMLINK_FOLLOW) != 0)          if ((flags & ~AT_SYMLINK_FOLLOW) != 0)
681                  return -EINVAL;                  return -EINVAL;
682  @@ -2322,6 +2370,9 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2322,6 +2413,13 @@ asmlinkage long sys_linkat(int olddfd, c
683          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
684          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
685                  goto out_unlock;                  goto out_unlock;
686  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
687  +       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 = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
688    +       if (!error)
689    +               error = ccs_check_2path_perm(TYPE_LINK_ACL, old_nd.dentry,
690    +                                            old_nd.mnt, new_dentry, nd.mnt);
691    +       if (!error)
692  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
693          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
694          dput(new_dentry);          dput(new_dentry);
695   out_unlock:   out_unlock:
696  @@ -2547,6 +2598,12 @@ static int do_rename(int olddfd, const c  @@ -2547,6 +2645,16 @@ static int do_rename(int olddfd, const c
697          error = -ENOTEMPTY;          error = -ENOTEMPTY;
698          if (new_dentry == trap)          if (new_dentry == trap)
699                  goto exit5;                  goto exit5;
700  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
701  +       if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||  +       error = pre_vfs_rename(old_dir->d_inode, old_dentry,
702  +               (error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {  +                              new_dir->d_inode, new_dentry);
703    +       if (error)
704    +               goto exit5;
705    +       error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt,
706    +                                    new_dentry, newnd.mnt);
707    +       if (error)
708  +               goto exit5;  +               goto exit5;
 +       }  
709  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
710    
711          error = vfs_rename(old_dir->d_inode, old_dentry,          error = vfs_rename(old_dir->d_inode, old_dentry,
712                                     new_dir->d_inode, new_dentry);                                     new_dir->d_inode, new_dentry);
713  @@ -2570,6 +2627,9 @@ asmlinkage long sys_renameat(int olddfd,  @@ -2570,6 +2678,10 @@ asmlinkage long sys_renameat(int olddfd,
714          int error;          int error;
715          char * from;          char * from;
716          char * to;          char * to;
717  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
718  +       if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_RENAME))
719    +               return -EPERM;
720  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
721    
722          from = getname(oldname);          from = getname(oldname);
723          if(IS_ERR(from))          if(IS_ERR(from))
724  --- linux-2.6.21.orig/fs/namespace.c  --- linux-2.6.21.7.orig/fs/namespace.c
725  +++ linux-2.6.21/fs/namespace.c  +++ linux-2.6.21.7/fs/namespace.c
726  @@ -28,6 +28,12 @@  @@ -28,6 +28,12 @@
727   #include <asm/uaccess.h>   #include <asm/uaccess.h>
728   #include <asm/unistd.h>   #include <asm/unistd.h>
# Line 573  Source code for this patch is http://www Line 736  Source code for this patch is http://www
736    
737   /* spinlock for vfsmount related operations, inplace of dcache_lock */   /* spinlock for vfsmount related operations, inplace of dcache_lock */
738   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
739  @@ -545,6 +551,10 @@ static int do_umount(struct vfsmount *mn  @@ -545,6 +551,11 @@ static int do_umount(struct vfsmount *mn
740          if (retval)          if (retval)
741                  return retval;                  return retval;
742    
743  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
744  +       if (SAKURA_MayUmount(mnt) < 0) return -EPERM;  +       if (ccs_may_umount(mnt))
745    +               return -EPERM;
746  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
747  +  +
748          /*          /*
749           * Allow userspace to request a mountpoint be expired rather than           * Allow userspace to request a mountpoint be expired rather than
750           * unmounting unconditionally. Unmount only happens if:           * unmounting unconditionally. Unmount only happens if:
751  @@ -633,6 +643,9 @@ asmlinkage long sys_umount(char __user *  @@ -633,6 +644,10 @@ asmlinkage long sys_umount(char __user *
752   {   {
753          struct nameidata nd;          struct nameidata nd;
754          int retval;          int retval;
755  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
756  +       if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_UMOUNT))
757    +               return -EPERM;
758  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
759    
760          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
761          if (retval)          if (retval)
762  @@ -917,6 +930,10 @@ static int do_loopback(struct nameidata  @@ -917,6 +932,11 @@ static int do_loopback(struct nameidata
763    
764          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
765                  goto out;                  goto out;
766  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
767  +       err = -EPERM;  +       err = -EPERM;
768  +       if (SAKURA_MayMount(nd) < 0) goto out;  +       if (ccs_may_mount(nd))
769    +               goto out;
770  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
771    
772          err = -ENOMEM;          err = -ENOMEM;
773          if (recurse)          if (recurse)
774  @@ -1002,6 +1019,10 @@ static int do_move_mount(struct nameidat  @@ -1002,6 +1022,11 @@ static int do_move_mount(struct nameidat
775          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
776                  goto out;                  goto out;
777    
778  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
779  +       err = -EPERM;  +       err = -EPERM;
780  +       if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0) goto out;  +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
781    +               goto out;
782  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
783          err = -ENOENT;          err = -ENOENT;
784          mutex_lock(&nd->dentry->d_inode->i_mutex);          mutex_lock(&nd->dentry->d_inode->i_mutex);
785          if (IS_DEADDIR(nd->dentry->d_inode))          if (IS_DEADDIR(nd->dentry->d_inode))
786  @@ -1103,6 +1124,10 @@ int do_add_mount(struct vfsmount *newmnt  @@ -1103,6 +1128,11 @@ int do_add_mount(struct vfsmount *newmnt
787          err = -EINVAL;          err = -EINVAL;
788          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
789                  goto unlock;                  goto unlock;
790  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
791  +       err = -EPERM;  +       err = -EPERM;
792  +       if (SAKURA_MayMount(nd) < 0) goto unlock;  +       if (ccs_may_mount(nd))
793    +               goto unlock;
794  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
795    
796          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
797          if ((err = graft_tree(newmnt, nd)))          if ((err = graft_tree(newmnt, nd)))
798  @@ -1394,6 +1419,13 @@ long do_mount(char *dev_name, char *dir_  @@ -1394,6 +1424,17 @@ long do_mount(char *dev_name, char *dir_
799          if (data_page)          if (data_page)
800                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                  ((char *)data_page)[PAGE_SIZE - 1] = 0;
801    
802  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
803  +       if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_MOUNT))
804    +               return -EPERM;
805  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
806  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
807  +       if ((retval = CheckMountPermission(dev_name, dir_name, type_page, &flags)) < 0) return retval;  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
808    +                                           &flags);
809    +       if (retval)
810    +               return retval;
811  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
812  +  +
813          /* Separate the per-mountpoint flags */          /* Separate the per-mountpoint flags */
814          if (flags & MS_NOSUID)          if (flags & MS_NOSUID)
815                  mnt_flags |= MNT_NOSUID;                  mnt_flags |= MNT_NOSUID;
816  @@ -1686,6 +1718,9 @@ asmlinkage long sys_pivot_root(const cha  @@ -1686,6 +1727,10 @@ asmlinkage long sys_pivot_root(const cha
817    
818          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
819                  return -EPERM;                  return -EPERM;
820  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
821  +       if (CheckCapabilityACL(TOMOYO_SYS_PIVOT_ROOT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT))
822    +               return -EPERM;
823  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
824    
825          lock_kernel();          lock_kernel();
826    
827  @@ -1702,6 +1737,9 @@ asmlinkage long sys_pivot_root(const cha  @@ -1702,6 +1747,10 @@ asmlinkage long sys_pivot_root(const cha
828                  goto out1;                  goto out1;
829    
830          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
831  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
832  +       if (!error) error = CheckPivotRootPermission(&old_nd, &new_nd);  +       if (!error)
833    +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
834  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
835          if (error) {          if (error) {
836                  path_release(&old_nd);                  path_release(&old_nd);
837                  goto out1;                  goto out1;
838  --- linux-2.6.21.orig/fs/open.c  --- linux-2.6.21.7.orig/fs/open.c
839  +++ linux-2.6.21/fs/open.c  +++ linux-2.6.21.7/fs/open.c
840  @@ -27,6 +27,12 @@  @@ -27,6 +27,12 @@
841   #include <linux/syscalls.h>   #include <linux/syscalls.h>
842   #include <linux/rcupdate.h>   #include <linux/rcupdate.h>
# Line 676  Source code for this patch is http://www Line 850  Source code for this patch is http://www
850    
851   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
852   {   {
853  @@ -264,6 +270,9 @@ static long do_sys_truncate(const char _  @@ -264,6 +270,10 @@ static long do_sys_truncate(const char _
854          if (error)          if (error)
855                  goto dput_and_out;                  goto dput_and_out;
856    
857  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
858  +       if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)  +       error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt);
859    +       if (!error)
860  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
861          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
862          if (!error) {          if (!error) {
863                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
864  @@ -317,6 +326,9 @@ static long do_sys_ftruncate(unsigned in  @@ -317,6 +327,11 @@ static long do_sys_ftruncate(unsigned in
865          if (IS_APPEND(inode))          if (IS_APPEND(inode))
866                  goto out_putf;                  goto out_putf;
867    
868  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
869  +       if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)  +       error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt);
870    +       if (error)
871    +               goto out_putf;
872  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
873          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
874          if (!error)          if (!error)
875                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
876  @@ -481,6 +493,12 @@ asmlinkage long sys_chroot(const char __  @@ -481,6 +496,14 @@ asmlinkage long sys_chroot(const char __
877          error = -EPERM;          error = -EPERM;
878          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
879                  goto dput_and_out;                  goto dput_and_out;
880  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
881  +       if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) goto dput_and_out;  +       if (!ccs_capable(TOMOYO_SYS_CHROOT))
882    +               goto dput_and_out;
883  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
884  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
885  +       if (CheckChRootPermission(&nd)) goto dput_and_out;  +       if (ccs_check_chroot_permission(&nd))
886    +               goto dput_and_out;
887  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
888    
889          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
890          set_fs_altroot();          set_fs_altroot();
891  @@ -1085,6 +1103,9 @@ EXPORT_SYMBOL(sys_close);  @@ -1085,6 +1108,10 @@ EXPORT_SYMBOL(sys_close);
892    */    */
893   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
894   {   {
895  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
896  +       if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0)  +       if (!ccs_capable(TOMOYO_SYS_VHANGUP))
897    +               return -EPERM;
898  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
899          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
900                  /* XXX: this needs locking */                  /* XXX: this needs locking */
901                  tty_vhangup(current->signal->tty);                  tty_vhangup(current->signal->tty);
902  --- linux-2.6.21.orig/fs/proc/Makefile  --- linux-2.6.21.7.orig/fs/proc/Makefile
903  +++ linux-2.6.21/fs/proc/Makefile  +++ linux-2.6.21.7/fs/proc/Makefile
904  @@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE)     += kcore.o  @@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE)     += kcore.o
905   proc-$(CONFIG_PROC_VMCORE)     += vmcore.o   proc-$(CONFIG_PROC_VMCORE)     += vmcore.o
906   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 908  Source code for this patch is http://www
908  +  +
909  +proc-$(CONFIG_SAKURA) += ccs_proc.o  +proc-$(CONFIG_SAKURA) += ccs_proc.o
910  +proc-$(CONFIG_TOMOYO) += ccs_proc.o  +proc-$(CONFIG_TOMOYO) += ccs_proc.o
911  --- linux-2.6.21.orig/fs/proc/proc_misc.c  --- linux-2.6.21.7.orig/fs/proc/proc_misc.c
912  +++ linux-2.6.21/fs/proc/proc_misc.c  +++ linux-2.6.21.7/fs/proc/proc_misc.c
913  @@ -747,4 +747,13 @@ void __init proc_misc_init(void)  @@ -747,4 +747,9 @@ void __init proc_misc_init(void)
914                          entry->proc_fops = &proc_sysrq_trigger_operations;                          entry->proc_fops = &proc_sysrq_trigger_operations;
915          }          }
916   #endif   #endif
917  +       /***** CCS start. *****/  +       /***** CCS start. *****/
918  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
919  +       {  +       printk(KERN_INFO "Hook version: 2.6.21.7 2008/10/30\n");
 +               extern void __init CCSProc_Init(void);  
 +               CCSProc_Init();  
 +               printk("Hook version: 2.6.21 2008/01/05\n");  
 +       }  
920  +#endif  +#endif
921  +       /***** CCS end. *****/  +       /***** CCS end. *****/
922   }   }
923  --- linux-2.6.21.orig/include/linux/init_task.h  --- linux-2.6.21.7.orig/include/linux/init_task.h
924  +++ linux-2.6.21/include/linux/init_task.h  +++ linux-2.6.21.7/include/linux/init_task.h
925  @@ -141,6 +141,10 @@ extern struct group_info init_groups;  @@ -141,6 +141,10 @@ extern struct group_info init_groups;
926          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \
927          INIT_TRACE_IRQFLAGS                                             \          INIT_TRACE_IRQFLAGS                                             \
# Line 757  Source code for this patch is http://www Line 933  Source code for this patch is http://www
933   }   }
934    
935    
936  --- linux-2.6.21.orig/include/linux/sched.h  --- linux-2.6.21.7.orig/include/linux/sched.h
937  +++ linux-2.6.21/include/linux/sched.h  +++ linux-2.6.21.7/include/linux/sched.h
938  @@ -27,6 +27,11 @@  @@ -27,6 +27,11 @@
939   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */
940   #define CLONE_NEWIPC           0x08000000      /* New ipcs */   #define CLONE_NEWIPC           0x08000000      /* New ipcs */
# Line 782  Source code for this patch is http://www Line 958  Source code for this patch is http://www
958   };   };
959    
960   static inline pid_t process_group(struct task_struct *tsk)   static inline pid_t process_group(struct task_struct *tsk)
961  --- linux-2.6.21.orig/kernel/compat.c  --- linux-2.6.21.7.orig/kernel/compat.c
962  +++ linux-2.6.21/kernel/compat.c  +++ linux-2.6.21.7/kernel/compat.c
963  @@ -25,6 +25,9 @@  @@ -25,6 +25,9 @@
964   #include <linux/posix-timers.h>   #include <linux/posix-timers.h>
965    
# Line 794  Source code for this patch is http://www Line 970  Source code for this patch is http://www
970    
971   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)
972   {   {
973  @@ -869,6 +872,9 @@ asmlinkage long compat_sys_stime(compat_  @@ -869,6 +872,10 @@ asmlinkage long compat_sys_stime(compat_
974          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
975          if (err)          if (err)
976                  return err;                  return err;
977  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
978  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME))
979    +               return -EPERM;
980  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
981    
982          do_settimeofday(&tv);          do_settimeofday(&tv);
983          return 0;          return 0;
984  --- linux-2.6.21.orig/kernel/kexec.c  --- linux-2.6.21.7.orig/kernel/kexec.c
985  +++ linux-2.6.21/kernel/kexec.c  +++ linux-2.6.21.7/kernel/kexec.c
986  @@ -28,6 +28,9 @@  @@ -28,6 +28,9 @@
987   #include <asm/io.h>   #include <asm/io.h>
988   #include <asm/system.h>   #include <asm/system.h>
# Line 816  Source code for this patch is http://www Line 993  Source code for this patch is http://www
993    
994   /* Per cpu memory for storing cpu states in case of system crash. */   /* Per cpu memory for storing cpu states in case of system crash. */
995   note_buf_t* crash_notes;   note_buf_t* crash_notes;
996  @@ -924,6 +927,9 @@ asmlinkage long sys_kexec_load(unsigned  @@ -924,6 +927,10 @@ asmlinkage long sys_kexec_load(unsigned
997          /* We only trust the superuser with rebooting the system. */          /* We only trust the superuser with rebooting the system. */
998          if (!capable(CAP_SYS_BOOT))          if (!capable(CAP_SYS_BOOT))
999                  return -EPERM;                  return -EPERM;
1000  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1001  +       if (CheckCapabilityACL(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD))
1002    +               return -EPERM;
1003  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1004    
1005          /*          /*
1006           * Verify we have a legal set of flags           * Verify we have a legal set of flags
1007  --- linux-2.6.21.orig/kernel/kmod.c  --- linux-2.6.21.7.orig/kernel/kmod.c
1008  +++ linux-2.6.21/kernel/kmod.c  +++ linux-2.6.21.7/kernel/kmod.c
1009  @@ -166,6 +166,11 @@ static int ____call_usermodehelper(void  @@ -166,6 +166,11 @@ static int ____call_usermodehelper(void
1010          /* We can run anywhere, unlike our parent keventd(). */          /* We can run anywhere, unlike our parent keventd(). */
1011          set_cpus_allowed(current, CPU_MASK_ALL);          set_cpus_allowed(current, CPU_MASK_ALL);
# Line 840  Source code for this patch is http://www Line 1018  Source code for this patch is http://www
1018          retval = -EPERM;          retval = -EPERM;
1019          if (current->fs->root)          if (current->fs->root)
1020                  retval = kernel_execve(sub_info->path,                  retval = kernel_execve(sub_info->path,
1021  --- linux-2.6.21.orig/kernel/module.c  --- linux-2.6.21.7.orig/kernel/module.c
1022  +++ linux-2.6.21/kernel/module.c  +++ linux-2.6.21.7/kernel/module.c
1023  @@ -44,6 +44,9 @@  @@ -44,6 +44,9 @@
1024   #include <asm/semaphore.h>   #include <asm/semaphore.h>
1025   #include <asm/cacheflush.h>   #include <asm/cacheflush.h>
# Line 852  Source code for this patch is http://www Line 1030  Source code for this patch is http://www
1030    
1031   #if 0   #if 0
1032   #define DEBUGP printk   #define DEBUGP printk
1033  @@ -662,6 +665,9 @@ sys_delete_module(const char __user *nam  @@ -662,6 +665,10 @@ sys_delete_module(const char __user *nam
1034    
1035          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
1036                  return -EPERM;                  return -EPERM;
1037  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1038  +       if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1039    +               return -EPERM;
1040  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1041    
1042          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
1043                  return -EFAULT;                  return -EFAULT;
1044  @@ -1983,6 +1989,9 @@ sys_init_module(void __user *umod,  @@ -1983,6 +1990,10 @@ sys_init_module(void __user *umod,
1045          /* Must have permission */          /* Must have permission */
1046          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
1047                  return -EPERM;                  return -EPERM;
1048  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1049  +       if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1050    +               return -EPERM;
1051  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1052    
1053          /* Only one module load at a time, please */          /* Only one module load at a time, please */
1054          if (mutex_lock_interruptible(&module_mutex) != 0)          if (mutex_lock_interruptible(&module_mutex) != 0)
1055  --- linux-2.6.21.orig/kernel/ptrace.c  --- linux-2.6.21.7.orig/kernel/ptrace.c
1056  +++ linux-2.6.21/kernel/ptrace.c  +++ linux-2.6.21.7/kernel/ptrace.c
1057  @@ -21,6 +21,9 @@  @@ -21,6 +21,9 @@
1058    
1059   #include <asm/pgtable.h>   #include <asm/pgtable.h>
# Line 884  Source code for this patch is http://www Line 1064  Source code for this patch is http://www
1064    
1065   /*   /*
1066    * ptrace a task: make the debugger its new parent and    * ptrace a task: make the debugger its new parent and
1067  @@ -456,6 +459,11 @@ asmlinkage long sys_ptrace(long request,  @@ -456,6 +459,12 @@ asmlinkage long sys_ptrace(long request,
1068          /*          /*
1069           * This lock_kernel fixes a subtle race with suid exec           * This lock_kernel fixes a subtle race with suid exec
1070           */           */
1071  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1072  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
1073  +       if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
1074    +               return -EPERM;
1075  +#endif  +#endif
1076  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1077          lock_kernel();          lock_kernel();
1078          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
1079                  ret = ptrace_traceme();                  ret = ptrace_traceme();
1080  --- linux-2.6.21.orig/kernel/sched.c  --- linux-2.6.21.7.orig/kernel/sched.c
1081  +++ linux-2.6.21/kernel/sched.c  +++ linux-2.6.21.7/kernel/sched.c
1082  @@ -55,6 +55,9 @@  @@ -55,6 +55,9 @@
1083   #include <asm/tlb.h>   #include <asm/tlb.h>
1084    
# Line 908  Source code for this patch is http://www Line 1089  Source code for this patch is http://www
1089    
1090   /*   /*
1091    * Scheduler clock - returns current time in nanosec units.    * Scheduler clock - returns current time in nanosec units.
1092  @@ -3960,6 +3963,9 @@ int can_nice(const struct task_struct *p  @@ -3964,6 +3967,10 @@ int can_nice(const struct task_struct *p
1093   asmlinkage long sys_nice(int increment)   asmlinkage long sys_nice(int increment)
1094   {   {
1095          long nice, retval;          long nice, retval;
1096  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1097  +       if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_NICE))
1098    +               return -EPERM;
1099  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1100    
1101          /*          /*
1102           * Setpriority might change our priority at the same moment.           * Setpriority might change our priority at the same moment.
1103  --- linux-2.6.21.orig/kernel/signal.c  --- linux-2.6.21.7.orig/kernel/signal.c
1104  +++ linux-2.6.21/kernel/signal.c  +++ linux-2.6.21.7/kernel/signal.c
1105  @@ -32,6 +32,9 @@  @@ -32,6 +32,9 @@
1106   #include <asm/unistd.h>   #include <asm/unistd.h>
1107   #include <asm/siginfo.h>   #include <asm/siginfo.h>
# Line 930  Source code for this patch is http://www Line 1112  Source code for this patch is http://www
1112    
1113   /*   /*
1114    * SLAB caches for signal bits.    * SLAB caches for signal bits.
1115  @@ -2235,6 +2238,10 @@ asmlinkage long  @@ -2235,6 +2238,12 @@ asmlinkage long
1116   sys_kill(int pid, int sig)   sys_kill(int pid, int sig)
1117   {   {
1118          struct siginfo info;          struct siginfo info;
1119  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1120  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1121  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1122    +       if (sig && ccs_check_signal_acl(sig, pid))
1123    +               return -EPERM;
1124  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1125    
1126          info.si_signo = sig;          info.si_signo = sig;
1127          info.si_errno = 0;          info.si_errno = 0;
1128  @@ -2293,6 +2300,10 @@ asmlinkage long sys_tgkill(int tgid, int  @@ -2293,6 +2302,12 @@ asmlinkage long sys_tgkill(int tgid, int
1129          /* This is only valid for single tasks */          /* This is only valid for single tasks */
1130          if (pid <= 0 || tgid <= 0)          if (pid <= 0 || tgid <= 0)
1131                  return -EINVAL;                  return -EINVAL;
1132  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1133  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1134  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1135    +       if (sig && ccs_check_signal_acl(sig, pid))
1136    +               return -EPERM;
1137  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1138    
1139          return do_tkill(tgid, pid, sig);          return do_tkill(tgid, pid, sig);
1140   }   }
1141  @@ -2306,6 +2317,10 @@ sys_tkill(int pid, int sig)  @@ -2306,6 +2321,12 @@ sys_tkill(int pid, int sig)
1142          /* This is only valid for single tasks */          /* This is only valid for single tasks */
1143          if (pid <= 0)          if (pid <= 0)
1144                  return -EINVAL;                  return -EINVAL;
1145  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1146  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1147  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1148    +       if (sig && ccs_check_signal_acl(sig, pid))
1149    +               return -EPERM;
1150  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1151    
1152          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
1153   }   }
1154  --- linux-2.6.21.orig/kernel/sys.c  --- linux-2.6.21.7.orig/kernel/sys.c
1155  +++ linux-2.6.21/kernel/sys.c  +++ linux-2.6.21.7/kernel/sys.c
1156  @@ -37,6 +37,9 @@  @@ -37,6 +37,9 @@
1157   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1158   #include <asm/io.h>   #include <asm/io.h>
# Line 975  Source code for this patch is http://www Line 1163  Source code for this patch is http://www
1163    
1164   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
1165   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
1166  @@ -600,6 +603,9 @@ asmlinkage long sys_setpriority(int whic  @@ -600,6 +603,12 @@ asmlinkage long sys_setpriority(int whic
1167    
1168          if (which > 2 || which < 0)          if (which > 2 || which < 0)
1169                  goto out;                  goto out;
1170  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1171  +       if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_NICE)) {
1172    +               error = -EPERM;
1173    +               goto out;
1174    +       }
1175  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1176    
1177          /* normalize: avoid signed division (rounding problems) */          /* normalize: avoid signed division (rounding problems) */
1178          error = -ESRCH;          error = -ESRCH;
1179  @@ -830,6 +836,9 @@ asmlinkage long sys_reboot(int magic1, i  @@ -830,6 +839,10 @@ asmlinkage long sys_reboot(int magic1, i
1180                          magic2 != LINUX_REBOOT_MAGIC2B &&                          magic2 != LINUX_REBOOT_MAGIC2B &&
1181                          magic2 != LINUX_REBOOT_MAGIC2C))                          magic2 != LINUX_REBOOT_MAGIC2C))
1182                  return -EINVAL;                  return -EINVAL;
1183  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1184  +       if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_REBOOT))
1185    +               return -EPERM;
1186  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1187    
1188          /* Instead of trying to make the power_off code look like          /* Instead of trying to make the power_off code look like
1189           * 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.
1190  @@ -1806,6 +1815,9 @@ asmlinkage long sys_sethostname(char __u  @@ -1806,6 +1819,10 @@ asmlinkage long sys_sethostname(char __u
1191                  return -EPERM;                  return -EPERM;
1192          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
1193                  return -EINVAL;                  return -EINVAL;
1194  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1195  +       if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1196    +               return -EPERM;
1197  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1198          down_write(&uts_sem);          down_write(&uts_sem);
1199          errno = -EFAULT;          errno = -EFAULT;
1200          if (!copy_from_user(tmp, name, len)) {          if (!copy_from_user(tmp, name, len)) {
1201  @@ -1851,6 +1863,9 @@ asmlinkage long sys_setdomainname(char _  @@ -1851,6 +1868,10 @@ asmlinkage long sys_setdomainname(char _
1202                  return -EPERM;                  return -EPERM;
1203          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
1204                  return -EINVAL;                  return -EINVAL;
1205  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1206  +       if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1207    +               return -EPERM;
1208  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1209    
1210          down_write(&uts_sem);          down_write(&uts_sem);
1211          errno = -EFAULT;          errno = -EFAULT;
1212  --- linux-2.6.21.orig/kernel/sysctl.c  --- linux-2.6.21.7.orig/kernel/sysctl.c
1213  +++ linux-2.6.21/kernel/sysctl.c  +++ linux-2.6.21.7/kernel/sysctl.c
1214  @@ -48,6 +48,9 @@  @@ -48,6 +48,9 @@
1215    
1216   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 1027  Source code for this patch is http://www Line 1221  Source code for this patch is http://www
1221    
1222   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,
1223                        void __user *buffer, size_t *lenp, loff_t *ppos);                        void __user *buffer, size_t *lenp, loff_t *ppos);
1224  @@ -1088,6 +1091,81 @@ struct ctl_table_header *sysctl_head_nex  @@ -1088,6 +1091,93 @@ struct ctl_table_header *sysctl_head_nex
1225   }   }
1226    
1227   #ifdef CONFIG_SYSCTL_SYSCALL   #ifdef CONFIG_SYSCTL_SYSCALL
1228  +  +
1229  +/***** TOMOYO Linux start. *****/  +/***** TOMOYO Linux start. *****/
1230  +static int try_parse_table(int __user *name, int nlen, void __user *oldval, void __user *newval, ctl_table *table)  +static int try_parse_table(int __user *name, int nlen, void __user *oldval,
1231    +                          void __user *newval, ctl_table *table)
1232  +{  +{
1233  +       int n;  +       int n;
1234  +       int error = -ENOMEM;  +       int error = -ENOMEM;
1235  +       int op = 0;  +       int op = 0;
1236  +       char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);  +       char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1237  +       if (oldval) op |= 004;  +       if (oldval)
1238  +       if (newval) op |= 002;  +               op |= 004;
1239    +       if (newval)
1240    +               op |= 002;
1241  +       if (!op) { /* Neither read nor write */  +       if (!op) { /* Neither read nor write */
1242  +               error = 0;  +               error = 0;
1243  +               goto out;  +               goto out;
1244  +       }  +       }
1245  +       if (!buffer) goto out;  +       if (!buffer)
1246    +               goto out;
1247  +       memset(buffer, 0, PAGE_SIZE);  +       memset(buffer, 0, PAGE_SIZE);
1248  +       snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");  +       snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1249  + repeat:  + repeat:
# Line 1063  Source code for this patch is http://www Line 1261  Source code for this patch is http://www
1261  +                       const char *cp = table->procname;  +                       const char *cp = table->procname;
1262  +                       error = -ENOMEM;  +                       error = -ENOMEM;
1263  +                       if (cp) {  +                       if (cp) {
1264  +                               if (pos + 1 >= PAGE_SIZE - 1) goto out;  +                               if (pos + 1 >= PAGE_SIZE - 1)
1265    +                                       goto out;
1266  +                               buffer[pos++] = '/';  +                               buffer[pos++] = '/';
1267  +                               while (*cp) {  +                               while (*cp) {
1268  +                                       const unsigned char c = * (const unsigned char *) cp;  +                                       const unsigned char c
1269    +                                               = *(const unsigned char *) cp;
1270  +                                       if (c == '\\') {  +                                       if (c == '\\') {
1271  +                                               if (pos + 2 >= PAGE_SIZE - 1) goto out;  +                                               if (pos + 2 >= PAGE_SIZE - 1)
1272    +                                                       goto out;
1273  +                                               buffer[pos++] = '\\';  +                                               buffer[pos++] = '\\';
1274  +                                               buffer[pos++] = '\\';  +                                               buffer[pos++] = '\\';
1275  +                                       } else if (c > ' ' && c < 127) {  +                                       } else if (c > ' ' && c < 127) {
1276  +                                               if (pos + 1 >= PAGE_SIZE - 1) goto out;  +                                               if (pos + 1 >= PAGE_SIZE - 1)
1277    +                                                       goto out;
1278  +                                               buffer[pos++] = c;  +                                               buffer[pos++] = c;
1279  +                                       } else {  +                                       } else {
1280  +                                               if (pos + 4 >= PAGE_SIZE - 1) goto out;  +                                               if (pos + 4 >= PAGE_SIZE - 1)
1281    +                                                       goto out;
1282  +                                               buffer[pos++] = '\\';  +                                               buffer[pos++] = '\\';
1283  +                                               buffer[pos++] = (c >> 6) + '0';  +                                               buffer[pos++] = (c >> 6) + '0';
1284  +                                               buffer[pos++] = ((c >> 3) & 7) + '0';  +                                               buffer[pos++] = ((c >> 3) & 7)
1285    +                                                       + '0';
1286  +                                               buffer[pos++] = (c & 7) + '0';  +                                               buffer[pos++] = (c & 7) + '0';
1287  +                                       }  +                                       }
1288  +                                       cp++;  +                                       cp++;
1289  +                               }  +                               }
1290  +                       } else {  +                       } else {
1291  +                               /* Assume nobody assigns "=\$=" for procname. */  +                               /* Assume nobody assigns "=\$=" for procname. */
1292  +                               snprintf(buffer + pos, PAGE_SIZE - pos - 1, "/=%d=", n);  +                               snprintf(buffer + pos, PAGE_SIZE - pos - 1,
1293  +                               if (memchr(buffer, '\0', PAGE_SIZE - 2) == NULL) goto out;  +                                        "/=%d=", n);
1294    +                               if (!memchr(buffer, '\0', PAGE_SIZE - 2))
1295    +                                       goto out;
1296  +                       }  +                       }
1297  +                       if (table->child) {  +                       if (table->child) {
1298  +                               name++;  +                               name++;
# Line 1095  Source code for this patch is http://www Line 1301  Source code for this patch is http://www
1301  +                               goto repeat;  +                               goto repeat;
1302  +                       }  +                       }
1303  +                       /* printk("sysctl='%s'\n", buffer); */  +                       /* printk("sysctl='%s'\n", buffer); */
1304  +                       error = CheckFilePerm(buffer, op, "sysctl");  +                       error = ccs_check_file_perm(buffer, op, "sysctl");
1305  +                       goto out;  +                       goto out;
1306  +               }  +               }
1307  +       }  +       }
# Line 1109  Source code for this patch is http://www Line 1315  Source code for this patch is http://www
1315   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,
1316                 void __user *newval, size_t newlen)                 void __user *newval, size_t newlen)
1317   {   {
1318  @@ -1104,6 +1182,9 @@ int do_sysctl(int __user *name, int nlen  @@ -1104,6 +1194,11 @@ int do_sysctl(int __user *name, int nlen
1319    
1320          for (head = sysctl_head_next(NULL); head;          for (head = sysctl_head_next(NULL); head;
1321                          head = sysctl_head_next(head)) {                          head = sysctl_head_next(head)) {
1322  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1323  +               if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0)  +               error = try_parse_table(name, nlen, oldval, newval,
1324    +                                       head->ctl_table);
1325    +               if (!error)
1326  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1327                  error = parse_table(name, nlen, oldval, oldlenp,                  error = parse_table(name, nlen, oldval, oldlenp,
1328                                          newval, newlen, head->ctl_table);                                          newval, newlen, head->ctl_table);
1329                  if (error != -ENOTDIR) {                  if (error != -ENOTDIR) {
1330  --- linux-2.6.21.orig/kernel/time.c  --- linux-2.6.21.7.orig/kernel/time.c
1331  +++ linux-2.6.21/kernel/time.c  +++ linux-2.6.21.7/kernel/time.c
1332  @@ -39,6 +39,9 @@  @@ -39,6 +39,9 @@
1333    
1334   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 1131  Source code for this patch is http://www Line 1339  Source code for this patch is http://www
1339    
1340   /*   /*
1341    * 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
1342  @@ -91,6 +94,9 @@ asmlinkage long sys_stime(time_t __user  @@ -91,6 +94,10 @@ asmlinkage long sys_stime(time_t __user
1343          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
1344          if (err)          if (err)
1345                  return err;                  return err;
1346  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1347  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME))
1348    +               return -EPERM;
1349  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1350    
1351          do_settimeofday(&tv);          do_settimeofday(&tv);
1352          return 0;          return 0;
1353  @@ -161,6 +167,9 @@ int do_sys_settimeofday(struct timespec  @@ -161,6 +168,10 @@ int do_sys_settimeofday(struct timespec
1354          error = security_settime(tv, tz);          error = security_settime(tv, tz);
1355          if (error)          if (error)
1356                  return error;                  return error;
1357  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1358  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME))
1359    +               return -EPERM;
1360  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1361    
1362          if (tz) {          if (tz) {
1363                  /* SMP safe, global irq locking makes it work. */                  /* SMP safe, global irq locking makes it work. */
1364  --- linux-2.6.21.orig/kernel/time/ntp.c  --- linux-2.6.21.7.orig/kernel/time/ntp.c
1365  +++ linux-2.6.21/kernel/time/ntp.c  +++ linux-2.6.21.7/kernel/time/ntp.c
1366  @@ -14,6 +14,9 @@  @@ -14,6 +14,9 @@
1367    
1368   #include <asm/div64.h>   #include <asm/div64.h>
# Line 1163  Source code for this patch is http://www Line 1373  Source code for this patch is http://www
1373    
1374   /*   /*
1375    * Timekeeping variables    * Timekeeping variables
1376  @@ -203,6 +206,9 @@ int do_adjtimex(struct timex *txc)  @@ -201,6 +204,10 @@ int do_adjtimex(struct timex *txc)
1377          /* In order to modify anything, you gotta be super-user! */          /* In order to modify anything, you gotta be super-user! */
1378          if (txc->modes && !capable(CAP_SYS_TIME))          if (txc->modes && !capable(CAP_SYS_TIME))
1379                  return -EPERM;                  return -EPERM;
1380  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1381  +       if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME))
1382    +               return -EPERM;
1383  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1384    
1385          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
1386    
1387  --- linux-2.6.21.orig/net/core/datagram.c  --- linux-2.6.21.7.orig/net/core/datagram.c
1388  +++ linux-2.6.21/net/core/datagram.c  +++ linux-2.6.21.7/net/core/datagram.c
1389  @@ -56,6 +56,11 @@  @@ -56,6 +56,11 @@
1390   #include <net/sock.h>   #include <net/sock.h>
1391   #include <net/tcp_states.h>   #include <net/tcp_states.h>
# Line 1187  Source code for this patch is http://www Line 1398  Source code for this patch is http://www
1398   /*   /*
1399    *     Is a socket 'connection oriented' ?    *     Is a socket 'connection oriented' ?
1400    */    */
1401  @@ -178,6 +183,10 @@ struct sk_buff *skb_recv_datagram(struct  @@ -178,6 +183,12 @@ struct sk_buff *skb_recv_datagram(struct
1402                  } else                  } else
1403                          skb = skb_dequeue(&sk->sk_receive_queue);                          skb = skb_dequeue(&sk->sk_receive_queue);
1404    
1405  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1406  +               if ((error = CheckSocketRecvDatagramPermission(sk, skb, flags)) < 0) goto no_packet;  +               error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1407    +               if (error)
1408    +                       goto no_packet;
1409  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1410  +  +
1411                  if (skb)                  if (skb)
1412                          return skb;                          return skb;
1413    
1414  --- linux-2.6.21.orig/net/ipv4/inet_connection_sock.c  --- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c
1415  +++ linux-2.6.21/net/ipv4/inet_connection_sock.c  +++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c
1416  @@ -23,6 +23,9 @@  @@ -23,6 +23,9 @@
1417   #include <net/route.h>   #include <net/route.h>
1418   #include <net/tcp_states.h>   #include <net/tcp_states.h>
# Line 1210  Source code for this patch is http://www Line 1423  Source code for this patch is http://www
1423    
1424   #ifdef INET_CSK_DEBUG   #ifdef INET_CSK_DEBUG
1425   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";
1426  @@ -87,6 +90,9 @@ int inet_csk_get_port(struct inet_hashin  @@ -85,6 +88,10 @@ int inet_csk_get_port(struct inet_hashin
1427                  do {                  do {
1428                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1429                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1430  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1431  +                       if (SAKURA_MayAutobind(rover) < 0) goto next;  +                       if (ccs_may_autobind(rover))
1432    +                               goto next;
1433  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1434                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
1435                                  if (tb->port == rover)                                  if (tb->port == rover)
1436                                          goto next;                                          goto next;
1437  --- linux-2.6.21.orig/net/ipv4/inet_hashtables.c  --- linux-2.6.21.7.orig/net/ipv4/inet_hashtables.c
1438  +++ linux-2.6.21/net/ipv4/inet_hashtables.c  +++ linux-2.6.21.7/net/ipv4/inet_hashtables.c
1439  @@ -22,6 +22,9 @@  @@ -22,6 +22,9 @@
1440   #include <net/inet_connection_sock.h>   #include <net/inet_connection_sock.h>
1441   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
# Line 1232  Source code for this patch is http://www Line 1446  Source code for this patch is http://www
1446    
1447   /*   /*
1448    * Allocate and initialize a new local port bind bucket.    * Allocate and initialize a new local port bind bucket.
1449  @@ -292,6 +295,9 @@ int inet_hash_connect(struct inet_timewa  @@ -292,6 +295,10 @@ int inet_hash_connect(struct inet_timewa
1450                  local_bh_disable();                  local_bh_disable();
1451                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1452                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1453  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1454  +                       if (SAKURA_MayAutobind(port) < 0) continue;  +                       if (ccs_may_autobind(port))
1455    +                               continue;
1456  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1457                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1458                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1459    
1460  --- linux-2.6.21.orig/net/ipv4/udp.c  --- linux-2.6.21.7.orig/net/ipv4/udp.c
1461  +++ linux-2.6.21/net/ipv4/udp.c  +++ linux-2.6.21.7/net/ipv4/udp.c
1462  @@ -102,6 +102,9 @@  @@ -102,6 +102,9 @@
1463   #include <net/checksum.h>   #include <net/checksum.h>
1464   #include <net/xfrm.h>   #include <net/xfrm.h>
# Line 1254  Source code for this patch is http://www Line 1469  Source code for this patch is http://www
1469    
1470   /*   /*
1471    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
1472  @@ -162,6 +165,9 @@ int __udp_lib_get_port(struct sock *sk,  @@ -162,6 +165,10 @@ int __udp_lib_get_port(struct sock *sk,
1473                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1474                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1475                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
1476  +                               /***** SAKURA Linux start. *****/  +                               /***** SAKURA Linux start. *****/
1477  +                               if (SAKURA_MayAutobind(result) < 0) continue;  +                               if (ccs_may_autobind(result))
1478    +                                       continue;
1479  +                               /***** SAKURA Linux end. *****/  +                               /***** SAKURA Linux end. *****/
1480                                  goto gotit;                                  goto gotit;
1481                          }                          }
1482                          size = 0;                          size = 0;
1483  @@ -180,6 +186,9 @@ int __udp_lib_get_port(struct sock *sk,  @@ -180,6 +187,10 @@ int __udp_lib_get_port(struct sock *sk,
1484                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1485                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1486                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
1487  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1488  +                       if (SAKURA_MayAutobind(result) < 0) continue;  +                       if (ccs_may_autobind(result))
1489    +                               continue;
1490  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1491                          if (! __udp_lib_lport_inuse(result, udptable))                          if (! __udp_lib_lport_inuse(result, udptable))
1492                                  break;                                  break;
1493                  }                  }
1494  --- linux-2.6.21.orig/net/ipv6/inet6_hashtables.c  --- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c
1495  +++ linux-2.6.21/net/ipv6/inet6_hashtables.c  +++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c
1496  @@ -21,6 +21,9 @@  @@ -21,6 +21,9 @@
1497   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1498   #include <net/inet6_hashtables.h>   #include <net/inet6_hashtables.h>
# Line 1286  Source code for this patch is http://www Line 1503  Source code for this patch is http://www
1503    
1504   void __inet6_hash(struct inet_hashinfo *hashinfo,   void __inet6_hash(struct inet_hashinfo *hashinfo,
1505                                  struct sock *sk)                                  struct sock *sk)
1506  @@ -266,6 +269,9 @@ int inet6_hash_connect(struct inet_timew  @@ -266,6 +269,10 @@ int inet6_hash_connect(struct inet_timew
1507                  local_bh_disable();                  local_bh_disable();
1508                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1509                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1510  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1511  +                       if (SAKURA_MayAutobind(port) < 0) continue;  +                       if (ccs_may_autobind(port))
1512    +                               continue;
1513  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1514                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1515                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1516    
1517  --- linux-2.6.21.orig/net/socket.c  --- linux-2.6.21.7.orig/net/socket.c
1518  +++ linux-2.6.21/net/socket.c  +++ linux-2.6.21.7/net/socket.c
1519  @@ -93,6 +93,11 @@  @@ -93,6 +93,11 @@
1520   #include <net/sock.h>   #include <net/sock.h>
1521   #include <linux/netfilter.h>   #include <linux/netfilter.h>
# Line 1310  Source code for this patch is http://www Line 1528  Source code for this patch is http://www
1528   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1529   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,
1530                           unsigned long nr_segs, loff_t pos);                           unsigned long nr_segs, loff_t pos);
1531  @@ -549,6 +554,9 @@ static inline int __sock_sendmsg(struct  @@ -549,6 +554,12 @@ static inline int __sock_sendmsg(struct
1532          err = security_socket_sendmsg(sock, msg, size);          err = security_socket_sendmsg(sock, msg, size);
1533          if (err)          if (err)
1534                  return err;                  return err;
1535  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1536  +       if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;  +       if (ccs_socket_sendmsg_permission(sock,
1537    +                                         (struct sockaddr *) msg->msg_name,
1538    +                                         msg->msg_namelen))
1539    +               return -EPERM;
1540  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1541    
1542          return sock->ops->sendmsg(iocb, sock, msg, size);          return sock->ops->sendmsg(iocb, sock, msg, size);
1543   }   }
1544  @@ -1070,6 +1078,10 @@ static int __sock_create(int family, int  @@ -1070,6 +1081,12 @@ static int __sock_create(int family, int
1545                  family = PF_PACKET;                  family = PF_PACKET;
1546          }          }
1547    
1548  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1549  +       if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err;  +       err = ccs_socket_create_permission(family, type, protocol);
1550    +       if (err)
1551    +               return err;
1552  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1553  +  +
1554          err = security_socket_create(family, type, protocol, kern);          err = security_socket_create(family, type, protocol, kern);
1555          if (err)          if (err)
1556                  return err;                  return err;
1557  @@ -1298,6 +1310,9 @@ asmlinkage long sys_bind(int fd, struct  @@ -1298,6 +1315,13 @@ asmlinkage long sys_bind(int fd, struct
1558                          err = security_socket_bind(sock,                          err = security_socket_bind(sock,
1559                                                     (struct sockaddr *)address,                                                     (struct sockaddr *)address,
1560                                                     addrlen);                                                     addrlen);
1561  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
1562  +                       if (!err) err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen);  +                       if (!err)
1563    +                               err = ccs_socket_bind_permission(sock,
1564    +                                                        (struct sockaddr *)
1565    +                                                                address,
1566    +                                                                addrlen);
1567  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
1568                          if (!err)                          if (!err)
1569                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
1570                                                        (struct sockaddr *)                                                        (struct sockaddr *)
1571  @@ -1327,6 +1342,9 @@ asmlinkage long sys_listen(int fd, int b  @@ -1327,6 +1351,10 @@ asmlinkage long sys_listen(int fd, int b
1572                          backlog = sysctl_somaxconn;                          backlog = sysctl_somaxconn;
1573    
1574                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
1575  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1576  +               if (!err) err = CheckSocketListenPermission(sock);  +               if (!err)
1577    +                       err = ccs_socket_listen_permission(sock);
1578  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1579                  if (!err)                  if (!err)
1580                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
1581    
1582  @@ -1391,6 +1409,12 @@ asmlinkage long sys_accept(int fd, struc  @@ -1391,6 +1419,13 @@ asmlinkage long sys_accept(int fd, struc
1583          if (err < 0)          if (err < 0)
1584                  goto out_fd;                  goto out_fd;
1585    
1586  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1587  +       if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) {  +       if (ccs_socket_accept_permission(newsock,
1588    +                                        (struct sockaddr *) address)) {
1589  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1590  +               goto out_fd;  +               goto out_fd;
1591  +       }  +       }
# Line 1364  Source code for this patch is http://www Line 1593  Source code for this patch is http://www
1593          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1594                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1595                                            &len, 2) < 0) {                                            &len, 2) < 0) {
1596  @@ -1455,6 +1479,10 @@ asmlinkage long sys_connect(int fd, stru  @@ -1455,6 +1490,12 @@ asmlinkage long sys_connect(int fd, stru
1597              security_socket_connect(sock, (struct sockaddr *)address, addrlen);              security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1598          if (err)          if (err)
1599                  goto out_put;                  goto out_put;
1600  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1601  +       err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen);  +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1602  +       if (err) goto out_put;  +                                           addrlen);
1603    +       if (err)
1604    +               goto out_put;
1605  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1606    
1607          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
1608                                   sock->file->f_flags);                                   sock->file->f_flags);
1609  --- linux-2.6.21.orig/net/unix/af_unix.c  --- linux-2.6.21.7.orig/net/unix/af_unix.c
1610  +++ linux-2.6.21/net/unix/af_unix.c  +++ linux-2.6.21.7/net/unix/af_unix.c
1611  @@ -116,6 +116,9 @@  @@ -116,6 +116,9 @@
1612   #include <linux/mount.h>   #include <linux/mount.h>
1613   #include <net/checksum.h>   #include <net/checksum.h>
# Line 1387  Source code for this patch is http://www Line 1618  Source code for this patch is http://www
1618    
1619   int sysctl_unix_max_dgram_qlen __read_mostly = 10;   int sysctl_unix_max_dgram_qlen __read_mostly = 10;
1620    
1621  @@ -765,6 +768,10 @@ static int unix_bind(struct socket *sock  @@ -765,6 +768,11 @@ static int unix_bind(struct socket *sock
1622                  err = unix_autobind(sock);                  err = unix_autobind(sock);
1623                  goto out;                  goto out;
1624          }          }
1625  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1626  +       err = -EPERM;  +       err = -EPERM;
1627  +       if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out;  +       if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
1628    +               goto out;
1629  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1630    
1631          err = unix_mkname(sunaddr, addr_len, &hash);          err = unix_mkname(sunaddr, addr_len, &hash);
1632          if (err < 0)          if (err < 0)
1633  @@ -808,6 +815,9 @@ static int unix_bind(struct socket *sock  @@ -808,6 +816,13 @@ static int unix_bind(struct socket *sock
1634                   */                   */
1635                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1636                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1637  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1638  +               if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)  +               err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
1639    +               if (!err)
1640    +                       err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry,
1641    +                                                  nd.mnt);
1642    +               if (!err)
1643  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1644                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1645                  if (err)                  if (err)
1646                          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.1769

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