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

Subversion リポジトリの参照

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

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

revision 1055 by kumaneko, Tue Mar 25 09:01:31 2008 UTC revision 1128 by kumaneko, Tue Apr 22 12:51:52 2008 UTC
# Line 3  This is TOMOYO Linux patch for kernel 2. Line 3  This is TOMOYO Linux patch for kernel 2.
3  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.tar.bz2  Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.tar.bz2
4  ---  ---
5   Makefile                        |    2   Makefile                        |    2
6   arch/alpha/kernel/ptrace.c      |    8 +++   arch/alpha/kernel/ptrace.c      |    9 +++
7   arch/ia64/ia32/sys_ia32.c       |    8 +++   arch/ia64/ia32/sys_ia32.c       |    9 +++
8   arch/ia64/kernel/ptrace.c       |    8 +++   arch/ia64/kernel/ptrace.c       |    9 +++
9   arch/m32r/kernel/ptrace.c       |    8 +++   arch/m32r/kernel/ptrace.c       |    9 +++
10   arch/mips/kernel/ptrace32.c     |    8 +++   arch/mips/kernel/ptrace32.c     |    9 +++
11   arch/powerpc/kernel/ptrace32.c  |    8 +++   arch/powerpc/kernel/ptrace32.c  |    9 +++
12   arch/s390/kernel/ptrace.c       |    8 +++   arch/s390/kernel/ptrace.c       |    9 +++
13   arch/sh64/kernel/ptrace.c       |    8 +++   arch/sh64/kernel/ptrace.c       |    9 +++
14   arch/sparc/kernel/ptrace.c      |   11 +++++   arch/sparc/kernel/ptrace.c      |   11 +++
15   arch/sparc64/kernel/ptrace.c    |   11 +++++   arch/sparc64/kernel/ptrace.c    |   11 +++
16   arch/x86_64/ia32/ptrace32.c     |    8 +++   arch/x86_64/ia32/ptrace32.c     |    9 +++
17   fs/Kconfig                      |    2   fs/Kconfig                      |    2
18   fs/Makefile                     |    2   fs/Makefile                     |    2
19   fs/attr.c                       |   11 +++++   fs/attr.c                       |   19 ++++++
20   fs/compat.c                     |    8 +++   fs/compat.c                     |   11 +++
21   fs/exec.c                       |   14 ++++++   fs/exec.c                       |   20 ++++++-
22   fs/fcntl.c                      |    7 +++   fs/fcntl.c                      |    9 +++
23   fs/ioctl.c                      |    6 ++   fs/ioctl.c                      |    7 ++
24   fs/namei.c                      |   60 +++++++++++++++++++++++++++++   fs/namei.c                      |  112 ++++++++++++++++++++++++++++++++++++++++
25   fs/namespace.c                  |   38 ++++++++++++++++++   fs/namespace.c                  |   49 +++++++++++++++++
26   fs/open.c                       |   21 ++++++++++   fs/open.c                       |   26 +++++++++
27   fs/proc/Makefile                |    3 +   fs/proc/Makefile                |    3 +
28   fs/proc/proc_misc.c             |    5 ++   fs/proc/proc_misc.c             |    5 +
29   include/linux/init_task.h       |    4 +   include/linux/init_task.h       |    4 +
30   include/linux/sched.h           |    9 ++++   include/linux/sched.h           |    9 +++
31   kernel/compat.c                 |    6 ++   kernel/compat.c                 |    7 ++
32   kernel/kexec.c                  |    6 ++   kernel/kexec.c                  |    7 ++
33   kernel/kmod.c                   |    5 ++   kernel/kmod.c                   |    5 +
34   kernel/module.c                 |    9 ++++   kernel/module.c                 |   11 +++
35   kernel/ptrace.c                 |    8 +++   kernel/ptrace.c                 |    9 +++
36   kernel/sched.c                  |    6 ++   kernel/sched.c                  |    7 ++
37   kernel/signal.c                 |   15 +++++++   kernel/signal.c                 |   21 +++++++
38   kernel/sys.c                    |   15 +++++++   kernel/sys.c                    |   19 ++++++
39   kernel/sysctl.c                 |   81 ++++++++++++++++++++++++++++++++++++++++   kernel/sysctl.c                 |   95 +++++++++++++++++++++++++++++++++
40   kernel/time.c                   |    9 ++++   kernel/time.c                   |   11 +++
41   kernel/time/ntp.c               |    6 ++   kernel/time/ntp.c               |    7 ++
42   net/core/datagram.c             |    9 ++++   net/core/datagram.c             |   11 +++
43   net/ipv4/inet_connection_sock.c |    6 ++   net/ipv4/inet_connection_sock.c |    7 ++
44   net/ipv4/inet_hashtables.c      |    6 ++   net/ipv4/inet_hashtables.c      |    7 ++
45   net/ipv4/udp.c                  |    9 ++++   net/ipv4/udp.c                  |   11 +++
46   net/ipv6/inet6_hashtables.c     |    6 ++   net/ipv6/inet6_hashtables.c     |    7 ++
47   net/socket.c                    |   28 +++++++++++++   net/socket.c                    |   41 ++++++++++++++
48   net/unix/af_unix.c              |   10 ++++   net/unix/af_unix.c              |   15 +++++
49   44 files changed, 523 insertions(+), 3 deletions(-)   44 files changed, 678 insertions(+), 3 deletions(-)
50    
51  --- linux-2.6.21.orig/Makefile  --- linux-2.6.21.orig/Makefile
52  +++ linux-2.6.21/Makefile  +++ linux-2.6.21/Makefile
# Line 71  Source code for this patch is http://www Line 71  Source code for this patch is http://www
71    
72   #include "proto.h"   #include "proto.h"
73    
74  @@ -268,6 +271,11 @@ do_sys_ptrace(long request, long pid, lo  @@ -268,6 +271,12 @@ do_sys_ptrace(long request, long pid, lo
75          unsigned long tmp;          unsigned long tmp;
76          size_t copied;          size_t copied;
77          long ret;          long ret;
78  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
79  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
80  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
81    +               return -EPERM;
82  +#endif  +#endif
83  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
84    
# Line 95  Source code for this patch is http://www Line 96  Source code for this patch is http://www
96    
97   #include "entry.h"   #include "entry.h"
98    
99  @@ -1418,6 +1421,11 @@ sys_ptrace (long request, pid_t pid, uns  @@ -1418,6 +1421,12 @@ sys_ptrace (long request, pid_t pid, uns
100          struct task_struct *child;          struct task_struct *child;
101          struct switch_stack *sw;          struct switch_stack *sw;
102          long ret;          long ret;
103  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
104  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
105  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
106    +               return -EPERM;
107  +#endif  +#endif
108  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
109    
# Line 119  Source code for this patch is http://www Line 121  Source code for this patch is http://www
121    
122   /*   /*
123    * This routine will get a word off of the process kernel stack.    * This routine will get a word off of the process kernel stack.
124  @@ -742,6 +745,11 @@ asmlinkage long sys_ptrace(long request,  @@ -742,6 +745,12 @@ asmlinkage long sys_ptrace(long request,
125   {   {
126          struct task_struct *child;          struct task_struct *child;
127          int ret;          int ret;
128  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
129  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
130  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
131    +               return -EPERM;
132  +#endif  +#endif
133  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
134    
# Line 143  Source code for this patch is http://www Line 146  Source code for this patch is http://www
146    
147   #ifdef CONFIG_COMPAT   #ifdef CONFIG_COMPAT
148   #include "compat_ptrace.h"   #include "compat_ptrace.h"
149  @@ -713,6 +716,11 @@ sys_ptrace(long request, long pid, long  @@ -713,6 +716,12 @@ sys_ptrace(long request, long pid, long
150          struct task_struct *child;          struct task_struct *child;
151          int ret;          int ret;
152    
153  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
154  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
155  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
156    +               return -EPERM;
157  +#endif  +#endif
158  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
159          lock_kernel();          lock_kernel();
# Line 239  Source code for this patch is http://www Line 243  Source code for this patch is http://www
243    
244   /* Taken over from the old code... */   /* Taken over from the old code... */
245    
246  @@ -145,12 +148,20 @@ int notify_change(struct dentry * dentry  @@ -145,12 +148,28 @@ int notify_change(struct dentry * dentry
247    
248          if (inode->i_op && inode->i_op->setattr) {          if (inode->i_op && inode->i_op->setattr) {
249                  error = security_inode_setattr(dentry, attr);                  error = security_inode_setattr(dentry, attr);
250  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
251  +               if (!error && (ia_valid & ATTR_MODE) && !ccs_capable(TOMOYO_SYS_CHMOD)) error = -EPERM;  +               if (!error && (ia_valid & ATTR_MODE) &&
252  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && !ccs_capable(TOMOYO_SYS_CHOWN)) error = -EPERM;  +                   !ccs_capable(TOMOYO_SYS_CHMOD))
253    +                       error = -EPERM;
254    +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
255    +                   !ccs_capable(TOMOYO_SYS_CHOWN))
256    +                       error = -EPERM;
257  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
258                  if (!error)                  if (!error)
259                          error = inode->i_op->setattr(dentry, attr);                          error = inode->i_op->setattr(dentry, attr);
# Line 254  Source code for this patch is http://www Line 262  Source code for this patch is http://www
262                  if (!error)                  if (!error)
263                          error = security_inode_setattr(dentry, attr);                          error = security_inode_setattr(dentry, attr);
264  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
265  +               if (!error && (ia_valid & ATTR_MODE) && !ccs_capable(TOMOYO_SYS_CHMOD)) error = -EPERM;  +               if (!error && (ia_valid & ATTR_MODE) &&
266  +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && !ccs_capable(TOMOYO_SYS_CHOWN)) error = -EPERM;  +                   !ccs_capable(TOMOYO_SYS_CHMOD))
267    +                       error = -EPERM;
268    +               if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
269    +                   !ccs_capable(TOMOYO_SYS_CHOWN))
270    +                       error = -EPERM;
271  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
272                  if (!error) {                  if (!error) {
273                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||                          if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
# Line 272  Source code for this patch is http://www Line 284  Source code for this patch is http://www
284    
285   int compat_log = 1;   int compat_log = 1;
286    
287  @@ -422,6 +425,9 @@ asmlinkage long compat_sys_ioctl(unsigne  @@ -422,6 +425,12 @@ asmlinkage long compat_sys_ioctl(unsigne
288                  /*FALL THROUGH*/                  /*FALL THROUGH*/
289    
290          default:          default:
291  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
292  +               if (!ccs_capable(TOMOYO_SYS_IOCTL)) { error = -EPERM; goto out_fput; }  +               if (!ccs_capable(TOMOYO_SYS_IOCTL)) {
293    +                       error = -EPERM;
294    +                       goto out_fput;
295    +               }
296  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
297                  if (filp->f_op && filp->f_op->compat_ioctl) {                  if (filp->f_op && filp->f_op->compat_ioctl) {
298                          error = filp->f_op->compat_ioctl(filp, cmd, arg);                          error = filp->f_op->compat_ioctl(filp, cmd, arg);
299                          if (error != -ENOIOCTLCMD)                          if (error != -ENOIOCTLCMD)
300  @@ -1552,7 +1558,7 @@ int compat_do_execve(char * filename,  @@ -1552,7 +1561,7 @@ int compat_do_execve(char * filename,
301          if (retval < 0)          if (retval < 0)
302                  goto out;                  goto out;
303    
# Line 304  Source code for this patch is http://www Line 319  Source code for this patch is http://www
319   int core_uses_pid;   int core_uses_pid;
320   char core_pattern[128] = "core";   char core_pattern[128] = "core";
321   int suid_dumpable = 0;   int suid_dumpable = 0;
322  @@ -140,6 +144,11 @@ asmlinkage long sys_uselib(const char __  @@ -140,6 +144,13 @@ asmlinkage long sys_uselib(const char __
323          if (error)          if (error)
324                  goto exit;                  goto exit;
325    
326  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
327  +       error = ccs_check_open_permission(nd.dentry, nd.mnt, 01); /* 01 means "read". */  +       /* 01 means "read". */
328  +       if (error) goto exit;  +       error = ccs_check_open_permission(nd.dentry, nd.mnt, 01);
329    +       if (error)
330    +               goto exit;
331  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
332  +  +
333          file = nameidata_to_filp(&nd, O_RDONLY);          file = nameidata_to_filp(&nd, O_RDONLY);
334          error = PTR_ERR(file);          error = PTR_ERR(file);
335          if (IS_ERR(file))          if (IS_ERR(file))
336  @@ -485,6 +494,9 @@ struct file *open_exec(const char *name)  @@ -485,6 +496,13 @@ struct file *open_exec(const char *name)
337                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&                  if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
338                      S_ISREG(inode->i_mode)) {                      S_ISREG(inode->i_mode)) {
339                          int err = vfs_permission(&nd, MAY_EXEC);                          int err = vfs_permission(&nd, MAY_EXEC);
340  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
341  +                       if (!err && (current->tomoyo_flags & TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) err = ccs_check_open_permission(nd.dentry, nd.mnt, 01); /* 01 means "read". */  +                       if (!err && (current->tomoyo_flags &
342    +                                    TOMOYO_CHECK_READ_FOR_OPEN_EXEC))
343    +                               /* 01 means "read". */
344    +                               err = ccs_check_open_permission(nd.dentry,
345    +                                                               nd.mnt, 01);
346  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
347                          file = ERR_PTR(err);                          file = ERR_PTR(err);
348                          if (!err) {                          if (!err) {
349                                  file = nameidata_to_filp(&nd, O_RDONLY);                                  file = nameidata_to_filp(&nd, O_RDONLY);
350  @@ -1183,7 +1195,7 @@ int do_execve(char * filename,  @@ -1183,7 +1201,7 @@ int do_execve(char * filename,
351          if (retval < 0)          if (retval < 0)
352                  goto out;                  goto out;
353    
354  -       retval = search_binary_handler(bprm,regs);  -       retval = search_binary_handler(bprm,regs);
355  +       retval = search_binary_handler_with_transition(bprm,regs);  +       retval = search_binary_handler_with_transition(bprm, regs);
356          if (retval >= 0) {          if (retval >= 0) {
357                  free_arg_pages(bprm);                  free_arg_pages(bprm);
358    
# Line 347  Source code for this patch is http://www Line 368  Source code for this patch is http://www
368    
369   void fastcall set_close_on_exec(unsigned int fd, int flag)   void fastcall set_close_on_exec(unsigned int fd, int flag)
370   {   {
371  @@ -213,6 +216,10 @@ static int setfl(int fd, struct file * f  @@ -213,6 +216,12 @@ static int setfl(int fd, struct file * f
372          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))          if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
373                  return -EPERM;                  return -EPERM;
374    
375  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
376  +       if (((arg ^ filp->f_flags) & O_APPEND) && ccs_check_rewrite_permission(filp)) return -EPERM;  +       if (((arg ^ filp->f_flags) & O_APPEND) &&
377    +           ccs_check_rewrite_permission(filp))
378    +               return -EPERM;
379  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
380  +  +
381          /* O_NOATIME can only be set by the owner or superuser */          /* O_NOATIME can only be set by the owner or superuser */
# Line 370  Source code for this patch is http://www Line 393  Source code for this patch is http://www
393    
394   static long do_ioctl(struct file *filp, unsigned int cmd,   static long do_ioctl(struct file *filp, unsigned int cmd,
395                  unsigned long arg)                  unsigned long arg)
396  @@ -23,6 +26,9 @@ static long do_ioctl(struct file *filp,  @@ -23,6 +26,10 @@ static long do_ioctl(struct file *filp,
397    
398          if (!filp->f_op)          if (!filp->f_op)
399                  goto out;                  goto out;
400  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
401  +       if (!ccs_capable(TOMOYO_SYS_IOCTL)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_IOCTL))
402    +               return -EPERM;
403  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
404    
405          if (filp->f_op->unlocked_ioctl) {          if (filp->f_op->unlocked_ioctl) {
# Line 393  Source code for this patch is http://www Line 417  Source code for this patch is http://www
417   /* [Feb-1997 T. Schoebel-Theuer]   /* [Feb-1997 T. Schoebel-Theuer]
418    * Fundamental changes in the pathname lookup mechanisms (namei)    * Fundamental changes in the pathname lookup mechanisms (namei)
419    * were necessary because of omirr.  The reason is that omirr needs    * were necessary because of omirr.  The reason is that omirr needs
420  @@ -1506,6 +1510,9 @@ int vfs_create(struct inode *dir, struct  @@ -1506,6 +1510,13 @@ int vfs_create(struct inode *dir, struct
421          error = security_inode_create(dir, dentry, mode);          error = security_inode_create(dir, dentry, mode);
422          if (error)          if (error)
423                  return error;                  return error;
424  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
425  +       if (nd && (error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;  +       if (nd) {
426    +               error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt);
427    +               if (error)
428    +                       return error;
429    +       }
430  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
431          DQUOT_INIT(dir);          DQUOT_INIT(dir);
432          error = dir->i_op->create(dir, dentry, mode, nd);          error = dir->i_op->create(dir, dentry, mode, nd);
433          if (!error)          if (!error)
434  @@ -1561,6 +1568,11 @@ int may_open(struct nameidata *nd, int a  @@ -1561,6 +1572,13 @@ int may_open(struct nameidata *nd, int a
435                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))                  if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
436                          return -EPERM;                          return -EPERM;
437    
438  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
439  +       error = ccs_check_open_permission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */  +       /* includes O_APPEND and O_TRUNC checks */
440  +       if (error) return error;  +       error = ccs_check_open_permission(dentry, nd->mnt, flag);
441    +       if (error)
442    +               return error;
443  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
444  +  +
445          /*          /*
446           * Ensure there are no outstanding leases on the file.           * Ensure there are no outstanding leases on the file.
447           */           */
448  @@ -1610,6 +1622,9 @@ static int open_namei_create(struct name  @@ -1610,6 +1628,9 @@ static int open_namei_create(struct name
449          return may_open(nd, 0, flag & ~O_TRUNC);          return may_open(nd, 0, flag & ~O_TRUNC);
450   }   }
451    
# Line 425  Source code for this patch is http://www Line 455  Source code for this patch is http://www
455   /*   /*
456    *     open_namei()    *     open_namei()
457    *    *
458  @@ -1870,6 +1885,12 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1870,6 +1891,16 @@ asmlinkage long sys_mknodat(int dfd, con
459    
460          if (S_ISDIR(mode))          if (S_ISDIR(mode))
461                  return -EPERM;                  return -EPERM;
462  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
463  +       if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;  +       if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV))
464  +       if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;  +               return -EPERM;
465  +       if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO)) return -EPERM;  +       if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV))
466  +       if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;  +               return -EPERM;
467    +       if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO))
468    +               return -EPERM;
469    +       if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
470    +               return -EPERM;
471  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
472          tmp = getname(filename);          tmp = getname(filename);
473          if (IS_ERR(tmp))          if (IS_ERR(tmp))
474                  return PTR_ERR(tmp);                  return PTR_ERR(tmp);
475  @@ -1888,10 +1909,16 @@ asmlinkage long sys_mknodat(int dfd, con  @@ -1888,10 +1919,32 @@ asmlinkage long sys_mknodat(int dfd, con
476                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);                          error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
477                          break;                          break;
478                  case S_IFCHR: case S_IFBLK:                  case S_IFCHR: case S_IFBLK:
479  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
480  +                       if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = ccs_check_1path_perm(S_ISCHR(mode) ? TYPE_MKCHAR_ACL : TYPE_MKBLOCK_ACL, dentry, nd.mnt)) == 0)  +                       error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
481    +                       if (error)
482    +                               break;
483    +                       error = ccs_check_1path_perm(S_ISCHR(mode) ?
484    +                                                    TYPE_MKCHAR_ACL :
485    +                                                    TYPE_MKBLOCK_ACL,
486    +                                                    dentry, nd.mnt);
487    +                       if (error)
488    +                               break;
489  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
490                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
491                                          new_decode_dev(dev));                                          new_decode_dev(dev));
492                          break;                          break;
493                  case S_IFIFO: case S_IFSOCK:                  case S_IFIFO: case S_IFSOCK:
494  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
495  +                       if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = ccs_check_1path_perm(S_ISFIFO(mode) ? TYPE_MKFIFO_ACL : TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)  +                       error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
496    +                       if (error)
497    +                               break;
498    +                       error = ccs_check_1path_perm(S_ISFIFO(mode) ?
499    +                                                    TYPE_MKFIFO_ACL :
500    +                                                    TYPE_MKSOCK_ACL,
501    +                                                    dentry, nd.mnt);
502    +                       if (error)
503    +                               break;
504  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
505                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);                          error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
506                          break;                          break;
507                  case S_IFDIR:                  case S_IFDIR:
508  @@ -1959,6 +1986,9 @@ asmlinkage long sys_mkdirat(int dfd, con  @@ -1959,6 +2012,12 @@ asmlinkage long sys_mkdirat(int dfd, con
509    
510          if (!IS_POSIXACL(nd.dentry->d_inode))          if (!IS_POSIXACL(nd.dentry->d_inode))
511                  mode &= ~current->fs->umask;                  mode &= ~current->fs->umask;
512  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
513  +       if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)  +       error = pre_vfs_mkdir(nd.dentry->d_inode, dentry);
514    +       if (!error)
515    +               error = ccs_check_1path_perm(TYPE_MKDIR_ACL, dentry, nd.mnt);
516    +       if (!error)
517  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
518          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);          error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
519          dput(dentry);          dput(dentry);
520   out_unlock:   out_unlock:
521  @@ -2066,6 +2096,9 @@ static long do_rmdir(int dfd, const char  @@ -2066,6 +2125,12 @@ static long do_rmdir(int dfd, const char
522          error = PTR_ERR(dentry);          error = PTR_ERR(dentry);
523          if (IS_ERR(dentry))          if (IS_ERR(dentry))
524                  goto exit2;                  goto exit2;
525  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
526  +       if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)  +       error = pre_vfs_rmdir(nd.dentry->d_inode, dentry);
527    +       if (!error)
528    +               error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, nd.mnt);
529    +       if (!error)
530  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
531          error = vfs_rmdir(nd.dentry->d_inode, dentry);          error = vfs_rmdir(nd.dentry->d_inode, dentry);
532          dput(dentry);          dput(dentry);
533   exit2:   exit2:
534  @@ -2125,6 +2158,9 @@ static long do_unlinkat(int dfd, const c  @@ -2125,6 +2190,10 @@ static long do_unlinkat(int dfd, const c
535          struct dentry *dentry;          struct dentry *dentry;
536          struct nameidata nd;          struct nameidata nd;
537          struct inode *inode = NULL;          struct inode *inode = NULL;
538  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
539  +       if (!ccs_capable(TOMOYO_SYS_UNLINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_UNLINK))
540    +               return -EPERM;
541  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
542    
543          name = getname(pathname);          name = getname(pathname);
544          if(IS_ERR(name))          if(IS_ERR(name))
545  @@ -2146,6 +2182,9 @@ static long do_unlinkat(int dfd, const c  @@ -2146,6 +2215,14 @@ static long do_unlinkat(int dfd, const c
546                  inode = dentry->d_inode;                  inode = dentry->d_inode;
547                  if (inode)                  if (inode)
548                          atomic_inc(&inode->i_count);                          atomic_inc(&inode->i_count);
549  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
550  +               if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)  +               error = pre_vfs_unlink(nd.dentry->d_inode, dentry);
551    +               if (error)
552    +                       goto exit2;
553    +               error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt);
554    +               if (error)
555    +                       goto exit2;
556  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
557                  error = vfs_unlink(nd.dentry->d_inode, dentry);                  error = vfs_unlink(nd.dentry->d_inode, dentry);
558          exit2:          exit2:
559                  dput(dentry);                  dput(dentry);
560  @@ -2210,6 +2249,9 @@ asmlinkage long sys_symlinkat(const char  @@ -2210,6 +2287,10 @@ asmlinkage long sys_symlinkat(const char
561          char * to;          char * to;
562          struct dentry *dentry;          struct dentry *dentry;
563          struct nameidata nd;          struct nameidata nd;
564  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
565  +       if (!ccs_capable(TOMOYO_SYS_SYMLINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SYMLINK))
566    +               return -EPERM;
567  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
568    
569          from = getname(oldname);          from = getname(oldname);
570          if(IS_ERR(from))          if(IS_ERR(from))
571  @@ -2227,6 +2269,9 @@ asmlinkage long sys_symlinkat(const char  @@ -2227,6 +2308,12 @@ asmlinkage long sys_symlinkat(const char
572          if (IS_ERR(dentry))          if (IS_ERR(dentry))
573                  goto out_unlock;                  goto out_unlock;
574    
575  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
576  +       if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)  +       error = pre_vfs_symlink(nd.dentry->d_inode, dentry);
577    +       if (!error)
578    +               error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, dentry, nd.mnt);
579    +       if (!error)
580  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
581          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);          error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
582          dput(dentry);          dput(dentry);
583   out_unlock:   out_unlock:
584  @@ -2299,6 +2344,9 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2299,6 +2386,10 @@ asmlinkage long sys_linkat(int olddfd, c
585          struct nameidata nd, old_nd;          struct nameidata nd, old_nd;
586          int error;          int error;
587          char * to;          char * to;
588  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
589  +       if (!ccs_capable(TOMOYO_SYS_LINK)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_LINK))
590    +               return -EPERM;
591  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
592    
593          if ((flags & ~AT_SYMLINK_FOLLOW) != 0)          if ((flags & ~AT_SYMLINK_FOLLOW) != 0)
594                  return -EINVAL;                  return -EINVAL;
595  @@ -2322,6 +2370,9 @@ asmlinkage long sys_linkat(int olddfd, c  @@ -2322,6 +2413,13 @@ asmlinkage long sys_linkat(int olddfd, c
596          error = PTR_ERR(new_dentry);          error = PTR_ERR(new_dentry);
597          if (IS_ERR(new_dentry))          if (IS_ERR(new_dentry))
598                  goto out_unlock;                  goto out_unlock;
599  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
600  +       if ((error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry)) == 0 && (error = ccs_check_2path_perm(TYPE_LINK_ACL, old_nd.dentry, old_nd.mnt, new_dentry, nd.mnt)) == 0)  +       error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
601    +       if (!error)
602    +               error = ccs_check_2path_perm(TYPE_LINK_ACL, old_nd.dentry,
603    +                                            old_nd.mnt, new_dentry, nd.mnt);
604    +       if (!error)
605  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
606          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);          error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
607          dput(new_dentry);          dput(new_dentry);
608   out_unlock:   out_unlock:
609  @@ -2547,6 +2598,12 @@ static int do_rename(int olddfd, const c  @@ -2547,6 +2645,16 @@ static int do_rename(int olddfd, const c
610          error = -ENOTEMPTY;          error = -ENOTEMPTY;
611          if (new_dentry == trap)          if (new_dentry == trap)
612                  goto exit5;                  goto exit5;
613  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
614  +       if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||  +       error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode,
615  +               (error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {  +                              new_dentry);
616    +       if (error)
617    +               goto exit5;
618    +       error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt,
619    +                                    new_dentry, newnd.mnt);
620    +       if (error)
621  +               goto exit5;  +               goto exit5;
 +       }  
622  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
623    
624          error = vfs_rename(old_dir->d_inode, old_dentry,          error = vfs_rename(old_dir->d_inode, old_dentry,
625                                     new_dir->d_inode, new_dentry);                                     new_dir->d_inode, new_dentry);
626  @@ -2570,6 +2627,9 @@ asmlinkage long sys_renameat(int olddfd,  @@ -2570,6 +2678,10 @@ asmlinkage long sys_renameat(int olddfd,
627          int error;          int error;
628          char * from;          char * from;
629          char * to;          char * to;
630  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
631  +       if (!ccs_capable(TOMOYO_SYS_RENAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_RENAME))
632    +               return -EPERM;
633  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
634    
635          from = getname(oldname);          from = getname(oldname);
# Line 573  Source code for this patch is http://www Line 649  Source code for this patch is http://www
649    
650   /* spinlock for vfsmount related operations, inplace of dcache_lock */   /* spinlock for vfsmount related operations, inplace of dcache_lock */
651   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);   __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
652  @@ -545,6 +551,10 @@ static int do_umount(struct vfsmount *mn  @@ -545,6 +551,11 @@ static int do_umount(struct vfsmount *mn
653          if (retval)          if (retval)
654                  return retval;                  return retval;
655    
656  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
657  +       if (ccs_may_umount(mnt) < 0) return -EPERM;  +       if (ccs_may_umount(mnt))
658    +               return -EPERM;
659  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
660  +  +
661          /*          /*
662           * Allow userspace to request a mountpoint be expired rather than           * Allow userspace to request a mountpoint be expired rather than
663           * unmounting unconditionally. Unmount only happens if:           * unmounting unconditionally. Unmount only happens if:
664  @@ -633,6 +643,9 @@ asmlinkage long sys_umount(char __user *  @@ -633,6 +644,10 @@ asmlinkage long sys_umount(char __user *
665   {   {
666          struct nameidata nd;          struct nameidata nd;
667          int retval;          int retval;
668  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
669  +       if (!ccs_capable(TOMOYO_SYS_UMOUNT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_UMOUNT))
670    +               return -EPERM;
671  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
672    
673          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);          retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
674          if (retval)          if (retval)
675  @@ -917,6 +930,10 @@ static int do_loopback(struct nameidata  @@ -917,6 +932,11 @@ static int do_loopback(struct nameidata
676    
677          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
678                  goto out;                  goto out;
679  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
680  +       err = -EPERM;  +       err = -EPERM;
681  +       if (ccs_may_mount(nd) < 0) goto out;  +       if (ccs_may_mount(nd))
682    +               goto out;
683  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
684    
685          err = -ENOMEM;          err = -ENOMEM;
686          if (recurse)          if (recurse)
687  @@ -1002,6 +1019,10 @@ static int do_move_mount(struct nameidat  @@ -1002,6 +1022,11 @@ static int do_move_mount(struct nameidat
688          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))          if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
689                  goto out;                  goto out;
690    
691  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
692  +       err = -EPERM;  +       err = -EPERM;
693  +       if (ccs_may_umount(old_nd.mnt) < 0 || ccs_may_mount(nd) < 0) goto out;  +       if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
694    +               goto out;
695  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
696          err = -ENOENT;          err = -ENOENT;
697          mutex_lock(&nd->dentry->d_inode->i_mutex);          mutex_lock(&nd->dentry->d_inode->i_mutex);
698          if (IS_DEADDIR(nd->dentry->d_inode))          if (IS_DEADDIR(nd->dentry->d_inode))
699  @@ -1103,6 +1124,10 @@ int do_add_mount(struct vfsmount *newmnt  @@ -1103,6 +1128,11 @@ int do_add_mount(struct vfsmount *newmnt
700          err = -EINVAL;          err = -EINVAL;
701          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))          if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
702                  goto unlock;                  goto unlock;
703  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
704  +       err = -EPERM;  +       err = -EPERM;
705  +       if (ccs_may_mount(nd) < 0) goto unlock;  +       if (ccs_may_mount(nd))
706    +               goto unlock;
707  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
708    
709          newmnt->mnt_flags = mnt_flags;          newmnt->mnt_flags = mnt_flags;
710          if ((err = graft_tree(newmnt, nd)))          if ((err = graft_tree(newmnt, nd)))
711  @@ -1394,6 +1419,13 @@ long do_mount(char *dev_name, char *dir_  @@ -1394,6 +1424,17 @@ long do_mount(char *dev_name, char *dir_
712          if (data_page)          if (data_page)
713                  ((char *)data_page)[PAGE_SIZE - 1] = 0;                  ((char *)data_page)[PAGE_SIZE - 1] = 0;
714    
715  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
716  +       if (!ccs_capable(TOMOYO_SYS_MOUNT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_MOUNT))
717    +               return -EPERM;
718  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
719  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
720  +       if ((retval = ccs_check_mount_permission(dev_name, dir_name, type_page, &flags)) < 0) return retval;  +       retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
721    +                                           &flags);
722    +       if (retval)
723    +               return retval;
724  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
725  +  +
726          /* Separate the per-mountpoint flags */          /* Separate the per-mountpoint flags */
727          if (flags & MS_NOSUID)          if (flags & MS_NOSUID)
728                  mnt_flags |= MNT_NOSUID;                  mnt_flags |= MNT_NOSUID;
729  @@ -1686,6 +1718,9 @@ asmlinkage long sys_pivot_root(const cha  @@ -1686,6 +1727,10 @@ asmlinkage long sys_pivot_root(const cha
730    
731          if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
732                  return -EPERM;                  return -EPERM;
733  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
734  +       if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT))
735    +               return -EPERM;
736  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
737    
738          lock_kernel();          lock_kernel();
739    
740  @@ -1702,6 +1737,9 @@ asmlinkage long sys_pivot_root(const cha  @@ -1702,6 +1747,10 @@ asmlinkage long sys_pivot_root(const cha
741                  goto out1;                  goto out1;
742    
743          error = security_sb_pivotroot(&old_nd, &new_nd);          error = security_sb_pivotroot(&old_nd, &new_nd);
744  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
745  +       if (!error) error = ccs_check_pivot_root_permission(&old_nd, &new_nd);  +       if (!error)
746    +               error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
747  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
748          if (error) {          if (error) {
749                  path_release(&old_nd);                  path_release(&old_nd);
# Line 676  Source code for this patch is http://www Line 763  Source code for this patch is http://www
763    
764   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)   int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
765   {   {
766  @@ -264,6 +270,9 @@ static long do_sys_truncate(const char _  @@ -264,6 +270,10 @@ static long do_sys_truncate(const char _
767          if (error)          if (error)
768                  goto dput_and_out;                  goto dput_and_out;
769    
770  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
771  +       if ((error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)  +       error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt);
772    +       if (!error)
773  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
774          error = locks_verify_truncate(inode, NULL, length);          error = locks_verify_truncate(inode, NULL, length);
775          if (!error) {          if (!error) {
776                  DQUOT_INIT(inode);                  DQUOT_INIT(inode);
777  @@ -317,6 +326,9 @@ static long do_sys_ftruncate(unsigned in  @@ -317,6 +327,10 @@ static long do_sys_ftruncate(unsigned in
778          if (IS_APPEND(inode))          if (IS_APPEND(inode))
779                  goto out_putf;                  goto out_putf;
780    
781  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
782  +       if ((error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)  +       error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt);
783    +       if (!error)
784  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
785          error = locks_verify_truncate(inode, file, length);          error = locks_verify_truncate(inode, file, length);
786          if (!error)          if (!error)
787                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);                  error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
788  @@ -481,6 +493,12 @@ asmlinkage long sys_chroot(const char __  @@ -481,6 +495,14 @@ asmlinkage long sys_chroot(const char __
789          error = -EPERM;          error = -EPERM;
790          if (!capable(CAP_SYS_CHROOT))          if (!capable(CAP_SYS_CHROOT))
791                  goto dput_and_out;                  goto dput_and_out;
792  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
793  +       if (!ccs_capable(TOMOYO_SYS_CHROOT)) goto dput_and_out;  +       if (!ccs_capable(TOMOYO_SYS_CHROOT))
794    +               goto dput_and_out;
795  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
796  +       /***** SAKURA Linux start. *****/  +       /***** SAKURA Linux start. *****/
797  +       if (ccs_check_chroot_permission(&nd)) goto dput_and_out;  +       if (ccs_check_chroot_permission(&nd))
798    +               goto dput_and_out;
799  +       /***** SAKURA Linux end. *****/  +       /***** SAKURA Linux end. *****/
800    
801          set_fs_root(current->fs, nd.mnt, nd.dentry);          set_fs_root(current->fs, nd.mnt, nd.dentry);
802          set_fs_altroot();          set_fs_altroot();
803  @@ -1085,6 +1103,9 @@ EXPORT_SYMBOL(sys_close);  @@ -1085,6 +1107,10 @@ EXPORT_SYMBOL(sys_close);
804    */    */
805   asmlinkage long sys_vhangup(void)   asmlinkage long sys_vhangup(void)
806   {   {
807  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
808  +       if (!ccs_capable(TOMOYO_SYS_VHANGUP)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_VHANGUP))
809    +               return -EPERM;
810  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
811          if (capable(CAP_SYS_TTY_CONFIG)) {          if (capable(CAP_SYS_TTY_CONFIG)) {
812                  /* XXX: this needs locking */                  /* XXX: this needs locking */
# Line 736  Source code for this patch is http://www Line 828  Source code for this patch is http://www
828   #endif   #endif
829  +       /***** CCS start. *****/  +       /***** CCS start. *****/
830  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)  +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
831  +       printk(KERN_INFO "Hook version: 2.6.21 2008/03/24\n");  +       printk(KERN_INFO "Hook version: 2.6.21 2008/04/22\n");
832  +#endif  +#endif
833  +       /***** CCS end. *****/  +       /***** CCS end. *****/
834   }   }
# Line 790  Source code for this patch is http://www Line 882  Source code for this patch is http://www
882    
883   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)
884   {   {
885  @@ -869,6 +872,9 @@ asmlinkage long compat_sys_stime(compat_  @@ -869,6 +872,10 @@ asmlinkage long compat_sys_stime(compat_
886          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
887          if (err)          if (err)
888                  return err;                  return err;
889  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
890  +       if (!ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME))
891    +               return -EPERM;
892  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
893    
894          do_settimeofday(&tv);          do_settimeofday(&tv);
# Line 812  Source code for this patch is http://www Line 905  Source code for this patch is http://www
905    
906   /* Per cpu memory for storing cpu states in case of system crash. */   /* Per cpu memory for storing cpu states in case of system crash. */
907   note_buf_t* crash_notes;   note_buf_t* crash_notes;
908  @@ -924,6 +927,9 @@ asmlinkage long sys_kexec_load(unsigned  @@ -924,6 +927,10 @@ asmlinkage long sys_kexec_load(unsigned
909          /* We only trust the superuser with rebooting the system. */          /* We only trust the superuser with rebooting the system. */
910          if (!capable(CAP_SYS_BOOT))          if (!capable(CAP_SYS_BOOT))
911                  return -EPERM;                  return -EPERM;
912  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
913  +       if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD))
914    +               return -EPERM;
915  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
916    
917          /*          /*
# Line 848  Source code for this patch is http://www Line 942  Source code for this patch is http://www
942    
943   #if 0   #if 0
944   #define DEBUGP printk   #define DEBUGP printk
945  @@ -662,6 +665,9 @@ sys_delete_module(const char __user *nam  @@ -662,6 +665,10 @@ sys_delete_module(const char __user *nam
946    
947          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
948                  return -EPERM;                  return -EPERM;
949  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
950  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
951    +               return -EPERM;
952  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
953    
954          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)          if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
955                  return -EFAULT;                  return -EFAULT;
956  @@ -1983,6 +1989,9 @@ sys_init_module(void __user *umod,  @@ -1983,6 +1990,10 @@ sys_init_module(void __user *umod,
957          /* Must have permission */          /* Must have permission */
958          if (!capable(CAP_SYS_MODULE))          if (!capable(CAP_SYS_MODULE))
959                  return -EPERM;                  return -EPERM;
960  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
961  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
962    +               return -EPERM;
963  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
964    
965          /* Only one module load at a time, please */          /* Only one module load at a time, please */
# Line 880  Source code for this patch is http://www Line 976  Source code for this patch is http://www
976    
977   /*   /*
978    * ptrace a task: make the debugger its new parent and    * ptrace a task: make the debugger its new parent and
979  @@ -456,6 +459,11 @@ asmlinkage long sys_ptrace(long request,  @@ -456,6 +459,12 @@ asmlinkage long sys_ptrace(long request,
980          /*          /*
981           * This lock_kernel fixes a subtle race with suid exec           * This lock_kernel fixes a subtle race with suid exec
982           */           */
983  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
984  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
985  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
986    +               return -EPERM;
987  +#endif  +#endif
988  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
989          lock_kernel();          lock_kernel();
# Line 904  Source code for this patch is http://www Line 1001  Source code for this patch is http://www
1001    
1002   /*   /*
1003    * Scheduler clock - returns current time in nanosec units.    * Scheduler clock - returns current time in nanosec units.
1004  @@ -3960,6 +3963,9 @@ int can_nice(const struct task_struct *p  @@ -3960,6 +3963,10 @@ int can_nice(const struct task_struct *p
1005   asmlinkage long sys_nice(int increment)   asmlinkage long sys_nice(int increment)
1006   {   {
1007          long nice, retval;          long nice, retval;
1008  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1009  +       if (!ccs_capable(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_NICE))
1010    +               return -EPERM;
1011  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1012    
1013          /*          /*
# Line 926  Source code for this patch is http://www Line 1024  Source code for this patch is http://www
1024    
1025   /*   /*
1026    * SLAB caches for signal bits.    * SLAB caches for signal bits.
1027  @@ -2235,6 +2238,10 @@ asmlinkage long  @@ -2235,6 +2238,12 @@ asmlinkage long
1028   sys_kill(int pid, int sig)   sys_kill(int pid, int sig)
1029   {   {
1030          struct siginfo info;          struct siginfo info;
1031  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1032  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL)) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1033  +       if (sig && ccs_check_signal_acl(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1034    +       if (sig && ccs_check_signal_acl(sig, pid))
1035    +               return -EPERM;
1036  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1037    
1038          info.si_signo = sig;          info.si_signo = sig;
1039          info.si_errno = 0;          info.si_errno = 0;
1040  @@ -2293,6 +2300,10 @@ asmlinkage long sys_tgkill(int tgid, int  @@ -2293,6 +2302,12 @@ asmlinkage long sys_tgkill(int tgid, int
1041          /* This is only valid for single tasks */          /* This is only valid for single tasks */
1042          if (pid <= 0 || tgid <= 0)          if (pid <= 0 || tgid <= 0)
1043                  return -EINVAL;                  return -EINVAL;
1044  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1045  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL)) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1046  +       if (sig && ccs_check_signal_acl(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1047    +       if (sig && ccs_check_signal_acl(sig, pid))
1048    +               return -EPERM;
1049  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1050    
1051          return do_tkill(tgid, pid, sig);          return do_tkill(tgid, pid, sig);
1052   }   }
1053  @@ -2306,6 +2317,10 @@ sys_tkill(int pid, int sig)  @@ -2306,6 +2321,12 @@ sys_tkill(int pid, int sig)
1054          /* This is only valid for single tasks */          /* This is only valid for single tasks */
1055          if (pid <= 0)          if (pid <= 0)
1056                  return -EINVAL;                  return -EINVAL;
1057  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1058  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL)) return -EPERM;  +       if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1059  +       if (sig && ccs_check_signal_acl(sig, pid) < 0) return -EPERM;  +               return -EPERM;
1060    +       if (sig && ccs_check_signal_acl(sig, pid))
1061    +               return -EPERM;
1062  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1063    
1064          return do_tkill(0, pid, sig);          return do_tkill(0, pid, sig);
# Line 971  Source code for this patch is http://www Line 1075  Source code for this patch is http://www
1075    
1076   #ifndef SET_UNALIGN_CTL   #ifndef SET_UNALIGN_CTL
1077   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)   # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
1078  @@ -600,6 +603,9 @@ asmlinkage long sys_setpriority(int whic  @@ -600,6 +603,10 @@ asmlinkage long sys_setpriority(int whic
1079    
1080          if (which > 2 || which < 0)          if (which > 2 || which < 0)
1081                  goto out;                  goto out;
1082  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1083  +       if (!ccs_capable(TOMOYO_SYS_NICE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_NICE))
1084    +               return -EPERM;
1085  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1086    
1087          /* normalize: avoid signed division (rounding problems) */          /* normalize: avoid signed division (rounding problems) */
1088          error = -ESRCH;          error = -ESRCH;
1089  @@ -830,6 +836,9 @@ asmlinkage long sys_reboot(int magic1, i  @@ -830,6 +837,10 @@ asmlinkage long sys_reboot(int magic1, i
1090                          magic2 != LINUX_REBOOT_MAGIC2B &&                          magic2 != LINUX_REBOOT_MAGIC2B &&
1091                          magic2 != LINUX_REBOOT_MAGIC2C))                          magic2 != LINUX_REBOOT_MAGIC2C))
1092                  return -EINVAL;                  return -EINVAL;
1093  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1094  +       if (!ccs_capable(TOMOYO_SYS_REBOOT)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_REBOOT))
1095    +               return -EPERM;
1096  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1097    
1098          /* Instead of trying to make the power_off code look like          /* Instead of trying to make the power_off code look like
1099           * 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.
1100  @@ -1806,6 +1815,9 @@ asmlinkage long sys_sethostname(char __u  @@ -1806,6 +1817,10 @@ asmlinkage long sys_sethostname(char __u
1101                  return -EPERM;                  return -EPERM;
1102          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
1103                  return -EINVAL;                  return -EINVAL;
1104  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1105  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1106    +               return -EPERM;
1107  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1108          down_write(&uts_sem);          down_write(&uts_sem);
1109          errno = -EFAULT;          errno = -EFAULT;
1110          if (!copy_from_user(tmp, name, len)) {          if (!copy_from_user(tmp, name, len)) {
1111  @@ -1851,6 +1863,9 @@ asmlinkage long sys_setdomainname(char _  @@ -1851,6 +1866,10 @@ asmlinkage long sys_setdomainname(char _
1112                  return -EPERM;                  return -EPERM;
1113          if (len < 0 || len > __NEW_UTS_LEN)          if (len < 0 || len > __NEW_UTS_LEN)
1114                  return -EINVAL;                  return -EINVAL;
1115  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1116  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1117    +               return -EPERM;
1118  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1119    
1120          down_write(&uts_sem);          down_write(&uts_sem);
# Line 1023  Source code for this patch is http://www Line 1131  Source code for this patch is http://www
1131    
1132   extern int proc_nr_files(ctl_table *table, int write, struct file *filp,   extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
1133                        void __user *buffer, size_t *lenp, loff_t *ppos);                        void __user *buffer, size_t *lenp, loff_t *ppos);
1134  @@ -1088,6 +1091,81 @@ struct ctl_table_header *sysctl_head_nex  @@ -1088,6 +1091,93 @@ struct ctl_table_header *sysctl_head_nex
1135   }   }
1136    
1137   #ifdef CONFIG_SYSCTL_SYSCALL   #ifdef CONFIG_SYSCTL_SYSCALL
1138  +  +
1139  +/***** TOMOYO Linux start. *****/  +/***** TOMOYO Linux start. *****/
1140  +static int try_parse_table(int __user *name, int nlen, void __user *oldval, void __user *newval, ctl_table *table)  +static int try_parse_table(int __user *name, int nlen, void __user *oldval,
1141    +                          void __user *newval, ctl_table *table)
1142  +{  +{
1143  +       int n;  +       int n;
1144  +       int error = -ENOMEM;  +       int error = -ENOMEM;
1145  +       int op = 0;  +       int op = 0;
1146  +       char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);  +       char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1147  +       if (oldval) op |= 004;  +       if (oldval)
1148  +       if (newval) op |= 002;  +               op |= 004;
1149    +       if (newval)
1150    +               op |= 002;
1151  +       if (!op) { /* Neither read nor write */  +       if (!op) { /* Neither read nor write */
1152  +               error = 0;  +               error = 0;
1153  +               goto out;  +               goto out;
1154  +       }  +       }
1155  +       if (!buffer) goto out;  +       if (!buffer)
1156    +               goto out;
1157  +       memset(buffer, 0, PAGE_SIZE);  +       memset(buffer, 0, PAGE_SIZE);
1158  +       snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");  +       snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1159  + repeat:  + repeat:
# Line 1059  Source code for this patch is http://www Line 1171  Source code for this patch is http://www
1171  +                       const char *cp = table->procname;  +                       const char *cp = table->procname;
1172  +                       error = -ENOMEM;  +                       error = -ENOMEM;
1173  +                       if (cp) {  +                       if (cp) {
1174  +                               if (pos + 1 >= PAGE_SIZE - 1) goto out;  +                               if (pos + 1 >= PAGE_SIZE - 1)
1175    +                                       goto out;
1176  +                               buffer[pos++] = '/';  +                               buffer[pos++] = '/';
1177  +                               while (*cp) {  +                               while (*cp) {
1178  +                                       const unsigned char c = * (const unsigned char *) cp;  +                                       const unsigned char c
1179    +                                               = *(const unsigned char *) cp;
1180  +                                       if (c == '\\') {  +                                       if (c == '\\') {
1181  +                                               if (pos + 2 >= PAGE_SIZE - 1) goto out;  +                                               if (pos + 2 >= PAGE_SIZE - 1)
1182    +                                                       goto out;
1183  +                                               buffer[pos++] = '\\';  +                                               buffer[pos++] = '\\';
1184  +                                               buffer[pos++] = '\\';  +                                               buffer[pos++] = '\\';
1185  +                                       } else if (c > ' ' && c < 127) {  +                                       } else if (c > ' ' && c < 127) {
1186  +                                               if (pos + 1 >= PAGE_SIZE - 1) goto out;  +                                               if (pos + 1 >= PAGE_SIZE - 1)
1187    +                                                       goto out;
1188  +                                               buffer[pos++] = c;  +                                               buffer[pos++] = c;
1189  +                                       } else {  +                                       } else {
1190  +                                               if (pos + 4 >= PAGE_SIZE - 1) goto out;  +                                               if (pos + 4 >= PAGE_SIZE - 1)
1191    +                                                       goto out;
1192  +                                               buffer[pos++] = '\\';  +                                               buffer[pos++] = '\\';
1193  +                                               buffer[pos++] = (c >> 6) + '0';  +                                               buffer[pos++] = (c >> 6) + '0';
1194  +                                               buffer[pos++] = ((c >> 3) & 7) + '0';  +                                               buffer[pos++] = ((c >> 3) & 7)
1195    +                                                       + '0';
1196  +                                               buffer[pos++] = (c & 7) + '0';  +                                               buffer[pos++] = (c & 7) + '0';
1197  +                                       }  +                                       }
1198  +                                       cp++;  +                                       cp++;
1199  +                               }  +                               }
1200  +                       } else {  +                       } else {
1201  +                               /* Assume nobody assigns "=\$=" for procname. */  +                               /* Assume nobody assigns "=\$=" for procname. */
1202  +                               snprintf(buffer + pos, PAGE_SIZE - pos - 1, "/=%d=", n);  +                               snprintf(buffer + pos, PAGE_SIZE - pos - 1,
1203  +                               if (memchr(buffer, '\0', PAGE_SIZE - 2) == NULL) goto out;  +                                        "/=%d=", n);
1204    +                               if (!memchr(buffer, '\0', PAGE_SIZE - 2))
1205    +                                       goto out;
1206  +                       }  +                       }
1207  +                       if (table->child) {  +                       if (table->child) {
1208  +                               name++;  +                               name++;
# Line 1105  Source code for this patch is http://www Line 1225  Source code for this patch is http://www
1225   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,
1226                 void __user *newval, size_t newlen)                 void __user *newval, size_t newlen)
1227   {   {
1228  @@ -1104,6 +1182,9 @@ int do_sysctl(int __user *name, int nlen  @@ -1104,6 +1194,11 @@ int do_sysctl(int __user *name, int nlen
1229    
1230          for (head = sysctl_head_next(NULL); head;          for (head = sysctl_head_next(NULL); head;
1231                          head = sysctl_head_next(head)) {                          head = sysctl_head_next(head)) {
1232  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1233  +               if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0)  +               error = try_parse_table(name, nlen, oldval, newval,
1234    +                                       head->ctl_table);
1235    +               if (!error)
1236  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1237                  error = parse_table(name, nlen, oldval, oldlenp,                  error = parse_table(name, nlen, oldval, oldlenp,
1238                                          newval, newlen, head->ctl_table);                                          newval, newlen, head->ctl_table);
# Line 1127  Source code for this patch is http://www Line 1249  Source code for this patch is http://www
1249    
1250   /*   /*
1251    * The timezone where the local system is located.  Used as a default by some    * The timezone where the local system is located.  Used as a default by some
1252  @@ -91,6 +94,9 @@ asmlinkage long sys_stime(time_t __user  @@ -91,6 +94,10 @@ asmlinkage long sys_stime(time_t __user
1253          err = security_settime(&tv, NULL);          err = security_settime(&tv, NULL);
1254          if (err)          if (err)
1255                  return err;                  return err;
1256  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1257  +       if (!ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME))
1258    +               return -EPERM;
1259  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1260    
1261          do_settimeofday(&tv);          do_settimeofday(&tv);
1262          return 0;          return 0;
1263  @@ -161,6 +167,9 @@ int do_sys_settimeofday(struct timespec  @@ -161,6 +168,10 @@ int do_sys_settimeofday(struct timespec
1264          error = security_settime(tv, tz);          error = security_settime(tv, tz);
1265          if (error)          if (error)
1266                  return error;                  return error;
1267  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1268  +       if (!ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_SETTIME))
1269    +               return -EPERM;
1270  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1271    
1272          if (tz) {          if (tz) {
# Line 1159  Source code for this patch is http://www Line 1283  Source code for this patch is http://www
1283    
1284   /*   /*
1285    * Timekeeping variables    * Timekeeping variables
1286  @@ -203,6 +206,9 @@ int do_adjtimex(struct timex *txc)  @@ -203,6 +206,10 @@ int do_adjtimex(struct timex *txc)
1287          /* In order to modify anything, you gotta be super-user! */          /* In order to modify anything, you gotta be super-user! */
1288          if (txc->modes && !capable(CAP_SYS_TIME))          if (txc->modes && !capable(CAP_SYS_TIME))
1289                  return -EPERM;                  return -EPERM;
1290  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1291  +       if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME)) return -EPERM;  +       if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME))
1292    +               return -EPERM;
1293  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1294    
1295          /* Now we validate the data before disabling interrupts */          /* Now we validate the data before disabling interrupts */
# Line 1183  Source code for this patch is http://www Line 1308  Source code for this patch is http://www
1308   /*   /*
1309    *     Is a socket 'connection oriented' ?    *     Is a socket 'connection oriented' ?
1310    */    */
1311  @@ -178,6 +183,10 @@ struct sk_buff *skb_recv_datagram(struct  @@ -178,6 +183,12 @@ struct sk_buff *skb_recv_datagram(struct
1312                  } else                  } else
1313                          skb = skb_dequeue(&sk->sk_receive_queue);                          skb = skb_dequeue(&sk->sk_receive_queue);
1314    
1315  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1316  +               if ((error = ccs_socket_recv_datagram_permission(sk, skb, flags)) < 0) goto no_packet;  +               error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1317    +               if (error)
1318    +                       goto no_packet;
1319  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1320  +  +
1321                  if (skb)                  if (skb)
# Line 1206  Source code for this patch is http://www Line 1333  Source code for this patch is http://www
1333    
1334   #ifdef INET_CSK_DEBUG   #ifdef INET_CSK_DEBUG
1335   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";
1336  @@ -87,6 +90,9 @@ int inet_csk_get_port(struct inet_hashin  @@ -87,6 +90,10 @@ int inet_csk_get_port(struct inet_hashin
1337                  do {                  do {
1338                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];                          head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1339                          spin_lock(&head->lock);                          spin_lock(&head->lock);
1340  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1341  +                       if (ccs_may_autobind(rover) < 0) goto next;  +                       if (ccs_may_autobind(rover))
1342    +                               goto next;
1343  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1344                          inet_bind_bucket_for_each(tb, node, &head->chain)                          inet_bind_bucket_for_each(tb, node, &head->chain)
1345                                  if (tb->port == rover)                                  if (tb->port == rover)
# Line 1228  Source code for this patch is http://www Line 1356  Source code for this patch is http://www
1356    
1357   /*   /*
1358    * Allocate and initialize a new local port bind bucket.    * Allocate and initialize a new local port bind bucket.
1359  @@ -292,6 +295,9 @@ int inet_hash_connect(struct inet_timewa  @@ -292,6 +295,10 @@ int inet_hash_connect(struct inet_timewa
1360                  local_bh_disable();                  local_bh_disable();
1361                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1362                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1363  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1364  +                       if (ccs_may_autobind(port) < 0) continue;  +                       if (ccs_may_autobind(port))
1365    +                               continue;
1366  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1367                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1368                          spin_lock(&head->lock);                          spin_lock(&head->lock);
# Line 1250  Source code for this patch is http://www Line 1379  Source code for this patch is http://www
1379    
1380   /*   /*
1381    *     Snmp MIB for the UDP layer    *     Snmp MIB for the UDP layer
1382  @@ -162,6 +165,9 @@ int __udp_lib_get_port(struct sock *sk,  @@ -162,6 +165,10 @@ int __udp_lib_get_port(struct sock *sk,
1383                                          result = sysctl_local_port_range[0] +                                          result = sysctl_local_port_range[0] +
1384                                                  ((result - sysctl_local_port_range[0]) &                                                  ((result - sysctl_local_port_range[0]) &
1385                                                   (UDP_HTABLE_SIZE - 1));                                                   (UDP_HTABLE_SIZE - 1));
1386  +                               /***** SAKURA Linux start. *****/  +                               /***** SAKURA Linux start. *****/
1387  +                               if (ccs_may_autobind(result) < 0) continue;  +                               if (ccs_may_autobind(result))
1388    +                                       continue;
1389  +                               /***** SAKURA Linux end. *****/  +                               /***** SAKURA Linux end. *****/
1390                                  goto gotit;                                  goto gotit;
1391                          }                          }
1392                          size = 0;                          size = 0;
1393  @@ -180,6 +186,9 @@ int __udp_lib_get_port(struct sock *sk,  @@ -180,6 +187,10 @@ int __udp_lib_get_port(struct sock *sk,
1394                                  result = sysctl_local_port_range[0]                                  result = sysctl_local_port_range[0]
1395                                          + ((result - sysctl_local_port_range[0]) &                                          + ((result - sysctl_local_port_range[0]) &
1396                                             (UDP_HTABLE_SIZE - 1));                                             (UDP_HTABLE_SIZE - 1));
1397  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1398  +                       if (ccs_may_autobind(result) < 0) continue;  +                       if (ccs_may_autobind(result))
1399    +                               continue;
1400  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1401                          if (! __udp_lib_lport_inuse(result, udptable))                          if (! __udp_lib_lport_inuse(result, udptable))
1402                                  break;                                  break;
# Line 1282  Source code for this patch is http://www Line 1413  Source code for this patch is http://www
1413    
1414   void __inet6_hash(struct inet_hashinfo *hashinfo,   void __inet6_hash(struct inet_hashinfo *hashinfo,
1415                                  struct sock *sk)                                  struct sock *sk)
1416  @@ -266,6 +269,9 @@ int inet6_hash_connect(struct inet_timew  @@ -266,6 +269,10 @@ int inet6_hash_connect(struct inet_timew
1417                  local_bh_disable();                  local_bh_disable();
1418                  for (i = 1; i <= range; i++) {                  for (i = 1; i <= range; i++) {
1419                          port = low + (i + offset) % range;                          port = low + (i + offset) % range;
1420  +                       /***** SAKURA Linux start. *****/  +                       /***** SAKURA Linux start. *****/
1421  +                       if (ccs_may_autobind(port) < 0) continue;  +                       if (ccs_may_autobind(port))
1422    +                               continue;
1423  +                       /***** SAKURA Linux end. *****/  +                       /***** SAKURA Linux end. *****/
1424                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];                          head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1425                          spin_lock(&head->lock);                          spin_lock(&head->lock);
# Line 1306  Source code for this patch is http://www Line 1438  Source code for this patch is http://www
1438   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);   static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1439   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,
1440                           unsigned long nr_segs, loff_t pos);                           unsigned long nr_segs, loff_t pos);
1441  @@ -549,6 +554,9 @@ static inline int __sock_sendmsg(struct  @@ -549,6 +554,12 @@ static inline int __sock_sendmsg(struct
1442          err = security_socket_sendmsg(sock, msg, size);          err = security_socket_sendmsg(sock, msg, size);
1443          if (err)          if (err)
1444                  return err;                  return err;
1445  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1446  +       if (ccs_socket_sendmsg_permission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;  +       if (ccs_socket_sendmsg_permission(sock,
1447    +                                         (struct sockaddr *) msg->msg_name,
1448    +                                         msg->msg_namelen))
1449    +               return -EPERM;
1450  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1451    
1452          return sock->ops->sendmsg(iocb, sock, msg, size);          return sock->ops->sendmsg(iocb, sock, msg, size);
1453   }   }
1454  @@ -1070,6 +1078,10 @@ static int __sock_create(int family, int  @@ -1070,6 +1081,12 @@ static int __sock_create(int family, int
1455                  family = PF_PACKET;                  family = PF_PACKET;
1456          }          }
1457    
1458  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1459  +       if ((err = ccs_socket_create_permission(family, type, protocol)) < 0) return err;  +       err = ccs_socket_create_permission(family, type, protocol);
1460    +       if (err)
1461    +               return err;
1462  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1463  +  +
1464          err = security_socket_create(family, type, protocol, kern);          err = security_socket_create(family, type, protocol, kern);
1465          if (err)          if (err)
1466                  return err;                  return err;
1467  @@ -1298,6 +1310,9 @@ asmlinkage long sys_bind(int fd, struct  @@ -1298,6 +1315,13 @@ asmlinkage long sys_bind(int fd, struct
1468                          err = security_socket_bind(sock,                          err = security_socket_bind(sock,
1469                                                     (struct sockaddr *)address,                                                     (struct sockaddr *)address,
1470                                                     addrlen);                                                     addrlen);
1471  +                       /***** TOMOYO Linux start. *****/  +                       /***** TOMOYO Linux start. *****/
1472  +                       if (!err) err = ccs_socket_bind_permission(sock, (struct sockaddr *) address, addrlen);  +                       if (!err)
1473    +                               err = ccs_socket_bind_permission(sock,
1474    +                                                        (struct sockaddr *)
1475    +                                                                address,
1476    +                                                                addrlen);
1477  +                       /***** TOMOYO Linux end. *****/  +                       /***** TOMOYO Linux end. *****/
1478                          if (!err)                          if (!err)
1479                                  err = sock->ops->bind(sock,                                  err = sock->ops->bind(sock,
1480                                                        (struct sockaddr *)                                                        (struct sockaddr *)
1481  @@ -1327,6 +1342,9 @@ asmlinkage long sys_listen(int fd, int b  @@ -1327,6 +1351,10 @@ asmlinkage long sys_listen(int fd, int b
1482                          backlog = sysctl_somaxconn;                          backlog = sysctl_somaxconn;
1483    
1484                  err = security_socket_listen(sock, backlog);                  err = security_socket_listen(sock, backlog);
1485  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1486  +               if (!err) err = ccs_socket_listen_permission(sock);  +               if (!err)
1487    +                       err = ccs_socket_listen_permission(sock);
1488  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1489                  if (!err)                  if (!err)
1490                          err = sock->ops->listen(sock, backlog);                          err = sock->ops->listen(sock, backlog);
1491    
1492  @@ -1391,6 +1409,12 @@ asmlinkage long sys_accept(int fd, struc  @@ -1391,6 +1419,13 @@ asmlinkage long sys_accept(int fd, struc
1493          if (err < 0)          if (err < 0)
1494                  goto out_fd;                  goto out_fd;
1495    
1496  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1497  +       if (ccs_socket_accept_permission(newsock, (struct sockaddr *) address)) {  +       if (ccs_socket_accept_permission(newsock,
1498    +                                        (struct sockaddr *) address)) {
1499  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */  +               err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1500  +               goto out_fd;  +               goto out_fd;
1501  +       }  +       }
# Line 1360  Source code for this patch is http://www Line 1503  Source code for this patch is http://www
1503          if (upeer_sockaddr) {          if (upeer_sockaddr) {
1504                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,                  if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1505                                            &len, 2) < 0) {                                            &len, 2) < 0) {
1506  @@ -1455,6 +1479,10 @@ asmlinkage long sys_connect(int fd, stru  @@ -1455,6 +1490,12 @@ asmlinkage long sys_connect(int fd, stru
1507              security_socket_connect(sock, (struct sockaddr *)address, addrlen);              security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1508          if (err)          if (err)
1509                  goto out_put;                  goto out_put;
1510  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1511  +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, addrlen);  +       err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1512  +       if (err) goto out_put;  +                                           addrlen);
1513    +       if (err)
1514    +               goto out_put;
1515  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1516    
1517          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,          err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
# Line 1383  Source code for this patch is http://www Line 1528  Source code for this patch is http://www
1528    
1529   int sysctl_unix_max_dgram_qlen __read_mostly = 10;   int sysctl_unix_max_dgram_qlen __read_mostly = 10;
1530    
1531  @@ -765,6 +768,10 @@ static int unix_bind(struct socket *sock  @@ -765,6 +768,11 @@ static int unix_bind(struct socket *sock
1532                  err = unix_autobind(sock);                  err = unix_autobind(sock);
1533                  goto out;                  goto out;
1534          }          }
1535  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1536  +       err = -EPERM;  +       err = -EPERM;
1537  +       if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) goto out;  +       if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
1538    +               goto out;
1539  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1540    
1541          err = unix_mkname(sunaddr, addr_len, &hash);          err = unix_mkname(sunaddr, addr_len, &hash);
1542          if (err < 0)          if (err < 0)
1543  @@ -808,6 +815,9 @@ static int unix_bind(struct socket *sock  @@ -808,6 +816,13 @@ static int unix_bind(struct socket *sock
1544                   */                   */
1545                  mode = S_IFSOCK |                  mode = S_IFSOCK |
1546                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);                         (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1547  +               /***** TOMOYO Linux start. *****/  +               /***** TOMOYO Linux start. *****/
1548  +               if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)  +               err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
1549    +               if (!err)
1550    +                       err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry,
1551    +                                                  nd.mnt);
1552    +               if (!err)
1553  +               /***** TOMOYO Linux end. *****/  +               /***** TOMOYO Linux end. *****/
1554                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);                  err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1555                  if (err)                  if (err)
# Line 1416  Source code for this patch is http://www Line 1566  Source code for this patch is http://www
1566    
1567   #include "ptrace-common.h"   #include "ptrace-common.h"
1568    
1569  @@ -45,6 +48,11 @@ long compat_sys_ptrace(int request, int  @@ -45,6 +48,12 @@ long compat_sys_ptrace(int request, int
1570   {   {
1571          struct task_struct *child;          struct task_struct *child;
1572          int ret;          int ret;
1573  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1574  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
1575  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
1576    +               return -EPERM;
1577  +#endif  +#endif
1578  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1579    
# Line 1440  Source code for this patch is http://www Line 1591  Source code for this patch is http://www
1591    
1592   /* This mask defines the bits of the SR which the user is not allowed to   /* This mask defines the bits of the SR which the user is not allowed to
1593      change, which are everything except S, Q, M, PR, SZ, FR. */      change, which are everything except S, Q, M, PR, SZ, FR. */
1594  @@ -271,6 +274,11 @@ asmlinkage int sh64_ptrace(long request,  @@ -271,6 +274,12 @@ asmlinkage int sh64_ptrace(long request,
1595          extern void poke_real_address_q(unsigned long long addr, unsigned long long data);          extern void poke_real_address_q(unsigned long long addr, unsigned long long data);
1596   #define WPC_DBRMODE 0x0d104008   #define WPC_DBRMODE 0x0d104008
1597          static int first_call = 1;          static int first_call = 1;
1598  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1599  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
1600  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
1601    +               return -EPERM;
1602  +#endif  +#endif
1603  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1604    
# Line 1464  Source code for this patch is http://www Line 1616  Source code for this patch is http://www
1616    
1617   /*   /*
1618    * Determines which flags the user has access to [1 = access, 0 = no access].    * Determines which flags the user has access to [1 = access, 0 = no access].
1619  @@ -234,6 +237,11 @@ asmlinkage long sys32_ptrace(long reques  @@ -234,6 +237,12 @@ asmlinkage long sys32_ptrace(long reques
1620          void __user *datap = compat_ptr(data);          void __user *datap = compat_ptr(data);
1621          int ret;          int ret;
1622          __u32 val;          __u32 val;
1623  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1624  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
1625  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
1626    +               return -EPERM;
1627  +#endif  +#endif
1628  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1629    
# Line 1488  Source code for this patch is http://www Line 1641  Source code for this patch is http://www
1641    
1642   #include "ia32priv.h"   #include "ia32priv.h"
1643    
1644  @@ -1758,6 +1761,11 @@ sys32_ptrace (int request, pid_t pid, un  @@ -1758,6 +1761,12 @@ sys32_ptrace (int request, pid_t pid, un
1645          struct task_struct *child;          struct task_struct *child;
1646          unsigned int value, tmp;          unsigned int value, tmp;
1647          long i, ret;          long i, ret;
1648  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1649  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
1650  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
1651    +               return -EPERM;
1652  +#endif  +#endif
1653  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1654    
# Line 1512  Source code for this patch is http://www Line 1666  Source code for this patch is http://www
1666    
1667   int ptrace_getregs (struct task_struct *child, __s64 __user *data);   int ptrace_getregs (struct task_struct *child, __s64 __user *data);
1668   int ptrace_setregs (struct task_struct *child, __s64 __user *data);   int ptrace_setregs (struct task_struct *child, __s64 __user *data);
1669  @@ -50,6 +53,11 @@ asmlinkage int sys32_ptrace(int request,  @@ -50,6 +53,12 @@ asmlinkage int sys32_ptrace(int request,
1670   {   {
1671          struct task_struct *child;          struct task_struct *child;
1672          int ret;          int ret;
1673  +       /***** TOMOYO Linux start. *****/  +       /***** TOMOYO Linux start. *****/
1674  +#ifdef TOMOYO_SYS_PTRACE  +#ifdef TOMOYO_SYS_PTRACE
1675  +       if (!ccs_capable(TOMOYO_SYS_PTRACE)) return -EPERM;  +       if (!ccs_capable(TOMOYO_SYS_PTRACE))
1676    +               return -EPERM;
1677  +#endif  +#endif
1678  +       /***** TOMOYO Linux end. *****/  +       /***** TOMOYO Linux end. *****/
1679    

Legend:
Removed from v.1055  
changed lines
  Added in v.1128

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