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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/1.6.x/ccs-patch/patches/ccs-patch-2.4.37.diff revision 2851 by kumaneko, Wed Aug 5 04:58:04 2009 UTC trunk/1.7.x/ccs-patch/patches/ccs-patch-2.4.37.diff revision 3053 by kumaneko, Thu Sep 17 07:09:58 2009 UTC
# Line 1  Line 1 
1  This is TOMOYO Linux patch for kernel 2.4.37.4.  This is TOMOYO Linux patch for kernel 2.4.37.6.
2    
3  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.4.tar.bz2  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.6.tar.bz2
4  ---  ---
5   Documentation/Configure.help |   86 +++++++++++++++++++++++++++++++++++++++++++   arch/alpha/kernel/ptrace.c   |    3 +++
6   arch/alpha/kernel/ptrace.c   |    3 +   arch/arm/kernel/ptrace.c     |    3 +++
7   arch/arm/kernel/ptrace.c     |    3 +   arch/cris/kernel/ptrace.c    |    3 +++
8   arch/cris/kernel/ptrace.c    |    3 +   arch/i386/kernel/ptrace.c    |    3 +++
9   arch/i386/kernel/ptrace.c    |    3 +   arch/ia64/ia32/sys_ia32.c    |    3 +++
10   arch/ia64/ia32/sys_ia32.c    |    3 +   arch/ia64/kernel/ptrace.c    |    3 +++
11   arch/ia64/kernel/ptrace.c    |    3 +   arch/m68k/kernel/ptrace.c    |    3 +++
12   arch/m68k/kernel/ptrace.c    |    3 +   arch/mips/kernel/ptrace.c    |    3 +++
13   arch/mips/kernel/ptrace.c    |    3 +   arch/mips64/kernel/ptrace.c  |    5 +++++
14   arch/mips64/kernel/ptrace.c  |    5 ++   arch/parisc/kernel/ptrace.c  |    3 +++
15   arch/parisc/kernel/ptrace.c  |    3 +   arch/ppc/kernel/ptrace.c     |    3 +++
16   arch/ppc/kernel/ptrace.c     |    3 +   arch/ppc64/kernel/ptrace.c   |    3 +++
17   arch/ppc64/kernel/ptrace.c   |    3 +   arch/ppc64/kernel/ptrace32.c |    3 +++
18   arch/ppc64/kernel/ptrace32.c |    3 +   arch/s390/kernel/ptrace.c    |    3 +++
19   arch/s390/kernel/ptrace.c    |    3 +   arch/s390x/kernel/ptrace.c   |    3 +++
20   arch/s390x/kernel/ptrace.c   |    3 +   arch/sh/kernel/ptrace.c      |    3 +++
21   arch/sh/kernel/ptrace.c      |    3 +   arch/sh64/kernel/ptrace.c    |    3 +++
22   arch/sh64/kernel/ptrace.c    |    3 +   arch/sparc/kernel/ptrace.c   |    5 +++++
23   arch/sparc/kernel/ptrace.c   |    5 ++   arch/sparc64/kernel/ptrace.c |    5 +++++
24   arch/sparc64/kernel/ptrace.c |    5 ++   arch/x86_64/ia32/ptrace32.c  |    3 +++
25   arch/x86_64/ia32/ptrace32.c  |    3 +   arch/x86_64/kernel/ptrace.c  |    3 +++
26   arch/x86_64/kernel/ptrace.c  |    3 +   fs/Config.in                 |    3 +++
27   fs/Config.in                 |    3 +   fs/Makefile                  |    2 ++
28   fs/Makefile                  |    2 -   fs/attr.c                    |    4 ++++
29   fs/attr.c                    |    4 ++   fs/exec.c                    |   12 +++++++++++-
30   fs/exec.c                    |   12 +++++-   fs/fcntl.c                   |    4 ++++
31   fs/fcntl.c                   |    4 ++   fs/ioctl.c                   |   10 ++++++++++
32   fs/ioctl.c                   |   10 +++++   fs/namei.c                   |   40 ++++++++++++++++++++++++++++++++++++++++
33   fs/namei.c                   |   45 ++++++++++++++++++++++   fs/namespace.c               |   34 +++++++++++++++++++++++++++++++++-
34   fs/namespace.c               |   34 ++++++++++++++++-   fs/open.c                    |   29 +++++++++++++++++++++++++++++
35   fs/open.c                    |   16 ++++++++   fs/proc/proc_misc.c          |    1 +
36   fs/proc/Makefile             |    4 ++   include/linux/sched.h        |   14 ++++++++++++++
37   fs/proc/proc_misc.c          |    1   kernel/kmod.c                |    5 +++++
38   include/linux/sched.h        |    6 +++   kernel/module.c              |    7 +++++++
39   kernel/kmod.c                |    3 +   kernel/sched.c               |    3 +++
40   kernel/module.c              |    7 +++   kernel/signal.c              |    7 +++++++
41   kernel/sched.c               |    3 +   kernel/sys.c                 |    9 +++++++++
42   kernel/signal.c              |    5 ++   kernel/sysctl.c              |   13 ++++++++++++-
43   kernel/sys.c                 |    9 ++++   kernel/time.c                |    7 +++++++
44   kernel/sysctl.c              |   13 ++++++   net/ipv4/raw.c               |    4 ++++
45   kernel/time.c                |    7 +++   net/ipv4/tcp_ipv4.c          |    5 +++++
46   net/ipv4/raw.c               |    4 ++   net/ipv4/udp.c               |    8 ++++++++
47   net/ipv4/tcp_ipv4.c          |    5 ++   net/ipv6/raw.c               |    4 ++++
48   net/ipv4/udp.c               |    9 ++++   net/ipv6/tcp_ipv6.c          |    3 +++
49   net/ipv6/raw.c               |    4 ++   net/ipv6/udp.c               |    8 ++++++++
50   net/ipv6/tcp_ipv6.c          |    3 +   net/socket.c                 |   25 +++++++++++++++++++++++--
51   net/ipv6/udp.c               |    9 ++++   net/unix/af_unix.c           |    4 ++++
52   net/socket.c                 |   26 ++++++++++++-   47 files changed, 329 insertions(+), 5 deletions(-)
  net/unix/af_unix.c           |    4 ++  
  49 files changed, 401 insertions(+), 6 deletions(-)  
53    
54  --- linux-2.4.37.4.orig/Documentation/Configure.help  --- linux-2.4.37.6.orig/arch/alpha/kernel/ptrace.c
55  +++ linux-2.4.37.4/Documentation/Configure.help  +++ linux-2.4.37.6/arch/alpha/kernel/ptrace.c
 @@ -29158,6 +29158,92 @@ CONFIG_SOUND_WM97XX  
     
    If unsure, say N.  
   
 +CONFIG_SAKURA  
 +  Say Y here to support the Domain-Free Mandatory Access Control.  
 +  
 +  SAKURA stands for  
 +  "Security Advancement Know-how Upon Read-only Approach".  
 +  As the name shows, SAKURA was originally a methodology to make  
 +  root fs read-only to avoid tampering the system files.  
 +  But now, SAKURA is not only a methodology but also a kernel patch  
 +  that improves the system security with less effort.  
 +  
 +  SAKURA can restrict operations that affect systemwide.  
 +  
 +CONFIG_TOMOYO  
 +  Say Y here to support the Domain-Based Mandatory Access Control.  
 +  
 +  TOMOYO stands for "Task Oriented Management Obviates Your Onus".  
 +  TOMOYO is intended to provide the Domain-Based MAC  
 +  utilizing task_struct.  
 +  
 +  The word "domain" in TOMOYO is a class that a process  
 +  (i.e. task_struct) belong to.  
 +  The domain of a process changes whenever the process  
 +  executes a program.  
 +  This allows you to classify at the finest level.  
 +  The access permission is granted to domains, not to processes.  
 +  Policy is defined as "Which domain can access to which resource.".  
 +  
 +  The biggest feature of TOMOYO is that TOMOYO has "learning mode".  
 +  The learning mode can automatically generate policy definition,  
 +  and dramatically reduces the policy definition labors.  
 +  
 +  TOMOYO is applicable to figuring out the system's behavior, for  
 +  TOMOYO uses the canonicalized absolute pathnames and  
 +  TreeView style domain transitions.  
 +  
 +  You can make custom root fs with minimum files  
 +  to run minimum applications with TOMOYO.  
 +  
 +CONFIG_TOMOYO_MAX_ACCEPT_ENTRY  
 +  This is the default value for maximal ACL entries  
 +  that are automatically appended into policy at "learning mode".  
 +  Some programs access thousands of objects, so running  
 +  such programs in "learning mode" dulls the system response  
 +  and consumes much memory.  
 +  This is the safeguard for such programs.  
 +  
 +CONFIG_TOMOYO_MAX_GRANT_LOG  
 +  This is the default value for maximal entries for  
 +  access grant logs that the kernel can hold on memory.  
 +  You can read the log via /proc/ccs/grant_log.  
 +  If you don't need access grant logs,  
 +  you may set this value to 0.  
 +  
 +CONFIG_TOMOYO_MAX_REJECT_LOG  
 +  This is the default value for maximal entries for  
 +  access reject logs that the kernel can hold on memory.  
 +  You can read the log via /proc/ccs/reject_log.  
 +  If you don't need access reject logs,  
 +  you may set this value to 0.  
 +  
 +CONFIG_SYAORAN  
 +  Say Y or M here to support the Tamper-Proof Device Filesystem.  
 +  
 +  SYAORAN stands for  
 +  "Simple Yet All-important Object Realizing Abiding Nexus".  
 +  SYAORAN is a filesystem for /dev with Mandatory Access Control.  
 +  
 +  SAKURA can make root fs read-only, but the system can't work  
 +  if /dev is read-only. Therefore you need to mount a writable  
 +  filesystem (such as tmpfs) for /dev if root fs is read-only.  
 +  
 +  But the writable /dev means that files on /dev might be tampered.  
 +  For example, if /dev/null is deleted and re-created as a symbolic  
 +  link to /dev/hda by an attacker, the contents of the IDE HDD  
 +  will be destroyed at a blow.  
 +  
 +  Also, TOMOYO controls file access by pathnames,  
 +  not by security labels.  
 +  Therefore /dev/null, for example, might be tampered  
 +  if a process have write permission to /dev/null .  
 +  
 +  SYAORAN can ensure /dev/null is a character device file  
 +  with major=1 minor=3.  
 +  
 +  You can use SAKURA to make /dev not unmountable.  
 +  
  #  
  # A couple of things I keep forgetting:  
  #   capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet,  
 --- linux-2.4.37.4.orig/arch/alpha/kernel/ptrace.c  
 +++ linux-2.4.37.4/arch/alpha/kernel/ptrace.c  
