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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2279 - (hide annotations) (download) (as text)
Wed Mar 18 09:16:37 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: 57140 byte(s)
Fix misplaced ccs_capable() for kernel 2.6.8 and kernel 2.6.9 . Add ccs_check_ioctl_permission() for TOMOYO 1.6.7 . 
1 kumaneko 1913 This is TOMOYO Linux patch for kernel 2.4.37.
2 kumaneko 1603
3 kumaneko 1913 Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.tar.bz2
4 kumaneko 1603 ---
5 kumaneko 1768 Documentation/Configure.help | 86 +++++++++++++++++++++++++++++
6 kumaneko 2278 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 kumaneko 1603 fs/Config.in | 3 +
28     fs/Makefile | 2
29     fs/attr.c | 10 +++
30     fs/exec.c | 21 ++++++-
31     fs/fcntl.c | 8 ++
32 kumaneko 2279 fs/ioctl.c | 14 ++++
33 kumaneko 1603 fs/namei.c | 127 +++++++++++++++++++++++++++++++++++++++++++
34     fs/namespace.c | 58 +++++++++++++++++++
35     fs/open.c | 29 +++++++++
36     fs/proc/Makefile | 4 +
37     fs/proc/proc_misc.c | 5 +
38     include/linux/sched.h | 13 ++++
39     kernel/kmod.c | 5 +
40     kernel/module.c | 15 +++++
41     kernel/sched.c | 7 ++
42     kernel/signal.c | 15 +++++
43     kernel/sys.c | 19 ++++++
44     kernel/sysctl.c | 113 +++++++++++++++++++++++++++++++++++++-
45     kernel/time.c | 15 +++++
46     net/core/datagram.c | 10 +++
47     net/ipv4/tcp_ipv4.c | 11 +++
48     net/ipv4/udp.c | 11 +++
49     net/ipv6/tcp_ipv6.c | 7 ++
50     net/ipv6/udp.c | 11 +++
51     net/socket.c | 40 ++++++++++++-
52     net/unix/af_unix.c | 15 +++++
53 kumaneko 2279 48 files changed, 823 insertions(+), 6 deletions(-)
54 kumaneko 1603
55 kumaneko 1913 --- linux-2.4.37.orig/Documentation/Configure.help
56     +++ linux-2.4.37/Documentation/Configure.help
57 kumaneko 1811 @@ -29158,6 +29158,92 @@ CONFIG_SOUND_WM97XX
58 kumaneko 1603
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 kumaneko 1913 --- linux-2.4.37.orig/arch/alpha/kernel/ptrace.c
151     +++ linux-2.4.37/arch/alpha/kernel/ptrace.c
152 kumaneko 1603 @@ -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 kumaneko 2278 @@ -251,6 +254,10 @@ sys_ptrace(long request, long pid, long
163 kumaneko 1603 {
164     struct task_struct *child;
165     long ret;
166     + /***** TOMOYO Linux start. *****/
167     + if (!ccs_capable(TOMOYO_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 kumaneko 1913 --- linux-2.4.37.orig/arch/arm/kernel/ptrace.c
174     +++ linux-2.4.37/arch/arm/kernel/ptrace.c
175 kumaneko 1603 @@ -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 kumaneko 2278 @@ -695,6 +698,10 @@ asmlinkage int sys_ptrace(long request,
186 kumaneko 1603 {
187     struct task_struct *child;
188     int ret;
189     + /***** TOMOYO Linux start. *****/
190     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
191     + return -EPERM;
192     + /***** TOMOYO Linux end. *****/
193    
194     lock_kernel();
195     ret = -EPERM;
196 kumaneko 1913 --- linux-2.4.37.orig/arch/cris/kernel/ptrace.c
197     +++ linux-2.4.37/arch/cris/kernel/ptrace.c
198 kumaneko 1603 @@ -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 kumaneko 2278 @@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request,
209 kumaneko 1603 {
210     struct task_struct *child;
211     int ret;
212     + /***** TOMOYO Linux start. *****/
213     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
214     + return -EPERM;
215     + /***** TOMOYO Linux end. *****/
216    
217     lock_kernel();
218     ret = -EPERM;
219 kumaneko 1913 --- linux-2.4.37.orig/arch/i386/kernel/ptrace.c
220     +++ linux-2.4.37/arch/i386/kernel/ptrace.c
221 kumaneko 1603 @@ -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 kumaneko 2278 @@ -152,6 +155,10 @@ asmlinkage int sys_ptrace(long request,
232 kumaneko 1603 struct task_struct *child;
233     struct user * dummy = NULL;
234     int i, ret;
235     + /***** TOMOYO Linux start. *****/
236     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
237     + return -EPERM;
238     + /***** TOMOYO Linux end. *****/
239    
240     lock_kernel();
241     ret = -EPERM;
242 kumaneko 1913 --- linux-2.4.37.orig/arch/ia64/ia32/sys_ia32.c
243     +++ linux-2.4.37/arch/ia64/ia32/sys_ia32.c
244 kumaneko 1603 @@ -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 kumaneko 2278 @@ -3131,6 +3134,10 @@ sys32_ptrace (int request, pid_t pid, un
255 kumaneko 1603 struct task_struct *child;
256     unsigned int value, tmp;
257     long i, ret;
258     + /***** TOMOYO Linux start. *****/
259     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
260     + return -EPERM;
261     + /***** TOMOYO Linux end. *****/
262    
263     lock_kernel();
264     if (request == PTRACE_TRACEME) {
265 kumaneko 1913 --- linux-2.4.37.orig/arch/ia64/kernel/ptrace.c
266     +++ linux-2.4.37/arch/ia64/kernel/ptrace.c
267 kumaneko 1603 @@ -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 kumaneko 2278 @@ -1273,6 +1276,10 @@ sys_ptrace (long request, pid_t pid, uns
278 kumaneko 1603 struct task_struct *child;
279     struct switch_stack *sw;
280     long ret;
281     + /***** TOMOYO Linux start. *****/
282     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
283     + return -EPERM;
284     + /***** TOMOYO Linux end. *****/
285    
286     lock_kernel();
287     ret = -EPERM;
288 kumaneko 1913 --- linux-2.4.37.orig/arch/m68k/kernel/ptrace.c
289     +++ linux-2.4.37/arch/m68k/kernel/ptrace.c
290 kumaneko 1603 @@ -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 kumaneko 2278 @@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request,
301 kumaneko 1603 {
302     struct task_struct *child;
303     int ret;
304     + /***** TOMOYO Linux start. *****/
305     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
306     + return -EPERM;
307     + /***** TOMOYO Linux end. *****/
308    
309     lock_kernel();
310     ret = -EPERM;
311 kumaneko 1913 --- linux-2.4.37.orig/arch/mips/kernel/ptrace.c
312     +++ linux-2.4.37/arch/mips/kernel/ptrace.c
313 kumaneko 1603 @@ -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 kumaneko 2278 @@ -43,6 +46,10 @@ asmlinkage int sys_ptrace(long request,
324 kumaneko 1603 {
325     struct task_struct *child;
326     int ret;
327     + /***** TOMOYO Linux start. *****/
328     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
329     + return -EPERM;
330     + /***** TOMOYO Linux end. *****/
331    
332     lock_kernel();
333     #if 0
334 kumaneko 1913 --- linux-2.4.37.orig/arch/mips64/kernel/ptrace.c
335     +++ linux-2.4.37/arch/mips64/kernel/ptrace.c
336 kumaneko 1603 @@ -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 kumaneko 2278 @@ -49,6 +52,10 @@ asmlinkage int sys32_ptrace(int request,
347 kumaneko 1603 {
348     struct task_struct *child;
349     int ret;
350     + /***** TOMOYO Linux start. *****/
351     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
352     + return -EPERM;
353     + /***** TOMOYO Linux end. *****/
354    
355     lock_kernel();
356     ret = -EPERM;
357 kumaneko 2278 @@ -288,6 +295,10 @@ asmlinkage int sys_ptrace(long request,
358 kumaneko 1603 {
359     struct task_struct *child;
360     int ret;
361     + /***** TOMOYO Linux start. *****/
362     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
363     + return -EPERM;
364     + /***** TOMOYO Linux end. *****/
365    
366     lock_kernel();
367     #if 0
368 kumaneko 1913 --- linux-2.4.37.orig/arch/parisc/kernel/ptrace.c
369     +++ linux-2.4.37/arch/parisc/kernel/ptrace.c
370 kumaneko 1603 @@ -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 kumaneko 2278 @@ -94,6 +97,10 @@ long sys_ptrace(long request, pid_t pid,
381 kumaneko 1603 #ifdef DEBUG_PTRACE
382     long oaddr=addr, odata=data;
383     #endif
384     + /***** TOMOYO Linux start. *****/
385     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
386     + return -EPERM;
387     + /***** TOMOYO Linux end. *****/
388    
389     lock_kernel();
390     ret = -EPERM;
391 kumaneko 1913 --- linux-2.4.37.orig/arch/ppc/kernel/ptrace.c
392     +++ linux-2.4.37/arch/ppc/kernel/ptrace.c
393 kumaneko 1603 @@ -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 kumaneko 2278 @@ -171,6 +174,10 @@ int sys_ptrace(long request, long pid, l
404 kumaneko 1603 {
405     struct task_struct *child;
406     int ret = -EPERM;
407     + /***** TOMOYO Linux start. *****/
408     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
409     + return -EPERM;
410     + /***** TOMOYO Linux end. *****/
411    
412     lock_kernel();
413     if (request == PTRACE_TRACEME) {
414 kumaneko 1913 --- linux-2.4.37.orig/arch/ppc64/kernel/ptrace.c
415     +++ linux-2.4.37/arch/ppc64/kernel/ptrace.c
416 kumaneko 1603 @@ -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 kumaneko 2278 @@ -120,6 +123,10 @@ int sys_ptrace(long request, long pid, l
427 kumaneko 1603 {
428     struct task_struct *child;
429     int ret = -EPERM;
430     + /***** TOMOYO Linux start. *****/
431     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
432     + return -EPERM;
433     + /***** TOMOYO Linux end. *****/
434    
435     lock_kernel();
436     if (request == PTRACE_TRACEME) {
437 kumaneko 1913 --- linux-2.4.37.orig/arch/ppc64/kernel/ptrace32.c
438     +++ linux-2.4.37/arch/ppc64/kernel/ptrace32.c
439 kumaneko 1603 @@ -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 kumaneko 2278 @@ -121,6 +124,10 @@ int sys32_ptrace(long request, long pid,
450 kumaneko 1603 {
451     struct task_struct *child;
452     int ret = -EPERM;
453     + /***** TOMOYO Linux start. *****/
454     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
455     + return -EPERM;
456     + /***** TOMOYO Linux end. *****/
457    
458     lock_kernel();
459     if (request == PTRACE_TRACEME) {
460 kumaneko 1913 --- linux-2.4.37.orig/arch/s390/kernel/ptrace.c
461     +++ linux-2.4.37/arch/s390/kernel/ptrace.c
462 kumaneko 1603 @@ -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 kumaneko 2278 @@ -221,6 +224,10 @@ asmlinkage int sys_ptrace(long request,
473 kumaneko 1603 unsigned long tmp;
474     int copied;
475     ptrace_area parea;
476     + /***** TOMOYO Linux start. *****/
477     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
478     + return -EPERM;
479     + /***** TOMOYO Linux end. *****/
480    
481     lock_kernel();
482     if (request == PTRACE_TRACEME)
483 kumaneko 1913 --- linux-2.4.37.orig/arch/s390x/kernel/ptrace.c
484     +++ linux-2.4.37/arch/s390x/kernel/ptrace.c
485 kumaneko 1603 @@ -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 kumaneko 2278 @@ -431,6 +434,10 @@ asmlinkage int sys_ptrace(long request,
496 kumaneko 1603 #define sizeof_parent_long 8
497     #define dataptr (u8 *)&data
498     #endif
499     + /***** TOMOYO Linux start. *****/
500     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
501     + return -EPERM;
502     + /***** TOMOYO Linux end. *****/
503     lock_kernel();
504     if (request == PTRACE_TRACEME)
505     {
506 kumaneko 1913 --- linux-2.4.37.orig/arch/sh/kernel/ptrace.c
507     +++ linux-2.4.37/arch/sh/kernel/ptrace.c
508 kumaneko 1603 @@ -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 kumaneko 2278 @@ -144,6 +147,10 @@ asmlinkage int sys_ptrace(long request,
519 kumaneko 1603 struct task_struct *child, *tsk = current;
520     struct user * dummy = NULL;
521     int ret;
522     + /***** TOMOYO Linux start. *****/
523     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
524     + return -EPERM;
525     + /***** TOMOYO Linux end. *****/
526    
527     lock_kernel();
528     ret = -EPERM;
529 kumaneko 1913 --- linux-2.4.37.orig/arch/sh64/kernel/ptrace.c
530     +++ linux-2.4.37/arch/sh64/kernel/ptrace.c
531 kumaneko 1603 @@ -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 kumaneko 2278 @@ -122,6 +125,10 @@ asmlinkage int sys_ptrace(long request,
542 kumaneko 1603 {
543     struct task_struct *child, *tsk = current;
544     int ret;
545     + /***** TOMOYO Linux start. *****/
546     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
547     + return -EPERM;
548     + /***** TOMOYO Linux end. *****/
549    
550     lock_kernel();
551     ret = -EPERM;
552 kumaneko 1913 --- linux-2.4.37.orig/arch/sparc/kernel/ptrace.c
553     +++ linux-2.4.37/arch/sparc/kernel/ptrace.c
554 kumaneko 1603 @@ -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 kumaneko 2278 @@ -262,6 +265,12 @@ asmlinkage void do_ptrace(struct pt_regs
565 kumaneko 1603 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(TOMOYO_SYS_PTRACE)) {
570     + pt_error_return(regs, EPERM);
571     + return;
572     + }
573     + /***** TOMOYO Linux end. *****/
574    
575     lock_kernel();
576     #ifdef DEBUG_PTRACE
577 kumaneko 1913 --- linux-2.4.37.orig/arch/sparc64/kernel/ptrace.c
578     +++ linux-2.4.37/arch/sparc64/kernel/ptrace.c
579 kumaneko 1603 @@ -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 kumaneko 2278 @@ -108,6 +111,12 @@ asmlinkage void do_ptrace(struct pt_regs
590 kumaneko 1603 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(TOMOYO_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 kumaneko 1913 --- linux-2.4.37.orig/arch/x86_64/ia32/ptrace32.c
603     +++ linux-2.4.37/arch/x86_64/ia32/ptrace32.c
604 kumaneko 1603 @@ -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 kumaneko 2278 @@ -203,6 +206,10 @@ asmlinkage long sys32_ptrace(long reques
615 kumaneko 1603 struct pt_regs *childregs;
616     int ret;
617     __u32 val;
618     + /***** TOMOYO Linux start. *****/
619     + if (!ccs_capable(TOMOYO_SYS_PTRACE))
620     + return -EPERM;
621     + /***** TOMOYO Linux end. *****/
622    
623     switch (request) {
624     case PTRACE_TRACEME:
625 kumaneko 1913 --- linux-2.4.37.orig/arch/x86_64/kernel/ptrace.c
626     +++ linux-2.4.37/arch/x86_64/kernel/ptrace.c
627 kumaneko 1603 @@ -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 kumaneko 2278 @@ -180,6 +183,10 @@ asmlinkage long sys_ptrace(long request,
638 kumaneko 1603 struct task_struct *child;
639     struct user * dummy = NULL;
640     long i, ret;
641     + /***** TOMOYO Linux start. *****/
642     + if (!ccs_capable(TOMOYO_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 kumaneko 1913 --- linux-2.4.37.orig/fs/Config.in
649     +++ linux-2.4.37/fs/Config.in
650 kumaneko 1603 @@ -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 kumaneko 1913 --- linux-2.4.37.orig/fs/Makefile
659     +++ linux-2.4.37/fs/Makefile
660 kumaneko 1603 @@ -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 kumaneko 1913 --- linux-2.4.37.orig/fs/attr.c
668     +++ linux-2.4.37/fs/attr.c
669 kumaneko 1603 @@ -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(TOMOYO_SYS_CHMOD))
685     + return -EPERM;
686     + if ((ia_valid & (ATTR_UID | ATTR_GID)) &&
687     + !ccs_capable(TOMOYO_SYS_CHOWN))
688     + return -EPERM;
689     + /***** TOMOYO Linux end. *****/
690    
691     lock_kernel();
692     if (inode->i_op && inode->i_op->setattr)
693 kumaneko 1913 --- linux-2.4.37.orig/fs/exec.c
694     +++ linux-2.4.37/fs/exec.c
695 kumaneko 1603 @@ -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->tomoyo_flags &
726     + TOMOYO_CHECK_READ_FOR_OPEN_EXEC))
727     + /* 01 means "read". */
728     + err = ccs_check_open_permission(nd.dentry,
729     + nd.mnt, 01);
730     + /***** TOMOYO Linux end. *****/
731     file = ERR_PTR(err);
732     if (!err) {
733     file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
734     @@ -986,7 +1004,8 @@ int do_execve(char * filename, char ** a
735     if (retval < 0)
736     goto out;
737    
738     - retval = search_binary_handler(&bprm,regs);
739     + retval = search_binary_handler_with_transition(&bprm, regs);
740     +
741     if (retval >= 0)
742     /* execve success */
743     return retval;
744 kumaneko 1913 --- linux-2.4.37.orig/fs/fcntl.c
745     +++ linux-2.4.37/fs/fcntl.c
746 kumaneko 1603 @@ -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 kumaneko 1913 --- linux-2.4.37.orig/fs/ioctl.c
769     +++ linux-2.4.37/fs/ioctl.c
770 kumaneko 1603 @@ -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 kumaneko 2279 @@ -55,6 +58,11 @@ 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     + goto out;
788     + /***** TOMOYO Linux end. *****/
789     error = 0;
790     lock_kernel();
791     switch (cmd) {
792     @@ -112,6 +120,12 @@ asmlinkage long sys_ioctl(unsigned int f
793 kumaneko 1603 error = -ENOTTY;
794     break;
795     default:
796     + /***** TOMOYO Linux start. *****/
797     + if (!ccs_capable(TOMOYO_SYS_IOCTL)) {
798     + error = -EPERM;
799     + break;
800     + }
801     + /***** TOMOYO Linux end. *****/
802     error = -ENOTTY;
803     if (S_ISREG(filp->f_dentry->d_inode->i_mode))
804     error = file_ioctl(filp, cmd, arg);
805 kumaneko 1913 --- linux-2.4.37.orig/fs/namei.c
806     +++ linux-2.4.37/fs/namei.c
807 kumaneko 1603 @@ -28,6 +28,11 @@
808    
809     #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
810    
811     +/***** TOMOYO Linux start. *****/
812     +#include <linux/tomoyo.h>
813     +#include <linux/module.h>
814     +/***** TOMOYO Linux end. *****/
815     +
816     /* [Feb-1997 T. Schoebel-Theuer]
817     * Fundamental changes in the pathname lookup mechanisms (namei)
818     * were necessary because of omirr. The reason is that omirr needs
819 kumaneko 1811 @@ -1003,6 +1008,9 @@ exit_lock:
820 kumaneko 1603 return error;
821     }
822    
823     +/***** TOMOYO Linux start. *****/
824     +#include <linux/tomoyo_vfs.h>
825     +/***** TOMOYO Linux end. *****/
826     /*
827     * open_namei()
828     *
829 kumaneko 1811 @@ -1068,6 +1076,13 @@ do_last:
830 kumaneko 1603
831     /* Negative dentry, just create the file */
832     if (!dentry->d_inode) {
833     + /***** TOMOYO Linux start. *****/
834     + error = pre_vfs_create(dir->d_inode, dentry);
835     + if (!error)
836     + error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry,
837     + nd->mnt);
838     + if (!error)
839     + /***** TOMOYO Linux end. *****/
840     error = vfs_create(dir->d_inode, dentry,
841     mode & ~current->fs->umask);
842     up(&dir->d_inode->i_sem);
843 kumaneko 1811 @@ -1154,6 +1169,13 @@ ok:
844 kumaneko 1603 goto exit;
845     }
846    
847     + /***** TOMOYO Linux start. *****/
848     + /* includes O_APPEND and O_TRUNC checks */
849     + error = ccs_check_open_permission(dentry, nd->mnt, flag);
850     + if (error)
851     + goto exit;
852     + /***** TOMOYO Linux end. *****/
853     +
854     /*
855     * Ensure there are no outstanding leases on the file.
856     */
857 kumaneko 1811 @@ -1292,6 +1314,17 @@ asmlinkage long sys_mknod(const char * f
858 kumaneko 1603
859     if (S_ISDIR(mode))
860     return -EPERM;
861     + /***** TOMOYO Linux start. *****/
862     + if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV))
863     + return -EPERM;
864     + if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV))
865     + return -EPERM;
866     + if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO))
867     + return -EPERM;
868     + if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
869     + return -EPERM;
870     + /***** TOMOYO Linux end. *****/
871     +
872     tmp = getname(filename);
873     if (IS_ERR(tmp))
874     return PTR_ERR(tmp);
875 kumaneko 1811 @@ -1306,9 +1339,33 @@ asmlinkage long sys_mknod(const char * f
876 kumaneko 1603 if (!IS_ERR(dentry)) {
877     switch (mode & S_IFMT) {
878     case 0: case S_IFREG:
879     + /***** TOMOYO Linux start. *****/
880     + error = pre_vfs_create(nd.dentry->d_inode, dentry);
881     + if (error)
882     + break;
883     + error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry,
884     + nd.mnt);
885     + if (error)
886     + break;
887     + /***** TOMOYO Linux end. *****/
888     error = vfs_create(nd.dentry->d_inode,dentry,mode);
889     break;
890     case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
891     + /***** TOMOYO Linux start. *****/
892     + error = pre_vfs_mknod(nd.dentry->d_inode, dentry);
893     + if (error)
894     + break;
895     + error = ccs_check_1path_perm(S_ISCHR(mode) ?
896     + TYPE_MKCHAR_ACL :
897     + S_ISBLK(mode) ?
898     + TYPE_MKBLOCK_ACL :
899     + S_ISFIFO(mode) ?
900     + TYPE_MKFIFO_ACL :
901     + TYPE_MKSOCK_ACL,
902     + dentry, nd.mnt);
903     + if (error)
904     + break;
905     + /***** TOMOYO Linux end. *****/
906     error = vfs_mknod(nd.dentry->d_inode,dentry,mode,dev);
907     break;
908     case S_IFDIR:
909 kumaneko 1811 @@ -1370,6 +1427,13 @@ asmlinkage long sys_mkdir(const char * p
910 kumaneko 1603 dentry = lookup_create(&nd, 1);
911     error = PTR_ERR(dentry);
912     if (!IS_ERR(dentry)) {
913     + /***** TOMOYO Linux start. *****/
914     + error = pre_vfs_mkdir(nd.dentry->d_inode, dentry);
915     + if (!error)
916     + error = ccs_check_1path_perm(TYPE_MKDIR_ACL,
917     + dentry, nd.mnt);
918     + if (!error)
919     + /***** TOMOYO Linux end. *****/
920     error = vfs_mkdir(nd.dentry->d_inode, dentry,
921     mode & ~current->fs->umask);
922     dput(dentry);
923 kumaneko 1811 @@ -1479,6 +1543,13 @@ asmlinkage long sys_rmdir(const char * p
924 kumaneko 1603 dentry = lookup_hash(&nd.last, nd.dentry);
925     error = PTR_ERR(dentry);
926     if (!IS_ERR(dentry)) {
927     + /***** TOMOYO Linux start. *****/
928     + error = pre_vfs_rmdir(nd.dentry->d_inode, dentry);
929     + if (!error)
930     + error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry,
931     + nd.mnt);
932     + if (!error)
933     + /***** TOMOYO Linux end. *****/
934     error = vfs_rmdir(nd.dentry->d_inode, dentry);
935     dput(dentry);
936     }
937 kumaneko 1811 @@ -1530,6 +1601,10 @@ asmlinkage long sys_unlink(const char *
938 kumaneko 1603 char * name;
939     struct dentry *dentry;
940     struct nameidata nd;
941     + /***** TOMOYO Linux start. *****/
942     + if (!ccs_capable(TOMOYO_SYS_UNLINK))
943     + return -EPERM;
944     + /***** TOMOYO Linux end. *****/
945    
946     name = getname(pathname);
947     if(IS_ERR(name))
948 kumaneko 1811 @@ -1548,6 +1623,14 @@ asmlinkage long sys_unlink(const char *
949 kumaneko 1603 /* Why not before? Because we want correct error value */
950     if (nd.last.name[nd.last.len])
951     goto slashes;
952     + /***** TOMOYO Linux start. *****/
953     + error = pre_vfs_unlink(nd.dentry->d_inode, dentry);
954     + if (error)
955     + goto exit2;
956     + error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt);
957     + if (error)
958     + goto exit2;
959     + /***** TOMOYO Linux end. *****/
960     error = vfs_unlink(nd.dentry->d_inode, dentry);
961     exit2:
962     dput(dentry);
963 kumaneko 1811 @@ -1596,6 +1679,10 @@ asmlinkage long sys_symlink(const char *
964 kumaneko 1603 int error = 0;
965     char * from;
966     char * to;
967     + /***** TOMOYO Linux start. *****/
968     + if (!ccs_capable(TOMOYO_SYS_SYMLINK))
969     + return -EPERM;
970     + /***** TOMOYO Linux end. *****/
971    
972     from = getname(oldname);
973     if(IS_ERR(from))
974 kumaneko 1811 @@ -1612,6 +1699,13 @@ asmlinkage long sys_symlink(const char *
975 kumaneko 1603 dentry = lookup_create(&nd, 0);
976     error = PTR_ERR(dentry);
977     if (!IS_ERR(dentry)) {
978     + /***** TOMOYO Linux start. *****/
979     + error = pre_vfs_symlink(nd.dentry->d_inode, dentry);
980     + if (!error)
981     + error = ccs_check_1path_perm(TYPE_SYMLINK_ACL,
982     + dentry, nd.mnt);
983     + if (!error)
984     + /***** TOMOYO Linux end. *****/
985     error = vfs_symlink(nd.dentry->d_inode, dentry, from);
986     dput(dentry);
987     }
988 kumaneko 1811 @@ -1679,6 +1773,10 @@ asmlinkage long sys_link(const char * ol
989 kumaneko 1603 {
990     int error;
991     char * to;
992     + /***** TOMOYO Linux start. *****/
993     + if (!ccs_capable(TOMOYO_SYS_LINK))
994     + return -EPERM;
995     + /***** TOMOYO Linux end. *****/
996    
997     to = getname(newname);
998     error = PTR_ERR(to);
999 kumaneko 1811 @@ -1698,6 +1796,17 @@ asmlinkage long sys_link(const char * ol
1000 kumaneko 1603 new_dentry = lookup_create(&nd, 0);
1001     error = PTR_ERR(new_dentry);
1002     if (!IS_ERR(new_dentry)) {
1003     + /***** TOMOYO Linux start. *****/
1004     + error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode,
1005     + new_dentry);
1006     + if (!error)
1007     + error = ccs_check_2path_perm(TYPE_LINK_ACL,
1008     + old_nd.dentry,
1009     + old_nd.mnt,
1010     + new_dentry,
1011     + nd.mnt);
1012     + if (!error)
1013     + /***** TOMOYO Linux end. *****/
1014     error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
1015     dput(new_dentry);
1016     }
1017 kumaneko 1811 @@ -1928,6 +2037,20 @@ static inline int do_rename(const char *
1018 kumaneko 1603 error = PTR_ERR(new_dentry);
1019     if (IS_ERR(new_dentry))
1020     goto exit4;
1021     + /***** TOMOYO Linux start. *****/
1022     + error = pre_vfs_rename(old_dir->d_inode, old_dentry,
1023     + new_dir->d_inode, new_dentry);
1024     + if (error) {
1025     + dput(new_dentry);
1026     + goto exit4;
1027     + }
1028     + error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt,
1029     + new_dentry, newnd.mnt);
1030     + if (error) {
1031     + dput(new_dentry);
1032     + goto exit4;
1033     + }
1034     + /***** TOMOYO Linux end. *****/
1035    
1036     lock_kernel();
1037     error = vfs_rename(old_dir->d_inode, old_dentry,
1038 kumaneko 1811 @@ -1952,6 +2075,10 @@ asmlinkage long sys_rename(const char *
1039 kumaneko 1603 int error;
1040     char * from;
1041     char * to;
1042     + /***** TOMOYO Linux start. *****/
1043     + if (!ccs_capable(TOMOYO_SYS_RENAME))
1044     + return -EPERM;
1045     + /***** TOMOYO Linux end. *****/
1046    
1047     from = getname(oldname);
1048     if(IS_ERR(from))
1049 kumaneko 1913 --- linux-2.4.37.orig/fs/namespace.c
1050     +++ linux-2.4.37/fs/namespace.c
1051 kumaneko 1603 @@ -21,6 +21,13 @@
1052     #include <linux/seq_file.h>
1053     #include <linux/namespace.h>
1054    
1055     +/***** SAKURA Linux start. *****/
1056     +#include <linux/sakura.h>
1057     +/***** SAKURA Linux end. *****/
1058     +/***** TOMOYO Linux start. *****/
1059     +#include <linux/tomoyo.h>
1060     +/***** TOMOYO Linux end. *****/
1061     +
1062     struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
1063     int do_remount_sb(struct super_block *sb, int flags, void * data);
1064     void kill_super(struct super_block *sb);
1065     @@ -290,6 +297,10 @@ static int do_umount(struct vfsmount *mn
1066     {
1067     struct super_block * sb = mnt->mnt_sb;
1068     int retval = 0;
1069     + /***** SAKURA Linux start. *****/
1070     + if (ccs_may_umount(mnt))
1071     + return -EPERM;
1072     + /***** SAKURA Linux end. *****/
1073    
1074     /*
1075     * If we may have to abort operations to get out of this
1076     @@ -365,6 +376,10 @@ asmlinkage long sys_umount(char * name,
1077     {
1078     struct nameidata nd;
1079     int retval;
1080     + /***** TOMOYO Linux start. *****/
1081     + if (!ccs_capable(TOMOYO_SYS_UMOUNT))
1082     + return -EPERM;
1083     + /***** TOMOYO Linux end. *****/
1084    
1085     retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd);
1086     if (retval)
1087     @@ -500,6 +515,11 @@ static int do_loopback(struct nameidata
1088     down_write(&current->namespace->sem);
1089     err = -EINVAL;
1090     if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {
1091     + /***** SAKURA Linux start. *****/
1092     + err = -EPERM;
1093     + if (ccs_may_mount(nd))
1094     + goto out;
1095     + /***** SAKURA Linux end. *****/
1096     err = -ENOMEM;
1097     if (recurse)
1098     mnt = copy_tree(old_nd.mnt, old_nd.dentry);
1099     @@ -516,7 +536,9 @@ static int do_loopback(struct nameidata
1100     } else
1101     mntput(mnt);
1102     }
1103     -
1104     + /***** SAKURA Linux start. *****/
1105     + out:
1106     + /***** SAKURA Linux end. *****/
1107     up_write(&current->namespace->sem);
1108     path_release(&old_nd);
1109     return err;
1110     @@ -570,6 +592,12 @@ static int do_move_mount(struct nameidat
1111     if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
1112     goto out;
1113    
1114     + /***** SAKURA Linux start. *****/
1115     + err = -EPERM;
1116     + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
1117     + goto out;
1118     + /***** SAKURA Linux end. *****/
1119     +
1120     err = -ENOENT;
1121     down(&nd->dentry->d_inode->i_zombie);
1122     if (IS_DEADDIR(nd->dentry->d_inode))
1123     @@ -641,6 +669,12 @@ static int do_add_mount(struct nameidata
1124     if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry)
1125     goto unlock;
1126    
1127     + /***** SAKURA Linux start. *****/
1128     + err = -EPERM;
1129     + if (ccs_may_mount(nd))
1130     + goto unlock;
1131     + /***** SAKURA Linux end. *****/
1132     +
1133     mnt->mnt_flags = mnt_flags;
1134     err = graft_tree(mnt, nd);
1135     unlock:
1136     @@ -718,6 +752,17 @@ long do_mount(char * dev_name, char * di
1137     if (data_page)
1138     ((char *)data_page)[PAGE_SIZE - 1] = 0;
1139    
1140     + /***** TOMOYO Linux start. *****/
1141     + if (!ccs_capable(TOMOYO_SYS_MOUNT))
1142     + return -EPERM;
1143     + /***** TOMOYO Linux end. *****/
1144     + /***** SAKURA Linux start. *****/
1145     + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
1146     + &flags);
1147     + if (retval)
1148     + return retval;
1149     + /***** SAKURA Linux end. *****/
1150     +
1151     /* Separate the per-mountpoint flags */
1152     if (flags & MS_NOSUID)
1153     mnt_flags |= MNT_NOSUID;
1154     @@ -911,6 +956,10 @@ asmlinkage long sys_pivot_root(const cha
1155    
1156     if (!capable(CAP_SYS_ADMIN))
1157     return -EPERM;
1158     + /***** TOMOYO Linux start. *****/
1159     + if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT))
1160     + return -EPERM;
1161     + /***** TOMOYO Linux end. *****/
1162    
1163     lock_kernel();
1164    
1165     @@ -925,6 +974,13 @@ asmlinkage long sys_pivot_root(const cha
1166     if (error)
1167     goto out1;
1168    
1169     + /***** SAKURA Linux start. *****/
1170     + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
1171     + if (error) {
1172     + path_release(&old_nd);
1173     + goto out1;
1174     + }
1175     + /***** SAKURA Linux end. *****/
1176     read_lock(&current->fs->lock);
1177     user_nd.mnt = mntget(current->fs->rootmnt);
1178     user_nd.dentry = dget(current->fs->root);
1179 kumaneko 1913 --- linux-2.4.37.orig/fs/open.c
1180     +++ linux-2.4.37/fs/open.c
1181 kumaneko 1603 @@ -20,6 +20,13 @@
1182    
1183     #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1184    
1185     +/***** SAKURA Linux start. *****/
1186     +#include <linux/sakura.h>
1187     +/***** SAKURA Linux end. *****/
1188     +/***** TOMOYO Linux start. *****/
1189     +#include <linux/tomoyo.h>
1190     +/***** TOMOYO Linux end. *****/
1191     +
1192     int vfs_statfs(struct super_block *sb, struct statfs *buf)
1193     {
1194     int retval = -ENODEV;
1195 kumaneko 1811 @@ -164,6 +171,11 @@ static inline long do_sys_truncate(const
1196 kumaneko 1603 if (error)
1197     goto dput_and_out;
1198    
1199     + /***** TOMOYO Linux start. *****/
1200     + error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt);
1201     + if (!error)
1202     + /***** TOMOYO Linux end. *****/
1203     +
1204     error = locks_verify_truncate(inode, NULL, length);
1205     if (!error) {
1206     DQUOT_INIT(inode);
1207 kumaneko 1811 @@ -217,6 +229,11 @@ static inline long do_sys_ftruncate(unsi
1208 kumaneko 1603 if (IS_APPEND(inode))
1209     goto out_putf;
1210    
1211     + /***** TOMOYO Linux start. *****/
1212     + error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt);
1213     + if (error)
1214     + goto out_putf;
1215     + /***** TOMOYO Linux end. *****/
1216     error = locks_verify_truncate(inode, file, length);
1217     if (!error)
1218     error = do_truncate(dentry, length);
1219 kumaneko 1811 @@ -466,6 +483,14 @@ asmlinkage long sys_chroot(const char *
1220 kumaneko 1603 error = -EPERM;
1221     if (!capable(CAP_SYS_CHROOT))
1222     goto dput_and_out;
1223     + /***** TOMOYO Linux start. *****/
1224     + if (!ccs_capable(TOMOYO_SYS_CHROOT))
1225     + goto dput_and_out;
1226     + /***** TOMOYO Linux end. *****/
1227     + /***** SAKURA Linux start. *****/
1228     + if (ccs_check_chroot_permission(&nd))
1229     + goto dput_and_out;
1230     + /***** SAKURA Linux end. *****/
1231    
1232     set_fs_root(current->fs, nd.mnt, nd.dentry);
1233     set_fs_altroot();
1234 kumaneko 1811 @@ -897,6 +922,10 @@ out_unlock:
1235 kumaneko 1603 */
1236     asmlinkage long sys_vhangup(void)
1237     {
1238     + /***** TOMOYO Linux start. *****/
1239     + if (!ccs_capable(TOMOYO_SYS_VHANGUP))
1240     + return -EPERM;
1241     + /***** TOMOYO Linux end. *****/
1242     if (capable(CAP_SYS_TTY_CONFIG)) {
1243     tty_vhangup(current->tty);
1244     return 0;
1245 kumaneko 1913 --- linux-2.4.37.orig/fs/proc/Makefile
1246     +++ linux-2.4.37/fs/proc/Makefile
1247 kumaneko 1603 @@ -18,4 +18,8 @@ ifeq ($(CONFIG_PROC_DEVICETREE),y)
1248     obj-y += proc_devtree.o
1249     endif
1250    
1251     +export-objs += ccs_proc.o
1252     +obj-$(CONFIG_SAKURA) += ccs_proc.o
1253     +obj-$(CONFIG_TOMOYO) += ccs_proc.o
1254     +
1255     include $(TOPDIR)/Rules.make
1256 kumaneko 1913 --- linux-2.4.37.orig/fs/proc/proc_misc.c
1257     +++ linux-2.4.37/fs/proc/proc_misc.c
1258 kumaneko 1603 @@ -670,4 +670,9 @@ void __init proc_misc_init(void)
1259     entry->proc_fops = &ppc_htab_operations;
1260     }
1261     #endif
1262     + /***** CCS start. *****/
1263     +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
1264 kumaneko 2279 + printk(KERN_INFO "Hook version: 2.4.37 2009/03/18\n");
1265 kumaneko 1603 +#endif
1266     + /***** CCS end. *****/
1267     }
1268 kumaneko 1913 --- linux-2.4.37.orig/include/linux/sched.h
1269     +++ linux-2.4.37/include/linux/sched.h
1270 kumaneko 1603 @@ -29,6 +29,11 @@ extern unsigned long event;
1271    
1272     struct exec_domain;
1273    
1274     +/***** TOMOYO Linux start. *****/
1275     +struct domain_info;
1276     +extern struct domain_info KERNEL_DOMAIN;
1277     +/***** TOMOYO Linux end. *****/
1278     +
1279     /*
1280     * cloning flags:
1281     */
1282 kumaneko 1811 @@ -417,6 +422,10 @@ struct task_struct {
1283     void *journal_info;
1284 kumaneko 1603
1285 kumaneko 1811 struct list_head *scm_work_list;
1286 kumaneko 1603 + /***** TOMOYO Linux start. *****/
1287     + struct domain_info *domain_info;
1288     + u32 tomoyo_flags;
1289     + /***** TOMOYO Linux end. *****/
1290     };
1291    
1292     /*
1293 kumaneko 1811 @@ -512,6 +521,10 @@ extern struct exec_domain default_exec_d
1294 kumaneko 1603 blocked: {{0}}, \
1295     alloc_lock: SPIN_LOCK_UNLOCKED, \
1296     journal_info: NULL, \
1297     + /***** TOMOYO Linux start. *****/ \
1298     + domain_info: &KERNEL_DOMAIN, \
1299     + tomoyo_flags: 0 \
1300     + /***** TOMOYO Linux end. *****/ \
1301     }
1302    
1303    
1304 kumaneko 1913 --- linux-2.4.37.orig/kernel/kmod.c
1305     +++ linux-2.4.37/kernel/kmod.c
1306 kumaneko 1603 @@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa
1307     /* Allow execve args to be in kernel space. */
1308     set_fs(KERNEL_DS);
1309    
1310     + /***** TOMOYO Linux start. *****/
1311     + current->domain_info = &KERNEL_DOMAIN;
1312     + current->tomoyo_flags = 0;
1313     + /***** TOMOYO Linux end. *****/
1314     +
1315     /* Go, go, go... */
1316     if (execve(program_path, argv, envp) < 0)
1317     return -errno;
1318 kumaneko 1913 --- linux-2.4.37.orig/kernel/module.c
1319     +++ linux-2.4.37/kernel/module.c
1320 kumaneko 1603 @@ -10,6 +10,9 @@
1321     #include <linux/slab.h>
1322     #include <linux/kmod.h>
1323     #include <linux/seq_file.h>
1324     +/***** TOMOYO Linux start. *****/
1325     +#include <linux/tomoyo.h>
1326     +/***** TOMOYO Linux end. *****/
1327    
1328     /*
1329     * Originally by Anonymous (as far as I know...)
1330     @@ -298,6 +301,10 @@ sys_create_module(const char *name_user,
1331    
1332     if (!capable(CAP_SYS_MODULE))
1333     return -EPERM;
1334     + /***** TOMOYO Linux start. *****/
1335     + if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1336     + return -EPERM;
1337     + /***** TOMOYO Linux end. *****/
1338     lock_kernel();
1339     if ((namelen = get_mod_name(name_user, &name)) < 0) {
1340     error = namelen;
1341     @@ -353,6 +360,10 @@ sys_init_module(const char *name_user, s
1342    
1343     if (!capable(CAP_SYS_MODULE))
1344     return -EPERM;
1345     + /***** TOMOYO Linux start. *****/
1346     + if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1347     + return -EPERM;
1348     + /***** TOMOYO Linux end. *****/
1349     lock_kernel();
1350     if ((namelen = get_mod_name(name_user, &name)) < 0) {
1351     error = namelen;
1352     @@ -614,6 +625,10 @@ sys_delete_module(const char *name_user)
1353    
1354     if (!capable(CAP_SYS_MODULE))
1355     return -EPERM;
1356     + /***** TOMOYO Linux start. *****/
1357     + if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1358     + return -EPERM;
1359     + /***** TOMOYO Linux end. *****/
1360    
1361     lock_kernel();
1362     if (name_user) {
1363 kumaneko 1913 --- linux-2.4.37.orig/kernel/sched.c
1364     +++ linux-2.4.37/kernel/sched.c
1365 kumaneko 1603 @@ -32,6 +32,9 @@
1366    
1367     #include <asm/uaccess.h>
1368     #include <asm/mmu_context.h>
1369     +/***** TOMOYO Linux start. *****/
1370     +#include <linux/tomoyo.h>
1371     +/***** TOMOYO Linux end. *****/
1372    
1373     extern void timer_bh(void);
1374     extern void tqueue_bh(void);
1375     @@ -899,6 +902,10 @@ void set_cpus_allowed(struct task_struct
1376     asmlinkage long sys_nice(int increment)
1377     {
1378     long newprio;
1379     + /***** TOMOYO Linux start. *****/
1380     + if (!ccs_capable(TOMOYO_SYS_NICE))
1381     + return -EPERM;
1382     + /***** TOMOYO Linux end. *****/
1383    
1384     /*
1385     * Setpriority might change our priority at the same moment.
1386 kumaneko 1913 --- linux-2.4.37.orig/kernel/signal.c
1387     +++ linux-2.4.37/kernel/signal.c
1388 kumaneko 1603 @@ -15,6 +15,9 @@
1389     #include <linux/sched.h>
1390    
1391     #include <asm/uaccess.h>
1392     +/***** TOMOYO Linux start. *****/
1393     +#include <linux/tomoyo.h>
1394     +/***** TOMOYO Linux end. *****/
1395    
1396     /*
1397     * SLAB caches for signal bits.
1398     @@ -1025,6 +1028,12 @@ asmlinkage long
1399     sys_kill(int pid, int sig)
1400     {
1401     struct siginfo info;
1402     + /***** TOMOYO Linux start. *****/
1403     + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1404     + return -EPERM;
1405     + if (sig && ccs_check_signal_acl(sig, pid))
1406     + return -EPERM;
1407     + /***** TOMOYO Linux end. *****/
1408    
1409     info.si_signo = sig;
1410     info.si_errno = 0;
1411     @@ -1049,6 +1058,12 @@ sys_tkill(int pid, int sig)
1412     if (pid <= 0)
1413     return -EINVAL;
1414    
1415     + /***** TOMOYO Linux start. *****/
1416     + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1417     + return -EPERM;
1418     + if (sig && ccs_check_signal_acl(sig, pid))
1419     + return -EPERM;
1420     + /***** TOMOYO Linux end. *****/
1421     info.si_signo = sig;
1422     info.si_errno = 0;
1423     info.si_code = SI_TKILL;
1424 kumaneko 1913 --- linux-2.4.37.orig/kernel/sys.c
1425     +++ linux-2.4.37/kernel/sys.c
1426 kumaneko 1603 @@ -17,6 +17,9 @@
1427    
1428     #include <asm/uaccess.h>
1429     #include <asm/io.h>
1430     +/***** TOMOYO Linux start. *****/
1431     +#include <linux/tomoyo.h>
1432     +/***** TOMOYO Linux end. *****/
1433    
1434     #ifndef SET_UNALIGN_CTL
1435     # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1436     @@ -220,6 +223,10 @@ asmlinkage long sys_setpriority(int whic
1437    
1438     if (which > 2 || which < 0)
1439     return -EINVAL;
1440     + /***** TOMOYO Linux start. *****/
1441     + if (!ccs_capable(TOMOYO_SYS_NICE))
1442     + return -EPERM;
1443     + /***** TOMOYO Linux end. *****/
1444    
1445     /* normalize: avoid signed division (rounding problems) */
1446     error = -ESRCH;
1447     @@ -299,6 +306,10 @@ asmlinkage long sys_reboot(int magic1, i
1448     (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A &&
1449     magic2 != LINUX_REBOOT_MAGIC2B))
1450     return -EINVAL;
1451     + /***** TOMOYO Linux start. *****/
1452     + if (!ccs_capable(TOMOYO_SYS_REBOOT))
1453     + return -EPERM;
1454     + /***** TOMOYO Linux end. *****/
1455    
1456     lock_kernel();
1457     switch (cmd) {
1458     @@ -1042,6 +1053,10 @@ asmlinkage long sys_sethostname(char *na
1459     return -EPERM;
1460     if (len < 0 || len > __NEW_UTS_LEN)
1461     return -EINVAL;
1462     + /***** TOMOYO Linux start. *****/
1463     + if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1464     + return -EPERM;
1465     + /***** TOMOYO Linux end. *****/
1466     down_write(&uts_sem);
1467     errno = -EFAULT;
1468     if (!copy_from_user(tmp, name, len)) {
1469     @@ -1083,6 +1098,10 @@ asmlinkage long sys_setdomainname(char *
1470     return -EPERM;
1471     if (len < 0 || len > __NEW_UTS_LEN)
1472     return -EINVAL;
1473     + /***** TOMOYO Linux start. *****/
1474     + if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1475     + return -EPERM;
1476     + /***** TOMOYO Linux end. *****/
1477    
1478     down_write(&uts_sem);
1479     errno = -EFAULT;
1480 kumaneko 1913 --- linux-2.4.37.orig/kernel/sysctl.c
1481     +++ linux-2.4.37/kernel/sysctl.c
1482 kumaneko 1603 @@ -33,6 +33,9 @@
1483     #include <linux/swap.h>
1484    
1485     #include <asm/uaccess.h>
1486     +/***** TOMOYO Linux start. *****/
1487     +#include <linux/tomoyo.h>
1488     +/***** TOMOYO Linux end. *****/
1489    
1490     #ifdef CONFIG_ROOT_NFS
1491     #include <linux/nfs_fs.h>
1492     @@ -411,6 +414,100 @@ void __init sysctl_init(void)
1493     #endif
1494     }
1495    
1496     +/***** TOMOYO Linux start. *****/
1497     +static int try_parse_table(int __user *name, int nlen, void __user *oldval,
1498     + void __user *newval, ctl_table *table)
1499     +{
1500     + int n;
1501     + int error = -ENOMEM;
1502     + int op = 0;
1503     + char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1504     + if (oldval)
1505     + op |= 004;
1506     + if (newval)
1507     + op |= 002;
1508     + if (!op) { /* Neither read nor write */
1509     + error = 0;
1510     + goto out;
1511     + }
1512     + if (!buffer)
1513     + goto out;
1514     + memset(buffer, 0, PAGE_SIZE);
1515     + snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1516     + repeat:
1517     + if (!nlen) {
1518     + error = -ENOTDIR;
1519     + goto out;
1520     + }
1521     + if (get_user(n, name)) {
1522     + error = -EFAULT;
1523     + goto out;
1524     + }
1525     + for ( ; table->ctl_name; table++) {
1526     + if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1527     + int pos = strlen(buffer);
1528     + const char *cp = table->procname;
1529     + error = -ENOMEM;
1530     + if (cp) {
1531     + if (pos + 1 >= PAGE_SIZE - 1)
1532     + goto out;
1533     + buffer[pos++] = '/';
1534     + while (*cp) {
1535     + const unsigned char c
1536     + = *(const unsigned char *) cp;
1537     + if (c == '\\') {
1538     + if (pos + 2 >= PAGE_SIZE - 1)
1539     + goto out;
1540     + buffer[pos++] = '\\';
1541     + buffer[pos++] = '\\';
1542     + } else if (c > ' ' && c < 127) {
1543     + if (pos + 1 >= PAGE_SIZE - 1)
1544     + goto out;
1545     + buffer[pos++] = c;
1546     + } else {
1547     + if (pos + 4 >= PAGE_SIZE - 1)
1548     + goto out;
1549     + buffer[pos++] = '\\';
1550     + buffer[pos++] = (c >> 6) + '0';
1551     + buffer[pos++] = ((c >> 3) & 7)
1552     + + '0';
1553     + buffer[pos++] = (c & 7) + '0';
1554     + }
1555     + cp++;
1556     + }
1557     + } else {
1558     + /* Assume nobody assigns "=\$=" for procname. */
1559     + snprintf(buffer + pos, PAGE_SIZE - pos - 1,
1560     + "/=%d=", table->ctl_name);
1561     + if (!memchr(buffer, '\0', PAGE_SIZE - 2))
1562     + goto out;
1563     + }
1564     + if (table->child) {
1565     + if (table->strategy) {
1566     + /* printk("sysctl='%s'\n", buffer); */
1567     + if (ccs_check_file_perm(buffer, op,
1568     + "sysctl")) {
1569     + error = -EPERM;
1570     + goto out;
1571     + }
1572     + }
1573     + name++;
1574     + nlen--;
1575     + table = table->child;
1576     + goto repeat;
1577     + }
1578     + /* printk("sysctl='%s'\n", buffer); */
1579     + error = ccs_check_file_perm(buffer, op, "sysctl");
1580     + goto out;
1581     + }
1582     + }
1583     + error = -ENOTDIR;
1584     + out:
1585     + kfree(buffer);
1586     + return error;
1587     +}
1588     +/***** TOMOYO Linux end. *****/
1589     +
1590     int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
1591     void *newval, size_t newlen)
1592     {
1593     @@ -439,6 +536,11 @@ int do_sysctl(int *name, int nlen, void
1594    
1595     spin_unlock(&sysctl_lock);
1596    
1597     + /***** TOMOYO Linux start. *****/
1598     + error = try_parse_table(name, nlen, oldval, newval,
1599     + head->ctl_table);
1600     + if (!error)
1601     + /***** TOMOYO Linux end. *****/
1602     error = parse_table(name, nlen, oldval, oldlenp,
1603     newval, newlen, head->ctl_table,
1604     &context);
1605     @@ -508,6 +610,15 @@ repeat:
1606     if (ctl_perm(table, 001))
1607     return -EPERM;
1608     if (table->strategy) {
1609     + /***** TOMOYO Linux start. *****/
1610     + int op = 0;
1611     + if (oldval)
1612     + op |= 004;
1613     + if (newval)
1614     + op |= 002;
1615     + if (ctl_perm(table, op))
1616     + return -EPERM;
1617     + /***** TOMOYO Linux end. *****/
1618     error = table->strategy(
1619     table, name, nlen,
1620     oldval, oldlenp,
1621     @@ -1456,7 +1567,7 @@ int sysctl_string(ctl_table *table, int
1622     len--;
1623     ((char *) table->data)[len] = 0;
1624     }
1625     - return 0;
1626     + return 1;
1627     }
1628    
1629     /*
1630 kumaneko 1913 --- linux-2.4.37.orig/kernel/time.c
1631     +++ linux-2.4.37/kernel/time.c
1632 kumaneko 1603 @@ -29,6 +29,9 @@
1633     #include <linux/smp_lock.h>
1634    
1635     #include <asm/uaccess.h>
1636     +/***** TOMOYO Linux start. *****/
1637     +#include <linux/tomoyo.h>
1638     +/***** TOMOYO Linux end. *****/
1639    
1640     /*
1641     * The timezone where the local system is located. Used as a default by some
1642     @@ -77,6 +80,10 @@ asmlinkage long sys_stime(int * tptr)
1643    
1644     if (!capable(CAP_SYS_TIME))
1645     return -EPERM;
1646     + /***** TOMOYO Linux start. *****/
1647     + if (!ccs_capable(TOMOYO_SYS_SETTIME))
1648     + return -EPERM;
1649     + /***** TOMOYO Linux end. *****/
1650     if (get_user(value, tptr))
1651     return -EFAULT;
1652     write_lock_irq(&xtime_lock);
1653     @@ -151,6 +158,10 @@ int do_sys_settimeofday(struct timeval *
1654    
1655     if (!capable(CAP_SYS_TIME))
1656     return -EPERM;
1657     + /***** TOMOYO Linux start. *****/
1658     + if (!ccs_capable(TOMOYO_SYS_SETTIME))
1659     + return -EPERM;
1660     + /***** TOMOYO Linux end. *****/
1661    
1662     if (tz) {
1663     /* SMP safe, global irq locking makes it work. */
1664     @@ -217,6 +228,10 @@ int do_adjtimex(struct timex *txc)
1665     /* In order to modify anything, you gotta be super-user! */
1666     if (txc->modes && !capable(CAP_SYS_TIME))
1667     return -EPERM;
1668     + /***** TOMOYO Linux start. *****/
1669     + if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME))
1670     + return -EPERM;
1671     + /***** TOMOYO Linux end. *****/
1672    
1673     /* Now we validate the data before disabling interrupts */
1674    
1675 kumaneko 1913 --- linux-2.4.37.orig/net/core/datagram.c
1676     +++ linux-2.4.37/net/core/datagram.c
1677 kumaneko 1603 @@ -43,6 +43,10 @@
1678     #include <net/sock.h>
1679     #include <net/checksum.h>
1680    
1681     +/***** TOMOYO Linux start. *****/
1682     +#include <linux/tomoyo.h>
1683     +#include <linux/tomoyo_socket.h>
1684     +/***** TOMOYO Linux end. *****/
1685    
1686     /*
1687     * Is a socket 'connection oriented' ?
1688     @@ -164,6 +168,12 @@ struct sk_buff *skb_recv_datagram(struct
1689     } else
1690     skb = skb_dequeue(&sk->receive_queue);
1691    
1692     + /***** TOMOYO Linux start. *****/
1693     + error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1694     + if (error)
1695     + goto no_packet;
1696     + /***** TOMOYO Linux end. *****/
1697     +
1698     if (skb)
1699     return skb;
1700    
1701 kumaneko 1913 --- linux-2.4.37.orig/net/ipv4/tcp_ipv4.c
1702     +++ linux-2.4.37/net/ipv4/tcp_ipv4.c
1703 kumaneko 1603 @@ -67,6 +67,9 @@
1704     #include <linux/inet.h>
1705     #include <linux/stddef.h>
1706     #include <linux/ipsec.h>
1707     +/***** SAKURA Linux start. *****/
1708     +#include <linux/sakura.h>
1709     +/***** SAKURA Linux end. *****/
1710    
1711     extern int sysctl_ip_dynaddr;
1712     extern int sysctl_ip_default_ttl;
1713     @@ -228,6 +231,10 @@ static int tcp_v4_get_port(struct sock *
1714     rover = low;
1715     head = &tcp_bhash[tcp_bhashfn(rover)];
1716     spin_lock(&head->lock);
1717     + /***** SAKURA Linux start. *****/
1718     + if (ccs_may_autobind(rover))
1719     + goto next;
1720     + /***** SAKURA Linux end. *****/
1721     for (tb = head->chain; tb; tb = tb->next)
1722     if (tb->port == rover)
1723     goto next;
1724     @@ -688,6 +695,10 @@ static int tcp_v4_hash_connect(struct so
1725     rover = low;
1726     head = &tcp_bhash[tcp_bhashfn(rover)];
1727     spin_lock(&head->lock);
1728     + /***** SAKURA Linux start. *****/
1729     + if (ccs_may_autobind(rover))
1730     + goto next_port;
1731     + /***** SAKURA Linux end. *****/
1732    
1733     /* Does not bother with rcv_saddr checks,
1734     * because the established check is already
1735 kumaneko 1913 --- linux-2.4.37.orig/net/ipv4/udp.c
1736     +++ linux-2.4.37/net/ipv4/udp.c
1737 kumaneko 1603 @@ -97,6 +97,9 @@
1738     #include <net/route.h>
1739     #include <net/inet_common.h>
1740     #include <net/checksum.h>
1741     +/***** SAKURA Linux start. *****/
1742     +#include <linux/sakura.h>
1743     +/***** SAKURA Linux end. *****/
1744    
1745     /*
1746     * Snmp MIB for the UDP layer
1747     @@ -131,6 +134,10 @@ static int udp_v4_get_port(struct sock *
1748     result = sysctl_local_port_range[0] +
1749     ((result - sysctl_local_port_range[0]) &
1750     (UDP_HTABLE_SIZE - 1));
1751     + /***** SAKURA Linux start. *****/
1752     + if (ccs_may_autobind(result))
1753     + continue;
1754     + /***** SAKURA Linux end. *****/
1755     goto gotit;
1756     }
1757     size = 0;
1758     @@ -148,6 +155,10 @@ static int udp_v4_get_port(struct sock *
1759     result = sysctl_local_port_range[0]
1760     + ((result - sysctl_local_port_range[0]) &
1761     (UDP_HTABLE_SIZE - 1));
1762     + /***** SAKURA Linux start. *****/
1763     + if (ccs_may_autobind(result))
1764     + continue;
1765     + /***** SAKURA Linux end. *****/
1766     if (!udp_lport_inuse(result))
1767     break;
1768     }
1769 kumaneko 1913 --- linux-2.4.37.orig/net/ipv6/tcp_ipv6.c
1770     +++ linux-2.4.37/net/ipv6/tcp_ipv6.c
1771 kumaneko 1603 @@ -52,6 +52,9 @@
1772     #include <net/inet_ecn.h>
1773    
1774     #include <asm/uaccess.h>
1775     +/***** SAKURA Linux start. *****/
1776     +#include <linux/sakura.h>
1777     +/***** SAKURA Linux end. *****/
1778    
1779     static void tcp_v6_send_reset(struct sk_buff *skb);
1780     static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
1781     @@ -110,6 +113,10 @@ static int tcp_v6_get_port(struct sock *
1782     rover = low;
1783     head = &tcp_bhash[tcp_bhashfn(rover)];
1784     spin_lock(&head->lock);
1785     + /***** SAKURA Linux start. *****/
1786     + if (ccs_may_autobind(rover))
1787     + goto next;
1788     + /***** SAKURA Linux end. *****/
1789     for (tb = head->chain; tb; tb = tb->next)
1790     if (tb->port == rover)
1791     goto next;
1792 kumaneko 1913 --- linux-2.4.37.orig/net/ipv6/udp.c
1793     +++ linux-2.4.37/net/ipv6/udp.c
1794 kumaneko 1603 @@ -50,6 +50,9 @@
1795     #include <net/inet_common.h>
1796    
1797     #include <net/checksum.h>
1798     +/***** SAKURA Linux start. *****/
1799     +#include <linux/sakura.h>
1800     +/***** SAKURA Linux end. *****/
1801    
1802     struct udp_mib udp_stats_in6[NR_CPUS*2];
1803    
1804     @@ -77,6 +80,10 @@ static int udp_v6_get_port(struct sock *
1805     result = sysctl_local_port_range[0] +
1806     ((result - sysctl_local_port_range[0]) &
1807     (UDP_HTABLE_SIZE - 1));
1808     + /***** SAKURA Linux start. *****/
1809     + if (ccs_may_autobind(result))
1810     + continue;
1811     + /***** SAKURA Linux end. *****/
1812     goto gotit;
1813     }
1814     size = 0;
1815     @@ -94,6 +101,10 @@ static int udp_v6_get_port(struct sock *
1816     result = sysctl_local_port_range[0]
1817     + ((result - sysctl_local_port_range[0]) &
1818     (UDP_HTABLE_SIZE - 1));
1819     + /***** SAKURA Linux start. *****/
1820     + if (ccs_may_autobind(result))
1821     + continue;
1822     + /***** SAKURA Linux end. *****/
1823     if (!udp_lport_inuse(result))
1824     break;
1825     }
1826 kumaneko 1913 --- linux-2.4.37.orig/net/socket.c
1827     +++ linux-2.4.37/net/socket.c
1828 kumaneko 1603 @@ -84,6 +84,10 @@
1829     #include <net/sock.h>
1830     #include <net/scm.h>
1831     #include <linux/netfilter.h>
1832     +/***** TOMOYO Linux start. *****/
1833     +#include <linux/tomoyo.h>
1834     +#include <linux/tomoyo_socket.h>
1835     +/***** TOMOYO Linux end. *****/
1836    
1837     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1838     static ssize_t sock_read(struct file *file, char *buf,
1839     @@ -501,7 +505,12 @@ int sock_sendmsg(struct socket *sock, st
1840     {
1841     int err;
1842     struct scm_cookie scm;
1843     -
1844     + /***** TOMOYO Linux start. *****/
1845     + err = ccs_socket_sendmsg_permission(sock,
1846     + (struct sockaddr *) msg->msg_name,
1847     + msg->msg_namelen);
1848     + if (!err)
1849     + /***** TOMOYO Linux end. *****/
1850     err = scm_send(sock, msg, &scm);
1851     if (err >= 0) {
1852     err = sock->ops->sendmsg(sock, msg, size, &scm);
1853     @@ -847,7 +856,11 @@ int sock_create(int family, int type, in
1854     }
1855     family = PF_PACKET;
1856     }
1857     -
1858     + /***** TOMOYO Linux start. *****/
1859     + i = ccs_socket_create_permission(family, type, protocol);
1860     + if (i)
1861     + return i;
1862     + /***** TOMOYO Linux end. *****/
1863     #if defined(CONFIG_KMOD) && defined(CONFIG_NET)
1864     /* Attempt to load a protocol module if the find failed.
1865     *
1866     @@ -1003,6 +1016,12 @@ asmlinkage long sys_bind(int fd, struct
1867     if((sock = sockfd_lookup(fd,&err))!=NULL)
1868     {
1869     if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)
1870     + /***** TOMOYO Linux start. *****/
1871     + err = ccs_socket_bind_permission(sock,
1872     + (struct sockaddr *)
1873     + address, addrlen);
1874     + if (!err)
1875     + /***** TOMOYO Linux end. *****/
1876     err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1877     sockfd_put(sock);
1878     }
1879     @@ -1026,6 +1045,10 @@ asmlinkage long sys_listen(int fd, int b
1880     if ((sock = sockfd_lookup(fd, &err)) != NULL) {
1881     if ((unsigned) backlog > sysctl_somaxconn)
1882     backlog = sysctl_somaxconn;
1883     + /***** TOMOYO Linux start. *****/
1884     + err = ccs_socket_listen_permission(sock);
1885     + if (!err)
1886     + /***** TOMOYO Linux end. *****/
1887     err=sock->ops->listen(sock, backlog);
1888     sockfd_put(sock);
1889     }
1890     @@ -1066,6 +1089,13 @@ asmlinkage long sys_accept(int fd, struc
1891     if (err < 0)
1892     goto out_release;
1893    
1894     + /***** TOMOYO Linux start. *****/
1895     + if (ccs_socket_accept_permission(newsock,
1896     + (struct sockaddr *) address)) {
1897     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1898     + goto out_release;
1899     + }
1900     + /***** TOMOYO Linux end. *****/
1901     if (upeer_sockaddr) {
1902     if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1903     err = -ECONNABORTED;
1904     @@ -1116,6 +1146,12 @@ asmlinkage long sys_connect(int fd, stru
1905     err = move_addr_to_kernel(uservaddr, addrlen, address);
1906     if (err < 0)
1907     goto out_put;
1908     + /***** TOMOYO Linux start. *****/
1909     + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1910     + addrlen);
1911     + if (err)
1912     + goto out_put;
1913     + /***** TOMOYO Linux end. *****/
1914     err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1915     sock->file->f_flags);
1916     out_put:
1917 kumaneko 1913 --- linux-2.4.37.orig/net/unix/af_unix.c
1918     +++ linux-2.4.37/net/unix/af_unix.c
1919 kumaneko 1603 @@ -111,6 +111,9 @@
1920     #include <linux/rtnetlink.h>
1921    
1922     #include <asm/checksum.h>
1923     +/***** TOMOYO Linux start. *****/
1924     +#include <linux/tomoyo.h>
1925     +/***** TOMOYO Linux end. *****/
1926    
1927     int sysctl_unix_max_dgram_qlen = 10;
1928    
1929     @@ -645,6 +648,11 @@ static int unix_bind(struct socket *sock
1930     err = unix_autobind(sock);
1931     goto out;
1932     }
1933     + /***** TOMOYO Linux start. *****/
1934     + err = -EPERM;
1935     + if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
1936     + goto out;
1937     + /***** TOMOYO Linux end. *****/
1938    
1939     err = unix_mkname(sunaddr, addr_len, &hash);
1940     if (err < 0)
1941     @@ -709,6 +717,13 @@ static int unix_bind(struct socket *sock
1942     * All right, let's create it.
1943     */
1944     mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);
1945     + /***** TOMOYO Linux start. *****/
1946     + err = pre_vfs_mknod(nd.dentry->d_inode, dentry);
1947     + if (!err)
1948     + err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry,
1949     + nd.mnt);
1950     + if (!err)
1951     + /***** TOMOYO Linux end. *****/
1952     err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1953     if (err)
1954     goto out_mknod_dput;

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