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

Subversion リポジトリの参照

Annotation of /branches/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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