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

Subversion リポジトリの参照

Annotation of /branches/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2090 - (hide annotations) (download) (as text)
Thu Jan 29 09:33:00 2009 UTC (15 years, 4 months ago) by kumaneko
Original Path: trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff
File MIME type: text/x-diff
File size: 50475 byte(s)


1 kumaneko 1498 This is TOMOYO Linux patch for Ubuntu 6.06.
2    
3     Source code for this patch is "apt-get install linux-source-2.6.15"
4     ---
5     arch/alpha/kernel/ptrace.c | 9 +++
6     arch/ia64/ia32/sys_ia32.c | 9 +++
7     arch/ia64/kernel/ptrace.c | 9 +++
8     arch/m32r/kernel/ptrace.c | 9 +++
9     arch/mips/kernel/ptrace32.c | 9 +++
10     arch/powerpc/kernel/ptrace32.c | 9 +++
11     arch/s390/kernel/ptrace.c | 9 +++
12     arch/sparc/kernel/ptrace.c | 11 +++
13     arch/sparc64/kernel/ptrace.c | 11 +++
14     arch/x86_64/ia32/ptrace32.c | 9 +++
15     fs/Kconfig | 2
16     fs/Makefile | 2
17     fs/attr.c | 19 ++++++
18     fs/compat.c | 11 +++
19     fs/exec.c | 21 ++++++-
20     fs/fcntl.c | 8 ++
21     fs/ioctl.c | 7 ++
22     fs/namei.c | 118 ++++++++++++++++++++++++++++++++++++++++
23     fs/namespace.c | 50 ++++++++++++++++
24     fs/open.c | 29 +++++++++
25     fs/proc/Makefile | 3 +
26     fs/proc/proc_misc.c | 5 +
27     include/linux/init_task.h | 4 +
28     include/linux/sched.h | 9 +++
29     kernel/compat.c | 7 ++
30     kernel/kexec.c | 7 ++
31     kernel/kmod.c | 5 +
32     kernel/module.c | 13 +++-
33     kernel/ptrace.c | 9 +++
34     kernel/sched.c | 7 ++
35     kernel/signal.c | 21 +++++++
36     kernel/sys.c | 21 +++++++
37     kernel/sysctl.c | 111 +++++++++++++++++++++++++++++++++++++
38     kernel/time.c | 15 +++++
39     net/core/datagram.c | 11 +++
40     net/ipv4/inet_connection_sock.c | 7 ++
41     net/ipv4/tcp_ipv4.c | 7 ++
42     net/ipv4/udp.c | 11 +++
43     net/ipv6/tcp_ipv6.c | 11 +++
44     net/ipv6/udp.c | 11 +++
45     net/socket.c | 43 +++++++++++++-
46     net/unix/af_unix.c | 15 +++++
47 kumaneko 1766 42 files changed, 705 insertions(+), 9 deletions(-)
48 kumaneko 1498
49 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/alpha/kernel/ptrace.c
50     +++ linux-2.6.15-53.75/arch/alpha/kernel/ptrace.c
51 kumaneko 1498 @@ -20,6 +20,9 @@
52     #include <asm/pgtable.h>
53     #include <asm/system.h>
54     #include <asm/fpu.h>
55     +/***** TOMOYO Linux start. *****/
56     +#include <linux/tomoyo.h>
57     +/***** TOMOYO Linux end. *****/
58    
59     #include "proto.h"
60    
61     @@ -261,6 +264,12 @@ do_sys_ptrace(long request, long pid, lo
62     unsigned long tmp;
63     size_t copied;
64     long ret;
65     + /***** TOMOYO Linux start. *****/
66     +#ifdef TOMOYO_SYS_PTRACE
67     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
68     + return -EPERM;
69     +#endif
70     + /***** TOMOYO Linux end. *****/
71    
72     lock_kernel();
73     DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
74 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/ia64/ia32/sys_ia32.c
75     +++ linux-2.6.15-53.75/arch/ia64/ia32/sys_ia32.c
76 kumaneko 1498 @@ -57,6 +57,9 @@
77     #include <asm/types.h>
78     #include <asm/uaccess.h>
79     #include <asm/unistd.h>
80     +/***** TOMOYO Linux start. *****/
81     +#include <linux/tomoyo.h>
82     +/***** TOMOYO Linux end. *****/
83    
84     #include "ia32priv.h"
85    
86     @@ -1758,6 +1761,12 @@ sys32_ptrace (int request, pid_t pid, un
87     struct task_struct *child;
88     unsigned int value, tmp;
89     long i, ret;
90     + /***** TOMOYO Linux start. *****/
91     +#ifdef TOMOYO_SYS_PTRACE
92     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
93     + return -EPERM;
94     +#endif
95     + /***** TOMOYO Linux end. *****/
96    
97     lock_kernel();
98     if (request == PTRACE_TRACEME) {
99 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/ia64/kernel/ptrace.c
100     +++ linux-2.6.15-53.75/arch/ia64/kernel/ptrace.c
101 kumaneko 1498 @@ -29,6 +29,9 @@
102     #ifdef CONFIG_PERFMON
103     #include <asm/perfmon.h>
104     #endif
105     +/***** TOMOYO Linux start. *****/
106     +#include <linux/tomoyo.h>
107     +/***** TOMOYO Linux end. *****/
108    
109     #include "entry.h"
110    
111     @@ -1418,6 +1421,12 @@ sys_ptrace (long request, pid_t pid, uns
112     struct task_struct *child;
113     struct switch_stack *sw;
114     long ret;
115     + /***** TOMOYO Linux start. *****/
116     +#ifdef TOMOYO_SYS_PTRACE
117     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
118     + return -EPERM;
119     +#endif
120     + /***** TOMOYO Linux end. *****/
121    
122     lock_kernel();
123     ret = -EPERM;
124 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/m32r/kernel/ptrace.c
125     +++ linux-2.6.15-53.75/arch/m32r/kernel/ptrace.c
126 kumaneko 1498 @@ -33,6 +33,9 @@
127     #include <asm/system.h>
128     #include <asm/processor.h>
129     #include <asm/mmu_context.h>
130     +/***** TOMOYO Linux start. *****/
131     +#include <linux/tomoyo.h>
132     +/***** TOMOYO Linux end. *****/
133    
134     /*
135     * Get the address of the live pt_regs for the specified task.
136     @@ -760,6 +763,12 @@ asmlinkage long sys_ptrace(long request,
137     {
138     struct task_struct *child;
139     int ret;
140     + /***** TOMOYO Linux start. *****/
141     +#ifdef TOMOYO_SYS_PTRACE
142     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
143     + return -EPERM;
144     +#endif
145     + /***** TOMOYO Linux end. *****/
146    
147     lock_kernel();
148     ret = -EPERM;
149 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/mips/kernel/ptrace32.c
150     +++ linux-2.6.15-53.75/arch/mips/kernel/ptrace32.c
151 kumaneko 1498 @@ -35,6 +35,9 @@
152     #include <asm/system.h>
153     #include <asm/uaccess.h>
154     #include <asm/bootinfo.h>
155     +/***** TOMOYO Linux start. *****/
156     +#include <linux/tomoyo.h>
157     +/***** TOMOYO Linux end. *****/
158    
159     int ptrace_getregs (struct task_struct *child, __s64 __user *data);
160     int ptrace_setregs (struct task_struct *child, __s64 __user *data);
161     @@ -50,6 +53,12 @@ asmlinkage int sys32_ptrace(int request,
162     {
163     struct task_struct *child;
164     int ret;
165     + /***** TOMOYO Linux start. *****/
166     +#ifdef TOMOYO_SYS_PTRACE
167     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
168     + return -EPERM;
169     +#endif
170     + /***** TOMOYO Linux end. *****/
171    
172     #if 0
173     printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
174 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/powerpc/kernel/ptrace32.c
175     +++ linux-2.6.15-53.75/arch/powerpc/kernel/ptrace32.c
176 kumaneko 1498 @@ -33,6 +33,9 @@
177     #include <asm/page.h>
178     #include <asm/pgtable.h>
179     #include <asm/system.h>
180     +/***** TOMOYO Linux start. *****/
181     +#include <linux/tomoyo.h>
182     +/***** TOMOYO Linux end. *****/
183    
184     #include "ptrace-common.h"
185    
186     @@ -46,6 +49,12 @@ long compat_sys_ptrace(int request, int
187     {
188     struct task_struct *child;
189     int ret = -EPERM;
190     + /***** TOMOYO Linux start. *****/
191     +#ifdef TOMOYO_SYS_PTRACE
192     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
193     + return -EPERM;
194     +#endif
195     + /***** TOMOYO Linux end. *****/
196    
197     lock_kernel();
198     if (request == PTRACE_TRACEME) {
199 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/s390/kernel/ptrace.c
200     +++ linux-2.6.15-53.75/arch/s390/kernel/ptrace.c
201 kumaneko 1498 @@ -41,6 +41,9 @@
202     #include <asm/system.h>
203     #include <asm/uaccess.h>
204     #include <asm/unistd.h>
205     +/***** TOMOYO Linux start. *****/
206     +#include <linux/tomoyo.h>
207     +/***** TOMOYO Linux end. *****/
208    
209     #ifdef CONFIG_S390_SUPPORT
210     #include "compat_ptrace.h"
211     @@ -711,6 +714,12 @@ sys_ptrace(long request, long pid, long
212     struct task_struct *child;
213     int ret;
214    
215     + /***** TOMOYO Linux start. *****/
216     +#ifdef TOMOYO_SYS_PTRACE
217     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
218     + return -EPERM;
219     +#endif
220     + /***** TOMOYO Linux end. *****/
221     lock_kernel();
222    
223     if (request == PTRACE_TRACEME) {
224 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/sparc/kernel/ptrace.c
225     +++ linux-2.6.15-53.75/arch/sparc/kernel/ptrace.c
226 kumaneko 1498 @@ -23,6 +23,9 @@
227     #include <asm/pgtable.h>
228     #include <asm/system.h>
229     #include <asm/uaccess.h>
230     +/***** TOMOYO Linux start. *****/
231     +#include <linux/tomoyo.h>
232     +/***** TOMOYO Linux end. *****/
233    
234     #define MAGIC_CONSTANT 0x80000000
235    
236     @@ -267,6 +270,14 @@ asmlinkage void do_ptrace(struct pt_regs
237     unsigned long addr2 = regs->u_regs[UREG_I4];
238     struct task_struct *child;
239     int ret;
240     + /***** TOMOYO Linux start. *****/
241     +#ifdef TOMOYO_SYS_PTRACE
242     + if (!ccs_capable(TOMOYO_SYS_PTRACE)) {
243     + pt_error_return(regs, EPERM);
244     + return;
245     + }
246     +#endif
247     + /***** TOMOYO Linux end. *****/
248    
249     lock_kernel();
250     #ifdef DEBUG_PTRACE
251 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/sparc64/kernel/ptrace.c
252     +++ linux-2.6.15-53.75/arch/sparc64/kernel/ptrace.c
253 kumaneko 1498 @@ -32,6 +32,9 @@
254     #include <asm/spitfire.h>
255     #include <asm/page.h>
256     #include <asm/cpudata.h>
257     +/***** TOMOYO Linux start. *****/
258     +#include <linux/tomoyo.h>
259     +/***** TOMOYO Linux end. *****/
260    
261     /* Returning from ptrace is a bit tricky because the syscall return
262     * low level code assumes any value returned which is negative and
263     @@ -176,6 +179,14 @@ asmlinkage void do_ptrace(struct pt_regs
264     unsigned long addr2 = regs->u_regs[UREG_I4];
265     struct task_struct *child;
266     int ret;
267     + /***** TOMOYO Linux start. *****/
268     +#ifdef TOMOYO_SYS_PTRACE
269     + if (!ccs_capable(TOMOYO_SYS_PTRACE)) {
270     + pt_error_return(regs, EPERM);
271     + return;
272     + }
273     +#endif
274     + /***** TOMOYO Linux end. *****/
275    
276     if (test_thread_flag(TIF_32BIT)) {
277     addr &= 0xffffffffUL;
278 kumaneko 2090 --- linux-2.6.15-53.75.orig/arch/x86_64/ia32/ptrace32.c
279     +++ linux-2.6.15-53.75/arch/x86_64/ia32/ptrace32.c
280 kumaneko 1498 @@ -27,6 +27,9 @@
281     #include <asm/debugreg.h>
282     #include <asm/i387.h>
283     #include <asm/fpu32.h>
284     +/***** TOMOYO Linux start. *****/
285     +#include <linux/tomoyo.h>
286     +/***** TOMOYO Linux end. *****/
287    
288     /* determines which flags the user has access to. */
289     /* 1 = access 0 = no access */
290     @@ -233,6 +236,12 @@ asmlinkage long sys32_ptrace(long reques
291     void __user *datap = compat_ptr(data);
292     int ret;
293     __u32 val;
294     + /***** TOMOYO Linux start. *****/
295     +#ifdef TOMOYO_SYS_PTRACE
296     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
297     + return -EPERM;
298     +#endif
299     + /***** TOMOYO Linux end. *****/
300    
301     switch (request) {
302     default:
303 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/Kconfig
304     +++ linux-2.6.15-53.75/fs/Kconfig
305 kumaneko 1498 @@ -1910,5 +1910,7 @@ endmenu
306    
307     source "fs/nls/Kconfig"
308    
309     +source "fs/Kconfig.ccs"
310     +
311     endmenu
312    
313 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/Makefile
314     +++ linux-2.6.15-53.75/fs/Makefile
315 kumaneko 1498 @@ -108,3 +108,5 @@ obj-$(CONFIG_CONFIGFS_FS) += configfs/
316     obj-$(CONFIG_OCFS2_FS) += ocfs2/
317     obj-$(CONFIG_UNION_FS) += unionfs/
318     obj-$(CONFIG_DAZUKO) += dazuko/
319     +
320     +include $(srctree)/fs/Makefile-2.6.ccs
321 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/attr.c
322     +++ linux-2.6.15-53.75/fs/attr.c
323 kumaneko 1498 @@ -15,6 +15,9 @@
324     #include <linux/quotaops.h>
325     #include <linux/security.h>
326     #include <linux/time.h>
327     +/***** TOMOYO Linux start. *****/
328     +#include <linux/tomoyo.h>
329     +/***** TOMOYO Linux end. *****/
330    
331     /* Taken over from the old code... */
332    
333     @@ -153,12 +156,28 @@ int notify_change(struct dentry * dentry
334    
335     if (inode->i_op && inode->i_op->setattr) {
336     error = security_inode_setattr(dentry, attr);
337     + /***** TOMOYO Linux start. *****/
338     + if (!error && (ia_valid & ATTR_MODE) &&
339     + !ccs_capable(TOMOYO_SYS_CHMOD))
340     + error = -EPERM;
341     + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
342     + !ccs_capable(TOMOYO_SYS_CHOWN))
343     + error = -EPERM;
344     + /***** TOMOYO Linux end. *****/
345     if (!error)
346     error = inode->i_op->setattr(dentry, attr);
347     } else {
348     error = inode_change_ok(inode, attr);
349     if (!error)
350     error = security_inode_setattr(dentry, attr);
351     + /***** TOMOYO Linux start. *****/
352     + if (!error && (ia_valid & ATTR_MODE) &&
353     + !ccs_capable(TOMOYO_SYS_CHMOD))
354     + error = -EPERM;
355     + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
356     + !ccs_capable(TOMOYO_SYS_CHOWN))
357     + error = -EPERM;
358     + /***** TOMOYO Linux end. *****/
359     if (!error) {
360     if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
361     (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
362 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/compat.c
363     +++ linux-2.6.15-53.75/fs/compat.c
364 kumaneko 1498 @@ -52,6 +52,9 @@
365     #include <asm/uaccess.h>
366     #include <asm/mmu_context.h>
367     #include <asm/ioctls.h>
368     +/***** TOMOYO Linux start. *****/
369     +#include <linux/tomoyo.h>
370     +/***** TOMOYO Linux end. *****/
371    
372     /*
373     * Not all architectures have sys_utime, so implement this in terms
374     @@ -377,6 +380,12 @@ asmlinkage long compat_sys_ioctl(unsigne
375     /*FALL THROUGH*/
376    
377     default:
378     + /***** TOMOYO Linux start. *****/
379     + if (!ccs_capable(TOMOYO_SYS_IOCTL)) {
380     + error = -EPERM;
381     + goto out_fput;
382     + }
383     + /***** TOMOYO Linux end. *****/
384     if (filp->f_op && filp->f_op->compat_ioctl) {
385     error = filp->f_op->compat_ioctl(filp, cmd, arg);
386     if (error != -ENOIOCTLCMD)
387     @@ -1480,7 +1489,7 @@ int compat_do_execve(char * filename,
388     if (retval < 0)
389     goto out;
390    
391     - retval = search_binary_handler(bprm, regs);
392     + retval = search_binary_handler_with_transition(bprm, regs);
393     if (retval >= 0) {
394     free_arg_pages(bprm);
395    
396 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/exec.c
397     +++ linux-2.6.15-53.75/fs/exec.c
398 kumaneko 1498 @@ -57,6 +57,10 @@
399     #include <linux/kmod.h>
400     #endif
401    
402     +/***** TOMOYO Linux start. *****/
403     +#include <linux/tomoyo.h>
404     +/***** TOMOYO Linux end. *****/
405     +
406     int core_uses_pid;
407     char core_pattern[65] = "core";
408     int suid_dumpable = 0;
409     @@ -139,6 +143,13 @@ asmlinkage long sys_uselib(const char __
410     if (error)
411     goto exit;
412    
413     + /***** TOMOYO Linux start. *****/
414     + /* 01 means "read". */
415     + error = ccs_check_open_permission(nd.dentry, nd.mnt, 01);
416     + if (error)
417     + goto exit;
418     + /***** TOMOYO Linux end. *****/
419     +
420     file = nameidata_to_filp(&nd, O_RDONLY);
421     error = PTR_ERR(file);
422     if (IS_ERR(file))
423     @@ -488,6 +499,13 @@ struct file *open_exec(const char *name)
424     int err = vfs_permission(&nd, MAY_EXEC);
425     if (!err && !(inode->i_mode & 0111))
426     err = -EACCES;
427     + /***** TOMOYO Linux start. *****/
428     + if (!err && (current->tomoyo_flags &
429     + TOMOYO_CHECK_READ_FOR_OPEN_EXEC))
430     + /* 01 means "read". */
431     + err = ccs_check_open_permission(nd.dentry,
432     + nd.mnt, 01);
433     + /***** TOMOYO Linux end. *****/
434     file = ERR_PTR(err);
435     if (!err) {
436     file = nameidata_to_filp(&nd, O_RDONLY);
437     @@ -1197,7 +1215,8 @@ int do_execve(char * filename,
438     if (retval < 0)
439     goto out;
440    
441     - retval = search_binary_handler(bprm,regs);
442     + retval = search_binary_handler_with_transition(bprm, regs);
443     +
444     if (retval >= 0) {
445     free_arg_pages(bprm);
446    
447 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/fcntl.c
448     +++ linux-2.6.15-53.75/fs/fcntl.c
449 kumaneko 1498 @@ -21,6 +21,9 @@
450     #include <asm/poll.h>
451     #include <asm/siginfo.h>
452     #include <asm/uaccess.h>
453     +/***** TOMOYO Linux start. *****/
454     +#include <linux/tomoyo.h>
455     +/***** TOMOYO Linux end. *****/
456    
457     void fastcall set_close_on_exec(unsigned int fd, int flag)
458     {
459     @@ -211,6 +214,11 @@ static int setfl(int fd, struct file * f
460     if (!(arg & O_APPEND) && IS_APPEND(inode))
461     return -EPERM;
462    
463     + /***** TOMOYO Linux start. *****/
464     + if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp))
465     + return -EPERM;
466     + /***** TOMOYO Linux end. *****/
467     +
468     /* O_NOATIME can only be set by the owner or superuser */
469     if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
470     if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
471 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/ioctl.c
472     +++ linux-2.6.15-53.75/fs/ioctl.c
473 kumaneko 1498 @@ -15,6 +15,9 @@
474    
475     #include <asm/uaccess.h>
476     #include <asm/ioctls.h>
477     +/***** TOMOYO Linux start. *****/
478     +#include <linux/tomoyo.h>
479     +/***** TOMOYO Linux end. *****/
480    
481     static long do_ioctl(struct file *filp, unsigned int cmd,
482     unsigned long arg)
483     @@ -23,6 +26,10 @@ static long do_ioctl(struct file *filp,
484    
485     if (!filp->f_op)
486     goto out;
487     + /***** TOMOYO Linux start. *****/
488     + if (!ccs_capable(TOMOYO_SYS_IOCTL))
489     + return -EPERM;
490     + /***** TOMOYO Linux end. *****/
491    
492     if (filp->f_op->unlocked_ioctl) {
493     error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
494 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/namei.c
495     +++ linux-2.6.15-53.75/fs/namei.c
496 kumaneko 1498 @@ -34,6 +34,10 @@
497    
498     #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
499    
500     +/***** TOMOYO Linux start. *****/
501     +#include <linux/tomoyo.h>
502     +/***** TOMOYO Linux end. *****/
503     +
504     /* [Feb-1997 T. Schoebel-Theuer]
505     * Fundamental changes in the pathname lookup mechanisms (namei)
506     * were necessary because of omirr. The reason is that omirr needs
507     @@ -1433,6 +1437,13 @@ int vfs_create(struct inode *dir, struct
508     error = security_inode_create(dir, dentry, mode);
509     if (error)
510     return error;
511     + /***** TOMOYO Linux start. *****/
512     + if (nd) {
513     + error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt);
514     + if (error)
515     + return error;
516     + }
517     + /***** TOMOYO Linux end. *****/
518     DQUOT_INIT(dir);
519     error = dir->i_op->create(dir, dentry, mode, nd);
520     if (!error)
521     @@ -1488,6 +1499,13 @@ int may_open(struct nameidata *nd, int a
522     if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
523     return -EPERM;
524    
525     + /***** TOMOYO Linux start. *****/
526     + /* includes O_APPEND and O_TRUNC checks */
527     + error = ccs_check_open_permission(dentry, nd->mnt, flag);
528     + if (error)
529     + return error;
530     + /***** TOMOYO Linux end. *****/
531     +
532     /*
533     * Ensure there are no outstanding leases on the file.
534     */
535     @@ -1519,6 +1537,9 @@ int may_open(struct nameidata *nd, int a
536     return 0;
537     }
538    
539     +/***** TOMOYO Linux start. *****/
540     +#include <linux/tomoyo_vfs.h>
541     +/***** TOMOYO Linux end. *****/
542     /*
543     * open_namei()
544     *
545     @@ -1768,6 +1789,16 @@ asmlinkage long sys_mknod(const char __u
546    
547     if (S_ISDIR(mode))
548     return -EPERM;
549     + /***** TOMOYO Linux start. *****/
550     + if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV))
551     + return -EPERM;
552     + if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV))
553     + return -EPERM;
554     + if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO))
555     + return -EPERM;
556     + if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
557     + return -EPERM;
558     + /***** TOMOYO Linux end. *****/
559     tmp = getname(filename);
560     if (IS_ERR(tmp))
561     return PTR_ERR(tmp);
562     @@ -1786,10 +1817,32 @@ asmlinkage long sys_mknod(const char __u
563     error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
564     break;
565     case S_IFCHR: case S_IFBLK:
566     + /***** TOMOYO Linux start. *****/
567     + error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
568     + if (error)
569     + break;
570     + error = ccs_check_1path_perm(S_ISCHR(mode) ?
571     + TYPE_MKCHAR_ACL :
572     + TYPE_MKBLOCK_ACL,
573     + dentry, nd.mnt);
574     + if (error)
575     + break;
576     + /***** TOMOYO Linux end. *****/
577     error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
578     new_decode_dev(dev));
579     break;
580     case S_IFIFO: case S_IFSOCK:
581     + /***** TOMOYO Linux start. *****/
582     + error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
583     + if (error)
584     + break;
585     + error = ccs_check_1path_perm(S_ISFIFO(mode) ?
586     + TYPE_MKFIFO_ACL :
587     + TYPE_MKSOCK_ACL,
588     + dentry, nd.mnt);
589     + if (error)
590     + break;
591     + /***** TOMOYO Linux end. *****/
592     error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
593     break;
594     case S_IFDIR:
595     @@ -1849,6 +1902,13 @@ asmlinkage long sys_mkdir(const char __u
596     if (!IS_ERR(dentry)) {
597     if (!IS_POSIXACL(nd.dentry->d_inode))
598     mode &= ~current->fs->umask;
599     + /***** TOMOYO Linux start. *****/
600     + error = pre_vfs_mkdir(nd.dentry->d_inode, dentry);
601     + if (!error)
602     + error = ccs_check_1path_perm(TYPE_MKDIR_ACL,
603     + dentry, nd.mnt);
604     + if (!error)
605     + /***** TOMOYO Linux end. *****/
606     error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
607     dput(dentry);
608     }
609     @@ -1952,6 +2012,13 @@ asmlinkage long sys_rmdir(const char __u
610     dentry = lookup_hash(&nd);
611     error = PTR_ERR(dentry);
612     if (!IS_ERR(dentry)) {
613     + /***** TOMOYO Linux start. *****/
614     + error = pre_vfs_rmdir(nd.dentry->d_inode, dentry);
615     + if (!error)
616     + error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry,
617     + nd.mnt);
618     + if (!error)
619     + /***** TOMOYO Linux end. *****/
620     error = vfs_rmdir(nd.dentry->d_inode, dentry);
621     dput(dentry);
622     }
623     @@ -2006,6 +2073,10 @@ asmlinkage long sys_unlink(const char __
624     struct dentry *dentry;
625     struct nameidata nd;
626     struct inode *inode = NULL;
627     + /***** TOMOYO Linux start. *****/
628     + if (!ccs_capable(TOMOYO_SYS_UNLINK))
629     + return -EPERM;
630     + /***** TOMOYO Linux end. *****/
631    
632     name = getname(pathname);
633     if(IS_ERR(name))
634     @@ -2027,6 +2098,14 @@ asmlinkage long sys_unlink(const char __
635     inode = dentry->d_inode;
636     if (inode)
637     atomic_inc(&inode->i_count);
638     + /***** TOMOYO Linux start. *****/
639     + error = pre_vfs_unlink(nd.dentry->d_inode, dentry);
640     + if (error)
641     + goto exit2;
642     + error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt);
643     + if (error)
644     + goto exit2;
645     + /***** TOMOYO Linux end. *****/
646     error = vfs_unlink(nd.dentry->d_inode, dentry);
647     exit2:
648     dput(dentry);
649     @@ -2072,6 +2151,10 @@ asmlinkage long sys_symlink(const char _
650     int error = 0;
651     char * from;
652     char * to;
653     + /***** TOMOYO Linux start. *****/
654     + if (!ccs_capable(TOMOYO_SYS_SYMLINK))
655     + return -EPERM;
656     + /***** TOMOYO Linux end. *****/
657    
658     from = getname(oldname);
659     if(IS_ERR(from))
660     @@ -2088,6 +2171,13 @@ asmlinkage long sys_symlink(const char _
661     dentry = lookup_create(&nd, 0);
662     error = PTR_ERR(dentry);
663     if (!IS_ERR(dentry)) {
664     + /***** TOMOYO Linux start. *****/
665     + error = pre_vfs_symlink(nd.dentry->d_inode, dentry);
666     + if (!error)
667     + error = ccs_check_1path_perm(TYPE_SYMLINK_ACL,
668     + dentry, nd.mnt);
669     + if (!error)
670     + /***** TOMOYO Linux end. *****/
671     error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
672     dput(dentry);
673     }
674     @@ -2153,6 +2243,10 @@ asmlinkage long sys_link(const char __us
675     struct nameidata nd, old_nd;
676     int error;
677     char * to;
678     + /***** TOMOYO Linux start. *****/
679     + if (!ccs_capable(TOMOYO_SYS_LINK))
680     + return -EPERM;
681     + /***** TOMOYO Linux end. *****/
682    
683     to = getname(newname);
684     if (IS_ERR(to))
685     @@ -2170,6 +2264,15 @@ asmlinkage long sys_link(const char __us
686     new_dentry = lookup_create(&nd, 0);
687     error = PTR_ERR(new_dentry);
688     if (!IS_ERR(new_dentry)) {
689     + /***** TOMOYO Linux start. *****/
690     + error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode,
691     + new_dentry);
692     + if (!error)
693     + error = ccs_check_2path_perm(TYPE_LINK_ACL,
694     + old_nd.dentry, old_nd.mnt,
695     + new_dentry, nd.mnt);
696     + if (!error)
697     + /***** TOMOYO Linux end. *****/
698     error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
699     dput(new_dentry);
700     }
701     @@ -2390,6 +2493,17 @@ static inline int do_rename(const char *
702     if (new_dentry == trap)
703     goto exit5;
704    
705     + /***** TOMOYO Linux start. *****/
706     + error = pre_vfs_rename(old_dir->d_inode, old_dentry,
707     + new_dir->d_inode, new_dentry);
708     + if (error)
709     + goto exit5;
710     + error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt,
711     + new_dentry, newnd.mnt);
712     + if (error)
713     + goto exit5;
714     + /***** TOMOYO Linux end. *****/
715     +
716     error = vfs_rename(old_dir->d_inode, old_dentry,
717     new_dir->d_inode, new_dentry);
718     exit5:
719     @@ -2411,6 +2525,10 @@ asmlinkage long sys_rename(const char __
720     int error;
721     char * from;
722     char * to;
723     + /***** TOMOYO Linux start. *****/
724     + if (!ccs_capable(TOMOYO_SYS_RENAME))
725     + return -EPERM;
726     + /***** TOMOYO Linux end. *****/
727    
728     from = getname(oldname);
729     if(IS_ERR(from))
730 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/namespace.c
731     +++ linux-2.6.15-53.75/fs/namespace.c
732 kumaneko 1498 @@ -25,6 +25,12 @@
733     #include <asm/uaccess.h>
734     #include <asm/unistd.h>
735     #include "pnode.h"
736     +/***** SAKURA Linux start. *****/
737     +#include <linux/sakura.h>
738     +/***** SAKURA Linux end. *****/
739     +/***** TOMOYO Linux start. *****/
740     +#include <linux/tomoyo.h>
741     +/***** TOMOYO Linux end. *****/
742    
743     extern int __init init_rootfs(void);
744    
745     @@ -504,6 +510,11 @@ static int do_umount(struct vfsmount *mn
746     if (retval)
747     return retval;
748    
749     + /***** SAKURA Linux start. *****/
750     + if (ccs_may_umount(mnt))
751     + return -EPERM;
752     + /***** SAKURA Linux end. *****/
753     +
754     /*
755     * Allow userspace to request a mountpoint be expired rather than
756     * unmounting unconditionally. Unmount only happens if:
757     @@ -592,6 +603,10 @@ asmlinkage long sys_umount(char __user *
758     {
759     struct nameidata nd;
760     int retval;
761     + /***** TOMOYO Linux start. *****/
762     + if (!ccs_capable(TOMOYO_SYS_UMOUNT))
763     + return -EPERM;
764     + /***** TOMOYO Linux end. *****/
765    
766     retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
767     if (retval)
768     @@ -879,6 +894,11 @@ static int do_loopback(struct nameidata
769    
770     if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
771     goto out;
772     + /***** SAKURA Linux start. *****/
773     + err = -EPERM;
774     + if (ccs_may_mount(nd))
775     + goto out;
776     + /***** SAKURA Linux end. *****/
777    
778     err = -ENOMEM;
779     if (recurse)
780     @@ -963,7 +983,11 @@ static int do_move_mount(struct nameidat
781     err = -EINVAL;
782     if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
783     goto out;
784     -
785     + /***** SAKURA Linux start. *****/
786     + err = -EPERM;
787     + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
788     + goto out;
789     + /***** SAKURA Linux end. *****/
790     err = -ENOENT;
791     down(&nd->dentry->d_inode->i_sem);
792     if (IS_DEADDIR(nd->dentry->d_inode))
793     @@ -1065,6 +1089,11 @@ int do_add_mount(struct vfsmount *newmnt
794     err = -EINVAL;
795     if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
796     goto unlock;
797     + /***** SAKURA Linux start. *****/
798     + err = -EPERM;
799     + if (ccs_may_mount(nd))
800     + goto unlock;
801     + /***** SAKURA Linux end. *****/
802    
803     newmnt->mnt_flags = mnt_flags;
804     if ((err = graft_tree(newmnt, nd)))
805     @@ -1282,6 +1311,17 @@ long do_mount(char *dev_name, char *dir_
806     if (data_page)
807     ((char *)data_page)[PAGE_SIZE - 1] = 0;
808    
809     + /***** TOMOYO Linux start. *****/
810     + if (!ccs_capable(TOMOYO_SYS_MOUNT))
811     + return -EPERM;
812     + /***** TOMOYO Linux end. *****/
813     + /***** SAKURA Linux start. *****/
814     + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
815     + &flags);
816     + if (retval)
817     + return retval;
818     + /***** SAKURA Linux end. *****/
819     +
820     /* Separate the per-mountpoint flags */
821     if (flags & MS_NOSUID)
822     mnt_flags |= MNT_NOSUID;
823     @@ -1546,6 +1586,10 @@ asmlinkage long sys_pivot_root(const cha
824    
825     if (!capable(CAP_SYS_ADMIN))
826     return -EPERM;
827     + /***** TOMOYO Linux start. *****/
828     + if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT))
829     + return -EPERM;
830     + /***** TOMOYO Linux end. *****/
831    
832     lock_kernel();
833    
834     @@ -1562,6 +1606,10 @@ asmlinkage long sys_pivot_root(const cha
835     goto out1;
836    
837     error = security_sb_pivotroot(&old_nd, &new_nd);
838     + /***** SAKURA Linux start. *****/
839     + if (!error)
840     + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
841     + /***** SAKURA Linux end. *****/
842     if (error) {
843     path_release(&old_nd);
844     goto out1;
845 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/open.c
846     +++ linux-2.6.15-53.75/fs/open.c
847 kumaneko 1498 @@ -28,6 +28,13 @@
848    
849     #include <asm/unistd.h>
850    
851     +/***** SAKURA Linux start. *****/
852     +#include <linux/sakura.h>
853     +/***** SAKURA Linux end. *****/
854     +/***** TOMOYO Linux start. *****/
855     +#include <linux/tomoyo.h>
856     +/***** TOMOYO Linux end. *****/
857     +
858     int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
859     {
860     int retval = -ENODEV;
861 kumaneko 1896 @@ -285,6 +292,10 @@ static inline long do_sys_truncate(const
862 kumaneko 1498 if (error)
863     goto dput_and_out;
864    
865     + /***** TOMOYO Linux start. *****/
866     + error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt);
867     + if (!error)
868     + /***** TOMOYO Linux end. *****/
869     error = locks_verify_truncate(inode, NULL, length);
870     if (!error) {
871     DQUOT_INIT(inode);
872 kumaneko 1896 @@ -337,7 +348,11 @@ static inline long do_sys_ftruncate(unsi
873 kumaneko 1498 error = -EPERM;
874     if (IS_APPEND(inode))
875     goto out_putf;
876     -
877     + /***** TOMOYO Linux start. *****/
878     + error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt);
879     + if (error)
880     + goto out_putf;
881     + /***** TOMOYO Linux end. *****/
882     error = locks_verify_truncate(inode, file, length);
883     if (!error)
884     error = do_truncate(dentry, length, file);
885 kumaneko 1896 @@ -610,6 +625,14 @@ asmlinkage long sys_chroot(const char __
886 kumaneko 1498 error = -EPERM;
887     if (!capable(CAP_SYS_CHROOT))
888     goto dput_and_out;
889     + /***** TOMOYO Linux start. *****/
890     + if (!ccs_capable(TOMOYO_SYS_CHROOT))
891     + goto dput_and_out;
892     + /***** TOMOYO Linux end. *****/
893     + /***** SAKURA Linux start. *****/
894     + if (ccs_check_chroot_permission(&nd))
895     + goto dput_and_out;
896     + /***** SAKURA Linux end. *****/
897    
898     set_fs_root(current->fs, nd.mnt, nd.dentry);
899     set_fs_altroot();
900 kumaneko 1896 @@ -1141,6 +1164,10 @@ EXPORT_SYMBOL(sys_close);
901 kumaneko 1498 */
902     asmlinkage long sys_vhangup(void)
903     {
904     + /***** TOMOYO Linux start. *****/
905     + if (!ccs_capable(TOMOYO_SYS_VHANGUP))
906     + return -EPERM;
907     + /***** TOMOYO Linux end. *****/
908     if (capable(CAP_SYS_TTY_CONFIG)) {
909     tty_vhangup(current->signal->tty);
910     return 0;
911 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/proc/Makefile
912     +++ linux-2.6.15-53.75/fs/proc/Makefile
913 kumaneko 1498 @@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge
914     proc-$(CONFIG_PROC_KCORE) += kcore.o
915     proc-$(CONFIG_PROC_VMCORE) += vmcore.o
916     proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
917     +
918     +proc-$(CONFIG_SAKURA) += ccs_proc.o
919     +proc-$(CONFIG_TOMOYO) += ccs_proc.o
920 kumaneko 2090 --- linux-2.6.15-53.75.orig/fs/proc/proc_misc.c
921     +++ linux-2.6.15-53.75/fs/proc/proc_misc.c
922 kumaneko 1498 @@ -629,4 +629,9 @@ void __init proc_misc_init(void)
923     if (entry)
924     entry->proc_fops = &proc_sysrq_trigger_operations;
925     #endif
926     + /***** CCS start. *****/
927     +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
928 kumaneko 2090 + printk(KERN_INFO "Hook version: 2.6.15-53.75 2009/01/29\n");
929 kumaneko 1498 +#endif
930     + /***** CCS end. *****/
931     }
932 kumaneko 2090 --- linux-2.6.15-53.75.orig/include/linux/init_task.h
933     +++ linux-2.6.15-53.75/include/linux/init_task.h
934 kumaneko 1498 @@ -121,6 +121,10 @@ extern struct group_info init_groups;
935     .journal_info = NULL, \
936     .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
937     .fs_excl = ATOMIC_INIT(0), \
938     + /***** TOMOYO Linux start. *****/ \
939     + .domain_info = &KERNEL_DOMAIN, \
940     + .tomoyo_flags = 0, \
941     + /***** TOMOYO Linux end. *****/ \
942     }
943    
944    
945 kumaneko 2090 --- linux-2.6.15-53.75.orig/include/linux/sched.h
946     +++ linux-2.6.15-53.75/include/linux/sched.h
947 kumaneko 1498 @@ -39,6 +39,11 @@
948    
949     struct exec_domain;
950    
951     +/***** TOMOYO Linux start. *****/
952     +struct domain_info;
953     +extern struct domain_info KERNEL_DOMAIN;
954     +/***** TOMOYO Linux end. *****/
955     +
956     /*
957     * cloning flags:
958     */
959 kumaneko 1896 @@ -858,6 +863,10 @@ struct task_struct {
960 kumaneko 1498 #endif
961     atomic_t fs_excl; /* holding fs exclusive resources */
962 kumaneko 1896 struct list_head *scm_work_list;
963 kumaneko 1498 + /***** TOMOYO Linux start. *****/
964     + struct domain_info *domain_info;
965     + u32 tomoyo_flags;
966     + /***** TOMOYO Linux end. *****/
967     };
968    
969     static inline pid_t process_group(struct task_struct *tsk)
970 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/compat.c
971     +++ linux-2.6.15-53.75/kernel/compat.c
972 kumaneko 1498 @@ -24,6 +24,9 @@
973    
974     #include <asm/uaccess.h>
975     #include <asm/bug.h>
976     +/***** TOMOYO Linux start. *****/
977     +#include <linux/tomoyo.h>
978     +/***** TOMOYO Linux end. *****/
979    
980     int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
981     {
982     @@ -849,6 +852,10 @@ asmlinkage long compat_sys_stime(compat_
983     err = security_settime(&tv, NULL);
984     if (err)
985     return err;
986     + /***** TOMOYO Linux start. *****/
987     + if (!ccs_capable(TOMOYO_SYS_SETTIME))
988     + return -EPERM;
989     + /***** TOMOYO Linux end. *****/
990    
991     do_settimeofday(&tv);
992     return 0;
993 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/kexec.c
994     +++ linux-2.6.15-53.75/kernel/kexec.c
995 kumaneko 1498 @@ -25,6 +25,9 @@
996     #include <asm/io.h>
997     #include <asm/system.h>
998     #include <asm/semaphore.h>
999     +/***** TOMOYO Linux start. *****/
1000     +#include <linux/tomoyo.h>
1001     +/***** TOMOYO Linux end. *****/
1002    
1003     /* Location of the reserved area for the crash kernel */
1004     struct resource crashk_res = {
1005     @@ -918,6 +921,10 @@ asmlinkage long sys_kexec_load(unsigned
1006     /* We only trust the superuser with rebooting the system. */
1007     if (!capable(CAP_SYS_BOOT))
1008     return -EPERM;
1009     + /***** TOMOYO Linux start. *****/
1010     + if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD))
1011     + return -EPERM;
1012     + /***** TOMOYO Linux end. *****/
1013    
1014     /*
1015     * Verify we have a legal set of flags
1016 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/kmod.c
1017     +++ linux-2.6.15-53.75/kernel/kmod.c
1018 kumaneko 1498 @@ -149,6 +149,11 @@ static int ____call_usermodehelper(void
1019     /* We can run anywhere, unlike our parent keventd(). */
1020     set_cpus_allowed(current, CPU_MASK_ALL);
1021    
1022     + /***** TOMOYO Linux start. *****/
1023     + current->domain_info = &KERNEL_DOMAIN;
1024     + current->tomoyo_flags = 0;
1025     + /***** TOMOYO Linux end. *****/
1026     +
1027     retval = -EPERM;
1028     if (current->fs->root)
1029     retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
1030 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/module.c
1031     +++ linux-2.6.15-53.75/kernel/module.c
1032 kumaneko 1498 @@ -41,6 +41,9 @@
1033     #include <asm/uaccess.h>
1034     #include <asm/semaphore.h>
1035     #include <asm/cacheflush.h>
1036     +/***** TOMOYO Linux start. *****/
1037     +#include <linux/tomoyo.h>
1038     +/***** TOMOYO Linux end. *****/
1039    
1040     #if 0
1041     #define DEBUGP printk
1042     @@ -577,7 +580,10 @@ sys_delete_module(const char __user *nam
1043    
1044     if (!capable(CAP_SYS_MODULE))
1045     return -EPERM;
1046     -
1047     + /***** TOMOYO Linux start. *****/
1048     + if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1049     + return -EPERM;
1050     + /***** TOMOYO Linux end. *****/
1051     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
1052     return -EFAULT;
1053     name[MODULE_NAME_LEN-1] = '\0';
1054     @@ -1886,7 +1892,10 @@ sys_init_module(void __user *umod,
1055     /* Must have permission */
1056     if (!capable(CAP_SYS_MODULE))
1057     return -EPERM;
1058     -
1059     + /***** TOMOYO Linux start. *****/
1060     + if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1061     + return -EPERM;
1062     + /***** TOMOYO Linux end. *****/
1063     /* Only one module load at a time, please */
1064     if (down_interruptible(&module_mutex) != 0)
1065     return -EINTR;
1066 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/ptrace.c
1067     +++ linux-2.6.15-53.75/kernel/ptrace.c
1068 kumaneko 1498 @@ -20,6 +20,9 @@
1069    
1070     #include <asm/pgtable.h>
1071     #include <asm/uaccess.h>
1072     +/***** TOMOYO Linux start. *****/
1073     +#include <linux/tomoyo.h>
1074     +/***** TOMOYO Linux end. *****/
1075    
1076     /*
1077     * ptrace a task: make the debugger its new parent and
1078     @@ -492,6 +495,12 @@ asmlinkage long sys_ptrace(long request,
1079     /*
1080     * This lock_kernel fixes a subtle race with suid exec
1081     */
1082     + /***** TOMOYO Linux start. *****/
1083     +#ifdef TOMOYO_SYS_PTRACE
1084     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
1085     + return -EPERM;
1086     +#endif
1087     + /***** TOMOYO Linux end. *****/
1088     lock_kernel();
1089     ret = ptrace_get_task_struct(request, pid, &child);
1090     if (!child)
1091 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/sched.c
1092     +++ linux-2.6.15-53.75/kernel/sched.c
1093 kumaneko 1498 @@ -50,6 +50,9 @@
1094     #include <asm/tlb.h>
1095    
1096     #include <asm/unistd.h>
1097     +/***** TOMOYO Linux start. *****/
1098     +#include <linux/tomoyo.h>
1099     +/***** TOMOYO Linux end. *****/
1100    
1101     /*
1102     * Convert user-nice values [ -20 ... 0 ... 19 ]
1103     @@ -3603,6 +3606,10 @@ asmlinkage long sys_nice(int increment)
1104     {
1105     int retval;
1106     long nice;
1107     + /***** TOMOYO Linux start. *****/
1108     + if (!ccs_capable(TOMOYO_SYS_NICE))
1109     + return -EPERM;
1110     + /***** TOMOYO Linux end. *****/
1111    
1112     /*
1113     * Setpriority might change our priority at the same moment.
1114 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/signal.c
1115     +++ linux-2.6.15-53.75/kernel/signal.c
1116 kumaneko 1498 @@ -29,6 +29,9 @@
1117     #include <asm/uaccess.h>
1118     #include <asm/unistd.h>
1119     #include <asm/siginfo.h>
1120     +/***** TOMOYO Linux start. *****/
1121     +#include <linux/tomoyo.h>
1122     +/***** TOMOYO Linux end. *****/
1123    
1124     /*
1125     * SLAB caches for signal bits.
1126     @@ -2241,6 +2244,12 @@ asmlinkage long
1127     sys_kill(int pid, int sig)
1128     {
1129     struct siginfo info;
1130     + /***** TOMOYO Linux start. *****/
1131     + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1132     + return -EPERM;
1133     + if (sig && ccs_check_signal_acl(sig, pid))
1134     + return -EPERM;
1135     + /***** TOMOYO Linux end. *****/
1136    
1137     info.si_signo = sig;
1138     info.si_errno = 0;
1139     @@ -2299,6 +2308,12 @@ asmlinkage long sys_tgkill(int tgid, int
1140     /* This is only valid for single tasks */
1141     if (pid <= 0 || tgid <= 0)
1142     return -EINVAL;
1143     + /***** TOMOYO Linux start. *****/
1144     + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1145     + return -EPERM;
1146     + if (sig && ccs_check_signal_acl(sig, pid))
1147     + return -EPERM;
1148     + /***** TOMOYO Linux end. *****/
1149    
1150     return do_tkill(tgid, pid, sig);
1151     }
1152     @@ -2312,6 +2327,12 @@ sys_tkill(int pid, int sig)
1153     /* This is only valid for single tasks */
1154     if (pid <= 0)
1155     return -EINVAL;
1156     + /***** TOMOYO Linux start. *****/
1157     + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1158     + return -EPERM;
1159     + if (sig && ccs_check_signal_acl(sig, pid))
1160     + return -EPERM;
1161     + /***** TOMOYO Linux end. *****/
1162    
1163     return do_tkill(0, pid, sig);
1164     }
1165 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/sys.c
1166     +++ linux-2.6.15-53.75/kernel/sys.c
1167 kumaneko 1498 @@ -37,6 +37,9 @@
1168     #include <asm/uaccess.h>
1169     #include <asm/io.h>
1170     #include <asm/unistd.h>
1171     +/***** TOMOYO Linux start. *****/
1172     +#include <linux/tomoyo.h>
1173     +/***** TOMOYO Linux end. *****/
1174    
1175     #ifndef SET_UNALIGN_CTL
1176     # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1177     @@ -256,6 +259,12 @@ asmlinkage long sys_setpriority(int whic
1178    
1179     if (which > 2 || which < 0)
1180     goto out;
1181     + /***** TOMOYO Linux start. *****/
1182     + if (!ccs_capable(TOMOYO_SYS_NICE)) {
1183     + error = -EPERM;
1184     + goto out;
1185     + }
1186     + /***** TOMOYO Linux end. *****/
1187    
1188     /* normalize: avoid signed division (rounding problems) */
1189     error = -ESRCH;
1190     @@ -483,6 +492,10 @@ asmlinkage long sys_reboot(int magic1, i
1191     magic2 != LINUX_REBOOT_MAGIC2B &&
1192     magic2 != LINUX_REBOOT_MAGIC2C))
1193     return -EINVAL;
1194     + /***** TOMOYO Linux start. *****/
1195     + if (!ccs_capable(TOMOYO_SYS_REBOOT))
1196     + return -EPERM;
1197     + /***** TOMOYO Linux end. *****/
1198    
1199     lock_kernel();
1200     switch (cmd) {
1201     @@ -1515,6 +1528,10 @@ asmlinkage long sys_sethostname(char __u
1202     return -EPERM;
1203     if (len < 0 || len > __NEW_UTS_LEN)
1204     return -EINVAL;
1205     + /***** TOMOYO Linux start. *****/
1206     + if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1207     + return -EPERM;
1208     + /***** TOMOYO Linux end. *****/
1209     down_write(&uts_sem);
1210     errno = -EFAULT;
1211     if (!copy_from_user(tmp, name, len)) {
1212     @@ -1560,6 +1577,10 @@ asmlinkage long sys_setdomainname(char _
1213     return -EPERM;
1214     if (len < 0 || len > __NEW_UTS_LEN)
1215     return -EINVAL;
1216     + /***** TOMOYO Linux start. *****/
1217     + if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1218     + return -EPERM;
1219     + /***** TOMOYO Linux end. *****/
1220    
1221     down_write(&uts_sem);
1222     errno = -EFAULT;
1223 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/sysctl.c
1224     +++ linux-2.6.15-53.75/kernel/sysctl.c
1225 kumaneko 1498 @@ -45,6 +45,9 @@
1226    
1227     #include <asm/uaccess.h>
1228     #include <asm/processor.h>
1229     +/***** TOMOYO Linux start. *****/
1230     +#include <linux/tomoyo.h>
1231     +/***** TOMOYO Linux end. *****/
1232    
1233     #ifdef CONFIG_ROOT_NFS
1234     #include <linux/nfs_fs.h>
1235     @@ -1041,6 +1044,100 @@ void __init sysctl_init(void)
1236     #endif
1237     }
1238    
1239     +/***** TOMOYO Linux start. *****/
1240     +static int try_parse_table(int __user *name, int nlen, void __user *oldval,
1241     + void __user *newval, ctl_table *table)
1242     +{
1243     + int n;
1244     + int error = -ENOMEM;
1245     + int op = 0;
1246     + char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1247     + if (oldval)
1248     + op |= 004;
1249     + if (newval)
1250     + op |= 002;
1251     + if (!op) { /* Neither read nor write */
1252     + error = 0;
1253     + goto out;
1254     + }
1255     + if (!buffer)
1256     + goto out;
1257     + memset(buffer, 0, PAGE_SIZE);
1258     + snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1259     + repeat:
1260     + if (!nlen) {
1261     + error = -ENOTDIR;
1262     + goto out;
1263     + }
1264     + if (get_user(n, name)) {
1265     + error = -EFAULT;
1266     + goto out;
1267     + }
1268     + for ( ; table->ctl_name; table++) {
1269     + if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1270     + int pos = strlen(buffer);
1271     + const char *cp = table->procname;
1272     + error = -ENOMEM;
1273     + if (cp) {
1274     + if (pos + 1 >= PAGE_SIZE - 1)
1275     + goto out;
1276     + buffer[pos++] = '/';
1277     + while (*cp) {
1278     + const unsigned char c
1279     + = *(const unsigned char *) cp;
1280     + if (c == '\\') {
1281     + if (pos + 2 >= PAGE_SIZE - 1)
1282     + goto out;
1283     + buffer[pos++] = '\\';
1284     + buffer[pos++] = '\\';
1285     + } else if (c > ' ' && c < 127) {
1286     + if (pos + 1 >= PAGE_SIZE - 1)
1287     + goto out;
1288     + buffer[pos++] = c;
1289     + } else {
1290     + if (pos + 4 >= PAGE_SIZE - 1)
1291     + goto out;
1292     + buffer[pos++] = '\\';
1293     + buffer[pos++] = (c >> 6) + '0';
1294     + buffer[pos++] = ((c >> 3) & 7)
1295     + + '0';
1296     + buffer[pos++] = (c & 7) + '0';
1297     + }
1298     + cp++;
1299     + }
1300     + } else {
1301     + /* Assume nobody assigns "=\$=" for procname. */
1302     + snprintf(buffer + pos, PAGE_SIZE - pos - 1,
1303     + "/=%d=", table->ctl_name);
1304     + if (!memchr(buffer, '\0', PAGE_SIZE - 2))
1305     + goto out;
1306     + }
1307     + if (table->child) {
1308     + if (table->strategy) {
1309     + /* printk("sysctl='%s'\n", buffer); */
1310     + if (ccs_check_file_perm(buffer, op,
1311     + "sysctl")) {
1312     + error = -EPERM;
1313     + goto out;
1314     + }
1315     + }
1316     + name++;
1317     + nlen--;
1318     + table = table->child;
1319     + goto repeat;
1320     + }
1321     + /* printk("sysctl='%s'\n", buffer); */
1322     + error = ccs_check_file_perm(buffer, op, "sysctl");
1323     + goto out;
1324     + }
1325     + }
1326     + error = -ENOTDIR;
1327     + out:
1328     + kfree(buffer);
1329     + return error;
1330     +}
1331     +/***** TOMOYO Linux end. *****/
1332     +
1333     int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1334     void __user *newval, size_t newlen)
1335     {
1336     @@ -1066,6 +1163,11 @@ int do_sysctl(int __user *name, int nlen
1337    
1338     spin_unlock(&sysctl_lock);
1339    
1340     + /***** TOMOYO Linux start. *****/
1341     + error = try_parse_table(name, nlen, oldval, newval,
1342     + head->ctl_table);
1343     + if (!error)
1344     + /***** TOMOYO Linux end. *****/
1345     error = parse_table(name, nlen, oldval, oldlenp,
1346     newval, newlen, head->ctl_table,
1347     &context);
1348     @@ -1138,6 +1240,15 @@ repeat:
1349     if (ctl_perm(table, 001))
1350     return -EPERM;
1351     if (table->strategy) {
1352     + /***** TOMOYO Linux start. *****/
1353     + int op = 0;
1354     + if (oldval)
1355     + op |= 004;
1356     + if (newval)
1357     + op |= 002;
1358     + if (ctl_perm(table, op))
1359     + return -EPERM;
1360     + /***** TOMOYO Linux end. *****/
1361     error = table->strategy(
1362     table, name, nlen,
1363     oldval, oldlenp,
1364 kumaneko 2090 --- linux-2.6.15-53.75.orig/kernel/time.c
1365     +++ linux-2.6.15-53.75/kernel/time.c
1366 kumaneko 1498 @@ -38,6 +38,9 @@
1367    
1368     #include <asm/uaccess.h>
1369     #include <asm/unistd.h>
1370     +/***** TOMOYO Linux start. *****/
1371     +#include <linux/tomoyo.h>
1372     +/***** TOMOYO Linux end. *****/
1373    
1374     /*
1375     * The timezone where the local system is located. Used as a default by some
1376     @@ -90,6 +93,10 @@ asmlinkage long sys_stime(time_t __user
1377     err = security_settime(&tv, NULL);
1378     if (err)
1379     return err;
1380     + /***** TOMOYO Linux start. *****/
1381     + if (!ccs_capable(TOMOYO_SYS_SETTIME))
1382     + return -EPERM;
1383     + /***** TOMOYO Linux end. *****/
1384    
1385     do_settimeofday(&tv);
1386     return 0;
1387     @@ -157,6 +164,10 @@ int do_sys_settimeofday(struct timespec
1388     error = security_settime(tv, tz);
1389     if (error)
1390     return error;
1391     + /***** TOMOYO Linux start. *****/
1392     + if (!ccs_capable(TOMOYO_SYS_SETTIME))
1393     + return -EPERM;
1394     + /***** TOMOYO Linux end. *****/
1395    
1396     if (tz) {
1397     /* SMP safe, global irq locking makes it work. */
1398     @@ -235,6 +246,10 @@ int do_adjtimex(struct timex *txc)
1399     /* In order to modify anything, you gotta be super-user! */
1400     if (txc->modes && !capable(CAP_SYS_TIME))
1401     return -EPERM;
1402     + /***** TOMOYO Linux start. *****/
1403     + if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME))
1404     + return -EPERM;
1405     + /***** TOMOYO Linux end. *****/
1406    
1407     /* Now we validate the data before disabling interrupts */
1408    
1409 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/core/datagram.c
1410     +++ linux-2.6.15-53.75/net/core/datagram.c
1411 kumaneko 1498 @@ -55,6 +55,11 @@
1412     #include <net/sock.h>
1413     #include <net/tcp_states.h>
1414    
1415     +/***** TOMOYO Linux start. *****/
1416     +#include <linux/tomoyo.h>
1417     +#include <linux/tomoyo_socket.h>
1418     +/***** TOMOYO Linux end. *****/
1419     +
1420     /*
1421     * Is a socket 'connection oriented' ?
1422     */
1423     @@ -177,6 +182,12 @@ struct sk_buff *skb_recv_datagram(struct
1424     } else
1425     skb = skb_dequeue(&sk->sk_receive_queue);
1426    
1427     + /***** TOMOYO Linux start. *****/
1428     + error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1429     + if (error)
1430     + goto no_packet;
1431     + /***** TOMOYO Linux end. *****/
1432     +
1433     if (skb)
1434     return skb;
1435    
1436 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/ipv4/inet_connection_sock.c
1437     +++ linux-2.6.15-53.75/net/ipv4/inet_connection_sock.c
1438 kumaneko 1498 @@ -24,6 +24,9 @@
1439     #include <net/route.h>
1440     #include <net/tcp_states.h>
1441     #include <net/xfrm.h>
1442     +/***** SAKURA Linux start. *****/
1443     +#include <linux/sakura.h>
1444     +/***** SAKURA Linux end. *****/
1445    
1446     #ifdef INET_CSK_DEBUG
1447     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1448     @@ -83,6 +86,10 @@ int inet_csk_get_port(struct inet_hashin
1449     do {
1450     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1451     spin_lock(&head->lock);
1452     + /***** SAKURA Linux start. *****/
1453     + if (ccs_may_autobind(rover))
1454     + goto next;
1455     + /***** SAKURA Linux end. *****/
1456     inet_bind_bucket_for_each(tb, node, &head->chain)
1457     if (tb->port == rover)
1458     goto next;
1459 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/ipv4/tcp_ipv4.c
1460     +++ linux-2.6.15-53.75/net/ipv4/tcp_ipv4.c
1461 kumaneko 1498 @@ -76,6 +76,9 @@
1462     #include <linux/stddef.h>
1463     #include <linux/proc_fs.h>
1464     #include <linux/seq_file.h>
1465     +/***** SAKURA Linux start. *****/
1466     +#include <linux/sakura.h>
1467     +/***** SAKURA Linux end. *****/
1468    
1469     int sysctl_tcp_tw_reuse;
1470     int sysctl_tcp_low_latency;
1471     @@ -243,6 +246,10 @@ static inline int tcp_v4_hash_connect(st
1472     local_bh_disable();
1473     for (i = 1; i <= range; i++) {
1474     port = low + (i + offset) % range;
1475     + /***** SAKURA Linux start. *****/
1476     + if (ccs_may_autobind(port))
1477     + continue;
1478     + /***** SAKURA Linux end. *****/
1479     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1480     spin_lock(&head->lock);
1481    
1482 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/ipv4/udp.c
1483     +++ linux-2.6.15-53.75/net/ipv4/udp.c
1484 kumaneko 1498 @@ -108,6 +108,9 @@
1485     #include <net/inet_common.h>
1486     #include <net/checksum.h>
1487     #include <net/xfrm.h>
1488     +/***** SAKURA Linux start. *****/
1489     +#include <linux/sakura.h>
1490     +/***** SAKURA Linux end. *****/
1491    
1492     /*
1493     * Snmp MIB for the UDP layer
1494     @@ -146,6 +149,10 @@ static int udp_v4_get_port(struct sock *
1495     result = sysctl_local_port_range[0] +
1496     ((result - sysctl_local_port_range[0]) &
1497     (UDP_HTABLE_SIZE - 1));
1498     + /***** SAKURA Linux start. *****/
1499     + if (ccs_may_autobind(result))
1500     + continue;
1501     + /***** SAKURA Linux end. *****/
1502     goto gotit;
1503     }
1504     size = 0;
1505     @@ -162,6 +169,10 @@ static int udp_v4_get_port(struct sock *
1506     result = sysctl_local_port_range[0]
1507     + ((result - sysctl_local_port_range[0]) &
1508     (UDP_HTABLE_SIZE - 1));
1509     + /***** SAKURA Linux start. *****/
1510     + if (ccs_may_autobind(result))
1511     + continue;
1512     + /***** SAKURA Linux end. *****/
1513     if (!udp_lport_inuse(result))
1514     break;
1515     }
1516 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/ipv6/tcp_ipv6.c
1517     +++ linux-2.6.15-53.75/net/ipv6/tcp_ipv6.c
1518 kumaneko 1498 @@ -64,6 +64,9 @@
1519    
1520     #include <linux/proc_fs.h>
1521     #include <linux/seq_file.h>
1522     +/***** SAKURA Linux start. *****/
1523     +#include <linux/sakura.h>
1524     +/***** SAKURA Linux end. *****/
1525    
1526     static void tcp_v6_send_reset(struct sk_buff *skb);
1527     static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1528     @@ -119,6 +122,10 @@ static int tcp_v6_get_port(struct sock *
1529     do {
1530     head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1531     spin_lock(&head->lock);
1532     + /***** SAKURA Linux start. *****/
1533     + if (ccs_may_autobind(rover))
1534     + goto next;
1535     + /***** SAKURA Linux end. *****/
1536     inet_bind_bucket_for_each(tb, node, &head->chain)
1537     if (tb->port == rover)
1538     goto next;
1539     @@ -419,6 +426,10 @@ static int tcp_v6_hash_connect(struct so
1540     local_bh_disable();
1541     for (i = 1; i <= range; i++) {
1542     port = low + (i + offset) % range;
1543     + /***** SAKURA Linux start. *****/
1544     + if (ccs_may_autobind(port))
1545     + continue;
1546     + /***** SAKURA Linux end. *****/
1547     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1548     spin_lock(&head->lock);
1549    
1550 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/ipv6/udp.c
1551     +++ linux-2.6.15-53.75/net/ipv6/udp.c
1552 kumaneko 1498 @@ -58,6 +58,9 @@
1553    
1554     #include <linux/proc_fs.h>
1555     #include <linux/seq_file.h>
1556     +/***** SAKURA Linux start. *****/
1557     +#include <linux/sakura.h>
1558     +/***** SAKURA Linux end. *****/
1559    
1560     DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1561    
1562     @@ -88,6 +91,10 @@ static int udp_v6_get_port(struct sock *
1563     result = sysctl_local_port_range[0] +
1564     ((result - sysctl_local_port_range[0]) &
1565     (UDP_HTABLE_SIZE - 1));
1566     + /***** SAKURA Linux start. *****/
1567     + if (ccs_may_autobind(result))
1568     + continue;
1569     + /***** SAKURA Linux end. *****/
1570     goto gotit;
1571     }
1572     size = 0;
1573     @@ -104,6 +111,10 @@ static int udp_v6_get_port(struct sock *
1574     result = sysctl_local_port_range[0]
1575     + ((result - sysctl_local_port_range[0]) &
1576     (UDP_HTABLE_SIZE - 1));
1577     + /***** SAKURA Linux start. *****/
1578     + if (ccs_may_autobind(result))
1579     + continue;
1580     + /***** SAKURA Linux end. *****/
1581     if (!udp_lport_inuse(result))
1582     break;
1583     }
1584 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/socket.c
1585     +++ linux-2.6.15-53.75/net/socket.c
1586 kumaneko 1498 @@ -97,6 +97,11 @@
1587     #include <net/sock.h>
1588     #include <linux/netfilter.h>
1589    
1590     +/***** TOMOYO Linux start. *****/
1591     +#include <linux/tomoyo.h>
1592     +#include <linux/tomoyo_socket.h>
1593     +/***** TOMOYO Linux end. *****/
1594     +
1595     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1596     static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1597     size_t size, loff_t pos);
1598     @@ -546,7 +551,12 @@ static inline int __sock_sendmsg(struct
1599     err = security_socket_sendmsg(sock, msg, size);
1600     if (err)
1601     return err;
1602     -
1603     + /***** TOMOYO Linux start. *****/
1604     + if (ccs_socket_sendmsg_permission(sock,
1605     + (struct sockaddr *) msg->msg_name,
1606     + msg->msg_namelen))
1607     + return -EPERM;
1608     + /***** TOMOYO Linux end. *****/
1609     return sock->ops->sendmsg(iocb, sock, msg, size);
1610     }
1611    
1612     @@ -1099,6 +1109,12 @@ static int __sock_create(int family, int
1613     family = PF_PACKET;
1614     }
1615    
1616     + /***** TOMOYO Linux start. *****/
1617     + err = ccs_socket_create_permission(family, type, protocol);
1618     + if (err)
1619     + return err;
1620     + /***** TOMOYO Linux end. *****/
1621     +
1622     err = security_socket_create(family, type, protocol, kern);
1623     if (err)
1624     return err;
1625     @@ -1296,6 +1312,12 @@ asmlinkage long sys_bind(int fd, struct
1626     sockfd_put(sock);
1627     return err;
1628     }
1629     + /***** TOMOYO Linux start. *****/
1630     + err = ccs_socket_bind_permission(sock,
1631     + (struct sockaddr *)
1632     + address, addrlen);
1633     + if (!err)
1634     + /***** TOMOYO Linux end. *****/
1635     err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1636     }
1637     sockfd_put(sock);
1638     @@ -1326,7 +1348,10 @@ asmlinkage long sys_listen(int fd, int b
1639     sockfd_put(sock);
1640     return err;
1641     }
1642     -
1643     + /***** TOMOYO Linux start. *****/
1644     + err = ccs_socket_listen_permission(sock);
1645     + if (!err)
1646     + /***** TOMOYO Linux end. *****/
1647     err=sock->ops->listen(sock, backlog);
1648     sockfd_put(sock);
1649     }
1650     @@ -1377,6 +1402,13 @@ asmlinkage long sys_accept(int fd, struc
1651     if (err < 0)
1652     goto out_release;
1653    
1654     + /***** TOMOYO Linux start. *****/
1655     + if (ccs_socket_accept_permission(newsock,
1656     + (struct sockaddr *) address)) {
1657     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1658     + goto out_release;
1659     + }
1660     + /***** TOMOYO Linux end. *****/
1661     if (upeer_sockaddr) {
1662     if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1663     err = -ECONNABORTED;
1664     @@ -1432,7 +1464,12 @@ asmlinkage long sys_connect(int fd, stru
1665     err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1666     if (err)
1667     goto out_put;
1668     -
1669     + /***** TOMOYO Linux start. *****/
1670     + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1671     + addrlen);
1672     + if (err)
1673     + goto out_put;
1674     + /***** TOMOYO Linux end. *****/
1675     err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1676     sock->file->f_flags);
1677     out_put:
1678 kumaneko 2090 --- linux-2.6.15-53.75.orig/net/unix/af_unix.c
1679     +++ linux-2.6.15-53.75/net/unix/af_unix.c
1680 kumaneko 1498 @@ -117,6 +117,9 @@
1681     #include <linux/mount.h>
1682     #include <net/checksum.h>
1683     #include <linux/security.h>
1684     +/***** TOMOYO Linux start. *****/
1685     +#include <linux/tomoyo.h>
1686     +/***** TOMOYO Linux end. *****/
1687    
1688     int sysctl_unix_max_dgram_qlen = 10;
1689    
1690     @@ -738,6 +741,11 @@ static int unix_bind(struct socket *sock
1691     err = unix_autobind(sock);
1692     goto out;
1693     }
1694     + /***** TOMOYO Linux start. *****/
1695     + err = -EPERM;
1696     + if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
1697     + goto out;
1698     + /***** TOMOYO Linux end. *****/
1699    
1700     err = unix_mkname(sunaddr, addr_len, &hash);
1701     if (err < 0)
1702     @@ -781,6 +789,13 @@ static int unix_bind(struct socket *sock
1703     */
1704     mode = S_IFSOCK |
1705     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1706     + /***** TOMOYO Linux start. *****/
1707     + err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
1708     + if (!err)
1709     + err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry,
1710     + nd.mnt);
1711     + if (!err)
1712     + /***** TOMOYO Linux end. *****/
1713     err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1714     if (err)
1715     goto out_mknod_dput;

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