56  @@ -18,6 +18,7 @@  @@ -18,6 +18,7 @@
57   #include <asm/pgtable.h>   #include <asm/pgtable.h>
58   #include <asm/system.h>   #include <asm/system.h>
59   #include <asm/fpu.h>   #include <asm/fpu.h>
60  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
61    
62   #include "proto.h"   #include "proto.h"
63    
# Line 167  Source code for this patch is http://www Line 70  Source code for this patch is http://www
70    
71          lock_kernel();          lock_kernel();
72          DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",          DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
73  --- linux-2.4.37.4.orig/arch/arm/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/arm/kernel/ptrace.c
74  +++ linux-2.4.37.4/arch/arm/kernel/ptrace.c  +++ linux-2.4.37.6/arch/arm/kernel/ptrace.c
75  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
76   #include <asm/uaccess.h>   #include <asm/uaccess.h>
77   #include <asm/pgtable.h>   #include <asm/pgtable.h>
78   #include <asm/system.h>   #include <asm/system.h>
79  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
80    
81   #include "ptrace.h"   #include "ptrace.h"
82    
# Line 186  Source code for this patch is http://www Line 89  Source code for this patch is http://www
89    
90          lock_kernel();          lock_kernel();
91          ret = -EPERM;          ret = -EPERM;
92  --- linux-2.4.37.4.orig/arch/cris/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/cris/kernel/ptrace.c
93  +++ linux-2.4.37.4/arch/cris/kernel/ptrace.c  +++ linux-2.4.37.6/arch/cris/kernel/ptrace.c
94  @@ -48,6 +48,7 @@  @@ -48,6 +48,7 @@
95   #include <asm/pgtable.h>   #include <asm/pgtable.h>
96   #include <asm/system.h>   #include <asm/system.h>
97   #include <asm/processor.h>   #include <asm/processor.h>
98  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
99    
100   /*   /*
101    * does not yet catch signals sent when the child dies.    * does not yet catch signals sent when the child dies.
# Line 205  Source code for this patch is http://www Line 108  Source code for this patch is http://www
108    
109          lock_kernel();          lock_kernel();
110          ret = -EPERM;          ret = -EPERM;
111  --- linux-2.4.37.4.orig/arch/i386/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/i386/kernel/ptrace.c
112  +++ linux-2.4.37.4/arch/i386/kernel/ptrace.c  +++ linux-2.4.37.6/arch/i386/kernel/ptrace.c
113  @@ -20,6 +20,7 @@  @@ -20,6 +20,7 @@
114   #include <asm/processor.h>   #include <asm/processor.h>
115   #include <asm/i387.h>   #include <asm/i387.h>
116   #include <asm/debugreg.h>   #include <asm/debugreg.h>
117  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
118    
119   /*   /*
120    * does not yet catch signals sent when the child dies.    * does not yet catch signals sent when the child dies.
# Line 224  Source code for this patch is http://www Line 127  Source code for this patch is http://www
127    
128          lock_kernel();          lock_kernel();
129          ret = -EPERM;          ret = -EPERM;
130  --- linux-2.4.37.4.orig/arch/ia64/ia32/sys_ia32.c  --- linux-2.4.37.6.orig/arch/ia64/ia32/sys_ia32.c
131  +++ linux-2.4.37.4/arch/ia64/ia32/sys_ia32.c  +++ linux-2.4.37.6/arch/ia64/ia32/sys_ia32.c
132  @@ -57,6 +57,7 @@  @@ -57,6 +57,7 @@
133   #include <net/scm.h>   #include <net/scm.h>
134   #include <net/sock.h>   #include <net/sock.h>
135   #include <asm/ia32.h>   #include <asm/ia32.h>
136  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
137    
138   #define DEBUG  0   #define DEBUG  0
139    
# Line 243  Source code for this patch is http://www Line 146  Source code for this patch is http://www
146    
147          lock_kernel();          lock_kernel();
148          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
149  --- linux-2.4.37.4.orig/arch/ia64/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/ia64/kernel/ptrace.c
150  +++ linux-2.4.37.4/arch/ia64/kernel/ptrace.c  +++ linux-2.4.37.6/arch/ia64/kernel/ptrace.c
151  @@ -27,6 +27,7 @@  @@ -27,6 +27,7 @@
152   #ifdef CONFIG_PERFMON   #ifdef CONFIG_PERFMON
153   #include <asm/perfmon.h>   #include <asm/perfmon.h>
154   #endif   #endif
155  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
156    
157   #define offsetof(type,field)    ((unsigned long) &((type *) 0)->field)   #define offsetof(type,field)    ((unsigned long) &((type *) 0)->field)
158    
# Line 262  Source code for this patch is http://www Line 165  Source code for this patch is http://www
165    
166          lock_kernel();          lock_kernel();
167          ret = -EPERM;          ret = -EPERM;
168  --- linux-2.4.37.4.orig/arch/m68k/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/m68k/kernel/ptrace.c
169  +++ linux-2.4.37.4/arch/m68k/kernel/ptrace.c  +++ linux-2.4.37.6/arch/m68k/kernel/ptrace.c
170  @@ -25,6 +25,7 @@  @@ -25,6 +25,7 @@
171   #include <asm/pgtable.h>   #include <asm/pgtable.h>
172   #include <asm/system.h>   #include <asm/system.h>
173   #include <asm/processor.h>   #include <asm/processor.h>
174  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
175    
176   /*   /*
177    * does not yet catch signals sent when the child dies.    * does not yet catch signals sent when the child dies.
# Line 281  Source code for this patch is http://www Line 184  Source code for this patch is http://www
184    
185          lock_kernel();          lock_kernel();
186          ret = -EPERM;          ret = -EPERM;
187  --- linux-2.4.37.4.orig/arch/mips/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/mips/kernel/ptrace.c
188  +++ linux-2.4.37.4/arch/mips/kernel/ptrace.c  +++ linux-2.4.37.6/arch/mips/kernel/ptrace.c
189  @@ -28,6 +28,7 @@  @@ -28,6 +28,7 @@
190   #include <asm/bootinfo.h>   #include <asm/bootinfo.h>
191   #include <asm/cpu.h>   #include <asm/cpu.h>
192   #include <asm/fpu.h>   #include <asm/fpu.h>
193  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
194    
195   /*   /*
196    * Called by kernel/ptrace.c when detaching..    * Called by kernel/ptrace.c when detaching..
# Line 300  Source code for this patch is http://www Line 203  Source code for this patch is http://www
203    
204          lock_kernel();          lock_kernel();
205   #if 0   #if 0
206  --- linux-2.4.37.4.orig/arch/mips64/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/mips64/kernel/ptrace.c
207  +++ linux-2.4.37.4/arch/mips64/kernel/ptrace.c  +++ linux-2.4.37.6/arch/mips64/kernel/ptrace.c
208  @@ -30,6 +30,7 @@  @@ -30,6 +30,7 @@
209   #include <asm/system.h>   #include <asm/system.h>
210   #include <asm/uaccess.h>   #include <asm/uaccess.h>
211   #include <asm/bootinfo.h>   #include <asm/bootinfo.h>
212  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
213    
214   /*   /*
215    * Called by kernel/ptrace.c when detaching..    * Called by kernel/ptrace.c when detaching..
# Line 328  Source code for this patch is http://www Line 231  Source code for this patch is http://www
231    
232          lock_kernel();          lock_kernel();
233   #if 0   #if 0
234  --- linux-2.4.37.4.orig/arch/parisc/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/parisc/kernel/ptrace.c
235  +++ linux-2.4.37.4/arch/parisc/kernel/ptrace.c  +++ linux-2.4.37.6/arch/parisc/kernel/ptrace.c
236  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
237   #include <asm/system.h>   #include <asm/system.h>
238   #include <asm/processor.h>   #include <asm/processor.h>
239   #include <asm/offset.h>   #include <asm/offset.h>
240  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
241    
242   /* These are used in entry.S, syscall_restore_rfi.  We need to record the   /* These are used in entry.S, syscall_restore_rfi.  We need to record the
243    * current stepping mode somewhere other than in PSW, because there is no    * current stepping mode somewhere other than in PSW, because there is no
# Line 347  Source code for this patch is http://www Line 250  Source code for this patch is http://www
250    
251          lock_kernel();          lock_kernel();
252          ret = -EPERM;          ret = -EPERM;
253  --- linux-2.4.37.4.orig/arch/ppc/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/ppc/kernel/ptrace.c
254  +++ linux-2.4.37.4/arch/ppc/kernel/ptrace.c  +++ linux-2.4.37.6/arch/ppc/kernel/ptrace.c
255  @@ -29,6 +29,7 @@  @@ -29,6 +29,7 @@
256   #include <asm/page.h>   #include <asm/page.h>
257   #include <asm/pgtable.h>   #include <asm/pgtable.h>
258   #include <asm/system.h>   #include <asm/system.h>
259  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
260    
261   /*   /*
262    * Set of msr bits that gdb can change on behalf of a process.    * Set of msr bits that gdb can change on behalf of a process.
# Line 366  Source code for this patch is http://www Line 269  Source code for this patch is http://www
269    
270          lock_kernel();          lock_kernel();
271          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
272  --- linux-2.4.37.4.orig/arch/ppc64/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/ppc64/kernel/ptrace.c
273  +++ linux-2.4.37.4/arch/ppc64/kernel/ptrace.c  +++ linux-2.4.37.6/arch/ppc64/kernel/ptrace.c
274  @@ -30,6 +30,7 @@  @@ -30,6 +30,7 @@
275   #include <asm/page.h>   #include <asm/page.h>
276   #include <asm/pgtable.h>   #include <asm/pgtable.h>
277   #include <asm/system.h>   #include <asm/system.h>
278  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
279    
280   /*   /*
281    * Set of msr bits that gdb can change on behalf of a process.    * Set of msr bits that gdb can change on behalf of a process.
# Line 385  Source code for this patch is http://www Line 288  Source code for this patch is http://www
288    
289          lock_kernel();          lock_kernel();
290          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
291  --- linux-2.4.37.4.orig/arch/ppc64/kernel/ptrace32.c  --- linux-2.4.37.6.orig/arch/ppc64/kernel/ptrace32.c
292  +++ linux-2.4.37.4/arch/ppc64/kernel/ptrace32.c  +++ linux-2.4.37.6/arch/ppc64/kernel/ptrace32.c
293  @@ -30,6 +30,7 @@  @@ -30,6 +30,7 @@
294   #include <asm/page.h>   #include <asm/page.h>
295   #include <asm/pgtable.h>   #include <asm/pgtable.h>
296   #include <asm/system.h>   #include <asm/system.h>
297  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
298    
299   #ifdef CONFIG_ALTIVEC   #ifdef CONFIG_ALTIVEC
300   /*   /*
# Line 404  Source code for this patch is http://www Line 307  Source code for this patch is http://www
307    
308          lock_kernel();          lock_kernel();
309          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
310  --- linux-2.4.37.4.orig/arch/s390/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/s390/kernel/ptrace.c
311  +++ linux-2.4.37.4/arch/s390/kernel/ptrace.c  +++ linux-2.4.37.6/arch/s390/kernel/ptrace.c
312  @@ -37,6 +37,7 @@  @@ -37,6 +37,7 @@
313   #include <asm/pgalloc.h>   #include <asm/pgalloc.h>
314   #include <asm/system.h>   #include <asm/system.h>
315   #include <asm/uaccess.h>   #include <asm/uaccess.h>
316  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
317    
318    
319   void FixPerRegisters(struct task_struct *task)   void FixPerRegisters(struct task_struct *task)
# Line 423  Source code for this patch is http://www Line 326  Source code for this patch is http://www
326    
327          lock_kernel();          lock_kernel();
328          if (request == PTRACE_TRACEME)          if (request == PTRACE_TRACEME)
329  --- linux-2.4.37.4.orig/arch/s390x/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/s390x/kernel/ptrace.c
330  +++ linux-2.4.37.4/arch/s390x/kernel/ptrace.c  +++ linux-2.4.37.6/arch/s390x/kernel/ptrace.c
331  @@ -43,6 +43,7 @@  @@ -43,6 +43,7 @@
332   #else   #else
333   #define parent_31bit 0   #define parent_31bit 0
334   #endif   #endif
335  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
336    
337    
338   void FixPerRegisters(struct task_struct *task)   void FixPerRegisters(struct task_struct *task)
# Line 442  Source code for this patch is http://www Line 345  Source code for this patch is http://www
345          lock_kernel();          lock_kernel();
346          if (request == PTRACE_TRACEME)          if (request == PTRACE_TRACEME)
347          {          {
348  --- linux-2.4.37.4.orig/arch/sh/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/sh/kernel/ptrace.c
349  +++ linux-2.4.37.4/arch/sh/kernel/ptrace.c  +++ linux-2.4.37.6/arch/sh/kernel/ptrace.c
350  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
351   #include <asm/system.h>   #include <asm/system.h>
352   #include <asm/processor.h>   #include <asm/processor.h>
353   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
354  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
355    
356   /*   /*
357    * does not yet catch signals sent when the child dies.    * does not yet catch signals sent when the child dies.
# Line 461  Source code for this patch is http://www Line 364  Source code for this patch is http://www
364    
365          lock_kernel();          lock_kernel();
366          ret = -EPERM;          ret = -EPERM;
367  --- linux-2.4.37.4.orig/arch/sh64/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/sh64/kernel/ptrace.c
368  +++ linux-2.4.37.4/arch/sh64/kernel/ptrace.c  +++ linux-2.4.37.6/arch/sh64/kernel/ptrace.c
369  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
370   #include <asm/system.h>   #include <asm/system.h>
371   #include <asm/processor.h>   #include <asm/processor.h>
372   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
373  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
374    
375   /* This mask defines the bits of the SR which the user is not allowed to   /* This mask defines the bits of the SR which the user is not allowed to
376      change, which are everything except S, Q, M, PR, SZ, FR. */      change, which are everything except S, Q, M, PR, SZ, FR. */
# Line 480  Source code for this patch is http://www Line 383  Source code for this patch is http://www
383    
384          lock_kernel();          lock_kernel();
385          ret = -EPERM;          ret = -EPERM;
386  --- linux-2.4.37.4.orig/arch/sparc/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/sparc/kernel/ptrace.c
387  +++ linux-2.4.37.4/arch/sparc/kernel/ptrace.c  +++ linux-2.4.37.6/arch/sparc/kernel/ptrace.c
388  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
389   #include <asm/pgtable.h>   #include <asm/pgtable.h>
390   #include <asm/system.h>   #include <asm/system.h>
391   #include <asm/uaccess.h>   #include <asm/uaccess.h>
392  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
393    
394   #define MAGIC_CONSTANT 0x80000000   #define MAGIC_CONSTANT 0x80000000
395    
# Line 501  Source code for this patch is http://www Line 404  Source code for this patch is http://www
404    
405          lock_kernel();          lock_kernel();
406   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
407  --- linux-2.4.37.4.orig/arch/sparc64/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/sparc64/kernel/ptrace.c
408  +++ linux-2.4.37.4/arch/sparc64/kernel/ptrace.c  +++ linux-2.4.37.6/arch/sparc64/kernel/ptrace.c
409  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
410   #include <asm/psrcompat.h>   #include <asm/psrcompat.h>
411   #include <asm/visasm.h>   #include <asm/visasm.h>
412   #include <asm/spitfire.h>   #include <asm/spitfire.h>
413  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
414    
415   #define MAGIC_CONSTANT 0x80000000   #define MAGIC_CONSTANT 0x80000000
416    
# Line 522  Source code for this patch is http://www Line 425  Source code for this patch is http://www
425    
426          if (current->thread.flags & SPARC_FLAG_32BIT) {          if (current->thread.flags & SPARC_FLAG_32BIT) {
427                  addr &= 0xffffffffUL;                  addr &= 0xffffffffUL;
428  --- linux-2.4.37.4.orig/arch/x86_64/ia32/ptrace32.c  --- linux-2.4.37.6.orig/arch/x86_64/ia32/ptrace32.c
429  +++ linux-2.4.37.4/arch/x86_64/ia32/ptrace32.c  +++ linux-2.4.37.6/arch/x86_64/ia32/ptrace32.c
430  @@ -24,6 +24,7 @@  @@ -24,6 +24,7 @@
431   #include <asm/i387.h>   #include <asm/i387.h>
432   #include <asm/fpu32.h>   #include <asm/fpu32.h>
433   #include <linux/mm.h>   #include <linux/mm.h>
434  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
435    
436   /* determines which flags the user has access to. */   /* determines which flags the user has access to. */
437   /* 1 = access 0 = no access */   /* 1 = access 0 = no access */
# Line 541  Source code for this patch is http://www Line 444  Source code for this patch is http://www
444    
445          switch (request) {          switch (request) {
446          case PTRACE_TRACEME:          case PTRACE_TRACEME:
447  --- linux-2.4.37.4.orig/arch/x86_64/kernel/ptrace.c  --- linux-2.4.37.6.orig/arch/x86_64/kernel/ptrace.c
448  +++ linux-2.4.37.4/arch/x86_64/kernel/ptrace.c  +++ linux-2.4.37.6/arch/x86_64/kernel/ptrace.c
449  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
450   #include <asm/processor.h>   #include <asm/processor.h>
451   #include <asm/i387.h>   #include <asm/i387.h>
452   #include <asm/debugreg.h>   #include <asm/debugreg.h>
453  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
454    
455   /*   /*
456    * does not yet catch signals sent when the child dies.    * does not yet catch signals sent when the child dies.
# Line 560  Source code for this patch is http://www Line 463  Source code for this patch is http://www
463    
464          /* This lock_kernel fixes a subtle race with suid exec */          /* This lock_kernel fixes a subtle race with suid exec */
465          lock_kernel();          lock_kernel();
466  --- linux-2.4.37.4.orig/fs/Config.in  --- linux-2.4.37.6.orig/fs/Config.in
467  +++ linux-2.4.37.4/fs/Config.in  +++ linux-2.4.37.6/fs/Config.in
468  @@ -176,4 +176,7 @@ comment 'Partition Types'  @@ -176,4 +176,7 @@ comment 'Partition Types'
469   source fs/partitions/Config.in   source fs/partitions/Config.in
470   endmenu   endmenu
471   source fs/nls/Config.in   source fs/nls/Config.in
472  +  +
 +source fs/Config.ccs.in  
 +  
473   endmenu   endmenu
474  --- linux-2.4.37.4.orig/fs/Makefile  +
475  +++ linux-2.4.37.4/fs/Makefile  +source security/ccsecurity/Config.in
476  @@ -80,5 +80,5 @@ obj-$(CONFIG_BINFMT_ELF)      += binfmt_elf.o  --- linux-2.4.37.6.orig/fs/Makefile
477    +++ linux-2.4.37.6/fs/Makefile
478    @@ -80,5 +80,7 @@ obj-$(CONFIG_BINFMT_ELF)      += binfmt_elf.o
479   # persistent filesystems   # persistent filesystems
480   obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))   obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
481    
482  -  +subdir-$(CONFIG_CCSECURITY)    += ../security/ccsecurity
483  +include Makefile-2.4.ccs  +obj-$(CONFIG_CCSECURITY)       += ../security/ccsecurity/ccsecurity.o
484    
485   include $(TOPDIR)/Rules.make   include $(TOPDIR)/Rules.make
486  --- linux-2.4.37.4.orig/fs/attr.c  --- linux-2.4.37.6.orig/fs/attr.c
487  +++ linux-2.4.37.4/fs/attr.c  +++ linux-2.4.37.6/fs/attr.c
488  @@ -12,6 +12,7 @@  @@ -12,6 +12,7 @@
489   #include <linux/dnotify.h>   #include <linux/dnotify.h>
490   #include <linux/fcntl.h>   #include <linux/fcntl.h>
491   #include <linux/quotaops.h>   #include <linux/quotaops.h>
492  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
493    
494   /* Taken over from the old code... */   /* Taken over from the old code... */
495    
# Line 593  Source code for this patch is http://www Line 497  Source code for this patch is http://www
497                  attr->ia_atime = now;                  attr->ia_atime = now;
498          if (!(ia_valid & ATTR_MTIME_SET))          if (!(ia_valid & ATTR_MTIME_SET))
499                  attr->ia_mtime = now;                  attr->ia_mtime = now;
500  +       error = ccs_check_setattr_permission(dentry, attr);  +       error = ccs_setattr_permission(dentry, attr);
501  +       if (error)  +       if (error)
502  +               return error;  +               return error;
503    
504          lock_kernel();          lock_kernel();
505          if (inode->i_op && inode->i_op->setattr)          if (inode->i_op && inode->i_op->setattr)
506  --- linux-2.4.37.4.orig/fs/exec.c  --- linux-2.4.37.6.orig/fs/exec.c
507  +++ linux-2.4.37.4/fs/exec.c  +++ linux-2.4.37.6/fs/exec.c
508  @@ -48,6 +48,8 @@  @@ -48,6 +48,8 @@
509   #include <linux/kmod.h>   #include <linux/kmod.h>
510   #endif   #endif
511    
512  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
513  +  +
514   int core_uses_pid;   int core_uses_pid;
515   char core_pattern[65] = "core";   char core_pattern[65] = "core";
# Line 614  Source code for this patch is http://www Line 518  Source code for this patch is http://www
518          if (error)          if (error)
519                  goto exit;                  goto exit;
520    
521  +       error = ccs_check_uselib_permission(nd.dentry, nd.mnt);  +       error = ccs_uselib_permission(nd.dentry, nd.mnt);
522  +       if (error)  +       if (error)
523  +               goto exit;  +               goto exit;
524  +  +
# Line 626  Source code for this patch is http://www Line 530  Source code for this patch is http://www
530                          if (!err && !(inode->i_mode & 0111))                          if (!err && !(inode->i_mode & 0111))
531                                  err = -EACCES;                                  err = -EACCES;
532  +                       if (!err)  +                       if (!err)
533  +                               err = ccs_check_open_exec_permission(nd.dentry,  +                               err = ccs_open_exec_permission(nd.dentry,
534  +                                                                    nd.mnt);  +                                                                    nd.mnt);
535                          file = ERR_PTR(err);                          file = ERR_PTR(err);
536                          if (!err) {                          if (!err) {
# Line 641  Source code for this patch is http://www Line 545  Source code for this patch is http://www
545          if (retval >= 0)          if (retval >= 0)
546                  /* execve success */                  /* execve success */
547                  return retval;                  return retval;
548  --- linux-2.4.37.4.orig/fs/fcntl.c  --- linux-2.4.37.6.orig/fs/fcntl.c
549  +++ linux-2.4.37.4/fs/fcntl.c  +++ linux-2.4.37.6/fs/fcntl.c
550  @@ -16,6 +16,7 @@  @@ -16,6 +16,7 @@
551   #include <asm/poll.h>   #include <asm/poll.h>
552   #include <asm/siginfo.h>   #include <asm/siginfo.h>
553   #include <asm/uaccess.h>   #include <asm/uaccess.h>
554  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
555    
556   extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg);   extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg);
557   extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);   extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
# Line 655  Source code for this patch is http://www Line 559  Source code for this patch is http://www
559          if (!(arg & O_APPEND) && IS_APPEND(inode))          if (!(arg & O_APPEND) && IS_APPEND(inode))
560                  return -EPERM;                  return -EPERM;
561    
562  +       if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp))  +       if (!(arg & O_APPEND) && ccs_rewrite_permission(filp))
563  +               return -EPERM;  +               return -EPERM;
564  +  +
565          /* Did FASYNC state change? */          /* Did FASYNC state change? */
566          if ((arg ^ filp->f_flags) & FASYNC) {          if ((arg ^ filp->f_flags) & FASYNC) {
567                  if (filp->f_op && filp->f_op->fasync) {                  if (filp->f_op && filp->f_op->fasync) {
568  --- linux-2.4.37.4.orig/fs/ioctl.c  --- linux-2.4.37.6.orig/fs/ioctl.c
569  +++ linux-2.4.37.4/fs/ioctl.c  +++ linux-2.4.37.6/fs/ioctl.c
570  @@ -10,6 +10,7 @@  @@ -10,6 +10,7 @@
571    
572   #include <asm/uaccess.h>   #include <asm/uaccess.h>
573   #include <asm/ioctls.h>   #include <asm/ioctls.h>
574  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
575    
576   static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)   static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
577   {   {
# Line 675  Source code for this patch is http://www Line 579  Source code for this patch is http://www
579          filp = fget(fd);          filp = fget(fd);
580          if (!filp)          if (!filp)
581                  goto out;                  goto out;
582  +       error = ccs_check_ioctl_permission(filp, cmd, arg);  +       error = ccs_ioctl_permission(filp, cmd, arg);
583  +       if (error) {  +       if (error) {
584  +               fput(filp);  +               fput(filp);
585  +               goto out;  +               goto out;
# Line 694  Source code for this patch is http://www Line 598  Source code for this patch is http://www
598                          error = -ENOTTY;                          error = -ENOTTY;
599                          if (S_ISREG(filp->f_dentry->d_inode->i_mode))                          if (S_ISREG(filp->f_dentry->d_inode->i_mode))
600                                  error = file_ioctl(filp, cmd, arg);                                  error = file_ioctl(filp, cmd, arg);
601  --- linux-2.4.37.4.orig/fs/namei.c  --- linux-2.4.37.6.orig/fs/namei.c
602  +++ linux-2.4.37.4/fs/namei.c  +++ linux-2.4.37.6/fs/namei.c
603  @@ -28,6 +28,9 @@  @@ -28,6 +28,9 @@
604    
605   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
606    
607  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
608  +#include <linux/module.h>  +#include <linux/module.h>
609  +  +
610   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
# Line 710  Source code for this patch is http://www Line 614  Source code for this patch is http://www
614          return error;          return error;
615   }   }
616    
617  +#include <linux/tomoyo_vfs.h>  +#include <linux/ccsecurity_vfs.h>
618   /*   /*
619    *     open_namei()    *     open_namei()
620    *    *
621  @@ -1068,6 +1072,11 @@ do_last:  @@ -1068,6 +1072,9 @@ do_last:
622    
623          /* Negative dentry, just create the file */          /* Negative dentry, just create the file */
624          if (!dentry->d_inode) {          if (!dentry->d_inode) {
625  +               error = ccs_check_mknod_permission(dir->d_inode, dentry,  +               error = ccs_mknod_permission(dir->d_inode, dentry, nd->mnt,
626  +                                                  nd->mnt,  +                                            mode & ~current->fs->umask, 0);
 +                                                  mode & ~current->fs->umask,  
 +                                                  0);  
627  +               if (!error)  +               if (!error)
628                  error = vfs_create(dir->d_inode, dentry,                  error = vfs_create(dir->d_inode, dentry,
629                                     mode & ~current->fs->umask);                                     mode & ~current->fs->umask);
630                  up(&dir->d_inode->i_sem);                  up(&dir->d_inode->i_sem);
631  @@ -1154,6 +1163,11 @@ ok:  @@ -1154,6 +1161,11 @@ ok:
632                          goto exit;                          goto exit;
633          }          }
634    
635  +       /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
636  +       error = ccs_check_open_permission(dentry, nd->mnt, flag);  +       error = ccs_open_permission(dentry, nd->mnt, flag);
637  +       if (error)  +       if (error)
638  +               goto exit;  +               goto exit;
639  +  +
640          /*          /*
641           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
642           */           */
643  @@ -1292,6 +1306,7 @@ asmlinkage long sys_mknod(const char * f  @@ -1292,6 +1304,7 @@ asmlinkage long sys_mknod(const char * f
644    
645          if (S_ISDIR(mode))          if (S_ISDIR(mode))
646                  return -EPERM;                  return -EPERM;
# Line 746  Source code for this patch is http://www Line 648  Source code for this patch is http://www
648          tmp = getname(filename);          tmp = getname(filename);
649          if (IS_ERR(tmp))          if (IS_ERR(tmp))
650                  return PTR_ERR(tmp);                  return PTR_ERR(tmp);
651  @@ -1304,6 +1319,10 @@ asmlinkage long sys_mknod(const char * f  @@ -1304,6 +1317,10 @@ asmlinkage long sys_mknod(const char * f
652    
653          mode &= ~current->fs->umask;          mode &= ~current->fs->umask;
654          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
655  +               error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
656  +                                                  nd.mnt, mode, dev);  +                                            nd.mnt, mode, dev);
657  +               if (error)  +               if (error)
658  +                       goto out_dput;  +                       goto out_dput;
659                  switch (mode & S_IFMT) {                  switch (mode & S_IFMT) {
660                  case 0: case S_IFREG:                  case 0: case S_IFREG:
661                          error = vfs_create(nd.dentry->d_inode,dentry,mode);                          error = vfs_create(nd.dentry->d_inode,dentry,mode);
662  @@ -1317,6 +1336,7 @@ asmlinkage long sys_mknod(const char * f  @@ -1317,6 +1334,7 @@ asmlinkage long sys_mknod(const char * f
663                  default:                  default:
664                          error = -EINVAL;                          error = -EINVAL;
665                  }                  }
# Line 765  Source code for this patch is http://www Line 667  Source code for this patch is http://www
667                  dput(dentry);                  dput(dentry);
668          }          }
669          up(&nd.dentry->d_inode->i_sem);          up(&nd.dentry->d_inode->i_sem);
670  @@ -1370,6 +1390,10 @@ asmlinkage long sys_mkdir(const char * p  @@ -1370,6 +1388,9 @@ asmlinkage long sys_mkdir(const char * p
671                  dentry = lookup_create(&nd, 1);                  dentry = lookup_create(&nd, 1);
672                  error = PTR_ERR(dentry);                  error = PTR_ERR(dentry);
673                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
674  +                       error = ccs_check_mkdir_permission(nd.dentry->d_inode,  +                       error = ccs_mkdir_permission(nd.dentry->d_inode,
675  +                                                          dentry, nd.mnt,  +                                                    dentry, nd.mnt, mode);
 +                                                          mode);  
676  +                       if (!error)  +                       if (!error)
677                          error = vfs_mkdir(nd.dentry->d_inode, dentry,                          error = vfs_mkdir(nd.dentry->d_inode, dentry,
678                                            mode & ~current->fs->umask);                                            mode & ~current->fs->umask);
679                          dput(dentry);                          dput(dentry);
680  @@ -1479,6 +1503,9 @@ asmlinkage long sys_rmdir(const char * p  @@ -1479,6 +1500,9 @@ asmlinkage long sys_rmdir(const char * p
681          dentry = lookup_hash(&nd.last, nd.dentry);          dentry = lookup_hash(&nd.last, nd.dentry);
682          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
683          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
684  +               error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,  +               error = ccs_rmdir_permission(nd.dentry->d_inode, dentry,
685  +                                                  nd.mnt);  +                                            nd.mnt);
686  +               if (!error)  +               if (!error)
687                  error = vfs_rmdir(nd.dentry->d_inode, dentry);                  error = vfs_rmdir(nd.dentry->d_inode, dentry);
688                  dput(dentry);                  dput(dentry);
689          }          }
690  @@ -1548,6 +1575,10 @@ asmlinkage long sys_unlink(const char *  @@ -1548,6 +1572,10 @@ asmlinkage long sys_unlink(const char *
691                  /* Why not before? Because we want correct error value */                  /* Why not before? Because we want correct error value */
692                  if (nd.last.name[nd.last.len])                  if (nd.last.name[nd.last.len])
693                          goto slashes;                          goto slashes;
694  +               error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,  +               error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
695  +                                                   nd.mnt);  +                                             nd.mnt);
696  +               if (error)  +               if (error)
697  +                       goto exit2;  +                       goto exit2;
698                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
699          exit2:          exit2:
700                  dput(dentry);                  dput(dentry);
701  @@ -1612,6 +1643,10 @@ asmlinkage long sys_symlink(const char *  @@ -1612,6 +1640,9 @@ asmlinkage long sys_symlink(const char *
702                  dentry = lookup_create(&nd, 0);                  dentry = lookup_create(&nd, 0);
703                  error = PTR_ERR(dentry);                  error = PTR_ERR(dentry);
704                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
705  +                       error = ccs_check_symlink_permission(nd.dentry->d_inode,  +                       error = ccs_symlink_permission(nd.dentry->d_inode,
706  +                                                            dentry, nd.mnt,  +                                                      dentry, nd.mnt, from);
 +                                                            from);  
707  +                       if (!error)  +                       if (!error)
708                          error = vfs_symlink(nd.dentry->d_inode, dentry, from);                          error = vfs_symlink(nd.dentry->d_inode, dentry, from);
709                          dput(dentry);                          dput(dentry);
710                  }                  }
711  @@ -1698,6 +1733,10 @@ asmlinkage long sys_link(const char * ol  @@ -1698,6 +1729,10 @@ asmlinkage long sys_link(const char * ol
712                  new_dentry = lookup_create(&nd, 0);                  new_dentry = lookup_create(&nd, 0);
713                  error = PTR_ERR(new_dentry);                  error = PTR_ERR(new_dentry);
714                  if (!IS_ERR(new_dentry)) {                  if (!IS_ERR(new_dentry)) {
715  +                       error = ccs_check_link_permission(old_nd.dentry,  +                       error = ccs_link_permission(old_nd.dentry,
716  +                                                         nd.dentry->d_inode,  +                                                   nd.dentry->d_inode,
717  +                                                         new_dentry, nd.mnt);  +                                                   new_dentry, nd.mnt);
718  +                       if (!error)  +                       if (!error)
719                          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);                          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
720                          dput(new_dentry);                          dput(new_dentry);
721                  }                  }
722  @@ -1928,12 +1967,18 @@ static inline int do_rename(const char *  @@ -1928,12 +1963,17 @@ static inline int do_rename(const char *
723          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
724          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
725                  goto exit4;                  goto exit4;
726  +       error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,  +       error = ccs_rename_permission(old_dir->d_inode, old_dentry,
727  +                                           new_dir->d_inode, new_dentry,  +                                     new_dir->d_inode, new_dentry, newnd.mnt);
 +                                           newnd.mnt);  
728  +       if (error)  +       if (error)
729  +               goto exit5;  +               goto exit5;
730    
# Line 838  Source code for this patch is http://www Line 737  Source code for this patch is http://www
737          dput(new_dentry);          dput(new_dentry);
738   exit4:   exit4:
739          dput(old_dentry);          dput(old_dentry);
740  --- linux-2.4.37.4.orig/fs/namespace.c  --- linux-2.4.37.6.orig/fs/namespace.c
741  +++ linux-2.4.37.4/fs/namespace.c  +++ linux-2.4.37.6/fs/namespace.c
742  @@ -21,6 +21,9 @@  @@ -21,6 +21,8 @@
743   #include <linux/seq_file.h>   #include <linux/seq_file.h>
744   #include <linux/namespace.h>   #include <linux/namespace.h>
745    
746  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
747  +  +
748   struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);   struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
749   int do_remount_sb(struct super_block *sb, int flags, void * data);   int do_remount_sb(struct super_block *sb, int flags, void * data);
750   void kill_super(struct super_block *sb);   void kill_super(struct super_block *sb);
751  @@ -290,6 +293,8 @@ static int do_umount(struct vfsmount *mn  @@ -290,6 +292,9 @@ static int do_umount(struct vfsmount *mn
752   {   {
753          struct super_block * sb = mnt->mnt_sb;          struct super_block * sb = mnt->mnt_sb;
754          int retval = 0;          int retval = 0;
755  +       if (ccs_may_umount(mnt))  +       retval = ccs_umount_permission(mnt, flags);
756  +               return -EPERM;  +       if (retval)
757    +               return retval;
758    
759          /*          /*
760           * If we may have to abort operations to get out of this           * If we may have to abort operations to get out of this
# Line 892  Source code for this patch is http://www Line 791  Source code for this patch is http://www
791                  goto out;                  goto out;
792    
793  +       err = -EPERM;  +       err = -EPERM;
794  +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
795  +               goto out;  +               goto out;
796  +  +
797          err = -ENOENT;          err = -ENOENT;
# Line 909  Source code for this patch is http://www Line 808  Source code for this patch is http://www
808          mnt->mnt_flags = mnt_flags;          mnt->mnt_flags = mnt_flags;
809          err = graft_tree(mnt, nd);          err = graft_tree(mnt, nd);
810   unlock:   unlock:
811  @@ -718,6 +736,13 @@ long do_mount(char * dev_name, char * di  @@ -700,6 +718,7 @@ static int copy_mount_options (const voi
812          if (data_page)   long do_mount(char * dev_name, char * dir_name, char *type_page,
813                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                    unsigned long flags, void *data_page)
814     {
815    +       const unsigned long original_flags = flags;
816            struct nameidata nd;
817            int retval = 0;
818            int mnt_flags = 0;
819    @@ -732,6 +751,11 @@ long do_mount(char * dev_name, char * di
820            if (retval)
821                    return retval;
822    
823  +       if (!ccs_capable(CCS_SYS_MOUNT))  +       retval = ccs_mount_permission(dev_name, &nd, type_page,
824  +               return -EPERM;  +                                     original_flags, data_page);
 +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,  
 +                                           &flags);  
825  +       if (retval)  +       if (retval)
826  +               return retval;  +               goto out;
827  +  +
828          /* Separate the per-mountpoint flags */          if (flags & MS_REMOUNT)
829          if (flags & MS_NOSUID)                  retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
830                  mnt_flags |= MNT_NOSUID;                                      data_page);
831    @@ -742,6 +766,7 @@ long do_mount(char * dev_name, char * di
832            else
833                    retval = do_add_mount(&nd, type_page, flags, mnt_flags,
834                                          dev_name, data_page);
835    + out:
836            path_release(&nd);
837            return retval;
838     }
839  @@ -911,6 +936,8 @@ asmlinkage long sys_pivot_root(const cha  @@ -911,6 +936,8 @@ asmlinkage long sys_pivot_root(const cha
840    
841          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
# Line 936  Source code for this patch is http://www Line 849  Source code for this patch is http://www
849          if (error)          if (error)
850                  goto out1;                  goto out1;
851    
852  +       error = ccs_check_pivot_root_permission(&old_nd, &new_nd);  +       error = ccs_pivot_root_permission(&old_nd, &new_nd);
853  +       if (error) {  +       if (error) {
854  +               path_release(&old_nd);  +               path_release(&old_nd);
855  +               goto out1;  +               goto out1;
# Line 944  Source code for this patch is http://www Line 857  Source code for this patch is http://www
857          read_lock(&current->fs->lock);          read_lock(&current->fs->lock);
858          user_nd.mnt = mntget(current->fs->rootmnt);          user_nd.mnt = mntget(current->fs->rootmnt);
859          user_nd.dentry = dget(current->fs->root);          user_nd.dentry = dget(current->fs->root);
860  --- linux-2.4.37.4.orig/fs/open.c  --- linux-2.4.37.6.orig/fs/open.c
861  +++ linux-2.4.37.4/fs/open.c  +++ linux-2.4.37.6/fs/open.c
862  @@ -20,6 +20,9 @@  @@ -20,6 +20,8 @@
863    
864   #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))   #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
865    
866  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo.h>  
867  +  +
868   int vfs_statfs(struct super_block *sb, struct statfs *buf)   int vfs_statfs(struct super_block *sb, struct statfs *buf)
869   {   {
870          int retval = -ENODEV;          int retval = -ENODEV;
871  @@ -164,6 +167,9 @@ static inline long do_sys_truncate(const  @@ -164,6 +166,9 @@ static inline long do_sys_truncate(const
872          if (error)          if (error)
873                  goto dput_and_out;                  goto dput_and_out;
874    
875  +       error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);  +       error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
876  +       if (!error)  +       if (!error)
877  +  +
878          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
879          if (!error) {          if (!error) {
880                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
881  @@ -217,6 +223,10 @@ static inline long do_sys_ftruncate(unsi  @@ -217,6 +222,9 @@ static inline long do_sys_ftruncate(unsi
882          if (IS_APPEND(inode))          if (IS_APPEND(inode))
883                  goto out_putf;                  goto out_putf;
884    
885  +       error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,  +       error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
 +                                             0);  
886  +       if (error)  +       if (error)
887  +               goto out_putf;  +               goto out_putf;
888          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
889          if (!error)          if (!error)
890                  error = do_truncate(dentry, length);                  error = do_truncate(dentry, length);
891  @@ -466,6 +476,10 @@ asmlinkage long sys_chroot(const char *  @@ -466,6 +474,10 @@ asmlinkage long sys_chroot(const char *
892          error = -EPERM;          error = -EPERM;
893          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
894                  goto dput_and_out;                  goto dput_and_out;
895  +       if (!ccs_capable(CCS_SYS_CHROOT))  +       if (!ccs_capable(CCS_SYS_CHROOT))
896  +               goto dput_and_out;  +               goto dput_and_out;
897  +       if (ccs_check_chroot_permission(&nd))  +       if (ccs_chroot_permission(&nd))
898  +               goto dput_and_out;  +               goto dput_and_out;
899    
900          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
901          set_fs_altroot();          set_fs_altroot();
902  @@ -897,6 +911,8 @@ out_unlock:  @@ -497,6 +509,9 @@ asmlinkage long sys_fchmod(unsigned int
903            err = -EPERM;
904            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
905                    goto out_putf;
906    +       err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
907    +       if (err)
908    +               goto out_putf;
909            if (mode == (mode_t) -1)
910                    mode = inode->i_mode;
911            newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
912    @@ -528,6 +543,9 @@ asmlinkage long sys_chmod(const char * f
913            error = -EPERM;
914            if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
915                    goto dput_and_out;
916    +       error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
917    +       if (error)
918    +               goto dput_and_out;
919    
920            if (mode == (mode_t) -1)
921                    mode = inode->i_mode;
922    @@ -608,6 +626,8 @@ asmlinkage long sys_chown(const char * f
923    
924            error = user_path_walk(filename, &nd);
925            if (!error) {
926    +               error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
927    +               if (!error)
928                    error = chown_common(nd.dentry, user, group);
929                    path_release(&nd);
930            }
931    @@ -621,6 +641,8 @@ asmlinkage long sys_lchown(const char *
932    
933            error = user_path_walk_link(filename, &nd);
934            if (!error) {
935    +               error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
936    +               if (!error)
937                    error = chown_common(nd.dentry, user, group);
938                    path_release(&nd);
939            }
940    @@ -635,6 +657,9 @@ asmlinkage long sys_fchown(unsigned int
941    
942            file = fget(fd);
943            if (file) {
944    +               error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt,
945    +                                            user, group);
946    +               if (!error)
947                    error = chown_common(file->f_dentry, user, group);
948                    fput(file);
949            }
950    @@ -666,7 +691,9 @@ struct file *filp_open(const char * file
951            if (namei_flags & O_TRUNC)
952                    namei_flags |= 2;
953    
954    +       ccs_save_open_mode(flags);
955            error = open_namei(filename, namei_flags, mode, &nd);
956    +       ccs_clear_open_mode();
957            if (!error)
958                    return dentry_open(nd.dentry, nd.mnt, flags);
959    
960    @@ -897,6 +924,8 @@ out_unlock:
961    */    */
962   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
963   {   {
# Line 997  Source code for this patch is http://www Line 966  Source code for this patch is http://www
966          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
967                  tty_vhangup(current->tty);                  tty_vhangup(current->tty);
968                  return 0;                  return 0;
969  --- linux-2.4.37.4.orig/fs/proc/Makefile  --- linux-2.4.37.6.orig/fs/proc/proc_misc.c
970  +++ linux-2.4.37.4/fs/proc/Makefile  +++ linux-2.4.37.6/fs/proc/proc_misc.c
 @@ -18,4 +18,8 @@ ifeq ($(CONFIG_PROC_DEVICETREE),y)  
  obj-y += proc_devtree.o  
  endif  
   
 +export-objs += ccs_proc.o  
 +obj-$(CONFIG_SAKURA) += ccs_proc.o  
 +obj-$(CONFIG_TOMOYO) += ccs_proc.o  
 +  
  include $(TOPDIR)/Rules.make  
 --- linux-2.4.37.4.orig/fs/proc/proc_misc.c  
 +++ linux-2.4.37.4/fs/proc/proc_misc.c  
971  @@ -670,4 +670,5 @@ void __init proc_misc_init(void)  @@ -670,4 +670,5 @@ void __init proc_misc_init(void)
972                          entry->proc_fops = &ppc_htab_operations;                          entry->proc_fops = &ppc_htab_operations;
973          }          }
974   #endif   #endif
975  +       printk(KERN_INFO "Hook version: 2.4.37.4 2009/08/05\n");  +       printk(KERN_INFO "Hook version: 2.4.37.6 2009/09/17\n);
976   }   }
977  --- linux-2.4.37.4.orig/include/linux/sched.h  --- linux-2.4.37.6.orig/include/linux/sched.h
978  +++ linux-2.4.37.4/include/linux/sched.h  +++ linux-2.4.37.6/include/linux/sched.h
979  @@ -29,6 +29,8 @@ extern unsigned long event;  @@ -29,6 +29,15 @@ extern unsigned long event;
980    
981   struct exec_domain;   struct exec_domain;
982    
983    +#ifdef CONFIG_CCSECURITY
984  +struct ccs_domain_info;  +struct ccs_domain_info;
985    +#define INIT_CCSECURITY          \
986    +       .ccs_domain_info = NULL, \
987    +       .ccs_flags = 0,
988    +#else
989    +#define INIT_CCSECURITY
990    +#endif
991  +  +
992   /*   /*
993    * cloning flags:    * cloning flags:
994    */    */
995  @@ -417,6 +419,8 @@ struct task_struct {  @@ -417,6 +426,10 @@ struct task_struct {
996          void *journal_info;          void *journal_info;
997    
998          struct list_head *scm_work_list;          struct list_head *scm_work_list;
999    +#ifdef CONFIG_CCSECURITY
1000  +       struct ccs_domain_info *ccs_domain_info;  +       struct ccs_domain_info *ccs_domain_info;
1001  +       u32 ccs_flags;  +       u32 ccs_flags;
1002    +#endif
1003   };   };
1004    
1005   /*   /*
1006  @@ -512,6 +516,8 @@ extern struct exec_domain   default_exec_d  @@ -512,6 +525,7 @@ extern struct exec_domain   default_exec_d
1007       blocked:           {{0}},                                          \       blocked:           {{0}},                                          \
1008       alloc_lock:                SPIN_LOCK_UNLOCKED,                             \       alloc_lock:                SPIN_LOCK_UNLOCKED,                             \
1009       journal_info:      NULL,                                           \       journal_info:      NULL,                                           \
1010  +       ccs_domain_info: NULL,            \  +       INIT_CCSECURITY                                                 \
 +       ccs_flags: 0                      \  
1011   }   }
1012    
1013    
1014  --- linux-2.4.37.4.orig/kernel/kmod.c  --- linux-2.4.37.6.orig/kernel/kmod.c
1015  +++ linux-2.4.37.4/kernel/kmod.c  +++ linux-2.4.37.6/kernel/kmod.c
1016  @@ -134,6 +134,9 @@ int exec_usermodehelper(char *program_pa  @@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa
1017          /* Allow execve args to be in kernel space. */          /* Allow execve args to be in kernel space. */
1018          set_fs(KERNEL_DS);          set_fs(KERNEL_DS);
1019    
1020    +#ifdef CONFIG_CCSECURITY
1021  +       current->ccs_domain_info = NULL;  +       current->ccs_domain_info = NULL;
1022  +       current->ccs_flags = 0;  +       current->ccs_flags = 0;
1023    +#endif
1024  +  +
1025          /* Go, go, go... */          /* Go, go, go... */
1026          if (execve(program_path, argv, envp) < 0)          if (execve(program_path, argv, envp) < 0)
1027                  return -errno;                  return -errno;
1028  --- linux-2.4.37.4.orig/kernel/module.c  --- linux-2.4.37.6.orig/kernel/module.c
1029  +++ linux-2.4.37.4/kernel/module.c  +++ linux-2.4.37.6/kernel/module.c
1030  @@ -10,6 +10,7 @@  @@ -10,6 +10,7 @@
1031   #include <linux/slab.h>   #include <linux/slab.h>
1032   #include <linux/kmod.h>   #include <linux/kmod.h>
1033   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1034  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1035    
1036   /*   /*
1037    * Originally by Anonymous (as far as I know...)    * Originally by Anonymous (as far as I know...)
# Line 1094  Source code for this patch is http://www Line 1062  Source code for this patch is http://www
1062    
1063          lock_kernel();          lock_kernel();
1064          if (name_user) {          if (name_user) {
1065  --- linux-2.4.37.4.orig/kernel/sched.c  --- linux-2.4.37.6.orig/kernel/sched.c
1066  +++ linux-2.4.37.4/kernel/sched.c  +++ linux-2.4.37.6/kernel/sched.c
1067  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
1068    
1069   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1070   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
1071  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1072    
1073   extern void timer_bh(void);   extern void timer_bh(void);
1074   extern void tqueue_bh(void);   extern void tqueue_bh(void);
# Line 1113  Source code for this patch is http://www Line 1081  Source code for this patch is http://www
1081    
1082          /*          /*
1083           *      Setpriority might change our priority at the same moment.           *      Setpriority might change our priority at the same moment.
1084  --- linux-2.4.37.4.orig/kernel/signal.c  --- linux-2.4.37.6.orig/kernel/signal.c
1085  +++ linux-2.4.37.4/kernel/signal.c  +++ linux-2.4.37.6/kernel/signal.c
1086  @@ -15,6 +15,7 @@  @@ -15,6 +15,7 @@
1087   #include <linux/sched.h>   #include <linux/sched.h>
1088    
1089   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1090  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1091    
1092   /*   /*
1093    * SLAB caches for signal bits.    * SLAB caches for signal bits.
# Line 1141  Source code for this patch is http://www Line 1109  Source code for this patch is http://www
1109    
1110          info.si_signo = sig;          info.si_signo = sig;
1111          info.si_errno = 0;          info.si_errno = 0;
1112  --- linux-2.4.37.4.orig/kernel/sys.c  @@ -1078,6 +1083,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
1113  +++ linux-2.4.37.4/kernel/sys.c          if (info.si_code >= 0)
1114                    return -EPERM;
1115            info.si_signo = sig;
1116    +       if (ccs_sigqueue_permission(pid, sig))
1117    +               return -EPERM;
1118    
1119            /* POSIX.1b doesn't mention process groups.  */
1120            return kill_proc_info(sig, &info, pid);
1121    --- linux-2.4.37.6.orig/kernel/sys.c
1122    +++ linux-2.4.37.6/kernel/sys.c
1123  @@ -17,6 +17,7 @@  @@ -17,6 +17,7 @@
1124    
1125   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1126   #include <asm/io.h>   #include <asm/io.h>
1127  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1128    
1129   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
1130   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
# Line 1187  Source code for this patch is http://www Line 1164  Source code for this patch is http://www
1164    
1165          down_write(&uts_sem);          down_write(&uts_sem);
1166          errno = -EFAULT;          errno = -EFAULT;
1167  --- linux-2.4.37.4.orig/kernel/sysctl.c  --- linux-2.4.37.6.orig/kernel/sysctl.c
1168  +++ linux-2.4.37.4/kernel/sysctl.c  +++ linux-2.4.37.6/kernel/sysctl.c
1169  @@ -33,6 +33,7 @@  @@ -33,6 +33,7 @@
1170   #include <linux/swap.h>   #include <linux/swap.h>
1171    
1172   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1173  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1174    
1175   #ifdef CONFIG_ROOT_NFS   #ifdef CONFIG_ROOT_NFS
1176   #include <linux/nfs_fs.h>   #include <linux/nfs_fs.h>
# Line 1230  Source code for this patch is http://www Line 1207  Source code for this patch is http://www
1207   }   }
1208    
1209   /*   /*
1210  --- linux-2.4.37.4.orig/kernel/time.c  --- linux-2.4.37.6.orig/kernel/time.c
1211  +++ linux-2.4.37.4/kernel/time.c  +++ linux-2.4.37.6/kernel/time.c
1212  @@ -29,6 +29,7 @@  @@ -29,6 +29,7 @@
1213   #include <linux/smp_lock.h>   #include <linux/smp_lock.h>
1214    
1215   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1216  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1217    
1218   /*   /*
1219    * The timezone where the local system is located.  Used as a default by some    * The timezone where the local system is located.  Used as a default by some
# Line 1267  Source code for this patch is http://www Line 1244  Source code for this patch is http://www
1244                                    
1245          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
1246    
1247  --- linux-2.4.37.4.orig/net/ipv4/raw.c  --- linux-2.4.37.6.orig/net/ipv4/raw.c
1248  +++ linux-2.4.37.4/net/ipv4/raw.c  +++ linux-2.4.37.6/net/ipv4/raw.c
1249  @@ -64,6 +64,7 @@  @@ -64,6 +64,7 @@
1250   #include <net/raw.h>   #include <net/raw.h>
1251   #include <net/inet_common.h>   #include <net/inet_common.h>
1252   #include <net/checksum.h>   #include <net/checksum.h>
1253  +#include <linux/tomoyo_socket.h>  +#include <linux/ccsecurity.h>
1254    
1255   struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE];   struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE];
1256   rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED;   rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED;
# Line 1287  Source code for this patch is http://www Line 1264  Source code for this patch is http://www
1264    
1265          copied = skb->len;          copied = skb->len;
1266          if (len < copied) {          if (len < copied) {
1267  --- linux-2.4.37.4.orig/net/ipv4/tcp_ipv4.c  --- linux-2.4.37.6.orig/net/ipv4/tcp_ipv4.c
1268  +++ linux-2.4.37.4/net/ipv4/tcp_ipv4.c  +++ linux-2.4.37.6/net/ipv4/tcp_ipv4.c
1269  @@ -67,6 +67,7 @@  @@ -67,6 +67,7 @@
1270   #include <linux/inet.h>   #include <linux/inet.h>
1271   #include <linux/stddef.h>   #include <linux/stddef.h>
1272   #include <linux/ipsec.h>   #include <linux/ipsec.h>
1273  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1274    
1275   extern int sysctl_ip_dynaddr;   extern int sysctl_ip_dynaddr;
1276   extern int sysctl_ip_default_ttl;   extern int sysctl_ip_default_ttl;
# Line 1315  Source code for this patch is http://www Line 1292  Source code for this patch is http://www
1292    
1293                          /* Does not bother with rcv_saddr checks,                          /* Does not bother with rcv_saddr checks,
1294                           * because the established check is already                           * because the established check is already
1295  --- linux-2.4.37.4.orig/net/ipv4/udp.c  --- linux-2.4.37.6.orig/net/ipv4/udp.c
1296  +++ linux-2.4.37.4/net/ipv4/udp.c  +++ linux-2.4.37.6/net/ipv4/udp.c
1297  @@ -97,6 +97,8 @@  @@ -97,6 +97,7 @@
1298   #include <net/route.h>   #include <net/route.h>
1299   #include <net/inet_common.h>   #include <net/inet_common.h>
1300   #include <net/checksum.h>   #include <net/checksum.h>
1301  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1302    
1303   /*   /*
1304    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
1305  @@ -131,6 +133,8 @@ static int udp_v4_get_port(struct sock *  @@ -131,6 +132,8 @@ static int udp_v4_get_port(struct sock *
1306                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1307                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1308                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
# Line 1335  Source code for this patch is http://www Line 1311  Source code for this patch is http://www
1311                                  goto gotit;                                  goto gotit;
1312                          }                          }
1313                          size = 0;                          size = 0;
1314  @@ -148,6 +152,8 @@ static int udp_v4_get_port(struct sock *  @@ -148,6 +151,8 @@ static int udp_v4_get_port(struct sock *
1315                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1316                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1317                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
# Line 1344  Source code for this patch is http://www Line 1320  Source code for this patch is http://www
1320                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1321                                  break;                                  break;
1322                  }                  }
1323  @@ -711,6 +717,9 @@ try_again:  @@ -711,6 +716,9 @@ try_again:
1324          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1325          if (!skb)          if (!skb)
1326                  goto out;                  goto out;
# Line 1354  Source code for this patch is http://www Line 1330  Source code for this patch is http://www
1330        
1331          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1332          if (copied > len) {          if (copied > len) {
1333  --- linux-2.4.37.4.orig/net/ipv6/raw.c  --- linux-2.4.37.6.orig/net/ipv6/raw.c
1334  +++ linux-2.4.37.4/net/ipv6/raw.c  +++ linux-2.4.37.6/net/ipv6/raw.c
1335  @@ -45,6 +45,7 @@  @@ -45,6 +45,7 @@
1336   #include <net/inet_common.h>   #include <net/inet_common.h>
1337    
1338   #include <net/rawv6.h>   #include <net/rawv6.h>
1339  +#include <linux/tomoyo_socket.h>  +#include <linux/ccsecurity.h>
1340    
1341   struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE];   struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE];
1342   rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED;   rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED;
# Line 1374  Source code for this patch is http://www Line 1350  Source code for this patch is http://www
1350    
1351          copied = skb->len;          copied = skb->len;
1352          if (copied > len) {          if (copied > len) {
1353  --- linux-2.4.37.4.orig/net/ipv6/tcp_ipv6.c  --- linux-2.4.37.6.orig/net/ipv6/tcp_ipv6.c
1354  +++ linux-2.4.37.4/net/ipv6/tcp_ipv6.c  +++ linux-2.4.37.6/net/ipv6/tcp_ipv6.c
1355  @@ -52,6 +52,7 @@  @@ -52,6 +52,7 @@
1356   #include <net/inet_ecn.h>   #include <net/inet_ecn.h>
1357    
1358   #include <asm/uaccess.h>   #include <asm/uaccess.h>
1359  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
1360    
1361   static void    tcp_v6_send_reset(struct sk_buff *skb);   static void    tcp_v6_send_reset(struct sk_buff *skb);
1362   static void    tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);   static void    tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
# Line 1393  Source code for this patch is http://www Line 1369  Source code for this patch is http://www
1369                          for (tb = head->chain; tb; tb = tb->next)                          for (tb = head->chain; tb; tb = tb->next)
1370                                  if (tb->port == rover)                                  if (tb->port == rover)
1371                                          goto next;                                          goto next;
1372  --- linux-2.4.37.4.orig/net/ipv6/udp.c  --- linux-2.4.37.6.orig/net/ipv6/udp.c
1373  +++ linux-2.4.37.4/net/ipv6/udp.c  +++ linux-2.4.37.6/net/ipv6/udp.c
1374  @@ -50,6 +50,8 @@  @@ -50,6 +50,7 @@
1375   #include <net/inet_common.h>   #include <net/inet_common.h>
1376    
1377   #include <net/checksum.h>   #include <net/checksum.h>
1378  +#include <linux/sakura.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1379    
1380   struct udp_mib udp_stats_in6[NR_CPUS*2];   struct udp_mib udp_stats_in6[NR_CPUS*2];
1381    
1382  @@ -77,6 +79,8 @@ static int udp_v6_get_port(struct sock *  @@ -77,6 +78,8 @@ static int udp_v6_get_port(struct sock *
1383                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1384                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1385                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
# Line 1413  Source code for this patch is http://www Line 1388  Source code for this patch is http://www
1388                                  goto gotit;                                  goto gotit;
1389                          }                          }
1390                          size = 0;                          size = 0;
1391  @@ -94,6 +98,8 @@ static int udp_v6_get_port(struct sock *  @@ -94,6 +97,8 @@ static int udp_v6_get_port(struct sock *
1392                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1393                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1394                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
# Line 1422  Source code for this patch is http://www Line 1397  Source code for this patch is http://www
1397                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1398                                  break;                                  break;
1399                  }                  }
1400  @@ -406,6 +412,9 @@ try_again:  @@ -406,6 +411,9 @@ try_again:
1401          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1402          if (!skb)          if (!skb)
1403                  goto out;                  goto out;
# Line 1432  Source code for this patch is http://www Line 1407  Source code for this patch is http://www
1407    
1408          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1409          if (copied > len) {          if (copied > len) {
1410  --- linux-2.4.37.4.orig/net/socket.c  --- linux-2.4.37.6.orig/net/socket.c
1411  +++ linux-2.4.37.4/net/socket.c  +++ linux-2.4.37.6/net/socket.c
1412  @@ -84,6 +84,8 @@  @@ -84,6 +84,7 @@
1413   #include <net/sock.h>   #include <net/sock.h>
1414   #include <net/scm.h>   #include <net/scm.h>
1415   #include <linux/netfilter.h>   #include <linux/netfilter.h>
1416  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
 +#include <linux/tomoyo_socket.h>  
1417    
1418   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1419   static ssize_t sock_read(struct file *file, char *buf,   static ssize_t sock_read(struct file *file, char *buf,
1420  @@ -501,7 +503,10 @@ int sock_sendmsg(struct socket *sock, st  @@ -501,7 +502,10 @@ int sock_sendmsg(struct socket *sock, st
1421   {   {
1422          int err;          int err;
1423          struct scm_cookie scm;          struct scm_cookie scm;
# Line 1455  Source code for this patch is http://www Line 1429  Source code for this patch is http://www
1429          err = scm_send(sock, msg, &scm);          err = scm_send(sock, msg, &scm);
1430          if (err >= 0) {          if (err >= 0) {
1431                  err = sock->ops->sendmsg(sock, msg, size, &scm);                  err = sock->ops->sendmsg(sock, msg, size, &scm);
1432  @@ -847,7 +852,9 @@ int sock_create(int family, int type, in  @@ -850,7 +854,9 @@ int sock_create(int family, int type, in
1433                  }                  }
1434                  family = PF_PACKET;                  family = PF_PACKET;
1435          }          }
# Line 1466  Source code for this patch is http://www Line 1440  Source code for this patch is http://www
1440   #if defined(CONFIG_KMOD) && defined(CONFIG_NET)   #if defined(CONFIG_KMOD) && defined(CONFIG_NET)
1441          /* Attempt to load a protocol module if the find failed.          /* Attempt to load a protocol module if the find failed.
1442           *           *
1443  @@ -1003,6 +1010,10 @@ asmlinkage long sys_bind(int fd, struct  @@ -1006,6 +1012,10 @@ asmlinkage long sys_bind(int fd, struct
1444          if((sock = sockfd_lookup(fd,&err))!=NULL)          if((sock = sockfd_lookup(fd,&err))!=NULL)
1445          {          {
1446                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)
# Line 1477  Source code for this patch is http://www Line 1451  Source code for this patch is http://www
1451                          err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);                          err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1452                  sockfd_put(sock);                  sockfd_put(sock);
1453          }                                }                      
1454  @@ -1026,6 +1037,8 @@ asmlinkage long sys_listen(int fd, int b  @@ -1029,6 +1039,8 @@ asmlinkage long sys_listen(int fd, int b
1455          if ((sock = sockfd_lookup(fd, &err)) != NULL) {          if ((sock = sockfd_lookup(fd, &err)) != NULL) {
1456                  if ((unsigned) backlog > sysctl_somaxconn)                  if ((unsigned) backlog > sysctl_somaxconn)
1457                          backlog = sysctl_somaxconn;                          backlog = sysctl_somaxconn;
# Line 1486  Source code for this patch is http://www Line 1460  Source code for this patch is http://www
1460                  err=sock->ops->listen(sock, backlog);                  err=sock->ops->listen(sock, backlog);
1461                  sockfd_put(sock);                  sockfd_put(sock);
1462          }          }
1463  @@ -1066,6 +1079,11 @@ asmlinkage long sys_accept(int fd, struc  @@ -1069,6 +1081,11 @@ asmlinkage long sys_accept(int fd, struc
1464          if (err < 0)          if (err < 0)
1465                  goto out_release;                  goto out_release;
1466    
# Line 1498  Source code for this patch is http://www Line 1472  Source code for this patch is http://www
1472          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1473                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1474                          err = -ECONNABORTED;                          err = -ECONNABORTED;
1475  @@ -1116,6 +1134,10 @@ asmlinkage long sys_connect(int fd, stru  @@ -1119,6 +1136,10 @@ asmlinkage long sys_connect(int fd, stru
1476          err = move_addr_to_kernel(uservaddr, addrlen, address);          err = move_addr_to_kernel(uservaddr, addrlen, address);
1477          if (err < 0)          if (err < 0)
1478                  goto out_put;                  goto out_put;
# Line 1509  Source code for this patch is http://www Line 1483  Source code for this patch is http://www
1483          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1484                                   sock->file->f_flags);                                   sock->file->f_flags);
1485   out_put:   out_put:
1486  --- linux-2.4.37.4.orig/net/unix/af_unix.c  --- linux-2.4.37.6.orig/net/unix/af_unix.c
1487  +++ linux-2.4.37.4/net/unix/af_unix.c  +++ linux-2.4.37.6/net/unix/af_unix.c
1488  @@ -111,6 +111,7 @@  @@ -111,6 +111,7 @@
1489   #include <linux/rtnetlink.h>   #include <linux/rtnetlink.h>
1490    
1491   #include <asm/checksum.h>   #include <asm/checksum.h>
1492  +#include <linux/tomoyo.h>  +#include <linux/ccsecurity.h>
1493    
1494   int sysctl_unix_max_dgram_qlen = 10;   int sysctl_unix_max_dgram_qlen = 10;
1495    
# Line 1523  Source code for this patch is http://www Line 1497  Source code for this patch is http://www
1497                   * All right, let's create it.                   * All right, let's create it.
1498                   */                   */
1499                  mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);                  mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);
1500  +               err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1501  +                                                nd.mnt, mode, 0);  +                                          mode, 0);
1502  +               if (!err)  +               if (!err)
1503                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1504                  if (err)                  if (err)

Legend:
Removed from v.2851  
changed lines
  Added in v.3053

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