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

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

Legend:
Removed from v.2300  
changed lines
  Added in v.2822

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