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

Subversion リポジトリの参照

Contents of /branches/ccs-patch/patches/ccs-patch-2.4.37.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2290 - (show annotations) (download) (as text)
Sat Mar 21 02:09:49 2009 UTC (15 years, 2 months ago) by kumaneko
Original Path: trunk/1.6.x/ccs-patch/patches/ccs-patch-2.4.37.diff
File MIME type: text/x-diff
File size: 54092 byte(s)


1 This is TOMOYO Linux patch for kernel 2.4.37.
2
3 Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.tar.bz2
4 ---
5 Documentation/Configure.help | 86 ++++++++++++++++++++++++++++++++
6 arch/alpha/kernel/ptrace.c | 7 ++
7 arch/arm/kernel/ptrace.c | 7 ++
8 arch/cris/kernel/ptrace.c | 7 ++
9 arch/i386/kernel/ptrace.c | 7 ++
10 arch/ia64/ia32/sys_ia32.c | 7 ++
11 arch/ia64/kernel/ptrace.c | 7 ++
12 arch/m68k/kernel/ptrace.c | 7 ++
13 arch/mips/kernel/ptrace.c | 7 ++
14 arch/mips64/kernel/ptrace.c | 11 ++++
15 arch/parisc/kernel/ptrace.c | 7 ++
16 arch/ppc/kernel/ptrace.c | 7 ++
17 arch/ppc64/kernel/ptrace.c | 7 ++
18 arch/ppc64/kernel/ptrace32.c | 7 ++
19 arch/s390/kernel/ptrace.c | 7 ++
20 arch/s390x/kernel/ptrace.c | 7 ++
21 arch/sh/kernel/ptrace.c | 7 ++
22 arch/sh64/kernel/ptrace.c | 7 ++
23 arch/sparc/kernel/ptrace.c | 9 +++
24 arch/sparc64/kernel/ptrace.c | 9 +++
25 arch/x86_64/ia32/ptrace32.c | 7 ++
26 arch/x86_64/kernel/ptrace.c | 7 ++
27 fs/Config.in | 3 +
28 fs/Makefile | 2
29 fs/attr.c | 10 +++
30 fs/exec.c | 21 +++++++
31 fs/fcntl.c | 8 +++
32 fs/ioctl.c | 16 ++++++
33 fs/namei.c | 66 +++++++++++++++++++++++++
34 fs/namespace.c | 58 +++++++++++++++++++++-
35 fs/open.c | 30 +++++++++++
36 fs/proc/Makefile | 4 +
37 fs/proc/proc_misc.c | 5 +
38 include/linux/sched.h | 12 ++++
39 kernel/kmod.c | 5 +
40 kernel/module.c | 15 +++++
41 kernel/sched.c | 7 ++
42 kernel/signal.c | 15 +++++
43 kernel/sys.c | 19 +++++++
44 kernel/sysctl.c | 113 ++++++++++++++++++++++++++++++++++++++++++-
45 kernel/time.c | 15 +++++
46 net/core/datagram.c | 10 +++
47 net/ipv4/tcp_ipv4.c | 11 ++++
48 net/ipv4/udp.c | 11 ++++
49 net/ipv6/tcp_ipv6.c | 7 ++
50 net/ipv6/udp.c | 11 ++++
51 net/socket.c | 40 ++++++++++++++-
52 net/unix/af_unix.c | 8 +++
53 48 files changed, 757 insertions(+), 6 deletions(-)
54
55 --- linux-2.4.37.orig/Documentation/Configure.help
56 +++ linux-2.4.37/Documentation/Configure.help
57 @@ -29158,6 +29158,92 @@ CONFIG_SOUND_WM97XX
58
59 If unsure, say N.
60
61 +CONFIG_SAKURA
62 + Say Y here to support the Domain-Free Mandatory Access Control.
63 +
64 + SAKURA stands for
65 + "Security Advancement Know-how Upon Read-only Approach".
66 + As the name shows, SAKURA was originally a methodology to make
67 + root fs read-only to avoid tampering the system files.
68 + But now, SAKURA is not only a methodology but also a kernel patch
69 + that improves the system security with less effort.
70 +
71 + SAKURA can restrict operations that affect systemwide.
72 +
73 +CONFIG_TOMOYO
74 + Say Y here to support the Domain-Based Mandatory Access Control.
75 +
76 + TOMOYO stands for "Task Oriented Management Obviates Your Onus".
77 + TOMOYO is intended to provide the Domain-Based MAC
78 + utilizing task_struct.
79 +
80 + The word "domain" in TOMOYO is a class that a process
81 + (i.e. task_struct) belong to.
82 + The domain of a process changes whenever the process
83 + executes a program.
84 + This allows you to classify at the finest level.
85 + The access permission is granted to domains, not to processes.
86 + Policy is defined as "Which domain can access to which resource.".
87 +
88 + The biggest feature of TOMOYO is that TOMOYO has "learning mode".
89 + The learning mode can automatically generate policy definition,
90 + and dramatically reduces the policy definition labors.
91 +
92 + TOMOYO is applicable to figuring out the system's behavior, for
93 + TOMOYO uses the canonicalized absolute pathnames and
94 + TreeView style domain transitions.
95 +
96 + You can make custom root fs with minimum files
97 + to run minimum applications with TOMOYO.
98 +
99 +CONFIG_TOMOYO_MAX_ACCEPT_ENTRY
100 + This is the default value for maximal ACL entries
101 + that are automatically appended into policy at "learning mode".
102 + Some programs access thousands of objects, so running
103 + such programs in "learning mode" dulls the system response
104 + and consumes much memory.
105 + This is the safeguard for such programs.
106 +
107 +CONFIG_TOMOYO_MAX_GRANT_LOG
108 + This is the default value for maximal entries for
109 + access grant logs that the kernel can hold on memory.
110 + You can read the log via /proc/ccs/grant_log.
111 + If you don't need access grant logs,
112 + you may set this value to 0.
113 +
114 +CONFIG_TOMOYO_MAX_REJECT_LOG
115 + This is the default value for maximal entries for
116 + access reject logs that the kernel can hold on memory.
117 + You can read the log via /proc/ccs/reject_log.
118 + If you don't need access reject logs,
119 + you may set this value to 0.
120 +
121 +CONFIG_SYAORAN
122 + Say Y or M here to support the Tamper-Proof Device Filesystem.
123 +
124 + SYAORAN stands for
125 + "Simple Yet All-important Object Realizing Abiding Nexus".
126 + SYAORAN is a filesystem for /dev with Mandatory Access Control.
127 +
128 + SAKURA can make root fs read-only, but the system can't work
129 + if /dev is read-only. Therefore you need to mount a writable
130 + filesystem (such as tmpfs) for /dev if root fs is read-only.
131 +
132 + But the writable /dev means that files on /dev might be tampered.
133 + For example, if /dev/null is deleted and re-created as a symbolic
134 + link to /dev/hda by an attacker, the contents of the IDE HDD
135 + will be destroyed at a blow.
136 +
137 + Also, TOMOYO controls file access by pathnames,
138 + not by security labels.
139 + Therefore /dev/null, for example, might be tampered
140 + if a process have write permission to /dev/null .
141 +
142 + SYAORAN can ensure /dev/null is a character device file
143 + with major=1 minor=3.
144 +
145 + You can use SAKURA to make /dev not unmountable.
146 +
147 #
148 # A couple of things I keep forgetting:
149 # capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet,
150 --- linux-2.4.37.orig/arch/alpha/kernel/ptrace.c
151 +++ linux-2.4.37/arch/alpha/kernel/ptrace.c
152 @@ -18,6 +18,9 @@
153 #include <asm/pgtable.h>
154 #include <asm/system.h>
155 #include <asm/fpu.h>
156 +/***** TOMOYO Linux start. *****/
157 +#include <linux/tomoyo.h>
158 +/***** TOMOYO Linux end. *****/
159
160 #include "proto.h"
161
162 @@ -251,6 +254,10 @@ sys_ptrace(long request, long pid, long
163 {
164 struct task_struct *child;
165 long ret;
166 + /***** TOMOYO Linux start. *****/
167 + if (!ccs_capable(CCS_SYS_PTRACE))
168 + return -EPERM;
169 + /***** TOMOYO Linux end. *****/
170
171 lock_kernel();
172 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
173 --- linux-2.4.37.orig/arch/arm/kernel/ptrace.c
174 +++ linux-2.4.37/arch/arm/kernel/ptrace.c
175 @@ -22,6 +22,9 @@
176 #include <asm/uaccess.h>
177 #include <asm/pgtable.h>
178 #include <asm/system.h>
179 +/***** TOMOYO Linux start. *****/
180 +#include <linux/tomoyo.h>
181 +/***** TOMOYO Linux end. *****/
182
183 #include "ptrace.h"
184
185 @@ -695,6 +698,10 @@ asmlinkage int sys_ptrace(long request,
186 {
187 struct task_struct *child;
188 int ret;
189 + /***** TOMOYO Linux start. *****/
190 + if (!ccs_capable(CCS_SYS_PTRACE))
191 + return -EPERM;
192 + /***** TOMOYO Linux end. *****/
193
194 lock_kernel();
195 ret = -EPERM;
196 --- linux-2.4.37.orig/arch/cris/kernel/ptrace.c
197 +++ linux-2.4.37/arch/cris/kernel/ptrace.c
198 @@ -48,6 +48,9 @@
199 #include <asm/pgtable.h>
200 #include <asm/system.h>
201 #include <asm/processor.h>
202 +/***** TOMOYO Linux start. *****/
203 +#include <linux/tomoyo.h>
204 +/***** TOMOYO Linux end. *****/
205
206 /*
207 * does not yet catch signals sent when the child dies.
208 @@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request,
209 {
210 struct task_struct *child;
211 int ret;
212 + /***** TOMOYO Linux start. *****/
213 + if (!ccs_capable(CCS_SYS_PTRACE))
214 + return -EPERM;
215 + /***** TOMOYO Linux end. *****/
216
217 lock_kernel();
218 ret = -EPERM;
219 --- linux-2.4.37.orig/arch/i386/kernel/ptrace.c
220 +++ linux-2.4.37/arch/i386/kernel/ptrace.c
221 @@ -20,6 +20,9 @@
222 #include <asm/processor.h>
223 #include <asm/i387.h>
224 #include <asm/debugreg.h>
225 +/***** TOMOYO Linux start. *****/
226 +#include <linux/tomoyo.h>
227 +/***** TOMOYO Linux end. *****/
228
229 /*
230 * does not yet catch signals sent when the child dies.
231 @@ -152,6 +155,10 @@ asmlinkage int sys_ptrace(long request,
232 struct task_struct *child;
233 struct user * dummy = NULL;
234 int i, ret;
235 + /***** TOMOYO Linux start. *****/
236 + if (!ccs_capable(CCS_SYS_PTRACE))
237 + return -EPERM;
238 + /***** TOMOYO Linux end. *****/
239
240 lock_kernel();
241 ret = -EPERM;
242 --- linux-2.4.37.orig/arch/ia64/ia32/sys_ia32.c
243 +++ linux-2.4.37/arch/ia64/ia32/sys_ia32.c
244 @@ -57,6 +57,9 @@
245 #include <net/scm.h>
246 #include <net/sock.h>
247 #include <asm/ia32.h>
248 +/***** TOMOYO Linux start. *****/
249 +#include <linux/tomoyo.h>
250 +/***** TOMOYO Linux end. *****/
251
252 #define DEBUG 0
253
254 @@ -3131,6 +3134,10 @@ sys32_ptrace (int request, pid_t pid, un
255 struct task_struct *child;
256 unsigned int value, tmp;
257 long i, ret;
258 + /***** TOMOYO Linux start. *****/
259 + if (!ccs_capable(CCS_SYS_PTRACE))
260 + return -EPERM;
261 + /***** TOMOYO Linux end. *****/
262
263 lock_kernel();
264 if (request == PTRACE_TRACEME) {
265 --- linux-2.4.37.orig/arch/ia64/kernel/ptrace.c
266 +++ linux-2.4.37/arch/ia64/kernel/ptrace.c
267 @@ -27,6 +27,9 @@
268 #ifdef CONFIG_PERFMON
269 #include <asm/perfmon.h>
270 #endif
271 +/***** TOMOYO Linux start. *****/
272 +#include <linux/tomoyo.h>
273 +/***** TOMOYO Linux end. *****/
274
275 #define offsetof(type,field) ((unsigned long) &((type *) 0)->field)
276
277 @@ -1273,6 +1276,10 @@ sys_ptrace (long request, pid_t pid, uns
278 struct task_struct *child;
279 struct switch_stack *sw;
280 long ret;
281 + /***** TOMOYO Linux start. *****/
282 + if (!ccs_capable(CCS_SYS_PTRACE))
283 + return -EPERM;
284 + /***** TOMOYO Linux end. *****/
285
286 lock_kernel();
287 ret = -EPERM;
288 --- linux-2.4.37.orig/arch/m68k/kernel/ptrace.c
289 +++ linux-2.4.37/arch/m68k/kernel/ptrace.c
290 @@ -25,6 +25,9 @@
291 #include <asm/pgtable.h>
292 #include <asm/system.h>
293 #include <asm/processor.h>
294 +/***** TOMOYO Linux start. *****/
295 +#include <linux/tomoyo.h>
296 +/***** TOMOYO Linux end. *****/
297
298 /*
299 * does not yet catch signals sent when the child dies.
300 @@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request,
301 {
302 struct task_struct *child;
303 int ret;
304 + /***** TOMOYO Linux start. *****/
305 + if (!ccs_capable(CCS_SYS_PTRACE))
306 + return -EPERM;
307 + /***** TOMOYO Linux end. *****/
308
309 lock_kernel();
310 ret = -EPERM;
311 --- linux-2.4.37.orig/arch/mips/kernel/ptrace.c
312 +++ linux-2.4.37/arch/mips/kernel/ptrace.c
313 @@ -28,6 +28,9 @@
314 #include <asm/bootinfo.h>
315 #include <asm/cpu.h>
316 #include <asm/fpu.h>
317 +/***** TOMOYO Linux start. *****/
318 +#include <linux/tomoyo.h>
319 +/***** TOMOYO Linux end. *****/
320
321 /*
322 * Called by kernel/ptrace.c when detaching..
323 @@ -43,6 +46,10 @@ asmlinkage int sys_ptrace(long request,
324 {
325 struct task_struct *child;
326 int ret;
327 + /***** TOMOYO Linux start. *****/
328 + if (!ccs_capable(CCS_SYS_PTRACE))
329 + return -EPERM;
330 + /***** TOMOYO Linux end. *****/
331
332 lock_kernel();
333 #if 0
334 --- linux-2.4.37.orig/arch/mips64/kernel/ptrace.c
335 +++ linux-2.4.37/arch/mips64/kernel/ptrace.c
336 @@ -30,6 +30,9 @@
337 #include <asm/system.h>
338 #include <asm/uaccess.h>
339 #include <asm/bootinfo.h>
340 +/***** TOMOYO Linux start. *****/
341 +#include <linux/tomoyo.h>
342 +/***** TOMOYO Linux end. *****/
343
344 /*
345 * Called by kernel/ptrace.c when detaching..
346 @@ -49,6 +52,10 @@ asmlinkage int sys32_ptrace(int request,
347 {
348 struct task_struct *child;
349 int ret;
350 + /***** TOMOYO Linux start. *****/
351 + if (!ccs_capable(CCS_SYS_PTRACE))
352 + return -EPERM;
353 + /***** TOMOYO Linux end. *****/
354
355 lock_kernel();
356 ret = -EPERM;
357 @@ -288,6 +295,10 @@ asmlinkage int sys_ptrace(long request,
358 {
359 struct task_struct *child;
360 int ret;
361 + /***** TOMOYO Linux start. *****/
362 + if (!ccs_capable(CCS_SYS_PTRACE))
363 + return -EPERM;
364 + /***** TOMOYO Linux end. *****/
365
366 lock_kernel();
367 #if 0
368 --- linux-2.4.37.orig/arch/parisc/kernel/ptrace.c
369 +++ linux-2.4.37/arch/parisc/kernel/ptrace.c
370 @@ -21,6 +21,9 @@
371 #include <asm/system.h>
372 #include <asm/processor.h>
373 #include <asm/offset.h>
374 +/***** TOMOYO Linux start. *****/
375 +#include <linux/tomoyo.h>
376 +/***** TOMOYO Linux end. *****/
377
378 /* These are used in entry.S, syscall_restore_rfi. We need to record the
379 * current stepping mode somewhere other than in PSW, because there is no
380 @@ -94,6 +97,10 @@ long sys_ptrace(long request, pid_t pid,
381 #ifdef DEBUG_PTRACE
382 long oaddr=addr, odata=data;
383 #endif
384 + /***** TOMOYO Linux start. *****/
385 + if (!ccs_capable(CCS_SYS_PTRACE))
386 + return -EPERM;
387 + /***** TOMOYO Linux end. *****/
388
389 lock_kernel();
390 ret = -EPERM;
391 --- linux-2.4.37.orig/arch/ppc/kernel/ptrace.c
392 +++ linux-2.4.37/arch/ppc/kernel/ptrace.c
393 @@ -29,6 +29,9 @@
394 #include <asm/page.h>
395 #include <asm/pgtable.h>
396 #include <asm/system.h>
397 +/***** TOMOYO Linux start. *****/
398 +#include <linux/tomoyo.h>
399 +/***** TOMOYO Linux end. *****/
400
401 /*
402 * Set of msr bits that gdb can change on behalf of a process.
403 @@ -171,6 +174,10 @@ int sys_ptrace(long request, long pid, l
404 {
405 struct task_struct *child;
406 int ret = -EPERM;
407 + /***** TOMOYO Linux start. *****/
408 + if (!ccs_capable(CCS_SYS_PTRACE))
409 + return -EPERM;
410 + /***** TOMOYO Linux end. *****/
411
412 lock_kernel();
413 if (request == PTRACE_TRACEME) {
414 --- linux-2.4.37.orig/arch/ppc64/kernel/ptrace.c
415 +++ linux-2.4.37/arch/ppc64/kernel/ptrace.c
416 @@ -30,6 +30,9 @@
417 #include <asm/page.h>
418 #include <asm/pgtable.h>
419 #include <asm/system.h>
420 +/***** TOMOYO Linux start. *****/
421 +#include <linux/tomoyo.h>
422 +/***** TOMOYO Linux end. *****/
423
424 /*
425 * Set of msr bits that gdb can change on behalf of a process.
426 @@ -120,6 +123,10 @@ int sys_ptrace(long request, long pid, l
427 {
428 struct task_struct *child;
429 int ret = -EPERM;
430 + /***** TOMOYO Linux start. *****/
431 + if (!ccs_capable(CCS_SYS_PTRACE))
432 + return -EPERM;
433 + /***** TOMOYO Linux end. *****/
434
435 lock_kernel();
436 if (request == PTRACE_TRACEME) {
437 --- linux-2.4.37.orig/arch/ppc64/kernel/ptrace32.c
438 +++ linux-2.4.37/arch/ppc64/kernel/ptrace32.c
439 @@ -30,6 +30,9 @@
440 #include <asm/page.h>
441 #include <asm/pgtable.h>
442 #include <asm/system.h>
443 +/***** TOMOYO Linux start. *****/
444 +#include <linux/tomoyo.h>
445 +/***** TOMOYO Linux end. *****/
446
447 #ifdef CONFIG_ALTIVEC
448 /*
449 @@ -121,6 +124,10 @@ int sys32_ptrace(long request, long pid,
450 {
451 struct task_struct *child;
452 int ret = -EPERM;
453 + /***** TOMOYO Linux start. *****/
454 + if (!ccs_capable(CCS_SYS_PTRACE))
455 + return -EPERM;
456 + /***** TOMOYO Linux end. *****/
457
458 lock_kernel();
459 if (request == PTRACE_TRACEME) {
460 --- linux-2.4.37.orig/arch/s390/kernel/ptrace.c
461 +++ linux-2.4.37/arch/s390/kernel/ptrace.c
462 @@ -37,6 +37,9 @@
463 #include <asm/pgalloc.h>
464 #include <asm/system.h>
465 #include <asm/uaccess.h>
466 +/***** TOMOYO Linux start. *****/
467 +#include <linux/tomoyo.h>
468 +/***** TOMOYO Linux end. *****/
469
470
471 void FixPerRegisters(struct task_struct *task)
472 @@ -221,6 +224,10 @@ asmlinkage int sys_ptrace(long request,
473 unsigned long tmp;
474 int copied;
475 ptrace_area parea;
476 + /***** TOMOYO Linux start. *****/
477 + if (!ccs_capable(CCS_SYS_PTRACE))
478 + return -EPERM;
479 + /***** TOMOYO Linux end. *****/
480
481 lock_kernel();
482 if (request == PTRACE_TRACEME)
483 --- linux-2.4.37.orig/arch/s390x/kernel/ptrace.c
484 +++ linux-2.4.37/arch/s390x/kernel/ptrace.c
485 @@ -43,6 +43,9 @@
486 #else
487 #define parent_31bit 0
488 #endif
489 +/***** TOMOYO Linux start. *****/
490 +#include <linux/tomoyo.h>
491 +/***** TOMOYO Linux end. *****/
492
493
494 void FixPerRegisters(struct task_struct *task)
495 @@ -431,6 +434,10 @@ asmlinkage int sys_ptrace(long request,
496 #define sizeof_parent_long 8
497 #define dataptr (u8 *)&data
498 #endif
499 + /***** TOMOYO Linux start. *****/
500 + if (!ccs_capable(CCS_SYS_PTRACE))
501 + return -EPERM;
502 + /***** TOMOYO Linux end. *****/
503 lock_kernel();
504 if (request == PTRACE_TRACEME)
505 {
506 --- linux-2.4.37.orig/arch/sh/kernel/ptrace.c
507 +++ linux-2.4.37/arch/sh/kernel/ptrace.c
508 @@ -26,6 +26,9 @@
509 #include <asm/system.h>
510 #include <asm/processor.h>
511 #include <asm/mmu_context.h>
512 +/***** TOMOYO Linux start. *****/
513 +#include <linux/tomoyo.h>
514 +/***** TOMOYO Linux end. *****/
515
516 /*
517 * does not yet catch signals sent when the child dies.
518 @@ -144,6 +147,10 @@ asmlinkage int sys_ptrace(long request,
519 struct task_struct *child, *tsk = current;
520 struct user * dummy = NULL;
521 int ret;
522 + /***** TOMOYO Linux start. *****/
523 + if (!ccs_capable(CCS_SYS_PTRACE))
524 + return -EPERM;
525 + /***** TOMOYO Linux end. *****/
526
527 lock_kernel();
528 ret = -EPERM;
529 --- linux-2.4.37.orig/arch/sh64/kernel/ptrace.c
530 +++ linux-2.4.37/arch/sh64/kernel/ptrace.c
531 @@ -32,6 +32,9 @@
532 #include <asm/system.h>
533 #include <asm/processor.h>
534 #include <asm/mmu_context.h>
535 +/***** TOMOYO Linux start. *****/
536 +#include <linux/tomoyo.h>
537 +/***** TOMOYO Linux end. *****/
538
539 /* This mask defines the bits of the SR which the user is not allowed to
540 change, which are everything except S, Q, M, PR, SZ, FR. */
541 @@ -122,6 +125,10 @@ asmlinkage int sys_ptrace(long request,
542 {
543 struct task_struct *child, *tsk = current;
544 int ret;
545 + /***** TOMOYO Linux start. *****/
546 + if (!ccs_capable(CCS_SYS_PTRACE))
547 + return -EPERM;
548 + /***** TOMOYO Linux end. *****/
549
550 lock_kernel();
551 ret = -EPERM;
552 --- linux-2.4.37.orig/arch/sparc/kernel/ptrace.c
553 +++ linux-2.4.37/arch/sparc/kernel/ptrace.c
554 @@ -21,6 +21,9 @@
555 #include <asm/pgtable.h>
556 #include <asm/system.h>
557 #include <asm/uaccess.h>
558 +/***** TOMOYO Linux start. *****/
559 +#include <linux/tomoyo.h>
560 +/***** TOMOYO Linux end. *****/
561
562 #define MAGIC_CONSTANT 0x80000000
563
564 @@ -262,6 +265,12 @@ asmlinkage void do_ptrace(struct pt_regs
565 unsigned long data = regs->u_regs[UREG_I3];
566 unsigned long addr2 = regs->u_regs[UREG_I4];
567 struct task_struct *child;
568 + /***** TOMOYO Linux start. *****/
569 + if (!ccs_capable(CCS_SYS_PTRACE)) {
570 + pt_error_return(regs, EPERM);
571 + return;
572 + }
573 + /***** TOMOYO Linux end. *****/
574
575 lock_kernel();
576 #ifdef DEBUG_PTRACE
577 --- linux-2.4.37.orig/arch/sparc64/kernel/ptrace.c
578 +++ linux-2.4.37/arch/sparc64/kernel/ptrace.c
579 @@ -26,6 +26,9 @@
580 #include <asm/psrcompat.h>
581 #include <asm/visasm.h>
582 #include <asm/spitfire.h>
583 +/***** TOMOYO Linux start. *****/
584 +#include <linux/tomoyo.h>
585 +/***** TOMOYO Linux end. *****/
586
587 #define MAGIC_CONSTANT 0x80000000
588
589 @@ -108,6 +111,12 @@ asmlinkage void do_ptrace(struct pt_regs
590 unsigned long data = regs->u_regs[UREG_I3];
591 unsigned long addr2 = regs->u_regs[UREG_I4];
592 struct task_struct *child;
593 + /***** TOMOYO Linux start. *****/
594 + if (!ccs_capable(CCS_SYS_PTRACE)) {
595 + pt_error_return(regs, EPERM);
596 + return;
597 + }
598 + /***** TOMOYO Linux end. *****/
599
600 if (current->thread.flags & SPARC_FLAG_32BIT) {
601 addr &= 0xffffffffUL;
602 --- linux-2.4.37.orig/arch/x86_64/ia32/ptrace32.c
603 +++ linux-2.4.37/arch/x86_64/ia32/ptrace32.c
604 @@ -24,6 +24,9 @@
605 #include <asm/i387.h>
606 #include <asm/fpu32.h>
607 #include <linux/mm.h>
608 +/***** TOMOYO Linux start. *****/
609 +#include <linux/tomoyo.h>
610 +/***** TOMOYO Linux end. *****/
611
612 /* determines which flags the user has access to. */
613 /* 1 = access 0 = no access */
614 @@ -203,6 +206,10 @@ asmlinkage long sys32_ptrace(long reques
615 struct pt_regs *childregs;
616 int ret;
617 __u32 val;
618 + /***** TOMOYO Linux start. *****/
619 + if (!ccs_capable(CCS_SYS_PTRACE))
620 + return -EPERM;
621 + /***** TOMOYO Linux end. *****/
622
623 switch (request) {
624 case PTRACE_TRACEME:
625 --- linux-2.4.37.orig/arch/x86_64/kernel/ptrace.c
626 +++ linux-2.4.37/arch/x86_64/kernel/ptrace.c
627 @@ -22,6 +22,9 @@
628 #include <asm/processor.h>
629 #include <asm/i387.h>
630 #include <asm/debugreg.h>
631 +/***** TOMOYO Linux start. *****/
632 +#include <linux/tomoyo.h>
633 +/***** TOMOYO Linux end. *****/
634
635 /*
636 * does not yet catch signals sent when the child dies.
637 @@ -180,6 +183,10 @@ asmlinkage long sys_ptrace(long request,
638 struct task_struct *child;
639 struct user * dummy = NULL;
640 long i, ret;
641 + /***** TOMOYO Linux start. *****/
642 + if (!ccs_capable(CCS_SYS_PTRACE))
643 + return -EPERM;
644 + /***** TOMOYO Linux end. *****/
645
646 /* This lock_kernel fixes a subtle race with suid exec */
647 lock_kernel();
648 --- linux-2.4.37.orig/fs/Config.in
649 +++ linux-2.4.37/fs/Config.in
650 @@ -176,4 +176,7 @@ comment 'Partition Types'
651 source fs/partitions/Config.in
652 endmenu
653 source fs/nls/Config.in
654 +
655 +source fs/Config.ccs.in
656 +
657 endmenu
658 --- linux-2.4.37.orig/fs/Makefile
659 +++ linux-2.4.37/fs/Makefile
660 @@ -80,5 +80,5 @@ obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
661 # persistent filesystems
662 obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
663
664 -
665 +include Makefile-2.4.ccs
666 include $(TOPDIR)/Rules.make
667 --- linux-2.4.37.orig/fs/attr.c
668 +++ linux-2.4.37/fs/attr.c
669 @@ -12,6 +12,9 @@
670 #include <linux/dnotify.h>
671 #include <linux/fcntl.h>
672 #include <linux/quotaops.h>
673 +/***** TOMOYO Linux start. *****/
674 +#include <linux/tomoyo.h>
675 +/***** TOMOYO Linux end. *****/
676
677 /* Taken over from the old code... */
678
679 @@ -127,6 +130,13 @@ int notify_change(struct dentry * dentry
680 attr->ia_atime = now;
681 if (!(ia_valid & ATTR_MTIME_SET))
682 attr->ia_mtime = now;
683 + /***** TOMOYO Linux start. *****/
684 + if ((ia_valid & ATTR_MODE) && !ccs_capable(CCS_SYS_CHMOD))
685 + return -EPERM;
686 + if ((ia_valid & (ATTR_UID | ATTR_GID)) &&
687 + !ccs_capable(CCS_SYS_CHOWN))
688 + return -EPERM;
689 + /***** TOMOYO Linux end. *****/
690
691 lock_kernel();
692 if (inode->i_op && inode->i_op->setattr)
693 --- linux-2.4.37.orig/fs/exec.c
694 +++ linux-2.4.37/fs/exec.c
695 @@ -48,6 +48,10 @@
696 #include <linux/kmod.h>
697 #endif
698
699 +/***** TOMOYO Linux start. *****/
700 +#include <linux/tomoyo.h>
701 +/***** TOMOYO Linux end. *****/
702 +
703 int core_uses_pid;
704 char core_pattern[65] = "core";
705 int core_setuid_ok = 0;
706 @@ -125,6 +129,13 @@ asmlinkage long sys_uselib(const char *
707 if (error)
708 goto exit;
709
710 + /***** TOMOYO Linux start. *****/
711 + /* 01 means "read". */
712 + error = ccs_check_open_permission(nd.dentry, nd.mnt, 01);
713 + if (error)
714 + goto exit;
715 + /***** TOMOYO Linux end. *****/
716 +
717 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
718 error = PTR_ERR(file);
719 if (IS_ERR(file))
720 @@ -389,6 +400,13 @@ struct file *open_exec(const char *name)
721 int err = permission(inode, MAY_EXEC);
722 if (!err && !(inode->i_mode & 0111))
723 err = -EACCES;
724 + /***** TOMOYO Linux start. *****/
725 + if (!err && (current->ccs_flags &
726 + CCS_CHECK_READ_FOR_OPEN_EXEC))
727 + /* 01 means "read". */
728 + err = ccs_check_open_permission(nd.dentry,
729 + nd.mnt, 01);
730 + /***** TOMOYO Linux end. *****/
731 file = ERR_PTR(err);
732 if (!err) {
733 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
734 @@ -986,7 +1004,8 @@ int do_execve(char * filename, char ** a
735 if (retval < 0)
736 goto out;
737
738 - retval = search_binary_handler(&bprm,regs);
739 + retval = search_binary_handler_with_transition(&bprm, regs);
740 +
741 if (retval >= 0)
742 /* execve success */
743 return retval;
744 --- linux-2.4.37.orig/fs/fcntl.c
745 +++ linux-2.4.37/fs/fcntl.c
746 @@ -16,6 +16,9 @@
747 #include <asm/poll.h>
748 #include <asm/siginfo.h>
749 #include <asm/uaccess.h>
750 +/***** TOMOYO Linux start. *****/
751 +#include <linux/tomoyo.h>
752 +/***** TOMOYO Linux end. *****/
753
754 extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg);
755 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
756 @@ -214,6 +217,11 @@ static int setfl(int fd, struct file * f
757 if (!(arg & O_APPEND) && IS_APPEND(inode))
758 return -EPERM;
759
760 + /***** TOMOYO Linux start. *****/
761 + if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp))
762 + return -EPERM;
763 + /***** TOMOYO Linux end. *****/
764 +
765 /* Did FASYNC state change? */
766 if ((arg ^ filp->f_flags) & FASYNC) {
767 if (filp->f_op && filp->f_op->fasync) {
768 --- linux-2.4.37.orig/fs/ioctl.c
769 +++ linux-2.4.37/fs/ioctl.c
770 @@ -10,6 +10,9 @@
771
772 #include <asm/uaccess.h>
773 #include <asm/ioctls.h>
774 +/***** TOMOYO Linux start. *****/
775 +#include <linux/tomoyo.h>
776 +/***** TOMOYO Linux end. *****/
777
778 static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
779 {
780 @@ -55,6 +58,13 @@ asmlinkage long sys_ioctl(unsigned int f
781 filp = fget(fd);
782 if (!filp)
783 goto out;
784 + /***** TOMOYO Linux start. *****/
785 + error = ccs_check_ioctl_permission(filp, cmd, arg);
786 + if (error) {
787 + fput(filp);
788 + goto out;
789 + }
790 + /***** TOMOYO Linux end. *****/
791 error = 0;
792 lock_kernel();
793 switch (cmd) {
794 @@ -112,6 +122,12 @@ asmlinkage long sys_ioctl(unsigned int f
795 error = -ENOTTY;
796 break;
797 default:
798 + /***** TOMOYO Linux start. *****/
799 + if (!ccs_capable(CCS_SYS_IOCTL)) {
800 + error = -EPERM;
801 + break;
802 + }
803 + /***** TOMOYO Linux end. *****/
804 error = -ENOTTY;
805 if (S_ISREG(filp->f_dentry->d_inode->i_mode))
806 error = file_ioctl(filp, cmd, arg);
807 --- linux-2.4.37.orig/fs/namei.c
808 +++ linux-2.4.37/fs/namei.c
809 @@ -28,6 +28,11 @@
810
811 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
812
813 +/***** TOMOYO Linux start. *****/
814 +#include <linux/tomoyo.h>
815 +#include <linux/module.h>
816 +/***** TOMOYO Linux end. *****/
817 +
818 /* [Feb-1997 T. Schoebel-Theuer]
819 * Fundamental changes in the pathname lookup mechanisms (namei)
820 * were necessary because of omirr. The reason is that omirr needs
821 @@ -1003,6 +1008,9 @@ exit_lock:
822 return error;
823 }
824
825 +/***** TOMOYO Linux start. *****/
826 +#include <linux/tomoyo_vfs.h>
827 +/***** TOMOYO Linux end. *****/
828 /*
829 * open_namei()
830 *
831 @@ -1068,6 +1076,13 @@ do_last:
832
833 /* Negative dentry, just create the file */
834 if (!dentry->d_inode) {
835 + /***** TOMOYO Linux start. *****/
836 + error = ccs_check_mknod_permission(dir->d_inode, dentry,
837 + nd->mnt,
838 + mode & ~current->fs->umask,
839 + 0);
840 + if (!error)
841 + /***** TOMOYO Linux end. *****/
842 error = vfs_create(dir->d_inode, dentry,
843 mode & ~current->fs->umask);
844 up(&dir->d_inode->i_sem);
845 @@ -1154,6 +1169,13 @@ ok:
846 goto exit;
847 }
848
849 + /***** TOMOYO Linux start. *****/
850 + /* includes O_APPEND and O_TRUNC checks */
851 + error = ccs_check_open_permission(dentry, nd->mnt, flag);
852 + if (error)
853 + goto exit;
854 + /***** TOMOYO Linux end. *****/
855 +
856 /*
857 * Ensure there are no outstanding leases on the file.
858 */
859 @@ -1292,6 +1314,7 @@ asmlinkage long sys_mknod(const char * f
860
861 if (S_ISDIR(mode))
862 return -EPERM;
863 +
864 tmp = getname(filename);
865 if (IS_ERR(tmp))
866 return PTR_ERR(tmp);
867 @@ -1304,6 +1327,11 @@ asmlinkage long sys_mknod(const char * f
868
869 mode &= ~current->fs->umask;
870 if (!IS_ERR(dentry)) {
871 + /***** TOMOYO Linux start. *****/
872 + error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
873 + nd.mnt, mode, dev);
874 + if (!error)
875 + /***** TOMOYO Linux end. *****/
876 switch (mode & S_IFMT) {
877 case 0: case S_IFREG:
878 error = vfs_create(nd.dentry->d_inode,dentry,mode);
879 @@ -1370,6 +1398,12 @@ asmlinkage long sys_mkdir(const char * p
880 dentry = lookup_create(&nd, 1);
881 error = PTR_ERR(dentry);
882 if (!IS_ERR(dentry)) {
883 + /***** TOMOYO Linux start. *****/
884 + error = ccs_check_mkdir_permission(nd.dentry->d_inode,
885 + dentry, nd.mnt,
886 + mode);
887 + if (!error)
888 + /***** TOMOYO Linux end. *****/
889 error = vfs_mkdir(nd.dentry->d_inode, dentry,
890 mode & ~current->fs->umask);
891 dput(dentry);
892 @@ -1479,6 +1513,11 @@ asmlinkage long sys_rmdir(const char * p
893 dentry = lookup_hash(&nd.last, nd.dentry);
894 error = PTR_ERR(dentry);
895 if (!IS_ERR(dentry)) {
896 + /***** TOMOYO Linux start. *****/
897 + error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,
898 + nd.mnt);
899 + if (!error)
900 + /***** TOMOYO Linux end. *****/
901 error = vfs_rmdir(nd.dentry->d_inode, dentry);
902 dput(dentry);
903 }
904 @@ -1548,6 +1587,11 @@ asmlinkage long sys_unlink(const char *
905 /* Why not before? Because we want correct error value */
906 if (nd.last.name[nd.last.len])
907 goto slashes;
908 + /***** TOMOYO Linux start. *****/
909 + error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,
910 + nd.mnt);
911 + if (!error)
912 + /***** TOMOYO Linux end. *****/
913 error = vfs_unlink(nd.dentry->d_inode, dentry);
914 exit2:
915 dput(dentry);
916 @@ -1612,6 +1656,12 @@ asmlinkage long sys_symlink(const char *
917 dentry = lookup_create(&nd, 0);
918 error = PTR_ERR(dentry);
919 if (!IS_ERR(dentry)) {
920 + /***** TOMOYO Linux start. *****/
921 + error = ccs_check_symlink_permission(nd.dentry->d_inode,
922 + dentry, nd.mnt,
923 + from);
924 + if (!error)
925 + /***** TOMOYO Linux end. *****/
926 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
927 dput(dentry);
928 }
929 @@ -1698,6 +1748,12 @@ asmlinkage long sys_link(const char * ol
930 new_dentry = lookup_create(&nd, 0);
931 error = PTR_ERR(new_dentry);
932 if (!IS_ERR(new_dentry)) {
933 + /***** TOMOYO Linux start. *****/
934 + error = ccs_check_link_permission(old_nd.dentry,
935 + nd.dentry->d_inode,
936 + new_dentry, nd.mnt);
937 + if (!error)
938 + /***** TOMOYO Linux end. *****/
939 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
940 dput(new_dentry);
941 }
942 @@ -1928,12 +1984,22 @@ static inline int do_rename(const char *
943 error = PTR_ERR(new_dentry);
944 if (IS_ERR(new_dentry))
945 goto exit4;
946 + /***** TOMOYO Linux start. *****/
947 + error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,
948 + new_dir->d_inode, new_dentry,
949 + newnd.mnt);
950 + if (error)
951 + goto exit5;
952 + /***** TOMOYO Linux end. *****/
953
954 lock_kernel();
955 error = vfs_rename(old_dir->d_inode, old_dentry,
956 new_dir->d_inode, new_dentry);
957 unlock_kernel();
958
959 + /***** TOMOYO Linux start. *****/
960 +exit5:
961 + /***** TOMOYO Linux end. *****/
962 dput(new_dentry);
963 exit4:
964 dput(old_dentry);
965 --- linux-2.4.37.orig/fs/namespace.c
966 +++ linux-2.4.37/fs/namespace.c
967 @@ -21,6 +21,13 @@
968 #include <linux/seq_file.h>
969 #include <linux/namespace.h>
970
971 +/***** SAKURA Linux start. *****/
972 +#include <linux/sakura.h>
973 +/***** SAKURA Linux end. *****/
974 +/***** TOMOYO Linux start. *****/
975 +#include <linux/tomoyo.h>
976 +/***** TOMOYO Linux end. *****/
977 +
978 struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
979 int do_remount_sb(struct super_block *sb, int flags, void * data);
980 void kill_super(struct super_block *sb);
981 @@ -290,6 +297,10 @@ static int do_umount(struct vfsmount *mn
982 {
983 struct super_block * sb = mnt->mnt_sb;
984 int retval = 0;
985 + /***** SAKURA Linux start. *****/
986 + if (ccs_may_umount(mnt))
987 + return -EPERM;
988 + /***** SAKURA Linux end. *****/
989
990 /*
991 * If we may have to abort operations to get out of this
992 @@ -365,6 +376,10 @@ asmlinkage long sys_umount(char * name,
993 {
994 struct nameidata nd;
995 int retval;
996 + /***** TOMOYO Linux start. *****/
997 + if (!ccs_capable(CCS_SYS_UMOUNT))
998 + return -EPERM;
999 + /***** TOMOYO Linux end. *****/
1000
1001 retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd);
1002 if (retval)
1003 @@ -500,6 +515,11 @@ static int do_loopback(struct nameidata
1004 down_write(&current->namespace->sem);
1005 err = -EINVAL;
1006 if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {
1007 + /***** SAKURA Linux start. *****/
1008 + err = -EPERM;
1009 + if (ccs_may_mount(nd))
1010 + goto out;
1011 + /***** SAKURA Linux end. *****/
1012 err = -ENOMEM;
1013 if (recurse)
1014 mnt = copy_tree(old_nd.mnt, old_nd.dentry);
1015 @@ -516,7 +536,9 @@ static int do_loopback(struct nameidata
1016 } else
1017 mntput(mnt);
1018 }
1019 -
1020 + /***** SAKURA Linux start. *****/
1021 + out:
1022 + /***** SAKURA Linux end. *****/
1023 up_write(&current->namespace->sem);
1024 path_release(&old_nd);
1025 return err;
1026 @@ -570,6 +592,12 @@ static int do_move_mount(struct nameidat
1027 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
1028 goto out;
1029
1030 + /***** SAKURA Linux start. *****/
1031 + err = -EPERM;
1032 + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
1033 + goto out;
1034 + /***** SAKURA Linux end. *****/
1035 +
1036 err = -ENOENT;
1037 down(&nd->dentry->d_inode->i_zombie);
1038 if (IS_DEADDIR(nd->dentry->d_inode))
1039 @@ -641,6 +669,12 @@ static int do_add_mount(struct nameidata
1040 if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry)
1041 goto unlock;
1042
1043 + /***** SAKURA Linux start. *****/
1044 + err = -EPERM;
1045 + if (ccs_may_mount(nd))
1046 + goto unlock;
1047 + /***** SAKURA Linux end. *****/
1048 +
1049 mnt->mnt_flags = mnt_flags;
1050 err = graft_tree(mnt, nd);
1051 unlock:
1052 @@ -718,6 +752,17 @@ long do_mount(char * dev_name, char * di
1053 if (data_page)
1054 ((char *)data_page)[PAGE_SIZE - 1] = 0;
1055
1056 + /***** TOMOYO Linux start. *****/
1057 + if (!ccs_capable(CCS_SYS_MOUNT))
1058 + return -EPERM;
1059 + /***** TOMOYO Linux end. *****/
1060 + /***** SAKURA Linux start. *****/
1061 + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
1062 + &flags);
1063 + if (retval)
1064 + return retval;
1065 + /***** SAKURA Linux end. *****/
1066 +
1067 /* Separate the per-mountpoint flags */
1068 if (flags & MS_NOSUID)
1069 mnt_flags |= MNT_NOSUID;
1070 @@ -911,6 +956,10 @@ asmlinkage long sys_pivot_root(const cha
1071
1072 if (!capable(CAP_SYS_ADMIN))
1073 return -EPERM;
1074 + /***** TOMOYO Linux start. *****/
1075 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
1076 + return -EPERM;
1077 + /***** TOMOYO Linux end. *****/
1078
1079 lock_kernel();
1080
1081 @@ -925,6 +974,13 @@ asmlinkage long sys_pivot_root(const cha
1082 if (error)
1083 goto out1;
1084
1085 + /***** SAKURA Linux start. *****/
1086 + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
1087 + if (error) {
1088 + path_release(&old_nd);
1089 + goto out1;
1090 + }
1091 + /***** SAKURA Linux end. *****/
1092 read_lock(&current->fs->lock);
1093 user_nd.mnt = mntget(current->fs->rootmnt);
1094 user_nd.dentry = dget(current->fs->root);
1095 --- linux-2.4.37.orig/fs/open.c
1096 +++ linux-2.4.37/fs/open.c
1097 @@ -20,6 +20,13 @@
1098
1099 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1100
1101 +/***** SAKURA Linux start. *****/
1102 +#include <linux/sakura.h>
1103 +/***** SAKURA Linux end. *****/
1104 +/***** TOMOYO Linux start. *****/
1105 +#include <linux/tomoyo.h>
1106 +/***** TOMOYO Linux end. *****/
1107 +
1108 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1109 {
1110 int retval = -ENODEV;
1111 @@ -164,6 +171,11 @@ static inline long do_sys_truncate(const
1112 if (error)
1113 goto dput_and_out;
1114
1115 + /***** TOMOYO Linux start. *****/
1116 + error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);
1117 + if (!error)
1118 + /***** TOMOYO Linux end. *****/
1119 +
1120 error = locks_verify_truncate(inode, NULL, length);
1121 if (!error) {
1122 DQUOT_INIT(inode);
1123 @@ -217,6 +229,12 @@ static inline long do_sys_ftruncate(unsi
1124 if (IS_APPEND(inode))
1125 goto out_putf;
1126
1127 + /***** TOMOYO Linux start. *****/
1128 + error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
1129 + 0);
1130 + if (error)
1131 + goto out_putf;
1132 + /***** TOMOYO Linux end. *****/
1133 error = locks_verify_truncate(inode, file, length);
1134 if (!error)
1135 error = do_truncate(dentry, length);
1136 @@ -466,6 +484,14 @@ asmlinkage long sys_chroot(const char *
1137 error = -EPERM;
1138 if (!capable(CAP_SYS_CHROOT))
1139 goto dput_and_out;
1140 + /***** TOMOYO Linux start. *****/
1141 + if (!ccs_capable(CCS_SYS_CHROOT))
1142 + goto dput_and_out;
1143 + /***** TOMOYO Linux end. *****/
1144 + /***** SAKURA Linux start. *****/
1145 + if (ccs_check_chroot_permission(&nd))
1146 + goto dput_and_out;
1147 + /***** SAKURA Linux end. *****/
1148
1149 set_fs_root(current->fs, nd.mnt, nd.dentry);
1150 set_fs_altroot();
1151 @@ -897,6 +923,10 @@ out_unlock:
1152 */
1153 asmlinkage long sys_vhangup(void)
1154 {
1155 + /***** TOMOYO Linux start. *****/
1156 + if (!ccs_capable(CCS_SYS_VHANGUP))
1157 + return -EPERM;
1158 + /***** TOMOYO Linux end. *****/
1159 if (capable(CAP_SYS_TTY_CONFIG)) {
1160 tty_vhangup(current->tty);
1161 return 0;
1162 --- linux-2.4.37.orig/fs/proc/Makefile
1163 +++ linux-2.4.37/fs/proc/Makefile
1164 @@ -18,4 +18,8 @@ ifeq ($(CONFIG_PROC_DEVICETREE),y)
1165 obj-y += proc_devtree.o
1166 endif
1167
1168 +export-objs += ccs_proc.o
1169 +obj-$(CONFIG_SAKURA) += ccs_proc.o
1170 +obj-$(CONFIG_TOMOYO) += ccs_proc.o
1171 +
1172 include $(TOPDIR)/Rules.make
1173 --- linux-2.4.37.orig/fs/proc/proc_misc.c
1174 +++ linux-2.4.37/fs/proc/proc_misc.c
1175 @@ -670,4 +670,9 @@ void __init proc_misc_init(void)
1176 entry->proc_fops = &ppc_htab_operations;
1177 }
1178 #endif
1179 + /***** CCS start. *****/
1180 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
1181 + printk(KERN_INFO "Hook version: 2.4.37 2009/03/18\n");
1182 +#endif
1183 + /***** CCS end. *****/
1184 }
1185 --- linux-2.4.37.orig/include/linux/sched.h
1186 +++ linux-2.4.37/include/linux/sched.h
1187 @@ -29,6 +29,10 @@ extern unsigned long event;
1188
1189 struct exec_domain;
1190
1191 +/***** TOMOYO Linux start. *****/
1192 +struct ccs_domain_info;
1193 +/***** TOMOYO Linux end. *****/
1194 +
1195 /*
1196 * cloning flags:
1197 */
1198 @@ -417,6 +421,10 @@ struct task_struct {
1199 void *journal_info;
1200
1201 struct list_head *scm_work_list;
1202 + /***** TOMOYO Linux start. *****/
1203 + struct ccs_domain_info *ccs_domain_info;
1204 + u32 ccs_flags;
1205 + /***** TOMOYO Linux end. *****/
1206 };
1207
1208 /*
1209 @@ -512,6 +520,10 @@ extern struct exec_domain default_exec_d
1210 blocked: {{0}}, \
1211 alloc_lock: SPIN_LOCK_UNLOCKED, \
1212 journal_info: NULL, \
1213 + /***** TOMOYO Linux start. *****/ \
1214 + ccs_domain_info: NULL, \
1215 + ccs_flags: 0 \
1216 + /***** TOMOYO Linux end. *****/ \
1217 }
1218
1219
1220 --- linux-2.4.37.orig/kernel/kmod.c
1221 +++ linux-2.4.37/kernel/kmod.c
1222 @@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa
1223 /* Allow execve args to be in kernel space. */
1224 set_fs(KERNEL_DS);
1225
1226 + /***** TOMOYO Linux start. *****/
1227 + current->ccs_domain_info = NULL;
1228 + current->ccs_flags = 0;
1229 + /***** TOMOYO Linux end. *****/
1230 +
1231 /* Go, go, go... */
1232 if (execve(program_path, argv, envp) < 0)
1233 return -errno;
1234 --- linux-2.4.37.orig/kernel/module.c
1235 +++ linux-2.4.37/kernel/module.c
1236 @@ -10,6 +10,9 @@
1237 #include <linux/slab.h>
1238 #include <linux/kmod.h>
1239 #include <linux/seq_file.h>
1240 +/***** TOMOYO Linux start. *****/
1241 +#include <linux/tomoyo.h>
1242 +/***** TOMOYO Linux end. *****/
1243
1244 /*
1245 * Originally by Anonymous (as far as I know...)
1246 @@ -298,6 +301,10 @@ sys_create_module(const char *name_user,
1247
1248 if (!capable(CAP_SYS_MODULE))
1249 return -EPERM;
1250 + /***** TOMOYO Linux start. *****/
1251 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1252 + return -EPERM;
1253 + /***** TOMOYO Linux end. *****/
1254 lock_kernel();
1255 if ((namelen = get_mod_name(name_user, &name)) < 0) {
1256 error = namelen;
1257 @@ -353,6 +360,10 @@ sys_init_module(const char *name_user, s
1258
1259 if (!capable(CAP_SYS_MODULE))
1260 return -EPERM;
1261 + /***** TOMOYO Linux start. *****/
1262 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1263 + return -EPERM;
1264 + /***** TOMOYO Linux end. *****/
1265 lock_kernel();
1266 if ((namelen = get_mod_name(name_user, &name)) < 0) {
1267 error = namelen;
1268 @@ -614,6 +625,10 @@ sys_delete_module(const char *name_user)
1269
1270 if (!capable(CAP_SYS_MODULE))
1271 return -EPERM;
1272 + /***** TOMOYO Linux start. *****/
1273 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1274 + return -EPERM;
1275 + /***** TOMOYO Linux end. *****/
1276
1277 lock_kernel();
1278 if (name_user) {
1279 --- linux-2.4.37.orig/kernel/sched.c
1280 +++ linux-2.4.37/kernel/sched.c
1281 @@ -32,6 +32,9 @@
1282
1283 #include <asm/uaccess.h>
1284 #include <asm/mmu_context.h>
1285 +/***** TOMOYO Linux start. *****/
1286 +#include <linux/tomoyo.h>
1287 +/***** TOMOYO Linux end. *****/
1288
1289 extern void timer_bh(void);
1290 extern void tqueue_bh(void);
1291 @@ -899,6 +902,10 @@ void set_cpus_allowed(struct task_struct
1292 asmlinkage long sys_nice(int increment)
1293 {
1294 long newprio;
1295 + /***** TOMOYO Linux start. *****/
1296 + if (!ccs_capable(CCS_SYS_NICE))
1297 + return -EPERM;
1298 + /***** TOMOYO Linux end. *****/
1299
1300 /*
1301 * Setpriority might change our priority at the same moment.
1302 --- linux-2.4.37.orig/kernel/signal.c
1303 +++ linux-2.4.37/kernel/signal.c
1304 @@ -15,6 +15,9 @@
1305 #include <linux/sched.h>
1306
1307 #include <asm/uaccess.h>
1308 +/***** TOMOYO Linux start. *****/
1309 +#include <linux/tomoyo.h>
1310 +/***** TOMOYO Linux end. *****/
1311
1312 /*
1313 * SLAB caches for signal bits.
1314 @@ -1025,6 +1028,12 @@ asmlinkage long
1315 sys_kill(int pid, int sig)
1316 {
1317 struct siginfo info;
1318 + /***** TOMOYO Linux start. *****/
1319 + if (sig && !ccs_capable(CCS_SYS_KILL))
1320 + return -EPERM;
1321 + if (sig && ccs_check_signal_acl(sig, pid))
1322 + return -EPERM;
1323 + /***** TOMOYO Linux end. *****/
1324
1325 info.si_signo = sig;
1326 info.si_errno = 0;
1327 @@ -1049,6 +1058,12 @@ sys_tkill(int pid, int sig)
1328 if (pid <= 0)
1329 return -EINVAL;
1330
1331 + /***** TOMOYO Linux start. *****/
1332 + if (sig && !ccs_capable(CCS_SYS_KILL))
1333 + return -EPERM;
1334 + if (sig && ccs_check_signal_acl(sig, pid))
1335 + return -EPERM;
1336 + /***** TOMOYO Linux end. *****/
1337 info.si_signo = sig;
1338 info.si_errno = 0;
1339 info.si_code = SI_TKILL;
1340 --- linux-2.4.37.orig/kernel/sys.c
1341 +++ linux-2.4.37/kernel/sys.c
1342 @@ -17,6 +17,9 @@
1343
1344 #include <asm/uaccess.h>
1345 #include <asm/io.h>
1346 +/***** TOMOYO Linux start. *****/
1347 +#include <linux/tomoyo.h>
1348 +/***** TOMOYO Linux end. *****/
1349
1350 #ifndef SET_UNALIGN_CTL
1351 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1352 @@ -220,6 +223,10 @@ asmlinkage long sys_setpriority(int whic
1353
1354 if (which > 2 || which < 0)
1355 return -EINVAL;
1356 + /***** TOMOYO Linux start. *****/
1357 + if (!ccs_capable(CCS_SYS_NICE))
1358 + return -EPERM;
1359 + /***** TOMOYO Linux end. *****/
1360
1361 /* normalize: avoid signed division (rounding problems) */
1362 error = -ESRCH;
1363 @@ -299,6 +306,10 @@ asmlinkage long sys_reboot(int magic1, i
1364 (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A &&
1365 magic2 != LINUX_REBOOT_MAGIC2B))
1366 return -EINVAL;
1367 + /***** TOMOYO Linux start. *****/
1368 + if (!ccs_capable(CCS_SYS_REBOOT))
1369 + return -EPERM;
1370 + /***** TOMOYO Linux end. *****/
1371
1372 lock_kernel();
1373 switch (cmd) {
1374 @@ -1042,6 +1053,10 @@ asmlinkage long sys_sethostname(char *na
1375 return -EPERM;
1376 if (len < 0 || len > __NEW_UTS_LEN)
1377 return -EINVAL;
1378 + /***** TOMOYO Linux start. *****/
1379 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1380 + return -EPERM;
1381 + /***** TOMOYO Linux end. *****/
1382 down_write(&uts_sem);
1383 errno = -EFAULT;
1384 if (!copy_from_user(tmp, name, len)) {
1385 @@ -1083,6 +1098,10 @@ asmlinkage long sys_setdomainname(char *
1386 return -EPERM;
1387 if (len < 0 || len > __NEW_UTS_LEN)
1388 return -EINVAL;
1389 + /***** TOMOYO Linux start. *****/
1390 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1391 + return -EPERM;
1392 + /***** TOMOYO Linux end. *****/
1393
1394 down_write(&uts_sem);
1395 errno = -EFAULT;
1396 --- linux-2.4.37.orig/kernel/sysctl.c
1397 +++ linux-2.4.37/kernel/sysctl.c
1398 @@ -33,6 +33,9 @@
1399 #include <linux/swap.h>
1400
1401 #include <asm/uaccess.h>
1402 +/***** TOMOYO Linux start. *****/
1403 +#include <linux/tomoyo.h>
1404 +/***** TOMOYO Linux end. *****/
1405
1406 #ifdef CONFIG_ROOT_NFS
1407 #include <linux/nfs_fs.h>
1408 @@ -411,6 +414,100 @@ void __init sysctl_init(void)
1409 #endif
1410 }
1411
1412 +/***** TOMOYO Linux start. *****/
1413 +static int try_parse_table(int __user *name, int nlen, void __user *oldval,
1414 + void __user *newval, ctl_table *table)
1415 +{
1416 + int n;
1417 + int error = -ENOMEM;
1418 + int op = 0;
1419 + char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1420 + if (oldval)
1421 + op |= 004;
1422 + if (newval)
1423 + op |= 002;
1424 + if (!op) { /* Neither read nor write */
1425 + error = 0;
1426 + goto out;
1427 + }
1428 + if (!buffer)
1429 + goto out;
1430 + memset(buffer, 0, PAGE_SIZE);
1431 + snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1432 + repeat:
1433 + if (!nlen) {
1434 + error = -ENOTDIR;
1435 + goto out;
1436 + }
1437 + if (get_user(n, name)) {
1438 + error = -EFAULT;
1439 + goto out;
1440 + }
1441 + for ( ; table->ctl_name; table++) {
1442 + if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1443 + int pos = strlen(buffer);
1444 + const char *cp = table->procname;
1445 + error = -ENOMEM;
1446 + if (cp) {
1447 + if (pos + 1 >= PAGE_SIZE - 1)
1448 + goto out;
1449 + buffer[pos++] = '/';
1450 + while (*cp) {
1451 + const unsigned char c
1452 + = *(const unsigned char *) cp;
1453 + if (c == '\\') {
1454 + if (pos + 2 >= PAGE_SIZE - 1)
1455 + goto out;
1456 + buffer[pos++] = '\\';
1457 + buffer[pos++] = '\\';
1458 + } else if (c > ' ' && c < 127) {
1459 + if (pos + 1 >= PAGE_SIZE - 1)
1460 + goto out;
1461 + buffer[pos++] = c;
1462 + } else {
1463 + if (pos + 4 >= PAGE_SIZE - 1)
1464 + goto out;
1465 + buffer[pos++] = '\\';
1466 + buffer[pos++] = (c >> 6) + '0';
1467 + buffer[pos++] = ((c >> 3) & 7)
1468 + + '0';
1469 + buffer[pos++] = (c & 7) + '0';
1470 + }
1471 + cp++;
1472 + }
1473 + } else {
1474 + /* Assume nobody assigns "=\$=" for procname. */
1475 + snprintf(buffer + pos, PAGE_SIZE - pos - 1,
1476 + "/=%d=", table->ctl_name);
1477 + if (!memchr(buffer, '\0', PAGE_SIZE - 2))
1478 + goto out;
1479 + }
1480 + if (table->child) {
1481 + if (table->strategy) {
1482 + /* printk("sysctl='%s'\n", buffer); */
1483 + if (ccs_check_file_perm(buffer, op,
1484 + "sysctl")) {
1485 + error = -EPERM;
1486 + goto out;
1487 + }
1488 + }
1489 + name++;
1490 + nlen--;
1491 + table = table->child;
1492 + goto repeat;
1493 + }
1494 + /* printk("sysctl='%s'\n", buffer); */
1495 + error = ccs_check_file_perm(buffer, op, "sysctl");
1496 + goto out;
1497 + }
1498 + }
1499 + error = -ENOTDIR;
1500 + out:
1501 + kfree(buffer);
1502 + return error;
1503 +}
1504 +/***** TOMOYO Linux end. *****/
1505 +
1506 int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
1507 void *newval, size_t newlen)
1508 {
1509 @@ -439,6 +536,11 @@ int do_sysctl(int *name, int nlen, void
1510
1511 spin_unlock(&sysctl_lock);
1512
1513 + /***** TOMOYO Linux start. *****/
1514 + error = try_parse_table(name, nlen, oldval, newval,
1515 + head->ctl_table);
1516 + if (!error)
1517 + /***** TOMOYO Linux end. *****/
1518 error = parse_table(name, nlen, oldval, oldlenp,
1519 newval, newlen, head->ctl_table,
1520 &context);
1521 @@ -508,6 +610,15 @@ repeat:
1522 if (ctl_perm(table, 001))
1523 return -EPERM;
1524 if (table->strategy) {
1525 + /***** TOMOYO Linux start. *****/
1526 + int op = 0;
1527 + if (oldval)
1528 + op |= 004;
1529 + if (newval)
1530 + op |= 002;
1531 + if (ctl_perm(table, op))
1532 + return -EPERM;
1533 + /***** TOMOYO Linux end. *****/
1534 error = table->strategy(
1535 table, name, nlen,
1536 oldval, oldlenp,
1537 @@ -1456,7 +1567,7 @@ int sysctl_string(ctl_table *table, int
1538 len--;
1539 ((char *) table->data)[len] = 0;
1540 }
1541 - return 0;
1542 + return 1;
1543 }
1544
1545 /*
1546 --- linux-2.4.37.orig/kernel/time.c
1547 +++ linux-2.4.37/kernel/time.c
1548 @@ -29,6 +29,9 @@
1549 #include <linux/smp_lock.h>
1550
1551 #include <asm/uaccess.h>
1552 +/***** TOMOYO Linux start. *****/
1553 +#include <linux/tomoyo.h>
1554 +/***** TOMOYO Linux end. *****/
1555
1556 /*
1557 * The timezone where the local system is located. Used as a default by some
1558 @@ -77,6 +80,10 @@ asmlinkage long sys_stime(int * tptr)
1559
1560 if (!capable(CAP_SYS_TIME))
1561 return -EPERM;
1562 + /***** TOMOYO Linux start. *****/
1563 + if (!ccs_capable(CCS_SYS_SETTIME))
1564 + return -EPERM;
1565 + /***** TOMOYO Linux end. *****/
1566 if (get_user(value, tptr))
1567 return -EFAULT;
1568 write_lock_irq(&xtime_lock);
1569 @@ -151,6 +158,10 @@ int do_sys_settimeofday(struct timeval *
1570
1571 if (!capable(CAP_SYS_TIME))
1572 return -EPERM;
1573 + /***** TOMOYO Linux start. *****/
1574 + if (!ccs_capable(CCS_SYS_SETTIME))
1575 + return -EPERM;
1576 + /***** TOMOYO Linux end. *****/
1577
1578 if (tz) {
1579 /* SMP safe, global irq locking makes it work. */
1580 @@ -217,6 +228,10 @@ int do_adjtimex(struct timex *txc)
1581 /* In order to modify anything, you gotta be super-user! */
1582 if (txc->modes && !capable(CAP_SYS_TIME))
1583 return -EPERM;
1584 + /***** TOMOYO Linux start. *****/
1585 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1586 + return -EPERM;
1587 + /***** TOMOYO Linux end. *****/
1588
1589 /* Now we validate the data before disabling interrupts */
1590
1591 --- linux-2.4.37.orig/net/core/datagram.c
1592 +++ linux-2.4.37/net/core/datagram.c
1593 @@ -43,6 +43,10 @@
1594 #include <net/sock.h>
1595 #include <net/checksum.h>
1596
1597 +/***** TOMOYO Linux start. *****/
1598 +#include <linux/tomoyo.h>
1599 +#include <linux/tomoyo_socket.h>
1600 +/***** TOMOYO Linux end. *****/
1601
1602 /*
1603 * Is a socket 'connection oriented' ?
1604 @@ -164,6 +168,12 @@ struct sk_buff *skb_recv_datagram(struct
1605 } else
1606 skb = skb_dequeue(&sk->receive_queue);
1607
1608 + /***** TOMOYO Linux start. *****/
1609 + error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1610 + if (error)
1611 + goto no_packet;
1612 + /***** TOMOYO Linux end. *****/
1613 +
1614 if (skb)
1615 return skb;
1616
1617 --- linux-2.4.37.orig/net/ipv4/tcp_ipv4.c
1618 +++ linux-2.4.37/net/ipv4/tcp_ipv4.c
1619 @@ -67,6 +67,9 @@
1620 #include <linux/inet.h>
1621 #include <linux/stddef.h>
1622 #include <linux/ipsec.h>
1623 +/***** SAKURA Linux start. *****/
1624 +#include <linux/sakura.h>
1625 +/***** SAKURA Linux end. *****/
1626
1627 extern int sysctl_ip_dynaddr;
1628 extern int sysctl_ip_default_ttl;
1629 @@ -228,6 +231,10 @@ static int tcp_v4_get_port(struct sock *
1630 rover = low;
1631 head = &tcp_bhash[tcp_bhashfn(rover)];
1632 spin_lock(&head->lock);
1633 + /***** SAKURA Linux start. *****/
1634 + if (ccs_may_autobind(rover))
1635 + goto next;
1636 + /***** SAKURA Linux end. *****/
1637 for (tb = head->chain; tb; tb = tb->next)
1638 if (tb->port == rover)
1639 goto next;
1640 @@ -688,6 +695,10 @@ static int tcp_v4_hash_connect(struct so
1641 rover = low;
1642 head = &tcp_bhash[tcp_bhashfn(rover)];
1643 spin_lock(&head->lock);
1644 + /***** SAKURA Linux start. *****/
1645 + if (ccs_may_autobind(rover))
1646 + goto next_port;
1647 + /***** SAKURA Linux end. *****/
1648
1649 /* Does not bother with rcv_saddr checks,
1650 * because the established check is already
1651 --- linux-2.4.37.orig/net/ipv4/udp.c
1652 +++ linux-2.4.37/net/ipv4/udp.c
1653 @@ -97,6 +97,9 @@
1654 #include <net/route.h>
1655 #include <net/inet_common.h>
1656 #include <net/checksum.h>
1657 +/***** SAKURA Linux start. *****/
1658 +#include <linux/sakura.h>
1659 +/***** SAKURA Linux end. *****/
1660
1661 /*
1662 * Snmp MIB for the UDP layer
1663 @@ -131,6 +134,10 @@ static int udp_v4_get_port(struct sock *
1664 result = sysctl_local_port_range[0] +
1665 ((result - sysctl_local_port_range[0]) &
1666 (UDP_HTABLE_SIZE - 1));
1667 + /***** SAKURA Linux start. *****/
1668 + if (ccs_may_autobind(result))
1669 + continue;
1670 + /***** SAKURA Linux end. *****/
1671 goto gotit;
1672 }
1673 size = 0;
1674 @@ -148,6 +155,10 @@ static int udp_v4_get_port(struct sock *
1675 result = sysctl_local_port_range[0]
1676 + ((result - sysctl_local_port_range[0]) &
1677 (UDP_HTABLE_SIZE - 1));
1678 + /***** SAKURA Linux start. *****/
1679 + if (ccs_may_autobind(result))
1680 + continue;
1681 + /***** SAKURA Linux end. *****/
1682 if (!udp_lport_inuse(result))
1683 break;
1684 }
1685 --- linux-2.4.37.orig/net/ipv6/tcp_ipv6.c
1686 +++ linux-2.4.37/net/ipv6/tcp_ipv6.c
1687 @@ -52,6 +52,9 @@
1688 #include <net/inet_ecn.h>
1689
1690 #include <asm/uaccess.h>
1691 +/***** SAKURA Linux start. *****/
1692 +#include <linux/sakura.h>
1693 +/***** SAKURA Linux end. *****/
1694
1695 static void tcp_v6_send_reset(struct sk_buff *skb);
1696 static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
1697 @@ -110,6 +113,10 @@ static int tcp_v6_get_port(struct sock *
1698 rover = low;
1699 head = &tcp_bhash[tcp_bhashfn(rover)];
1700 spin_lock(&head->lock);
1701 + /***** SAKURA Linux start. *****/
1702 + if (ccs_may_autobind(rover))
1703 + goto next;
1704 + /***** SAKURA Linux end. *****/
1705 for (tb = head->chain; tb; tb = tb->next)
1706 if (tb->port == rover)
1707 goto next;
1708 --- linux-2.4.37.orig/net/ipv6/udp.c
1709 +++ linux-2.4.37/net/ipv6/udp.c
1710 @@ -50,6 +50,9 @@
1711 #include <net/inet_common.h>
1712
1713 #include <net/checksum.h>
1714 +/***** SAKURA Linux start. *****/
1715 +#include <linux/sakura.h>
1716 +/***** SAKURA Linux end. *****/
1717
1718 struct udp_mib udp_stats_in6[NR_CPUS*2];
1719
1720 @@ -77,6 +80,10 @@ static int udp_v6_get_port(struct sock *
1721 result = sysctl_local_port_range[0] +
1722 ((result - sysctl_local_port_range[0]) &
1723 (UDP_HTABLE_SIZE - 1));
1724 + /***** SAKURA Linux start. *****/
1725 + if (ccs_may_autobind(result))
1726 + continue;
1727 + /***** SAKURA Linux end. *****/
1728 goto gotit;
1729 }
1730 size = 0;
1731 @@ -94,6 +101,10 @@ static int udp_v6_get_port(struct sock *
1732 result = sysctl_local_port_range[0]
1733 + ((result - sysctl_local_port_range[0]) &
1734 (UDP_HTABLE_SIZE - 1));
1735 + /***** SAKURA Linux start. *****/
1736 + if (ccs_may_autobind(result))
1737 + continue;
1738 + /***** SAKURA Linux end. *****/
1739 if (!udp_lport_inuse(result))
1740 break;
1741 }
1742 --- linux-2.4.37.orig/net/socket.c
1743 +++ linux-2.4.37/net/socket.c
1744 @@ -84,6 +84,10 @@
1745 #include <net/sock.h>
1746 #include <net/scm.h>
1747 #include <linux/netfilter.h>
1748 +/***** TOMOYO Linux start. *****/
1749 +#include <linux/tomoyo.h>
1750 +#include <linux/tomoyo_socket.h>
1751 +/***** TOMOYO Linux end. *****/
1752
1753 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1754 static ssize_t sock_read(struct file *file, char *buf,
1755 @@ -501,7 +505,12 @@ int sock_sendmsg(struct socket *sock, st
1756 {
1757 int err;
1758 struct scm_cookie scm;
1759 -
1760 + /***** TOMOYO Linux start. *****/
1761 + err = ccs_socket_sendmsg_permission(sock,
1762 + (struct sockaddr *) msg->msg_name,
1763 + msg->msg_namelen);
1764 + if (!err)
1765 + /***** TOMOYO Linux end. *****/
1766 err = scm_send(sock, msg, &scm);
1767 if (err >= 0) {
1768 err = sock->ops->sendmsg(sock, msg, size, &scm);
1769 @@ -847,7 +856,11 @@ int sock_create(int family, int type, in
1770 }
1771 family = PF_PACKET;
1772 }
1773 -
1774 + /***** TOMOYO Linux start. *****/
1775 + i = ccs_socket_create_permission(family, type, protocol);
1776 + if (i)
1777 + return i;
1778 + /***** TOMOYO Linux end. *****/
1779 #if defined(CONFIG_KMOD) && defined(CONFIG_NET)
1780 /* Attempt to load a protocol module if the find failed.
1781 *
1782 @@ -1003,6 +1016,12 @@ asmlinkage long sys_bind(int fd, struct
1783 if((sock = sockfd_lookup(fd,&err))!=NULL)
1784 {
1785 if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)
1786 + /***** TOMOYO Linux start. *****/
1787 + err = ccs_socket_bind_permission(sock,
1788 + (struct sockaddr *)
1789 + address, addrlen);
1790 + if (!err)
1791 + /***** TOMOYO Linux end. *****/
1792 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1793 sockfd_put(sock);
1794 }
1795 @@ -1026,6 +1045,10 @@ asmlinkage long sys_listen(int fd, int b
1796 if ((sock = sockfd_lookup(fd, &err)) != NULL) {
1797 if ((unsigned) backlog > sysctl_somaxconn)
1798 backlog = sysctl_somaxconn;
1799 + /***** TOMOYO Linux start. *****/
1800 + err = ccs_socket_listen_permission(sock);
1801 + if (!err)
1802 + /***** TOMOYO Linux end. *****/
1803 err=sock->ops->listen(sock, backlog);
1804 sockfd_put(sock);
1805 }
1806 @@ -1066,6 +1089,13 @@ asmlinkage long sys_accept(int fd, struc
1807 if (err < 0)
1808 goto out_release;
1809
1810 + /***** TOMOYO Linux start. *****/
1811 + if (ccs_socket_accept_permission(newsock,
1812 + (struct sockaddr *) address)) {
1813 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1814 + goto out_release;
1815 + }
1816 + /***** TOMOYO Linux end. *****/
1817 if (upeer_sockaddr) {
1818 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1819 err = -ECONNABORTED;
1820 @@ -1116,6 +1146,12 @@ asmlinkage long sys_connect(int fd, stru
1821 err = move_addr_to_kernel(uservaddr, addrlen, address);
1822 if (err < 0)
1823 goto out_put;
1824 + /***** TOMOYO Linux start. *****/
1825 + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1826 + addrlen);
1827 + if (err)
1828 + goto out_put;
1829 + /***** TOMOYO Linux end. *****/
1830 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1831 sock->file->f_flags);
1832 out_put:
1833 --- linux-2.4.37.orig/net/unix/af_unix.c
1834 +++ linux-2.4.37/net/unix/af_unix.c
1835 @@ -111,6 +111,9 @@
1836 #include <linux/rtnetlink.h>
1837
1838 #include <asm/checksum.h>
1839 +/***** TOMOYO Linux start. *****/
1840 +#include <linux/tomoyo.h>
1841 +/***** TOMOYO Linux end. *****/
1842
1843 int sysctl_unix_max_dgram_qlen = 10;
1844
1845 @@ -709,6 +712,11 @@ static int unix_bind(struct socket *sock
1846 * All right, let's create it.
1847 */
1848 mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);
1849 + /***** TOMOYO Linux start. *****/
1850 + err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
1851 + nd.mnt, mode, 0);
1852 + if (!err)
1853 + /***** TOMOYO Linux end. *****/
1854 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1855 if (err)
1856 goto out_mknod_dput;

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