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

Subversion リポジトリの参照

Annotation of /trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.21.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 998 - (hide annotations) (download) (as text)
Tue Feb 19 08:39:58 2008 UTC (16 years, 3 months ago) by kumaneko
File MIME type: text/x-diff
File size: 49289 byte(s)


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

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