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

Subversion リポジトリの参照

Diff of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.25-suse-11.0.diff

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

revision 2794 by kumaneko, Thu Jul 23 05:17:11 2009 UTC revision 2796 by kumaneko, Thu Jul 23 09:07:39 2009 UTC
# Line 2  This is TOMOYO Linux patch for openSUSE Line 2  This is TOMOYO Linux patch for openSUSE
2    
3  Source code for this patch is http://download.opensuse.org/update/11.0/rpm/i586/kernel-source-2.6.25.20-0.4.i586.rpm  Source code for this patch is http://download.opensuse.org/update/11.0/rpm/i586/kernel-source-2.6.25.20-0.4.i586.rpm
4  ---  ---
5   arch/ia64/ia32/sys_ia32.c       |    7 ++++   arch/ia64/ia32/sys_ia32.c       |    3 +++
6   arch/mips/kernel/ptrace32.c     |    7 ++++   arch/mips/kernel/ptrace32.c     |    3 +++
7   arch/s390/kernel/ptrace.c       |    7 ++++   arch/s390/kernel/ptrace.c       |    3 +++
8   arch/x86/kernel/ptrace.c        |    7 ++++   arch/x86/kernel/ptrace.c        |    3 +++
9   fs/Kconfig                      |    2 +   fs/Kconfig                      |    2 ++
10   fs/Makefile                     |    2 +   fs/Makefile                     |    2 ++
11   fs/attr.c                       |   11 +++++++   fs/attr.c                       |    5 +++++
12   fs/compat.c                     |    5 ++-   fs/compat.c                     |    3 ++-
13   fs/compat_ioctl.c               |   13 +++++++++   fs/compat_ioctl.c               |    7 +++++++
14   fs/exec.c                       |   18 +++++++++++-   fs/exec.c                       |   12 +++++++++++-
15   fs/fcntl.c                      |    9 ++++++   fs/fcntl.c                      |    5 +++++
16   fs/ioctl.c                      |   11 +++++++   fs/ioctl.c                      |    5 +++++
17   fs/namei.c                      |   57 ++++++++++++++++++++++++++++++++++++++++   fs/namei.c                      |   35 +++++++++++++++++++++++++++++++++++
18   fs/namespace.c                  |   49 ++++++++++++++++++++++++++++++++++   fs/namespace.c                  |   27 +++++++++++++++++++++++++++
19   fs/open.c                       |   30 +++++++++++++++++++++   fs/open.c                       |   16 ++++++++++++++++
20   fs/proc/Makefile                |    3 ++   fs/proc/Makefile                |    3 +++
21   fs/proc/proc_misc.c             |    5 +++   fs/proc/proc_misc.c             |    1 +
22   include/linux/init_task.h       |    4 ++   include/linux/init_task.h       |    2 ++
23   include/linux/sched.h           |    8 +++++   include/linux/sched.h           |    4 ++++
24   kernel/compat.c                 |    7 ++++   kernel/compat.c                 |    3 +++
25   kernel/kexec.c                  |    7 ++++   kernel/kexec.c                  |    3 +++
26   kernel/kmod.c                   |    5 +++   kernel/kmod.c                   |    3 +++
27   kernel/module.c                 |   11 +++++++   kernel/module.c                 |    5 +++++
28   kernel/ptrace.c                 |   11 +++++++   kernel/ptrace.c                 |    5 +++++
29   kernel/sched.c                  |    7 ++++   kernel/sched.c                  |    3 +++
30   kernel/signal.c                 |   21 ++++++++++++++   kernel/signal.c                 |   13 +++++++++++++
31   kernel/sys.c                    |   21 ++++++++++++++   kernel/sys.c                    |   11 +++++++++++
32   kernel/sysctl.c                 |    9 ++++++   kernel/sysctl.c                 |    5 +++++
33   kernel/time.c                   |   11 +++++++   kernel/time.c                   |    5 +++++
34   kernel/time/ntp.c               |    7 ++++   kernel/time/ntp.c               |    3 +++
35   net/ipv4/inet_connection_sock.c |    7 ++++   net/ipv4/inet_connection_sock.c |    3 +++
36   net/ipv4/inet_hashtables.c      |    7 ++++   net/ipv4/inet_hashtables.c      |    3 +++
37   net/ipv4/raw.c                  |    8 +++++   net/ipv4/raw.c                  |    4 ++++
38   net/ipv4/udp.c                  |   18 ++++++++++++   net/ipv4/udp.c                  |    8 ++++++++
39   net/ipv6/raw.c                  |    8 +++++   net/ipv6/raw.c                  |    4 ++++
40   net/ipv6/udp.c                  |    8 +++++   net/ipv6/udp.c                  |    4 ++++
41   net/socket.c                    |   41 ++++++++++++++++++++++++++++   net/socket.c                    |   27 +++++++++++++++++++++++++++
42   net/unix/af_unix.c              |    8 +++++   net/unix/af_unix.c              |    4 ++++
43   38 files changed, 475 insertions(+), 2 deletions(-)   38 files changed, 255 insertions(+), 2 deletions(-)
44    
45  --- linux-2.6.25.20-0.4.orig/arch/ia64/ia32/sys_ia32.c  --- linux-2.6.25.20-0.4.orig/arch/ia64/ia32/sys_ia32.c
46  +++ linux-2.6.25.20-0.4/arch/ia64/ia32/sys_ia32.c  +++ linux-2.6.25.20-0.4/arch/ia64/ia32/sys_ia32.c
47  @@ -50,6 +50,9 @@  @@ -50,6 +50,7 @@
48   #include <asm/types.h>   #include <asm/types.h>
49   #include <asm/uaccess.h>   #include <asm/uaccess.h>
50   #include <asm/unistd.h>   #include <asm/unistd.h>
 +/***** TOMOYO Linux start. *****/  
