開發和下載開源軟體

Browse Subversion Repository

Contents of /trunk/ccs-patch/ccs-patch-2.6.12-2.3.legacy_FC3.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: 44150 byte(s)


1 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/Makefile linux-2.6.12-2.3.legacy_FC3-ccs/Makefile
2 --- linux-2.6.12-2.3.legacy_FC3/Makefile 2007-03-03 18:17:49.000000000 +0900
3 +++ linux-2.6.12-2.3.legacy_FC3-ccs/Makefile 2007-03-03 18:17:52.000000000 +0900
4 @@ -1,7 +1,7 @@
5 VERSION = 2
6 PATCHLEVEL = 6
7 SUBLEVEL = 12
8 -EXTRAVERSION = -2.3.legacy_FC3
9 +EXTRAVERSION = -2.3.legacy_FC3-ccs
10 NAME=Woozy Numbat
11
12 # *DOCUMENTATION*
13 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/fs/Kconfig linux-2.6.12-2.3.legacy_FC3-ccs/fs/Kconfig
14 --- linux-2.6.12-2.3.legacy_FC3/fs/Kconfig 2007-03-03 18:17:49.000000000 +0900
15 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/Kconfig 2007-03-03 18:17:52.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-2.3.legacy_FC3/fs/Makefile linux-2.6.12-2.3.legacy_FC3-ccs/fs/Makefile
25 --- linux-2.6.12-2.3.legacy_FC3/fs/Makefile 2007-03-03 18:17:49.000000000 +0900
26 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/Makefile 2007-03-03 18:17:52.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-2.3.legacy_FC3/fs/attr.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/attr.c
34 --- linux-2.6.12-2.3.legacy_FC3/fs/attr.c 2007-03-03 18:17:49.000000000 +0900
35 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/attr.c 2007-03-03 18:19:08.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-2.3.legacy_FC3/fs/compat.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/compat.c
68 --- linux-2.6.12-2.3.legacy_FC3/fs/compat.c 2007-03-03 18:17:49.000000000 +0900
69 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/compat.c 2007-03-03 18:19:09.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-2.3.legacy_FC3/fs/exec.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/exec.c
100 --- linux-2.6.12-2.3.legacy_FC3/fs/exec.c 2007-03-03 18:17:50.000000000 +0900
101 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/exec.c 2007-03-06 09:11:47.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 @@ -1189,7 +1201,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-2.3.legacy_FC3/fs/fcntl.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/fcntl.c
146 --- linux-2.6.12-2.3.legacy_FC3/fs/fcntl.c 2007-03-03 18:17:50.000000000 +0900
147 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/fcntl.c 2007-03-03 18:19:09.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 @@ -195,6 +198,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-2.3.legacy_FC3/fs/ioctl.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/ioctl.c
170 --- linux-2.6.12-2.3.legacy_FC3/fs/ioctl.c 2007-03-03 18:17:50.000000000 +0900
171 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/ioctl.c 2007-03-03 18:19:09.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-2.3.legacy_FC3/fs/namei.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/namei.c
193 --- linux-2.6.12-2.3.legacy_FC3/fs/namei.c 2007-03-03 18:17:50.000000000 +0900
194 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/namei.c 2007-03-03 18:19:09.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 @@ -1317,6 +1321,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 @@ -1374,6 +1381,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 @@ -1405,6 +1417,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 @@ -1644,6 +1659,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 @@ -1662,10 +1683,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 @@ -1727,6 +1754,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 @@ -1831,6 +1861,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 @@ -1885,6 +1918,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 @@ -1906,6 +1942,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 @@ -1953,6 +1992,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 @@ -1969,6 +2011,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 @@ -2036,6 +2081,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 @@ -2053,6 +2101,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 @@ -2275,6 +2326,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 @@ -2296,6 +2354,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-2.3.legacy_FC3/fs/namespace.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/namespace.c
373 --- linux-2.6.12-2.3.legacy_FC3/fs/namespace.c 2007-03-03 18:17:50.000000000 +0900
374 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/namespace.c 2007-03-05 13:02:06.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 @@ -1287,6 +1320,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-2.3.legacy_FC3/fs/open.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/open.c
480 --- linux-2.6.12-2.3.legacy_FC3/fs/open.c 2007-03-03 18:17:50.000000000 +0900
481 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/open.c 2007-03-05 13:01:57.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 @@ -572,6 +585,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 @@ -585,6 +601,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 @@ -1044,6 +1073,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-2.3.legacy_FC3/fs/proc/Makefile linux-2.6.12-2.3.legacy_FC3-ccs/fs/proc/Makefile
557 --- linux-2.6.12-2.3.legacy_FC3/fs/proc/Makefile 2007-03-03 18:17:50.000000000 +0900
558 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/proc/Makefile 2007-03-03 18:17:52.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-2.3.legacy_FC3/fs/proc/proc_misc.c linux-2.6.12-2.3.legacy_FC3-ccs/fs/proc/proc_misc.c
567 --- linux-2.6.12-2.3.legacy_FC3/fs/proc/proc_misc.c 2007-03-03 18:17:50.000000000 +0900
568 +++ linux-2.6.12-2.3.legacy_FC3-ccs/fs/proc/proc_misc.c 2007-03-06 09:11:50.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 CCSProc_Init(void);
577 + CCSProc_Init();
578 + printk("Hook version: 2.6.12-2.3.legacy_FC3 2007/03/06\n");
579 + }
580 +#endif
581 + /***** CCS end. *****/
582 }
583 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/include/linux/init_task.h linux-2.6.12-2.3.legacy_FC3-ccs/include/linux/init_task.h
584 --- linux-2.6.12-2.3.legacy_FC3/include/linux/init_task.h 2007-03-03 18:17:50.000000000 +0900
585 +++ linux-2.6.12-2.3.legacy_FC3-ccs/include/linux/init_task.h 2007-03-03 18:18:18.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-2.3.legacy_FC3/include/linux/sched.h linux-2.6.12-2.3.legacy_FC3-ccs/include/linux/sched.h
598 --- linux-2.6.12-2.3.legacy_FC3/include/linux/sched.h 2007-03-03 18:17:50.000000000 +0900
599 +++ linux-2.6.12-2.3.legacy_FC3-ccs/include/linux/sched.h 2007-03-03 18:18:13.000000000 +0900
600 @@ -39,6 +39,11 @@ struct exec_domain;
601 extern int exec_shield;
602 extern int print_fatal_signals;
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 @@ -754,6 +759,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-2.3.legacy_FC3/kernel/kmod.c linux-2.6.12-2.3.legacy_FC3-ccs/kernel/kmod.c
624 --- linux-2.6.12-2.3.legacy_FC3/kernel/kmod.c 2007-03-03 18:17:50.000000000 +0900
625 +++ linux-2.6.12-2.3.legacy_FC3-ccs/kernel/kmod.c 2007-03-03 18:18:21.000000000 +0900
626 @@ -139,6 +139,11 @@ int __exec_usermodehelper(char *path, ch
627 recalc_sigpending();
628 spin_unlock_irq(&current->sighand->siglock);
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(path, argv, envp);
638 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/kernel/module.c linux-2.6.12-2.3.legacy_FC3-ccs/kernel/module.c
639 --- linux-2.6.12-2.3.legacy_FC3/kernel/module.c 2007-03-03 18:17:50.000000000 +0900
640 +++ linux-2.6.12-2.3.legacy_FC3-ccs/kernel/module.c 2007-03-03 18:17:52.000000000 +0900
641 @@ -39,6 +39,9 @@
642 #include <asm/semaphore.h>
643 #include <asm/cacheflush.h>
644 #include "module-verify.h"
645 +/***** TOMOYO Linux start. *****/
646 +#include <linux/tomoyo.h>
647 +/***** TOMOYO Linux end. *****/
648
649 #if 0
650 #define DEBUGP printk
651 @@ -538,7 +541,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 @@ -1777,7 +1782,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-2.3.legacy_FC3/kernel/sched.c linux-2.6.12-2.3.legacy_FC3-ccs/kernel/sched.c
674 --- linux-2.6.12-2.3.legacy_FC3/kernel/sched.c 2007-03-03 18:17:50.000000000 +0900
675 +++ linux-2.6.12-2.3.legacy_FC3-ccs/kernel/sched.c 2007-03-03 18:17:52.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 @@ -3252,6 +3255,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-2.3.legacy_FC3/kernel/signal.c linux-2.6.12-2.3.legacy_FC3-ccs/kernel/signal.c
697 --- linux-2.6.12-2.3.legacy_FC3/kernel/signal.c 2007-03-03 18:17:50.000000000 +0900
698 +++ linux-2.6.12-2.3.legacy_FC3-ccs/kernel/signal.c 2007-03-03 18:17:52.000000000 +0900
699 @@ -29,6 +29,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 @@ -2288,6 +2291,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 @@ -2318,6 +2325,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 @@ -2358,6 +2370,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-2.3.legacy_FC3/kernel/sys.c linux-2.6.12-2.3.legacy_FC3-ccs/kernel/sys.c
744 --- linux-2.6.12-2.3.legacy_FC3/kernel/sys.c 2007-03-03 18:17:50.000000000 +0900
745 +++ linux-2.6.12-2.3.legacy_FC3-ccs/kernel/sys.c 2007-03-03 18:17:52.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-2.3.legacy_FC3/kernel/sysctl.c linux-2.6.12-2.3.legacy_FC3-ccs/kernel/sysctl.c
797 --- linux-2.6.12-2.3.legacy_FC3/kernel/sysctl.c 2007-03-03 18:17:50.000000000 +0900
798 +++ linux-2.6.12-2.3.legacy_FC3-ccs/kernel/sysctl.c 2007-03-03 18:17:52.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 @@ -1052,6 +1055,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 @@ -1077,6 +1161,9 @@ int do_sysctl(int __user *name, int nlen
898
899 spin_unlock(&sysctl_lock);
900
901 + /***** TOMOYO Linux start. *****/
902 + if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0)
903 + /***** TOMOYO Linux end. *****/
904 error = parse_table(name, nlen, oldval, oldlenp,
905 newval, newlen, head->ctl_table,
906 &context);
907 @@ -1150,6 +1237,12 @@ repeat:
908 if (ctl_perm(table, 001))
909 return -EPERM;
910 if (table->strategy) {
911 + /***** TOMOYO Linux start. *****/
912 + int op = 0;
913 + if (oldval) op |= 004;
914 + if (newval) op |= 002;
915 + if (ctl_perm(table, op)) return -EPERM;
916 + /***** TOMOYO Linux end. *****/
917 error = table->strategy(
918 table, name, nlen,
919 oldval, oldlenp,
920 @@ -2234,7 +2327,7 @@ int sysctl_string(ctl_table *table, int
921 len--;
922 ((char *) table->data)[len] = 0;
923 }
924 - return 0;
925 + return 1;
926 }
927
928 /*
929 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/kernel/time.c linux-2.6.12-2.3.legacy_FC3-ccs/kernel/time.c
930 --- linux-2.6.12-2.3.legacy_FC3/kernel/time.c 2007-03-03 18:17:50.000000000 +0900
931 +++ linux-2.6.12-2.3.legacy_FC3-ccs/kernel/time.c 2007-03-03 18:17:52.000000000 +0900
932 @@ -38,6 +38,9 @@
933
934 #include <asm/uaccess.h>
935 #include <asm/unistd.h>
936 +/***** TOMOYO Linux start. *****/
937 +#include <linux/tomoyo.h>
938 +/***** TOMOYO Linux end. *****/
939
940 /*
941 * The timezone where the local system is located. Used as a default by some
942 @@ -90,6 +93,9 @@ asmlinkage long sys_stime(time_t __user
943 err = security_settime(&tv, NULL);
944 if (err)
945 return err;
946 + /***** TOMOYO Linux start. *****/
947 + if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
948 + /***** TOMOYO Linux end. *****/
949
950 do_settimeofday(&tv);
951 return 0;
952 @@ -157,6 +163,9 @@ int do_sys_settimeofday(struct timespec
953 error = security_settime(tv, tz);
954 if (error)
955 return error;
956 + /***** TOMOYO Linux start. *****/
957 + if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
958 + /***** TOMOYO Linux end. *****/
959
960 if (tz) {
961 /* SMP safe, global irq locking makes it work. */
962 @@ -235,6 +244,9 @@ int do_adjtimex(struct timex *txc)
963 /* In order to modify anything, you gotta be super-user! */
964 if (txc->modes && !capable(CAP_SYS_TIME))
965 return -EPERM;
966 + /***** TOMOYO Linux start. *****/
967 + if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
968 + /***** TOMOYO Linux end. *****/
969
970 /* Now we validate the data before disabling interrupts */
971
972 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/net/ipv4/tcp_ipv4.c linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv4/tcp_ipv4.c
973 --- linux-2.6.12-2.3.legacy_FC3/net/ipv4/tcp_ipv4.c 2007-03-03 18:17:50.000000000 +0900
974 +++ linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv4/tcp_ipv4.c 2007-03-03 18:17:52.000000000 +0900
975 @@ -74,6 +74,9 @@
976 #include <linux/stddef.h>
977 #include <linux/proc_fs.h>
978 #include <linux/seq_file.h>
979 +/***** SAKURA Linux start. *****/
980 +#include <linux/sakura.h>
981 +/***** SAKURA Linux end. *****/
982
983 extern int sysctl_ip_dynaddr;
984 int sysctl_tcp_tw_reuse;
985 @@ -232,6 +235,9 @@ static int tcp_v4_get_port(struct sock *
986 rover = low;
987 head = &tcp_bhash[tcp_bhashfn(rover)];
988 spin_lock(&head->lock);
989 + /***** SAKURA Linux start. *****/
990 + if (SAKURA_MayAutobind(rover) < 0) goto next;
991 + /***** SAKURA Linux end. *****/
992 tb_for_each(tb, node, &head->chain)
993 if (tb->port == rover)
994 goto next;
995 @@ -672,6 +678,9 @@ static inline int tcp_v4_hash_connect(st
996 local_bh_disable();
997 for (i = 1; i <= range; i++) {
998 port = low + (i + offset) % range;
999 + /***** SAKURA Linux start. *****/
1000 + if (SAKURA_MayAutobind(port) < 0) continue;
1001 + /***** SAKURA Linux end. *****/
1002 head = &tcp_bhash[tcp_bhashfn(port)];
1003 spin_lock(&head->lock);
1004
1005 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/net/ipv4/udp.c linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv4/udp.c
1006 --- linux-2.6.12-2.3.legacy_FC3/net/ipv4/udp.c 2007-03-03 18:17:50.000000000 +0900
1007 +++ linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv4/udp.c 2007-03-03 18:17:52.000000000 +0900
1008 @@ -107,6 +107,9 @@
1009 #include <net/inet_common.h>
1010 #include <net/checksum.h>
1011 #include <net/xfrm.h>
1012 +/***** SAKURA Linux start. *****/
1013 +#include <linux/sakura.h>
1014 +/***** SAKURA Linux end. *****/
1015
1016 /*
1017 * Snmp MIB for the UDP layer
1018 @@ -138,6 +141,9 @@ static int udp_v4_get_port(struct sock *
1019 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
1020 struct hlist_head *list;
1021 int size;
1022 + /***** SAKURA Linux start. *****/
1023 + if (SAKURA_MayAutobind(result) < 0) continue;
1024 + /***** SAKURA Linux end. *****/
1025
1026 list = &udp_hash[result & (UDP_HTABLE_SIZE - 1)];
1027 if (hlist_empty(list)) {
1028 @@ -161,6 +167,9 @@ static int udp_v4_get_port(struct sock *
1029 result = sysctl_local_port_range[0]
1030 + ((result - sysctl_local_port_range[0]) &
1031 (UDP_HTABLE_SIZE - 1));
1032 + /***** SAKURA Linux start. *****/
1033 + if (SAKURA_MayAutobind(result) < 0) continue;
1034 + /***** SAKURA Linux end. *****/
1035 if (!udp_lport_inuse(result))
1036 break;
1037 }
1038 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/net/ipv6/tcp_ipv6.c linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv6/tcp_ipv6.c
1039 --- linux-2.6.12-2.3.legacy_FC3/net/ipv6/tcp_ipv6.c 2007-03-03 18:17:50.000000000 +0900
1040 +++ linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv6/tcp_ipv6.c 2007-03-03 18:17:52.000000000 +0900
1041 @@ -63,6 +63,9 @@
1042
1043 #include <linux/proc_fs.h>
1044 #include <linux/seq_file.h>
1045 +/***** SAKURA Linux start. *****/
1046 +#include <linux/sakura.h>
1047 +/***** SAKURA Linux end. *****/
1048
1049 static void tcp_v6_send_reset(struct sk_buff *skb);
1050 static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
1051 @@ -148,6 +151,9 @@ static int tcp_v6_get_port(struct sock *
1052 rover = low;
1053 head = &tcp_bhash[tcp_bhashfn(rover)];
1054 spin_lock(&head->lock);
1055 + /***** SAKURA Linux start. *****/
1056 + if (SAKURA_MayAutobind(rover) < 0) goto next;
1057 + /***** SAKURA Linux end. *****/
1058 tb_for_each(tb, node, &head->chain)
1059 if (tb->port == rover)
1060 goto next;
1061 @@ -551,6 +557,9 @@ static int tcp_v6_hash_connect(struct so
1062 local_bh_disable();
1063 for (i = 1; i <= range; i++) {
1064 port = low + (i + offset) % range;
1065 + /***** SAKURA Linux start. *****/
1066 + if (SAKURA_MayAutobind(port) < 0) continue;
1067 + /***** SAKURA Linux end. *****/
1068 head = &tcp_bhash[tcp_bhashfn(port)];
1069 spin_lock(&head->lock);
1070
1071 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/net/ipv6/udp.c linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv6/udp.c
1072 --- linux-2.6.12-2.3.legacy_FC3/net/ipv6/udp.c 2007-03-03 18:17:50.000000000 +0900
1073 +++ linux-2.6.12-2.3.legacy_FC3-ccs/net/ipv6/udp.c 2007-03-03 18:17:52.000000000 +0900
1074 @@ -57,6 +57,9 @@
1075
1076 #include <linux/proc_fs.h>
1077 #include <linux/seq_file.h>
1078 +/***** SAKURA Linux start. *****/
1079 +#include <linux/sakura.h>
1080 +/***** SAKURA Linux end. *****/
1081
1082 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6);
1083
1084 @@ -80,6 +83,9 @@ static int udp_v6_get_port(struct sock *
1085 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
1086 int size;
1087 struct hlist_head *list;
1088 + /***** SAKURA Linux start. *****/
1089 + if (SAKURA_MayAutobind(result) < 0) continue;
1090 + /***** SAKURA Linux end. *****/
1091
1092 list = &udp_hash[result & (UDP_HTABLE_SIZE - 1)];
1093 if (hlist_empty(list)) {
1094 @@ -103,6 +109,9 @@ static int udp_v6_get_port(struct sock *
1095 result = sysctl_local_port_range[0]
1096 + ((result - sysctl_local_port_range[0]) &
1097 (UDP_HTABLE_SIZE - 1));
1098 + /***** SAKURA Linux start. *****/
1099 + if (SAKURA_MayAutobind(result) < 0) continue;
1100 + /***** SAKURA Linux end. *****/
1101 if (!udp_lport_inuse(result))
1102 break;
1103 }
1104 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/net/socket.c linux-2.6.12-2.3.legacy_FC3-ccs/net/socket.c
1105 --- linux-2.6.12-2.3.legacy_FC3/net/socket.c 2007-03-03 18:17:50.000000000 +0900
1106 +++ linux-2.6.12-2.3.legacy_FC3-ccs/net/socket.c 2007-03-03 18:17:52.000000000 +0900
1107 @@ -96,6 +96,11 @@
1108 #include <net/sock.h>
1109 #include <linux/netfilter.h>
1110
1111 +/***** TOMOYO Linux start. *****/
1112 +#include <linux/tomoyo.h>
1113 +#include <linux/tomoyo_socket.h>
1114 +/***** TOMOYO Linux end. *****/
1115 +
1116 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1117 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1118 size_t size, loff_t pos);
1119 @@ -555,7 +560,9 @@ static inline int __sock_sendmsg(struct
1120 err = security_socket_sendmsg(sock, msg, size);
1121 if (err)
1122 return err;
1123 -
1124 + /***** TOMOYO Linux start. *****/
1125 + if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;
1126 + /***** TOMOYO Linux start. *****/
1127 return sock->ops->sendmsg(iocb, sock, msg, size);
1128 }
1129
1130 @@ -622,6 +629,11 @@ int sock_recvmsg(struct socket *sock, st
1131 ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
1132 if (-EIOCBQUEUED == ret)
1133 ret = wait_on_sync_kiocb(&iocb);
1134 + /***** TOMOYO Linux start. *****/
1135 + if (ret >= 0 && CheckSocketRecvMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) {
1136 + ret = -EAGAIN; /* Hope less harmful than -EPERM. */
1137 + }
1138 + /***** TOMOYO Linux end. *****/
1139 return ret;
1140 }
1141
1142 @@ -1110,6 +1122,10 @@ static int __sock_create(int family, int
1143 family = PF_PACKET;
1144 }
1145
1146 + /***** TOMOYO Linux start. *****/
1147 + if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err;
1148 + /***** TOMOYO Linux end. *****/
1149 +
1150 err = security_socket_create(family, type, protocol, kern);
1151 if (err)
1152 return err;
1153 @@ -1304,6 +1320,9 @@ asmlinkage long sys_bind(int fd, struct
1154 sockfd_put(sock);
1155 return err;
1156 }
1157 + /***** TOMOYO Linux start. *****/
1158 + if ((err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen)) == 0)
1159 + /***** TOMOYO Linux end. *****/
1160 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1161 }
1162 sockfd_put(sock);
1163 @@ -1334,7 +1353,9 @@ asmlinkage long sys_listen(int fd, int b
1164 sockfd_put(sock);
1165 return err;
1166 }
1167 -
1168 + /***** TOMOYO Linux start. *****/
1169 + if ((err = CheckSocketListenPermission(sock)) == 0)
1170 + /***** TOMOYO Linux end. *****/
1171 err=sock->ops->listen(sock, backlog);
1172 sockfd_put(sock);
1173 }
1174 @@ -1385,6 +1406,12 @@ asmlinkage long sys_accept(int fd, struc
1175 if (err < 0)
1176 goto out_release;
1177
1178 + /***** TOMOYO Linux start. *****/
1179 + if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) {
1180 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1181 + goto out_release;
1182 + }
1183 + /***** TOMOYO Linux end. *****/
1184 if (upeer_sockaddr) {
1185 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1186 err = -ECONNABORTED;
1187 @@ -1440,7 +1467,9 @@ asmlinkage long sys_connect(int fd, stru
1188 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1189 if (err)
1190 goto out_put;
1191 -
1192 + /***** TOMOYO Linux start. *****/
1193 + if ((err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen)) == 0)
1194 + /***** TOMOYO Linux end. *****/
1195 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1196 sock->file->f_flags);
1197 out_put:
1198 diff -ubBpEr linux-2.6.12-2.3.legacy_FC3/net/unix/af_unix.c linux-2.6.12-2.3.legacy_FC3-ccs/net/unix/af_unix.c
1199 --- linux-2.6.12-2.3.legacy_FC3/net/unix/af_unix.c 2007-03-03 18:17:50.000000000 +0900
1200 +++ linux-2.6.12-2.3.legacy_FC3-ccs/net/unix/af_unix.c 2007-03-03 18:26:14.000000000 +0900
1201 @@ -117,6 +117,9 @@
1202 #include <linux/mount.h>
1203 #include <net/checksum.h>
1204 #include <linux/security.h>
1205 +/***** TOMOYO Linux start. *****/
1206 +#include <linux/tomoyo.h>
1207 +/***** TOMOYO Linux end. *****/
1208
1209 int sysctl_unix_max_dgram_qlen = 10;
1210
1211 @@ -738,6 +741,10 @@ static int unix_bind(struct socket *sock
1212 err = unix_autobind(sock);
1213 goto out;
1214 }
1215 + /***** TOMOYO Linux start. *****/
1216 + err = -EPERM;
1217 + if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out;
1218 + /***** TOMOYO Linux end. *****/
1219
1220 err = unix_mkname(sunaddr, addr_len, &hash);
1221 if (err < 0)
1222 @@ -781,6 +788,9 @@ static int unix_bind(struct socket *sock
1223 */
1224 mode = S_IFSOCK |
1225 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1226 + /***** TOMOYO Linux start. *****/
1227 + if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)
1228 + /***** TOMOYO Linux end. *****/
1229 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1230 if (err)
1231 goto out_mknod_dput;

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