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

Subversion リポジトリの参照

Contents of /trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.21.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2306 - (show annotations) (download) (as text)
Tue Mar 24 05:35:12 2009 UTC (15 years, 2 months ago) by kumaneko
File MIME type: text/x-diff
File size: 43806 byte(s)


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

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