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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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