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

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 2306 - (hide annotations) (download) (as text)
Tue Mar 24 05:35:12 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: 51905 byte(s)


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

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