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

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 3838 - (hide annotations) (download) (as text)
Fri Jul 23 03:20:04 2010 UTC (13 years, 10 months ago) by kumaneko
Original Path: branches/ccs-patch/patches/ccs-patch-2.4.37.diff
File MIME type: text/x-diff
File size: 42986 byte(s)


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

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