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

Subversion リポジトリの参照

Contents of /trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2794 - (show annotations) (download) (as text)
Thu Jul 23 05:17:11 2009 UTC (14 years, 10 months ago) by kumaneko
File MIME type: text/x-diff
File size: 47170 byte(s)


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

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