diff -ubBpEr linux-2.6.19-1.2895.fc6/Makefile linux-2.6.19-1.2895.fc6-ccs/Makefile
--- linux-2.6.19-1.2895.fc6/Makefile	2007-01-22 16:18:49.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/Makefile	2007-01-22 16:18:52.000000000 +0900
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 19
-EXTRAVERSION = -1.2895.fc6
+EXTRAVERSION = -1.2895.fc6-ccs
 NAME=Avast! A bilge rat!
 
 # *DOCUMENTATION*
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/Kconfig linux-2.6.19-1.2895.fc6-ccs/fs/Kconfig
--- linux-2.6.19-1.2895.fc6/fs/Kconfig	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/Kconfig	2007-01-22 16:18:27.000000000 +0900
@@ -2184,5 +2184,7 @@ endif
 source "fs/nls/Kconfig"
 source "fs/dlm/Kconfig"
 
+source "fs/Kconfig.ccs"
+
 endmenu
 
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/Makefile linux-2.6.19-1.2895.fc6-ccs/fs/Makefile
--- linux-2.6.19-1.2895.fc6/fs/Makefile	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/Makefile	2007-01-22 16:18:27.000000000 +0900
@@ -116,3 +116,5 @@ obj-$(CONFIG_CACHEFILES)	+= cachefiles/
 obj-$(CONFIG_DEBUG_FS)		+= debugfs/
 obj-$(CONFIG_OCFS2_FS)		+= ocfs2/
 obj-$(CONFIG_GFS2_FS)           += gfs2/
+
+include $(srctree)/fs/Makefile-2.6.ccs
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/attr.c linux-2.6.19-1.2895.fc6-ccs/fs/attr.c
--- linux-2.6.19-1.2895.fc6/fs/attr.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/attr.c	2007-01-22 16:18:27.000000000 +0900
@@ -15,6 +15,9 @@
 #include <linux/fcntl.h>
 #include <linux/quotaops.h>
 #include <linux/security.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 /* Taken over from the old code... */
 
