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

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 2822 - (hide annotations) (download) (as text)
Tue Jul 28 02:16:00 2009 UTC (14 years, 9 months ago) by kumaneko
Original Path: trunk/1.6.x/ccs-patch/patches/ccs-patch-2.4.37.diff
File MIME type: text/x-diff
File size: 43680 byte(s)


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

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