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

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

revision 2921 by kumaneko, Wed Aug 19 00:34:46 2009 UTC revision 3856 by kumaneko, Mon Jul 26 06:55:22 2010 UTC
# Line 1  Line 1 
1  This is TOMOYO Linux patch for kernel 2.4.37.5.  This is TOMOYO Linux patch for kernel 2.4.37.9.
2    
3  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.5.tar.bz2  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.9.tar.bz2
4  ---  ---
5   arch/alpha/kernel/ptrace.c   |    3 ++   Makefile                     |    8 ++++++++
6   arch/arm/kernel/ptrace.c     |    3 ++   arch/alpha/kernel/ptrace.c   |    3 +++
7   arch/cris/kernel/ptrace.c    |    3 ++   arch/arm/kernel/ptrace.c     |    3 +++
8   arch/i386/kernel/ptrace.c    |    3 ++   arch/cris/kernel/ptrace.c    |    3 +++
9   arch/ia64/ia32/sys_ia32.c    |    3 ++   arch/i386/kernel/ptrace.c    |    3 +++
10   arch/ia64/kernel/ptrace.c    |    3 ++   arch/ia64/ia32/sys_ia32.c    |    3 +++
11   arch/m68k/kernel/ptrace.c    |    3 ++   arch/ia64/kernel/ptrace.c    |    3 +++
12   arch/mips/kernel/ptrace.c    |    3 ++   arch/m68k/kernel/ptrace.c    |    3 +++
13   arch/mips64/kernel/ptrace.c  |    5 ++++   arch/mips/kernel/ptrace.c    |    3 +++
14   arch/parisc/kernel/ptrace.c  |    3 ++   arch/mips64/kernel/ptrace.c  |    5 +++++
15   arch/ppc/kernel/ptrace.c     |    3 ++   arch/parisc/kernel/ptrace.c  |    3 +++
16   arch/ppc64/kernel/ptrace.c   |    3 ++   arch/ppc/kernel/ptrace.c     |    3 +++
17   arch/ppc64/kernel/ptrace32.c |    3 ++   arch/ppc64/kernel/ptrace.c   |    3 +++
18   arch/s390/kernel/ptrace.c    |    3 ++   arch/ppc64/kernel/ptrace32.c |    3 +++
19   arch/s390x/kernel/ptrace.c   |    3 ++   arch/s390/kernel/ptrace.c    |    3 +++
20   arch/sh/kernel/ptrace.c      |    3 ++   arch/s390x/kernel/ptrace.c   |    3 +++
21   arch/sh64/kernel/ptrace.c    |    3 ++   arch/sh/kernel/ptrace.c      |    3 +++
22   arch/sparc/kernel/ptrace.c   |    5 ++++   arch/sh64/kernel/ptrace.c    |    3 +++
23   arch/sparc64/kernel/ptrace.c |    5 ++++   arch/sparc/kernel/ptrace.c   |    5 +++++
24   arch/x86_64/ia32/ptrace32.c  |    3 ++   arch/sparc64/kernel/ptrace.c |    5 +++++
25   arch/x86_64/kernel/ptrace.c  |    3 ++   arch/x86_64/ia32/ptrace32.c  |    3 +++
26   fs/Config.in                 |    3 ++   arch/x86_64/kernel/ptrace.c  |    3 +++
27   fs/Makefile                  |    2 +   fs/Config.in                 |    3 +++
28   fs/attr.c                    |    4 +++   fs/exec.c                    |   12 +++++++++++-
29   fs/exec.c                    |   12 ++++++++++-   fs/fcntl.c                   |    4 ++++
30   fs/fcntl.c                   |    4 +++   fs/ioctl.c                   |    6 ++++++
31   fs/ioctl.c                   |   10 +++++++++   fs/namei.c                   |   39 +++++++++++++++++++++++++++++++++++++++
32   fs/namei.c                   |   45 +++++++++++++++++++++++++++++++++++++++++++   fs/namespace.c               |   17 +++++++++++++++++
33   fs/namespace.c               |   31 ++++++++++++++++++++++++++++-   fs/open.c                    |   27 +++++++++++++++++++++++++++
34   fs/open.c                    |   28 ++++++++++++++++++++++++++   fs/proc/proc_misc.c          |    1 +
35   fs/proc/proc_misc.c          |    1   include/linux/sched.h        |   14 ++++++++++++++
36   include/linux/sched.h        |    6 +++++   kernel/kmod.c                |    5 +++++
37   kernel/kmod.c                |    3 ++   kernel/module.c              |    7 +++++++
38   kernel/module.c              |    7 ++++++   kernel/sched.c               |    3 +++
39   kernel/sched.c               |    3 ++   kernel/signal.c              |    7 +++++++
40   kernel/signal.c              |    7 ++++++   kernel/sys.c                 |    9 +++++++++
41   kernel/sys.c                 |    9 ++++++++   kernel/sysctl.c              |   13 ++++++++++++-
42   kernel/sysctl.c              |   13 +++++++++++-   kernel/time.c                |    7 +++++++
43   kernel/time.c                |    7 ++++++   net/ipv4/raw.c               |   12 +++++++++---
44   net/ipv4/raw.c               |    4 +++   net/ipv4/tcp_ipv4.c          |    5 +++++
45   net/ipv4/tcp_ipv4.c          |    5 ++++   net/ipv4/udp.c               |   14 +++++++++++++-
46   net/ipv4/udp.c               |    8 +++++++   net/ipv6/raw.c               |   12 +++++++++---
47   net/ipv6/raw.c               |    4 +++   net/ipv6/tcp_ipv6.c          |    3 +++
48   net/ipv6/tcp_ipv6.c          |    3 ++   net/ipv6/udp.c               |   14 +++++++++++++-
49   net/ipv6/udp.c               |    8 +++++++   net/socket.c                 |   23 +++++++++++++++++++++--
50   net/socket.c                 |   25 +++++++++++++++++++++--   net/unix/af_unix.c           |    4 ++++
51   net/unix/af_unix.c           |    4 +++   46 files changed, 326 insertions(+), 12 deletions(-)
  47 files changed, 320 insertions(+), 5 deletions(-)  
