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

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 2796 - (show annotations) (download) (as text)
Thu Jul 23 09:07:39 2009 UTC (14 years, 10 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: 43680 byte(s)


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

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