51  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
52    
53   #include "ia32priv.h"   #include "ia32priv.h"
54    
55  @@ -1753,6 +1756,10 @@ sys32_ptrace (int request, pid_t pid, un  @@ -1753,6 +1754,8 @@ sys32_ptrace (int request, pid_t pid, un
56          struct task_struct *child;          struct task_struct *child;
57          unsigned int value, tmp;          unsigned int value, tmp;
58          long i, ret;          long i, ret;
 +       /***** TOMOYO Linux start. *****/  
59  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (!ccs_capable(CCS_SYS_PTRACE))
60  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
61    
62          lock_kernel();          lock_kernel();
63          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
64  --- linux-2.6.25.20-0.4.orig/arch/mips/kernel/ptrace32.c  --- linux-2.6.25.20-0.4.orig/arch/mips/kernel/ptrace32.c
65  +++ linux-2.6.25.20-0.4/arch/mips/kernel/ptrace32.c  +++ linux-2.6.25.20-0.4/arch/mips/kernel/ptrace32.c
66  @@ -35,6 +35,9 @@  @@ -35,6 +35,7 @@
67   #include <asm/system.h>   #include <asm/system.h>
68   #include <asm/uaccess.h>   #include <asm/uaccess.h>
69   #include <asm/bootinfo.h>   #include <asm/bootinfo.h>
 +/***** TOMOYO Linux start. *****/  
70  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
71    
72   int ptrace_getregs(struct task_struct *child, __s64 __user *data);   int ptrace_getregs(struct task_struct *child, __s64 __user *data);
73   int ptrace_setregs(struct task_struct *child, __s64 __user *data);   int ptrace_setregs(struct task_struct *child, __s64 __user *data);
74  @@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request,  @@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request,
75   {   {
76          struct task_struct *child;          struct task_struct *child;
77          int ret;          int ret;
 +       /***** TOMOYO Linux start. *****/  
78  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (!ccs_capable(CCS_SYS_PTRACE))
79  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
80    
81   #if 0   #if 0
82          printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",          printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
83  --- linux-2.6.25.20-0.4.orig/arch/s390/kernel/ptrace.c  --- linux-2.6.25.20-0.4.orig/arch/s390/kernel/ptrace.c
84  +++ linux-2.6.25.20-0.4/arch/s390/kernel/ptrace.c  +++ linux-2.6.25.20-0.4/arch/s390/kernel/ptrace.c
85  @@ -41,6 +41,9 @@  @@ -41,6 +41,7 @@
86   #include <asm/system.h>   #include <asm/system.h>
87   #include <asm/uaccess.h>   #include <asm/uaccess.h>
88   #include <asm/unistd.h>   #include <asm/unistd.h>
 +/***** TOMOYO Linux start. *****/  
89  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
90    
91   #ifdef CONFIG_COMPAT   #ifdef CONFIG_COMPAT
92   #include "compat_ptrace.h"   #include "compat_ptrace.h"
93  @@ -698,6 +701,10 @@ sys_ptrace(long request, long pid, long  @@ -698,6 +699,8 @@ sys_ptrace(long request, long pid, long
94          struct task_struct *child;          struct task_struct *child;
95          int ret;          int ret;
96    
 +       /***** TOMOYO Linux start. *****/  
97  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (!ccs_capable(CCS_SYS_PTRACE))
98  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
99          lock_kernel();          lock_kernel();
100          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
101                   ret = ptrace_traceme();                   ret = ptrace_traceme();
102  --- linux-2.6.25.20-0.4.orig/arch/x86/kernel/ptrace.c  --- linux-2.6.25.20-0.4.orig/arch/x86/kernel/ptrace.c
103  +++ linux-2.6.25.20-0.4/arch/x86/kernel/ptrace.c  +++ linux-2.6.25.20-0.4/arch/x86/kernel/ptrace.c
104  @@ -32,6 +32,9 @@  @@ -32,6 +32,7 @@
105   #include <asm/prctl.h>   #include <asm/prctl.h>
106   #include <asm/proto.h>   #include <asm/proto.h>
107   #include <asm/ds.h>   #include <asm/ds.h>
 +/***** TOMOYO Linux start. *****/  
108  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
109    
110   #include "tls.h"   #include "tls.h"
111    
112  @@ -1240,6 +1243,10 @@ asmlinkage long sys32_ptrace(long reques  @@ -1240,6 +1241,8 @@ asmlinkage long sys32_ptrace(long reques
113          void __user *datap = compat_ptr(data);          void __user *datap = compat_ptr(data);
114          int ret;          int ret;
115          __u32 val;          __u32 val;
 +       /***** TOMOYO Linux start. *****/  
116  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (!ccs_capable(CCS_SYS_PTRACE))
117  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
118    
119          switch (request) {          switch (request) {
120          case PTRACE_TRACEME:          case PTRACE_TRACEME:
# Line 153  Source code for this patch is http://dow Line 137  Source code for this patch is http://dow
137  +include $(srctree)/fs/Makefile-2.6.ccs  +include $(srctree)/fs/Makefile-2.6.ccs
138  --- linux-2.6.25.20-0.4.orig/fs/attr.c  --- linux-2.6.25.20-0.4.orig/fs/attr.c
139  +++ linux-2.6.25.20-0.4/fs/attr.c  +++ linux-2.6.25.20-0.4/fs/attr.c
140  @@ -14,6 +14,9 @@  @@ -14,6 +14,7 @@
141   #include <linux/fcntl.h>   #include <linux/fcntl.h>
142   #include <linux/quotaops.h>   #include <linux/quotaops.h>
143   #include <linux/security.h>   #include <linux/security.h>
 +/***** TOMOYO Linux start. *****/  
144  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
145    
146   /* Taken over from the old code... */   /* Taken over from the old code... */
147    
148  @@ -160,6 +163,10 @@ int fnotify_change(struct dentry *dentry  @@ -160,6 +161,8 @@ int fnotify_change(struct dentry *dentry
149    
150          if (inode->i_op && inode->i_op->setattr) {          if (inode->i_op && inode->i_op->setattr) {
151                  error = security_inode_setattr(dentry, mnt, attr);                  error = security_inode_setattr(dentry, mnt, attr);
 +               /***** TOMOYO Linux start. *****/  
152  +               if (!error)  +               if (!error)
153  +                       error = ccs_check_setattr_permission(dentry, attr);  +                       error = ccs_check_setattr_permission(dentry, attr);
 +               /***** TOMOYO Linux end. *****/  
154                  if (!error) {                  if (!error) {
155                          if (file && file->f_op && file->f_op->fsetattr)                          if (file && file->f_op && file->f_op->fsetattr)
156                                  error = file->f_op->fsetattr(file, attr);                                  error = file->f_op->fsetattr(file, attr);
157  @@ -181,6 +188,10 @@ int fnotify_change(struct dentry *dentry  @@ -181,6 +184,8 @@ int fnotify_change(struct dentry *dentry
158                  error = inode_change_ok(inode, attr);                  error = inode_change_ok(inode, attr);
159                  if (!error)                  if (!error)
160                          error = security_inode_setattr(dentry, mnt, attr);                          error = security_inode_setattr(dentry, mnt, attr);
 +               /***** TOMOYO Linux start. *****/  
161  +               if (!error)  +               if (!error)
162  +                       error = ccs_check_setattr_permission(dentry, attr);  +                       error = ccs_check_setattr_permission(dentry, attr);
 +               /***** TOMOYO Linux end. *****/  
163                  if (!error) {                  if (!error) {
164                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
165                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))                              (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
166  --- linux-2.6.25.20-0.4.orig/fs/compat.c  --- linux-2.6.25.20-0.4.orig/fs/compat.c
167  +++ linux-2.6.25.20-0.4/fs/compat.c  +++ linux-2.6.25.20-0.4/fs/compat.c
168  @@ -55,6 +55,9 @@  @@ -55,6 +55,7 @@
169   #include <asm/mmu_context.h>   #include <asm/mmu_context.h>
170   #include <asm/ioctls.h>   #include <asm/ioctls.h>
171   #include "internal.h"   #include "internal.h"
 +/***** TOMOYO Linux start. *****/  
172  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
173    
174   int compat_log = 1;   int compat_log = 1;
175    
176  @@ -1399,7 +1402,7 @@ int compat_do_execve(char * filename,  @@ -1399,7 +1400,7 @@ int compat_do_execve(char * filename,
177          if (retval < 0)          if (retval < 0)
178                  goto out;                  goto out;
179    
# Line 208  Source code for this patch is http://dow Line 184  Source code for this patch is http://dow
184                  security_bprm_free(bprm);                  security_bprm_free(bprm);
185  --- linux-2.6.25.20-0.4.orig/fs/compat_ioctl.c  --- linux-2.6.25.20-0.4.orig/fs/compat_ioctl.c
186  +++ linux-2.6.25.20-0.4/fs/compat_ioctl.c  +++ linux-2.6.25.20-0.4/fs/compat_ioctl.c
187  @@ -120,6 +120,9 @@  @@ -120,6 +120,7 @@
188   #include <xen/public/privcmd.h>   #include <xen/public/privcmd.h>
189   #include <xen/compat_ioctl.h>   #include <xen/compat_ioctl.h>
190   #endif   #endif
 +/***** TOMOYO Linux start. *****/  
191  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
192    
193   static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,   static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
194                                unsigned long arg, struct file *f)                                unsigned long arg, struct file *f)
195  @@ -2906,6 +2909,10 @@ asmlinkage long compat_sys_ioctl(unsigne  @@ -2906,6 +2907,8 @@ asmlinkage long compat_sys_ioctl(unsigne
196    
197          /* RED-PEN how should LSM module know it's handling 32bit? */          /* RED-PEN how should LSM module know it's handling 32bit? */
198          error = security_file_ioctl(filp, cmd, arg);          error = security_file_ioctl(filp, cmd, arg);
 +       /***** TOMOYO Linux start. *****/  
199  +       if (!error)  +       if (!error)
200  +               error = ccs_check_ioctl_permission(filp, cmd, arg);  +               error = ccs_check_ioctl_permission(filp, cmd, arg);
 +       /***** TOMOYO Linux end. *****/  
201          if (error)          if (error)
202                  goto out_fput;                  goto out_fput;
203    
204  @@ -2930,6 +2937,12 @@ asmlinkage long compat_sys_ioctl(unsigne  @@ -2930,6 +2933,10 @@ asmlinkage long compat_sys_ioctl(unsigne
205                  /*FALL THROUGH*/                  /*FALL THROUGH*/
206    
207          default:          default:
 +               /***** TOMOYO Linux start. *****/  
208  +               if (!ccs_capable(CCS_SYS_IOCTL)) {  +               if (!ccs_capable(CCS_SYS_IOCTL)) {
209  +                       error = -EPERM;  +                       error = -EPERM;
210  +                       goto out_fput;  +                       goto out_fput;
211  +               }  +               }
 +               /***** TOMOYO Linux end. *****/  
212                  if (filp->f_op && filp->f_op->compat_ioctl) {                  if (filp->f_op && filp->f_op->compat_ioctl) {
213                          error = filp->f_op->compat_ioctl(filp, cmd, arg);                          error = filp->f_op->compat_ioctl(filp, cmd, arg);
214                          if (error != -ENOIOCTLCMD)                          if (error != -ENOIOCTLCMD)
215  --- linux-2.6.25.20-0.4.orig/fs/exec.c  --- linux-2.6.25.20-0.4.orig/fs/exec.c
216  +++ linux-2.6.25.20-0.4/fs/exec.c  +++ linux-2.6.25.20-0.4/fs/exec.c
217  @@ -60,6 +60,10 @@  @@ -60,6 +60,8 @@
218   #include <linux/kmod.h>   #include <linux/kmod.h>
219   #endif   #endif
220    
 +/***** TOMOYO Linux start. *****/  
221  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
222  +  +
223   int core_uses_pid;   int core_uses_pid;
224   char core_pattern[CORENAME_MAX_SIZE] = "core";   char core_pattern[CORENAME_MAX_SIZE] = "core";
225   int suid_dumpable = 0;   int suid_dumpable = 0;
226  @@ -118,6 +122,11 @@ asmlinkage long sys_uselib(const char __  @@ -118,6 +120,9 @@ asmlinkage long sys_uselib(const char __
227          error = vfs_permission(&nd, MAY_READ | MAY_EXEC);          error = vfs_permission(&nd, MAY_READ | MAY_EXEC);
228          if (error)          if (error)
229                  goto exit;                  goto exit;
 +       /***** TOMOYO Linux start. *****/  
230  +       error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt);  +       error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt);
231  +       if (error)  +       if (error)
232  +               goto exit;  +               goto exit;
 +       /***** TOMOYO Linux end. *****/  
233    
234          file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);          file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
235          error = PTR_ERR(file);          error = PTR_ERR(file);
236  @@ -664,6 +673,13 @@ struct file *open_exec(const char *name)  @@ -664,6 +669,11 @@ struct file *open_exec(const char *name)
237                  file = ERR_PTR(-EACCES);                  file = ERR_PTR(-EACCES);
238                  if (S_ISREG(inode->i_mode)) {                  if (S_ISREG(inode->i_mode)) {
239                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
 +                       /***** TOMOYO Linux start. *****/  
240  +                       if (!err)  +                       if (!err)
241  +                               err = ccs_check_open_exec_permission(nd.path.  +                               err = ccs_check_open_exec_permission(nd.path.
242  +                                                                    dentry,  +                                                                    dentry,
243  +                                                                    nd.path.  +                                                                    nd.path.
244  +                                                                    mnt);  +                                                                    mnt);
 +                       /***** TOMOYO Linux end. *****/  
245                          file = ERR_PTR(err);                          file = ERR_PTR(err);
246                          if (!err) {                          if (!err) {
247                                  file = nameidata_to_filp(&nd,                                  file = nameidata_to_filp(&nd,
248  @@ -1336,7 +1352,7 @@ int do_execve(char * filename,  @@ -1336,7 +1346,7 @@ int do_execve(char * filename,
249                  goto out;                  goto out;
250          bprm->argv_len = env_p - bprm->p;          bprm->argv_len = env_p - bprm->p;
251    
# Line 292  Source code for this patch is http://dow Line 256  Source code for this patch is http://dow
256                  free_arg_pages(bprm);                  free_arg_pages(bprm);
257  --- linux-2.6.25.20-0.4.orig/fs/fcntl.c  --- linux-2.6.25.20-0.4.orig/fs/fcntl.c
258  +++ linux-2.6.25.20-0.4/fs/fcntl.c  +++ linux-2.6.25.20-0.4/fs/fcntl.c
259  @@ -23,6 +23,9 @@  @@ -23,6 +23,7 @@
260   #include <asm/poll.h>   #include <asm/poll.h>
261   #include <asm/siginfo.h>   #include <asm/siginfo.h>
262   #include <asm/uaccess.h>   #include <asm/uaccess.h>
 +/***** TOMOYO Linux start. *****/  
263  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
264    
265   void set_close_on_exec(unsigned int fd, int flag)   void set_close_on_exec(unsigned int fd, int flag)
266   {   {
267  @@ -217,6 +220,12 @@ static int setfl(int fd, struct file * f  @@ -217,6 +218,10 @@ static int setfl(int fd, struct file * f
268          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
269                  return -EPERM;                  return -EPERM;
270    
 +       /***** TOMOYO Linux start. *****/  
271  +       if (((arg ^ filp->f_flags) & O_APPEND) &&  +       if (((arg ^ filp->f_flags) & O_APPEND) &&
272  +           ccs_check_rewrite_permission(filp))  +           ccs_check_rewrite_permission(filp))
273  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
274  +  +
275          /* O_NOATIME can only be set by the owner or superuser */          /* O_NOATIME can only be set by the owner or superuser */
276          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))          if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
277                  if (!is_owner_or_cap(inode))                  if (!is_owner_or_cap(inode))
278  --- linux-2.6.25.20-0.4.orig/fs/ioctl.c  --- linux-2.6.25.20-0.4.orig/fs/ioctl.c
279  +++ linux-2.6.25.20-0.4/fs/ioctl.c  +++ linux-2.6.25.20-0.4/fs/ioctl.c
280  @@ -15,6 +15,9 @@  @@ -15,6 +15,7 @@
281   #include <linux/uaccess.h>   #include <linux/uaccess.h>
282    
283   #include <asm/ioctls.h>   #include <asm/ioctls.h>
 +/***** TOMOYO Linux start. *****/  
284  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
285    
286   /**   /**
287    * vfs_ioctl - call filesystem specific ioctl methods    * vfs_ioctl - call filesystem specific ioctl methods
288  @@ -35,6 +38,10 @@ long vfs_ioctl(struct file *filp, unsign  @@ -35,6 +36,8 @@ long vfs_ioctl(struct file *filp, unsign
289    
290          if (!filp->f_op)          if (!filp->f_op)
291                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
292  +       if (!ccs_capable(CCS_SYS_IOCTL))  +       if (!ccs_capable(CCS_SYS_IOCTL))
293  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
294    
295          if (filp->f_op->unlocked_ioctl) {          if (filp->f_op->unlocked_ioctl) {
296                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);                  error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
297  @@ -202,6 +209,10 @@ asmlinkage long sys_ioctl(unsigned int f  @@ -202,6 +205,8 @@ asmlinkage long sys_ioctl(unsigned int f
298                  goto out;                  goto out;
299    
300          error = security_file_ioctl(filp, cmd, arg);          error = security_file_ioctl(filp, cmd, arg);
 +       /***** TOMOYO Linux start. *****/  
301  +       if (!error)  +       if (!error)
302  +               error = ccs_check_ioctl_permission(filp, cmd, arg);  +               error = ccs_check_ioctl_permission(filp, cmd, arg);
 +       /***** TOMOYO Linux end. *****/  
303          if (error)          if (error)
304                  goto out_fput;                  goto out_fput;
305    
306  --- linux-2.6.25.20-0.4.orig/fs/namei.c  --- linux-2.6.25.20-0.4.orig/fs/namei.c
307  +++ linux-2.6.25.20-0.4/fs/namei.c  +++ linux-2.6.25.20-0.4/fs/namei.c
308  @@ -35,6 +35,10 @@  @@ -35,6 +35,8 @@
309    
310   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])   #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
311    
 +/***** TOMOYO Linux start. *****/  
312  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
313  +  +
314   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
315    * Fundamental changes in the pathname lookup mechanisms (namei)    * Fundamental changes in the pathname lookup mechanisms (namei)
316    * were necessary because of omirr.  The reason is that omirr needs    * were necessary because of omirr.  The reason is that omirr needs
317  @@ -1690,6 +1694,13 @@ int may_open(struct nameidata *nd, int a  @@ -1690,6 +1692,11 @@ int may_open(struct nameidata *nd, int a
318                  if (!is_owner_or_cap(inode))                  if (!is_owner_or_cap(inode))
319                          return -EPERM;                          return -EPERM;
320    
 +       /***** TOMOYO Linux start. *****/  
321  +       /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
322  +       error = ccs_check_open_permission(dentry, nd->path.mnt, flag);  +       error = ccs_check_open_permission(dentry, nd->path.mnt, flag);
323  +       if (error)  +       if (error)
324  +               return error;  +               return error;
 +       /***** TOMOYO Linux end. *****/  
325  +  +
326          /*          /*
327           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
328           */           */
329  @@ -1731,6 +1742,11 @@ static int open_namei_create(struct name  @@ -1731,6 +1738,9 @@ static int open_namei_create(struct name
330    
331          if (!IS_POSIXACL(dir->d_inode))          if (!IS_POSIXACL(dir->d_inode))
332                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
 +       /***** TOMOYO Linux start. *****/  
333  +       error = ccs_check_mknod_permission(dir->d_inode, path->dentry,  +       error = ccs_check_mknod_permission(dir->d_inode, path->dentry,
334  +                                          nd->path.mnt, mode, 0);  +                                          nd->path.mnt, mode, 0);
335  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
336          error = vfs_create(dir->d_inode, path->dentry, mode, nd);          error = vfs_create(dir->d_inode, path->dentry, mode, nd);
337          mutex_unlock(&dir->d_inode->i_mutex);          mutex_unlock(&dir->d_inode->i_mutex);
338          dput(nd->path.dentry);          dput(nd->path.dentry);
339  @@ -1741,6 +1757,9 @@ static int open_namei_create(struct name  @@ -1741,6 +1751,7 @@ static int open_namei_create(struct name
340          return may_open(nd, 0, flag & ~O_TRUNC);          return may_open(nd, 0, flag & ~O_TRUNC);
341   }   }
342    
 +/***** TOMOYO Linux start. *****/  
343  +#include <linux/tomoyo_vfs.h>  +#include <linux/tomoyo_vfs.h>
 +/***** TOMOYO Linux end. *****/  
344   /*   /*
345    *     open_namei()    *     open_namei()
346    *    *
347  @@ -2019,6 +2038,12 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -2019,6 +2030,10 @@ asmlinkage long sys_mknodat(int dfd, con
348          if (!IS_POSIXACL(nd.path.dentry->d_inode))          if (!IS_POSIXACL(nd.path.dentry->d_inode))
349                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
350          if (!IS_ERR(dentry)) {          if (!IS_ERR(dentry)) {
 +               /***** TOMOYO Linux start. *****/  
351  +               error = ccs_check_mknod_permission(nd.path.dentry->d_inode,  +               error = ccs_check_mknod_permission(nd.path.dentry->d_inode,
352  +                                                  dentry, nd.path.mnt, mode,  +                                                  dentry, nd.path.mnt, mode,
353  +                                                  new_decode_dev(dev));  +                                                  new_decode_dev(dev));
354  +               if (!error)  +               if (!error)
 +               /***** TOMOYO Linux end. *****/  
355                  switch (mode & S_IFMT) {                  switch (mode & S_IFMT) {
356                  case 0: case S_IFREG:                  case 0: case S_IFREG:
357                          error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd);                          error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd);
358  @@ -2097,6 +2122,11 @@ asmlinkage long sys_mkdirat(int dfd, con  @@ -2097,6 +2112,9 @@ asmlinkage long sys_mkdirat(int dfd, con
359    
360          if (!IS_POSIXACL(nd.path.dentry->d_inode))          if (!IS_POSIXACL(nd.path.dentry->d_inode))
361                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
 +       /***** TOMOYO Linux start. *****/  
362  +       error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry,  +       error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry,
363  +                                          nd.path.mnt, mode);  +                                          nd.path.mnt, mode);
364  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
365          error = vfs_mkdir(nd.path.dentry->d_inode, dentry, nd.path.mnt, mode);          error = vfs_mkdir(nd.path.dentry->d_inode, dentry, nd.path.mnt, mode);
366          dput(dentry);          dput(dentry);
367   out_unlock:   out_unlock:
368  @@ -2205,6 +2235,11 @@ static long do_rmdir(int dfd, const char  @@ -2205,6 +2223,9 @@ static long do_rmdir(int dfd, const char
369          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
370          if (IS_ERR(dentry))          if (IS_ERR(dentry))
371                  goto exit2;                  goto exit2;
 +       /***** TOMOYO Linux start. *****/  
372  +       error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry,  +       error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry,
373  +                                          nd.path.mnt);  +                                          nd.path.mnt);
374  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
375          error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt);          error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt);
376          dput(dentry);          dput(dentry);
377   exit2:   exit2:
378  @@ -2286,6 +2321,11 @@ static long do_unlinkat(int dfd, const c  @@ -2286,6 +2307,9 @@ static long do_unlinkat(int dfd, const c
379                  inode = dentry->d_inode;                  inode = dentry->d_inode;
380                  if (inode)                  if (inode)
381                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
 +               /***** TOMOYO Linux start. *****/  
382  +               error = ccs_check_unlink_permission(nd.path.dentry->d_inode,  +               error = ccs_check_unlink_permission(nd.path.dentry->d_inode,
383  +                                                   dentry, nd.path.mnt);  +                                                   dentry, nd.path.mnt);
384  +               if (!error)  +               if (!error)
 +               /***** TOMOYO Linux end. *****/  
385                  error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt);                  error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt);
386          exit2:          exit2:
387                  dput(dentry);                  dput(dentry);
388  @@ -2368,6 +2408,11 @@ asmlinkage long sys_symlinkat(const char  @@ -2368,6 +2392,9 @@ asmlinkage long sys_symlinkat(const char
389          if (IS_ERR(dentry))          if (IS_ERR(dentry))
390                  goto out_unlock;                  goto out_unlock;
391    
 +       /***** TOMOYO Linux start. *****/  
392  +       error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry,  +       error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry,
393  +                                            nd.path.mnt, from);  +                                            nd.path.mnt, from);
394  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
395          error = vfs_symlink(nd.path.dentry->d_inode, dentry, nd.path.mnt, from,          error = vfs_symlink(nd.path.dentry->d_inode, dentry, nd.path.mnt, from,
396                              S_IALLUGO);                              S_IALLUGO);
397          dput(dentry);          dput(dentry);
398  @@ -2465,6 +2510,12 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2465,6 +2492,10 @@ asmlinkage long sys_linkat(int olddfd, c
399          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
400          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
401                  goto out_unlock;                  goto out_unlock;
 +       /***** TOMOYO Linux start. *****/  
402  +       error = ccs_check_link_permission(old_nd.path.dentry,  +       error = ccs_check_link_permission(old_nd.path.dentry,
403  +                                         nd.path.dentry->d_inode, new_dentry,  +                                         nd.path.dentry->d_inode, new_dentry,
404  +                                         nd.path.mnt);  +                                         nd.path.mnt);
405  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
406          error = vfs_link(old_nd.path.dentry, old_nd.path.mnt, nd.path.dentry->d_inode,          error = vfs_link(old_nd.path.dentry, old_nd.path.mnt, nd.path.dentry->d_inode,
407                           new_dentry, nd.path.mnt);                           new_dentry, nd.path.mnt);
408          dput(new_dentry);          dput(new_dentry);
409  @@ -2698,6 +2749,12 @@ static int do_rename(int olddfd, const c  @@ -2698,6 +2729,10 @@ static int do_rename(int olddfd, const c
410          error = -ENOTEMPTY;          error = -ENOTEMPTY;
411          if (new_dentry == trap)          if (new_dentry == trap)
412                  goto exit5;                  goto exit5;
 +       /***** TOMOYO Linux start. *****/  
413  +       error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,  +       error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,
414  +                                           new_dir->d_inode, new_dentry,  +                                           new_dir->d_inode, new_dentry,
415  +                                           newnd.path.mnt);  +                                           newnd.path.mnt);
416  +       if (!error)  +       if (!error)
 +       /***** TOMOYO Linux end. *****/  
417    
418          error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt,          error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt,
419                             new_dir->d_inode, new_dentry, newnd.path.mnt);                             new_dir->d_inode, new_dentry, newnd.path.mnt);
420  --- linux-2.6.25.20-0.4.orig/fs/namespace.c  --- linux-2.6.25.20-0.4.orig/fs/namespace.c
421  +++ linux-2.6.25.20-0.4/fs/namespace.c  +++ linux-2.6.25.20-0.4/fs/namespace.c
422  @@ -30,6 +30,12 @@  @@ -30,6 +30,8 @@
423   #include <asm/unistd.h>   #include <asm/unistd.h>
424   #include "pnode.h"   #include "pnode.h"
425   #include "internal.h"   #include "internal.h"
 +/***** SAKURA Linux start. *****/  
426  +#include <linux/sakura.h>  +#include <linux/sakura.h>
 +/***** SAKURA Linux end. *****/  
 +/***** TOMOYO Linux start. *****/  
427  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
428    
429   #define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head))   #define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head))
430   #define HASH_SIZE (1UL << HASH_SHIFT)   #define HASH_SIZE (1UL << HASH_SHIFT)
431  @@ -591,6 +597,11 @@ static int do_umount(struct vfsmount *mn  @@ -591,6 +593,9 @@ static int do_umount(struct vfsmount *mn
432          if (retval)          if (retval)
433                  return retval;                  return retval;
434    
 +       /***** SAKURA Linux start. *****/  
435  +       if (ccs_may_umount(mnt))  +       if (ccs_may_umount(mnt))
436  +               return -EPERM;  +               return -EPERM;
 +       /***** SAKURA Linux end. *****/  
437  +  +
438          /*          /*
439           * Allow userspace to request a mountpoint be expired rather than           * Allow userspace to request a mountpoint be expired rather than
440           * unmounting unconditionally. Unmount only happens if:           * unmounting unconditionally. Unmount only happens if:
441  @@ -682,6 +693,10 @@ asmlinkage long sys_umount(char __user *  @@ -682,6 +687,8 @@ asmlinkage long sys_umount(char __user *
442   {   {
443          struct nameidata nd;          struct nameidata nd;
444          int retval;          int retval;
 +       /***** TOMOYO Linux start. *****/  
445  +       if (!ccs_capable(CCS_SYS_UMOUNT))  +       if (!ccs_capable(CCS_SYS_UMOUNT))
446  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
447    
448          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
449          if (retval)          if (retval)
450  @@ -991,6 +1006,11 @@ static noinline int do_loopback(struct n  @@ -991,6 +998,9 @@ static noinline int do_loopback(struct n
451          err = -EINVAL;          err = -EINVAL;
452          if (IS_MNT_UNBINDABLE(old_nd.path.mnt))          if (IS_MNT_UNBINDABLE(old_nd.path.mnt))
453                  goto out;                  goto out;
 +       /***** SAKURA Linux start. *****/  
454  +       err = -EPERM;  +       err = -EPERM;
455  +       if (ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
456  +               goto out;  +               goto out;
 +       /***** SAKURA Linux end. *****/  
457    
458          if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt))          if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt))
459                  goto out;                  goto out;
460  @@ -1085,6 +1105,11 @@ static noinline int do_move_mount(struct  @@ -1085,6 +1095,9 @@ static noinline int do_move_mount(struct
461          if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt))          if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt))
462                  goto out;                  goto out;
463    
 +       /***** SAKURA Linux start. *****/  
464  +       err = -EPERM;  +       err = -EPERM;
465  +       if (ccs_may_umount(old_nd.path.mnt) || ccs_may_mount(nd))  +       if (ccs_may_umount(old_nd.path.mnt) || ccs_may_mount(nd))
466  +               goto out;  +               goto out;
 +       /***** SAKURA Linux end. *****/  
467          err = -ENOENT;          err = -ENOENT;
468          mutex_lock(&nd->path.dentry->d_inode->i_mutex);          mutex_lock(&nd->path.dentry->d_inode->i_mutex);
469          if (IS_DEADDIR(nd->path.dentry->d_inode))          if (IS_DEADDIR(nd->path.dentry->d_inode))
470  @@ -1189,6 +1214,11 @@ int do_add_mount(struct vfsmount *newmnt  @@ -1189,6 +1202,9 @@ int do_add_mount(struct vfsmount *newmnt
471          err = -EINVAL;          err = -EINVAL;
472          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
473                  goto unlock;                  goto unlock;
 +       /***** SAKURA Linux start. *****/  
474  +       err = -EPERM;  +       err = -EPERM;
475  +       if (ccs_may_mount(nd))  +       if (ccs_may_mount(nd))
476  +               goto unlock;  +               goto unlock;
 +       /***** SAKURA Linux end. *****/  
477    
478          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
479          if ((err = graft_tree(newmnt, nd)))          if ((err = graft_tree(newmnt, nd)))
480  @@ -1412,6 +1442,17 @@ long do_mount(char *dev_name, char *dir_  @@ -1412,6 +1428,13 @@ long do_mount(char *dev_name, char *dir_
481          if (data_page)          if (data_page)
482                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                  ((char *)data_page)[PAGE_SIZE - 1] = 0;
483    
 +       /***** TOMOYO Linux start. *****/  
484  +       if (!ccs_capable(CCS_SYS_MOUNT))  +       if (!ccs_capable(CCS_SYS_MOUNT))
485  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
 +       /***** SAKURA Linux start. *****/  
486  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
487  +                                           &flags);  +                                           &flags);
488  +       if (retval)  +       if (retval)
489  +               return retval;  +               return retval;
 +       /***** SAKURA Linux end. *****/  
490  +  +
491          /* Separate the per-mountpoint flags */          /* Separate the per-mountpoint flags */
492          if (flags & MS_NOSUID)          if (flags & MS_NOSUID)
493                  mnt_flags |= MNT_NOSUID;                  mnt_flags |= MNT_NOSUID;
494  @@ -1680,6 +1721,10 @@ asmlinkage long sys_pivot_root(const cha  @@ -1680,6 +1703,8 @@ asmlinkage long sys_pivot_root(const cha
495    
496          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
497                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
498  +       if (!ccs_capable(CCS_SYS_PIVOT_ROOT))  +       if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
499  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
500    
501          lock_kernel();          lock_kernel();
502    
503  @@ -1696,6 +1741,10 @@ asmlinkage long sys_pivot_root(const cha  @@ -1696,6 +1721,8 @@ asmlinkage long sys_pivot_root(const cha
504                  goto out1;                  goto out1;
505    
506          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
 +       /***** SAKURA Linux start. *****/  
507  +       if (!error)  +       if (!error)
508  +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);  +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
 +       /***** SAKURA Linux end. *****/  
509          if (error) {          if (error) {
510                  path_put(&old_nd.path);                  path_put(&old_nd.path);
511                  goto out1;                  goto out1;
512  --- linux-2.6.25.20-0.4.orig/fs/open.c  --- linux-2.6.25.20-0.4.orig/fs/open.c
513  +++ linux-2.6.25.20-0.4/fs/open.c  +++ linux-2.6.25.20-0.4/fs/open.c
514  @@ -27,6 +27,12 @@  @@ -27,6 +27,8 @@
515   #include <linux/rcupdate.h>   #include <linux/rcupdate.h>
516   #include <linux/audit.h>   #include <linux/audit.h>
517   #include <linux/falloc.h>   #include <linux/falloc.h>
 +/***** SAKURA Linux start. *****/  
518  +#include <linux/sakura.h>  +#include <linux/sakura.h>
 +/***** SAKURA Linux end. *****/  
 +/***** TOMOYO Linux start. *****/  
519  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
520    
521   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
522   {   {
523  @@ -267,6 +273,12 @@ static long do_sys_truncate(const char _  @@ -267,6 +269,10 @@ static long do_sys_truncate(const char _
524          if (error)          if (error)
525                  goto put_write_and_out;                  goto put_write_and_out;
526    
 +       /***** TOMOYO Linux start. *****/  
527  +       error = ccs_check_truncate_permission(nd.path.dentry, nd.path.mnt,  +       error = ccs_check_truncate_permission(nd.path.dentry, nd.path.mnt,
528  +                                             length, 0);  +                                             length, 0);
529  +       if (error)  +       if (error)
530  +               goto put_write_and_out;  +               goto put_write_and_out;
 +       /***** TOMOYO Linux end. *****/  
531          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
532          if (!error) {          if (!error) {
533                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
534  @@ -321,6 +333,12 @@ static long do_sys_ftruncate(unsigned in  @@ -321,6 +327,10 @@ static long do_sys_ftruncate(unsigned in
535          if (IS_APPEND(inode))          if (IS_APPEND(inode))
536                  goto out_putf;                  goto out_putf;
537    
 +       /***** TOMOYO Linux start. *****/  
538  +       error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,  +       error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
539  +                                             0);  +                                             0);
540  +       if (error)  +       if (error)
541  +               goto out_putf;  +               goto out_putf;
 +       /***** TOMOYO Linux end. *****/  
542          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
543          if (!error)          if (!error)
544                  error = do_truncate(dentry, file->f_path.mnt, length,                  error = do_truncate(dentry, file->f_path.mnt, length,
545  @@ -539,6 +557,14 @@ asmlinkage long sys_chroot(const char __  @@ -539,6 +549,10 @@ asmlinkage long sys_chroot(const char __
546          error = -EPERM;          error = -EPERM;
547          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
548                  goto dput_and_out;                  goto dput_and_out;
 +       /***** TOMOYO Linux start. *****/  
549  +       if (!ccs_capable(CCS_SYS_CHROOT))  +       if (!ccs_capable(CCS_SYS_CHROOT))
550  +               goto dput_and_out;  +               goto dput_and_out;
 +       /***** TOMOYO Linux end. *****/  
 +       /***** SAKURA Linux start. *****/  
551  +       if (ccs_check_chroot_permission(&nd))  +       if (ccs_check_chroot_permission(&nd))
552  +               goto dput_and_out;  +               goto dput_and_out;
 +       /***** SAKURA Linux end. *****/  
553    
554          set_fs_root(current->fs, &nd.path);          set_fs_root(current->fs, &nd.path);
555          set_fs_altroot();          set_fs_altroot();
556  @@ -1172,6 +1198,10 @@ EXPORT_SYMBOL(sys_close);  @@ -1172,6 +1186,8 @@ EXPORT_SYMBOL(sys_close);
557    */    */
558   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
559   {   {
 +       /***** TOMOYO Linux start. *****/  
560  +       if (!ccs_capable(CCS_SYS_VHANGUP))  +       if (!ccs_capable(CCS_SYS_VHANGUP))
561  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
562          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
563                  /* XXX: this needs locking */                  /* XXX: this needs locking */
564                  tty_vhangup(current->signal->tty);                  tty_vhangup(current->signal->tty);
# Line 677  Source code for this patch is http://dow Line 573  Source code for this patch is http://dow
573  +proc-$(CONFIG_TOMOYO) += ccs_proc.o  +proc-$(CONFIG_TOMOYO) += ccs_proc.o
574  --- linux-2.6.25.20-0.4.orig/fs/proc/proc_misc.c  --- linux-2.6.25.20-0.4.orig/fs/proc/proc_misc.c
575  +++ linux-2.6.25.20-0.4/fs/proc/proc_misc.c  +++ linux-2.6.25.20-0.4/fs/proc/proc_misc.c
576  @@ -1021,4 +1021,9 @@ void __init proc_misc_init(void)  @@ -1021,4 +1021,5 @@ void __init proc_misc_init(void)
577                          entry->proc_fops = &proc_sysrq_trigger_operations;                          entry->proc_fops = &proc_sysrq_trigger_operations;
578          }          }
579   #endif   #endif
580  +       /***** CCS start. *****/  +       printk(KERN_INFO "Hook version: 2.6.25.20-0.4 2009/07/23\n");
 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)  
 +       printk(KERN_INFO "Hook version: 2.6.25.20-0.4 2009/06/09\n");  
 +#endif  
 +       /***** CCS end. *****/  
581   }   }
582  --- linux-2.6.25.20-0.4.orig/include/linux/init_task.h  --- linux-2.6.25.20-0.4.orig/include/linux/init_task.h
583  +++ linux-2.6.25.20-0.4/include/linux/init_task.h  +++ linux-2.6.25.20-0.4/include/linux/init_task.h
584  @@ -196,6 +196,10 @@ extern struct group_info init_groups;  @@ -196,6 +196,8 @@ extern struct group_info init_groups;
585          INIT_IDS                                                        \          INIT_IDS                                                        \
586          INIT_TRACE_IRQFLAGS                                             \          INIT_TRACE_IRQFLAGS                                             \
587          INIT_LOCKDEP                                                    \          INIT_LOCKDEP                                                    \
 +       /***** TOMOYO Linux start. *****/        \  
588  +       .ccs_domain_info = NULL,                 \  +       .ccs_domain_info = NULL,                 \
589  +       .ccs_flags = 0,                          \  +       .ccs_flags = 0,                          \
 +       /***** TOMOYO Linux end. *****/          \  
590   }   }
591    
592    
593  --- linux-2.6.25.20-0.4.orig/include/linux/sched.h  --- linux-2.6.25.20-0.4.orig/include/linux/sched.h
594  +++ linux-2.6.25.20-0.4/include/linux/sched.h  +++ linux-2.6.25.20-0.4/include/linux/sched.h
595  @@ -29,6 +29,10 @@  @@ -29,6 +29,8 @@
596   #define CLONE_NEWNET           0x40000000      /* New network namespace */   #define CLONE_NEWNET           0x40000000      /* New network namespace */
597   #define CLONE_IO               0x80000000      /* Clone io context */   #define CLONE_IO               0x80000000      /* Clone io context */
598    
 +/***** TOMOYO Linux start. *****/  
599  +struct ccs_domain_info;  +struct ccs_domain_info;
 +/***** TOMOYO Linux end. *****/  
600  +  +
601   /*   /*
602    * Scheduling policies    * Scheduling policies
603    */    */
604  @@ -1274,6 +1278,10 @@ struct task_struct {  @@ -1274,6 +1276,8 @@ struct task_struct {
605   #ifndef __GENKSYMS__   #ifndef __GENKSYMS__
606          struct list_head        *scm_work_list;          struct list_head        *scm_work_list;
607   #endif   #endif
 +       /***** TOMOYO Linux start. *****/  
608  +       struct ccs_domain_info *ccs_domain_info;  +       struct ccs_domain_info *ccs_domain_info;
609  +       u32 ccs_flags;  +       u32 ccs_flags;
 +       /***** TOMOYO Linux end. *****/  
610   };   };
611    
612   /*   /*
613  --- linux-2.6.25.20-0.4.orig/kernel/compat.c  --- linux-2.6.25.20-0.4.orig/kernel/compat.c
614  +++ linux-2.6.25.20-0.4/kernel/compat.c  +++ linux-2.6.25.20-0.4/kernel/compat.c
615  @@ -25,6 +25,9 @@  @@ -25,6 +25,7 @@
616   #include <linux/posix-timers.h>   #include <linux/posix-timers.h>
617    
618   #include <asm/uaccess.h>   #include <asm/uaccess.h>
 +/***** TOMOYO Linux start. *****/  
619  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
620    
621   int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)   int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
622   {   {
623  @@ -869,6 +872,10 @@ asmlinkage long compat_sys_stime(compat_  @@ -869,6 +870,8 @@ asmlinkage long compat_sys_stime(compat_
624          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
625          if (err)          if (err)
626                  return err;                  return err;
 +       /***** TOMOYO Linux start. *****/  
627  +       if (!ccs_capable(CCS_SYS_SETTIME))  +       if (!ccs_capable(CCS_SYS_SETTIME))
628  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
629    
630          do_settimeofday(&tv);          do_settimeofday(&tv);
631          return 0;          return 0;
632  --- linux-2.6.25.20-0.4.orig/kernel/kexec.c  --- linux-2.6.25.20-0.4.orig/kernel/kexec.c
633  +++ linux-2.6.25.20-0.4/kernel/kexec.c  +++ linux-2.6.25.20-0.4/kernel/kexec.c
634  @@ -31,6 +31,9 @@  @@ -31,6 +31,7 @@
635   #include <asm/system.h>   #include <asm/system.h>
636   #include <asm/semaphore.h>   #include <asm/semaphore.h>
637   #include <asm/sections.h>   #include <asm/sections.h>
 +/***** TOMOYO Linux start. *****/  
638  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
639    
640   /* Per cpu memory for storing cpu states in case of system crash. */   /* Per cpu memory for storing cpu states in case of system crash. */
641   note_buf_t* crash_notes;   note_buf_t* crash_notes;
642  @@ -969,6 +972,10 @@ asmlinkage long sys_kexec_load(unsigned  @@ -969,6 +970,8 @@ asmlinkage long sys_kexec_load(unsigned
643          /* We only trust the superuser with rebooting the system. */          /* We only trust the superuser with rebooting the system. */
644          if (!capable(CAP_SYS_BOOT))          if (!capable(CAP_SYS_BOOT))
645                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
646  +       if (!ccs_capable(CCS_SYS_KEXEC_LOAD))  +       if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
647  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
648    
649          /*          /*
650           * Verify we have a legal set of flags           * Verify we have a legal set of flags
651  --- linux-2.6.25.20-0.4.orig/kernel/kmod.c  --- linux-2.6.25.20-0.4.orig/kernel/kmod.c
652  +++ linux-2.6.25.20-0.4/kernel/kmod.c  +++ linux-2.6.25.20-0.4/kernel/kmod.c
653  @@ -173,6 +173,11 @@ static int ____call_usermodehelper(void  @@ -173,6 +173,9 @@ static int ____call_usermodehelper(void
654           */           */
655          set_user_nice(current, 0);          set_user_nice(current, 0);
656    
 +       /***** TOMOYO Linux start. *****/  
657  +       current->ccs_domain_info = NULL;  +       current->ccs_domain_info = NULL;
658  +       current->ccs_flags = 0;  +       current->ccs_flags = 0;
 +       /***** TOMOYO Linux end. *****/  
659  +  +
660          retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp);          retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp);
661    
662          /* Exec failed? */          /* Exec failed? */
663  --- linux-2.6.25.20-0.4.orig/kernel/module.c  --- linux-2.6.25.20-0.4.orig/kernel/module.c
664  +++ linux-2.6.25.20-0.4/kernel/module.c  +++ linux-2.6.25.20-0.4/kernel/module.c
665  @@ -47,6 +47,9 @@  @@ -47,6 +47,7 @@
666   #include <asm/cacheflush.h>   #include <asm/cacheflush.h>
667   #include <linux/license.h>   #include <linux/license.h>
668   #include <asm/sections.h>   #include <asm/sections.h>
 +/***** TOMOYO Linux start. *****/  
669  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
670    
671   #if 0   #if 0
672   #define DEBUGP printk   #define DEBUGP printk
673  @@ -700,6 +703,10 @@ sys_delete_module(const char __user *nam  @@ -700,6 +701,8 @@ sys_delete_module(const char __user *nam
674    
675          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
676                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
677  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))
678  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
679    
680          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
681                  return -EFAULT;                  return -EFAULT;
682  @@ -2181,6 +2188,10 @@ sys_init_module(void __user *umod,  @@ -2181,6 +2184,8 @@ sys_init_module(void __user *umod,
683          /* Must have permission */          /* Must have permission */
684          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
685                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
686  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))  +       if (!ccs_capable(CCS_USE_KERNEL_MODULE))
687  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
688    
689          /* Only one module load at a time, please */          /* Only one module load at a time, please */
690          if (mutex_lock_interruptible(&module_mutex) != 0)          if (mutex_lock_interruptible(&module_mutex) != 0)
691  --- linux-2.6.25.20-0.4.orig/kernel/ptrace.c  --- linux-2.6.25.20-0.4.orig/kernel/ptrace.c
692  +++ linux-2.6.25.20-0.4/kernel/ptrace.c  +++ linux-2.6.25.20-0.4/kernel/ptrace.c
693  @@ -24,6 +24,9 @@  @@ -24,6 +24,7 @@
694    
695   #include <asm/pgtable.h>   #include <asm/pgtable.h>
696   #include <asm/uaccess.h>   #include <asm/uaccess.h>
 +/***** TOMOYO Linux start. *****/  
697  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
698    
699   /*   /*
700    * ptrace a task: make the debugger its new parent and    * ptrace a task: make the debugger its new parent and
701  @@ -548,6 +551,10 @@ asmlinkage long sys_ptrace(long request,  @@ -548,6 +549,8 @@ asmlinkage long sys_ptrace(long request,
702          /*          /*
703           * This lock_kernel fixes a subtle race with suid exec           * This lock_kernel fixes a subtle race with suid exec
704           */           */
 +       /***** TOMOYO Linux start. *****/  
705  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (!ccs_capable(CCS_SYS_PTRACE))
706  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
707          lock_kernel();          lock_kernel();
708          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
709                  ret = ptrace_traceme();                  ret = ptrace_traceme();
710  @@ -655,6 +662,10 @@ asmlinkage long compat_sys_ptrace(compat  @@ -655,6 +658,8 @@ asmlinkage long compat_sys_ptrace(compat
711          /*          /*
712           * This lock_kernel fixes a subtle race with suid exec           * This lock_kernel fixes a subtle race with suid exec
713           */           */
 +       /***** TOMOYO Linux start. *****/  
714  +       if (!ccs_capable(CCS_SYS_PTRACE))  +       if (!ccs_capable(CCS_SYS_PTRACE))
715  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
716          lock_kernel();          lock_kernel();
717          if (request == PTRACE_TRACEME) {          if (request == PTRACE_TRACEME) {
718                  ret = ptrace_traceme();                  ret = ptrace_traceme();
719  --- linux-2.6.25.20-0.4.orig/kernel/sched.c  --- linux-2.6.25.20-0.4.orig/kernel/sched.c
720  +++ linux-2.6.25.20-0.4/kernel/sched.c  +++ linux-2.6.25.20-0.4/kernel/sched.c
721  @@ -69,6 +69,9 @@  @@ -69,6 +69,7 @@
722    
723   #include <asm/tlb.h>   #include <asm/tlb.h>
724   #include <asm/irq_regs.h>   #include <asm/irq_regs.h>
 +/***** TOMOYO Linux start. *****/  
725  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
726    
727   /*   /*
728    * Scheduler clock - returns current time in nanosec units.    * Scheduler clock - returns current time in nanosec units.
729  @@ -4510,6 +4513,10 @@ int can_nice(const struct task_struct *p  @@ -4510,6 +4511,8 @@ int can_nice(const struct task_struct *p
730   asmlinkage long sys_nice(int increment)   asmlinkage long sys_nice(int increment)
731   {   {
732          long nice, retval;          long nice, retval;
 +       /***** TOMOYO Linux start. *****/  
733  +       if (!ccs_capable(CCS_SYS_NICE))  +       if (!ccs_capable(CCS_SYS_NICE))
734  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
735    
736          /*          /*
737           * Setpriority might change our priority at the same moment.           * Setpriority might change our priority at the same moment.
738  --- linux-2.6.25.20-0.4.orig/kernel/signal.c  --- linux-2.6.25.20-0.4.orig/kernel/signal.c
739  +++ linux-2.6.25.20-0.4/kernel/signal.c  +++ linux-2.6.25.20-0.4/kernel/signal.c
740  @@ -32,6 +32,9 @@  @@ -32,6 +32,7 @@
741   #include <asm/unistd.h>   #include <asm/unistd.h>
742   #include <asm/siginfo.h>   #include <asm/siginfo.h>
743   #include "audit.h"     /* audit_signal_info() */   #include "audit.h"     /* audit_signal_info() */
 +/***** TOMOYO Linux start. *****/  
744  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
745    
746   /*   /*
747    * SLAB caches for signal bits.    * SLAB caches for signal bits.
748  @@ -2232,6 +2235,12 @@ asmlinkage long  @@ -2232,6 +2233,10 @@ asmlinkage long
749   sys_kill(int pid, int sig)   sys_kill(int pid, int sig)
750   {   {
751          struct siginfo info;          struct siginfo info;
 +       /***** TOMOYO Linux start. *****/  
752  +       if (sig && !ccs_capable(CCS_SYS_KILL))  +       if (sig && !ccs_capable(CCS_SYS_KILL))
753  +               return -EPERM;  +               return -EPERM;
754  +       if (sig && ccs_check_signal_acl(sig, pid))  +       if (sig && ccs_check_signal_acl(sig, pid))
755  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
756    
757          info.si_signo = sig;          info.si_signo = sig;
758          info.si_errno = 0;          info.si_errno = 0;
759  @@ -2290,6 +2299,12 @@ asmlinkage long sys_tgkill(int tgid, int  @@ -2290,6 +2295,10 @@ asmlinkage long sys_tgkill(int tgid, int
760          /* This is only valid for single tasks */          /* This is only valid for single tasks */
761          if (pid <= 0 || tgid <= 0)          if (pid <= 0 || tgid <= 0)
762                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
763  +       if (sig && !ccs_capable(CCS_SYS_KILL))  +       if (sig && !ccs_capable(CCS_SYS_KILL))
764  +               return -EPERM;  +               return -EPERM;
765  +       if (sig && ccs_check_signal_acl(sig, pid))  +       if (sig && ccs_check_signal_acl(sig, pid))
766  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
767    
768          return do_tkill(tgid, pid, sig);          return do_tkill(tgid, pid, sig);
769   }   }
770  @@ -2303,6 +2318,12 @@ sys_tkill(int pid, int sig)  @@ -2303,6 +2312,10 @@ sys_tkill(int pid, int sig)
771          /* This is only valid for single tasks */          /* This is only valid for single tasks */
772          if (pid <= 0)          if (pid <= 0)
773                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
774  +       if (sig && !ccs_capable(CCS_SYS_KILL))  +       if (sig && !ccs_capable(CCS_SYS_KILL))
775  +               return -EPERM;  +               return -EPERM;
776  +       if (sig && ccs_check_signal_acl(sig, pid))  +       if (sig && ccs_check_signal_acl(sig, pid))
777  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
778    
779          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
780   }   }
781  --- linux-2.6.25.20-0.4.orig/kernel/sys.c  --- linux-2.6.25.20-0.4.orig/kernel/sys.c
782  +++ linux-2.6.25.20-0.4/kernel/sys.c  +++ linux-2.6.25.20-0.4/kernel/sys.c
783  @@ -42,6 +42,9 @@  @@ -42,6 +42,7 @@
784   #include <asm/uaccess.h>   #include <asm/uaccess.h>
785   #include <asm/io.h>   #include <asm/io.h>
786   #include <asm/unistd.h>   #include <asm/unistd.h>
 +/***** TOMOYO Linux start. *****/  
787  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
788    
789   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
790   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
791  @@ -140,6 +143,12 @@ asmlinkage long sys_setpriority(int whic  @@ -140,6 +141,10 @@ asmlinkage long sys_setpriority(int whic
792    
793          if (which > PRIO_USER || which < PRIO_PROCESS)          if (which > PRIO_USER || which < PRIO_PROCESS)
794                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
795  +       if (!ccs_capable(CCS_SYS_NICE)) {  +       if (!ccs_capable(CCS_SYS_NICE)) {
796  +               error = -EPERM;  +               error = -EPERM;
797  +               goto out;  +               goto out;
798  +       }  +       }
 +       /***** TOMOYO Linux end. *****/  
799    
800          /* normalize: avoid signed division (rounding problems) */          /* normalize: avoid signed division (rounding problems) */
801          error = -ESRCH;          error = -ESRCH;
802  @@ -376,6 +385,10 @@ asmlinkage long sys_reboot(int magic1, i  @@ -376,6 +381,8 @@ asmlinkage long sys_reboot(int magic1, i
803                          magic2 != LINUX_REBOOT_MAGIC2B &&                          magic2 != LINUX_REBOOT_MAGIC2B &&
804                          magic2 != LINUX_REBOOT_MAGIC2C))                          magic2 != LINUX_REBOOT_MAGIC2C))
805                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
806  +       if (!ccs_capable(CCS_SYS_REBOOT))  +       if (!ccs_capable(CCS_SYS_REBOOT))
807  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
808    
809          /* Instead of trying to make the power_off code look like          /* Instead of trying to make the power_off code look like
810           * halt when pm_power_off is not set do it the easy way.           * halt when pm_power_off is not set do it the easy way.
811  @@ -1347,6 +1360,10 @@ asmlinkage long sys_sethostname(char __u  @@ -1347,6 +1354,8 @@ asmlinkage long sys_sethostname(char __u
812                  return -EPERM;                  return -EPERM;
813          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
814                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
815  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))
816  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
817          down_write(&uts_sem);          down_write(&uts_sem);
818          errno = -EFAULT;          errno = -EFAULT;
819          if (!copy_from_user(tmp, name, len)) {          if (!copy_from_user(tmp, name, len)) {
820  @@ -1392,6 +1409,10 @@ asmlinkage long sys_setdomainname(char _  @@ -1392,6 +1401,8 @@ asmlinkage long sys_setdomainname(char _
821                  return -EPERM;                  return -EPERM;
822          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
823                  return -EINVAL;                  return -EINVAL;
 +       /***** TOMOYO Linux start. *****/  
824  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))  +       if (!ccs_capable(CCS_SYS_SETHOSTNAME))
825  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
826    
827          down_write(&uts_sem);          down_write(&uts_sem);
828          errno = -EFAULT;          errno = -EFAULT;
829  --- linux-2.6.25.20-0.4.orig/kernel/sysctl.c  --- linux-2.6.25.20-0.4.orig/kernel/sysctl.c
830  +++ linux-2.6.25.20-0.4/kernel/sysctl.c  +++ linux-2.6.25.20-0.4/kernel/sysctl.c
831  @@ -48,6 +48,9 @@  @@ -48,6 +48,7 @@
832    
833   #include <asm/uaccess.h>   #include <asm/uaccess.h>
834   #include <asm/processor.h>   #include <asm/processor.h>
 +/***** TOMOYO Linux start. *****/  
835  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
836    
837   #ifdef CONFIG_X86   #ifdef CONFIG_X86
838   #include <asm/nmi.h>   #include <asm/nmi.h>
839  @@ -1500,6 +1503,7 @@ char *sysctl_pathname(struct ctl_table *  @@ -1500,6 +1501,7 @@ char *sysctl_pathname(struct ctl_table *
840   EXPORT_SYMBOL_GPL(sysctl_pathname);   EXPORT_SYMBOL_GPL(sysctl_pathname);
841    
842   #ifdef CONFIG_SYSCTL_SYSCALL   #ifdef CONFIG_SYSCTL_SYSCALL
# Line 1004  Source code for this patch is http://dow Line 844  Source code for this patch is http://dow
844   int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,   int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
845                 void __user *newval, size_t newlen)                 void __user *newval, size_t newlen)
846   {   {
847  @@ -1516,6 +1520,11 @@ int do_sysctl(int __user *name, int nlen  @@ -1516,6 +1518,9 @@ int do_sysctl(int __user *name, int nlen
848    
849          for (head = sysctl_head_next(NULL); head;          for (head = sysctl_head_next(NULL); head;
850                          head = sysctl_head_next(head)) {                          head = sysctl_head_next(head)) {
 +               /***** TOMOYO Linux start. *****/  
851  +               error = ccs_parse_table(name, nlen, oldval, newval,  +               error = ccs_parse_table(name, nlen, oldval, newval,
852  +                                       head->ctl_table);  +                                       head->ctl_table);
853  +               if (!error)  +               if (!error)
 +               /***** TOMOYO Linux end. *****/  
854                  error = parse_table(name, nlen, oldval, oldlenp,                  error = parse_table(name, nlen, oldval, oldlenp,
855                                          newval, newlen, head->ctl_table);                                          newval, newlen, head->ctl_table);
856                  if (error != -ENOTDIR) {                  if (error != -ENOTDIR) {
857  --- linux-2.6.25.20-0.4.orig/kernel/time.c  --- linux-2.6.25.20-0.4.orig/kernel/time.c
858  +++ linux-2.6.25.20-0.4/kernel/time.c  +++ linux-2.6.25.20-0.4/kernel/time.c
859  @@ -38,6 +38,9 @@  @@ -38,6 +38,7 @@
860    
861   #include <asm/uaccess.h>   #include <asm/uaccess.h>
862   #include <asm/unistd.h>   #include <asm/unistd.h>
 +/***** TOMOYO Linux start. *****/  
863  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
864    
865   #include "timeconst.h"   #include "timeconst.h"
866    
867  @@ -88,6 +91,10 @@ asmlinkage long sys_stime(time_t __user  @@ -88,6 +89,8 @@ asmlinkage long sys_stime(time_t __user
868          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
869          if (err)          if (err)
870                  return err;                  return err;
 +       /***** TOMOYO Linux start. *****/  
871  +       if (!ccs_capable(CCS_SYS_SETTIME))  +       if (!ccs_capable(CCS_SYS_SETTIME))
872  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
873    
874          do_settimeofday(&tv);          do_settimeofday(&tv);
875          return 0;          return 0;
876  @@ -159,6 +166,10 @@ int do_sys_settimeofday(struct timespec  @@ -159,6 +162,8 @@ int do_sys_settimeofday(struct timespec
877          error = security_settime(tv, tz);          error = security_settime(tv, tz);
878          if (error)          if (error)
879                  return error;                  return error;
 +       /***** TOMOYO Linux start. *****/  
880  +       if (!ccs_capable(CCS_SYS_SETTIME))  +       if (!ccs_capable(CCS_SYS_SETTIME))
881  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
882    
883          if (tz) {          if (tz) {
884                  /* SMP safe, global irq locking makes it work. */                  /* SMP safe, global irq locking makes it work. */
885  --- linux-2.6.25.20-0.4.orig/kernel/time/ntp.c  --- linux-2.6.25.20-0.4.orig/kernel/time/ntp.c
886  +++ linux-2.6.25.20-0.4/kernel/time/ntp.c  +++ linux-2.6.25.20-0.4/kernel/time/ntp.c
887  @@ -17,6 +17,9 @@  @@ -17,6 +17,7 @@
888   #include <linux/capability.h>   #include <linux/capability.h>
889   #include <asm/div64.h>   #include <asm/div64.h>
890   #include <asm/timex.h>   #include <asm/timex.h>
 +/***** TOMOYO Linux start. *****/  
891  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
892    
893   /*   /*
894    * Timekeeping variables    * Timekeeping variables
895  @@ -243,6 +246,10 @@ int do_adjtimex(struct timex *txc)  @@ -243,6 +244,8 @@ int do_adjtimex(struct timex *txc)
896          /* In order to modify anything, you gotta be super-user! */          /* In order to modify anything, you gotta be super-user! */
897          if (txc->modes && !capable(CAP_SYS_TIME))          if (txc->modes && !capable(CAP_SYS_TIME))
898                  return -EPERM;                  return -EPERM;
 +       /***** TOMOYO Linux start. *****/  
899  +       if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))  +       if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
900  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
901    
902          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
903    
904  --- linux-2.6.25.20-0.4.orig/net/ipv4/inet_connection_sock.c  --- linux-2.6.25.20-0.4.orig/net/ipv4/inet_connection_sock.c
905  +++ linux-2.6.25.20-0.4/net/ipv4/inet_connection_sock.c  +++ linux-2.6.25.20-0.4/net/ipv4/inet_connection_sock.c
906  @@ -23,6 +23,9 @@  @@ -23,6 +23,7 @@
907   #include <net/route.h>   #include <net/route.h>
908   #include <net/tcp_states.h>   #include <net/tcp_states.h>
909   #include <net/xfrm.h>   #include <net/xfrm.h>
 +/***** SAKURA Linux start. *****/  
910  +#include <linux/sakura.h>  +#include <linux/sakura.h>
 +/***** SAKURA Linux end. *****/  
911    
912   #ifdef INET_CSK_DEBUG   #ifdef INET_CSK_DEBUG
913   const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";   const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
914  @@ -98,6 +101,10 @@ int inet_csk_get_port(struct sock *sk, u  @@ -98,6 +99,8 @@ int inet_csk_get_port(struct sock *sk, u
915                  do {                  do {
916                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
917                          spin_lock(&head->lock);                          spin_lock(&head->lock);
 +                       /***** SAKURA Linux start. *****/  
918  +                       if (ccs_lport_reserved(rover))  +                       if (ccs_lport_reserved(rover))
919  +                               goto next;  +                               goto next;
 +                       /***** SAKURA Linux end. *****/  
920                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
921                                  if (tb->ib_net == net && tb->port == rover)                                  if (tb->ib_net == net && tb->port == rover)
922                                          goto next;                                          goto next;
923  --- linux-2.6.25.20-0.4.orig/net/ipv4/inet_hashtables.c  --- linux-2.6.25.20-0.4.orig/net/ipv4/inet_hashtables.c
924  +++ linux-2.6.25.20-0.4/net/ipv4/inet_hashtables.c  +++ linux-2.6.25.20-0.4/net/ipv4/inet_hashtables.c
925  @@ -22,6 +22,9 @@  @@ -22,6 +22,7 @@
926   #include <net/inet_connection_sock.h>   #include <net/inet_connection_sock.h>
927   #include <net/inet_hashtables.h>   #include <net/inet_hashtables.h>
928   #include <net/ip.h>   #include <net/ip.h>
 +/***** SAKURA Linux start. *****/  
929  +#include <linux/sakura.h>  +#include <linux/sakura.h>
 +/***** SAKURA Linux end. *****/  
930    
931   /*   /*
932    * Allocate and initialize a new local port bind bucket.    * Allocate and initialize a new local port bind bucket.
933  @@ -421,6 +424,10 @@ int __inet_hash_connect(struct inet_time  @@ -421,6 +422,8 @@ int __inet_hash_connect(struct inet_time
934                  local_bh_disable();                  local_bh_disable();
935                  for (i = 1; i <= remaining; i++) {                  for (i = 1; i <= remaining; i++) {
936                          port = low + (i + offset) % remaining;                          port = low + (i + offset) % remaining;
 +                       /***** SAKURA Linux start. *****/  
937  +                       if (ccs_lport_reserved(port))  +                       if (ccs_lport_reserved(port))
938  +                               continue;  +                               continue;
 +                       /***** SAKURA Linux end. *****/  
939                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
940                          spin_lock(&head->lock);                          spin_lock(&head->lock);
941    
942  --- linux-2.6.25.20-0.4.orig/net/ipv4/raw.c  --- linux-2.6.25.20-0.4.orig/net/ipv4/raw.c
943  +++ linux-2.6.25.20-0.4/net/ipv4/raw.c  +++ linux-2.6.25.20-0.4/net/ipv4/raw.c
944  @@ -79,6 +79,9 @@  @@ -79,6 +79,7 @@
945   #include <linux/seq_file.h>   #include <linux/seq_file.h>
946   #include <linux/netfilter.h>   #include <linux/netfilter.h>
947   #include <linux/netfilter_ipv4.h>   #include <linux/netfilter_ipv4.h>
 +/***** TOMOYO Linux start. *****/  
948  +#include <linux/tomoyo_socket.h>  +#include <linux/tomoyo_socket.h>
 +/***** TOMOYO Linux end. *****/  
949    
950   static struct raw_hashinfo raw_v4_hashinfo = {   static struct raw_hashinfo raw_v4_hashinfo = {
951          .lock = __RW_LOCK_UNLOCKED(),          .lock = __RW_LOCK_UNLOCKED(),
952  @@ -668,6 +671,11 @@ static int raw_recvmsg(struct kiocb *ioc  @@ -668,6 +669,9 @@ static int raw_recvmsg(struct kiocb *ioc
953          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
954          if (!skb)          if (!skb)
955                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
956  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
957  +       if (err)  +       if (err)
958  +               goto out;  +               goto out;
 +       /***** TOMOYO Linux end. *****/  
959    
960          copied = skb->len;          copied = skb->len;
961          if (len < copied) {          if (len < copied) {
962  --- linux-2.6.25.20-0.4.orig/net/ipv4/udp.c  --- linux-2.6.25.20-0.4.orig/net/ipv4/udp.c
963  +++ linux-2.6.25.20-0.4/net/ipv4/udp.c  +++ linux-2.6.25.20-0.4/net/ipv4/udp.c
964  @@ -105,6 +105,12 @@  @@ -105,6 +105,8 @@
965   #include <net/checksum.h>   #include <net/checksum.h>
966   #include <net/xfrm.h>   #include <net/xfrm.h>
967   #include "udp_impl.h"   #include "udp_impl.h"
 +/***** SAKURA Linux start. *****/  
968  +#include <linux/sakura.h>  +#include <linux/sakura.h>
 +/***** SAKURA Linux end. *****/  
 +/***** TOMOYO Linux start. *****/  
969  +#include <linux/tomoyo_socket.h>  +#include <linux/tomoyo_socket.h>
 +/***** TOMOYO Linux end. *****/  
970    
971   /*   /*
972    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
973  @@ -176,6 +182,10 @@ int __udp_lib_get_port(struct sock *sk,  @@ -176,6 +178,8 @@ int __udp_lib_get_port(struct sock *sk,
974                  /* 1st pass: look for empty (or shortest) hash chain */                  /* 1st pass: look for empty (or shortest) hash chain */
975                  for (i = 0; i < UDP_HTABLE_SIZE; i++) {                  for (i = 0; i < UDP_HTABLE_SIZE; i++) {
976                          int size = 0;                          int size = 0;
 +                       /***** SAKURA Linux start. *****/  
977  +                       if (ccs_lport_reserved(rover))  +                       if (ccs_lport_reserved(rover))
978  +                               goto next;  +                               goto next;
 +                       /***** SAKURA Linux end. *****/  
979    
980                          head = &udptable[rover & (UDP_HTABLE_SIZE - 1)];                          head = &udptable[rover & (UDP_HTABLE_SIZE - 1)];
981                          if (hlist_empty(head))                          if (hlist_empty(head))
982  @@ -199,6 +209,9 @@ int __udp_lib_get_port(struct sock *sk,  @@ -199,6 +203,7 @@ int __udp_lib_get_port(struct sock *sk,
983                  /* 2nd pass: find hole in shortest hash chain */                  /* 2nd pass: find hole in shortest hash chain */
984                  rover = best;                  rover = best;
985                  for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) {                  for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) {
 +                       /***** SAKURA Linux start. *****/  
986  +                       if (!ccs_lport_reserved(rover))  +                       if (!ccs_lport_reserved(rover))
 +                       /***** SAKURA Linux end. *****/  
987                          if (! __udp_lib_lport_inuse(net, rover, udptable))                          if (! __udp_lib_lport_inuse(net, rover, udptable))
988                                  goto gotit;                                  goto gotit;
989                          rover += UDP_HTABLE_SIZE;                          rover += UDP_HTABLE_SIZE;
990  @@ -863,6 +876,11 @@ try_again:  @@ -863,6 +868,9 @@ try_again:
991                                    &peeked, &err);                                    &peeked, &err);
992          if (!skb)          if (!skb)
993                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
994  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
995  +       if (err)  +       if (err)
996  +               goto out;  +               goto out;
 +       /***** TOMOYO Linux end. *****/  
997    
998          ulen = skb->len - sizeof(struct udphdr);          ulen = skb->len - sizeof(struct udphdr);
999          copied = len;          copied = len;
1000  --- linux-2.6.25.20-0.4.orig/net/ipv6/raw.c  --- linux-2.6.25.20-0.4.orig/net/ipv6/raw.c
1001  +++ linux-2.6.25.20-0.4/net/ipv6/raw.c  +++ linux-2.6.25.20-0.4/net/ipv6/raw.c
1002  @@ -60,6 +60,9 @@  @@ -60,6 +60,7 @@
1003    
1004   #include <linux/proc_fs.h>   #include <linux/proc_fs.h>
1005   #include <linux/seq_file.h>   #include <linux/seq_file.h>
 +/***** TOMOYO Linux start. *****/  
1006  +#include <linux/tomoyo_socket.h>  +#include <linux/tomoyo_socket.h>
 +/***** TOMOYO Linux end. *****/  
1007    
1008   static struct raw_hashinfo raw_v6_hashinfo = {   static struct raw_hashinfo raw_v6_hashinfo = {
1009          .lock = __RW_LOCK_UNLOCKED(),          .lock = __RW_LOCK_UNLOCKED(),
1010  @@ -482,6 +485,11 @@ static int rawv6_recvmsg(struct kiocb *i  @@ -482,6 +483,9 @@ static int rawv6_recvmsg(struct kiocb *i
1011          skb = skb_recv_datagram(sk, flags, noblock, &err);          skb = skb_recv_datagram(sk, flags, noblock, &err);
1012          if (!skb)          if (!skb)
1013                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
1014  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
1015  +       if (err)  +       if (err)
1016  +               goto out;  +               goto out;
 +       /***** TOMOYO Linux end. *****/  
1017    
1018          copied = skb->len;          copied = skb->len;
1019          if (copied > len) {          if (copied > len) {
1020  --- linux-2.6.25.20-0.4.orig/net/ipv6/udp.c  --- linux-2.6.25.20-0.4.orig/net/ipv6/udp.c
1021  +++ linux-2.6.25.20-0.4/net/ipv6/udp.c  +++ linux-2.6.25.20-0.4/net/ipv6/udp.c
1022  @@ -50,6 +50,9 @@  @@ -50,6 +50,7 @@
1023   #include <linux/proc_fs.h>   #include <linux/proc_fs.h>
1024   #include <linux/seq_file.h>   #include <linux/seq_file.h>
1025   #include "udp_impl.h"   #include "udp_impl.h"
 +/***** TOMOYO Linux start. *****/  
1026  +#include <linux/tomoyo_socket.h>  +#include <linux/tomoyo_socket.h>
 +/***** TOMOYO Linux end. *****/  
1027    
1028   static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)   static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
1029   {   {
1030  @@ -137,6 +140,11 @@ try_again:  @@ -137,6 +138,9 @@ try_again:
1031                                    &peeked, &err);                                    &peeked, &err);
1032          if (!skb)          if (!skb)
1033                  goto out;                  goto out;
 +       /***** TOMOYO Linux start. *****/  
1034  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);  +       err = ccs_socket_recvmsg_permission(sk, skb, flags);
1035  +       if (err)  +       if (err)
1036  +               goto out;  +               goto out;
 +       /***** TOMOYO Linux end. *****/  
1037    
1038          ulen = skb->len - sizeof(struct udphdr);          ulen = skb->len - sizeof(struct udphdr);
1039          copied = len;          copied = len;
1040  --- linux-2.6.25.20-0.4.orig/net/socket.c  --- linux-2.6.25.20-0.4.orig/net/socket.c
1041  +++ linux-2.6.25.20-0.4/net/socket.c  +++ linux-2.6.25.20-0.4/net/socket.c
1042  @@ -94,6 +94,11 @@  @@ -94,6 +94,9 @@
1043   #include <net/sock.h>   #include <net/sock.h>
1044   #include <linux/netfilter.h>   #include <linux/netfilter.h>
1045    
 +/***** TOMOYO Linux start. *****/  
1046  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
1047  +#include <linux/tomoyo_socket.h>  +#include <linux/tomoyo_socket.h>
 +/***** TOMOYO Linux end. *****/  
1048  +  +
1049   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1050   static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,   static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
1051                           unsigned long nr_segs, loff_t pos);                           unsigned long nr_segs, loff_t pos);
1052  @@ -557,6 +562,12 @@ static inline int __sock_sendmsg(struct  @@ -557,6 +560,10 @@ static inline int __sock_sendmsg(struct
1053          err = security_socket_sendmsg(sock, msg, size);          err = security_socket_sendmsg(sock, msg, size);
1054          if (err)          if (err)
1055                  return err;                  return err;
 +       /***** TOMOYO Linux start. *****/  
1056  +       if (ccs_socket_sendmsg_permission(sock,  +       if (ccs_socket_sendmsg_permission(sock,
1057  +                                         (struct sockaddr *) msg->msg_name,  +                                         (struct sockaddr *) msg->msg_name,
1058  +                                         msg->msg_namelen))  +                                         msg->msg_namelen))
1059  +               return -EPERM;  +               return -EPERM;
 +       /***** TOMOYO Linux end. *****/  
1060    
1061          return sock->ops->sendmsg(iocb, sock, msg, size);          return sock->ops->sendmsg(iocb, sock, msg, size);
1062   }   }
1063  @@ -1120,6 +1131,12 @@ static int __sock_create(struct net *net  @@ -1120,6 +1127,10 @@ static int __sock_create(struct net *net
1064                  family = PF_PACKET;                  family = PF_PACKET;
1065          }          }
1066    
 +       /***** TOMOYO Linux start. *****/  
1067  +       err = ccs_socket_create_permission(family, type, protocol);  +       err = ccs_socket_create_permission(family, type, protocol);
1068  +       if (err)  +       if (err)
1069  +               return err;  +               return err;
 +       /***** TOMOYO Linux end. *****/  
1070  +  +
1071          err = security_socket_create(family, type, protocol, kern);          err = security_socket_create(family, type, protocol, kern);
1072          if (err)          if (err)
1073                  return err;                  return err;
1074  @@ -1351,6 +1368,13 @@ asmlinkage long sys_bind(int fd, struct  @@ -1352,6 +1363,11 @@ asmlinkage long sys_bind(int fd, struct
                         err = security_socket_bind(sock,  
1075                                                     (struct sockaddr *)address,                                                     (struct sockaddr *)address,
1076                                                     addrlen);                                                     addrlen);
1077  +                       /***** TOMOYO Linux start. *****/                          if (!err)
 +                       if (!err)  
1078  +                               err = ccs_socket_bind_permission(sock,  +                               err = ccs_socket_bind_permission(sock,
1079  +                                                        (struct sockaddr *)  +                                                        (struct sockaddr *)
1080  +                                                                address,  +                                                                address,
1081  +                                                                addrlen);  +                                                                addrlen);
1082  +                       /***** TOMOYO Linux end. *****/  +                       if (!err)
                         if (!err)  
1083                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
1084                                                        (struct sockaddr *)                                                        (struct sockaddr *)
1085  @@ -1380,6 +1404,10 @@ asmlinkage long sys_listen(int fd, int b                                                        address, addrlen);
1086                          backlog = somaxconn;  @@ -1381,6 +1397,8 @@ asmlinkage long sys_listen(int fd, int b
1087    
1088                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
 +               /***** TOMOYO Linux start. *****/  
 +               if (!err)  
 +                       err = ccs_socket_listen_permission(sock);  
 +               /***** TOMOYO Linux end. *****/  
1089                  if (!err)                  if (!err)
1090    +                       err = ccs_socket_listen_permission(sock);
1091    +               if (!err)
1092                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
1093    
1094  @@ -1444,6 +1472,13 @@ asmlinkage long sys_accept(int fd, struc                  fput_light(sock->file, fput_needed);
1095    @@ -1444,6 +1462,11 @@ asmlinkage long sys_accept(int fd, struc
1096          if (err < 0)          if (err < 0)
1097                  goto out_fd;                  goto out_fd;
1098    
 +       /***** TOMOYO Linux start. *****/  
1099  +       if (ccs_socket_accept_permission(newsock,  +       if (ccs_socket_accept_permission(newsock,
1100  +                                        (struct sockaddr *) address)) {  +                                        (struct sockaddr *) address)) {
1101  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1102  +               goto out_fd;  +               goto out_fd;
1103  +       }  +       }
 +       /***** TOMOYO Linux end. *****/  
1104          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1105                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1106                                            &len, 2) < 0) {                                            &len, 2) < 0) {
1107  @@ -1508,6 +1543,12 @@ asmlinkage long sys_connect(int fd, stru  @@ -1508,6 +1531,10 @@ asmlinkage long sys_connect(int fd, stru
1108              security_socket_connect(sock, (struct sockaddr *)address, addrlen);              security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1109          if (err)          if (err)
1110                  goto out_put;                  goto out_put;
 +       /***** TOMOYO Linux start. *****/  
1111  +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,  +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1112  +                                           addrlen);  +                                           addrlen);
1113  +       if (err)  +       if (err)
1114  +               goto out_put;  +               goto out_put;
 +       /***** TOMOYO Linux end. *****/  
1115    
1116          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
1117                                   sock->file->f_flags);                                   sock->file->f_flags);
1118  --- linux-2.6.25.20-0.4.orig/net/unix/af_unix.c  --- linux-2.6.25.20-0.4.orig/net/unix/af_unix.c
1119  +++ linux-2.6.25.20-0.4/net/unix/af_unix.c  +++ linux-2.6.25.20-0.4/net/unix/af_unix.c
1120  @@ -116,6 +116,9 @@  @@ -116,6 +116,7 @@
1121   #include <linux/mount.h>   #include <linux/mount.h>
1122   #include <net/checksum.h>   #include <net/checksum.h>
1123   #include <linux/security.h>   #include <linux/security.h>
 +/***** TOMOYO Linux start. *****/  
1124  +#include <linux/tomoyo.h>  +#include <linux/tomoyo.h>
 +/***** TOMOYO Linux end. *****/  
1125    
1126   static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];   static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
1127   static DEFINE_SPINLOCK(unix_table_lock);   static DEFINE_SPINLOCK(unix_table_lock);
1128  @@ -819,6 +822,11 @@ static int unix_bind(struct socket *sock  @@ -819,6 +820,9 @@ static int unix_bind(struct socket *sock
1129                   */                   */
1130                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1131                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
 +               /***** TOMOYO Linux start. *****/  
1132  +               err = ccs_check_mknod_permission(nd.path.dentry->d_inode,  +               err = ccs_check_mknod_permission(nd.path.dentry->d_inode,
1133  +                                                dentry, nd.path.mnt, mode, 0);  +                                                dentry, nd.path.mnt, mode, 0);
1134  +               if (!err)  +               if (!err)
 +               /***** TOMOYO Linux end. *****/  
1135                  err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt,                  err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt,
1136                                  mode, 0);                                  mode, 0);
1137                  if (err)                  if (err)

Legend:
Removed from v.2794  
changed lines
  Added in v.2796

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