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

Subversion リポジトリの参照

Contents of /trunk/1.5.x/ccs-patch/patches/ccs-patch-2.6.18.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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