52    
53  --- linux-2.4.37.5.orig/arch/alpha/kernel/ptrace.c  --- linux-2.4.37.9.orig/Makefile
54  +++ linux-2.4.37.5/arch/alpha/kernel/ptrace.c  +++ 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    --- linux-2.4.37.9.orig/arch/alpha/kernel/ptrace.c
71    +++ linux-2.4.37.9/arch/alpha/kernel/ptrace.c
72  @@ -18,6 +18,7 @@  @@ -18,6 +18,7 @@
73   #include <asm/pgtable.h>   #include <asm/pgtable.h>
74   #include <asm/system.h>   #include <asm/system.h>
# Line 65  Source code for this patch is http://www Line 81  Source code for this patch is http://www
81   {   {
82          struct task_struct *child;          struct task_struct *child;
83          long ret;          long ret;
84  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
85  +               return -EPERM;  +               return -EPERM;
86    
87          lock_kernel();          lock_kernel();
88          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",
89  --- linux-2.4.37.5.orig/arch/arm/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/arm/kernel/ptrace.c
90  +++ linux-2.4.37.5/arch/arm/kernel/ptrace.c  +++ linux-2.4.37.9/arch/arm/kernel/ptrace.c
91  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
92   #include <asm/uaccess.h>   #include <asm/uaccess.h>
93   #include <asm/pgtable.h>   #include <asm/pgtable.h>
# Line 84  Source code for this patch is http://www Line 100  Source code for this patch is http://www
100   {   {
101          struct task_struct *child;          struct task_struct *child;
102          int ret;          int ret;
103  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
104  +               return -EPERM;  +               return -EPERM;
105    
106          lock_kernel();          lock_kernel();
107          ret = -EPERM;          ret = -EPERM;
108  --- linux-2.4.37.5.orig/arch/cris/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/cris/kernel/ptrace.c
109  +++ linux-2.4.37.5/arch/cris/kernel/ptrace.c  +++ linux-2.4.37.9/arch/cris/kernel/ptrace.c
110  @@ -48,6 +48,7 @@  @@ -48,6 +48,7 @@
111   #include <asm/pgtable.h>   #include <asm/pgtable.h>
112   #include <asm/system.h>   #include <asm/system.h>
# Line 103  Source code for this patch is http://www Line 119  Source code for this patch is http://www
119   {   {
120          struct task_struct *child;          struct task_struct *child;
121          int ret;          int ret;
122  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
123  +               return -EPERM;  +               return -EPERM;
124    
125          lock_kernel();          lock_kernel();
126          ret = -EPERM;          ret = -EPERM;
127  --- linux-2.4.37.5.orig/arch/i386/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/i386/kernel/ptrace.c
128  +++ linux-2.4.37.5/arch/i386/kernel/ptrace.c  +++ linux-2.4.37.9/arch/i386/kernel/ptrace.c
129  @@ -20,6 +20,7 @@  @@ -20,6 +20,7 @@
130   #include <asm/processor.h>   #include <asm/processor.h>
131   #include <asm/i387.h>   #include <asm/i387.h>
# Line 122  Source code for this patch is http://www Line 138  Source code for this patch is http://www
138          struct task_struct *child;          struct task_struct *child;
139          struct user * dummy = NULL;          struct user * dummy = NULL;
140          int i, ret;          int i, ret;
141  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
142  +               return -EPERM;  +               return -EPERM;
143    
144          lock_kernel();          lock_kernel();
145          ret = -EPERM;          ret = -EPERM;
146  --- linux-2.4.37.5.orig/arch/ia64/ia32/sys_ia32.c  --- linux-2.4.37.9.orig/arch/ia64/ia32/sys_ia32.c
147  +++ linux-2.4.37.5/arch/ia64/ia32/sys_ia32.c  +++ linux-2.4.37.9/arch/ia64/ia32/sys_ia32.c
148  @@ -57,6 +57,7 @@  @@ -57,6 +57,7 @@
149   #include <net/scm.h>   #include <net/scm.h>
150   #include <net/sock.h>   #include <net/sock.h>
# Line 141  Source code for this patch is http://www Line 157  Source code for this patch is http://www
157          struct task_struct *child;          struct task_struct *child;
158          unsigned int value, tmp;          unsigned int value, tmp;
159          long i, ret;          long i, ret;
160  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
161  +               return -EPERM;  +               return -EPERM;
162    
163          lock_kernel();          lock_kernel();
164          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
165  --- linux-2.4.37.5.orig/arch/ia64/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/ia64/kernel/ptrace.c
166  +++ linux-2.4.37.5/arch/ia64/kernel/ptrace.c  +++ linux-2.4.37.9/arch/ia64/kernel/ptrace.c
167  @@ -27,6 +27,7 @@  @@ -27,6 +27,7 @@
168   #ifdef CONFIG_PERFMON   #ifdef CONFIG_PERFMON
169   #include <asm/perfmon.h>   #include <asm/perfmon.h>
# Line 160  Source code for this patch is http://www Line 176  Source code for this patch is http://www
176          struct task_struct *child;          struct task_struct *child;
177          struct switch_stack *sw;          struct switch_stack *sw;
178          long ret;          long ret;
179  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
180  +               return -EPERM;  +               return -EPERM;
181    
182          lock_kernel();          lock_kernel();
183          ret = -EPERM;          ret = -EPERM;
184  --- linux-2.4.37.5.orig/arch/m68k/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/m68k/kernel/ptrace.c
185  +++ linux-2.4.37.5/arch/m68k/kernel/ptrace.c  +++ linux-2.4.37.9/arch/m68k/kernel/ptrace.c
186  @@ -25,6 +25,7 @@  @@ -25,6 +25,7 @@
187   #include <asm/pgtable.h>   #include <asm/pgtable.h>
188   #include <asm/system.h>   #include <asm/system.h>
# Line 179  Source code for this patch is http://www Line 195  Source code for this patch is http://www
195   {   {
196          struct task_struct *child;          struct task_struct *child;
197          int ret;          int ret;
198  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
199  +               return -EPERM;  +               return -EPERM;
200    
201          lock_kernel();          lock_kernel();
202          ret = -EPERM;          ret = -EPERM;
203  --- linux-2.4.37.5.orig/arch/mips/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/mips/kernel/ptrace.c
204  +++ linux-2.4.37.5/arch/mips/kernel/ptrace.c  +++ linux-2.4.37.9/arch/mips/kernel/ptrace.c
205  @@ -28,6 +28,7 @@  @@ -28,6 +28,7 @@
206   #include <asm/bootinfo.h>   #include <asm/bootinfo.h>
207   #include <asm/cpu.h>   #include <asm/cpu.h>
# Line 198  Source code for this patch is http://www Line 214  Source code for this patch is http://www
214   {   {
215          struct task_struct *child;          struct task_struct *child;
216          int ret;          int ret;
217  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
218  +               return -EPERM;  +               return -EPERM;
219    
220          lock_kernel();          lock_kernel();
221   #if 0   #if 0
222  --- linux-2.4.37.5.orig/arch/mips64/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/mips64/kernel/ptrace.c
223  +++ linux-2.4.37.5/arch/mips64/kernel/ptrace.c  +++ linux-2.4.37.9/arch/mips64/kernel/ptrace.c
224  @@ -30,6 +30,7 @@  @@ -30,6 +30,7 @@
225   #include <asm/system.h>   #include <asm/system.h>
226   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 217  Source code for this patch is http://www Line 233  Source code for this patch is http://www
233   {   {
234          struct task_struct *child;          struct task_struct *child;
235          int ret;          int ret;
236  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
237  +               return -EPERM;  +               return -EPERM;
238    
239          lock_kernel();          lock_kernel();
# Line 226  Source code for this patch is http://www Line 242  Source code for this patch is http://www
242   {   {
243          struct task_struct *child;          struct task_struct *child;
244          int ret;          int ret;
245  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
246  +               return -EPERM;  +               return -EPERM;
247    
248          lock_kernel();          lock_kernel();
249   #if 0   #if 0
250  --- linux-2.4.37.5.orig/arch/parisc/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/parisc/kernel/ptrace.c
251  +++ linux-2.4.37.5/arch/parisc/kernel/ptrace.c  +++ linux-2.4.37.9/arch/parisc/kernel/ptrace.c
252  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
253   #include <asm/system.h>   #include <asm/system.h>
254   #include <asm/processor.h>   #include <asm/processor.h>
# Line 245  Source code for this patch is http://www Line 261  Source code for this patch is http://www
261   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
262          long oaddr=addr, odata=data;          long oaddr=addr, odata=data;
263   #endif   #endif
264  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
265  +               return -EPERM;  +               return -EPERM;
266    
267          lock_kernel();          lock_kernel();
268          ret = -EPERM;          ret = -EPERM;
269  --- linux-2.4.37.5.orig/arch/ppc/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/ppc/kernel/ptrace.c
270  +++ linux-2.4.37.5/arch/ppc/kernel/ptrace.c  +++ linux-2.4.37.9/arch/ppc/kernel/ptrace.c
271  @@ -29,6 +29,7 @@  @@ -29,6 +29,7 @@
272   #include <asm/page.h>   #include <asm/page.h>
273   #include <asm/pgtable.h>   #include <asm/pgtable.h>
# Line 264  Source code for this patch is http://www Line 280  Source code for this patch is http://www
280   {   {
281          struct task_struct *child;          struct task_struct *child;
282          int ret = -EPERM;          int ret = -EPERM;
283  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
284  +               return -EPERM;  +               return -EPERM;
285    
286          lock_kernel();          lock_kernel();
287          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
288  --- linux-2.4.37.5.orig/arch/ppc64/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/ppc64/kernel/ptrace.c
289  +++ linux-2.4.37.5/arch/ppc64/kernel/ptrace.c  +++ linux-2.4.37.9/arch/ppc64/kernel/ptrace.c
290  @@ -30,6 +30,7 @@  @@ -30,6 +30,7 @@
291   #include <asm/page.h>   #include <asm/page.h>
292   #include <asm/pgtable.h>   #include <asm/pgtable.h>
# Line 283  Source code for this patch is http://www Line 299  Source code for this patch is http://www
299   {   {
300          struct task_struct *child;          struct task_struct *child;
301          int ret = -EPERM;          int ret = -EPERM;
302  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
303  +               return -EPERM;  +               return -EPERM;
304    
305          lock_kernel();          lock_kernel();
306          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
307  --- linux-2.4.37.5.orig/arch/ppc64/kernel/ptrace32.c  --- linux-2.4.37.9.orig/arch/ppc64/kernel/ptrace32.c
308  +++ linux-2.4.37.5/arch/ppc64/kernel/ptrace32.c  +++ linux-2.4.37.9/arch/ppc64/kernel/ptrace32.c
309  @@ -30,6 +30,7 @@  @@ -30,6 +30,7 @@
310   #include <asm/page.h>   #include <asm/page.h>
311   #include <asm/pgtable.h>   #include <asm/pgtable.h>
# Line 302  Source code for this patch is http://www Line 318  Source code for this patch is http://www
318   {   {
319          struct task_struct *child;          struct task_struct *child;
320          int ret = -EPERM;          int ret = -EPERM;
321  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
322  +               return -EPERM;  +               return -EPERM;
323    
324          lock_kernel();          lock_kernel();
325          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
326  --- linux-2.4.37.5.orig/arch/s390/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/s390/kernel/ptrace.c
327  +++ linux-2.4.37.5/arch/s390/kernel/ptrace.c  +++ linux-2.4.37.9/arch/s390/kernel/ptrace.c
328  @@ -37,6 +37,7 @@  @@ -37,6 +37,7 @@
329   #include <asm/pgalloc.h>   #include <asm/pgalloc.h>
330   #include <asm/system.h>   #include <asm/system.h>
# Line 321  Source code for this patch is http://www Line 337  Source code for this patch is http://www
337          unsigned long tmp;          unsigned long tmp;
338          int copied;          int copied;
339          ptrace_area   parea;          ptrace_area   parea;
340  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
341  +               return -EPERM;  +               return -EPERM;
342    
343          lock_kernel();          lock_kernel();
344          if (request == PTRACE_TRACEME)          if (request == PTRACE_TRACEME)
345  --- linux-2.4.37.5.orig/arch/s390x/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/s390x/kernel/ptrace.c
346  +++ linux-2.4.37.5/arch/s390x/kernel/ptrace.c  +++ linux-2.4.37.9/arch/s390x/kernel/ptrace.c
347  @@ -43,6 +43,7 @@  @@ -43,6 +43,7 @@
348   #else   #else
349   #define parent_31bit 0   #define parent_31bit 0
# Line 340  Source code for this patch is http://www Line 356  Source code for this patch is http://www
356   #define sizeof_parent_long 8   #define sizeof_parent_long 8
357   #define dataptr (u8 *)&data   #define dataptr (u8 *)&data
358   #endif   #endif
359  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
360  +               return -EPERM;  +               return -EPERM;
361          lock_kernel();          lock_kernel();
362          if (request == PTRACE_TRACEME)          if (request == PTRACE_TRACEME)
363          {          {
364  --- linux-2.4.37.5.orig/arch/sh/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/sh/kernel/ptrace.c
365  +++ linux-2.4.37.5/arch/sh/kernel/ptrace.c  +++ linux-2.4.37.9/arch/sh/kernel/ptrace.c
366  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
367   #include <asm/system.h>   #include <asm/system.h>
368   #include <asm/processor.h>   #include <asm/processor.h>
# Line 359  Source code for this patch is http://www Line 375  Source code for this patch is http://www
375          struct task_struct *child, *tsk = current;          struct task_struct *child, *tsk = current;
376          struct user * dummy = NULL;          struct user * dummy = NULL;
377          int ret;          int ret;
378  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
379  +               return -EPERM;  +               return -EPERM;
380    
381          lock_kernel();          lock_kernel();
382          ret = -EPERM;          ret = -EPERM;
383  --- linux-2.4.37.5.orig/arch/sh64/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/sh64/kernel/ptrace.c
384  +++ linux-2.4.37.5/arch/sh64/kernel/ptrace.c  +++ linux-2.4.37.9/arch/sh64/kernel/ptrace.c
385  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
386   #include <asm/system.h>   #include <asm/system.h>
387   #include <asm/processor.h>   #include <asm/processor.h>
# Line 378  Source code for this patch is http://www Line 394  Source code for this patch is http://www
394   {   {
395          struct task_struct *child, *tsk = current;          struct task_struct *child, *tsk = current;
396          int ret;          int ret;
397  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
398  +               return -EPERM;  +               return -EPERM;
399    
400          lock_kernel();          lock_kernel();
401          ret = -EPERM;          ret = -EPERM;
402  --- linux-2.4.37.5.orig/arch/sparc/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/sparc/kernel/ptrace.c
403  +++ linux-2.4.37.5/arch/sparc/kernel/ptrace.c  +++ linux-2.4.37.9/arch/sparc/kernel/ptrace.c
404  @@ -21,6 +21,7 @@  @@ -21,6 +21,7 @@
405   #include <asm/pgtable.h>   #include <asm/pgtable.h>
406   #include <asm/system.h>   #include <asm/system.h>
# Line 397  Source code for this patch is http://www Line 413  Source code for this patch is http://www
413          unsigned long data = regs->u_regs[UREG_I3];          unsigned long data = regs->u_regs[UREG_I3];
414          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
415          struct task_struct *child;          struct task_struct *child;
416  +       if (!ccs_capable(CCS_SYS_PTRACE)) {  +       if (ccs_ptrace_permission(request, pid)) {
417  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
418  +               return;  +               return;
419  +       }  +       }
420    
421          lock_kernel();          lock_kernel();
422   #ifdef DEBUG_PTRACE   #ifdef DEBUG_PTRACE
423  --- linux-2.4.37.5.orig/arch/sparc64/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/sparc64/kernel/ptrace.c
424  +++ linux-2.4.37.5/arch/sparc64/kernel/ptrace.c  +++ linux-2.4.37.9/arch/sparc64/kernel/ptrace.c
425  @@ -26,6 +26,7 @@  @@ -26,6 +26,7 @@
426   #include <asm/psrcompat.h>   #include <asm/psrcompat.h>
427   #include <asm/visasm.h>   #include <asm/visasm.h>
# Line 418  Source code for this patch is http://www Line 434  Source code for this patch is http://www
434          unsigned long data = regs->u_regs[UREG_I3];          unsigned long data = regs->u_regs[UREG_I3];
435          unsigned long addr2 = regs->u_regs[UREG_I4];          unsigned long addr2 = regs->u_regs[UREG_I4];
436          struct task_struct *child;          struct task_struct *child;
437  +       if (!ccs_capable(CCS_SYS_PTRACE)) {  +       if (ccs_ptrace_permission(request, pid)) {
438  +               pt_error_return(regs, EPERM);  +               pt_error_return(regs, EPERM);
439  +               return;  +               return;
440  +       }  +       }
441    
442          if (current->thread.flags & SPARC_FLAG_32BIT) {          if (current->thread.flags & SPARC_FLAG_32BIT) {
443                  addr &= 0xffffffffUL;                  addr &= 0xffffffffUL;
444  --- linux-2.4.37.5.orig/arch/x86_64/ia32/ptrace32.c  --- linux-2.4.37.9.orig/arch/x86_64/ia32/ptrace32.c
445  +++ linux-2.4.37.5/arch/x86_64/ia32/ptrace32.c  +++ linux-2.4.37.9/arch/x86_64/ia32/ptrace32.c
446  @@ -24,6 +24,7 @@  @@ -24,6 +24,7 @@
447   #include <asm/i387.h>   #include <asm/i387.h>
448   #include <asm/fpu32.h>   #include <asm/fpu32.h>
# Line 439  Source code for this patch is http://www Line 455  Source code for this patch is http://www
455          struct pt_regs *childregs;          struct pt_regs *childregs;
456          int ret;          int ret;
457          __u32 val;          __u32 val;
458  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
459  +               return -EPERM;  +               return -EPERM;
460    
461          switch (request) {          switch (request) {
462          case PTRACE_TRACEME:          case PTRACE_TRACEME:
463  --- linux-2.4.37.5.orig/arch/x86_64/kernel/ptrace.c  --- linux-2.4.37.9.orig/arch/x86_64/kernel/ptrace.c
464  +++ linux-2.4.37.5/arch/x86_64/kernel/ptrace.c  +++ linux-2.4.37.9/arch/x86_64/kernel/ptrace.c
465  @@ -22,6 +22,7 @@  @@ -22,6 +22,7 @@
466   #include <asm/processor.h>   #include <asm/processor.h>
467   #include <asm/i387.h>   #include <asm/i387.h>
# Line 458  Source code for this patch is http://www Line 474  Source code for this patch is http://www
474          struct task_struct *child;          struct task_struct *child;
475          struct user * dummy = NULL;          struct user * dummy = NULL;
476          long i, ret;          long i, ret;
477  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (ccs_ptrace_permission(request, pid))
478  +               return -EPERM;  +               return -EPERM;
479    
480          /* This lock_kernel fixes a subtle race with suid exec */          /* This lock_kernel fixes a subtle race with suid exec */
481          lock_kernel();          lock_kernel();
482  --- linux-2.4.37.5.orig/fs/Config.in  --- linux-2.4.37.9.orig/fs/Config.in
483  +++ linux-2.4.37.5/fs/Config.in  +++ linux-2.4.37.9/fs/Config.in
484  @@ -176,4 +176,7 @@ comment 'Partition Types'  @@ -176,4 +176,7 @@ comment 'Partition Types'
485   source fs/partitions/Config.in   source fs/partitions/Config.in
486   endmenu   endmenu
# Line 473  Source code for this patch is http://www Line 489  Source code for this patch is http://www
489   endmenu   endmenu
490  +  +
491  +source security/ccsecurity/Config.in  +source security/ccsecurity/Config.in
492  --- linux-2.4.37.5.orig/fs/Makefile  --- linux-2.4.37.9.orig/fs/exec.c
493  +++ linux-2.4.37.5/fs/Makefile  +++ linux-2.4.37.9/fs/exec.c
 @@ -80,5 +80,7 @@ obj-$(CONFIG_BINFMT_ELF)      += binfmt_elf.o  
  # persistent filesystems  
  obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))  
   
 +subdir-$(CONFIG_CCSECURITY)    += ../security/ccsecurity  
 +obj-$(CONFIG_CCSECURITY)       += ../security/ccsecurity/ccsecurity.o  
   
  include $(TOPDIR)/Rules.make  
 --- linux-2.4.37.5.orig/fs/attr.c  
 +++ linux-2.4.37.5/fs/attr.c  
 @@ -12,6 +12,7 @@  
  #include <linux/dnotify.h>  
  #include <linux/fcntl.h>  
  #include <linux/quotaops.h>  
 +#include <linux/ccsecurity.h>  
   
  /* Taken over from the old code... */  
   
 @@ -127,6 +128,9 @@ int notify_change(struct dentry * dentry  
                 attr->ia_atime = now;  
         if (!(ia_valid & ATTR_MTIME_SET))  
                 attr->ia_mtime = now;  
 +       error = ccs_check_setattr_permission(dentry, attr);  
 +       if (error)  
 +               return error;  
   
         lock_kernel();  
         if (inode->i_op && inode->i_op->setattr)  
 --- linux-2.4.37.5.orig/fs/exec.c  
 +++ linux-2.4.37.5/fs/exec.c  
494  @@ -48,6 +48,8 @@  @@ -48,6 +48,8 @@
495   #include <linux/kmod.h>   #include <linux/kmod.h>
496   #endif   #endif
# Line 518  Source code for this patch is http://www Line 504  Source code for this patch is http://www
504          if (error)          if (error)
505                  goto exit;                  goto exit;
506    
507  +       error = ccs_check_uselib_permission(nd.dentry, nd.mnt);  +       error = ccs_uselib_permission(nd.dentry, nd.mnt);
508  +       if (error)  +       if (error)
509  +               goto exit;  +               goto exit;
510  +  +
# Line 530  Source code for this patch is http://www Line 516  Source code for this patch is http://www
516                          if (!err && !(inode->i_mode & 0111))                          if (!err && !(inode->i_mode & 0111))
517                                  err = -EACCES;                                  err = -EACCES;
518  +                       if (!err)  +                       if (!err)
519  +                               err = ccs_check_open_exec_permission(nd.dentry,  +                               err = ccs_open_exec_permission(nd.dentry,
520  +                                                                    nd.mnt);  +                                                                    nd.mnt);
521                          file = ERR_PTR(err);                          file = ERR_PTR(err);
522                          if (!err) {                          if (!err) {
# Line 545  Source code for this patch is http://www Line 531  Source code for this patch is http://www
531          if (retval >= 0)          if (retval >= 0)
532                  /* execve success */                  /* execve success */
533                  return retval;                  return retval;
534  --- linux-2.4.37.5.orig/fs/fcntl.c  --- linux-2.4.37.9.orig/fs/fcntl.c
535  +++ linux-2.4.37.5/fs/fcntl.c  +++ linux-2.4.37.9/fs/fcntl.c
536  @@ -16,6 +16,7 @@  @@ -16,6 +16,7 @@
537   #include <asm/poll.h>   #include <asm/poll.h>
538   #include <asm/siginfo.h>   #include <asm/siginfo.h>
# Line 559  Source code for this patch is http://www Line 545  Source code for this patch is http://www
545          if (!(arg & O_APPEND) && IS_APPEND(inode))          if (!(arg & O_APPEND) && IS_APPEND(inode))
546                  return -EPERM;                  return -EPERM;
547    
548  +       if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp))  +       if (!(arg & O_APPEND) && ccs_rewrite_permission(filp))
549  +               return -EPERM;  +               return -EPERM;
550  +  +
551          /* Did FASYNC state change? */          /* Did FASYNC state change? */
552          if ((arg ^ filp->f_flags) & FASYNC) {          if ((arg ^ filp->f_flags) & FASYNC) {
553                  if (filp->f_op && filp->f_op->fasync) {                  if (filp->f_op && filp->f_op->fasync) {
554  --- linux-2.4.37.5.orig/fs/ioctl.c  --- linux-2.4.37.9.orig/fs/ioctl.c
555  +++ linux-2.4.37.5/fs/ioctl.c  +++ linux-2.4.37.9/fs/ioctl.c
556  @@ -10,6 +10,7 @@  @@ -10,6 +10,7 @@
557    
558   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 579  Source code for this patch is http://www Line 565  Source code for this patch is http://www
565          filp = fget(fd);          filp = fget(fd);
566          if (!filp)          if (!filp)
567                  goto out;                  goto out;
568  +       error = ccs_check_ioctl_permission(filp, cmd, arg);  +       error = ccs_ioctl_permission(filp, cmd, arg);
569  +       if (error) {  +       if (error) {
570  +               fput(filp);  +               fput(filp);
571  +               goto out;  +               goto out;
# Line 587  Source code for this patch is http://www Line 573  Source code for this patch is http://www
573          error = 0;          error = 0;
574          lock_kernel();          lock_kernel();
575          switch (cmd) {          switch (cmd) {
576  @@ -112,6 +118,10 @@ asmlinkage long sys_ioctl(unsigned int f  --- linux-2.4.37.9.orig/fs/namei.c
577                                  error = -ENOTTY;  +++ linux-2.4.37.9/fs/namei.c
                         break;  
                 default:  
 +                       if (!ccs_capable(CCS_SYS_IOCTL)) {  
 +                               error = -EPERM;  
 +                               break;  
 +                       }  
                         error = -ENOTTY;  
                         if (S_ISREG(filp->f_dentry->d_inode->i_mode))  
                                 error = file_ioctl(filp, cmd, arg);  
 --- linux-2.4.37.5.orig/fs/namei.c  
 +++ linux-2.4.37.5/fs/namei.c  
578  @@ -28,6 +28,9 @@  @@ -28,6 +28,9 @@
579    
580   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
# Line 610  Source code for this patch is http://www Line 585  Source code for this patch is http://www
585   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
586    * Fundamental changes in the pathname lookup mechanisms (namei)    * Fundamental changes in the pathname lookup mechanisms (namei)
587    * were necessary because of omirr.  The reason is that omirr needs    * were necessary because of omirr.  The reason is that omirr needs
588  @@ -1003,6 +1006,7 @@ exit_lock:  @@ -1068,6 +1071,9 @@ do_last:
         return error;  
  }  
   
 +#include <linux/ccsecurity_vfs.h>  
  /*  
   *     open_namei()  
   *  
 @@ -1068,6 +1072,11 @@ do_last:  
589    
590          /* Negative dentry, just create the file */          /* Negative dentry, just create the file */
591          if (!dentry->d_inode) {          if (!dentry->d_inode) {
592  +               error = ccs_check_mknod_permission(dir->d_inode, dentry,  +               error = ccs_mknod_permission(dir->d_inode, dentry, nd->mnt,
593  +                                                  nd->mnt,  +                                            mode & ~current->fs->umask, 0);
 +                                                  mode & ~current->fs->umask,  
 +                                                  0);  
594  +               if (!error)  +               if (!error)
595                  error = vfs_create(dir->d_inode, dentry,                  error = vfs_create(dir->d_inode, dentry,
596                                     mode & ~current->fs->umask);                                     mode & ~current->fs->umask);
597                  up(&dir->d_inode->i_sem);                  up(&dir->d_inode->i_sem);
598  @@ -1154,6 +1163,11 @@ ok:  @@ -1154,6 +1160,11 @@ ok:
599                          goto exit;                          goto exit;
600          }          }
601    
602  +       /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
603  +       error = ccs_check_open_permission(dentry, nd->mnt, flag);  +       error = ccs_open_permission(dentry, nd->mnt, flag);
604  +       if (error)  +       if (error)
605  +               goto exit;  +               goto exit;
606  +  +
607          /*          /*
608           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
609           */           */
610  @@ -1292,6 +1306,7 @@ asmlinkage long sys_mknod(const char * f  @@ -1292,6 +1303,7 @@ asmlinkage long sys_mknod(const char * f
611    
612          if (S_ISDIR(mode))          if (S_ISDIR(mode))
613                  return -EPERM;                  return -EPERM;
# Line 650  Source code for this patch is http://www Line 615  Source code for this patch is http://www
615          tmp = getname(filename);          tmp = getname(filename);
616          if (IS_ERR(tmp))          if (IS_ERR(tmp))
617                  return PTR_ERR(tmp);                  return PTR_ERR(tmp);
618  @@ -1304,6 +1319,10 @@ asmlinkage long sys_mknod(const char * f  @@ -1304,6 +1316,10 @@ asmlinkage long sys_mknod(const char * f
619    
620          mode &= ~current->fs->umask;          mode &= ~current->fs->umask;
621          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
622  +               error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
623  +                                                  nd.mnt, mode, dev);  +                                            nd.mnt, mode, dev);
624  +               if (error)  +               if (error)
625  +                       goto out_dput;  +                       goto out_dput;
626                  switch (mode & S_IFMT) {                  switch (mode & S_IFMT) {
627                  case 0: case S_IFREG:                  case 0: case S_IFREG:
628                          error = vfs_create(nd.dentry->d_inode,dentry,mode);                          error = vfs_create(nd.dentry->d_inode,dentry,mode);
629  @@ -1317,6 +1336,7 @@ asmlinkage long sys_mknod(const char * f  @@ -1317,6 +1333,7 @@ asmlinkage long sys_mknod(const char * f
630                  default:                  default:
631                          error = -EINVAL;                          error = -EINVAL;
632                  }                  }
# Line 669  Source code for this patch is http://www Line 634  Source code for this patch is http://www
634                  dput(dentry);                  dput(dentry);
635          }          }
636          up(&nd.dentry->d_inode->i_sem);          up(&nd.dentry->d_inode->i_sem);
637  @@ -1370,6 +1390,10 @@ asmlinkage long sys_mkdir(const char * p  @@ -1370,6 +1387,9 @@ asmlinkage long sys_mkdir(const char * p
638                  dentry = lookup_create(&nd, 1);                  dentry = lookup_create(&nd, 1);
639                  error = PTR_ERR(dentry);                  error = PTR_ERR(dentry);
640                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
641  +                       error = ccs_check_mkdir_permission(nd.dentry->d_inode,  +                       error = ccs_mkdir_permission(nd.dentry->d_inode,
642  +                                                          dentry, nd.mnt,  +                                                    dentry, nd.mnt, mode);
 +                                                          mode);  
643  +                       if (!error)  +                       if (!error)
644                          error = vfs_mkdir(nd.dentry->d_inode, dentry,                          error = vfs_mkdir(nd.dentry->d_inode, dentry,
645                                            mode & ~current->fs->umask);                                            mode & ~current->fs->umask);
646                          dput(dentry);                          dput(dentry);
647  @@ -1479,6 +1503,9 @@ asmlinkage long sys_rmdir(const char * p  @@ -1479,6 +1499,9 @@ asmlinkage long sys_rmdir(const char * p
648          dentry = lookup_hash(&nd.last, nd.dentry);          dentry = lookup_hash(&nd.last, nd.dentry);
649          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
650          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
651  +               error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,  +               error = ccs_rmdir_permission(nd.dentry->d_inode, dentry,
652  +                                                  nd.mnt);  +                                            nd.mnt);
653  +               if (!error)  +               if (!error)
654                  error = vfs_rmdir(nd.dentry->d_inode, dentry);                  error = vfs_rmdir(nd.dentry->d_inode, dentry);
655                  dput(dentry);                  dput(dentry);
656          }          }
657  @@ -1548,6 +1575,10 @@ asmlinkage long sys_unlink(const char *  @@ -1548,6 +1571,10 @@ asmlinkage long sys_unlink(const char *
658                  /* Why not before? Because we want correct error value */                  /* Why not before? Because we want correct error value */
659                  if (nd.last.name[nd.last.len])                  if (nd.last.name[nd.last.len])
660                          goto slashes;                          goto slashes;
661  +               error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,  +               error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
662  +                                                   nd.mnt);  +                                             nd.mnt);
663  +               if (error)  +               if (error)
664  +                       goto exit2;  +                       goto exit2;
665                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
666          exit2:          exit2:
667                  dput(dentry);                  dput(dentry);
668  @@ -1612,6 +1643,10 @@ asmlinkage long sys_symlink(const char *  @@ -1612,6 +1639,9 @@ asmlinkage long sys_symlink(const char *
669                  dentry = lookup_create(&nd, 0);                  dentry = lookup_create(&nd, 0);
670                  error = PTR_ERR(dentry);                  error = PTR_ERR(dentry);
671                  if (!IS_ERR(dentry)) {                  if (!IS_ERR(dentry)) {
672  +                       error = ccs_check_symlink_permission(nd.dentry->d_inode,  +                       error = ccs_symlink_permission(nd.dentry->d_inode,
673  +                                                            dentry, nd.mnt,  +                                                      dentry, nd.mnt, from);
 +                                                            from);  
674  +                       if (!error)  +                       if (!error)
675                          error = vfs_symlink(nd.dentry->d_inode, dentry, from);                          error = vfs_symlink(nd.dentry->d_inode, dentry, from);
676                          dput(dentry);                          dput(dentry);
677                  }                  }
678  @@ -1698,6 +1733,10 @@ asmlinkage long sys_link(const char * ol  @@ -1698,6 +1728,10 @@ asmlinkage long sys_link(const char * ol
679                  new_dentry = lookup_create(&nd, 0);                  new_dentry = lookup_create(&nd, 0);
680                  error = PTR_ERR(new_dentry);                  error = PTR_ERR(new_dentry);
681                  if (!IS_ERR(new_dentry)) {                  if (!IS_ERR(new_dentry)) {
682  +                       error = ccs_check_link_permission(old_nd.dentry,  +                       error = ccs_link_permission(old_nd.dentry,
683  +                                                         nd.dentry->d_inode,  +                                                   nd.dentry->d_inode,
684  +                                                         new_dentry, nd.mnt);  +                                                   new_dentry, nd.mnt);
685  +                       if (!error)  +                       if (!error)
686                          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);                          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
687                          dput(new_dentry);                          dput(new_dentry);
688                  }                  }
689  @@ -1928,12 +1967,18 @@ static inline int do_rename(const char *  @@ -1928,12 +1962,17 @@ static inline int do_rename(const char *
690          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
691          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
692                  goto exit4;                  goto exit4;
693  +       error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,  +       error = ccs_rename_permission(old_dir->d_inode, old_dentry,
694  +                                           new_dir->d_inode, new_dentry,  +                                     new_dir->d_inode, new_dentry, newnd.mnt);
 +                                           newnd.mnt);  
695  +       if (error)  +       if (error)
696  +               goto exit5;  +               goto exit5;
697    
# Line 742  Source code for this patch is http://www Line 704  Source code for this patch is http://www
704          dput(new_dentry);          dput(new_dentry);
705   exit4:   exit4:
706          dput(old_dentry);          dput(old_dentry);
707  --- linux-2.4.37.5.orig/fs/namespace.c  --- linux-2.4.37.9.orig/fs/namespace.c
708  +++ linux-2.4.37.5/fs/namespace.c  +++ linux-2.4.37.9/fs/namespace.c
709  @@ -21,6 +21,8 @@  @@ -21,6 +21,8 @@
710   #include <linux/seq_file.h>   #include <linux/seq_file.h>
711   #include <linux/namespace.h>   #include <linux/namespace.h>
# Line 753  Source code for this patch is http://www Line 715  Source code for this patch is http://www
715   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);
716   int do_remount_sb(struct super_block *sb, int flags, void * data);   int do_remount_sb(struct super_block *sb, int flags, void * data);
717   void kill_super(struct super_block *sb);   void kill_super(struct super_block *sb);
718  @@ -290,6 +292,8 @@ static int do_umount(struct vfsmount *mn  @@ -290,6 +292,9 @@ static int do_umount(struct vfsmount *mn
719   {   {
720          struct super_block * sb = mnt->mnt_sb;          struct super_block * sb = mnt->mnt_sb;
721          int retval = 0;          int retval = 0;
722  +       if (ccs_may_umount(mnt))  +       retval = ccs_umount_permission(mnt, flags);
723  +               return -EPERM;  +       if (retval)
724    +               return retval;
725    
726          /*          /*
727           * If we may have to abort operations to get out of this           * If we may have to abort operations to get out of this
728  @@ -365,6 +369,8 @@ asmlinkage long sys_umount(char * name,  @@ -700,6 +705,7 @@ static int copy_mount_options (const voi
729     long do_mount(char * dev_name, char * dir_name, char *type_page,
730                      unsigned long flags, void *data_page)
731   {   {
732    +       const unsigned long original_flags = flags;
733          struct nameidata nd;          struct nameidata nd;
734          int retval;          int retval = 0;
735  +       if (!ccs_capable(CCS_SYS_UMOUNT))          int mnt_flags = 0;
736  +               return -EPERM;  @@ -732,6 +738,11 @@ long do_mount(char * dev_name, char * di
   
         retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd);  
737          if (retval)          if (retval)
738  @@ -500,6 +506,9 @@ static int do_loopback(struct nameidata                  return retval;
         down_write(&current->namespace->sem);  
         err = -EINVAL;  
         if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {  
 +               err = -EPERM;  
 +               if (ccs_may_mount(nd))  
 +                       goto out;  
                 err = -ENOMEM;  
                 if (recurse)  
                         mnt = copy_tree(old_nd.mnt, old_nd.dentry);  
 @@ -516,7 +525,7 @@ static int do_loopback(struct nameidata  
                 } else  
                         mntput(mnt);  
         }  
 -  
 + out:  
         up_write(&current->namespace->sem);  
         path_release(&old_nd);  
         return err;  
 @@ -570,6 +579,10 @@ static int do_move_mount(struct nameidat  
         if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))  
                 goto out;  
   
 +       err = -EPERM;  
 +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))  
 +               goto out;  
 +  
         err = -ENOENT;  
         down(&nd->dentry->d_inode->i_zombie);  
         if (IS_DEADDIR(nd->dentry->d_inode))  
 @@ -641,6 +654,10 @@ static int do_add_mount(struct nameidata  
         if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry)  
                 goto unlock;  
   
 +       err = -EPERM;  
 +       if (ccs_may_mount(nd))  
 +               goto unlock;  
 +  
         mnt->mnt_flags = mnt_flags;  
         err = graft_tree(mnt, nd);  
  unlock:  
 @@ -718,6 +735,11 @@ long do_mount(char * dev_name, char * di  
         if (data_page)  
                 ((char *)data_page)[PAGE_SIZE - 1] = 0;  
739    
740  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,  +       retval = ccs_mount_permission(dev_name, &nd, type_page, original_flags,
741  +                                           &flags);  +                                     data_page);
742  +       if (retval)  +       if (retval)
743  +               return retval;  +               goto out;
744  +  +
745          /* Separate the per-mountpoint flags */          if (flags & MS_REMOUNT)
746          if (flags & MS_NOSUID)                  retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
747                  mnt_flags |= MNT_NOSUID;                                      data_page);
748  @@ -911,6 +933,8 @@ asmlinkage long sys_pivot_root(const cha  @@ -742,6 +753,7 @@ long do_mount(char * dev_name, char * di
749            else
750          if (!capable(CAP_SYS_ADMIN))                  retval = do_add_mount(&nd, type_page, flags, mnt_flags,
751                  return -EPERM;                                        dev_name, data_page);
752  +       if (!ccs_capable(CCS_SYS_PIVOT_ROOT))  + out:
753  +               return -EPERM;          path_release(&nd);
754            return retval;
755          lock_kernel();   }
756    @@ -925,6 +937,11 @@ asmlinkage long sys_pivot_root(const cha
 @@ -925,6 +949,11 @@ asmlinkage long sys_pivot_root(const cha  
757          if (error)          if (error)
758                  goto out1;                  goto out1;
759    
760  +       error = ccs_check_pivot_root_permission(&old_nd, &new_nd);  +       error = ccs_pivot_root_permission(&old_nd, &new_nd);
761  +       if (error) {  +       if (error) {
762  +               path_release(&old_nd);  +               path_release(&old_nd);
763  +               goto out1;  +               goto out1;
# Line 845  Source code for this patch is http://www Line 765  Source code for this patch is http://www
765          read_lock(&current->fs->lock);          read_lock(&current->fs->lock);
766          user_nd.mnt = mntget(current->fs->rootmnt);          user_nd.mnt = mntget(current->fs->rootmnt);
767          user_nd.dentry = dget(current->fs->root);          user_nd.dentry = dget(current->fs->root);
768  --- linux-2.4.37.5.orig/fs/open.c  --- linux-2.4.37.9.orig/fs/open.c
769  +++ linux-2.4.37.5/fs/open.c  +++ linux-2.4.37.9/fs/open.c
770  @@ -20,6 +20,8 @@  @@ -20,6 +20,8 @@
771    
772   #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))
# Line 860  Source code for this patch is http://www Line 780  Source code for this patch is http://www
780          if (error)          if (error)
781                  goto dput_and_out;                  goto dput_and_out;
782    
783  +       error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);  +       error = ccs_truncate_permission(nd.dentry, nd.mnt);
784  +       if (!error)  +       if (!error)
785  +  +
786          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
787          if (!error) {          if (!error) {
788                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
789  @@ -217,6 +222,10 @@ static inline long do_sys_ftruncate(unsi  @@ -217,6 +222,9 @@ static inline long do_sys_ftruncate(unsi
790          if (IS_APPEND(inode))          if (IS_APPEND(inode))
791                  goto out_putf;                  goto out_putf;
792    
793  +       error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,  +       error = ccs_truncate_permission(dentry, file->f_vfsmnt);
 +                                             0);  
794  +       if (error)  +       if (error)
795  +               goto out_putf;  +               goto out_putf;
796          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
797          if (!error)          if (!error)
798                  error = do_truncate(dentry, length);                  error = do_truncate(dentry, length);
799  @@ -466,6 +475,10 @@ asmlinkage long sys_chroot(const char *  @@ -466,6 +474,8 @@ asmlinkage long sys_chroot(const char *
800          error = -EPERM;          error = -EPERM;
801          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
802                  goto dput_and_out;                  goto dput_and_out;
803  +       if (!ccs_capable(CCS_SYS_CHROOT))  +       if (ccs_chroot_permission(&nd))
 +               goto dput_and_out;  
 +       if (ccs_check_chroot_permission(&nd))  
804  +               goto dput_and_out;  +               goto dput_and_out;
805    
806          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
807          set_fs_altroot();          set_fs_altroot();
808  @@ -497,6 +510,9 @@ asmlinkage long sys_fchmod(unsigned int  @@ -497,6 +507,9 @@ asmlinkage long sys_fchmod(unsigned int
809          err = -EPERM;          err = -EPERM;
810          if (IS_IMMUTABLE(inode) || IS_APPEND(inode))          if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
811                  goto out_putf;                  goto out_putf;
# Line 898  Source code for this patch is http://www Line 815  Source code for this patch is http://www
815          if (mode == (mode_t) -1)          if (mode == (mode_t) -1)
816                  mode = inode->i_mode;                  mode = inode->i_mode;
817          newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);          newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
818  @@ -528,6 +544,9 @@ asmlinkage long sys_chmod(const char * f  @@ -528,6 +541,9 @@ asmlinkage long sys_chmod(const char * f
819          error = -EPERM;          error = -EPERM;
820          if (IS_IMMUTABLE(inode) || IS_APPEND(inode))          if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
821                  goto dput_and_out;                  goto dput_and_out;
# Line 908  Source code for this patch is http://www Line 825  Source code for this patch is http://www
825    
826          if (mode == (mode_t) -1)          if (mode == (mode_t) -1)
827                  mode = inode->i_mode;                  mode = inode->i_mode;
828  @@ -608,6 +627,8 @@ asmlinkage long sys_chown(const char * f  @@ -608,6 +624,8 @@ asmlinkage long sys_chown(const char * f
829    
830          error = user_path_walk(filename, &nd);          error = user_path_walk(filename, &nd);
831          if (!error) {          if (!error) {
# Line 917  Source code for this patch is http://www Line 834  Source code for this patch is http://www
834                  error = chown_common(nd.dentry, user, group);                  error = chown_common(nd.dentry, user, group);
835                  path_release(&nd);                  path_release(&nd);
836          }          }
837  @@ -621,6 +642,8 @@ asmlinkage long sys_lchown(const char *  @@ -621,6 +639,8 @@ asmlinkage long sys_lchown(const char *
838    
839          error = user_path_walk_link(filename, &nd);          error = user_path_walk_link(filename, &nd);
840          if (!error) {          if (!error) {
# Line 926  Source code for this patch is http://www Line 843  Source code for this patch is http://www
843                  error = chown_common(nd.dentry, user, group);                  error = chown_common(nd.dentry, user, group);
844                  path_release(&nd);                  path_release(&nd);
845          }          }
846  @@ -635,6 +658,9 @@ asmlinkage long sys_fchown(unsigned int  @@ -635,6 +655,9 @@ asmlinkage long sys_fchown(unsigned int
847    
848          file = fget(fd);          file = fget(fd);
849          if (file) {          if (file) {
# Line 936  Source code for this patch is http://www Line 853  Source code for this patch is http://www
853                  error = chown_common(file->f_dentry, user, group);                  error = chown_common(file->f_dentry, user, group);
854                  fput(file);                  fput(file);
855          }          }
856  @@ -897,6 +923,8 @@ out_unlock:  @@ -666,7 +689,9 @@ struct file *filp_open(const char * file
857            if (namei_flags & O_TRUNC)
858                    namei_flags |= 2;
859    
860    +       ccs_save_open_mode(flags);
861            error = open_namei(filename, namei_flags, mode, &nd);
862    +       ccs_clear_open_mode();
863            if (!error)
864                    return dentry_open(nd.dentry, nd.mnt, flags);
865    
866    @@ -897,6 +922,8 @@ out_unlock:
867    */    */
868   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
869   {   {
# Line 945  Source code for this patch is http://www Line 872  Source code for this patch is http://www
872          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
873                  tty_vhangup(current->tty);                  tty_vhangup(current->tty);
874                  return 0;                  return 0;
875  --- linux-2.4.37.5.orig/fs/proc/proc_misc.c  --- linux-2.4.37.9.orig/fs/proc/proc_misc.c
876  +++ linux-2.4.37.5/fs/proc/proc_misc.c  +++ linux-2.4.37.9/fs/proc/proc_misc.c
877  @@ -670,4 +670,5 @@ void __init proc_misc_init(void)  @@ -670,4 +670,5 @@ void __init proc_misc_init(void)
878                          entry->proc_fops = &ppc_htab_operations;                          entry->proc_fops = &ppc_htab_operations;
879          }          }
880   #endif   #endif
881  +       printk(KERN_INFO "Hook version: 2.4.37.5 2009/08/14\n");  +       printk(KERN_INFO "Hook version: 2.4.37.9 2010/07/26\n");
882   }   }
883  --- linux-2.4.37.5.orig/include/linux/sched.h  --- linux-2.4.37.9.orig/include/linux/sched.h
884  +++ linux-2.4.37.5/include/linux/sched.h  +++ linux-2.4.37.9/include/linux/sched.h
885  @@ -29,6 +29,8 @@ extern unsigned long event;  @@ -123,6 +123,15 @@ struct completion;
886    
887   struct exec_domain;   #ifdef __KERNEL__
888    
889    +#ifdef CONFIG_CCSECURITY
890  +struct ccs_domain_info;  +struct ccs_domain_info;
891    +#define INIT_CCSECURITY          \
892    +       .ccs_domain_info = NULL, \
893    +       .ccs_flags = 0,
894    +#else
895    +#define INIT_CCSECURITY
896    +#endif
897  +  +
898     #include <linux/spinlock.h>
899    
900   /*   /*
901    * cloning flags:  @@ -417,6 +426,10 @@ struct task_struct {
   */  
 @@ -417,6 +419,8 @@ struct task_struct {  
902          void *journal_info;          void *journal_info;
903    
904          struct list_head *scm_work_list;          struct list_head *scm_work_list;
905    +#ifdef CONFIG_CCSECURITY
906  +       struct ccs_domain_info *ccs_domain_info;  +       struct ccs_domain_info *ccs_domain_info;
907  +       u32 ccs_flags;  +       u32 ccs_flags;
908    +#endif
909   };   };
910    
911   /*   /*
912  @@ -512,6 +516,8 @@ extern struct exec_domain   default_exec_d  @@ -512,6 +525,7 @@ extern struct exec_domain   default_exec_d
913       blocked:           {{0}},                                          \       blocked:           {{0}},                                          \
914       alloc_lock:                SPIN_LOCK_UNLOCKED,                             \       alloc_lock:                SPIN_LOCK_UNLOCKED,                             \
915       journal_info:      NULL,                                           \       journal_info:      NULL,                                           \
916  +       ccs_domain_info: NULL,            \  +       INIT_CCSECURITY                                                 \
 +       ccs_flags: 0                      \  
917   }   }
918    
919    
920  --- linux-2.4.37.5.orig/kernel/kmod.c  --- linux-2.4.37.9.orig/kernel/kmod.c
921  +++ linux-2.4.37.5/kernel/kmod.c  +++ linux-2.4.37.9/kernel/kmod.c
922  @@ -134,6 +134,9 @@ int exec_usermodehelper(char *program_pa  @@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa
923          /* Allow execve args to be in kernel space. */          /* Allow execve args to be in kernel space. */
924          set_fs(KERNEL_DS);          set_fs(KERNEL_DS);
925    
926    +#ifdef CONFIG_CCSECURITY
927  +       current->ccs_domain_info = NULL;  +       current->ccs_domain_info = NULL;
928  +       current->ccs_flags = 0;  +       current->ccs_flags = 0;
929    +#endif
930  +  +
931          /* Go, go, go... */          /* Go, go, go... */
932          if (execve(program_path, argv, envp) < 0)          if (execve(program_path, argv, envp) < 0)
933                  return -errno;                  return -errno;
934  --- linux-2.4.37.5.orig/kernel/module.c  --- linux-2.4.37.9.orig/kernel/module.c
935  +++ linux-2.4.37.5/kernel/module.c  +++ linux-2.4.37.9/kernel/module.c
936  @@ -10,6 +10,7 @@  @@ -10,6 +10,7 @@
937   #include <linux/slab.h>   #include <linux/slab.h>
938   #include <linux/kmod.h>   #include <linux/kmod.h>
# Line 1031  Source code for this patch is http://www Line 968  Source code for this patch is http://www
968    
969          lock_kernel();          lock_kernel();
970          if (name_user) {          if (name_user) {
971  --- linux-2.4.37.5.orig/kernel/sched.c  --- linux-2.4.37.9.orig/kernel/sched.c
972  +++ linux-2.4.37.5/kernel/sched.c  +++ linux-2.4.37.9/kernel/sched.c
973  @@ -32,6 +32,7 @@  @@ -32,6 +32,7 @@
974    
975   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 1050  Source code for this patch is http://www Line 987  Source code for this patch is http://www
987    
988          /*          /*
989           *      Setpriority might change our priority at the same moment.           *      Setpriority might change our priority at the same moment.
990  --- linux-2.4.37.5.orig/kernel/signal.c  --- linux-2.4.37.9.orig/kernel/signal.c
991  +++ linux-2.4.37.5/kernel/signal.c  +++ linux-2.4.37.9/kernel/signal.c
992  @@ -15,6 +15,7 @@  @@ -15,6 +15,7 @@
993   #include <linux/sched.h>   #include <linux/sched.h>
994    
# Line 1087  Source code for this patch is http://www Line 1024  Source code for this patch is http://www
1024    
1025          /* POSIX.1b doesn't mention process groups.  */          /* POSIX.1b doesn't mention process groups.  */
1026          return kill_proc_info(sig, &info, pid);          return kill_proc_info(sig, &info, pid);
1027  --- linux-2.4.37.5.orig/kernel/sys.c  --- linux-2.4.37.9.orig/kernel/sys.c
1028  +++ linux-2.4.37.5/kernel/sys.c  +++ linux-2.4.37.9/kernel/sys.c
1029  @@ -17,6 +17,7 @@  @@ -17,6 +17,7 @@
1030    
1031   #include <asm/uaccess.h>   #include <asm/uaccess.h>
# Line 1133  Source code for this patch is http://www Line 1070  Source code for this patch is http://www
1070    
1071          down_write(&uts_sem);          down_write(&uts_sem);
1072          errno = -EFAULT;          errno = -EFAULT;
1073  --- linux-2.4.37.5.orig/kernel/sysctl.c  --- linux-2.4.37.9.orig/kernel/sysctl.c
1074  +++ linux-2.4.37.5/kernel/sysctl.c  +++ linux-2.4.37.9/kernel/sysctl.c
1075  @@ -33,6 +33,7 @@  @@ -33,6 +33,7 @@
1076   #include <linux/swap.h>   #include <linux/swap.h>
1077    
# Line 1176  Source code for this patch is http://www Line 1113  Source code for this patch is http://www
1113   }   }
1114    
1115   /*   /*
1116  --- linux-2.4.37.5.orig/kernel/time.c  --- linux-2.4.37.9.orig/kernel/time.c
1117  +++ linux-2.4.37.5/kernel/time.c  +++ linux-2.4.37.9/kernel/time.c
1118  @@ -29,6 +29,7 @@  @@ -29,6 +29,7 @@
1119   #include <linux/smp_lock.h>   #include <linux/smp_lock.h>
1120    
# Line 1213  Source code for this patch is http://www Line 1150  Source code for this patch is http://www
1150                                    
1151          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
1152    
1153  --- linux-2.4.37.5.orig/net/ipv4/raw.c  --- linux-2.4.37.9.orig/net/ipv4/raw.c
1154  +++ linux-2.4.37.5/net/ipv4/raw.c  +++ linux-2.4.37.9/net/ipv4/raw.c
1155  @@ -64,6 +64,7 @@  @@ -64,6 +64,7 @@
1156   #include <net/raw.h>   #include <net/raw.h>
1157   #include <net/inet_common.h>   #include <net/inet_common.h>
# Line 1223  Source code for this patch is http://www Line 1160  Source code for this patch is http://www
1160    
1161   struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE];   struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE];
1162   rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED;   rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED;
1163  @@ -503,6 +504,9 @@ int raw_recvmsg(struct sock *sk, struct  @@ -500,9 +501,14 @@ int raw_recvmsg(struct sock *sk, struct
         skb = skb_recv_datagram(sk, flags, noblock, &err);  
         if (!skb)  
1164                  goto out;                  goto out;
1165  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);          }
1166  +       if (err)  
1167  +               goto out;  -       skb = skb_recv_datagram(sk, flags, noblock, &err);
1168    -       if (!skb)
1169    -               goto out;
1170    +       for (;;) {
1171    +               skb = skb_recv_datagram(sk, flags, noblock, &err);
1172    +               if (!skb)
1173    +                       goto out;
1174    +               if (!ccs_socket_post_recvmsg_permission(sk, skb))
1175    +                       break;
1176    +               skb_kill_datagram(sk, skb, flags);
1177    +       }
1178    
1179          copied = skb->len;          copied = skb->len;
1180          if (len < copied) {          if (len < copied) {
1181  --- linux-2.4.37.5.orig/net/ipv4/tcp_ipv4.c  --- linux-2.4.37.9.orig/net/ipv4/tcp_ipv4.c
1182  +++ linux-2.4.37.5/net/ipv4/tcp_ipv4.c  +++ linux-2.4.37.9/net/ipv4/tcp_ipv4.c
1183  @@ -67,6 +67,7 @@  @@ -67,6 +67,7 @@
1184   #include <linux/inet.h>   #include <linux/inet.h>
1185   #include <linux/stddef.h>   #include <linux/stddef.h>
# Line 1261  Source code for this patch is http://www Line 1206  Source code for this patch is http://www
1206    
1207                          /* Does not bother with rcv_saddr checks,                          /* Does not bother with rcv_saddr checks,
1208                           * because the established check is already                           * because the established check is already
1209  --- linux-2.4.37.5.orig/net/ipv4/udp.c  --- linux-2.4.37.9.orig/net/ipv4/udp.c
1210  +++ linux-2.4.37.5/net/ipv4/udp.c  +++ linux-2.4.37.9/net/ipv4/udp.c
1211  @@ -97,6 +97,7 @@  @@ -97,6 +97,7 @@
1212   #include <net/route.h>   #include <net/route.h>
1213   #include <net/inet_common.h>   #include <net/inet_common.h>
# Line 1289  Source code for this patch is http://www Line 1234  Source code for this patch is http://www
1234                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1235                                  break;                                  break;
1236                  }                  }
1237  @@ -711,6 +716,9 @@ try_again:  @@ -697,6 +702,7 @@ int udp_recvmsg(struct sock *sk, struct
1238            struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
1239            struct sk_buff *skb;
1240            int copied, err;
1241    +       _Bool update_stat;
1242    
1243            /*
1244             *      Check any passed addresses
1245    @@ -711,6 +717,11 @@ try_again:
1246          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1247          if (!skb)          if (!skb)
1248                  goto out;                  goto out;
1249  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);  +       if (ccs_socket_post_recvmsg_permission(sk, skb)) {
1250  +       if (err)  +               update_stat = 0;
1251  +               goto out;  +               goto csum_copy_err;
1252    +       }
1253    +       update_stat = 1;
1254        
1255          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1256          if (copied > len) {          if (copied > len) {
1257  --- linux-2.4.37.5.orig/net/ipv6/raw.c  @@ -759,7 +770,8 @@ out:
1258  +++ linux-2.4.37.5/net/ipv6/raw.c          return err;
1259    
1260     csum_copy_err:
1261    -       UDP_INC_STATS_BH(UdpInErrors);
1262    +       if (update_stat)
1263    +               UDP_INC_STATS_BH(UdpInErrors);
1264    
1265            /* Clear queue. */
1266            if (flags&MSG_PEEK) {
1267    --- linux-2.4.37.9.orig/net/ipv6/raw.c
1268    +++ linux-2.4.37.9/net/ipv6/raw.c
1269  @@ -45,6 +45,7 @@  @@ -45,6 +45,7 @@
1270   #include <net/inet_common.h>   #include <net/inet_common.h>
1271    
# Line 1309  Source code for this patch is http://www Line 1274  Source code for this patch is http://www
1274    
1275   struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE];   struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE];
1276   rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED;   rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED;
1277  @@ -369,6 +370,9 @@ int rawv6_recvmsg(struct sock *sk, struc  @@ -366,9 +367,14 @@ int rawv6_recvmsg(struct sock *sk, struc
1278          skb = skb_recv_datagram(sk, flags, noblock, &err);          if (flags & MSG_ERRQUEUE)
1279          if (!skb)                  return ipv6_recv_error(sk, msg, len);
1280                  goto out;  
1281  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);  -       skb = skb_recv_datagram(sk, flags, noblock, &err);
1282  +       if (err)  -       if (!skb)
1283  +               goto out;  -               goto out;
1284    +       for (;;) {
1285    +               skb = skb_recv_datagram(sk, flags, noblock, &err);
1286    +               if (!skb)
1287    +                       goto out;
1288    +               if (!ccs_socket_post_recvmsg_permission(sk, skb))
1289    +                       break;
1290    +               skb_kill_datagram(sk, skb, flags);
1291    +       }
1292    
1293          copied = skb->len;          copied = skb->len;
1294          if (copied > len) {          if (copied > len) {
1295  --- linux-2.4.37.5.orig/net/ipv6/tcp_ipv6.c  --- linux-2.4.37.9.orig/net/ipv6/tcp_ipv6.c
1296  +++ linux-2.4.37.5/net/ipv6/tcp_ipv6.c  +++ linux-2.4.37.9/net/ipv6/tcp_ipv6.c
1297  @@ -52,6 +52,7 @@  @@ -52,6 +52,7 @@
1298   #include <net/inet_ecn.h>   #include <net/inet_ecn.h>
1299    
# Line 1338  Source code for this patch is http://www Line 1311  Source code for this patch is http://www
1311                          for (tb = head->chain; tb; tb = tb->next)                          for (tb = head->chain; tb; tb = tb->next)
1312                                  if (tb->port == rover)                                  if (tb->port == rover)
1313                                          goto next;                                          goto next;
1314  --- linux-2.4.37.5.orig/net/ipv6/udp.c  --- linux-2.4.37.9.orig/net/ipv6/udp.c
1315  +++ linux-2.4.37.5/net/ipv6/udp.c  +++ linux-2.4.37.9/net/ipv6/udp.c
1316  @@ -50,6 +50,7 @@  @@ -50,6 +50,7 @@
1317   #include <net/inet_common.h>   #include <net/inet_common.h>
1318    
# Line 1366  Source code for this patch is http://www Line 1339  Source code for this patch is http://www
1339                          if (!udp_lport_inuse(result))                          if (!udp_lport_inuse(result))
1340                                  break;                                  break;
1341                  }                  }
1342  @@ -406,6 +411,9 @@ try_again:  @@ -395,6 +400,7 @@ int udpv6_recvmsg(struct sock *sk, struc
1343     {
1344            struct sk_buff *skb;
1345            int copied, err;
1346    +       _Bool update_stat;
1347    
1348            if (addr_len)
1349                    *addr_len=sizeof(struct sockaddr_in6);
1350    @@ -406,6 +412,11 @@ try_again:
1351          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1352          if (!skb)          if (!skb)
1353                  goto out;                  goto out;
1354  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);  +       if (ccs_socket_post_recvmsg_permission(sk, skb)) {
1355  +       if (err)  +               update_stat = 0;
1356  +               goto out;  +               goto csum_copy_err;
1357    +       }
1358    +       update_stat = 1;
1359    
1360          copied = skb->len - sizeof(struct udphdr);          copied = skb->len - sizeof(struct udphdr);
1361          if (copied > len) {          if (copied > len) {
1362  --- linux-2.4.37.5.orig/net/socket.c  @@ -485,7 +496,8 @@ csum_copy_err:
1363  +++ linux-2.4.37.5/net/socket.c          skb_free_datagram(sk, skb);
1364    
1365            if (flags & MSG_DONTWAIT) {
1366    -               UDP6_INC_STATS_USER(UdpInErrors);
1367    +               if (update_stat)
1368    +                       UDP6_INC_STATS_USER(UdpInErrors);
1369                    return -EAGAIN;
1370            }
1371            goto try_again;
1372    --- linux-2.4.37.9.orig/net/socket.c
1373    +++ linux-2.4.37.9/net/socket.c
1374  @@ -84,6 +84,7 @@  @@ -84,6 +84,7 @@
1375   #include <net/sock.h>   #include <net/sock.h>
1376   #include <net/scm.h>   #include <net/scm.h>
# Line 1386  Source code for this patch is http://www Line 1379  Source code for this patch is http://www
1379    
1380   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1381   static ssize_t sock_read(struct file *file, char *buf,   static ssize_t sock_read(struct file *file, char *buf,
1382  @@ -501,7 +502,10 @@ int sock_sendmsg(struct socket *sock, st  @@ -501,7 +502,8 @@ int sock_sendmsg(struct socket *sock, st
1383   {   {
1384          int err;          int err;
1385          struct scm_cookie scm;          struct scm_cookie scm;
1386  -  -
1387  +       err = ccs_socket_sendmsg_permission(sock,  +       err = ccs_socket_sendmsg_permission(sock, msg, size);
 +                                           (struct sockaddr *) msg->msg_name,  
 +                                           msg->msg_namelen);  
1388  +       if (!err)  +       if (!err)
1389          err = scm_send(sock, msg, &scm);          err = scm_send(sock, msg, &scm);
1390          if (err >= 0) {          if (err >= 0) {
1391                  err = sock->ops->sendmsg(sock, msg, size, &scm);                  err = sock->ops->sendmsg(sock, msg, size, &scm);
1392  @@ -850,7 +854,9 @@ int sock_create(int family, int type, in  @@ -850,7 +852,9 @@ int sock_create(int family, int type, in
1393                  }                  }
1394                  family = PF_PACKET;                  family = PF_PACKET;
1395          }          }
# Line 1409  Source code for this patch is http://www Line 1400  Source code for this patch is http://www
1400   #if defined(CONFIG_KMOD) && defined(CONFIG_NET)   #if defined(CONFIG_KMOD) && defined(CONFIG_NET)
1401          /* Attempt to load a protocol module if the find failed.          /* Attempt to load a protocol module if the find failed.
1402           *           *
1403  @@ -1006,6 +1012,10 @@ asmlinkage long sys_bind(int fd, struct  @@ -1006,6 +1010,10 @@ asmlinkage long sys_bind(int fd, struct
1404          if((sock = sockfd_lookup(fd,&err))!=NULL)          if((sock = sockfd_lookup(fd,&err))!=NULL)
1405          {          {
1406                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)                  if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)
# Line 1420  Source code for this patch is http://www Line 1411  Source code for this patch is http://www
1411                          err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);                          err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1412                  sockfd_put(sock);                  sockfd_put(sock);
1413          }                                }                      
1414  @@ -1029,6 +1039,8 @@ asmlinkage long sys_listen(int fd, int b  @@ -1029,6 +1037,8 @@ asmlinkage long sys_listen(int fd, int b
1415          if ((sock = sockfd_lookup(fd, &err)) != NULL) {          if ((sock = sockfd_lookup(fd, &err)) != NULL) {
1416                  if ((unsigned) backlog > sysctl_somaxconn)                  if ((unsigned) backlog > sysctl_somaxconn)
1417                          backlog = sysctl_somaxconn;                          backlog = sysctl_somaxconn;
# Line 1429  Source code for this patch is http://www Line 1420  Source code for this patch is http://www
1420                  err=sock->ops->listen(sock, backlog);                  err=sock->ops->listen(sock, backlog);
1421                  sockfd_put(sock);                  sockfd_put(sock);
1422          }          }
1423  @@ -1069,6 +1081,11 @@ asmlinkage long sys_accept(int fd, struc  @@ -1058,6 +1068,7 @@ asmlinkage long sys_accept(int fd, struc
1424            if (!sock)
1425                    goto out;
1426    
1427    +retry:
1428            err = -ENFILE;
1429            if (!(newsock = sock_alloc()))
1430                    goto out_put;
1431    @@ -1069,6 +1080,10 @@ asmlinkage long sys_accept(int fd, struc
1432          if (err < 0)          if (err < 0)
1433                  goto out_release;                  goto out_release;
1434    
1435  +       if (ccs_socket_accept_permission(newsock,  +       if (ccs_socket_post_accept_permission(sock, newsock)) {
1436  +                                        (struct sockaddr *) address)) {  +               sock_release(newsock);
1437  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */  +               goto retry;
 +               goto out_release;  
1438  +       }  +       }
1439          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1440                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {                  if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1441                          err = -ECONNABORTED;                          err = -ECONNABORTED;
1442  @@ -1119,6 +1136,10 @@ asmlinkage long sys_connect(int fd, stru  @@ -1119,6 +1134,10 @@ asmlinkage long sys_connect(int fd, stru
1443          err = move_addr_to_kernel(uservaddr, addrlen, address);          err = move_addr_to_kernel(uservaddr, addrlen, address);
1444          if (err < 0)          if (err < 0)
1445                  goto out_put;                  goto out_put;
# Line 1452  Source code for this patch is http://www Line 1450  Source code for this patch is http://www
1450          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1451                                   sock->file->f_flags);                                   sock->file->f_flags);
1452   out_put:   out_put:
1453  --- linux-2.4.37.5.orig/net/unix/af_unix.c  --- linux-2.4.37.9.orig/net/unix/af_unix.c
1454  +++ linux-2.4.37.5/net/unix/af_unix.c  +++ linux-2.4.37.9/net/unix/af_unix.c
1455  @@ -111,6 +111,7 @@  @@ -111,6 +111,7 @@
1456   #include <linux/rtnetlink.h>   #include <linux/rtnetlink.h>
1457    
# Line 1466  Source code for this patch is http://www Line 1464  Source code for this patch is http://www
1464                   * All right, let's create it.                   * All right, let's create it.
1465                   */                   */
1466                  mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);                  mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);
1467  +               err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,  +               err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1468  +                                                nd.mnt, mode, 0);  +                                          mode, 0);
1469  +               if (!err)  +               if (!err)
1470                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1471                  if (err)                  if (err)

Legend:
Removed from v.2921  
changed lines
  Added in v.3856

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