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

Subversion リポジトリの参照

Annotation of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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