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

Subversion リポジトリの参照

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

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

trunk/1.5.x/ccs-patch/ccs-patch-2.6.21.txt revision 352 by kumaneko, Tue Aug 14 11:27:50 2007 UTC trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.21.diff revision 1055 by kumaneko, Tue Mar 25 09:01:31 2008 UTC
# Line 1  Line 1 
1  diff -ubBpEr linux-2.6.21/Makefile linux-2.6.21-ccs/Makefile  This is TOMOYO Linux patch for kernel 2.6.21.
2  --- linux-2.6.21/Makefile       2007-04-28 04:02:41.000000000 +0900  
3  +++ linux-2.6.21-ccs/Makefile   2007-04-26 17:11:12.000000000 +0900  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.tar.bz2
4    ---
5     Makefile                        |    2
6     arch/alpha/kernel/ptrace.c      |    8 +++
7     arch/ia64/ia32/sys_ia32.c       |    8 +++
8     arch/ia64/kernel/ptrace.c       |    8 +++
9     arch/m32r/kernel/ptrace.c       |    8 +++
10     arch/mips/kernel/ptrace32.c     |    8 +++
11     arch/powerpc/kernel/ptrace32.c  |    8 +++
12     arch/s390/kernel/ptrace.c       |    8 +++
13     arch/sh64/kernel/ptrace.c       |    8 +++
14     arch/sparc/kernel/ptrace.c      |   11 +++++
15     arch/sparc64/kernel/ptrace.c    |   11 +++++
16     arch/x86_64/ia32/ptrace32.c     |    8 +++
17     fs/Kconfig                      |    2
18     fs/Makefile                     |    2
19     fs/attr.c                       |   11 +++++
20     fs/compat.c                     |    8 +++
21     fs/exec.c                       |   14 ++++++
22     fs/fcntl.c                      |    7 +++
23     fs/ioctl.c                      |    6 ++
24     fs/namei.c                      |   60 +++++++++++++++++++++++++++++
25     fs/namespace.c                  |   38 ++++++++++++++++++
26     fs/open.c                       |   21 ++++++++++
27     fs/proc/Makefile                |    3 +
28     fs/proc/proc_misc.c             |    5 ++
29     include/linux/init_task.h       |    4 +
30     include/linux/sched.h           |    9 ++++
31     kernel/compat.c                 |    6 ++
32     kernel/kexec.c                  |    6 ++
33     kernel/kmod.c                   |    5 ++
34     kernel/module.c                 |    9 ++++
35     kernel/ptrace.c                 |    8 +++
36     kernel/sched.c                  |    6 ++
37     kernel/signal.c                 |   15 +++++++
38     kernel/sys.c                    |   15 +++++++
39     kernel/sysctl.c                 |   81 ++++++++++++++++++++++++++++++++++++++++
40     kernel/time.c                   |    9 ++++
41     kernel/time/ntp.c               |    6 ++
42     net/core/datagram.c             |    9 ++++
43     net/ipv4/inet_connection_sock.c |    6 ++
44     net/ipv4/inet_hashtables.c      |    6 ++
45     net/ipv4/udp.c                  |    9 ++++
46     net/ipv6/inet6_hashtables.c     |    6 ++
47     net/socket.c                    |   28 +++++++++++++
48     net/unix/af_unix.c              |   10 ++++
49     44 files changed, 523 insertions(+), 3 deletions(-)
50    
51    --- linux-2.6.21.orig/Makefile
52    +++ linux-2.6.21/Makefile
53  @@ -1,7 +1,7 @@  @@ -1,7 +1,7 @@
54   VERSION = 2   VERSION = 2
55   PATCHLEVEL = 6   PATCHLEVEL = 6
# Line 10  diff -ubBpEr linux-2.6.21/Makefile linux Line 59  diff -ubBpEr linux-2.6.21/Makefile linux
59   NAME = Nocturnal Monster Puppy   NAME = Nocturnal Monster Puppy
60    
61   # *DOCUMENTATION*   # *DOCUMENTATION*
62  diff -ubBpEr linux-2.6.21/fs/Kconfig linux-2.6.21-ccs/fs/Kconfig  --- linux-2.6.21.orig/arch/alpha/kernel/ptrace.c
63  --- linux-2.6.21/fs/Kconfig     2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/arch/alpha/kernel/ptrace.c
64  +++ linux-2.6.21-ccs/fs/Kconfig 2007-04-26 17:17:25.000000000 +0900  @@ -20,6 +20,9 @@
65     #include <asm/pgtable.h>
66     #include <asm/system.h>
67     #include <asm/fpu.h>
68    +/***** TOMOYO Linux start. *****/
69    +#include <linux/tomoyo.h>
70    +/***** TOMOYO Linux end. *****/
71    
72     #include "proto.h"
73    
74    @@ -268,6 +271,11 @@ do_sys_ptrace(long request, long pid, lo
75            unsigned long tmp;
76            size_t copied;
77            long ret;
78    +       /***** TOMOYO Linux start. *****/
79    +#ifdef TOMOYO_SYS_PTRACE
80    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
81    +#endif
82    +       /***** TOMOYO Linux end. *****/
83    
84            lock_kernel();
85            DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
86    --- linux-2.6.21.orig/arch/ia64/kernel/ptrace.c
87    +++ linux-2.6.21/arch/ia64/kernel/ptrace.c
88    @@ -28,6 +28,9 @@
89     #ifdef CONFIG_PERFMON
90     #include <asm/perfmon.h>
91     #endif
92    +/***** TOMOYO Linux start. *****/
93    +#include <linux/tomoyo.h>
94    +/***** TOMOYO Linux end. *****/
95    
96     #include "entry.h"
97    
98    @@ -1418,6 +1421,11 @@ sys_ptrace (long request, pid_t pid, uns
99            struct task_struct *child;
100            struct switch_stack *sw;
101            long ret;
102    +       /***** TOMOYO Linux start. *****/
103    +#ifdef TOMOYO_SYS_PTRACE
104    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
105    +#endif
106    +       /***** TOMOYO Linux end. *****/
107    
108            lock_kernel();
109            ret = -EPERM;
110    --- linux-2.6.21.orig/arch/m32r/kernel/ptrace.c
111    +++ linux-2.6.21/arch/m32r/kernel/ptrace.c
112    @@ -32,6 +32,9 @@
113     #include <asm/system.h>
114     #include <asm/processor.h>
115     #include <asm/mmu_context.h>
116    +/***** TOMOYO Linux start. *****/
117    +#include <linux/tomoyo.h>
118    +/***** TOMOYO Linux end. *****/
119    
120     /*
121      * This routine will get a word off of the process kernel stack.
122    @@ -742,6 +745,11 @@ asmlinkage long sys_ptrace(long request,
123     {
124            struct task_struct *child;
125            int ret;
126    +       /***** TOMOYO Linux start. *****/
127    +#ifdef TOMOYO_SYS_PTRACE
128    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
129    +#endif
130    +       /***** TOMOYO Linux end. *****/
131    
132            lock_kernel();
133            if (request == PTRACE_TRACEME) {
134    --- linux-2.6.21.orig/arch/s390/kernel/ptrace.c
135    +++ linux-2.6.21/arch/s390/kernel/ptrace.c
136    @@ -41,6 +41,9 @@
137     #include <asm/system.h>
138     #include <asm/uaccess.h>
139     #include <asm/unistd.h>
140    +/***** TOMOYO Linux start. *****/
141    +#include <linux/tomoyo.h>
142    +/***** TOMOYO Linux end. *****/
143    
144     #ifdef CONFIG_COMPAT
145     #include "compat_ptrace.h"
146    @@ -713,6 +716,11 @@ sys_ptrace(long request, long pid, long
147            struct task_struct *child;
148            int ret;
149    
150    +       /***** TOMOYO Linux start. *****/
151    +#ifdef TOMOYO_SYS_PTRACE
152    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
153    +#endif
154    +       /***** TOMOYO Linux end. *****/
155            lock_kernel();
156            if (request == PTRACE_TRACEME) {
157                     ret = ptrace_traceme();
158    --- linux-2.6.21.orig/arch/sparc/kernel/ptrace.c
159    +++ linux-2.6.21/arch/sparc/kernel/ptrace.c
160    @@ -23,6 +23,9 @@
161     #include <asm/pgtable.h>
162     #include <asm/system.h>
163     #include <asm/uaccess.h>
164    +/***** TOMOYO Linux start. *****/
165    +#include <linux/tomoyo.h>
166    +/***** TOMOYO Linux end. *****/
167    
168     #define MAGIC_CONSTANT 0x80000000
169    
170    @@ -267,6 +270,14 @@ asmlinkage void do_ptrace(struct pt_regs
171            unsigned long addr2 = regs->u_regs[UREG_I4];
172            struct task_struct *child;
173            int ret;
174    +       /***** TOMOYO Linux start. *****/
175    +#ifdef TOMOYO_SYS_PTRACE
176    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) {
177    +               pt_error_return(regs, EPERM);
178    +               return;
179    +       }
180    +#endif
181    +       /***** TOMOYO Linux end. *****/
182    
183            lock_kernel();
184     #ifdef DEBUG_PTRACE
185    --- linux-2.6.21.orig/arch/sparc64/kernel/ptrace.c
186    +++ linux-2.6.21/arch/sparc64/kernel/ptrace.c
187    @@ -32,6 +32,9 @@
188     #include <asm/spitfire.h>
189     #include <asm/page.h>
190     #include <asm/cpudata.h>
191    +/***** TOMOYO Linux start. *****/
192    +#include <linux/tomoyo.h>
193    +/***** TOMOYO Linux end. *****/
194    
195     /* Returning from ptrace is a bit tricky because the syscall return
196      * low level code assumes any value returned which is negative and
197    @@ -176,6 +179,14 @@ asmlinkage void do_ptrace(struct pt_regs
198            unsigned long addr2 = regs->u_regs[UREG_I4];
199            struct task_struct *child;
200            int ret;
201    +       /***** TOMOYO Linux start. *****/
202    +#ifdef TOMOYO_SYS_PTRACE
203    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) {
204    +               pt_error_return(regs, EPERM);
205    +               return;
206    +       }
207    +#endif
208    +       /***** TOMOYO Linux end. *****/
209    
210            if (test_thread_flag(TIF_32BIT)) {
211                    addr &= 0xffffffffUL;
212    --- linux-2.6.21.orig/fs/Kconfig
213    +++ linux-2.6.21/fs/Kconfig
214  @@ -2055,5 +2055,7 @@ endif  @@ -2055,5 +2055,7 @@ endif
215   source "fs/nls/Kconfig"   source "fs/nls/Kconfig"
216   source "fs/dlm/Kconfig"   source "fs/dlm/Kconfig"
# Line 21  diff -ubBpEr linux-2.6.21/fs/Kconfig lin Line 219  diff -ubBpEr linux-2.6.21/fs/Kconfig lin
219  +  +
220   endmenu   endmenu
221    
222  diff -ubBpEr linux-2.6.21/fs/Makefile linux-2.6.21-ccs/fs/Makefile  --- linux-2.6.21.orig/fs/Makefile
223  --- linux-2.6.21/fs/Makefile    2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/Makefile
 +++ linux-2.6.21-ccs/fs/Makefile        2007-04-28 04:02:47.000000000 +0900  
224  @@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS)         += hppfs/  @@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS)         += hppfs/
225   obj-$(CONFIG_DEBUG_FS)         += debugfs/   obj-$(CONFIG_DEBUG_FS)         += debugfs/
226   obj-$(CONFIG_OCFS2_FS)         += ocfs2/   obj-$(CONFIG_OCFS2_FS)         += ocfs2/
227   obj-$(CONFIG_GFS2_FS)           += gfs2/   obj-$(CONFIG_GFS2_FS)           += gfs2/
228  +  +
229  +include $(srctree)/fs/Makefile-2.6.ccs  +include $(srctree)/fs/Makefile-2.6.ccs
230  diff -ubBpEr linux-2.6.21/fs/attr.c linux-2.6.21-ccs/fs/attr.c  --- linux-2.6.21.orig/fs/attr.c
231  --- linux-2.6.21/fs/attr.c      2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/attr.c
 +++ linux-2.6.21-ccs/fs/attr.c  2007-04-28 04:02:47.000000000 +0900  
232  @@ -15,6 +15,9 @@  @@ -15,6 +15,9 @@
233   #include <linux/fcntl.h>   #include <linux/fcntl.h>
234   #include <linux/quotaops.h>   #include <linux/quotaops.h>
# Line 48  diff -ubBpEr linux-2.6.21/fs/attr.c linu Line 244  diff -ubBpEr linux-2.6.21/fs/attr.c linu
244          if (inode->i_op && inode->i_op->setattr) {          if (inode->i_op && inode->i_op->setattr) {
245                  error = security_inode_setattr(dentry, attr);                  error = security_inode_setattr(dentry, attr);
246  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
247  +               if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);  +               if (!error && (ia_valid & ATTR_MODE) && !ccs_capable(TOMOYO_SYS_CHMOD)) error = -EPERM;
248  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && !ccs_capable(TOMOYO_SYS_CHOWN)) error = -EPERM;
249  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
250                  if (!error)                  if (!error)
251                          error = inode->i_op->setattr(dentry, attr);                          error = inode->i_op->setattr(dentry, attr);
# Line 58  diff -ubBpEr linux-2.6.21/fs/attr.c linu Line 254  diff -ubBpEr linux-2.6.21/fs/attr.c linu
254                  if (!error)                  if (!error)
255                          error = security_inode_setattr(dentry, attr);                          error = security_inode_setattr(dentry, attr);
256  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
257  +               if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);  +               if (!error && (ia_valid & ATTR_MODE) && !ccs_capable(TOMOYO_SYS_CHMOD)) error = -EPERM;
258  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && !ccs_capable(TOMOYO_SYS_CHOWN)) error = -EPERM;
259  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
260                  if (!error) {                  if (!error) {
261                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
262                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
263  diff -ubBpEr linux-2.6.21/fs/compat.c linux-2.6.21-ccs/fs/compat.c  --- linux-2.6.21.orig/fs/compat.c
264  --- linux-2.6.21/fs/compat.c    2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/compat.c
 +++ linux-2.6.21-ccs/fs/compat.c        2007-04-28 04:02:47.000000000 +0900  
265  @@ -56,6 +56,9 @@  @@ -56,6 +56,9 @@
266   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
267   #include <asm/ioctls.h>   #include <asm/ioctls.h>
# Line 82  diff -ubBpEr linux-2.6.21/fs/compat.c li Line 277  diff -ubBpEr linux-2.6.21/fs/compat.c li
277    
278          default:          default:
279  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
280  +               if ((error = CheckCapabilityACL(TOMOYO_SYS_IOCTL)) < 0) goto out_fput;  +               if (!ccs_capable(TOMOYO_SYS_IOCTL)) { error = -EPERM; goto out_fput; }
281  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
282                  if (filp->f_op && filp->f_op->compat_ioctl) {                  if (filp->f_op && filp->f_op->compat_ioctl) {
283                          error = filp->f_op->compat_ioctl(filp, cmd, arg);                          error = filp->f_op->compat_ioctl(filp, cmd, arg);
# Line 96  diff -ubBpEr linux-2.6.21/fs/compat.c li Line 291  diff -ubBpEr linux-2.6.21/fs/compat.c li
291          if (retval >= 0) {          if (retval >= 0) {
292                  free_arg_pages(bprm);                  free_arg_pages(bprm);
293    
294  diff -ubBpEr linux-2.6.21/fs/exec.c linux-2.6.21-ccs/fs/exec.c  --- linux-2.6.21.orig/fs/exec.c
295  --- linux-2.6.21/fs/exec.c      2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/exec.c
 +++ linux-2.6.21-ccs/fs/exec.c  2007-04-28 04:02:47.000000000 +0900  
296  @@ -58,6 +58,10 @@  @@ -58,6 +58,10 @@
297   #include <linux/kmod.h>   #include <linux/kmod.h>
298   #endif   #endif
# Line 115  diff -ubBpEr linux-2.6.21/fs/exec.c linu Line 309  diff -ubBpEr linux-2.6.21/fs/exec.c linu
309                  goto exit;                  goto exit;
310    
311  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
312  +       error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */  +       error = ccs_check_open_permission(nd.dentry, nd.mnt, 01); /* 01 means "read". */
313  +       if (error) goto exit;  +       if (error) goto exit;
314  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
315  +  +
# Line 127  diff -ubBpEr linux-2.6.21/fs/exec.c linu Line 321  diff -ubBpEr linux-2.6.21/fs/exec.c linu
321                      S_ISREG(inode->i_mode)) {                      S_ISREG(inode->i_mode)) {
322                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
323  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
324  +                       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 & TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) err = ccs_check_open_permission(nd.dentry, nd.mnt, 01); /* 01 means "read". */
325  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
326                          file = ERR_PTR(err);                          file = ERR_PTR(err);
327                          if (!err) {                          if (!err) {
# Line 141  diff -ubBpEr linux-2.6.21/fs/exec.c linu Line 335  diff -ubBpEr linux-2.6.21/fs/exec.c linu
335          if (retval >= 0) {          if (retval >= 0) {
336                  free_arg_pages(bprm);                  free_arg_pages(bprm);
337    
338  diff -ubBpEr linux-2.6.21/fs/fcntl.c linux-2.6.21-ccs/fs/fcntl.c  --- linux-2.6.21.orig/fs/fcntl.c
339  --- linux-2.6.21/fs/fcntl.c     2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/fcntl.c
 +++ linux-2.6.21-ccs/fs/fcntl.c 2007-04-28 04:02:47.000000000 +0900  
340  @@ -22,6 +22,9 @@  @@ -22,6 +22,9 @@
341   #include <asm/poll.h>   #include <asm/poll.h>
342   #include <asm/siginfo.h>   #include <asm/siginfo.h>
# Line 159  diff -ubBpEr linux-2.6.21/fs/fcntl.c lin Line 352  diff -ubBpEr linux-2.6.21/fs/fcntl.c lin
352                  return -EPERM;                  return -EPERM;
353    
354  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
355  +       if (((arg ^ filp->f_flags) & O_APPEND) && CheckReWritePermission(filp)) return -EPERM;  +       if (((arg ^ filp->f_flags) & O_APPEND) && ccs_check_rewrite_permission(filp)) return -EPERM;
356  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
357  +  +
358          /* O_NOATIME can only be set by the owner or superuser */          /* O_NOATIME can only be set by the owner or superuser */
359          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
360                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
361  diff -ubBpEr linux-2.6.21/fs/ioctl.c linux-2.6.21-ccs/fs/ioctl.c  --- linux-2.6.21.orig/fs/ioctl.c
362  --- linux-2.6.21/fs/ioctl.c     2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/ioctl.c
 +++ linux-2.6.21-ccs/fs/ioctl.c 2007-04-28 04:02:47.000000000 +0900  
363  @@ -15,6 +15,9 @@  @@ -15,6 +15,9 @@
364    
365   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 183  diff -ubBpEr linux-2.6.21/fs/ioctl.c lin Line 375  diff -ubBpEr linux-2.6.21/fs/ioctl.c lin
375          if (!filp->f_op)          if (!filp->f_op)
376                  goto out;                  goto out;
377  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
378  +       if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_IOCTL)) return -EPERM;
379  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
380    
381          if (filp->f_op->unlocked_ioctl) {          if (filp->f_op->unlocked_ioctl) {
382                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
383  diff -ubBpEr linux-2.6.21/fs/namei.c linux-2.6.21-ccs/fs/namei.c  --- linux-2.6.21.orig/fs/namei.c
384  --- linux-2.6.21/fs/namei.c     2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/namei.c
 +++ linux-2.6.21-ccs/fs/namei.c 2007-04-28 04:02:47.000000000 +0900  
385  @@ -37,6 +37,10 @@  @@ -37,6 +37,10 @@
386    
387   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
# Line 207  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 398  diff -ubBpEr linux-2.6.21/fs/namei.c lin
398          if (error)          if (error)
399                  return error;                  return error;
400  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
401  +       if (nd && (error = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;  +       if (nd && (error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;
402  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
403          DQUOT_INIT(dir);          DQUOT_INIT(dir);
404          error = dir->i_op->create(dir, dentry, mode, nd);          error = dir->i_op->create(dir, dentry, mode, nd);
# Line 216  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 407  diff -ubBpEr linux-2.6.21/fs/namei.c lin
407                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
408                          return -EPERM;                          return -EPERM;
409    
410  +    /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
411  +       error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */  +       error = ccs_check_open_permission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */
412  +    if (error) return error;  +       if (error) return error;
413  +    /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
414  +  +
415          /*          /*
416           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
# Line 239  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 430  diff -ubBpEr linux-2.6.21/fs/namei.c lin
430          if (S_ISDIR(mode))          if (S_ISDIR(mode))
431                  return -EPERM;                  return -EPERM;
432  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
433  +       if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;  +       if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;
434  +       if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;  +       if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;
435  +       if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM;  +       if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO)) return -EPERM;
436  +       if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;  +       if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;
437  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
438          tmp = getname(filename);          tmp = getname(filename);
439          if (IS_ERR(tmp))          if (IS_ERR(tmp))
# Line 252  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 443  diff -ubBpEr linux-2.6.21/fs/namei.c lin
443                          break;                          break;
444                  case S_IFCHR: case S_IFBLK:                  case S_IFCHR: case S_IFBLK:
445  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
446  +                       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)  +                       if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = ccs_check_1path_perm(S_ISCHR(mode) ? TYPE_MKCHAR_ACL : TYPE_MKBLOCK_ACL, dentry, nd.mnt)) == 0)
447  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
448                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
449                                          new_decode_dev(dev));                                          new_decode_dev(dev));
450                          break;                          break;
451                  case S_IFIFO: case S_IFSOCK:                  case S_IFIFO: case S_IFSOCK:
452  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
453  +                       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)  +                       if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = ccs_check_1path_perm(S_ISFIFO(mode) ? TYPE_MKFIFO_ACL : TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)
454  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
455                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
456                          break;                          break;
457                  case S_IFDIR:                  case S_IFDIR:
# Line 269  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 460  diff -ubBpEr linux-2.6.21/fs/namei.c lin
460          if (!IS_POSIXACL(nd.dentry->d_inode))          if (!IS_POSIXACL(nd.dentry->d_inode))
461                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
462  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
463  +       if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)  +       if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)
464  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
465          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
466          dput(dentry);          dput(dentry);
# Line 279  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 470  diff -ubBpEr linux-2.6.21/fs/namei.c lin
470          if (IS_ERR(dentry))          if (IS_ERR(dentry))
471                  goto exit2;                  goto exit2;
472  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
473  +       if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)  +       if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)
474  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
475          error = vfs_rmdir(nd.dentry->d_inode, dentry);          error = vfs_rmdir(nd.dentry->d_inode, dentry);
476          dput(dentry);          dput(dentry);
# Line 289  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 480  diff -ubBpEr linux-2.6.21/fs/namei.c lin
480          struct nameidata nd;          struct nameidata nd;
481          struct inode *inode = NULL;          struct inode *inode = NULL;
482  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
483  +       if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_UNLINK)) return -EPERM;
484  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
485    
486          name = getname(pathname);          name = getname(pathname);
# Line 299  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 490  diff -ubBpEr linux-2.6.21/fs/namei.c lin
490                  if (inode)                  if (inode)
491                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
492  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
493  +               if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)  +               if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)
494  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
495                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
496          exit2:          exit2:
497                  dput(dentry);                  dput(dentry);
# Line 309  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 500  diff -ubBpEr linux-2.6.21/fs/namei.c lin
500          struct dentry *dentry;          struct dentry *dentry;
501          struct nameidata nd;          struct nameidata nd;
502  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
503  +       if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SYMLINK)) return -EPERM;
504  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
505    
506          from = getname(oldname);          from = getname(oldname);
# Line 319  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 510  diff -ubBpEr linux-2.6.21/fs/namei.c lin
510                  goto out_unlock;                  goto out_unlock;
511    
512  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
513  +       if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)  +       if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)
514  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
515          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
516          dput(dentry);          dput(dentry);
# Line 329  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 520  diff -ubBpEr linux-2.6.21/fs/namei.c lin
520          int error;          int error;
521          char * to;          char * to;
522  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
523  +       if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_LINK)) return -EPERM;
524  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
525    
526          if ((flags & ~AT_SYMLINK_FOLLOW) != 0)          if ((flags & ~AT_SYMLINK_FOLLOW) != 0)
# Line 339  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 530  diff -ubBpEr linux-2.6.21/fs/namei.c lin
530          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
531                  goto out_unlock;                  goto out_unlock;
532  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
533  +       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)  +       if ((error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry)) == 0 && (error = ccs_check_2path_perm(TYPE_LINK_ACL, old_nd.dentry, old_nd.mnt, new_dentry, nd.mnt)) == 0)
534  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
535          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
536          dput(new_dentry);          dput(new_dentry);
# Line 349  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 540  diff -ubBpEr linux-2.6.21/fs/namei.c lin
540          if (new_dentry == trap)          if (new_dentry == trap)
541                  goto exit5;                  goto exit5;
542  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
543  +       if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||  +       if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||
544  +               (error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {  +               (error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {
545  +               goto exit5;  +               goto exit5;
546  +       }  +       }
547  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
# Line 362  diff -ubBpEr linux-2.6.21/fs/namei.c lin Line 553  diff -ubBpEr linux-2.6.21/fs/namei.c lin
553          char * from;          char * from;
554          char * to;          char * to;
555  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
556  +       if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_RENAME)) return -EPERM;
557  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
558    
559          from = getname(oldname);          from = getname(oldname);
560          if(IS_ERR(from))          if(IS_ERR(from))
561  diff -ubBpEr linux-2.6.21/fs/namespace.c linux-2.6.21-ccs/fs/namespace.c  --- linux-2.6.21.orig/fs/namespace.c
562  --- linux-2.6.21/fs/namespace.c 2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/namespace.c
 +++ linux-2.6.21-ccs/fs/namespace.c     2007-04-28 04:02:47.000000000 +0900  
563  @@ -28,6 +28,12 @@  @@ -28,6 +28,12 @@
564   #include <asm/uaccess.h>   #include <asm/uaccess.h>
565   #include <asm/unistd.h>   #include <asm/unistd.h>
# Line 388  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 578  diff -ubBpEr linux-2.6.21/fs/namespace.c
578                  return retval;                  return retval;
579    
580  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
581  +       if (SAKURA_MayUmount(mnt) < 0) return -EPERM;  +       if (ccs_may_umount(mnt) < 0) return -EPERM;
582  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
583  +  +
584          /*          /*
# Line 399  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 589  diff -ubBpEr linux-2.6.21/fs/namespace.c
589          struct nameidata nd;          struct nameidata nd;
590          int retval;          int retval;
591  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
592  +       if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_UMOUNT)) return -EPERM;
593  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
594    
595          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
# Line 410  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 600  diff -ubBpEr linux-2.6.21/fs/namespace.c
600                  goto out;                  goto out;
601  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
602  +       err = -EPERM;  +       err = -EPERM;
603  +       if (SAKURA_MayMount(nd) < 0) goto out;  +       if (ccs_may_mount(nd) < 0) goto out;
604  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
605    
606          err = -ENOMEM;          err = -ENOMEM;
# Line 421  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 611  diff -ubBpEr linux-2.6.21/fs/namespace.c
611    
612  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
613  +       err = -EPERM;  +       err = -EPERM;
614  +       if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0) goto out;  +       if (ccs_may_umount(old_nd.mnt) < 0 || ccs_may_mount(nd) < 0) goto out;
615  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
616          err = -ENOENT;          err = -ENOENT;
617          mutex_lock(&nd->dentry->d_inode->i_mutex);          mutex_lock(&nd->dentry->d_inode->i_mutex);
# Line 432  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 622  diff -ubBpEr linux-2.6.21/fs/namespace.c
622                  goto unlock;                  goto unlock;
623  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
624  +       err = -EPERM;  +       err = -EPERM;
625  +       if (SAKURA_MayMount(nd) < 0) goto unlock;  +       if (ccs_may_mount(nd) < 0) goto unlock;
626  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
627    
628          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
# Line 442  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 632  diff -ubBpEr linux-2.6.21/fs/namespace.c
632                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                  ((char *)data_page)[PAGE_SIZE - 1] = 0;
633    
634  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
635  +       if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_MOUNT)) return -EPERM;
636  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
637  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
638  +       if (CheckMountPermission(dev_name, dir_name, type_page, &flags)) return -EPERM;  +       if ((retval = ccs_check_mount_permission(dev_name, dir_name, type_page, &flags)) < 0) return retval;
639  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
640  +  +
641          /* Separate the per-mountpoint flags */          /* Separate the per-mountpoint flags */
# Line 456  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 646  diff -ubBpEr linux-2.6.21/fs/namespace.c
646          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
647                  return -EPERM;                  return -EPERM;
648  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
649  +       if (CheckCapabilityACL(TOMOYO_SYS_PIVOT_ROOT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT)) return -EPERM;
650  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
651    
652          lock_kernel();          lock_kernel();
# Line 466  diff -ubBpEr linux-2.6.21/fs/namespace.c Line 656  diff -ubBpEr linux-2.6.21/fs/namespace.c
656    
657          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
658  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
659  +       if (!error) error = CheckPivotRootPermission(&old_nd, &new_nd);  +       if (!error) error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
660  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
661          if (error) {          if (error) {
662                  path_release(&old_nd);                  path_release(&old_nd);
663                  goto out1;                  goto out1;
664  diff -ubBpEr linux-2.6.21/fs/open.c linux-2.6.21-ccs/fs/open.c  --- linux-2.6.21.orig/fs/open.c
665  --- linux-2.6.21/fs/open.c      2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/open.c
 +++ linux-2.6.21-ccs/fs/open.c  2007-04-28 04:02:47.000000000 +0900  
666  @@ -27,6 +27,12 @@  @@ -27,6 +27,12 @@
667   #include <linux/syscalls.h>   #include <linux/syscalls.h>
668   #include <linux/rcupdate.h>   #include <linux/rcupdate.h>
# Line 492  diff -ubBpEr linux-2.6.21/fs/open.c linu Line 681  diff -ubBpEr linux-2.6.21/fs/open.c linu
681                  goto dput_and_out;                  goto dput_and_out;
682    
683  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
684  +       if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)  +       if ((error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)
685  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
686          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
687          if (!error) {          if (!error) {
# Line 502  diff -ubBpEr linux-2.6.21/fs/open.c linu Line 691  diff -ubBpEr linux-2.6.21/fs/open.c linu
691                  goto out_putf;                  goto out_putf;
692    
693  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
694  +       if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)  +       if ((error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)
695  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
696          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
697          if (!error)          if (!error)
# Line 512  diff -ubBpEr linux-2.6.21/fs/open.c linu Line 701  diff -ubBpEr linux-2.6.21/fs/open.c linu
701          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
702                  goto dput_and_out;                  goto dput_and_out;
703  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
704  +       if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) goto dput_and_out;  +       if (!ccs_capable(TOMOYO_SYS_CHROOT)) goto dput_and_out;
705  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
706  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
707  +       if (CheckChRootPermission(&nd)) goto dput_and_out;  +       if (ccs_check_chroot_permission(&nd)) goto dput_and_out;
708  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
709    
710          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
# Line 525  diff -ubBpEr linux-2.6.21/fs/open.c linu Line 714  diff -ubBpEr linux-2.6.21/fs/open.c linu
714   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
715   {   {
716  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
717  +       if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0)  +       if (!ccs_capable(TOMOYO_SYS_VHANGUP)) return -EPERM;
718  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
719          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
720                  /* XXX: this needs locking */                  /* XXX: this needs locking */
721                  tty_vhangup(current->signal->tty);                  tty_vhangup(current->signal->tty);
722  diff -ubBpEr linux-2.6.21/fs/proc/Makefile linux-2.6.21-ccs/fs/proc/Makefile  --- linux-2.6.21.orig/fs/proc/Makefile
723  --- linux-2.6.21/fs/proc/Makefile       2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/proc/Makefile
 +++ linux-2.6.21-ccs/fs/proc/Makefile   2007-04-28 04:02:47.000000000 +0900  
724  @@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE)     += kcore.o  @@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE)     += kcore.o
725   proc-$(CONFIG_PROC_VMCORE)     += vmcore.o   proc-$(CONFIG_PROC_VMCORE)     += vmcore.o
726   proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o   proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
# Line 540  diff -ubBpEr linux-2.6.21/fs/proc/Makefi Line 728  diff -ubBpEr linux-2.6.21/fs/proc/Makefi
728  +  +
729  +proc-$(CONFIG_SAKURA) += ccs_proc.o  +proc-$(CONFIG_SAKURA) += ccs_proc.o
730  +proc-$(CONFIG_TOMOYO) += ccs_proc.o  +proc-$(CONFIG_TOMOYO) += ccs_proc.o
731  diff -ubBpEr linux-2.6.21/fs/proc/proc_misc.c linux-2.6.21-ccs/fs/proc/proc_misc.c  --- linux-2.6.21.orig/fs/proc/proc_misc.c
732  --- linux-2.6.21/fs/proc/proc_misc.c    2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/fs/proc/proc_misc.c
733  +++ linux-2.6.21-ccs/fs/proc/proc_misc.c        2007-07-10 09:03:54.000000000 +0900  @@ -747,4 +747,9 @@ void __init proc_misc_init(void)
 @@ -747,4 +747,13 @@ void __init proc_misc_init(void)  
734                          entry->proc_fops = &proc_sysrq_trigger_operations;                          entry->proc_fops = &proc_sysrq_trigger_operations;
735          }          }
736   #endif   #endif
737  +       /***** CCS start. *****/  +       /***** CCS start. *****/
738  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
739  +       {  +       printk(KERN_INFO "Hook version: 2.6.21 2008/03/24\n");
 +               extern void __init CCSProc_Init(void);  
 +               CCSProc_Init();  
 +               printk("Hook version: 2.6.21 2007/08/14\n");  
 +       }  
740  +#endif  +#endif
741  +       /***** CCS end. *****/  +       /***** CCS end. *****/
742   }   }
743  diff -ubBpEr linux-2.6.21/include/linux/init_task.h linux-2.6.21-ccs/include/linux/init_task.h  --- linux-2.6.21.orig/include/linux/init_task.h
744  --- linux-2.6.21/include/linux/init_task.h      2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/include/linux/init_task.h
 +++ linux-2.6.21-ccs/include/linux/init_task.h  2007-04-28 04:02:47.000000000 +0900  
745  @@ -141,6 +141,10 @@ extern struct group_info init_groups;  @@ -141,6 +141,10 @@ extern struct group_info init_groups;
746          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \          .pi_lock        = SPIN_LOCK_UNLOCKED,                           \
747          INIT_TRACE_IRQFLAGS                                             \          INIT_TRACE_IRQFLAGS                                             \
# Line 571  diff -ubBpEr linux-2.6.21/include/linux/ Line 753  diff -ubBpEr linux-2.6.21/include/linux/
753   }   }
754    
755    
756  diff -ubBpEr linux-2.6.21/include/linux/sched.h linux-2.6.21-ccs/include/linux/sched.h  --- linux-2.6.21.orig/include/linux/sched.h
757  --- linux-2.6.21/include/linux/sched.h  2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/include/linux/sched.h
 +++ linux-2.6.21-ccs/include/linux/sched.h      2007-04-28 04:02:47.000000000 +0900  
758  @@ -27,6 +27,11 @@  @@ -27,6 +27,11 @@
759   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */   #define CLONE_NEWUTS           0x04000000      /* New utsname group? */
760   #define CLONE_NEWIPC           0x08000000      /* New ipcs */   #define CLONE_NEWIPC           0x08000000      /* New ipcs */
# Line 597  diff -ubBpEr linux-2.6.21/include/linux/ Line 778  diff -ubBpEr linux-2.6.21/include/linux/
778   };   };
779    
780   static inline pid_t process_group(struct task_struct *tsk)   static inline pid_t process_group(struct task_struct *tsk)
781  diff -ubBpEr linux-2.6.21/kernel/compat.c linux-2.6.21-ccs/kernel/compat.c  --- linux-2.6.21.orig/kernel/compat.c
782  --- linux-2.6.21/kernel/compat.c        2007-04-26 12:08:32.000000000 +0900  +++ linux-2.6.21/kernel/compat.c
 +++ linux-2.6.21-ccs/kernel/compat.c    2007-07-10 09:02:19.000000000 +0900  
783  @@ -25,6 +25,9 @@  @@ -25,6 +25,9 @@
784   #include <linux/posix-timers.h>   #include <linux/posix-timers.h>
785    
# Line 615  diff -ubBpEr linux-2.6.21/kernel/compat. Line 795  diff -ubBpEr linux-2.6.21/kernel/compat.
795          if (err)          if (err)
796                  return err;                  return err;
797  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
798  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;
799  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
800    
801          do_settimeofday(&tv);          do_settimeofday(&tv);
802          return 0;          return 0;
803  diff -ubBpEr linux-2.6.21/kernel/kexec.c linux-2.6.21-ccs/kernel/kexec.c  --- linux-2.6.21.orig/kernel/kexec.c
804  --- linux-2.6.21/kernel/kexec.c 2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/kexec.c
 +++ linux-2.6.21-ccs/kernel/kexec.c     2007-04-28 04:02:47.000000000 +0900  
805  @@ -28,6 +28,9 @@  @@ -28,6 +28,9 @@
806   #include <asm/io.h>   #include <asm/io.h>
807   #include <asm/system.h>   #include <asm/system.h>
# Line 638  diff -ubBpEr linux-2.6.21/kernel/kexec.c Line 817  diff -ubBpEr linux-2.6.21/kernel/kexec.c
817          if (!capable(CAP_SYS_BOOT))          if (!capable(CAP_SYS_BOOT))
818                  return -EPERM;                  return -EPERM;
819  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
820  +       if (CheckCapabilityACL(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM;
821  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
822    
823          /*          /*
824           * Verify we have a legal set of flags           * Verify we have a legal set of flags
825  diff -ubBpEr linux-2.6.21/kernel/kmod.c linux-2.6.21-ccs/kernel/kmod.c  --- linux-2.6.21.orig/kernel/kmod.c
826  --- linux-2.6.21/kernel/kmod.c  2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/kmod.c
 +++ linux-2.6.21-ccs/kernel/kmod.c      2007-05-16 14:30:01.000000000 +0900  
827  @@ -166,6 +166,11 @@ static int ____call_usermodehelper(void  @@ -166,6 +166,11 @@ static int ____call_usermodehelper(void
828          /* We can run anywhere, unlike our parent keventd(). */          /* We can run anywhere, unlike our parent keventd(). */
829          set_cpus_allowed(current, CPU_MASK_ALL);          set_cpus_allowed(current, CPU_MASK_ALL);
# Line 658  diff -ubBpEr linux-2.6.21/kernel/kmod.c Line 836  diff -ubBpEr linux-2.6.21/kernel/kmod.c
836          retval = -EPERM;          retval = -EPERM;
837          if (current->fs->root)          if (current->fs->root)
838                  retval = kernel_execve(sub_info->path,                  retval = kernel_execve(sub_info->path,
839  diff -ubBpEr linux-2.6.21/kernel/module.c linux-2.6.21-ccs/kernel/module.c  --- linux-2.6.21.orig/kernel/module.c
840  --- linux-2.6.21/kernel/module.c        2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/module.c
 +++ linux-2.6.21-ccs/kernel/module.c    2007-04-28 04:02:47.000000000 +0900  
841  @@ -44,6 +44,9 @@  @@ -44,6 +44,9 @@
842   #include <asm/semaphore.h>   #include <asm/semaphore.h>
843   #include <asm/cacheflush.h>   #include <asm/cacheflush.h>
# Line 676  diff -ubBpEr linux-2.6.21/kernel/module. Line 853  diff -ubBpEr linux-2.6.21/kernel/module.
853          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
854                  return -EPERM;                  return -EPERM;
855  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
856  +       if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
857  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
858    
859          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
# Line 686  diff -ubBpEr linux-2.6.21/kernel/module. Line 863  diff -ubBpEr linux-2.6.21/kernel/module.
863          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
864                  return -EPERM;                  return -EPERM;
865  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
866  +       if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
867  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
868    
869          /* Only one module load at a time, please */          /* Only one module load at a time, please */
870          if (mutex_lock_interruptible(&module_mutex) != 0)          if (mutex_lock_interruptible(&module_mutex) != 0)
871  diff -ubBpEr linux-2.6.21/kernel/sched.c linux-2.6.21-ccs/kernel/sched.c  --- linux-2.6.21.orig/kernel/ptrace.c
872  --- linux-2.6.21/kernel/sched.c 2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/ptrace.c
873  +++ linux-2.6.21-ccs/kernel/sched.c     2007-04-28 04:02:47.000000000 +0900  @@ -21,6 +21,9 @@
874    
875     #include <asm/pgtable.h>
876     #include <asm/uaccess.h>
877    +/***** TOMOYO Linux start. *****/
878    +#include <linux/tomoyo.h>
879    +/***** TOMOYO Linux end. *****/
880    
881     /*
882      * ptrace a task: make the debugger its new parent and
883    @@ -456,6 +459,11 @@ asmlinkage long sys_ptrace(long request,
884            /*
885             * This lock_kernel fixes a subtle race with suid exec
886             */
887    +       /***** TOMOYO Linux start. *****/
888    +#ifdef TOMOYO_SYS_PTRACE
889    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
890    +#endif
891    +       /***** TOMOYO Linux end. *****/
892            lock_kernel();
893            if (request == PTRACE_TRACEME) {
894                    ret = ptrace_traceme();
895    --- linux-2.6.21.orig/kernel/sched.c
896    +++ linux-2.6.21/kernel/sched.c
897  @@ -55,6 +55,9 @@  @@ -55,6 +55,9 @@
898   #include <asm/tlb.h>   #include <asm/tlb.h>
899    
# Line 709  diff -ubBpEr linux-2.6.21/kernel/sched.c Line 909  diff -ubBpEr linux-2.6.21/kernel/sched.c
909   {   {
910          long nice, retval;          long nice, retval;
911  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
912  +       if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_NICE)) return -EPERM;
913  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
914    
915          /*          /*
916           * Setpriority might change our priority at the same moment.           * Setpriority might change our priority at the same moment.
917  diff -ubBpEr linux-2.6.21/kernel/signal.c linux-2.6.21-ccs/kernel/signal.c  --- linux-2.6.21.orig/kernel/signal.c
918  --- linux-2.6.21/kernel/signal.c        2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/signal.c
 +++ linux-2.6.21-ccs/kernel/signal.c    2007-04-28 04:02:47.000000000 +0900  
919  @@ -32,6 +32,9 @@  @@ -32,6 +32,9 @@
920   #include <asm/unistd.h>   #include <asm/unistd.h>
921   #include <asm/siginfo.h>   #include <asm/siginfo.h>
# Line 732  diff -ubBpEr linux-2.6.21/kernel/signal. Line 931  diff -ubBpEr linux-2.6.21/kernel/signal.
931   {   {
932          struct siginfo info;          struct siginfo info;
933  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
934  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL)) return -EPERM;
935  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +       if (sig && ccs_check_signal_acl(sig, pid) < 0) return -EPERM;
936  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
937    
938          info.si_signo = sig;          info.si_signo = sig;
# Line 743  diff -ubBpEr linux-2.6.21/kernel/signal. Line 942  diff -ubBpEr linux-2.6.21/kernel/signal.
942          if (pid <= 0 || tgid <= 0)          if (pid <= 0 || tgid <= 0)
943                  return -EINVAL;                  return -EINVAL;
944  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
945  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL)) return -EPERM;
946  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +       if (sig && ccs_check_signal_acl(sig, pid) < 0) return -EPERM;
947  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
948    
949          return do_tkill(tgid, pid, sig);          return do_tkill(tgid, pid, sig);
# Line 754  diff -ubBpEr linux-2.6.21/kernel/signal. Line 953  diff -ubBpEr linux-2.6.21/kernel/signal.
953          if (pid <= 0)          if (pid <= 0)
954                  return -EINVAL;                  return -EINVAL;
955  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
956  +       if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL)) return -EPERM;
957  +       if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;  +       if (sig && ccs_check_signal_acl(sig, pid) < 0) return -EPERM;
958  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
959    
960          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
961   }   }
962  diff -ubBpEr linux-2.6.21/kernel/sys.c linux-2.6.21-ccs/kernel/sys.c  --- linux-2.6.21.orig/kernel/sys.c
963  --- linux-2.6.21/kernel/sys.c   2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/sys.c
 +++ linux-2.6.21-ccs/kernel/sys.c       2007-04-28 04:02:47.000000000 +0900  
964  @@ -37,6 +37,9 @@  @@ -37,6 +37,9 @@
965   #include <asm/uaccess.h>   #include <asm/uaccess.h>
966   #include <asm/io.h>   #include <asm/io.h>
# Line 778  diff -ubBpEr linux-2.6.21/kernel/sys.c l Line 976  diff -ubBpEr linux-2.6.21/kernel/sys.c l
976          if (which > 2 || which < 0)          if (which > 2 || which < 0)
977                  goto out;                  goto out;
978  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
979  +       if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_NICE)) return -EPERM;
980  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
981    
982          /* normalize: avoid signed division (rounding problems) */          /* normalize: avoid signed division (rounding problems) */
# Line 788  diff -ubBpEr linux-2.6.21/kernel/sys.c l Line 986  diff -ubBpEr linux-2.6.21/kernel/sys.c l
986                          magic2 != LINUX_REBOOT_MAGIC2C))                          magic2 != LINUX_REBOOT_MAGIC2C))
987                  return -EINVAL;                  return -EINVAL;
988  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
989  +       if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_REBOOT)) return -EPERM;
990  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
991    
992          /* Instead of trying to make the power_off code look like          /* Instead of trying to make the power_off code look like
# Line 798  diff -ubBpEr linux-2.6.21/kernel/sys.c l Line 996  diff -ubBpEr linux-2.6.21/kernel/sys.c l
996          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
997                  return -EINVAL;                  return -EINVAL;
998  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
999  +       if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
1000  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1001          down_write(&uts_sem);          down_write(&uts_sem);
1002          errno = -EFAULT;          errno = -EFAULT;
# Line 808  diff -ubBpEr linux-2.6.21/kernel/sys.c l Line 1006  diff -ubBpEr linux-2.6.21/kernel/sys.c l
1006          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
1007                  return -EINVAL;                  return -EINVAL;
1008  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1009  +       if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
1010  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1011    
1012          down_write(&uts_sem);          down_write(&uts_sem);
1013          errno = -EFAULT;          errno = -EFAULT;
1014  diff -ubBpEr linux-2.6.21/kernel/sysctl.c linux-2.6.21-ccs/kernel/sysctl.c  --- linux-2.6.21.orig/kernel/sysctl.c
1015  --- linux-2.6.21/kernel/sysctl.c        2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/sysctl.c
 +++ linux-2.6.21-ccs/kernel/sysctl.c    2007-04-28 04:02:47.000000000 +0900  
1016  @@ -48,6 +48,9 @@  @@ -48,6 +48,9 @@
1017    
1018   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 894  diff -ubBpEr linux-2.6.21/kernel/sysctl. Line 1091  diff -ubBpEr linux-2.6.21/kernel/sysctl.
1091  +                               goto repeat;  +                               goto repeat;
1092  +                       }  +                       }
1093  +                       /* printk("sysctl='%s'\n", buffer); */  +                       /* printk("sysctl='%s'\n", buffer); */
1094  +                       error = CheckFilePerm(buffer, op, "sysctl");  +                       error = ccs_check_file_perm(buffer, op, "sysctl");
1095  +                       goto out;  +                       goto out;
1096  +               }  +               }
1097  +       }  +       }
# Line 918  diff -ubBpEr linux-2.6.21/kernel/sysctl. Line 1115  diff -ubBpEr linux-2.6.21/kernel/sysctl.
1115                  error = parse_table(name, nlen, oldval, oldlenp,                  error = parse_table(name, nlen, oldval, oldlenp,
1116                                          newval, newlen, head->ctl_table);                                          newval, newlen, head->ctl_table);
1117                  if (error != -ENOTDIR) {                  if (error != -ENOTDIR) {
1118  diff -ubBpEr linux-2.6.21/kernel/time/ntp.c linux-2.6.21-ccs/kernel/time/ntp.c  --- linux-2.6.21.orig/kernel/time.c
1119  --- linux-2.6.21/kernel/time/ntp.c      2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/kernel/time.c
 +++ linux-2.6.21-ccs/kernel/time/ntp.c  2007-04-28 04:02:47.000000000 +0900  
 @@ -14,6 +14,9 @@  
   
  #include <asm/div64.h>  
  #include <asm/timex.h>  
 +/***** TOMOYO Linux start. *****/  
 +#include <linux/tomoyo.h>  
 +/***** TOMOYO Linux end. *****/  
   
  /*  
   * Timekeeping variables  
 @@ -203,6 +206,9 @@ int do_adjtimex(struct timex *txc)  
         /* In order to modify anything, you gotta be super-user! */  
         if (txc->modes && !capable(CAP_SYS_TIME))  
                 return -EPERM;  
 +       /***** TOMOYO Linux start. *****/  
 +       if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  
 +       /***** TOMOYO Linux end. *****/  
   
         /* Now we validate the data before disabling interrupts */  
   
 diff -ubBpEr linux-2.6.21/kernel/time.c linux-2.6.21-ccs/kernel/time.c  
 --- linux-2.6.21/kernel/time.c  2007-04-28 04:02:41.000000000 +0900  
 +++ linux-2.6.21-ccs/kernel/time.c      2007-04-28 04:02:47.000000000 +0900  
1120  @@ -39,6 +39,9 @@  @@ -39,6 +39,9 @@
1121    
1122   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 959  diff -ubBpEr linux-2.6.21/kernel/time.c Line 1132  diff -ubBpEr linux-2.6.21/kernel/time.c
1132          if (err)          if (err)
1133                  return err;                  return err;
1134  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1135  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;
1136  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1137    
1138          do_settimeofday(&tv);          do_settimeofday(&tv);
# Line 969  diff -ubBpEr linux-2.6.21/kernel/time.c Line 1142  diff -ubBpEr linux-2.6.21/kernel/time.c
1142          if (error)          if (error)
1143                  return error;                  return error;
1144  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1145  +       if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;
1146  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1147    
1148          if (tz) {          if (tz) {
1149                  /* SMP safe, global irq locking makes it work. */                  /* SMP safe, global irq locking makes it work. */
1150  diff -ubBpEr linux-2.6.21/net/core/datagram.c linux-2.6.21-ccs/net/core/datagram.c  --- linux-2.6.21.orig/kernel/time/ntp.c
1151  --- linux-2.6.21/net/core/datagram.c    2007-04-26 12:08:32.000000000 +0900  +++ linux-2.6.21/kernel/time/ntp.c
1152  +++ linux-2.6.21-ccs/net/core/datagram.c        2007-08-14 10:55:26.000000000 +0900  @@ -14,6 +14,9 @@
1153    
1154     #include <asm/div64.h>
1155     #include <asm/timex.h>
1156    +/***** TOMOYO Linux start. *****/
1157    +#include <linux/tomoyo.h>
1158    +/***** TOMOYO Linux end. *****/
1159    
1160     /*
1161      * Timekeeping variables
1162    @@ -203,6 +206,9 @@ int do_adjtimex(struct timex *txc)
1163            /* In order to modify anything, you gotta be super-user! */
1164            if (txc->modes && !capable(CAP_SYS_TIME))
1165                    return -EPERM;
1166    +       /***** TOMOYO Linux start. *****/
1167    +       if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;
1168    +       /***** TOMOYO Linux end. *****/
1169    
1170            /* Now we validate the data before disabling interrupts */
1171    
1172    --- linux-2.6.21.orig/net/core/datagram.c
1173    +++ linux-2.6.21/net/core/datagram.c
1174  @@ -56,6 +56,11 @@  @@ -56,6 +56,11 @@
1175   #include <net/sock.h>   #include <net/sock.h>
1176   #include <net/tcp_states.h>   #include <net/tcp_states.h>
# Line 989  diff -ubBpEr linux-2.6.21/net/core/datag Line 1183  diff -ubBpEr linux-2.6.21/net/core/datag
1183   /*   /*
1184    *     Is a socket 'connection oriented' ?    *     Is a socket 'connection oriented' ?
1185    */    */
1186  @@ -178,6 +183,14 @@ struct sk_buff *skb_recv_datagram(struct  @@ -178,6 +183,10 @@ struct sk_buff *skb_recv_datagram(struct
1187                  } else                  } else
1188                          skb = skb_dequeue(&sk->sk_receive_queue);                          skb = skb_dequeue(&sk->sk_receive_queue);
1189    
1190  +                /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1191  +                error = CheckSocketRecvDatagramPermission(sk, skb);  +               if ((error = ccs_socket_recv_datagram_permission(sk, skb, flags)) < 0) goto no_packet;
1192  +                if (error) {  +               /***** TOMOYO Linux end. *****/
 +                        skb_kill_datagram(sk, skb, flags);  
 +                        goto no_packet;  
 +                }  
 +                /***** TOMOYO Linux end. *****/  
1193  +  +
1194                  if (skb)                  if (skb)
1195                          return skb;                          return skb;
1196    
1197  diff -ubBpEr linux-2.6.21/net/ipv4/inet_connection_sock.c linux-2.6.21-ccs/net/ipv4/inet_connection_sock.c  --- linux-2.6.21.orig/net/ipv4/inet_connection_sock.c
1198  --- linux-2.6.21/net/ipv4/inet_connection_sock.c        2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/net/ipv4/inet_connection_sock.c
 +++ linux-2.6.21-ccs/net/ipv4/inet_connection_sock.c    2007-04-28 04:02:47.000000000 +0900  
1199  @@ -23,6 +23,9 @@  @@ -23,6 +23,9 @@
1200   #include <net/route.h>   #include <net/route.h>
1201   #include <net/tcp_states.h>   #include <net/tcp_states.h>
# Line 1022  diff -ubBpEr linux-2.6.21/net/ipv4/inet_ Line 1211  diff -ubBpEr linux-2.6.21/net/ipv4/inet_
1211                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1212                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1213  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1214  +                       if (SAKURA_MayAutobind(rover) < 0) goto next;  +                       if (ccs_may_autobind(rover) < 0) goto next;
1215  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1216                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
1217                                  if (tb->port == rover)                                  if (tb->port == rover)
1218                                          goto next;                                          goto next;
1219  diff -ubBpEr linux-2.6.21/net/ipv4/inet_hashtables.c linux-2.6.21-ccs/net/ipv4/inet_hashtables.c  --- linux-2.6.21.orig/net/ipv4/inet_hashtables.c
1220  --- linux-2.6.21/net/ipv4/inet_hashtables.c     2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/net/ipv4/inet_hashtables.c
 +++ linux-2.6.21-ccs/net/ipv4/inet_hashtables.c 2007-04-28 04:02:47.000000000 +0900  
1221  @@ -22,6 +22,9 @@  @@ -22,6 +22,9 @@
1222   #include <net/inet_connection_sock.h>   #include <net/inet_connection_sock.h>
1223   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
# Line 1045  diff -ubBpEr linux-2.6.21/net/ipv4/inet_ Line 1233  diff -ubBpEr linux-2.6.21/net/ipv4/inet_
1233                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1234                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1235  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1236  +                       if (SAKURA_MayAutobind(port) < 0) continue;  +                       if (ccs_may_autobind(port) < 0) continue;
1237  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1238                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1239                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1240    
1241  diff -ubBpEr linux-2.6.21/net/ipv4/udp.c linux-2.6.21-ccs/net/ipv4/udp.c  --- linux-2.6.21.orig/net/ipv4/udp.c
1242  --- linux-2.6.21/net/ipv4/udp.c 2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/net/ipv4/udp.c
 +++ linux-2.6.21-ccs/net/ipv4/udp.c     2007-05-23 14:50:12.000000000 +0900  
1243  @@ -102,6 +102,9 @@  @@ -102,6 +102,9 @@
1244   #include <net/checksum.h>   #include <net/checksum.h>
1245   #include <net/xfrm.h>   #include <net/xfrm.h>
# Line 1068  diff -ubBpEr linux-2.6.21/net/ipv4/udp.c Line 1255  diff -ubBpEr linux-2.6.21/net/ipv4/udp.c
1255                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1256                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
1257  +                               /***** SAKURA Linux start. *****/  +                               /***** SAKURA Linux start. *****/
1258  +                               if (SAKURA_MayAutobind(result) < 0) continue;  +                               if (ccs_may_autobind(result) < 0) continue;
1259  +                               /***** SAKURA Linux end. *****/  +                               /***** SAKURA Linux end. *****/
1260                                  goto gotit;                                  goto gotit;
1261                          }                          }
# Line 1078  diff -ubBpEr linux-2.6.21/net/ipv4/udp.c Line 1265  diff -ubBpEr linux-2.6.21/net/ipv4/udp.c
1265                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1266                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
1267  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1268  +                       if (SAKURA_MayAutobind(result) < 0) continue;  +                       if (ccs_may_autobind(result) < 0) continue;
1269  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1270                          if (! __udp_lib_lport_inuse(result, udptable))                          if (! __udp_lib_lport_inuse(result, udptable))
1271                                  break;                                  break;
1272                  }                  }
1273  diff -ubBpEr linux-2.6.21/net/ipv6/inet6_hashtables.c linux-2.6.21-ccs/net/ipv6/inet6_hashtables.c  --- linux-2.6.21.orig/net/ipv6/inet6_hashtables.c
1274  --- linux-2.6.21/net/ipv6/inet6_hashtables.c    2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/net/ipv6/inet6_hashtables.c
 +++ linux-2.6.21-ccs/net/ipv6/inet6_hashtables.c        2007-04-28 04:02:47.000000000 +0900  
1275  @@ -21,6 +21,9 @@  @@ -21,6 +21,9 @@
1276   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
1277   #include <net/inet6_hashtables.h>   #include <net/inet6_hashtables.h>
# Line 1101  diff -ubBpEr linux-2.6.21/net/ipv6/inet6 Line 1287  diff -ubBpEr linux-2.6.21/net/ipv6/inet6
1287                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1288                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1289  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1290  +                       if (SAKURA_MayAutobind(port) < 0) continue;  +                       if (ccs_may_autobind(port) < 0) continue;
1291  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1292                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1293                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1294    
1295  diff -ubBpEr linux-2.6.21/net/socket.c linux-2.6.21-ccs/net/socket.c  --- linux-2.6.21.orig/net/socket.c
1296  --- linux-2.6.21/net/socket.c   2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/net/socket.c
 +++ linux-2.6.21-ccs/net/socket.c       2007-08-14 10:46:32.000000000 +0900  
1297  @@ -93,6 +93,11 @@  @@ -93,6 +93,11 @@
1298   #include <net/sock.h>   #include <net/sock.h>
1299   #include <linux/netfilter.h>   #include <linux/netfilter.h>
# Line 1126  diff -ubBpEr linux-2.6.21/net/socket.c l Line 1311  diff -ubBpEr linux-2.6.21/net/socket.c l
1311          if (err)          if (err)
1312                  return err;                  return err;
1313  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1314  +       if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;  +       if (ccs_socket_sendmsg_permission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;
1315  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux end. *****/
1316    
1317          return sock->ops->sendmsg(iocb, sock, msg, size);          return sock->ops->sendmsg(iocb, sock, msg, size);
1318   }   }
# Line 1136  diff -ubBpEr linux-2.6.21/net/socket.c l Line 1321  diff -ubBpEr linux-2.6.21/net/socket.c l
1321          }          }
1322    
1323  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1324  +       if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err;  +       if ((err = ccs_socket_create_permission(family, type, protocol)) < 0) return err;
1325  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1326  +  +
1327          err = security_socket_create(family, type, protocol, kern);          err = security_socket_create(family, type, protocol, kern);
# Line 1147  diff -ubBpEr linux-2.6.21/net/socket.c l Line 1332  diff -ubBpEr linux-2.6.21/net/socket.c l
1332                                                     (struct sockaddr *)address,                                                     (struct sockaddr *)address,
1333                                                     addrlen);                                                     addrlen);
1334  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
1335  +                       if (!err) err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen);  +                       if (!err) err = ccs_socket_bind_permission(sock, (struct sockaddr *) address, addrlen);
1336  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
1337                          if (!err)                          if (!err)
1338                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
# Line 1157  diff -ubBpEr linux-2.6.21/net/socket.c l Line 1342  diff -ubBpEr linux-2.6.21/net/socket.c l
1342    
1343                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
1344  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1345  +               if (!err) err = CheckSocketListenPermission(sock);  +               if (!err) err = ccs_socket_listen_permission(sock);
1346  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1347                  if (!err)                  if (!err)
1348                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
# Line 1167  diff -ubBpEr linux-2.6.21/net/socket.c l Line 1352  diff -ubBpEr linux-2.6.21/net/socket.c l
1352                  goto out_fd;                  goto out_fd;
1353    
1354  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1355  +       if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) {  +       if (ccs_socket_accept_permission(newsock, (struct sockaddr *) address)) {
1356  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1357  +               goto out_fd;  +               goto out_fd;
1358  +       }  +       }
# Line 1180  diff -ubBpEr linux-2.6.21/net/socket.c l Line 1365  diff -ubBpEr linux-2.6.21/net/socket.c l
1365          if (err)          if (err)
1366                  goto out_put;                  goto out_put;
1367  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1368  +       err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen);  +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, addrlen);
1369  +       if (err) goto out_put;  +       if (err) goto out_put;
1370  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1371    
1372          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
1373                                   sock->file->f_flags);                                   sock->file->f_flags);
1374  diff -ubBpEr linux-2.6.21/net/unix/af_unix.c linux-2.6.21-ccs/net/unix/af_unix.c  --- linux-2.6.21.orig/net/unix/af_unix.c
1375  --- linux-2.6.21/net/unix/af_unix.c     2007-04-28 04:02:41.000000000 +0900  +++ linux-2.6.21/net/unix/af_unix.c
 +++ linux-2.6.21-ccs/net/unix/af_unix.c 2007-04-28 04:02:47.000000000 +0900  
