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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2796 - (show annotations) (download) (as text)
Thu Jul 23 09:07:39 2009 UTC (14 years, 10 months 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: 38328 byte(s)


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

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