@@ -145,12 +148,20 @@ int notify_change(struct dentry * dentry
 
 	if (inode->i_op && inode->i_op->setattr) {
 		error = security_inode_setattr(dentry, attr);
+		/***** TOMOYO Linux start. *****/
+		if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);
+		if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);
+		/***** TOMOYO Linux end. *****/
 		if (!error)
 			error = inode->i_op->setattr(dentry, attr);
 	} else {
 		error = inode_change_ok(inode, attr);
 		if (!error)
 			error = security_inode_setattr(dentry, attr);
+		/***** TOMOYO Linux start. *****/
+		if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);
+		if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);
+		/***** TOMOYO Linux end. *****/
 		if (!error) {
 			if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 			    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/compat.c linux-2.6.19-1.2895.fc6-ccs/fs/compat.c
--- linux-2.6.19-1.2895.fc6/fs/compat.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/compat.c	2007-01-22 16:18:27.000000000 +0900
@@ -53,6 +53,9 @@
 #include <asm/mmu_context.h>
 #include <asm/ioctls.h>
 #include "internal.h"
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 int compat_log = 1;
 
@@ -419,6 +422,9 @@ asmlinkage long compat_sys_ioctl(unsigne
 		/*FALL THROUGH*/
 
 	default:
+		/***** TOMOYO Linux start. *****/
+		if ((error = CheckCapabilityACL(TOMOYO_SYS_IOCTL)) < 0) goto out_fput;
+		/***** TOMOYO Linux end. *****/
 		if (filp->f_op && filp->f_op->compat_ioctl) {
 			error = filp->f_op->compat_ioctl(filp, cmd, arg);
 			if (error != -ENOIOCTLCMD)
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/exec.c linux-2.6.19-1.2895.fc6-ccs/fs/exec.c
--- linux-2.6.19-1.2895.fc6/fs/exec.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/exec.c	2007-01-22 16:18:27.000000000 +0900
@@ -57,6 +57,13 @@
 #include <linux/kmod.h>
 #endif
 
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
+
 int core_uses_pid;
 char core_pattern[128] = "core";
 int suid_dumpable = 0;
@@ -139,6 +146,11 @@ asmlinkage long sys_uselib(const char __
 	if (error)
 		goto exit;
 
+    /***** TOMOYO Linux start. *****/
+	error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */
+    if (error) goto exit;
+    /***** TOMOYO Linux end. *****/
+
 	file = nameidata_to_filp(&nd, O_RDONLY);
 	error = PTR_ERR(file);
 	if (IS_ERR(file))
@@ -1123,6 +1135,25 @@ int do_execve(char * filename,
 	struct file *file;
 	int retval;
 	int i;
+	/***** TOMOYO Linux start. *****/
+#ifdef CONFIG_TOMOYO
+	struct domain_info *next_domain = NULL;
+#endif
+	/***** TOMOYO Linux end. *****/
+
+	/***** CCS Start. *****/
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
+	extern void CCS_LoadPolicy(const char *filename);
+	CCS_LoadPolicy(filename);
+#endif
+	/***** CCS end. *****/
+
+	/***** SAKURA Linux start. *****/
+#ifdef CONFIG_SAKURA_DROP_CAPABILITY_API
+	if (strcmp(filename, "\\\\disable") == 0) return DropTaskCapability(argv);
+	if (CheckTaskCapability(SAKURA_DISABLE_EXECVE) < 0) return -EPERM;
+#endif
+ 	/***** SAKURA Linux end. *****/
 
 	retval = -ENOMEM;
 	bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
@@ -1134,6 +1165,15 @@ int do_execve(char * filename,
 	if (IS_ERR(file))
 		goto out_kfree;
 
+ 	/***** TOMOYO Linux start. *****/
+#ifdef CONFIG_TOMOYO
+	retval = FindNextDomain(filename, file, &next_domain, argv);
+	if (retval < 0) {
+		allow_write_access(file); fput(file); goto out_kfree;
+	}
+#endif
+ 	/***** TOMOYO Linux end. *****/
+	
 	sched_exec();
 
 	bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
@@ -1180,6 +1220,19 @@ int do_execve(char * filename,
 		goto out;
 
 	retval = search_binary_handler(bprm,regs);
+
+	/***** TOMOYO Linux start. *****/
+#ifdef CONFIG_TOMOYO
+	if (retval >= 0) current->domain_info = next_domain;
+#endif
+	/***** TOMOYO Linux end. *****/
+
+	/***** SAKURA Linux start. *****/
+#ifdef CONFIG_SAKURA_DROP_CAPABILITY_API
+	if (retval >= 0) RestoreTaskCapability();
+#endif
+	/***** SAKURA Linux end. *****/
+
 	if (retval >= 0) {
 		free_arg_pages(bprm);
 
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/fcntl.c linux-2.6.19-1.2895.fc6-ccs/fs/fcntl.c
--- linux-2.6.19-1.2895.fc6/fs/fcntl.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/fcntl.c	2007-01-22 16:18:27.000000000 +0900
@@ -22,6 +22,9 @@
 #include <asm/poll.h>
 #include <asm/siginfo.h>
 #include <asm/uaccess.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 void fastcall set_close_on_exec(unsigned int fd, int flag)
 {
@@ -214,6 +217,10 @@ static int setfl(int fd, struct file * f
 	if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
 		return -EPERM;
 
+	/***** TOMOYO Linux start. *****/
+	if (!(arg & O_APPEND) && CheckReWritePermission(filp)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
+
 	/* O_NOATIME can only be set by the owner or superuser */
 	if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
 		if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/ioctl.c linux-2.6.19-1.2895.fc6-ccs/fs/ioctl.c
--- linux-2.6.19-1.2895.fc6/fs/ioctl.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/ioctl.c	2007-01-22 16:18:27.000000000 +0900
@@ -15,6 +15,9 @@
 
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 static long do_ioctl(struct file *filp, unsigned int cmd,
 		unsigned long arg)
@@ -23,6 +26,9 @@ static long do_ioctl(struct file *filp, 
 
 	if (!filp->f_op)
 		goto out;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	if (filp->f_op->unlocked_ioctl) {
 		error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/namei.c linux-2.6.19-1.2895.fc6-ccs/fs/namei.c
--- linux-2.6.19-1.2895.fc6/fs/namei.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/namei.c	2007-01-22 16:18:27.000000000 +0900
@@ -37,6 +37,13 @@
 
 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
 
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
+
 /* [Feb-1997 T. Schoebel-Theuer]
  * Fundamental changes in the pathname lookup mechanisms (namei)
  * were necessary because of omirr.  The reason is that omirr needs
@@ -817,6 +824,13 @@ static fastcall int __link_path_walk(con
 	int err;
 	unsigned int lookup_flags = nd->flags;
 	
+	/***** SAKURA Linux start. *****/
+	if (CheckEUID() < 0) {
+		path_release(nd);
+		return -EPERM;
+	}
+	/***** SAKURA Linux end. *****/
+
 	while (*name=='/')
 		name++;
 	if (!*name)
@@ -1509,6 +1523,9 @@ int vfs_create(struct inode *dir, struct
 	error = security_inode_create(dir, dentry, mode);
 	if (error)
 		return error;
+	/***** TOMOYO Linux start. *****/
+	if (nd && (error = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;
+	/***** TOMOYO Linux end. *****/
 	DQUOT_INIT(dir);
 	error = dir->i_op->create(dir, dentry, mode, nd);
 	if (!error)
@@ -1548,7 +1565,7 @@ int may_open(struct nameidata *nd, int a
 
 		flag &= ~O_TRUNC;
 	} else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
-		return -EROFS;
+		{ ROFS_Log_from_dentry(nd->dentry, nd->mnt, "may_open"); return -EROFS; } /***** ReadOnly Tracer *****/
 	/*
 	 * An append-only file must be opened in append mode for writing.
 	 */
@@ -1564,6 +1581,11 @@ int may_open(struct nameidata *nd, int a
 		if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
 			return -EPERM;
 
+    /***** TOMOYO Linux start. *****/
+	error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */
+    if (error) return error;
+    /***** TOMOYO Linux end. *****/
+
 	/*
 	 * Ensure there are no outstanding leases on the file.
 	 */
@@ -1613,6 +1635,9 @@ static int open_namei_create(struct name
 	return may_open(nd, 0, flag & ~O_TRUNC);
 }
 
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo_vfs.h>
+/***** TOMOYO Linux end. *****/
 /*
  *	open_namei()
  *
@@ -1735,6 +1760,7 @@ ok:
 exit_dput:
 	dput_path(&path, nd);
 exit:
+	if (error == -EROFS) ROFS_Log_from_dentry(nd->dentry, nd->mnt, "open_namei"); /***** ReadOnly Tracer *****/
 	if (!IS_ERR(nd->intent.open.file))
 		release_open_intent(nd);
 	path_release(nd);
@@ -1873,6 +1899,12 @@ asmlinkage long sys_mknodat(int dfd, con
 
 	if (S_ISDIR(mode))
 		return -EPERM;
+	/***** TOMOYO Linux start. *****/
+	if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;
+	if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;
+	if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM;
+	if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 	tmp = getname(filename);
 	if (IS_ERR(tmp))
 		return PTR_ERR(tmp);
@@ -1891,10 +1923,16 @@ asmlinkage long sys_mknodat(int dfd, con
 			error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
 			break;
 		case S_IFCHR: case S_IFBLK:
+			/***** TOMOYO Linux start. *****/
+ 			if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISCHR(mode) ? TYPE_MKCHAR_ACL : TYPE_MKBLOCK_ACL, dentry, nd.mnt)) == 0)
+ 			/***** TOMOYO Linux end. *****/
 			error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
 					new_decode_dev(dev));
 			break;
 		case S_IFIFO: case S_IFSOCK:
+			/***** TOMOYO Linux start. *****/
+ 			if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISFIFO(mode) ? TYPE_MKFIFO_ACL : TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)
+ 			/***** TOMOYO Linux end. *****/
 			error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
 			break;
 		case S_IFDIR:
@@ -1903,6 +1941,7 @@ asmlinkage long sys_mknodat(int dfd, con
 		default:
 			error = -EINVAL;
 		}
+		if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_mknod"); /***** ReadOnly Tracer *****/
 		dput(dentry);
 	}
 	mutex_unlock(&nd.dentry->d_inode->i_mutex);
@@ -1962,7 +2001,11 @@ asmlinkage long sys_mkdirat(int dfd, con
 
 	if (!IS_POSIXACL(nd.dentry->d_inode))
 		mode &= ~current->fs->umask;
+	/***** TOMOYO Linux start. *****/
+	if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)
+	/***** TOMOYO Linux end. *****/
 	error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
+	if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_mkdir"); /***** ReadOnly Tracer *****/
 	dput(dentry);
 out_unlock:
 	mutex_unlock(&nd.dentry->d_inode->i_mutex);
@@ -2070,7 +2113,11 @@ static long do_rmdir(int dfd, const char
 	error = PTR_ERR(dentry);
 	if (IS_ERR(dentry))
 		goto exit2;
+	/***** TOMOYO Linux start. *****/
+	if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)
+	/***** TOMOYO Linux end. *****/
 	error = vfs_rmdir(nd.dentry->d_inode, dentry);
+	if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_rmdir"); /***** ReadOnly Tracer *****/
 	dput(dentry);
 exit2:
 	mutex_unlock(&nd.dentry->d_inode->i_mutex);
@@ -2129,6 +2176,9 @@ static long do_unlinkat(int dfd, const c
 	struct dentry *dentry;
 	struct nameidata nd;
 	struct inode *inode = NULL;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	name = getname(pathname);
 	if(IS_ERR(name))
@@ -2150,7 +2200,11 @@ static long do_unlinkat(int dfd, const c
 		inode = dentry->d_inode;
 		if (inode)
 			atomic_inc(&inode->i_count);
+		/***** TOMOYO Linux start. *****/
+ 		if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)
+ 		/***** TOMOYO Linux end. *****/
 		error = vfs_unlink(nd.dentry->d_inode, dentry);
+		if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_unlink"); /***** ReadOnly Tracer *****/
 	exit2:
 		dput(dentry);
 	}
@@ -2214,6 +2268,9 @@ asmlinkage long sys_symlinkat(const char
 	char * to;
 	struct dentry *dentry;
 	struct nameidata nd;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	from = getname(oldname);
 	if(IS_ERR(from))
@@ -2231,7 +2288,11 @@ asmlinkage long sys_symlinkat(const char
 	if (IS_ERR(dentry))
 		goto out_unlock;
 
+	/***** TOMOYO Linux start. *****/
+	if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)
+	/***** TOMOYO Linux end. *****/
 	error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
+	if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "vfs_symlink"); /***** ReadOnly Tracer *****/
 	dput(dentry);
 out_unlock:
 	mutex_unlock(&nd.dentry->d_inode->i_mutex);
@@ -2303,6 +2364,9 @@ asmlinkage long sys_linkat(int olddfd, c
 	struct nameidata nd, old_nd;
 	int error;
 	char * to;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	if ((flags & ~AT_SYMLINK_FOLLOW) != 0)
 		return -EINVAL;
@@ -2326,7 +2390,11 @@ asmlinkage long sys_linkat(int olddfd, c
 	error = PTR_ERR(new_dentry);
 	if (IS_ERR(new_dentry))
 		goto out_unlock;
+	/***** TOMOYO Linux start. *****/
+	if ((error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry)) == 0 && (error = CheckDoubleWritePermission(TYPE_LINK_ACL, old_nd.dentry, old_nd.mnt, new_dentry, nd.mnt)) == 0)
+	/***** TOMOYO Linux end. *****/
 	error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
+	if (error == -EROFS) ROFS_Log_from_dentry(new_dentry, nd.mnt, "vfs_link"); /***** ReadOnly Tracer *****/
 	dput(new_dentry);
 out_unlock:
 	mutex_unlock(&nd.dentry->d_inode->i_mutex);
@@ -2551,6 +2619,12 @@ static int do_rename(int olddfd, const c
 	error = -ENOTEMPTY;
 	if (new_dentry == trap)
 		goto exit5;
+	/***** TOMOYO Linux start. *****/
+ 	if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||
+		(error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {
+		goto exit5;
+	}
+	/***** TOMOYO Linux end. *****/
 
 	error = vfs_rename(old_dir->d_inode, old_dentry,
 				   new_dir->d_inode, new_dentry);
@@ -2565,6 +2639,7 @@ exit2:
 exit1:
 	path_release(&oldnd);
 exit:
+	if (error == -EROFS) ROFS_Log(oldname, "do_rename"); /***** ReadOnly Tracer *****/
 	return error;
 }
 
@@ -2574,6 +2649,9 @@ asmlinkage long sys_renameat(int olddfd,
 	int error;
 	char * from;
 	char * to;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	from = getname(oldname);
 	if(IS_ERR(from))
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/namespace.c linux-2.6.19-1.2895.fc6-ccs/fs/namespace.c
--- linux-2.6.19-1.2895.fc6/fs/namespace.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/namespace.c	2007-01-22 16:18:27.000000000 +0900
@@ -28,6 +28,12 @@
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
 #include "pnode.h"
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 /* spinlock for vfsmount related operations, inplace of dcache_lock */
 __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
@@ -545,6 +551,10 @@ static int do_umount(struct vfsmount *mn
 	if (retval)
 		return retval;
 
+	/***** SAKURA Linux start. *****/
+	if (SAKURA_MayUmount(mnt) < 0) return -EPERM;
+	/***** SAKURA Linux end. *****/
+
 	/*
 	 * Allow userspace to request a mountpoint be expired rather than
 	 * unmounting unconditionally. Unmount only happens if:
@@ -633,6 +643,9 @@ asmlinkage long sys_umount(char __user *
 {
 	struct nameidata nd;
 	int retval;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
 	if (retval)
@@ -917,6 +930,10 @@ static int do_loopback(struct nameidata 
 
 	if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
 		goto out;
+	/***** SAKURA Linux start. *****/
+	err = -EPERM;
+	if (SAKURA_MayMount(nd) < 0 || CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) goto out;
+	/***** SAKURA Linux end. *****/
 
 	err = -ENOMEM;
 	if (recurse)
@@ -1001,7 +1018,10 @@ static int do_move_mount(struct nameidat
 	err = -EINVAL;
 	if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
 		goto out;
-
+	/***** SAKURA Linux start. *****/
+	err = -EPERM;
+	if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0 || CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) goto out;
+	/***** SAKURA Linux end. *****/
 	err = -ENOENT;
 	mutex_lock(&nd->dentry->d_inode->i_mutex);
 	if (IS_DEADDIR(nd->dentry->d_inode))
@@ -1103,6 +1123,10 @@ int do_add_mount(struct vfsmount *newmnt
 	err = -EINVAL;
 	if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
 		goto unlock;
+	/***** SAKURA Linux start. *****/
+	err = -EPERM;
+	if (SAKURA_MayMount(nd) < 0 || CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) goto unlock;
+	/***** SAKURA Linux end. *****/
 
 	newmnt->mnt_flags = mnt_flags;
 	if ((err = graft_tree(newmnt, nd)))
@@ -1547,6 +1571,9 @@ asmlinkage long sys_mount(char __user * 
 	unsigned long type_page;
 	unsigned long dev_page;
 	char *dir_page;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	retval = copy_mount_options(type, &type_page);
 	if (retval < 0)
@@ -1565,6 +1592,15 @@ asmlinkage long sys_mount(char __user * 
 	if (retval < 0)
 		goto out3;
 
+	/***** SAKURA Linux start. *****/
+	retval = -EPERM;
+	if (CheckMountPermission((char *) dev_page, dir_page, (char *) type_page, &flags) < 0 ||
+ 		CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) {
+		free_page(data_page);
+		goto out3;
+	}
+	/***** SAKURA Linux end. *****/
+
 	lock_kernel();
 	retval = do_mount((char *)dev_page, dir_page, (char *)type_page,
 			  flags, (void *)data_page);
@@ -1684,6 +1720,10 @@ asmlinkage long sys_pivot_root(const cha
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
+	/***** SAKURA Linux start. *****/
+	if (CheckPivotRootPermission() < 0 || CheckTaskCapability(SAKURA_DISABLE_PIVOTROOT) < 0) return -EPERM;
+	/***** SAKURA Linux end. *****/
+
 	lock_kernel();
 
 	error = __user_walk(new_root, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/open.c linux-2.6.19-1.2895.fc6-ccs/fs/open.c
--- linux-2.6.19-1.2895.fc6/fs/open.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/open.c	2007-01-22 16:18:27.000000000 +0900
@@ -27,6 +27,12 @@
 #include <linux/syscalls.h>
 #include <linux/rcupdate.h>
 #include <linux/audit.h>
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
@@ -264,6 +270,9 @@ static long do_sys_truncate(const char _
 	if (error)
 		goto dput_and_out;
 
+	/***** TOMOYO Linux start. *****/
+	if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)
+	/***** TOMOYO Linux end. *****/
 	error = locks_verify_truncate(inode, NULL, length);
 	if (!error) {
 		DQUOT_INIT(inode);
@@ -272,6 +281,7 @@ static long do_sys_truncate(const char _
 	put_write_access(inode);
 
 dput_and_out:
+	if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "do_sys_truncate"); /***** ReadOnly Tracer *****/
 	path_release(&nd);
 out:
 	return error;
@@ -317,10 +327,14 @@ static long do_sys_ftruncate(unsigned in
 	if (IS_APPEND(inode))
 		goto out_putf;
 
+	/***** TOMOYO Linux start. *****/
+	if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)
+	/***** TOMOYO Linux end. *****/
 	error = locks_verify_truncate(inode, file, length);
 	if (!error)
 		error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
 out_putf:
+	if (error == -EROFS) ROFS_Log_from_dentry(file->f_dentry, file->f_vfsmnt, "do_sys_ftruncate"); /***** ReadOnly Tracer *****/
 	fput(file);
 out:
 	return error;
@@ -399,6 +413,9 @@ asmlinkage long sys_faccessat(int dfd, c
 		res = -EROFS;
 
 out_path_release:
+#if 0
+	if (res == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_access"); /***** ReadOnly Tracer *****/
+#endif
 	path_release(&nd);
 out:
 	current->fsuid = old_fsuid;
@@ -469,6 +486,9 @@ asmlinkage long sys_chroot(const char __
 {
 	struct nameidata nd;
 	int error;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
 	if (error)
@@ -482,6 +502,19 @@ asmlinkage long sys_chroot(const char __
 	if (!capable(CAP_SYS_CHROOT))
 		goto dput_and_out;
 
+	/***** SAKURA Linux start. *****/
+    {
+        char *name = getname(filename);
+        if (!IS_ERR(name)) {
+            error = CheckChRootPermission(name) | CheckTaskCapability(SAKURA_DISABLE_CHROOT);
+            putname(name);
+        } else {
+            error = PTR_ERR(name);
+        }
+        if (error < 0) goto dput_and_out;
+    }
+	/***** SAKURA Linux end. *****/
+
 	set_fs_root(current->fs, nd.mnt, nd.dentry);
 	set_fs_altroot();
 	error = 0;
@@ -523,6 +556,7 @@ asmlinkage long sys_fchmod(unsigned int 
 	mutex_unlock(&inode->i_mutex);
 
 out_putf:
+	if (err == -EROFS) ROFS_Log_from_dentry(file->f_dentry, file->f_vfsmnt, "sys_fchmod"); /***** ReadOnly Tracer *****/
 	fput(file);
 out:
 	return err;
@@ -558,6 +592,7 @@ asmlinkage long sys_fchmodat(int dfd, co
 	mutex_unlock(&inode->i_mutex);
 
 dput_and_out:
+	if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_chmod"); /***** ReadOnly Tracer *****/
 	path_release(&nd);
 out:
 	return error;
@@ -612,6 +647,7 @@ asmlinkage long sys_chown(const char __u
 	if (error)
 		goto out;
 	error = chown_common(nd.dentry, user, group);
+	if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_chown"); /***** ReadOnly Tracer *****/
 	path_release(&nd);
 out:
 	return error;
@@ -632,6 +668,7 @@ asmlinkage long sys_fchownat(int dfd, co
 	if (error)
 		goto out;
 	error = chown_common(nd.dentry, user, group);
+	if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_fchownat"); /***** ReadOnly Tracer *****/
 	path_release(&nd);
 out:
 	return error;
@@ -646,6 +683,7 @@ asmlinkage long sys_lchown(const char __
 	if (error)
 		goto out;
 	error = chown_common(nd.dentry, user, group);
+	if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_lchown"); /***** ReadOnly Tracer *****/
 	path_release(&nd);
 out:
 	return error;
@@ -665,6 +703,7 @@ asmlinkage long sys_fchown(unsigned int 
 	dentry = file->f_dentry;
 	audit_inode(NULL, dentry->d_inode);
 	error = chown_common(dentry, user, group);
+	if (error == -EROFS) ROFS_Log_from_dentry(dentry, file->f_vfsmnt, "sys_fchown"); /***** ReadOnly Tracer *****/
 	fput(file);
 out:
 	return error;
@@ -1085,6 +1124,9 @@ EXPORT_SYMBOL(sys_close);
  */
 asmlinkage long sys_vhangup(void)
 {
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0)
+	/***** TOMOYO Linux end. *****/
 	if (capable(CAP_SYS_TTY_CONFIG)) {
 		tty_vhangup(current->signal->tty);
 		return 0;
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/proc/Makefile linux-2.6.19-1.2895.fc6-ccs/fs/proc/Makefile
--- linux-2.6.19-1.2895.fc6/fs/proc/Makefile	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/proc/Makefile	2007-01-22 16:18:27.000000000 +0900
@@ -13,3 +13,6 @@ proc-y       += inode.o root.o base.o ge
 proc-$(CONFIG_PROC_KCORE)	+= kcore.o
 proc-$(CONFIG_PROC_VMCORE)	+= vmcore.o
 proc-$(CONFIG_PROC_DEVICETREE)	+= proc_devtree.o
+
+proc-$(CONFIG_SAKURA) += ccs_proc.o
+proc-$(CONFIG_TOMOYO) += ccs_proc.o
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/proc/proc_misc.c linux-2.6.19-1.2895.fc6-ccs/fs/proc/proc_misc.c
--- linux-2.6.19-1.2895.fc6/fs/proc/proc_misc.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/proc/proc_misc.c	2007-01-22 16:19:46.000000000 +0900
@@ -742,4 +742,13 @@ void __init proc_misc_init(void)
 	if (entry)
 		entry->proc_fops = &proc_sysrq_trigger_operations;
 #endif
+	/***** CCS start. *****/
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
+	{
+		extern void __init CCSProc_Init(void);
+		CCSProc_Init();
+		printk("Hook version: 2.6.19-1.2895.fc6 2007/01/22\n");
+	}
+#endif
+	/***** CCS end. *****/
 }
diff -ubBpEr linux-2.6.19-1.2895.fc6/fs/utimes.c linux-2.6.19-1.2895.fc6-ccs/fs/utimes.c
--- linux-2.6.19-1.2895.fc6/fs/utimes.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/fs/utimes.c	2007-01-22 16:18:27.000000000 +0900
@@ -5,6 +5,9 @@
 #include <linux/utime.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
 
 #ifdef __ARCH_WANT_SYS_UTIME
 
@@ -64,6 +67,7 @@ asmlinkage long sys_utime(char __user * 
 	error = notify_change(nd.dentry, &newattrs);
 	mutex_unlock(&inode->i_mutex);
 dput_and_out:
+	if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_utime"); /***** ReadOnly Tracer *****/
 	path_release(&nd);
 out:
 	return error;
@@ -117,6 +121,7 @@ long do_utimes(int dfd, char __user *fil
 	error = notify_change(nd.dentry, &newattrs);
 	mutex_unlock(&inode->i_mutex);
 dput_and_out:
+	if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_utimes"); /***** ReadOnly Tracer *****/
 	path_release(&nd);
 out:
 	return error;
diff -ubBpEr linux-2.6.19-1.2895.fc6/include/linux/init_task.h linux-2.6.19-1.2895.fc6-ccs/include/linux/init_task.h
--- linux-2.6.19-1.2895.fc6/include/linux/init_task.h	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/include/linux/init_task.h	2007-01-22 16:18:27.000000000 +0900
@@ -137,6 +137,12 @@ extern struct group_info init_groups;
 	.pi_lock	= SPIN_LOCK_UNLOCKED,				\
 	INIT_TRACE_IRQFLAGS						\
 	INIT_LOCKDEP							\
+	/***** TOMOYO Linux start. *****/        \
+	.domain_info = &KERNEL_DOMAIN,           \
+	/***** TOMOYO Linux end. *****/          \
+	/***** SAKURA Linux start. *****/        \
+	.dropped_capability = 0,                 \
+	/***** SAKURA Linux end. *****/          \
 }
 
 
diff -ubBpEr linux-2.6.19-1.2895.fc6/include/linux/sched.h linux-2.6.19-1.2895.fc6-ccs/include/linux/sched.h
--- linux-2.6.19-1.2895.fc6/include/linux/sched.h	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/include/linux/sched.h	2007-01-22 16:18:27.000000000 +0900
@@ -27,6 +27,11 @@
 #define CLONE_NEWUTS		0x04000000	/* New utsname group? */
 #define CLONE_NEWIPC		0x08000000	/* New ipcs */
 
+/***** TOMOYO Linux start. *****/
+struct domain_info;
+extern struct domain_info KERNEL_DOMAIN;
+/***** TOMOYO Linux end. *****/
+
 /*
  * Scheduling policies
  */
@@ -1030,6 +1035,12 @@ struct task_struct {
 #ifdef	CONFIG_TASK_DELAY_ACCT
 	struct task_delay_info *delays;
 #endif
+	/***** TOMOYO Linux start. *****/
+	struct domain_info *domain_info;
+	/***** TOMOYO Linux end. *****/
+	/***** SAKURA Linux start. *****/
+	unsigned int dropped_capability;
+	/***** SAKURA Linux end. *****/
 };
 
 static inline pid_t process_group(struct task_struct *tsk)
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/kexec.c linux-2.6.19-1.2895.fc6-ccs/kernel/kexec.c
--- linux-2.6.19-1.2895.fc6/kernel/kexec.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/kexec.c	2007-01-22 16:18:27.000000000 +0900
@@ -26,6 +26,9 @@
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/semaphore.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 /* Per cpu memory for storing cpu states in case of system crash. */
 note_buf_t* crash_notes;
@@ -922,6 +925,9 @@ asmlinkage long sys_kexec_load(unsigned 
 	/* We only trust the superuser with rebooting the system. */
 	if (!capable(CAP_SYS_BOOT))
 		return -EPERM;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	/*
 	 * Verify we have a legal set of flags
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/kmod.c linux-2.6.19-1.2895.fc6-ccs/kernel/kmod.c
--- linux-2.6.19-1.2895.fc6/kernel/kmod.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/kmod.c	2007-01-22 16:18:27.000000000 +0900
@@ -165,6 +165,13 @@ static int ____call_usermodehelper(void 
 	/* We can run anywhere, unlike our parent keventd(). */
 	set_cpus_allowed(current, CPU_MASK_ALL);
 
+	/***** TOMOYO Linux start. *****/
+	current->domain_info = &KERNEL_DOMAIN;
+	/***** TOMOYO Linux start. *****/
+	/***** SAKURA Linux start. *****/
+	current->dropped_capability = 0;
+	/***** SAKURA Linux end. *****/
+
 	retval = -EPERM;
 	if (current->fs->root)
 		retval = kernel_execve(sub_info->path,
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/module.c linux-2.6.19-1.2895.fc6-ccs/kernel/module.c
--- linux-2.6.19-1.2895.fc6/kernel/module.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/module.c	2007-01-22 16:19:22.000000000 +0900
@@ -45,6 +45,9 @@
 #include <asm/cacheflush.h>
 #include <linux/license.h>
 #include "module-verify.h"
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 #if 0
 #define DEBUGP printk
@@ -659,7 +662,9 @@ sys_delete_module(const char __user *nam
 
 	if (!capable(CAP_SYS_MODULE))
 		return -EPERM;
-
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 	if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
 		return -EFAULT;
 	name[MODULE_NAME_LEN-1] = '\0';
@@ -1918,7 +1923,9 @@ sys_init_module(void __user *umod,
 	/* Must have permission */
 	if (!capable(CAP_SYS_MODULE))
 		return -EPERM;
-
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 	/* Only one module load at a time, please */
 	if (mutex_lock_interruptible(&module_mutex) != 0)
 		return -EINTR;
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/sched.c linux-2.6.19-1.2895.fc6-ccs/kernel/sched.c
--- linux-2.6.19-1.2895.fc6/kernel/sched.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/sched.c	2007-01-22 16:18:27.000000000 +0900
@@ -55,6 +55,9 @@
 #include <asm/tlb.h>
 
 #include <asm/unistd.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 /*
  * Convert user-nice values [ -20 ... 0 ... 19 ]
@@ -3998,6 +4001,9 @@ int can_nice(const struct task_struct *p
 asmlinkage long sys_nice(int increment)
 {
 	long nice, retval;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	/*
 	 * Setpriority might change our priority at the same moment.
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/signal.c linux-2.6.19-1.2895.fc6-ccs/kernel/signal.c
--- linux-2.6.19-1.2895.fc6/kernel/signal.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/signal.c	2007-01-22 16:18:27.000000000 +0900
@@ -28,6 +28,9 @@
 #include <asm/unistd.h>
 #include <asm/siginfo.h>
 #include "audit.h"	/* audit_signal_info() */
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 /*
  * SLAB caches for signal bits.
@@ -2131,6 +2134,10 @@ asmlinkage long
 sys_kill(int pid, int sig)
 {
 	struct siginfo info;
+	/***** TOMOYO Linux start. *****/
+	if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
+	if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	info.si_signo = sig;
 	info.si_errno = 0;
@@ -2189,6 +2196,10 @@ asmlinkage long sys_tgkill(int tgid, int
 	/* This is only valid for single tasks */
 	if (pid <= 0 || tgid <= 0)
 		return -EINVAL;
+	/***** TOMOYO Linux start. *****/
+	if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
+	if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	return do_tkill(tgid, pid, sig);
 }
@@ -2202,6 +2213,10 @@ sys_tkill(int pid, int sig)
 	/* This is only valid for single tasks */
 	if (pid <= 0)
 		return -EINVAL;
+	/***** TOMOYO Linux start. *****/
+	if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
+	if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	return do_tkill(0, pid, sig);
 }
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/sys.c linux-2.6.19-1.2895.fc6-ccs/kernel/sys.c
--- linux-2.6.19-1.2895.fc6/kernel/sys.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/sys.c	2007-01-22 16:18:27.000000000 +0900
@@ -37,6 +37,9 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unistd.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 #ifndef SET_UNALIGN_CTL
 # define SET_UNALIGN_CTL(a,b)	(-EINVAL)
@@ -592,6 +595,9 @@ asmlinkage long sys_setpriority(int whic
 
 	if (which > 2 || which < 0)
 		goto out;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	/* normalize: avoid signed division (rounding problems) */
 	error = -ESRCH;
@@ -815,6 +821,9 @@ asmlinkage long sys_reboot(int magic1, i
 			magic2 != LINUX_REBOOT_MAGIC2B &&
 	                magic2 != LINUX_REBOOT_MAGIC2C))
 		return -EINVAL;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	/* Instead of trying to make the power_off code look like
 	 * halt when pm_power_off is not set do it the easy way.
@@ -1793,6 +1802,9 @@ asmlinkage long sys_sethostname(char __u
 		return -EPERM;
 	if (len < 0 || len > __NEW_UTS_LEN)
 		return -EINVAL;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 	down_write(&uts_sem);
 	errno = -EFAULT;
 	if (!copy_from_user(tmp, name, len)) {
@@ -1838,6 +1850,9 @@ asmlinkage long sys_setdomainname(char _
 		return -EPERM;
 	if (len < 0 || len > __NEW_UTS_LEN)
 		return -EINVAL;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	down_write(&uts_sem);
 	errno = -EFAULT;
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/sysctl.c linux-2.6.19-1.2895.fc6-ccs/kernel/sysctl.c
--- linux-2.6.19-1.2895.fc6/kernel/sysctl.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/sysctl.c	2007-01-22 16:18:27.000000000 +0900
@@ -48,6 +48,9 @@
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
                      void __user *buffer, size_t *lenp, loff_t *ppos);
@@ -1279,6 +1282,88 @@ void __init sysctl_init(void)
 }
 
 #ifdef CONFIG_SYSCTL_SYSCALL
+
+/***** TOMOYO Linux start. *****/
+static int try_parse_table(int __user *name, int nlen, void __user *oldval, void __user *newval, ctl_table *table)
+{
+	int n;
+	int error = -ENOMEM;
+	int op = 0;
+	char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (oldval) op |= 004;
+	if (newval) op |= 002;
+	if (!op) { /* Neither read nor write */
+		error = 0;
+		goto out;
+	}
+	if (!buffer) goto out;
+	memset(buffer, 0, PAGE_SIZE);
+	snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
+ repeat:
+	if (!nlen) {
+		error = -ENOTDIR;
+		goto out;
+	}
+	if (get_user(n, name)) {
+		error = -EFAULT;
+		goto out;
+	}
+	for ( ; table->ctl_name; table++) {
+		if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
+			int pos = strlen(buffer);
+			const char *cp = table->procname;
+			error = -ENOMEM;
+			if (cp) {
+				if (pos + 1 >= PAGE_SIZE - 1) goto out;
+				buffer[pos++] = '/';
+				while (*cp) {
+					const unsigned char c = * (const unsigned char *) cp;
+					if (c == '\\') {
+						if (pos + 2 >= PAGE_SIZE - 1) goto out;
+						buffer[pos++] = '\\';
+						buffer[pos++] = '\\';
+					} else if (c > ' ' && c < 127) {
+						if (pos + 1 >= PAGE_SIZE - 1) goto out;
+						buffer[pos++] = c;
+					} else {
+						if (pos + 4 >= PAGE_SIZE - 1) goto out;
+						buffer[pos++] = '\\';
+						buffer[pos++] = (c >> 6) + '0';
+						buffer[pos++] = ((c >> 3) & 7) + '0';
+						buffer[pos++] = (c & 7) + '0';
+					}
+					cp++;
+				}
+			} else {
+				/* Assume nobody assigns "=\$=" for procname. */
+				snprintf(buffer + pos, PAGE_SIZE - pos - 1, "/=%d=", table->ctl_name);
+				if (memchr(buffer, '\0', PAGE_SIZE - 2) == NULL) goto out;
+			}
+			if (table->child) {
+				if (table->strategy) {
+					/* printk("sysctl='%s'\n", buffer); */
+					if (CheckFilePerm(buffer, op, "sysctl")) {
+						error = -EPERM;
+						goto out;
+					}
+				}
+				name++;
+				nlen--;
+				table = table->child;
+				goto repeat;
+			}
+			/* printk("sysctl='%s'\n", buffer); */
+			error = CheckFilePerm(buffer, op, "sysctl");
+			goto out;
+		}
+	}
+	error = -ENOTDIR;
+ out:
+	kfree(buffer);
+	return error;
+}
+/***** TOMOYO Linux end. *****/
+
 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
 	       void __user *newval, size_t newlen)
 {
@@ -1304,6 +1389,9 @@ int do_sysctl(int __user *name, int nlen
 
 		spin_unlock(&sysctl_lock);
 
+		/***** TOMOYO Linux start. *****/
+		if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0)
+		/***** TOMOYO Linux end. *****/
 		error = parse_table(name, nlen, oldval, oldlenp, 
 					newval, newlen, head->ctl_table,
 					&context);
@@ -1380,6 +1468,12 @@ repeat:
 				if (ctl_perm(table, 001))
 					return -EPERM;
 				if (table->strategy) {
+					/***** TOMOYO Linux start. *****/
+					int op = 0;
+					if (oldval) op |= 004;
+					if (newval) op |= 002;
+					if (ctl_perm(table, op)) return -EPERM;
+					/***** TOMOYO Linux end. *****/
 					error = table->strategy(
 						table, name, nlen,
 						oldval, oldlenp,
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/time/ntp.c linux-2.6.19-1.2895.fc6-ccs/kernel/time/ntp.c
--- linux-2.6.19-1.2895.fc6/kernel/time/ntp.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/time/ntp.c	2007-01-22 16:18:27.000000000 +0900
@@ -14,6 +14,9 @@
 
 #include <asm/div64.h>
 #include <asm/timex.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 /*
  * Timekeeping variables
@@ -199,6 +202,9 @@ int do_adjtimex(struct timex *txc)
 	/* In order to modify anything, you gotta be super-user! */
 	if (txc->modes && !capable(CAP_SYS_TIME))
 		return -EPERM;
+	/***** TOMOYO Linux start. *****/
+	if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	/* Now we validate the data before disabling interrupts */
 
diff -ubBpEr linux-2.6.19-1.2895.fc6/kernel/time.c linux-2.6.19-1.2895.fc6-ccs/kernel/time.c
--- linux-2.6.19-1.2895.fc6/kernel/time.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/kernel/time.c	2007-01-22 16:18:27.000000000 +0900
@@ -39,6 +39,9 @@
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 /* 
  * The timezone where the local system is located.  Used as a default by some
@@ -91,6 +94,9 @@ asmlinkage long sys_stime(time_t __user 
 	err = security_settime(&tv, NULL);
 	if (err)
 		return err;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	do_settimeofday(&tv);
 	return 0;
@@ -161,6 +167,9 @@ int do_sys_settimeofday(struct timespec 
 	error = security_settime(tv, tz);
 	if (error)
 		return error;
+	/***** TOMOYO Linux start. *****/
+	if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
+	/***** TOMOYO Linux end. *****/
 
 	if (tz) {
 		/* SMP safe, global irq locking makes it work. */
diff -ubBpEr linux-2.6.19-1.2895.fc6/net/ipv4/inet_connection_sock.c linux-2.6.19-1.2895.fc6-ccs/net/ipv4/inet_connection_sock.c
--- linux-2.6.19-1.2895.fc6/net/ipv4/inet_connection_sock.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/net/ipv4/inet_connection_sock.c	2007-01-22 16:18:27.000000000 +0900
@@ -23,6 +23,9 @@
 #include <net/route.h>
 #include <net/tcp_states.h>
 #include <net/xfrm.h>
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
 
 #ifdef INET_CSK_DEBUG
 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
@@ -87,6 +90,9 @@ int inet_csk_get_port(struct inet_hashin
 		do {
 			head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
 			spin_lock(&head->lock);
+			/***** SAKURA Linux start. *****/
+			if (SAKURA_MayAutobind(rover) < 0) goto next;
+			/***** SAKURA Linux end. *****/
 			inet_bind_bucket_for_each(tb, node, &head->chain)
 				if (tb->port == rover)
 					goto next;
diff -ubBpEr linux-2.6.19-1.2895.fc6/net/ipv4/inet_hashtables.c linux-2.6.19-1.2895.fc6-ccs/net/ipv4/inet_hashtables.c
--- linux-2.6.19-1.2895.fc6/net/ipv4/inet_hashtables.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/net/ipv4/inet_hashtables.c	2007-01-22 16:18:27.000000000 +0900
@@ -22,6 +22,9 @@
 #include <net/inet_connection_sock.h>
 #include <net/inet_hashtables.h>
 #include <net/ip.h>
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
 
 /*
  * Allocate and initialize a new local port bind bucket.
@@ -292,6 +295,9 @@ int inet_hash_connect(struct inet_timewa
  		local_bh_disable();
 		for (i = 1; i <= range; i++) {
 			port = low + (i + offset) % range;
+			/***** SAKURA Linux start. *****/
+			if (SAKURA_MayAutobind(port) < 0) continue;
+			/***** SAKURA Linux end. *****/
  			head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
  			spin_lock(&head->lock);
 
diff -ubBpEr linux-2.6.19-1.2895.fc6/net/ipv4/udp.c linux-2.6.19-1.2895.fc6-ccs/net/ipv4/udp.c
--- linux-2.6.19-1.2895.fc6/net/ipv4/udp.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/net/ipv4/udp.c	2007-01-22 16:18:27.000000000 +0900
@@ -108,6 +108,9 @@
 #include <net/inet_common.h>
 #include <net/checksum.h>
 #include <net/xfrm.h>
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
 
 /*
  *	Snmp MIB for the UDP layer
@@ -157,6 +160,9 @@ int udp_get_port(struct sock *sk, unsign
 		best = result = udp_port_rover;
 		for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
 			int size;
+			/***** SAKURA Linux start. *****/
+			if (SAKURA_MayAutobind(result) < 0) continue;
+			/***** SAKURA Linux end. *****/
 
 			head = &udp_hash[result & (UDP_HTABLE_SIZE - 1)];
 			if (hlist_empty(head)) {
@@ -182,6 +188,9 @@ int udp_get_port(struct sock *sk, unsign
 				result = sysctl_local_port_range[0]
 					+ ((result - sysctl_local_port_range[0]) &
 					   (UDP_HTABLE_SIZE - 1));
+			/***** SAKURA Linux start. *****/
+			if (SAKURA_MayAutobind(result) < 0) continue;
+			/***** SAKURA Linux end. *****/
 			if (!udp_lport_inuse(result))
 				break;
 		}
diff -ubBpEr linux-2.6.19-1.2895.fc6/net/ipv6/inet6_hashtables.c linux-2.6.19-1.2895.fc6-ccs/net/ipv6/inet6_hashtables.c
--- linux-2.6.19-1.2895.fc6/net/ipv6/inet6_hashtables.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/net/ipv6/inet6_hashtables.c	2007-01-22 16:18:27.000000000 +0900
@@ -21,6 +21,9 @@
 #include <net/inet_hashtables.h>
 #include <net/inet6_hashtables.h>
 #include <net/ip.h>
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
 
 void __inet6_hash(struct inet_hashinfo *hashinfo,
 				struct sock *sk)
@@ -266,6 +269,9 @@ int inet6_hash_connect(struct inet_timew
  		local_bh_disable();
 		for (i = 1; i <= range; i++) {
 			port = low + (i + offset) % range;
+			/***** SAKURA Linux start. *****/
+			if (SAKURA_MayAutobind(port) < 0) continue;
+			/***** SAKURA Linux end. *****/
  			head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
  			spin_lock(&head->lock);
 
diff -ubBpEr linux-2.6.19-1.2895.fc6/net/socket.c linux-2.6.19-1.2895.fc6-ccs/net/socket.c
--- linux-2.6.19-1.2895.fc6/net/socket.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/net/socket.c	2007-01-22 16:18:27.000000000 +0900
@@ -94,6 +94,11 @@
 #include <net/sock.h>
 #include <linux/netfilter.h>
 
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+#include <linux/tomoyo_socket.h>
+/***** TOMOYO Linux end. *****/
+
 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
 			 unsigned long nr_segs, loff_t pos);
@@ -550,7 +555,9 @@ static inline int __sock_sendmsg(struct 
 	err = security_socket_sendmsg(sock, msg, size);
 	if (err)
 		return err;
-
+	/***** TOMOYO Linux start. *****/
+	if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;
+	/***** TOMOYO Linux start. *****/
 	return sock->ops->sendmsg(iocb, sock, msg, size);
 }
 
@@ -617,6 +624,11 @@ int sock_recvmsg(struct socket *sock, st
 	ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
 	if (-EIOCBQUEUED == ret)
 		ret = wait_on_sync_kiocb(&iocb);
+	/***** TOMOYO Linux start. *****/
+	if (ret >= 0 && CheckSocketRecvMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) {
+		ret = -EAGAIN; /* Hope less harmful than -EPERM. */
+	}
+	/***** TOMOYO Linux end. *****/
 	return ret;
 }
 
@@ -1076,6 +1088,10 @@ static int __sock_create(int family, int
 		family = PF_PACKET;
 	}
 
+	/***** TOMOYO Linux start. *****/
+	if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err;
+	/***** TOMOYO Linux end. *****/
+
 	err = security_socket_create(family, type, protocol, kern);
 	if (err)
 		return err;
@@ -1278,6 +1294,9 @@ asmlinkage long sys_bind(int fd, struct 
 			err = security_socket_bind(sock,
 						   (struct sockaddr *)address,
 						   addrlen);
+			/***** TOMOYO Linux start. *****/
+			if (!err) err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen);
+			/***** TOMOYO Linux end. *****/
 			if (!err)
 				err = sock->ops->bind(sock,
 						      (struct sockaddr *)
@@ -1307,6 +1326,9 @@ asmlinkage long sys_listen(int fd, int b
 			backlog = sysctl_somaxconn;
 
 		err = security_socket_listen(sock, backlog);
+		/***** TOMOYO Linux start. *****/
+		if (!err) err = CheckSocketListenPermission(sock);
+		/***** TOMOYO Linux end. *****/
 		if (!err)
 			err = sock->ops->listen(sock, backlog);
 
@@ -1371,6 +1393,12 @@ asmlinkage long sys_accept(int fd, struc
 	if (err < 0)
 		goto out_fd;
 
+	/***** TOMOYO Linux start. *****/
+	if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) {
+		err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
+		goto out_fd;
+	}
+	/***** TOMOYO Linux end. *****/
 	if (upeer_sockaddr) {
 		if (newsock->ops->getname(newsock, (struct sockaddr *)address,
 					  &len, 2) < 0) {
@@ -1430,6 +1458,10 @@ asmlinkage long sys_connect(int fd, stru
 	    security_socket_connect(sock, (struct sockaddr *)address, addrlen);
 	if (err)
 		goto out_put;
+	/***** TOMOYO Linux start. *****/
+	err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen);
+	if (err) goto out_put;
+	/***** TOMOYO Linux end. *****/
 
 	err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
 				 sock->file->f_flags);
diff -ubBpEr linux-2.6.19-1.2895.fc6/net/unix/af_unix.c linux-2.6.19-1.2895.fc6-ccs/net/unix/af_unix.c
--- linux-2.6.19-1.2895.fc6/net/unix/af_unix.c	2007-01-22 16:17:18.000000000 +0900
+++ linux-2.6.19-1.2895.fc6-ccs/net/unix/af_unix.c	2007-01-22 16:18:27.000000000 +0900
@@ -116,6 +116,12 @@
 #include <linux/mount.h>
 #include <net/checksum.h>
 #include <linux/security.h>
+/***** SAKURA Linux start. *****/
+#include <linux/sakura.h>
+/***** SAKURA Linux end. *****/
+/***** TOMOYO Linux start. *****/
+#include <linux/tomoyo.h>
+/***** TOMOYO Linux end. *****/
 
 int sysctl_unix_max_dgram_qlen __read_mostly = 10;
 
@@ -764,6 +770,10 @@ static int unix_bind(struct socket *sock
 		err = unix_autobind(sock);
 		goto out;
 	}
+	/***** TOMOYO Linux start. *****/
+	err = -EPERM;
+	if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out;
+	/***** TOMOYO Linux end. *****/
 
 	err = unix_mkname(sunaddr, addr_len, &hash);
 	if (err < 0)
@@ -807,7 +817,11 @@ static int unix_bind(struct socket *sock
 		 */
 		mode = S_IFSOCK |
 		       (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
+		/***** TOMOYO Linux start. *****/
+		if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)
+		/***** TOMOYO Linux end. *****/
 		err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
+		if (err == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "unix_bind"); /***** ReadOnly Tracer *****/
 		if (err)
 			goto out_mknod_dput;
 		mutex_unlock(&nd.dentry->d_inode->i_mutex);