1376  @@ -116,6 +116,9 @@  @@ -116,6 +116,9 @@
1377   #include <linux/mount.h>   #include <linux/mount.h>
1378   #include <net/checksum.h>   #include <net/checksum.h>
# Line 1205  diff -ubBpEr linux-2.6.21/net/unix/af_un Line 1389  diff -ubBpEr linux-2.6.21/net/unix/af_un
1389          }          }
1390  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1391  +       err = -EPERM;  +       err = -EPERM;
1392  +       if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out;  +       if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) goto out;
1393  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1394    
1395          err = unix_mkname(sunaddr, addr_len, &hash);          err = unix_mkname(sunaddr, addr_len, &hash);
# Line 1215  diff -ubBpEr linux-2.6.21/net/unix/af_un Line 1399  diff -ubBpEr linux-2.6.21/net/unix/af_un
1399                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1400                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1401  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1402  +               if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)  +               if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)
1403  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1404                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1405                  if (err)                  if (err)
1406                          goto out_mknod_dput;                          goto out_mknod_dput;
1407    --- linux-2.6.21.orig/arch/powerpc/kernel/ptrace32.c
1408    +++ linux-2.6.21/arch/powerpc/kernel/ptrace32.c
1409    @@ -32,6 +32,9 @@
1410     #include <asm/page.h>
1411     #include <asm/pgtable.h>
1412     #include <asm/system.h>
1413    +/***** TOMOYO Linux start. *****/
1414    +#include <linux/tomoyo.h>
1415    +/***** TOMOYO Linux end. *****/
1416    
1417     #include "ptrace-common.h"
1418    
1419    @@ -45,6 +48,11 @@ long compat_sys_ptrace(int request, int
1420     {
1421            struct task_struct *child;
1422            int ret;
1423    +       /***** TOMOYO Linux start. *****/
1424    +#ifdef TOMOYO_SYS_PTRACE
1425    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
1426    +#endif
1427    +       /***** TOMOYO Linux end. *****/
1428    
1429            lock_kernel();
1430            if (request == PTRACE_TRACEME) {
1431    --- linux-2.6.21.orig/arch/sh64/kernel/ptrace.c
1432    +++ linux-2.6.21/arch/sh64/kernel/ptrace.c
1433    @@ -35,6 +35,9 @@
1434     #include <asm/system.h>
1435     #include <asm/processor.h>
1436     #include <asm/mmu_context.h>
1437    +/***** TOMOYO Linux start. *****/
1438    +#include <linux/tomoyo.h>
1439    +/***** TOMOYO Linux end. *****/
1440    
1441     /* This mask defines the bits of the SR which the user is not allowed to
1442        change, which are everything except S, Q, M, PR, SZ, FR. */
1443    @@ -271,6 +274,11 @@ asmlinkage int sh64_ptrace(long request,
1444            extern void poke_real_address_q(unsigned long long addr, unsigned long long data);
1445     #define WPC_DBRMODE 0x0d104008
1446            static int first_call = 1;
1447    +       /***** TOMOYO Linux start. *****/
1448    +#ifdef TOMOYO_SYS_PTRACE
1449    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
1450    +#endif
1451    +       /***** TOMOYO Linux end. *****/
1452    
1453            lock_kernel();
1454            if (first_call) {
1455    --- linux-2.6.21.orig/arch/x86_64/ia32/ptrace32.c
1456    +++ linux-2.6.21/arch/x86_64/ia32/ptrace32.c
1457    @@ -26,6 +26,9 @@
1458     #include <asm/i387.h>
1459     #include <asm/fpu32.h>
1460     #include <asm/ia32.h>
1461    +/***** TOMOYO Linux start. *****/
1462    +#include <linux/tomoyo.h>
1463    +/***** TOMOYO Linux end. *****/
1464    
1465     /*
1466      * Determines which flags the user has access to [1 = access, 0 = no access].
1467    @@ -234,6 +237,11 @@ asmlinkage long sys32_ptrace(long reques
1468            void __user *datap = compat_ptr(data);
1469            int ret;
1470            __u32 val;
1471    +       /***** TOMOYO Linux start. *****/
1472    +#ifdef TOMOYO_SYS_PTRACE
1473    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
1474    +#endif
1475    +       /***** TOMOYO Linux end. *****/
1476    
1477            switch (request) {
1478            case PTRACE_TRACEME:
1479    --- linux-2.6.21.orig/arch/ia64/ia32/sys_ia32.c
1480    +++ linux-2.6.21/arch/ia64/ia32/sys_ia32.c
1481    @@ -56,6 +56,9 @@
1482     #include <asm/types.h>
1483     #include <asm/uaccess.h>
1484     #include <asm/unistd.h>
1485    +/***** TOMOYO Linux start. *****/
1486    +#include <linux/tomoyo.h>
1487    +/***** TOMOYO Linux end. *****/
1488    
1489     #include "ia32priv.h"
1490    
1491    @@ -1758,6 +1761,11 @@ sys32_ptrace (int request, pid_t pid, un
1492            struct task_struct *child;
1493            unsigned int value, tmp;
1494            long i, ret;
1495    +       /***** TOMOYO Linux start. *****/
1496    +#ifdef TOMOYO_SYS_PTRACE
1497    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
1498    +#endif
1499    +       /***** TOMOYO Linux end. *****/
1500    
1501            lock_kernel();
1502            if (request == PTRACE_TRACEME) {
1503    --- linux-2.6.21.orig/arch/mips/kernel/ptrace32.c
1504    +++ linux-2.6.21/arch/mips/kernel/ptrace32.c
1505    @@ -35,6 +35,9 @@
1506     #include <asm/system.h>
1507     #include <asm/uaccess.h>
1508     #include <asm/bootinfo.h>
1509    +/***** TOMOYO Linux start. *****/
1510    +#include <linux/tomoyo.h>
1511    +/***** TOMOYO Linux end. *****/
1512    
1513     int ptrace_getregs (struct task_struct *child, __s64 __user *data);
1514     int ptrace_setregs (struct task_struct *child, __s64 __user *data);
1515    @@ -50,6 +53,11 @@ asmlinkage int sys32_ptrace(int request,
1516     {
1517            struct task_struct *child;
1518            int ret;
1519    +       /***** TOMOYO Linux start. *****/
1520    +#ifdef TOMOYO_SYS_PTRACE
1521    +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;
1522    +#endif
1523    +       /***** TOMOYO Linux end. *****/
1524    
1525     #if 0
1526            printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",

Legend:
Removed from v.352  
changed lines
  Added in v.1055

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