開發和下載開源軟體

Browse Subversion Repository

Contents of /trunk/ccs-patch/ccs-patch-2.6.12.3-a9-8.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 115 - (show annotations) (download)
Tue Mar 6 12:27:09 2007 UTC (17 years, 2 months ago) by kumaneko
File MIME type: text/plain
File size: 43425 byte(s)


1 diff -ubBpEr linux-2.6.12.3-a9-8/Makefile linux-2.6.12.3-a9-8-ccs/Makefile
2 --- linux-2.6.12.3-a9-8/Makefile 2006-10-19 21:19:32.000000000 +0900
3 +++ linux-2.6.12.3-a9-8-ccs/Makefile 2006-11-20 15:28:51.000000000 +0900
4 @@ -1,7 +1,7 @@
5 VERSION = 2
6 PATCHLEVEL = 6
7 SUBLEVEL = 12
8 -EXTRAVERSION = .3-a9-8
9 +EXTRAVERSION = .3-a9-8-ccs
10 NAME=Woozy Numbat
11
12 # *DOCUMENTATION*
13 diff -ubBpEr linux-2.6.12.3-a9-8/fs/Kconfig linux-2.6.12.3-a9-8-ccs/fs/Kconfig
14 --- linux-2.6.12.3-a9-8/fs/Kconfig 2005-07-16 06:18:57.000000000 +0900
15 +++ linux-2.6.12.3-a9-8-ccs/fs/Kconfig 2006-11-20 15:28:32.000000000 +0900
16 @@ -1725,5 +1725,7 @@ endmenu
17
18 source "fs/nls/Kconfig"
19
20 +source "fs/Kconfig.ccs"
21 +
22 endmenu
23
24 diff -ubBpEr linux-2.6.12.3-a9-8/fs/Makefile linux-2.6.12.3-a9-8-ccs/fs/Makefile
25 --- linux-2.6.12.3-a9-8/fs/Makefile 2005-07-16 06:18:57.000000000 +0900
26 +++ linux-2.6.12.3-a9-8-ccs/fs/Makefile 2006-11-20 15:28:32.000000000 +0900
27 @@ -95,3 +95,5 @@ obj-$(CONFIG_BEFS_FS) += befs/
28 obj-$(CONFIG_HOSTFS) += hostfs/
29 obj-$(CONFIG_HPPFS) += hppfs/
30 obj-$(CONFIG_DEBUG_FS) += debugfs/
31 +
32 +include $(srctree)/fs/Makefile-2.6.ccs
33 diff -ubBpEr linux-2.6.12.3-a9-8/fs/attr.c linux-2.6.12.3-a9-8-ccs/fs/attr.c
34 --- linux-2.6.12.3-a9-8/fs/attr.c 2005-07-16 06:18:57.000000000 +0900
35 +++ linux-2.6.12.3-a9-8-ccs/fs/attr.c 2007-03-05 17:58:28.000000000 +0900
36 @@ -15,6 +15,9 @@
37 #include <linux/quotaops.h>
38 #include <linux/security.h>
39 #include <linux/time.h>
40 +/***** TOMOYO Linux start. *****/
41 +#include <linux/tomoyo.h>
42 +/***** TOMOYO Linux end. *****/
43
44 /* Taken over from the old code... */
45
46 @@ -179,12 +182,20 @@ int notify_change(struct dentry * dentry
47
48 if (inode->i_op && inode->i_op->setattr) {
49 error = security_inode_setattr(dentry, attr);
50 + /***** TOMOYO Linux start. *****/
51 + if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);
52 + if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);
53 + /***** TOMOYO Linux end. *****/
54 if (!error)
55 error = inode->i_op->setattr(dentry, attr);
56 } else {
57 error = inode_change_ok(inode, attr);
58 if (!error)
59 error = security_inode_setattr(dentry, attr);
60 + /***** TOMOYO Linux start. *****/
61 + if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD);
62 + if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN);
63 + /***** TOMOYO Linux end. *****/
64 if (!error) {
65 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
66 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
67 diff -ubBpEr linux-2.6.12.3-a9-8/fs/compat.c linux-2.6.12.3-a9-8-ccs/fs/compat.c
68 --- linux-2.6.12.3-a9-8/fs/compat.c 2005-07-16 06:18:57.000000000 +0900
69 +++ linux-2.6.12.3-a9-8-ccs/fs/compat.c 2007-03-05 18:00:01.000000000 +0900
70 @@ -50,6 +50,9 @@
71 #include <asm/uaccess.h>
72 #include <asm/mmu_context.h>
73 #include <asm/ioctls.h>
74 +/***** TOMOYO Linux start. *****/
75 +#include <linux/tomoyo.h>
76 +/***** TOMOYO Linux end. *****/
77
78 /*
79 * Not all architectures have sys_utime, so implement this in terms
80 @@ -466,6 +469,9 @@ asmlinkage long compat_sys_ioctl(unsigne
81 /*FALL THROUGH*/
82
83 default:
84 + /***** TOMOYO Linux start. *****/
85 + if ((error = CheckCapabilityACL(TOMOYO_SYS_IOCTL)) < 0) goto out_fput;
86 + /***** TOMOYO Linux end. *****/
87 if (filp->f_op && filp->f_op->compat_ioctl) {
88 error = filp->f_op->compat_ioctl(filp, cmd, arg);
89 if (error != -ENOIOCTLCMD)
90 @@ -1557,7 +1563,7 @@ int compat_do_execve(char * filename,
91 if (retval < 0)
92 goto out;
93
94 - retval = search_binary_handler(bprm, regs);
95 + retval = search_binary_handler_with_transition(bprm, regs);
96 if (retval >= 0) {
97 free_arg_pages(bprm);
98
99 diff -ubBpEr linux-2.6.12.3-a9-8/fs/exec.c linux-2.6.12.3-a9-8-ccs/fs/exec.c
100 --- linux-2.6.12.3-a9-8/fs/exec.c 2005-07-16 06:18:57.000000000 +0900
101 +++ linux-2.6.12.3-a9-8-ccs/fs/exec.c 2007-03-06 11:27:49.000000000 +0900
102 @@ -56,6 +56,10 @@
103 #include <linux/kmod.h>
104 #endif
105
106 +/***** TOMOYO Linux start. *****/
107 +#include <linux/tomoyo.h>
108 +/***** TOMOYO Linux end. *****/
109 +
110 int core_uses_pid;
111 char core_pattern[65] = "core";
112 /* The maximal length of core_pattern is also specified in sysctl.c */
113 @@ -136,6 +140,11 @@ asmlinkage long sys_uselib(const char __
114 if (error)
115 goto exit;
116
117 + /***** TOMOYO Linux start. *****/
118 + error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */
119 + if (error) goto exit;
120 + /***** TOMOYO Linux end. *****/
121 +
122 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
123 error = PTR_ERR(file);
124 if (IS_ERR(file))
125 @@ -504,6 +513,9 @@ struct file *open_exec(const char *name)
126 int err = permission(inode, MAY_EXEC, &nd);
127 if (!err && !(inode->i_mode & 0111))
128 err = -EACCES;
129 + /***** TOMOYO Linux start. *****/
130 + if (!err && (current->tomoyo_flags & TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) err = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */
131 + /***** TOMOYO Linux end. *****/
132 file = ERR_PTR(err);
133 if (!err) {
134 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
135 @@ -1191,7 +1203,8 @@ int do_execve(char * filename,
136 if (retval < 0)
137 goto out;
138
139 - retval = search_binary_handler(bprm,regs);
140 + retval = search_binary_handler_with_transition(bprm,regs);
141 +
142 if (retval >= 0) {
143 free_arg_pages(bprm);
144
145 diff -ubBpEr linux-2.6.12.3-a9-8/fs/fcntl.c linux-2.6.12.3-a9-8-ccs/fs/fcntl.c
146 --- linux-2.6.12.3-a9-8/fs/fcntl.c 2005-07-16 06:18:57.000000000 +0900
147 +++ linux-2.6.12.3-a9-8-ccs/fs/fcntl.c 2007-03-05 18:00:01.000000000 +0900
148 @@ -20,6 +20,9 @@
149 #include <asm/poll.h>
150 #include <asm/siginfo.h>
151 #include <asm/uaccess.h>
152 +/***** TOMOYO Linux start. *****/
153 +#include <linux/tomoyo.h>
154 +/***** TOMOYO Linux end. *****/
155
156 void fastcall set_close_on_exec(unsigned int fd, int flag)
157 {
158 @@ -193,6 +196,10 @@ static int setfl(int fd, struct file * f
159 if (!(arg & O_APPEND) && IS_APPEND(inode))
160 return -EPERM;
161
162 + /***** TOMOYO Linux start. *****/
163 + if (!(arg & O_APPEND) && CheckReWritePermission(filp)) return -EPERM;
164 + /***** TOMOYO Linux end. *****/
165 +
166 /* O_NOATIME can only be set by the owner or superuser */
167 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
168 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
169 diff -ubBpEr linux-2.6.12.3-a9-8/fs/ioctl.c linux-2.6.12.3-a9-8-ccs/fs/ioctl.c
170 --- linux-2.6.12.3-a9-8/fs/ioctl.c 2005-07-16 06:18:57.000000000 +0900
171 +++ linux-2.6.12.3-a9-8-ccs/fs/ioctl.c 2007-03-05 18:00:01.000000000 +0900
172 @@ -15,6 +15,9 @@
173
174 #include <asm/uaccess.h>
175 #include <asm/ioctls.h>
176 +/***** TOMOYO Linux start. *****/
177 +#include <linux/tomoyo.h>
178 +/***** TOMOYO Linux end. *****/
179
180 static long do_ioctl(struct file *filp, unsigned int cmd,
181 unsigned long arg)
182 @@ -23,6 +26,9 @@ static long do_ioctl(struct file *filp,
183
184 if (!filp->f_op)
185 goto out;
186 + /***** TOMOYO Linux start. *****/
187 + if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM;
188 + /***** TOMOYO Linux end. *****/
189
190 if (filp->f_op->unlocked_ioctl) {
191 error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
192 diff -ubBpEr linux-2.6.12.3-a9-8/fs/namei.c linux-2.6.12.3-a9-8-ccs/fs/namei.c
193 --- linux-2.6.12.3-a9-8/fs/namei.c 2005-09-15 23:45:11.000000000 +0900
194 +++ linux-2.6.12.3-a9-8-ccs/fs/namei.c 2007-03-05 18:00:02.000000000 +0900
195 @@ -33,6 +33,10 @@
196
197 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
198
199 +/***** TOMOYO Linux start. *****/
200 +#include <linux/tomoyo.h>
201 +/***** TOMOYO Linux end. *****/
202 +
203 /* [Feb-1997 T. Schoebel-Theuer]
204 * Fundamental changes in the pathname lookup mechanisms (namei)
205 * were necessary because of omirr. The reason is that omirr needs
206 @@ -1311,6 +1315,9 @@ int vfs_create(struct inode *dir, struct
207 error = security_inode_create(dir, dentry, mode);
208 if (error)
209 return error;
210 + /***** TOMOYO Linux start. *****/
211 + if (nd && (error = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;
212 + /***** TOMOYO Linux end. *****/
213 DQUOT_INIT(dir);
214 error = dir->i_op->create(dir, dentry, mode, nd);
215 if (!error) {
216 @@ -1368,6 +1375,11 @@ int may_open(struct nameidata *nd, int a
217 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
218 return -EPERM;
219
220 + /***** TOMOYO Linux start. *****/
221 + error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */
222 + if (error) return error;
223 + /***** TOMOYO Linux end. *****/
224 +
225 /*
226 * Ensure there are no outstanding leases on the file.
227 */
228 @@ -1399,6 +1411,9 @@ int may_open(struct nameidata *nd, int a
229 return 0;
230 }
231
232 +/***** TOMOYO Linux start. *****/
233 +#include <linux/tomoyo_vfs.h>
234 +/***** TOMOYO Linux end. *****/
235 /*
236 * open_namei()
237 *
238 @@ -1638,6 +1653,12 @@ asmlinkage long sys_mknod(const char __u
239
240 if (S_ISDIR(mode))
241 return -EPERM;
242 + /***** TOMOYO Linux start. *****/
243 + if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;
244 + if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;
245 + if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM;
246 + if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;
247 + /***** TOMOYO Linux end. *****/
248 tmp = getname(filename);
249 if (IS_ERR(tmp))
250 return PTR_ERR(tmp);
251 @@ -1656,10 +1677,16 @@ asmlinkage long sys_mknod(const char __u
252 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
253 break;
254 case S_IFCHR: case S_IFBLK:
255 + /***** TOMOYO Linux start. *****/
256 + 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)
257 + /***** TOMOYO Linux end. *****/
258 error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
259 new_decode_dev(dev));
260 break;
261 case S_IFIFO: case S_IFSOCK:
262 + /***** TOMOYO Linux start. *****/
263 + 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)
264 + /***** TOMOYO Linux end. *****/
265 error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
266 break;
267 case S_IFDIR:
268 @@ -1721,6 +1748,9 @@ asmlinkage long sys_mkdir(const char __u
269 if (!IS_ERR(dentry)) {
270 if (!IS_POSIXACL(nd.dentry->d_inode))
271 mode &= ~current->fs->umask;
272 + /***** TOMOYO Linux start. *****/
273 + if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)
274 + /***** TOMOYO Linux end. *****/
275 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
276 dput(dentry);
277 }
278 @@ -1825,6 +1855,9 @@ asmlinkage long sys_rmdir(const char __u
279 dentry = lookup_hash(&nd.last, nd.dentry);
280 error = PTR_ERR(dentry);
281 if (!IS_ERR(dentry)) {
282 + /***** TOMOYO Linux start. *****/
283 + if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)
284 + /***** TOMOYO Linux end. *****/
285 error = vfs_rmdir(nd.dentry->d_inode, dentry);
286 dput(dentry);
287 }
288 @@ -1879,6 +1912,9 @@ asmlinkage long sys_unlink(const char __
289 struct dentry *dentry;
290 struct nameidata nd;
291 struct inode *inode = NULL;
292 + /***** TOMOYO Linux start. *****/
293 + if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM;
294 + /***** TOMOYO Linux end. *****/
295
296 name = getname(pathname);
297 if(IS_ERR(name))
298 @@ -1900,6 +1936,9 @@ asmlinkage long sys_unlink(const char __
299 inode = dentry->d_inode;
300 if (inode)
301 atomic_inc(&inode->i_count);
302 + /***** TOMOYO Linux start. *****/
303 + if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)
304 + /***** TOMOYO Linux end. *****/
305 error = vfs_unlink(nd.dentry->d_inode, dentry);
306 exit2:
307 dput(dentry);
308 @@ -1947,6 +1986,9 @@ asmlinkage long sys_symlink(const char _
309 int error = 0;
310 char * from;
311 char * to;
312 + /***** TOMOYO Linux start. *****/
313 + if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM;
314 + /***** TOMOYO Linux end. *****/
315
316 from = getname(oldname);
317 if(IS_ERR(from))
318 @@ -1963,6 +2005,9 @@ asmlinkage long sys_symlink(const char _
319 dentry = lookup_create(&nd, 0);
320 error = PTR_ERR(dentry);
321 if (!IS_ERR(dentry)) {
322 + /***** TOMOYO Linux start. *****/
323 + if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)
324 + /***** TOMOYO Linux end. *****/
325 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
326 dput(dentry);
327 }
328 @@ -2030,6 +2075,9 @@ asmlinkage long sys_link(const char __us
329 struct nameidata nd, old_nd;
330 int error;
331 char * to;
332 + /***** TOMOYO Linux start. *****/
333 + if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM;
334 + /***** TOMOYO Linux end. *****/
335
336 to = getname(newname);
337 if (IS_ERR(to))
338 @@ -2047,6 +2095,9 @@ asmlinkage long sys_link(const char __us
339 new_dentry = lookup_create(&nd, 0);
340 error = PTR_ERR(new_dentry);
341 if (!IS_ERR(new_dentry)) {
342 + /***** TOMOYO Linux start. *****/
343 + 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)
344 + /***** TOMOYO Linux end. *****/
345 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
346 dput(new_dentry);
347 }
348 @@ -2269,6 +2320,13 @@ static inline int do_rename(const char *
349 if (new_dentry == trap)
350 goto exit5;
351
352 + /***** TOMOYO Linux start. *****/
353 + if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||
354 + (error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {
355 + goto exit5;
356 + }
357 + /***** TOMOYO Linux end. *****/
358 +
359 error = vfs_rename(old_dir->d_inode, old_dentry,
360 new_dir->d_inode, new_dentry);
361 exit5:
362 @@ -2290,6 +2348,9 @@ asmlinkage long sys_rename(const char __
363 int error;
364 char * from;
365 char * to;
366 + /***** TOMOYO Linux start. *****/
367 + if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM;
368 + /***** TOMOYO Linux end. *****/
369
370 from = getname(oldname);
371 if(IS_ERR(from))
372 diff -ubBpEr linux-2.6.12.3-a9-8/fs/namespace.c linux-2.6.12.3-a9-8-ccs/fs/namespace.c
373 --- linux-2.6.12.3-a9-8/fs/namespace.c 2005-07-16 06:18:57.000000000 +0900
374 +++ linux-2.6.12.3-a9-8-ccs/fs/namespace.c 2007-03-05 18:00:02.000000000 +0900
375 @@ -24,6 +24,12 @@
376 #include <linux/mount.h>
377 #include <asm/uaccess.h>
378 #include <asm/unistd.h>
379 +/***** SAKURA Linux start. *****/
380 +#include <linux/sakura.h>
381 +/***** SAKURA Linux end. *****/
382 +/***** TOMOYO Linux start. *****/
383 +#include <linux/tomoyo.h>
384 +/***** TOMOYO Linux end. *****/
385
386 extern int __init init_rootfs(void);
387
388 @@ -373,6 +379,10 @@ static int do_umount(struct vfsmount *mn
389 if (retval)
390 return retval;
391
392 + /***** SAKURA Linux start. *****/
393 + if (SAKURA_MayUmount(mnt) < 0) return -EPERM;
394 + /***** SAKURA Linux end. *****/
395 +
396 /*
397 * Allow userspace to request a mountpoint be expired rather than
398 * unmounting unconditionally. Unmount only happens if:
399 @@ -469,6 +479,9 @@ asmlinkage long sys_umount(char __user *
400 {
401 struct nameidata nd;
402 int retval;
403 + /***** TOMOYO Linux start. *****/
404 + if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM;
405 + /***** TOMOYO Linux end. *****/
406
407 retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
408 if (retval)
409 @@ -634,6 +647,10 @@ static int do_loopback(struct nameidata
410 down_write(&current->namespace->sem);
411 err = -EINVAL;
412 if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {
413 + /***** SAKURA Linux start. *****/
414 + err = -EPERM;
415 + if (SAKURA_MayMount(nd) < 0) goto out;
416 + /***** SAKURA Linux end. *****/
417 err = -ENOMEM;
418 if (recurse)
419 mnt = copy_tree(old_nd.mnt, old_nd.dentry);
420 @@ -655,7 +672,9 @@ static int do_loopback(struct nameidata
421 } else
422 mntput(mnt);
423 }
424 -
425 + /***** SAKURA Linux start. *****/
426 + out:
427 + /***** SAKURA Linux end. *****/
428 up_write(&current->namespace->sem);
429 path_release(&old_nd);
430 return err;
431 @@ -711,7 +730,10 @@ static int do_move_mount(struct nameidat
432 err = -EINVAL;
433 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
434 goto out;
435 -
436 + /***** SAKURA Linux start. *****/
437 + err = -EPERM;
438 + if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0) goto out;
439 + /***** SAKURA Linux end. *****/
440 err = -ENOENT;
441 down(&nd->dentry->d_inode->i_sem);
442 if (IS_DEADDIR(nd->dentry->d_inode))
443 @@ -805,6 +827,10 @@ int do_add_mount(struct vfsmount *newmnt
444 err = -EINVAL;
445 if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
446 goto unlock;
447 + /***** SAKURA Linux start. *****/
448 + err = -EPERM;
449 + if (SAKURA_MayMount(nd) < 0) goto unlock;
450 + /***** SAKURA Linux end. *****/
451
452 newmnt->mnt_flags = mnt_flags;
453 err = graft_tree(newmnt, nd);
454 @@ -1026,6 +1052,13 @@ long do_mount(char * dev_name, char * di
455 if (data_page)
456 ((char *)data_page)[PAGE_SIZE - 1] = 0;
457
458 + /***** TOMOYO Linux start. *****/
459 + if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM;
460 + /***** TOMOYO Linux end. *****/
461 + /***** SAKURA Linux start. *****/
462 + if (CheckMountPermission(dev_name, dir_name, type_page, &flags)) return -EPERM;
463 + /***** SAKURA Linux end. *****/
464 +
465 /* Separate the per-mountpoint flags */
466 if (flags & MS_NOSUID)
467 mnt_flags |= MNT_NOSUID;
468 @@ -1285,6 +1318,10 @@ asmlinkage long sys_pivot_root(const cha
469 if (!capable(CAP_SYS_ADMIN))
470 return -EPERM;
471
472 + /***** SAKURA Linux start. *****/
473 + if (CheckPivotRootPermission() < 0) return -EPERM;
474 + /***** SAKURA Linux end. *****/
475 +
476 lock_kernel();
477
478 error = __user_walk(new_root, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
479 diff -ubBpEr linux-2.6.12.3-a9-8/fs/open.c linux-2.6.12.3-a9-8-ccs/fs/open.c
480 --- linux-2.6.12.3-a9-8/fs/open.c 2005-07-16 06:18:57.000000000 +0900
481 +++ linux-2.6.12.3-a9-8-ccs/fs/open.c 2007-03-05 18:12:31.000000000 +0900
482 @@ -26,6 +26,13 @@
483
484 #include <asm/unistd.h>
485
486 +/***** SAKURA Linux start. *****/
487 +#include <linux/sakura.h>
488 +/***** SAKURA Linux end. *****/
489 +/***** TOMOYO Linux start. *****/
490 +#include <linux/tomoyo.h>
491 +/***** TOMOYO Linux end. *****/
492 +
493 int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
494 {
495 int retval = -ENODEV;
496 @@ -257,6 +264,9 @@ static inline long do_sys_truncate(const
497 if (error)
498 goto dput_and_out;
499
500 + /***** TOMOYO Linux start. *****/
501 + if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)
502 + /***** TOMOYO Linux end. *****/
503 error = locks_verify_truncate(inode, NULL, length);
504 if (!error) {
505 DQUOT_INIT(inode);
506 @@ -310,6 +320,9 @@ static inline long do_sys_ftruncate(unsi
507 if (IS_APPEND(inode))
508 goto out_putf;
509
510 + /***** TOMOYO Linux start. *****/
511 + if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)
512 + /***** TOMOYO Linux end. *****/
513 error = locks_verify_truncate(inode, file, length);
514 if (!error)
515 error = do_truncate(dentry, length);
516 @@ -570,6 +583,9 @@ asmlinkage long sys_chroot(const char __
517 {
518 struct nameidata nd;
519 int error;
520 + /***** TOMOYO Linux start. *****/
521 + if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) return -EPERM;
522 + /***** TOMOYO Linux end. *****/
523
524 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
525 if (error)
526 @@ -583,6 +599,19 @@ asmlinkage long sys_chroot(const char __
527 if (!capable(CAP_SYS_CHROOT))
528 goto dput_and_out;
529
530 + /***** SAKURA Linux start. *****/
531 + {
532 + char *name = getname(filename);
533 + if (!IS_ERR(name)) {
534 + error = CheckChRootPermission(name);
535 + putname(name);
536 + } else {
537 + error = PTR_ERR(name);
538 + }
539 + if (error < 0) goto dput_and_out;
540 + }
541 + /***** SAKURA Linux end. *****/
542 +
543 set_fs_root(current->fs, nd.mnt, nd.dentry);
544 set_fs_altroot();
545 error = 0;
546 @@ -1041,6 +1070,9 @@ EXPORT_SYMBOL(sys_close);
547 */
548 asmlinkage long sys_vhangup(void)
549 {
550 + /***** TOMOYO Linux start. *****/
551 + if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0)
552 + /***** TOMOYO Linux end. *****/
553 if (capable(CAP_SYS_TTY_CONFIG)) {
554 tty_vhangup(current->signal->tty);
555 return 0;
556 diff -ubBpEr linux-2.6.12.3-a9-8/fs/proc/Makefile linux-2.6.12.3-a9-8-ccs/fs/proc/Makefile
557 --- linux-2.6.12.3-a9-8/fs/proc/Makefile 2005-07-16 06:18:57.000000000 +0900
558 +++ linux-2.6.12.3-a9-8-ccs/fs/proc/Makefile 2006-11-20 15:28:32.000000000 +0900
559 @@ -12,3 +12,6 @@ proc-y += inode.o root.o base.o ge
560
561 proc-$(CONFIG_PROC_KCORE) += kcore.o
562 proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
563 +
564 +proc-$(CONFIG_SAKURA) += ccs_proc.o
565 +proc-$(CONFIG_TOMOYO) += ccs_proc.o
566 diff -ubBpEr linux-2.6.12.3-a9-8/fs/proc/proc_misc.c linux-2.6.12.3-a9-8-ccs/fs/proc/proc_misc.c
567 --- linux-2.6.12.3-a9-8/fs/proc/proc_misc.c 2005-07-16 06:18:57.000000000 +0900
568 +++ linux-2.6.12.3-a9-8-ccs/fs/proc/proc_misc.c 2007-03-06 11:27:56.000000000 +0900
569 @@ -617,4 +617,13 @@ void __init proc_misc_init(void)
570 entry->proc_fops = &ppc_htab_operations;
571 }
572 #endif
573 + /***** CCS start. *****/
574 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
575 + {
576 + extern void __init CCSProc_Init(void);
577 + CCSProc_Init();
578 + printk("Hook version: 2.6.12.3-a9-8 2007/03/06\n");
579 + }
580 +#endif
581 + /***** CCS end. *****/
582 }
583 diff -ubBpEr linux-2.6.12.3-a9-8/include/linux/init_task.h linux-2.6.12.3-a9-8-ccs/include/linux/init_task.h
584 --- linux-2.6.12.3-a9-8/include/linux/init_task.h 2005-07-16 06:18:57.000000000 +0900
585 +++ linux-2.6.12.3-a9-8-ccs/include/linux/init_task.h 2007-03-05 17:56:29.000000000 +0900
586 @@ -111,6 +111,10 @@ extern struct group_info init_groups;
587 .switch_lock = SPIN_LOCK_UNLOCKED, \
588 .journal_info = NULL, \
589 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
590 + /***** TOMOYO Linux start. *****/ \
591 + .domain_info = &KERNEL_DOMAIN, \
592 + .tomoyo_flags = 0, \
593 + /***** TOMOYO Linux end. *****/ \
594 }
595
596
597 diff -ubBpEr linux-2.6.12.3-a9-8/include/linux/sched.h linux-2.6.12.3-a9-8-ccs/include/linux/sched.h
598 --- linux-2.6.12.3-a9-8/include/linux/sched.h 2005-07-16 06:18:57.000000000 +0900
599 +++ linux-2.6.12.3-a9-8-ccs/include/linux/sched.h 2007-03-05 17:56:18.000000000 +0900
600 @@ -37,6 +37,11 @@
601
602 struct exec_domain;
603
604 +/***** TOMOYO Linux start. *****/
605 +struct domain_info;
606 +extern struct domain_info KERNEL_DOMAIN;
607 +/***** TOMOYO Linux end. *****/
608 +
609 /*
610 * cloning flags:
611 */
612 @@ -740,6 +745,10 @@ struct task_struct {
613 nodemask_t mems_allowed;
614 int cpuset_mems_generation;
615 #endif
616 + /***** TOMOYO Linux start. *****/
617 + struct domain_info *domain_info;
618 + unsigned int tomoyo_flags;
619 + /***** TOMOYO Linux end. *****/
620 };
621
622 static inline pid_t process_group(struct task_struct *tsk)
623 diff -ubBpEr linux-2.6.12.3-a9-8/kernel/kmod.c linux-2.6.12.3-a9-8-ccs/kernel/kmod.c
624 --- linux-2.6.12.3-a9-8/kernel/kmod.c 2005-07-16 06:18:57.000000000 +0900
625 +++ linux-2.6.12.3-a9-8-ccs/kernel/kmod.c 2007-03-05 17:56:37.000000000 +0900
626 @@ -143,6 +143,11 @@ static int ____call_usermodehelper(void
627 /* We can run anywhere, unlike our parent keventd(). */
628 set_cpus_allowed(current, CPU_MASK_ALL);
629
630 + /***** TOMOYO Linux start. *****/
631 + current->domain_info = &KERNEL_DOMAIN;
632 + current->tomoyo_flags = 0;
633 + /***** TOMOYO Linux start. *****/
634 +
635 retval = -EPERM;
636 if (current->fs->root)
637 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
638 diff -ubBpEr linux-2.6.12.3-a9-8/kernel/module.c linux-2.6.12.3-a9-8-ccs/kernel/module.c
639 --- linux-2.6.12.3-a9-8/kernel/module.c 2005-07-16 06:18:57.000000000 +0900
640 +++ linux-2.6.12.3-a9-8-ccs/kernel/module.c 2006-11-20 15:28:32.000000000 +0900
641 @@ -38,6 +38,9 @@
642 #include <asm/uaccess.h>
643 #include <asm/semaphore.h>
644 #include <asm/cacheflush.h>
645 +/***** TOMOYO Linux start. *****/
646 +#include <linux/tomoyo.h>
647 +/***** TOMOYO Linux end. *****/
648
649 #if 0
650 #define DEBUGP printk
651 @@ -531,7 +534,9 @@ sys_delete_module(const char __user *nam
652
653 if (!capable(CAP_SYS_MODULE))
654 return -EPERM;
655 -
656 + /***** TOMOYO Linux start. *****/
657 + if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
658 + /***** TOMOYO Linux end. *****/
659 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
660 return -EFAULT;
661 name[MODULE_NAME_LEN-1] = '\0';
662 @@ -1764,7 +1769,9 @@ sys_init_module(void __user *umod,
663 /* Must have permission */
664 if (!capable(CAP_SYS_MODULE))
665 return -EPERM;
666 -
667 + /***** TOMOYO Linux start. *****/
668 + if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
669 + /***** TOMOYO Linux end. *****/
670 /* Only one module load at a time, please */
671 if (down_interruptible(&module_mutex) != 0)
672 return -EINTR;
673 diff -ubBpEr linux-2.6.12.3-a9-8/kernel/sched.c linux-2.6.12.3-a9-8-ccs/kernel/sched.c
674 --- linux-2.6.12.3-a9-8/kernel/sched.c 2005-07-16 06:18:57.000000000 +0900
675 +++ linux-2.6.12.3-a9-8-ccs/kernel/sched.c 2006-11-20 15:28:32.000000000 +0900
676 @@ -50,6 +50,9 @@
677 #include <asm/tlb.h>
678
679 #include <asm/unistd.h>
680 +/***** TOMOYO Linux start. *****/
681 +#include <linux/tomoyo.h>
682 +/***** TOMOYO Linux end. *****/
683
684 /*
685 * Convert user-nice values [ -20 ... 0 ... 19 ]
686 @@ -3250,6 +3253,9 @@ asmlinkage long sys_nice(int increment)
687 {
688 int retval;
689 long nice;
690 + /***** TOMOYO Linux start. *****/
691 + if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;
692 + /***** TOMOYO Linux end. *****/
693
694 /*
695 * Setpriority might change our priority at the same moment.
696 diff -ubBpEr linux-2.6.12.3-a9-8/kernel/signal.c linux-2.6.12.3-a9-8-ccs/kernel/signal.c
697 --- linux-2.6.12.3-a9-8/kernel/signal.c 2005-07-16 06:18:57.000000000 +0900
698 +++ linux-2.6.12.3-a9-8-ccs/kernel/signal.c 2006-11-20 15:28:32.000000000 +0900
699 @@ -28,6 +28,9 @@
700 #include <asm/uaccess.h>
701 #include <asm/unistd.h>
702 #include <asm/siginfo.h>
703 +/***** TOMOYO Linux start. *****/
704 +#include <linux/tomoyo.h>
705 +/***** TOMOYO Linux end. *****/
706
707 /*
708 * SLAB caches for signal bits.
709 @@ -2255,6 +2258,10 @@ asmlinkage long
710 sys_kill(int pid, int sig)
711 {
712 struct siginfo info;
713 + /***** TOMOYO Linux start. *****/
714 + if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
715 + if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
716 + /***** TOMOYO Linux end. *****/
717
718 info.si_signo = sig;
719 info.si_errno = 0;
720 @@ -2285,6 +2292,11 @@ asmlinkage long sys_tgkill(int tgid, int
721 if (pid <= 0 || tgid <= 0)
722 return -EINVAL;
723
724 + /***** TOMOYO Linux start. *****/
725 + if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
726 + if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
727 + /***** TOMOYO Linux end. *****/
728 +
729 info.si_signo = sig;
730 info.si_errno = 0;
731 info.si_code = SI_TKILL;
732 @@ -2325,6 +2337,10 @@ sys_tkill(int pid, int sig)
733 if (pid <= 0)
734 return -EINVAL;
735
736 + /***** TOMOYO Linux start. *****/
737 + if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
738 + if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
739 + /***** TOMOYO Linux end. *****/
740 info.si_signo = sig;
741 info.si_errno = 0;
742 info.si_code = SI_TKILL;
743 diff -ubBpEr linux-2.6.12.3-a9-8/kernel/sys.c linux-2.6.12.3-a9-8-ccs/kernel/sys.c
744 --- linux-2.6.12.3-a9-8/kernel/sys.c 2005-07-16 06:18:57.000000000 +0900
745 +++ linux-2.6.12.3-a9-8-ccs/kernel/sys.c 2006-11-20 15:28:32.000000000 +0900
746 @@ -33,6 +33,9 @@
747 #include <asm/uaccess.h>
748 #include <asm/io.h>
749 #include <asm/unistd.h>
750 +/***** TOMOYO Linux start. *****/
751 +#include <linux/tomoyo.h>
752 +/***** TOMOYO Linux end. *****/
753
754 #ifndef SET_UNALIGN_CTL
755 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
756 @@ -252,6 +255,9 @@ asmlinkage long sys_setpriority(int whic
757
758 if (which > 2 || which < 0)
759 goto out;
760 + /***** TOMOYO Linux start. *****/
761 + if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;
762 + /***** TOMOYO Linux end. *****/
763
764 /* normalize: avoid signed division (rounding problems) */
765 error = -ESRCH;
766 @@ -383,6 +389,9 @@ asmlinkage long sys_reboot(int magic1, i
767 magic2 != LINUX_REBOOT_MAGIC2B &&
768 magic2 != LINUX_REBOOT_MAGIC2C))
769 return -EINVAL;
770 + /***** TOMOYO Linux start. *****/
771 + if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM;
772 + /***** TOMOYO Linux end. *****/
773
774 lock_kernel();
775 switch (cmd) {
776 @@ -1385,6 +1394,9 @@ asmlinkage long sys_sethostname(char __u
777 return -EPERM;
778 if (len < 0 || len > __NEW_UTS_LEN)
779 return -EINVAL;
780 + /***** TOMOYO Linux start. *****/
781 + if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
782 + /***** TOMOYO Linux end. *****/
783 down_write(&uts_sem);
784 errno = -EFAULT;
785 if (!copy_from_user(tmp, name, len)) {
786 @@ -1430,6 +1442,9 @@ asmlinkage long sys_setdomainname(char _
787 return -EPERM;
788 if (len < 0 || len > __NEW_UTS_LEN)
789 return -EINVAL;
790 + /***** TOMOYO Linux start. *****/
791 + if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
792 + /***** TOMOYO Linux end. *****/
793
794 down_write(&uts_sem);
795 errno = -EFAULT;
796 diff -ubBpEr linux-2.6.12.3-a9-8/kernel/sysctl.c linux-2.6.12.3-a9-8-ccs/kernel/sysctl.c
797 --- linux-2.6.12.3-a9-8/kernel/sysctl.c 2005-07-16 06:18:57.000000000 +0900
798 +++ linux-2.6.12.3-a9-8-ccs/kernel/sysctl.c 2006-11-20 15:28:32.000000000 +0900
799 @@ -44,6 +44,9 @@
800
801 #include <asm/uaccess.h>
802 #include <asm/processor.h>
803 +/***** TOMOYO Linux start. *****/
804 +#include <linux/tomoyo.h>
805 +/***** TOMOYO Linux end. *****/
806
807 #ifdef CONFIG_ROOT_NFS
808 #include <linux/nfs_fs.h>
809 @@ -971,6 +974,87 @@ void __init sysctl_init(void)
810 #endif
811 }
812
813 +/***** TOMOYO Linux start. *****/
814 +static int try_parse_table(int __user *name, int nlen, void __user *oldval, void __user *newval, ctl_table *table)
815 +{
816 + int n;
817 + int error = -ENOMEM;
818 + int op = 0;
819 + char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
820 + if (oldval) op |= 004;
821 + if (newval) op |= 002;
822 + if (!op) { /* Neither read nor write */
823 + error = 0;
824 + goto out;
825 + }
826 + if (!buffer) goto out;
827 + memset(buffer, 0, PAGE_SIZE);
828 + snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
829 + repeat:
830 + if (!nlen) {
831 + error = -ENOTDIR;
832 + goto out;
833 + }
834 + if (get_user(n, name)) {
835 + error = -EFAULT;
836 + goto out;
837 + }
838 + for ( ; table->ctl_name; table++) {
839 + if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
840 + int pos = strlen(buffer);
841 + const char *cp = table->procname;
842 + error = -ENOMEM;
843 + if (cp) {
844 + if (pos + 1 >= PAGE_SIZE - 1) goto out;
845 + buffer[pos++] = '/';
846 + while (*cp) {
847 + const unsigned char c = * (const unsigned char *) cp;
848 + if (c == '\\') {
849 + if (pos + 2 >= PAGE_SIZE - 1) goto out;
850 + buffer[pos++] = '\\';
851 + buffer[pos++] = '\\';
852 + } else if (c > ' ' && c < 127) {
853 + if (pos + 1 >= PAGE_SIZE - 1) goto out;
854 + buffer[pos++] = c;
855 + } else {
856 + if (pos + 4 >= PAGE_SIZE - 1) goto out;
857 + buffer[pos++] = '\\';
858 + buffer[pos++] = (c >> 6) + '0';
859 + buffer[pos++] = ((c >> 3) & 7) + '0';
860 + buffer[pos++] = (c & 7) + '0';
861 + }
862 + cp++;
863 + }
864 + } else {
865 + /* Assume nobody assigns "=\$=" for procname. */
866 + snprintf(buffer + pos, PAGE_SIZE - pos - 1, "/=%d=", table->ctl_name);
867 + if (memchr(buffer, '\0', PAGE_SIZE - 2) == NULL) goto out;
868 + }
869 + if (table->child) {
870 + if (table->strategy) {
871 + /* printk("sysctl='%s'\n", buffer); */
872 + if (CheckFilePerm(buffer, op, "sysctl")) {
873 + error = -EPERM;
874 + goto out;
875 + }
876 + }
877 + name++;
878 + nlen--;
879 + table = table->child;
880 + goto repeat;
881 + }
882 + /* printk("sysctl='%s'\n", buffer); */
883 + error = CheckFilePerm(buffer, op, "sysctl");
884 + goto out;
885 + }
886 + }
887 + error = -ENOTDIR;
888 + out:
889 + kfree(buffer);
890 + return error;
891 +}
892 +/***** TOMOYO Linux end. *****/
893 +
894 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
895 void __user *newval, size_t newlen)
896 {
897 @@ -988,7 +1072,11 @@ int do_sysctl(int __user *name, int nlen
898 struct ctl_table_header *head =
899 list_entry(tmp, struct ctl_table_header, ctl_entry);
900 void *context = NULL;
901 - int error = parse_table(name, nlen, oldval, oldlenp,
902 + int error;
903 + /***** TOMOYO Linux start. *****/
904 + if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0)
905 + /***** TOMOYO Linux end. *****/
906 + error = parse_table(name, nlen, oldval, oldlenp,
907 newval, newlen, head->ctl_table,
908 &context);
909 if (context)
910 @@ -1058,6 +1146,12 @@ repeat:
911 if (ctl_perm(table, 001))
912 return -EPERM;
913 if (table->strategy) {
914 + /***** TOMOYO Linux start. *****/
915 + int op = 0;
916 + if (oldval) op |= 004;
917 + if (newval) op |= 002;
918 + if (ctl_perm(table, op)) return -EPERM;
919 + /***** TOMOYO Linux end. *****/
920 error = table->strategy(
921 table, name, nlen,
922 oldval, oldlenp,
923 @@ -2116,7 +2210,7 @@ int sysctl_string(ctl_table *table, int
924 len--;
925 ((char *) table->data)[len] = 0;
926 }
927 - return 0;
928 + return 1;
929 }
930
931 /*
932 diff -ubBpEr linux-2.6.12.3-a9-8/kernel/time.c linux-2.6.12.3-a9-8-ccs/kernel/time.c
933 --- linux-2.6.12.3-a9-8/kernel/time.c 2005-07-16 06:18:57.000000000 +0900
934 +++ linux-2.6.12.3-a9-8-ccs/kernel/time.c 2006-11-20 15:28:32.000000000 +0900
935 @@ -38,6 +38,9 @@
936
937 #include <asm/uaccess.h>
938 #include <asm/unistd.h>
939 +/***** TOMOYO Linux start. *****/
940 +#include <linux/tomoyo.h>
941 +/***** TOMOYO Linux end. *****/
942
943 /*
944 * The timezone where the local system is located. Used as a default by some
945 @@ -90,6 +93,9 @@ asmlinkage long sys_stime(time_t __user
946 err = security_settime(&tv, NULL);
947 if (err)
948 return err;
949 + /***** TOMOYO Linux start. *****/
950 + if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
951 + /***** TOMOYO Linux end. *****/
952
953 do_settimeofday(&tv);
954 return 0;
955 @@ -157,6 +163,9 @@ int do_sys_settimeofday(struct timespec
956 error = security_settime(tv, tz);
957 if (error)
958 return error;
959 + /***** TOMOYO Linux start. *****/
960 + if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
961 + /***** TOMOYO Linux end. *****/
962
963 if (tz) {
964 /* SMP safe, global irq locking makes it work. */
965 @@ -235,6 +244,9 @@ int do_adjtimex(struct timex *txc)
966 /* In order to modify anything, you gotta be super-user! */
967 if (txc->modes && !capable(CAP_SYS_TIME))
968 return -EPERM;
969 + /***** TOMOYO Linux start. *****/
970 + if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
971 + /***** TOMOYO Linux end. *****/
972
973 /* Now we validate the data before disabling interrupts */
974
975 diff -ubBpEr linux-2.6.12.3-a9-8/net/ipv4/tcp_ipv4.c linux-2.6.12.3-a9-8-ccs/net/ipv4/tcp_ipv4.c
976 --- linux-2.6.12.3-a9-8/net/ipv4/tcp_ipv4.c 2005-07-16 06:18:57.000000000 +0900
977 +++ linux-2.6.12.3-a9-8-ccs/net/ipv4/tcp_ipv4.c 2006-11-20 15:28:32.000000000 +0900
978 @@ -74,6 +74,9 @@
979 #include <linux/stddef.h>
980 #include <linux/proc_fs.h>
981 #include <linux/seq_file.h>
982 +/***** SAKURA Linux start. *****/
983 +#include <linux/sakura.h>
984 +/***** SAKURA Linux end. *****/
985
986 extern int sysctl_ip_dynaddr;
987 int sysctl_tcp_tw_reuse;
988 @@ -232,6 +235,9 @@ static int tcp_v4_get_port(struct sock *
989 rover = low;
990 head = &tcp_bhash[tcp_bhashfn(rover)];
991 spin_lock(&head->lock);
992 + /***** SAKURA Linux start. *****/
993 + if (SAKURA_MayAutobind(rover) < 0) goto next;
994 + /***** SAKURA Linux end. *****/
995 tb_for_each(tb, node, &head->chain)
996 if (tb->port == rover)
997 goto next;
998 @@ -671,6 +677,9 @@ static inline int tcp_v4_hash_connect(st
999 local_bh_disable();
1000 for (i = 1; i <= range; i++) {
1001 port = low + (i + offset) % range;
1002 + /***** SAKURA Linux start. *****/
1003 + if (SAKURA_MayAutobind(port) < 0) continue;
1004 + /***** SAKURA Linux end. *****/
1005 head = &tcp_bhash[tcp_bhashfn(port)];
1006 spin_lock(&head->lock);
1007
1008 diff -ubBpEr linux-2.6.12.3-a9-8/net/ipv4/udp.c linux-2.6.12.3-a9-8-ccs/net/ipv4/udp.c
1009 --- linux-2.6.12.3-a9-8/net/ipv4/udp.c 2005-07-16 06:18:57.000000000 +0900
1010 +++ linux-2.6.12.3-a9-8-ccs/net/ipv4/udp.c 2006-11-20 15:28:32.000000000 +0900
1011 @@ -107,6 +107,9 @@
1012 #include <net/inet_common.h>
1013 #include <net/checksum.h>
1014 #include <net/xfrm.h>
1015 +/***** SAKURA Linux start. *****/
1016 +#include <linux/sakura.h>
1017 +/***** SAKURA Linux end. *****/
1018
1019 /*
1020 * Snmp MIB for the UDP layer
1021 @@ -138,6 +141,9 @@ static int udp_v4_get_port(struct sock *
1022 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
1023 struct hlist_head *list;
1024 int size;
1025 + /***** SAKURA Linux start. *****/
1026 + if (SAKURA_MayAutobind(result) < 0) continue;
1027 + /***** SAKURA Linux end. *****/
1028
1029 list = &udp_hash[result & (UDP_HTABLE_SIZE - 1)];
1030 if (hlist_empty(list)) {
1031 @@ -161,6 +167,9 @@ static int udp_v4_get_port(struct sock *
1032 result = sysctl_local_port_range[0]
1033 + ((result - sysctl_local_port_range[0]) &
1034 (UDP_HTABLE_SIZE - 1));
1035 + /***** SAKURA Linux start. *****/
1036 + if (SAKURA_MayAutobind(result) < 0) continue;
1037 + /***** SAKURA Linux end. *****/
1038 if (!udp_lport_inuse(result))
1039 break;
1040 }
1041 diff -ubBpEr linux-2.6.12.3-a9-8/net/ipv6/tcp_ipv6.c linux-2.6.12.3-a9-8-ccs/net/ipv6/tcp_ipv6.c
1042 --- linux-2.6.12.3-a9-8/net/ipv6/tcp_ipv6.c 2005-12-14 14:54:14.000000000 +0900
1043 +++ linux-2.6.12.3-a9-8-ccs/net/ipv6/tcp_ipv6.c 2006-11-20 15:28:32.000000000 +0900
1044 @@ -63,6 +63,9 @@
1045
1046 #include <linux/proc_fs.h>
1047 #include <linux/seq_file.h>
1048 +/***** SAKURA Linux start. *****/
1049 +#include <linux/sakura.h>
1050 +/***** SAKURA Linux end. *****/
1051
1052 static void tcp_v6_send_reset(struct sk_buff *skb);
1053 static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
1054 @@ -148,6 +151,9 @@ static int tcp_v6_get_port(struct sock *
1055 rover = low;
1056 head = &tcp_bhash[tcp_bhashfn(rover)];
1057 spin_lock(&head->lock);
1058 + /***** SAKURA Linux start. *****/
1059 + if (SAKURA_MayAutobind(rover) < 0) goto next;
1060 + /***** SAKURA Linux end. *****/
1061 tb_for_each(tb, node, &head->chain)
1062 if (tb->port == rover)
1063 goto next;
1064 @@ -551,6 +557,9 @@ static int tcp_v6_hash_connect(struct so
1065 local_bh_disable();
1066 for (i = 1; i <= range; i++) {
1067 port = low + (i + offset) % range;
1068 + /***** SAKURA Linux start. *****/
1069 + if (SAKURA_MayAutobind(port) < 0) continue;
1070 + /***** SAKURA Linux end. *****/
1071 head = &tcp_bhash[tcp_bhashfn(port)];
1072 spin_lock(&head->lock);
1073
1074 diff -ubBpEr linux-2.6.12.3-a9-8/net/ipv6/udp.c linux-2.6.12.3-a9-8-ccs/net/ipv6/udp.c
1075 --- linux-2.6.12.3-a9-8/net/ipv6/udp.c 2005-12-14 14:54:14.000000000 +0900
1076 +++ linux-2.6.12.3-a9-8-ccs/net/ipv6/udp.c 2006-11-20 15:31:52.000000000 +0900
1077 @@ -57,6 +57,9 @@
1078
1079 #include <linux/proc_fs.h>
1080 #include <linux/seq_file.h>
1081 +/***** SAKURA Linux start. *****/
1082 +#include <linux/sakura.h>
1083 +/***** SAKURA Linux end. *****/
1084
1085 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6);
1086
1087 @@ -80,6 +83,9 @@ static int udp_v6_get_port(struct sock *
1088 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
1089 int size;
1090 struct hlist_head *list;
1091 + /***** SAKURA Linux start. *****/
1092 + if (SAKURA_MayAutobind(result) < 0) continue;
1093 + /***** SAKURA Linux end. *****/
1094
1095 list = &udp_hash[result & (UDP_HTABLE_SIZE - 1)];
1096 if (hlist_empty(list)) {
1097 @@ -103,6 +109,9 @@ static int udp_v6_get_port(struct sock *
1098 result = sysctl_local_port_range[0]
1099 + ((result - sysctl_local_port_range[0]) &
1100 (UDP_HTABLE_SIZE - 1));
1101 + /***** SAKURA Linux start. *****/
1102 + if (SAKURA_MayAutobind(result) < 0) continue;
1103 + /***** SAKURA Linux end. *****/
1104 if (!udp_lport_inuse(result))
1105 break;
1106 }
1107 diff -ubBpEr linux-2.6.12.3-a9-8/net/socket.c linux-2.6.12.3-a9-8-ccs/net/socket.c
1108 --- linux-2.6.12.3-a9-8/net/socket.c 2005-07-16 06:18:57.000000000 +0900
1109 +++ linux-2.6.12.3-a9-8-ccs/net/socket.c 2006-11-20 15:28:32.000000000 +0900
1110 @@ -94,6 +94,11 @@
1111 #include <net/sock.h>
1112 #include <linux/netfilter.h>
1113
1114 +/***** TOMOYO Linux start. *****/
1115 +#include <linux/tomoyo.h>
1116 +#include <linux/tomoyo_socket.h>
1117 +/***** TOMOYO Linux end. *****/
1118 +
1119 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1120 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1121 size_t size, loff_t pos);
1122 @@ -540,7 +545,9 @@ static inline int __sock_sendmsg(struct
1123 err = security_socket_sendmsg(sock, msg, size);
1124 if (err)
1125 return err;
1126 -
1127 + /***** TOMOYO Linux start. *****/
1128 + if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;
1129 + /***** TOMOYO Linux start. *****/
1130 return sock->ops->sendmsg(iocb, sock, msg, size);
1131 }
1132
1133 @@ -607,6 +614,11 @@ int sock_recvmsg(struct socket *sock, st
1134 ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
1135 if (-EIOCBQUEUED == ret)
1136 ret = wait_on_sync_kiocb(&iocb);
1137 + /***** TOMOYO Linux start. *****/
1138 + if (ret >= 0 && CheckSocketRecvMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) {
1139 + ret = -EAGAIN; /* Hope less harmful than -EPERM. */
1140 + }
1141 + /***** TOMOYO Linux end. *****/
1142 return ret;
1143 }
1144
1145 @@ -1093,6 +1105,10 @@ static int __sock_create(int family, int
1146 family = PF_PACKET;
1147 }
1148
1149 + /***** TOMOYO Linux start. *****/
1150 + if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err;
1151 + /***** TOMOYO Linux end. *****/
1152 +
1153 err = security_socket_create(family, type, protocol, kern);
1154 if (err)
1155 return err;
1156 @@ -1287,6 +1303,9 @@ asmlinkage long sys_bind(int fd, struct
1157 sockfd_put(sock);
1158 return err;
1159 }
1160 + /***** TOMOYO Linux start. *****/
1161 + if ((err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen)) == 0)
1162 + /***** TOMOYO Linux end. *****/
1163 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1164 }
1165 sockfd_put(sock);
1166 @@ -1317,7 +1336,9 @@ asmlinkage long sys_listen(int fd, int b
1167 sockfd_put(sock);
1168 return err;
1169 }
1170 -
1171 + /***** TOMOYO Linux start. *****/
1172 + if ((err = CheckSocketListenPermission(sock)) == 0)
1173 + /***** TOMOYO Linux end. *****/
1174 err=sock->ops->listen(sock, backlog);
1175 sockfd_put(sock);
1176 }
1177 @@ -1368,6 +1389,12 @@ asmlinkage long sys_accept(int fd, struc
1178 if (err < 0)
1179 goto out_release;
1180
1181 + /***** TOMOYO Linux start. *****/
1182 + if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) {
1183 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1184 + goto out_release;
1185 + }
1186 + /***** TOMOYO Linux end. *****/
1187 if (upeer_sockaddr) {
1188 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1189 err = -ECONNABORTED;
1190 @@ -1423,7 +1450,9 @@ asmlinkage long sys_connect(int fd, stru
1191 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1192 if (err)
1193 goto out_put;
1194 -
1195 + /***** TOMOYO Linux start. *****/
1196 + if ((err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen)) == 0)
1197 + /***** TOMOYO Linux end. *****/
1198 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1199 sock->file->f_flags);
1200 out_put:
1201 diff -ubBpEr linux-2.6.12.3-a9-8/net/unix/af_unix.c linux-2.6.12.3-a9-8-ccs/net/unix/af_unix.c
1202 --- linux-2.6.12.3-a9-8/net/unix/af_unix.c 2005-07-16 06:18:57.000000000 +0900
1203 +++ linux-2.6.12.3-a9-8-ccs/net/unix/af_unix.c 2007-03-05 18:00:17.000000000 +0900
1204 @@ -117,6 +117,9 @@
1205 #include <linux/mount.h>
1206 #include <net/checksum.h>
1207 #include <linux/security.h>
1208 +/***** TOMOYO Linux start. *****/
1209 +#include <linux/tomoyo.h>
1210 +/***** TOMOYO Linux end. *****/
1211
1212 int sysctl_unix_max_dgram_qlen = 10;
1213
1214 @@ -738,6 +741,10 @@ static int unix_bind(struct socket *sock
1215 err = unix_autobind(sock);
1216 goto out;
1217 }
1218 + /***** TOMOYO Linux start. *****/
1219 + err = -EPERM;
1220 + if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out;
1221 + /***** TOMOYO Linux end. *****/
1222
1223 err = unix_mkname(sunaddr, addr_len, &hash);
1224 if (err < 0)
1225 @@ -781,6 +788,9 @@ static int unix_bind(struct socket *sock
1226 */
1227 mode = S_IFSOCK |
1228 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1229 + /***** TOMOYO Linux start. *****/
1230 + if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)
1231 + /***** TOMOYO Linux end. *****/
1232 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1233 if (err)
1234 goto out_mknod_dput;

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