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

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.4.37.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2300 - (show annotations) (download) (as text)
Mon Mar 23 07:18:52 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: 52020 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 | 71 +++++++++++++++++++++++++++++++++++
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 | 19 +++++++++
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, 668 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 = ccs_search_binary_handler(&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,12 @@ 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 + goto out_dput;
876 + /***** TOMOYO Linux end. *****/
877 switch (mode & S_IFMT) {
878 case 0: case S_IFREG:
879 error = vfs_create(nd.dentry->d_inode,dentry,mode);
880 @@ -1317,6 +1346,9 @@ asmlinkage long sys_mknod(const char * f
881 default:
882 error = -EINVAL;
883 }
884 + /***** TOMOYO Linux start. *****/
885 +out_dput:
886 + /***** TOMOYO Linux end. *****/
887 dput(dentry);
888 }
889 up(&nd.dentry->d_inode->i_sem);
890 @@ -1370,6 +1402,12 @@ asmlinkage long sys_mkdir(const char * p
891 dentry = lookup_create(&nd, 1);
892 error = PTR_ERR(dentry);
893 if (!IS_ERR(dentry)) {
894 + /***** TOMOYO Linux start. *****/
895 + error = ccs_check_mkdir_permission(nd.dentry->d_inode,
896 + dentry, nd.mnt,
897 + mode);
898 + if (!error)
899 + /***** TOMOYO Linux end. *****/
900 error = vfs_mkdir(nd.dentry->d_inode, dentry,
901 mode & ~current->fs->umask);
902 dput(dentry);
903 @@ -1479,6 +1517,11 @@ asmlinkage long sys_rmdir(const char * p
904 dentry = lookup_hash(&nd.last, nd.dentry);
905 error = PTR_ERR(dentry);
906 if (!IS_ERR(dentry)) {
907 + /***** TOMOYO Linux start. *****/
908 + error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,
909 + nd.mnt);
910 + if (!error)
911 + /***** TOMOYO Linux end. *****/
912 error = vfs_rmdir(nd.dentry->d_inode, dentry);
913 dput(dentry);
914 }
915 @@ -1548,6 +1591,12 @@ asmlinkage long sys_unlink(const char *
916 /* Why not before? Because we want correct error value */
917 if (nd.last.name[nd.last.len])
918 goto slashes;
919 + /***** TOMOYO Linux start. *****/
920 + error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,
921 + nd.mnt);
922 + if (error)
923 + goto exit2;
924 + /***** TOMOYO Linux end. *****/
925 error = vfs_unlink(nd.dentry->d_inode, dentry);
926 exit2:
927 dput(dentry);
928 @@ -1612,6 +1661,12 @@ asmlinkage long sys_symlink(const char *
929 dentry = lookup_create(&nd, 0);
930 error = PTR_ERR(dentry);
931 if (!IS_ERR(dentry)) {
932 + /***** TOMOYO Linux start. *****/
933 + error = ccs_check_symlink_permission(nd.dentry->d_inode,
934 + dentry, nd.mnt,
935 + from);
936 + if (!error)
937 + /***** TOMOYO Linux end. *****/
938 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
939 dput(dentry);
940 }
941 @@ -1698,6 +1753,12 @@ asmlinkage long sys_link(const char * ol
942 new_dentry = lookup_create(&nd, 0);
943 error = PTR_ERR(new_dentry);
944 if (!IS_ERR(new_dentry)) {
945 + /***** TOMOYO Linux start. *****/
946 + error = ccs_check_link_permission(old_nd.dentry,
947 + nd.dentry->d_inode,
948 + new_dentry, nd.mnt);
949 + if (!error)
950 + /***** TOMOYO Linux end. *****/
951 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
952 dput(new_dentry);
953 }
954 @@ -1928,12 +1989,22 @@ static inline int do_rename(const char *
955 error = PTR_ERR(new_dentry);
956 if (IS_ERR(new_dentry))
957 goto exit4;
958 + /***** TOMOYO Linux start. *****/
959 + error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,
960 + new_dir->d_inode, new_dentry,
961 + newnd.mnt);
962 + if (error)
963 + goto exit5;
964 + /***** TOMOYO Linux end. *****/
965
966 lock_kernel();
967 error = vfs_rename(old_dir->d_inode, old_dentry,
968 new_dir->d_inode, new_dentry);
969 unlock_kernel();
970
971 + /***** TOMOYO Linux start. *****/
972 +exit5:
973 + /***** TOMOYO Linux end. *****/
974 dput(new_dentry);
975 exit4:
976 dput(old_dentry);
977 --- linux-2.4.37.orig/fs/namespace.c
978 +++ linux-2.4.37/fs/namespace.c
979 @@ -21,6 +21,13 @@
980 #include <linux/seq_file.h>
981 #include <linux/namespace.h>
982
983 +/***** SAKURA Linux start. *****/
984 +#include <linux/sakura.h>
985 +/***** SAKURA Linux end. *****/
986 +/***** TOMOYO Linux start. *****/
987 +#include <linux/tomoyo.h>
988 +/***** TOMOYO Linux end. *****/
989 +
990 struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
991 int do_remount_sb(struct super_block *sb, int flags, void * data);
992 void kill_super(struct super_block *sb);
993 @@ -290,6 +297,10 @@ static int do_umount(struct vfsmount *mn
994 {
995 struct super_block * sb = mnt->mnt_sb;
996 int retval = 0;
997 + /***** SAKURA Linux start. *****/
998 + if (ccs_may_umount(mnt))
999 + return -EPERM;
1000 + /***** SAKURA Linux end. *****/
1001
1002 /*
1003 * If we may have to abort operations to get out of this
1004 @@ -365,6 +376,10 @@ asmlinkage long sys_umount(char * name,
1005 {
1006 struct nameidata nd;
1007 int retval;
1008 + /***** TOMOYO Linux start. *****/
1009 + if (!ccs_capable(CCS_SYS_UMOUNT))
1010 + return -EPERM;
1011 + /***** TOMOYO Linux end. *****/
1012
1013 retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd);
1014 if (retval)
1015 @@ -500,6 +515,11 @@ static int do_loopback(struct nameidata
1016 down_write(&current->namespace->sem);
1017 err = -EINVAL;
1018 if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {
1019 + /***** SAKURA Linux start. *****/
1020 + err = -EPERM;
1021 + if (ccs_may_mount(nd))
1022 + goto out;
1023 + /***** SAKURA Linux end. *****/
1024 err = -ENOMEM;
1025 if (recurse)
1026 mnt = copy_tree(old_nd.mnt, old_nd.dentry);
1027 @@ -516,7 +536,9 @@ static int do_loopback(struct nameidata
1028 } else
1029 mntput(mnt);
1030 }
1031 -
1032 + /***** SAKURA Linux start. *****/
1033 + out:
1034 + /***** SAKURA Linux end. *****/
1035 up_write(&current->namespace->sem);
1036 path_release(&old_nd);
1037 return err;
1038 @@ -570,6 +592,12 @@ static int do_move_mount(struct nameidat
1039 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
1040 goto out;
1041
1042 + /***** SAKURA Linux start. *****/
1043 + err = -EPERM;
1044 + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
1045 + goto out;
1046 + /***** SAKURA Linux end. *****/
1047 +
1048 err = -ENOENT;
1049 down(&nd->dentry->d_inode->i_zombie);
1050 if (IS_DEADDIR(nd->dentry->d_inode))
1051 @@ -641,6 +669,12 @@ static int do_add_mount(struct nameidata
1052 if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry)
1053 goto unlock;
1054
1055 + /***** SAKURA Linux start. *****/
1056 + err = -EPERM;
1057 + if (ccs_may_mount(nd))
1058 + goto unlock;
1059 + /***** SAKURA Linux end. *****/
1060 +
1061 mnt->mnt_flags = mnt_flags;
1062 err = graft_tree(mnt, nd);
1063 unlock:
1064 @@ -718,6 +752,17 @@ long do_mount(char * dev_name, char * di
1065 if (data_page)
1066 ((char *)data_page)[PAGE_SIZE - 1] = 0;
1067
1068 + /***** TOMOYO Linux start. *****/
1069 + if (!ccs_capable(CCS_SYS_MOUNT))
1070 + return -EPERM;
1071 + /***** TOMOYO Linux end. *****/
1072 + /***** SAKURA Linux start. *****/
1073 + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
1074 + &flags);
1075 + if (retval)
1076 + return retval;
1077 + /***** SAKURA Linux end. *****/
1078 +
1079 /* Separate the per-mountpoint flags */
1080 if (flags & MS_NOSUID)
1081 mnt_flags |= MNT_NOSUID;
1082 @@ -911,6 +956,10 @@ asmlinkage long sys_pivot_root(const cha
1083
1084 if (!capable(CAP_SYS_ADMIN))
1085 return -EPERM;
1086 + /***** TOMOYO Linux start. *****/
1087 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
1088 + return -EPERM;
1089 + /***** TOMOYO Linux end. *****/
1090
1091 lock_kernel();
1092
1093 @@ -925,6 +974,13 @@ asmlinkage long sys_pivot_root(const cha
1094 if (error)
1095 goto out1;
1096
1097 + /***** SAKURA Linux start. *****/
1098 + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
1099 + if (error) {
1100 + path_release(&old_nd);
1101 + goto out1;
1102 + }
1103 + /***** SAKURA Linux end. *****/
1104 read_lock(&current->fs->lock);
1105 user_nd.mnt = mntget(current->fs->rootmnt);
1106 user_nd.dentry = dget(current->fs->root);
1107 --- linux-2.4.37.orig/fs/open.c
1108 +++ linux-2.4.37/fs/open.c
1109 @@ -20,6 +20,13 @@
1110
1111 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1112
1113 +/***** SAKURA Linux start. *****/
1114 +#include <linux/sakura.h>
1115 +/***** SAKURA Linux end. *****/
1116 +/***** TOMOYO Linux start. *****/
1117 +#include <linux/tomoyo.h>
1118 +/***** TOMOYO Linux end. *****/
1119 +
1120 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1121 {
1122 int retval = -ENODEV;
1123 @@ -164,6 +171,11 @@ static inline long do_sys_truncate(const
1124 if (error)
1125 goto dput_and_out;
1126
1127 + /***** TOMOYO Linux start. *****/
1128 + error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);
1129 + if (!error)
1130 + /***** TOMOYO Linux end. *****/
1131 +
1132 error = locks_verify_truncate(inode, NULL, length);
1133 if (!error) {
1134 DQUOT_INIT(inode);
1135 @@ -217,6 +229,12 @@ static inline long do_sys_ftruncate(unsi
1136 if (IS_APPEND(inode))
1137 goto out_putf;
1138
1139 + /***** TOMOYO Linux start. *****/
1140 + error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
1141 + 0);
1142 + if (error)
1143 + goto out_putf;
1144 + /***** TOMOYO Linux end. *****/
1145 error = locks_verify_truncate(inode, file, length);
1146 if (!error)
1147 error = do_truncate(dentry, length);
1148 @@ -466,6 +484,14 @@ asmlinkage long sys_chroot(const char *
1149 error = -EPERM;
1150 if (!capable(CAP_SYS_CHROOT))
1151 goto dput_and_out;
1152 + /***** TOMOYO Linux start. *****/
1153 + if (!ccs_capable(CCS_SYS_CHROOT))
1154 + goto dput_and_out;
1155 + /***** TOMOYO Linux end. *****/
1156 + /***** SAKURA Linux start. *****/
1157 + if (ccs_check_chroot_permission(&nd))
1158 + goto dput_and_out;
1159 + /***** SAKURA Linux end. *****/
1160
1161 set_fs_root(current->fs, nd.mnt, nd.dentry);
1162 set_fs_altroot();
1163 @@ -897,6 +923,10 @@ out_unlock:
1164 */
1165 asmlinkage long sys_vhangup(void)
1166 {
1167 + /***** TOMOYO Linux start. *****/
1168 + if (!ccs_capable(CCS_SYS_VHANGUP))
1169 + return -EPERM;
1170 + /***** TOMOYO Linux end. *****/
1171 if (capable(CAP_SYS_TTY_CONFIG)) {
1172 tty_vhangup(current->tty);
1173 return 0;
1174 --- linux-2.4.37.orig/fs/proc/Makefile
1175 +++ linux-2.4.37/fs/proc/Makefile
1176 @@ -18,4 +18,8 @@ ifeq ($(CONFIG_PROC_DEVICETREE),y)
1177 obj-y += proc_devtree.o
1178 endif
1179
1180 +export-objs += ccs_proc.o
1181 +obj-$(CONFIG_SAKURA) += ccs_proc.o
1182 +obj-$(CONFIG_TOMOYO) += ccs_proc.o
1183 +
1184 include $(TOPDIR)/Rules.make
1185 --- linux-2.4.37.orig/fs/proc/proc_misc.c
1186 +++ linux-2.4.37/fs/proc/proc_misc.c
1187 @@ -670,4 +670,9 @@ void __init proc_misc_init(void)
1188 entry->proc_fops = &ppc_htab_operations;
1189 }
1190 #endif
1191 + /***** CCS start. *****/
1192 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
1193 + printk(KERN_INFO "Hook version: 2.4.37 2009/03/18\n");
1194 +#endif
1195 + /***** CCS end. *****/
1196 }
1197 --- linux-2.4.37.orig/include/linux/sched.h
1198 +++ linux-2.4.37/include/linux/sched.h
1199 @@ -29,6 +29,10 @@ extern unsigned long event;
1200
1201 struct exec_domain;
1202
1203 +/***** TOMOYO Linux start. *****/
1204 +struct ccs_domain_info;
1205 +/***** TOMOYO Linux end. *****/
1206 +
1207 /*
1208 * cloning flags:
1209 */
1210 @@ -417,6 +421,10 @@ struct task_struct {
1211 void *journal_info;
1212
1213 struct list_head *scm_work_list;
1214 + /***** TOMOYO Linux start. *****/
1215 + struct ccs_domain_info *ccs_domain_info;
1216 + u32 ccs_flags;
1217 + /***** TOMOYO Linux end. *****/
1218 };
1219
1220 /*
1221 @@ -512,6 +520,10 @@ extern struct exec_domain default_exec_d
1222 blocked: {{0}}, \
1223 alloc_lock: SPIN_LOCK_UNLOCKED, \
1224 journal_info: NULL, \
1225 + /***** TOMOYO Linux start. *****/ \
1226 + ccs_domain_info: NULL, \
1227 + ccs_flags: 0 \
1228 + /***** TOMOYO Linux end. *****/ \
1229 }
1230
1231
1232 --- linux-2.4.37.orig/kernel/kmod.c
1233 +++ linux-2.4.37/kernel/kmod.c
1234 @@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa
1235 /* Allow execve args to be in kernel space. */
1236 set_fs(KERNEL_DS);
1237
1238 + /***** TOMOYO Linux start. *****/
1239 + current->ccs_domain_info = NULL;
1240 + current->ccs_flags = 0;
1241 + /***** TOMOYO Linux end. *****/
1242 +
1243 /* Go, go, go... */
1244 if (execve(program_path, argv, envp) < 0)
1245 return -errno;
1246 --- linux-2.4.37.orig/kernel/module.c
1247 +++ linux-2.4.37/kernel/module.c
1248 @@ -10,6 +10,9 @@
1249 #include <linux/slab.h>
1250 #include <linux/kmod.h>
1251 #include <linux/seq_file.h>
1252 +/***** TOMOYO Linux start. *****/
1253 +#include <linux/tomoyo.h>
1254 +/***** TOMOYO Linux end. *****/
1255
1256 /*
1257 * Originally by Anonymous (as far as I know...)
1258 @@ -298,6 +301,10 @@ sys_create_module(const char *name_user,
1259
1260 if (!capable(CAP_SYS_MODULE))
1261 return -EPERM;
1262 + /***** TOMOYO Linux start. *****/
1263 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1264 + return -EPERM;
1265 + /***** TOMOYO Linux end. *****/
1266 lock_kernel();
1267 if ((namelen = get_mod_name(name_user, &name)) < 0) {
1268 error = namelen;
1269 @@ -353,6 +360,10 @@ sys_init_module(const char *name_user, s
1270
1271 if (!capable(CAP_SYS_MODULE))
1272 return -EPERM;
1273 + /***** TOMOYO Linux start. *****/
1274 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1275 + return -EPERM;
1276 + /***** TOMOYO Linux end. *****/
1277 lock_kernel();
1278 if ((namelen = get_mod_name(name_user, &name)) < 0) {
1279 error = namelen;
1280 @@ -614,6 +625,10 @@ sys_delete_module(const char *name_user)
1281
1282 if (!capable(CAP_SYS_MODULE))
1283 return -EPERM;
1284 + /***** TOMOYO Linux start. *****/
1285 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1286 + return -EPERM;
1287 + /***** TOMOYO Linux end. *****/
1288
1289 lock_kernel();
1290 if (name_user) {
1291 --- linux-2.4.37.orig/kernel/sched.c
1292 +++ linux-2.4.37/kernel/sched.c
1293 @@ -32,6 +32,9 @@
1294
1295 #include <asm/uaccess.h>
1296 #include <asm/mmu_context.h>
1297 +/***** TOMOYO Linux start. *****/
1298 +#include <linux/tomoyo.h>
1299 +/***** TOMOYO Linux end. *****/
1300
1301 extern void timer_bh(void);
1302 extern void tqueue_bh(void);
1303 @@ -899,6 +902,10 @@ void set_cpus_allowed(struct task_struct
1304 asmlinkage long sys_nice(int increment)
1305 {
1306 long newprio;
1307 + /***** TOMOYO Linux start. *****/
1308 + if (!ccs_capable(CCS_SYS_NICE))
1309 + return -EPERM;
1310 + /***** TOMOYO Linux end. *****/
1311
1312 /*
1313 * Setpriority might change our priority at the same moment.
1314 --- linux-2.4.37.orig/kernel/signal.c
1315 +++ linux-2.4.37/kernel/signal.c
1316 @@ -15,6 +15,9 @@
1317 #include <linux/sched.h>
1318
1319 #include <asm/uaccess.h>
1320 +/***** TOMOYO Linux start. *****/
1321 +#include <linux/tomoyo.h>
1322 +/***** TOMOYO Linux end. *****/
1323
1324 /*
1325 * SLAB caches for signal bits.
1326 @@ -1025,6 +1028,12 @@ asmlinkage long
1327 sys_kill(int pid, int sig)
1328 {
1329 struct siginfo info;
1330 + /***** TOMOYO Linux start. *****/
1331 + if (sig && !ccs_capable(CCS_SYS_KILL))
1332 + return -EPERM;
1333 + if (sig && ccs_check_signal_acl(sig, pid))
1334 + return -EPERM;
1335 + /***** TOMOYO Linux end. *****/
1336
1337 info.si_signo = sig;
1338 info.si_errno = 0;
1339 @@ -1049,6 +1058,12 @@ sys_tkill(int pid, int sig)
1340 if (pid <= 0)
1341 return -EINVAL;
1342
1343 + /***** TOMOYO Linux start. *****/
1344 + if (sig && !ccs_capable(CCS_SYS_KILL))
1345 + return -EPERM;
1346 + if (sig && ccs_check_signal_acl(sig, pid))
1347 + return -EPERM;
1348 + /***** TOMOYO Linux end. *****/
1349 info.si_signo = sig;
1350 info.si_errno = 0;
1351 info.si_code = SI_TKILL;
1352 --- linux-2.4.37.orig/kernel/sys.c
1353 +++ linux-2.4.37/kernel/sys.c
1354 @@ -17,6 +17,9 @@
1355
1356 #include <asm/uaccess.h>
1357 #include <asm/io.h>
1358 +/***** TOMOYO Linux start. *****/
1359 +#include <linux/tomoyo.h>
1360 +/***** TOMOYO Linux end. *****/
1361
1362 #ifndef SET_UNALIGN_CTL
1363 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1364 @@ -220,6 +223,10 @@ asmlinkage long sys_setpriority(int whic
1365
1366 if (which > 2 || which < 0)
1367 return -EINVAL;
1368 + /***** TOMOYO Linux start. *****/
1369 + if (!ccs_capable(CCS_SYS_NICE))
1370 + return -EPERM;
1371 + /***** TOMOYO Linux end. *****/
1372
1373 /* normalize: avoid signed division (rounding problems) */
1374 error = -ESRCH;
1375 @@ -299,6 +306,10 @@ asmlinkage long sys_reboot(int magic1, i
1376 (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A &&
1377 magic2 != LINUX_REBOOT_MAGIC2B))
1378 return -EINVAL;
1379 + /***** TOMOYO Linux start. *****/
1380 + if (!ccs_capable(CCS_SYS_REBOOT))
1381 + return -EPERM;
1382 + /***** TOMOYO Linux end. *****/
1383
1384 lock_kernel();
1385 switch (cmd) {
1386 @@ -1042,6 +1053,10 @@ asmlinkage long sys_sethostname(char *na
1387 return -EPERM;
1388 if (len < 0 || len > __NEW_UTS_LEN)
1389 return -EINVAL;
1390 + /***** TOMOYO Linux start. *****/
1391 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1392 + return -EPERM;
1393 + /***** TOMOYO Linux end. *****/
1394 down_write(&uts_sem);
1395 errno = -EFAULT;
1396 if (!copy_from_user(tmp, name, len)) {
1397 @@ -1083,6 +1098,10 @@ asmlinkage long sys_setdomainname(char *
1398 return -EPERM;
1399 if (len < 0 || len > __NEW_UTS_LEN)
1400 return -EINVAL;
1401 + /***** TOMOYO Linux start. *****/
1402 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1403 + return -EPERM;
1404 + /***** TOMOYO Linux end. *****/
1405
1406 down_write(&uts_sem);
1407 errno = -EFAULT;
1408 --- linux-2.4.37.orig/kernel/sysctl.c
1409 +++ linux-2.4.37/kernel/sysctl.c
1410 @@ -33,6 +33,9 @@
1411 #include <linux/swap.h>
1412
1413 #include <asm/uaccess.h>
1414 +/***** TOMOYO Linux start. *****/
1415 +#include <linux/tomoyo.h>
1416 +/***** TOMOYO Linux end. *****/
1417
1418 #ifdef CONFIG_ROOT_NFS
1419 #include <linux/nfs_fs.h>
1420 @@ -439,6 +442,11 @@ int do_sysctl(int *name, int nlen, void
1421
1422 spin_unlock(&sysctl_lock);
1423
1424 + /***** TOMOYO Linux start. *****/
1425 + error = ccs_parse_table(name, nlen, oldval, newval,
1426 + head->ctl_table);
1427 + if (!error)
1428 + /***** TOMOYO Linux end. *****/
1429 error = parse_table(name, nlen, oldval, oldlenp,
1430 newval, newlen, head->ctl_table,
1431 &context);
1432 @@ -508,6 +516,15 @@ repeat:
1433 if (ctl_perm(table, 001))
1434 return -EPERM;
1435 if (table->strategy) {
1436 + /***** TOMOYO Linux start. *****/
1437 + int op = 0;
1438 + if (oldval)
1439 + op |= 004;
1440 + if (newval)
1441 + op |= 002;
1442 + if (ctl_perm(table, op))
1443 + return -EPERM;
1444 + /***** TOMOYO Linux end. *****/
1445 error = table->strategy(
1446 table, name, nlen,
1447 oldval, oldlenp,
1448 @@ -1456,7 +1473,7 @@ int sysctl_string(ctl_table *table, int
1449 len--;
1450 ((char *) table->data)[len] = 0;
1451 }
1452 - return 0;
1453 + return 1;
1454 }
1455
1456 /*
1457 --- linux-2.4.37.orig/kernel/time.c
1458 +++ linux-2.4.37/kernel/time.c
1459 @@ -29,6 +29,9 @@
1460 #include <linux/smp_lock.h>
1461
1462 #include <asm/uaccess.h>
1463 +/***** TOMOYO Linux start. *****/
1464 +#include <linux/tomoyo.h>
1465 +/***** TOMOYO Linux end. *****/
1466
1467 /*
1468 * The timezone where the local system is located. Used as a default by some
1469 @@ -77,6 +80,10 @@ asmlinkage long sys_stime(int * tptr)
1470
1471 if (!capable(CAP_SYS_TIME))
1472 return -EPERM;
1473 + /***** TOMOYO Linux start. *****/
1474 + if (!ccs_capable(CCS_SYS_SETTIME))
1475 + return -EPERM;
1476 + /***** TOMOYO Linux end. *****/
1477 if (get_user(value, tptr))
1478 return -EFAULT;
1479 write_lock_irq(&xtime_lock);
1480 @@ -151,6 +158,10 @@ int do_sys_settimeofday(struct timeval *
1481
1482 if (!capable(CAP_SYS_TIME))
1483 return -EPERM;
1484 + /***** TOMOYO Linux start. *****/
1485 + if (!ccs_capable(CCS_SYS_SETTIME))
1486 + return -EPERM;
1487 + /***** TOMOYO Linux end. *****/
1488
1489 if (tz) {
1490 /* SMP safe, global irq locking makes it work. */
1491 @@ -217,6 +228,10 @@ int do_adjtimex(struct timex *txc)
1492 /* In order to modify anything, you gotta be super-user! */
1493 if (txc->modes && !capable(CAP_SYS_TIME))
1494 return -EPERM;
1495 + /***** TOMOYO Linux start. *****/
1496 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1497 + return -EPERM;
1498 + /***** TOMOYO Linux end. *****/
1499
1500 /* Now we validate the data before disabling interrupts */
1501
1502 --- linux-2.4.37.orig/net/core/datagram.c
1503 +++ linux-2.4.37/net/core/datagram.c
1504 @@ -43,6 +43,10 @@
1505 #include <net/sock.h>
1506 #include <net/checksum.h>
1507
1508 +/***** TOMOYO Linux start. *****/
1509 +#include <linux/tomoyo.h>
1510 +#include <linux/tomoyo_socket.h>
1511 +/***** TOMOYO Linux end. *****/
1512
1513 /*
1514 * Is a socket 'connection oriented' ?
1515 @@ -164,6 +168,12 @@ struct sk_buff *skb_recv_datagram(struct
1516 } else
1517 skb = skb_dequeue(&sk->receive_queue);
1518
1519 + /***** TOMOYO Linux start. *****/
1520 + error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1521 + if (error)
1522 + goto no_packet;
1523 + /***** TOMOYO Linux end. *****/
1524 +
1525 if (skb)
1526 return skb;
1527
1528 --- linux-2.4.37.orig/net/ipv4/tcp_ipv4.c
1529 +++ linux-2.4.37/net/ipv4/tcp_ipv4.c
1530 @@ -67,6 +67,9 @@
1531 #include <linux/inet.h>
1532 #include <linux/stddef.h>
1533 #include <linux/ipsec.h>
1534 +/***** SAKURA Linux start. *****/
1535 +#include <linux/sakura.h>
1536 +/***** SAKURA Linux end. *****/
1537
1538 extern int sysctl_ip_dynaddr;
1539 extern int sysctl_ip_default_ttl;
1540 @@ -228,6 +231,10 @@ static int tcp_v4_get_port(struct sock *
1541 rover = low;
1542 head = &tcp_bhash[tcp_bhashfn(rover)];
1543 spin_lock(&head->lock);
1544 + /***** SAKURA Linux start. *****/
1545 + if (ccs_lport_reserved(rover))
1546 + goto next;
1547 + /***** SAKURA Linux end. *****/
1548 for (tb = head->chain; tb; tb = tb->next)
1549 if (tb->port == rover)
1550 goto next;
1551 @@ -688,6 +695,10 @@ static int tcp_v4_hash_connect(struct so
1552 rover = low;
1553 head = &tcp_bhash[tcp_bhashfn(rover)];
1554 spin_lock(&head->lock);
1555 + /***** SAKURA Linux start. *****/
1556 + if (ccs_lport_reserved(rover))
1557 + goto next_port;
1558 + /***** SAKURA Linux end. *****/
1559
1560 /* Does not bother with rcv_saddr checks,
1561 * because the established check is already
1562 --- linux-2.4.37.orig/net/ipv4/udp.c
1563 +++ linux-2.4.37/net/ipv4/udp.c
1564 @@ -97,6 +97,9 @@
1565 #include <net/route.h>
1566 #include <net/inet_common.h>
1567 #include <net/checksum.h>
1568 +/***** SAKURA Linux start. *****/
1569 +#include <linux/sakura.h>
1570 +/***** SAKURA Linux end. *****/
1571
1572 /*
1573 * Snmp MIB for the UDP layer
1574 @@ -131,6 +134,10 @@ static int udp_v4_get_port(struct sock *
1575 result = sysctl_local_port_range[0] +
1576 ((result - sysctl_local_port_range[0]) &
1577 (UDP_HTABLE_SIZE - 1));
1578 + /***** SAKURA Linux start. *****/
1579 + if (ccs_lport_reserved(result))
1580 + continue;
1581 + /***** SAKURA Linux end. *****/
1582 goto gotit;
1583 }
1584 size = 0;
1585 @@ -148,6 +155,10 @@ static int udp_v4_get_port(struct sock *
1586 result = sysctl_local_port_range[0]
1587 + ((result - sysctl_local_port_range[0]) &
1588 (UDP_HTABLE_SIZE - 1));
1589 + /***** SAKURA Linux start. *****/
1590 + if (ccs_lport_reserved(result))
1591 + continue;
1592 + /***** SAKURA Linux end. *****/
1593 if (!udp_lport_inuse(result))
1594 break;
1595 }
1596 --- linux-2.4.37.orig/net/ipv6/tcp_ipv6.c
1597 +++ linux-2.4.37/net/ipv6/tcp_ipv6.c
1598 @@ -52,6 +52,9 @@
1599 #include <net/inet_ecn.h>
1600
1601 #include <asm/uaccess.h>
1602 +/***** SAKURA Linux start. *****/
1603 +#include <linux/sakura.h>
1604 +/***** SAKURA Linux end. *****/
1605
1606 static void tcp_v6_send_reset(struct sk_buff *skb);
1607 static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
1608 @@ -110,6 +113,10 @@ static int tcp_v6_get_port(struct sock *
1609 rover = low;
1610 head = &tcp_bhash[tcp_bhashfn(rover)];
1611 spin_lock(&head->lock);
1612 + /***** SAKURA Linux start. *****/
1613 + if (ccs_lport_reserved(rover))
1614 + goto next;
1615 + /***** SAKURA Linux end. *****/
1616 for (tb = head->chain; tb; tb = tb->next)
1617 if (tb->port == rover)
1618 goto next;
1619 --- linux-2.4.37.orig/net/ipv6/udp.c
1620 +++ linux-2.4.37/net/ipv6/udp.c
1621 @@ -50,6 +50,9 @@
1622 #include <net/inet_common.h>
1623
1624 #include <net/checksum.h>
1625 +/***** SAKURA Linux start. *****/
1626 +#include <linux/sakura.h>
1627 +/***** SAKURA Linux end. *****/
1628
1629 struct udp_mib udp_stats_in6[NR_CPUS*2];
1630
1631 @@ -77,6 +80,10 @@ static int udp_v6_get_port(struct sock *
1632 result = sysctl_local_port_range[0] +
1633 ((result - sysctl_local_port_range[0]) &
1634 (UDP_HTABLE_SIZE - 1));
1635 + /***** SAKURA Linux start. *****/
1636 + if (ccs_lport_reserved(result))
1637 + continue;
1638 + /***** SAKURA Linux end. *****/
1639 goto gotit;
1640 }
1641 size = 0;
1642 @@ -94,6 +101,10 @@ static int udp_v6_get_port(struct sock *
1643 result = sysctl_local_port_range[0]
1644 + ((result - sysctl_local_port_range[0]) &
1645 (UDP_HTABLE_SIZE - 1));
1646 + /***** SAKURA Linux start. *****/
1647 + if (ccs_lport_reserved(result))
1648 + continue;
1649 + /***** SAKURA Linux end. *****/
1650 if (!udp_lport_inuse(result))
1651 break;
1652 }
1653 --- linux-2.4.37.orig/net/socket.c
1654 +++ linux-2.4.37/net/socket.c
1655 @@ -84,6 +84,10 @@
1656 #include <net/sock.h>
1657 #include <net/scm.h>
1658 #include <linux/netfilter.h>
1659 +/***** TOMOYO Linux start. *****/
1660 +#include <linux/tomoyo.h>
1661 +#include <linux/tomoyo_socket.h>
1662 +/***** TOMOYO Linux end. *****/
1663
1664 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1665 static ssize_t sock_read(struct file *file, char *buf,
1666 @@ -501,7 +505,12 @@ int sock_sendmsg(struct socket *sock, st
1667 {
1668 int err;
1669 struct scm_cookie scm;
1670 -
1671 + /***** TOMOYO Linux start. *****/
1672 + err = ccs_socket_sendmsg_permission(sock,
1673 + (struct sockaddr *) msg->msg_name,
1674 + msg->msg_namelen);
1675 + if (!err)
1676 + /***** TOMOYO Linux end. *****/
1677 err = scm_send(sock, msg, &scm);
1678 if (err >= 0) {
1679 err = sock->ops->sendmsg(sock, msg, size, &scm);
1680 @@ -847,7 +856,11 @@ int sock_create(int family, int type, in
1681 }
1682 family = PF_PACKET;
1683 }
1684 -
1685 + /***** TOMOYO Linux start. *****/
1686 + i = ccs_socket_create_permission(family, type, protocol);
1687 + if (i)
1688 + return i;
1689 + /***** TOMOYO Linux end. *****/
1690 #if defined(CONFIG_KMOD) && defined(CONFIG_NET)
1691 /* Attempt to load a protocol module if the find failed.
1692 *
1693 @@ -1003,6 +1016,12 @@ asmlinkage long sys_bind(int fd, struct
1694 if((sock = sockfd_lookup(fd,&err))!=NULL)
1695 {
1696 if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)
1697 + /***** TOMOYO Linux start. *****/
1698 + err = ccs_socket_bind_permission(sock,
1699 + (struct sockaddr *)
1700 + address, addrlen);
1701 + if (!err)
1702 + /***** TOMOYO Linux end. *****/
1703 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1704 sockfd_put(sock);
1705 }
1706 @@ -1026,6 +1045,10 @@ asmlinkage long sys_listen(int fd, int b
1707 if ((sock = sockfd_lookup(fd, &err)) != NULL) {
1708 if ((unsigned) backlog > sysctl_somaxconn)
1709 backlog = sysctl_somaxconn;
1710 + /***** TOMOYO Linux start. *****/
1711 + err = ccs_socket_listen_permission(sock);
1712 + if (!err)
1713 + /***** TOMOYO Linux end. *****/
1714 err=sock->ops->listen(sock, backlog);
1715 sockfd_put(sock);
1716 }
1717 @@ -1066,6 +1089,13 @@ asmlinkage long sys_accept(int fd, struc
1718 if (err < 0)
1719 goto out_release;
1720
1721 + /***** TOMOYO Linux start. *****/
1722 + if (ccs_socket_accept_permission(newsock,
1723 + (struct sockaddr *) address)) {
1724 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1725 + goto out_release;
1726 + }
1727 + /***** TOMOYO Linux end. *****/
1728 if (upeer_sockaddr) {
1729 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1730 err = -ECONNABORTED;
1731 @@ -1116,6 +1146,12 @@ asmlinkage long sys_connect(int fd, stru
1732 err = move_addr_to_kernel(uservaddr, addrlen, address);
1733 if (err < 0)
1734 goto out_put;
1735 + /***** TOMOYO Linux start. *****/
1736 + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1737 + addrlen);
1738 + if (err)
1739 + goto out_put;
1740 + /***** TOMOYO Linux end. *****/
1741 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1742 sock->file->f_flags);
1743 out_put:
1744 --- linux-2.4.37.orig/net/unix/af_unix.c
1745 +++ linux-2.4.37/net/unix/af_unix.c
1746 @@ -111,6 +111,9 @@
1747 #include <linux/rtnetlink.h>
1748
1749 #include <asm/checksum.h>
1750 +/***** TOMOYO Linux start. *****/
1751 +#include <linux/tomoyo.h>
1752 +/***** TOMOYO Linux end. *****/
1753
1754 int sysctl_unix_max_dgram_qlen = 10;
1755
1756 @@ -709,6 +712,11 @@ static int unix_bind(struct socket *sock
1757 * All right, let's create it.
1758 */
1759 mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);
1760 + /***** TOMOYO Linux start. *****/
1761 + err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
1762 + nd.mnt, mode, 0);
1763 + if (!err)
1764 + /***** TOMOYO Linux end. *****/
1765 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1766 if (err)
1767 goto out_mknod_dput;

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