開發和下載開源軟體

Browse Subversion Repository

Contents of /trunk/ccs-patch/ccs-patch-2.6.16.27-0.6_SUSE.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 111 - (show annotations) (download)
Wed Feb 28 11:45:08 2007 UTC (17 years, 2 months ago) by kumaneko
File MIME type: text/plain
File size: 51313 byte(s)


1 diff -ubBpEr linux-2.6.16.27-0.6/Makefile linux-2.6.16.27-0.6-ccs/Makefile
2 --- linux-2.6.16.27-0.6/Makefile 2006-12-26 10:45:12.000000000 +0900
3 +++ linux-2.6.16.27-0.6-ccs/Makefile 2006-12-26 10:46:05.000000000 +0900
4 @@ -1,7 +1,7 @@
5 VERSION = 2
6 PATCHLEVEL = 6
7 SUBLEVEL = 16
8 -EXTRAVERSION = .27
9 +EXTRAVERSION = .27-ccs
10 NAME=Sliding Snow Leopard
11
12 # *DOCUMENTATION*
13 diff -ubBpEr linux-2.6.16.27-0.6/fs/Kconfig linux-2.6.16.27-0.6-ccs/fs/Kconfig
14 --- linux-2.6.16.27-0.6/fs/Kconfig 2006-12-26 10:45:12.000000000 +0900
15 +++ linux-2.6.16.27-0.6-ccs/fs/Kconfig 2006-12-26 10:45:19.000000000 +0900
16 @@ -1888,5 +1888,7 @@ endmenu
17
18 source "fs/nls/Kconfig"
19
20 +source "fs/Kconfig.ccs"
21 +
22 endmenu
23
24 diff -ubBpEr linux-2.6.16.27-0.6/fs/Makefile linux-2.6.16.27-0.6-ccs/fs/Makefile
25 --- linux-2.6.16.27-0.6/fs/Makefile 2006-12-26 10:45:12.000000000 +0900
26 +++ linux-2.6.16.27-0.6-ccs/fs/Makefile 2006-12-26 10:45:19.000000000 +0900
27 @@ -106,3 +106,5 @@ obj-$(CONFIG_HPPFS) += hppfs/
28 obj-$(CONFIG_DEBUG_FS) += debugfs/
29 obj-$(CONFIG_CONFIGFS_FS) += configfs/
30 obj-$(CONFIG_OCFS2_FS) += ocfs2/
31 +
32 +include $(srctree)/fs/Makefile-2.6.ccs
33 diff -ubBpEr linux-2.6.16.27-0.6/fs/attr.c linux-2.6.16.27-0.6-ccs/fs/attr.c
34 --- linux-2.6.16.27-0.6/fs/attr.c 2006-12-26 10:45:12.000000000 +0900
35 +++ linux-2.6.16.27-0.6-ccs/fs/attr.c 2006-12-26 10:45:19.000000000 +0900
36 @@ -15,6 +15,9 @@
37 #include <linux/fcntl.h>
38 #include <linux/quotaops.h>
39 #include <linux/security.h>
40 +/***** TOMOYO Linux start. *****/
41 +#include <linux/tomoyo.h>
42 +/***** TOMOYO Linux end. *****/
43
44 /* Taken over from the old code... */
45
46 @@ -145,12 +148,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.16.27-0.6/fs/compat.c linux-2.6.16.27-0.6-ccs/fs/compat.c
68 --- linux-2.6.16.27-0.6/fs/compat.c 2006-12-26 10:45:12.000000000 +0900
69 +++ linux-2.6.16.27-0.6-ccs/fs/compat.c 2006-12-26 10:45:19.000000000 +0900
70 @@ -52,6 +52,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 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
79
80 @@ -405,6 +408,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 diff -ubBpEr linux-2.6.16.27-0.6/fs/exec.c linux-2.6.16.27-0.6-ccs/fs/exec.c
91 --- linux-2.6.16.27-0.6/fs/exec.c 2006-12-26 10:45:12.000000000 +0900
92 +++ linux-2.6.16.27-0.6-ccs/fs/exec.c 2006-12-26 10:45:19.000000000 +0900
93 @@ -58,6 +58,13 @@
94 #include <linux/kmod.h>
95 #endif
96
97 +/***** SAKURA Linux start. *****/
98 +#include <linux/sakura.h>
99 +/***** SAKURA Linux end. *****/
100 +/***** TOMOYO Linux start. *****/
101 +#include <linux/tomoyo.h>
102 +/***** TOMOYO Linux end. *****/
103 +
104 int core_uses_pid;
105 char core_pattern[65] = "core";
106 int suid_dumpable = 0;
107 @@ -140,6 +147,11 @@ asmlinkage long sys_uselib(const char __
108 if (error)
109 goto exit;
110
111 + /***** TOMOYO Linux start. *****/
112 + error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */
113 + if (error) goto exit;
114 + /***** TOMOYO Linux end. *****/
115 +
116 file = nameidata_to_filp(&nd, O_RDONLY);
117 error = PTR_ERR(file);
118 if (IS_ERR(file))
119 @@ -1149,6 +1161,25 @@ int do_execve(char * filename,
120 struct file *file;
121 int retval;
122 int i;
123 + /***** TOMOYO Linux start. *****/
124 +#ifdef CONFIG_TOMOYO
125 + struct domain_info *next_domain = NULL;
126 +#endif
127 + /***** TOMOYO Linux end. *****/
128 +
129 + /***** CCS Start. *****/
130 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
131 + extern void CCS_LoadPolicy(const char *filename);
132 + CCS_LoadPolicy(filename);
133 +#endif
134 + /***** CCS end. *****/
135 +
136 + /***** SAKURA Linux start. *****/
137 +#ifdef CONFIG_SAKURA_DROP_CAPABILITY_API
138 + if (strcmp(filename, "\\\\disable") == 0) return DropTaskCapability(argv);
139 + if (CheckTaskCapability(SAKURA_DISABLE_EXECVE) < 0) return -EPERM;
140 +#endif
141 + /***** SAKURA Linux end. *****/
142
143 retval = -ENOMEM;
144 bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
145 @@ -1161,6 +1192,15 @@ int do_execve(char * filename,
146 if (IS_ERR(file))
147 goto out_kfree;
148
149 + /***** TOMOYO Linux start. *****/
150 +#ifdef CONFIG_TOMOYO
151 + retval = FindNextDomain(filename, file, &next_domain, argv);
152 + if (retval < 0) {
153 + allow_write_access(file); fput(file); goto out_kfree;
154 + }
155 +#endif
156 + /***** TOMOYO Linux end. *****/
157 +
158 sched_exec();
159
160 bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
161 @@ -1207,6 +1247,19 @@ int do_execve(char * filename,
162 goto out;
163
164 retval = search_binary_handler(bprm,regs);
165 +
166 + /***** TOMOYO Linux start. *****/
167 +#ifdef CONFIG_TOMOYO
168 + if (retval >= 0) current->domain_info = next_domain;
169 +#endif
170 + /***** TOMOYO Linux end. *****/
171 +
172 + /***** SAKURA Linux start. *****/
173 +#ifdef CONFIG_SAKURA_DROP_CAPABILITY_API
174 + if (retval >= 0) RestoreTaskCapability();
175 +#endif
176 + /***** SAKURA Linux end. *****/
177 +
178 if (retval >= 0) {
179 free_arg_pages(bprm);
180
181 diff -ubBpEr linux-2.6.16.27-0.6/fs/fcntl.c linux-2.6.16.27-0.6-ccs/fs/fcntl.c
182 --- linux-2.6.16.27-0.6/fs/fcntl.c 2006-12-26 10:45:12.000000000 +0900
183 +++ linux-2.6.16.27-0.6-ccs/fs/fcntl.c 2006-12-26 10:45:19.000000000 +0900
184 @@ -22,6 +22,9 @@
185 #include <asm/poll.h>
186 #include <asm/siginfo.h>
187 #include <asm/uaccess.h>
188 +/***** TOMOYO Linux start. *****/
189 +#include <linux/tomoyo.h>
190 +/***** TOMOYO Linux end. *****/
191
192 void fastcall set_close_on_exec(unsigned int fd, int flag)
193 {
194 @@ -215,6 +218,10 @@ static int setfl(int fd, struct file * f
195 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
196 return -EPERM;
197
198 + /***** TOMOYO Linux start. *****/
199 + if (!(arg & O_APPEND) && CheckReWritePermission(filp)) return -EPERM;
200 + /***** TOMOYO Linux end. *****/
201 +
202 /* O_NOATIME can only be set by the owner or superuser */
203 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
204 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
205 diff -ubBpEr linux-2.6.16.27-0.6/fs/ioctl.c linux-2.6.16.27-0.6-ccs/fs/ioctl.c
206 --- linux-2.6.16.27-0.6/fs/ioctl.c 2006-12-26 10:45:12.000000000 +0900
207 +++ linux-2.6.16.27-0.6-ccs/fs/ioctl.c 2006-12-26 10:45:19.000000000 +0900
208 @@ -16,6 +16,9 @@
209
210 #include <asm/uaccess.h>
211 #include <asm/ioctls.h>
212 +/***** TOMOYO Linux start. *****/
213 +#include <linux/tomoyo.h>
214 +/***** TOMOYO Linux end. *****/
215
216 static long do_ioctl(struct file *filp, unsigned int cmd,
217 unsigned long arg)
218 @@ -24,6 +27,9 @@ static long do_ioctl(struct file *filp,
219
220 if (!filp->f_op)
221 goto out;
222 + /***** TOMOYO Linux start. *****/
223 + if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM;
224 + /***** TOMOYO Linux end. *****/
225
226 if (filp->f_op->unlocked_ioctl) {
227 error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
228 diff -ubBpEr linux-2.6.16.27-0.6/fs/namei.c linux-2.6.16.27-0.6-ccs/fs/namei.c
229 --- linux-2.6.16.27-0.6/fs/namei.c 2006-12-26 10:45:12.000000000 +0900
230 +++ linux-2.6.16.27-0.6-ccs/fs/namei.c 2006-12-26 10:45:19.000000000 +0900
231 @@ -37,6 +37,13 @@
232
233 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
234
235 +/***** SAKURA Linux start. *****/
236 +#include <linux/sakura.h>
237 +/***** SAKURA Linux end. *****/
238 +/***** TOMOYO Linux start. *****/
239 +#include <linux/tomoyo.h>
240 +/***** TOMOYO Linux end. *****/
241 +
242 /* [Feb-1997 T. Schoebel-Theuer]
243 * Fundamental changes in the pathname lookup mechanisms (namei)
244 * were necessary because of omirr. The reason is that omirr needs
245 @@ -783,6 +790,13 @@ static fastcall int __link_path_walk(con
246 int err;
247 unsigned int lookup_flags = nd->flags;
248
249 + /***** SAKURA Linux start. *****/
250 + if (CheckEUID() < 0) {
251 + path_release(nd);
252 + return -EPERM;
253 + }
254 + /***** SAKURA Linux end. *****/
255 +
256 while (*name=='/')
257 name++;
258 if (!*name)
259 @@ -1470,6 +1484,9 @@ int vfs_create(struct inode *dir, struct
260 error = security_inode_create(dir, dentry, mode);
261 if (error)
262 return error;
263 + /***** TOMOYO Linux start. *****/
264 + if (nd && (error = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error;
265 + /***** TOMOYO Linux end. *****/
266 DQUOT_INIT(dir);
267 error = dir->i_op->create(dir, dentry, mode, nd);
268 if (!error)
269 @@ -1509,7 +1526,7 @@ int may_open(struct nameidata *nd, int a
270
271 flag &= ~O_TRUNC;
272 } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
273 - return -EROFS;
274 + { ROFS_Log_from_dentry(nd->dentry, nd->mnt, "may_open"); return -EROFS; } /***** ReadOnly Tracer *****/
275 /*
276 * An append-only file must be opened in append mode for writing.
277 */
278 @@ -1525,6 +1542,11 @@ int may_open(struct nameidata *nd, int a
279 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
280 return -EPERM;
281
282 + /***** TOMOYO Linux start. *****/
283 + error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */
284 + if (error) return error;
285 + /***** TOMOYO Linux end. *****/
286 +
287 /*
288 * Ensure there are no outstanding leases on the file.
289 */
290 @@ -1556,6 +1578,9 @@ int may_open(struct nameidata *nd, int a
291 return 0;
292 }
293
294 +/***** TOMOYO Linux start. *****/
295 +#include <linux/tomoyo_vfs.h>
296 +/***** TOMOYO Linux end. *****/
297 /*
298 * open_namei()
299 *
300 @@ -1684,6 +1709,7 @@ ok:
301 exit_dput:
302 dput_path(&path, nd);
303 exit:
304 + if (error == -EROFS) ROFS_Log_from_dentry(nd->dentry, nd->mnt, "open_namei"); /***** ReadOnly Tracer *****/
305 if (!IS_ERR(nd->intent.open.file))
306 release_open_intent(nd);
307 path_release(nd);
308 @@ -1814,6 +1840,12 @@ asmlinkage long sys_mknodat(int dfd, con
309
310 if (S_ISDIR(mode))
311 return -EPERM;
312 + /***** TOMOYO Linux start. *****/
313 + if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM;
314 + if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM;
315 + if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM;
316 + if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM;
317 + /***** TOMOYO Linux end. *****/
318 tmp = getname(filename);
319 if (IS_ERR(tmp))
320 return PTR_ERR(tmp);
321 @@ -1832,10 +1864,16 @@ asmlinkage long sys_mknodat(int dfd, con
322 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
323 break;
324 case S_IFCHR: case S_IFBLK:
325 + /***** TOMOYO Linux start. *****/
326 + 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)
327 + /***** TOMOYO Linux end. *****/
328 error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
329 new_decode_dev(dev));
330 break;
331 case S_IFIFO: case S_IFSOCK:
332 + /***** TOMOYO Linux start. *****/
333 + 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)
334 + /***** TOMOYO Linux end. *****/
335 error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
336 break;
337 case S_IFDIR:
338 @@ -1844,6 +1882,7 @@ asmlinkage long sys_mknodat(int dfd, con
339 default:
340 error = -EINVAL;
341 }
342 + if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_mknod"); /***** ReadOnly Tracer *****/
343 dput(dentry);
344 }
345 mutex_unlock(&nd.dentry->d_inode->i_mutex);
346 @@ -1900,7 +1939,11 @@ asmlinkage long sys_mkdirat(int dfd, con
347 if (!IS_ERR(dentry)) {
348 if (!IS_POSIXACL(nd.dentry->d_inode))
349 mode &= ~current->fs->umask;
350 + /***** TOMOYO Linux start. *****/
351 + if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0)
352 + /***** TOMOYO Linux end. *****/
353 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
354 + if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_mkdir"); /***** ReadOnly Tracer *****/
355 dput(dentry);
356 }
357 mutex_unlock(&nd.dentry->d_inode->i_mutex);
358 @@ -2008,7 +2051,11 @@ static long do_rmdir(int dfd, const char
359 dentry = lookup_hash(&nd);
360 error = PTR_ERR(dentry);
361 if (!IS_ERR(dentry)) {
362 + /***** TOMOYO Linux start. *****/
363 + if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0)
364 + /***** TOMOYO Linux end. *****/
365 error = vfs_rmdir(nd.dentry->d_inode, dentry);
366 + if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_rmdir"); /***** ReadOnly Tracer *****/
367 dput(dentry);
368 }
369 mutex_unlock(&nd.dentry->d_inode->i_mutex);
370 @@ -2067,6 +2114,9 @@ static long do_unlinkat(int dfd, const c
371 struct dentry *dentry;
372 struct nameidata nd;
373 struct inode *inode = NULL;
374 + /***** TOMOYO Linux start. *****/
375 + if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM;
376 + /***** TOMOYO Linux end. *****/
377
378 name = getname(pathname);
379 if(IS_ERR(name))
380 @@ -2088,7 +2138,11 @@ static long do_unlinkat(int dfd, const c
381 inode = dentry->d_inode;
382 if (inode)
383 atomic_inc(&inode->i_count);
384 + /***** TOMOYO Linux start. *****/
385 + if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0)
386 + /***** TOMOYO Linux end. *****/
387 error = vfs_unlink(nd.dentry->d_inode, dentry);
388 + if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "sys_unlink"); /***** ReadOnly Tracer *****/
389 exit2:
390 dput(dentry);
391 }
392 @@ -2150,6 +2204,9 @@ asmlinkage long sys_symlinkat(const char
393 int error = 0;
394 char * from;
395 char * to;
396 + /***** TOMOYO Linux start. *****/
397 + if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM;
398 + /***** TOMOYO Linux end. *****/
399
400 from = getname(oldname);
401 if(IS_ERR(from))
402 @@ -2166,7 +2223,11 @@ asmlinkage long sys_symlinkat(const char
403 dentry = lookup_create(&nd, 0);
404 error = PTR_ERR(dentry);
405 if (!IS_ERR(dentry)) {
406 + /***** TOMOYO Linux start. *****/
407 + if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0)
408 + /***** TOMOYO Linux end. *****/
409 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
410 + if (error == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "vfs_symlink"); /***** ReadOnly Tracer *****/
411 dput(dentry);
412 }
413 mutex_unlock(&nd.dentry->d_inode->i_mutex);
414 @@ -2238,6 +2299,9 @@ asmlinkage long sys_linkat(int olddfd, c
415 struct nameidata nd, old_nd;
416 int error;
417 char * to;
418 + /***** TOMOYO Linux start. *****/
419 + if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM;
420 + /***** TOMOYO Linux end. *****/
421
422 if (flags != 0)
423 return -EINVAL;
424 @@ -2258,7 +2322,11 @@ asmlinkage long sys_linkat(int olddfd, c
425 new_dentry = lookup_create(&nd, 0);
426 error = PTR_ERR(new_dentry);
427 if (!IS_ERR(new_dentry)) {
428 + /***** TOMOYO Linux start. *****/
429 + 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)
430 + /***** TOMOYO Linux end. *****/
431 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
432 + if (error == -EROFS) ROFS_Log_from_dentry(new_dentry, nd.mnt, "vfs_link"); /***** ReadOnly Tracer *****/
433 dput(new_dentry);
434 }
435 mutex_unlock(&nd.dentry->d_inode->i_mutex);
436 @@ -2484,6 +2552,13 @@ static int do_rename(int olddfd, const c
437 if (new_dentry == trap)
438 goto exit5;
439
440 + /***** TOMOYO Linux start. *****/
441 + if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 ||
442 + (error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) {
443 + goto exit5;
444 + }
445 + /***** TOMOYO Linux end. *****/
446 +
447 error = vfs_rename(old_dir->d_inode, old_dentry,
448 new_dir->d_inode, new_dentry);
449 exit5:
450 @@ -2497,6 +2572,7 @@ exit2:
451 exit1:
452 path_release(&oldnd);
453 exit:
454 + if (error == -EROFS) ROFS_Log(oldname, "do_rename"); /***** ReadOnly Tracer *****/
455 return error;
456 }
457
458 @@ -2506,6 +2582,9 @@ asmlinkage long sys_renameat(int olddfd,
459 int error;
460 char * from;
461 char * to;
462 + /***** TOMOYO Linux start. *****/
463 + if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM;
464 + /***** TOMOYO Linux end. *****/
465
466 from = getname(oldname);
467 if(IS_ERR(from))
468 diff -ubBpEr linux-2.6.16.27-0.6/fs/namespace.c linux-2.6.16.27-0.6-ccs/fs/namespace.c
469 --- linux-2.6.16.27-0.6/fs/namespace.c 2006-12-26 10:45:12.000000000 +0900
470 +++ linux-2.6.16.27-0.6-ccs/fs/namespace.c 2006-12-26 10:45:19.000000000 +0900
471 @@ -26,6 +26,12 @@
472 #include <asm/uaccess.h>
473 #include <asm/unistd.h>
474 #include "pnode.h"
475 +/***** SAKURA Linux start. *****/
476 +#include <linux/sakura.h>
477 +/***** SAKURA Linux end. *****/
478 +/***** TOMOYO Linux start. *****/
479 +#include <linux/tomoyo.h>
480 +/***** TOMOYO Linux end. *****/
481
482 extern int __init init_rootfs(void);
483
484 @@ -510,6 +516,10 @@ static int do_umount(struct vfsmount *mn
485 if (retval)
486 return retval;
487
488 + /***** SAKURA Linux start. *****/
489 + if (SAKURA_MayUmount(mnt) < 0) return -EPERM;
490 + /***** SAKURA Linux end. *****/
491 +
492 /*
493 * Allow userspace to request a mountpoint be expired rather than
494 * unmounting unconditionally. Unmount only happens if:
495 @@ -598,6 +608,9 @@ asmlinkage long sys_umount(char __user *
496 {
497 struct nameidata nd;
498 int retval;
499 + /***** TOMOYO Linux start. *****/
500 + if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM;
501 + /***** TOMOYO Linux end. *****/
502
503 retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
504 if (retval)
505 @@ -882,6 +895,10 @@ static int do_loopback(struct nameidata
506
507 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
508 goto out;
509 + /***** SAKURA Linux start. *****/
510 + err = -EPERM;
511 + if (SAKURA_MayMount(nd) < 0 || CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) goto out;
512 + /***** SAKURA Linux end. *****/
513
514 err = -ENOMEM;
515 if (recurse)
516 @@ -966,7 +983,10 @@ static int do_move_mount(struct nameidat
517 err = -EINVAL;
518 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
519 goto out;
520 -
521 + /***** SAKURA Linux start. *****/
522 + err = -EPERM;
523 + if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0 || CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) goto out;
524 + /***** SAKURA Linux end. *****/
525 err = -ENOENT;
526 mutex_lock(&nd->dentry->d_inode->i_mutex);
527 if (IS_DEADDIR(nd->dentry->d_inode))
528 @@ -1068,6 +1088,10 @@ int do_add_mount(struct vfsmount *newmnt
529 err = -EINVAL;
530 if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
531 goto unlock;
532 + /***** SAKURA Linux start. *****/
533 + err = -EPERM;
534 + if (SAKURA_MayMount(nd) < 0 || CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) goto unlock;
535 + /***** SAKURA Linux end. *****/
536
537 newmnt->mnt_flags = mnt_flags;
538 if ((err = graft_tree(newmnt, nd)))
539 @@ -1438,6 +1462,9 @@ asmlinkage long sys_mount(char __user *
540 unsigned long type_page;
541 unsigned long dev_page;
542 char *dir_page;
543 + /***** TOMOYO Linux start. *****/
544 + if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM;
545 + /***** TOMOYO Linux end. *****/
546
547 retval = copy_mount_options(type, &type_page);
548 if (retval < 0)
549 @@ -1456,6 +1483,15 @@ asmlinkage long sys_mount(char __user *
550 if (retval < 0)
551 goto out3;
552
553 + /***** SAKURA Linux start. *****/
554 + retval = -EPERM;
555 + if (CheckMountPermission((char *) dev_page, dir_page, (char *) type_page, &flags) < 0 ||
556 + CheckTaskCapability(SAKURA_DISABLE_MOUNT) < 0) {
557 + free_page(data_page);
558 + goto out3;
559 + }
560 + /***** SAKURA Linux end. *****/
561 +
562 lock_kernel();
563 retval = do_mount((char *)dev_page, dir_page, (char *)type_page,
564 flags, (void *)data_page);
565 @@ -1575,6 +1611,10 @@ asmlinkage long sys_pivot_root(const cha
566 if (!capable(CAP_SYS_ADMIN))
567 return -EPERM;
568
569 + /***** SAKURA Linux start. *****/
570 + if (CheckPivotRootPermission() < 0 || CheckTaskCapability(SAKURA_DISABLE_PIVOTROOT) < 0) return -EPERM;
571 + /***** SAKURA Linux end. *****/
572 +
573 lock_kernel();
574
575 error = __user_walk(new_root, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
576 diff -ubBpEr linux-2.6.16.27-0.6/fs/open.c linux-2.6.16.27-0.6-ccs/fs/open.c
577 --- linux-2.6.16.27-0.6/fs/open.c 2006-12-26 10:45:12.000000000 +0900
578 +++ linux-2.6.16.27-0.6-ccs/fs/open.c 2006-12-26 10:45:19.000000000 +0900
579 @@ -30,6 +30,13 @@
580
581 #include <asm/unistd.h>
582
583 +/***** SAKURA Linux start. *****/
584 +#include <linux/sakura.h>
585 +/***** SAKURA Linux end. *****/
586 +/***** TOMOYO Linux start. *****/
587 +#include <linux/tomoyo.h>
588 +/***** TOMOYO Linux end. *****/
589 +
590 int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
591 {
592 int retval = -ENODEV;
593 @@ -266,6 +273,9 @@ static long do_sys_truncate(const char _
594 if (error)
595 goto dput_and_out;
596
597 + /***** TOMOYO Linux start. *****/
598 + if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0)
599 + /***** TOMOYO Linux end. *****/
600 error = locks_verify_truncate(inode, NULL, length);
601 if (!error) {
602 DQUOT_INIT(inode);
603 @@ -274,6 +284,7 @@ static long do_sys_truncate(const char _
604 put_write_access(inode);
605
606 dput_and_out:
607 + if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "do_sys_truncate"); /***** ReadOnly Tracer *****/
608 path_release(&nd);
609 out:
610 return error;
611 @@ -318,11 +329,14 @@ static long do_sys_ftruncate(unsigned in
612 error = -EPERM;
613 if (IS_APPEND(inode))
614 goto out_putf;
615 -
616 + /***** TOMOYO Linux start. *****/
617 + if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0)
618 + /***** TOMOYO Linux end. *****/
619 error = locks_verify_truncate(inode, file, length);
620 if (!error)
621 error = do_truncate(dentry, length, 0, file);
622 out_putf:
623 + if (error == -EROFS) ROFS_Log_from_dentry(file->f_dentry, file->f_vfsmnt, "do_sys_ftruncate"); /***** ReadOnly Tracer *****/
624 fput(file);
625 out:
626 return error;
627 @@ -410,6 +424,7 @@ asmlinkage long sys_utime(char __user *
628 error = notify_change(nd.dentry, &newattrs);
629 mutex_unlock(&inode->i_mutex);
630 dput_and_out:
631 + if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_utime"); /***** ReadOnly Tracer *****/
632 path_release(&nd);
633 out:
634 return error;
635 @@ -463,6 +478,7 @@ long do_utimes(int dfd, char __user *fil
636 error = notify_change(nd.dentry, &newattrs);
637 mutex_unlock(&inode->i_mutex);
638 dput_and_out:
639 + if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_utimes"); /***** ReadOnly Tracer *****/
640 path_release(&nd);
641 out:
642 return error;
643 @@ -525,6 +541,9 @@ asmlinkage long sys_faccessat(int dfd, c
644 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
645 && !special_file(nd.dentry->d_inode->i_mode))
646 res = -EROFS;
647 +#if 0
648 + if (res == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_access"); /***** ReadOnly Tracer *****/
649 +#endif
650 path_release(&nd);
651 }
652
653 @@ -595,6 +614,9 @@ asmlinkage long sys_chroot(const char __
654 {
655 struct nameidata nd;
656 int error;
657 + /***** TOMOYO Linux start. *****/
658 + if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) return -EPERM;
659 + /***** TOMOYO Linux end. *****/
660
661 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
662 if (error)
663 @@ -608,6 +630,19 @@ asmlinkage long sys_chroot(const char __
664 if (!capable(CAP_SYS_CHROOT))
665 goto dput_and_out;
666
667 + /***** SAKURA Linux start. *****/
668 + {
669 + char *name = getname(filename);
670 + if (!IS_ERR(name)) {
671 + error = CheckChRootPermission(name) | CheckTaskCapability(SAKURA_DISABLE_CHROOT);
672 + putname(name);
673 + } else {
674 + error = PTR_ERR(name);
675 + }
676 + if (error < 0) goto dput_and_out;
677 + }
678 + /***** SAKURA Linux end. *****/
679 +
680 set_fs_root(current->fs, nd.mnt, nd.dentry);
681 set_fs_altroot();
682 error = 0;
683 @@ -647,6 +682,7 @@ asmlinkage long sys_fchmod(unsigned int
684 mutex_unlock(&inode->i_mutex);
685
686 out_putf:
687 + if (err == -EROFS) ROFS_Log_from_dentry(file->f_dentry, file->f_vfsmnt, "sys_fchmod"); /***** ReadOnly Tracer *****/
688 fput(file);
689 out:
690 return err;
691 @@ -682,6 +718,7 @@ asmlinkage long sys_fchmodat(int dfd, co
692 mutex_unlock(&inode->i_mutex);
693
694 dput_and_out:
695 + if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_chmod"); /***** ReadOnly Tracer *****/
696 path_release(&nd);
697 out:
698 return error;
699 @@ -735,6 +772,7 @@ asmlinkage long sys_chown(const char __u
700 error = user_path_walk(filename, &nd);
701 if (!error) {
702 error = chown_common(nd.dentry, user, group);
703 + if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_chown"); /***** ReadOnly Tracer *****/
704 path_release(&nd);
705 }
706 return error;
707 @@ -768,6 +806,7 @@ asmlinkage long sys_lchown(const char __
708 error = user_path_walk_link(filename, &nd);
709 if (!error) {
710 error = chown_common(nd.dentry, user, group);
711 + if (error == -EROFS) ROFS_Log_from_dentry(nd.dentry, nd.mnt, "sys_lchown"); /***** ReadOnly Tracer *****/
712 path_release(&nd);
713 }
714 return error;
715 @@ -782,6 +821,7 @@ asmlinkage long sys_fchown(unsigned int
716 file = fget(fd);
717 if (file) {
718 error = chown_common(file->f_dentry, user, group);
719 + if (error == -EROFS) ROFS_Log_from_dentry(file->f_dentry, file->f_vfsmnt, "sys_fchown"); /***** ReadOnly Tracer *****/
720 fput(file);
721 }
722 return error;
723 @@ -1190,6 +1230,9 @@ EXPORT_SYMBOL(sys_close);
724 */
725 asmlinkage long sys_vhangup(void)
726 {
727 + /***** TOMOYO Linux start. *****/
728 + if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0)
729 + /***** TOMOYO Linux end. *****/
730 if (capable(CAP_SYS_TTY_CONFIG)) {
731 tty_vhangup(current->signal->tty);
732 return 0;
733 diff -ubBpEr linux-2.6.16.27-0.6/fs/proc/Makefile linux-2.6.16.27-0.6-ccs/fs/proc/Makefile
734 --- linux-2.6.16.27-0.6/fs/proc/Makefile 2006-12-26 10:45:12.000000000 +0900
735 +++ linux-2.6.16.27-0.6-ccs/fs/proc/Makefile 2006-12-26 10:45:19.000000000 +0900
736 @@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge
737 proc-$(CONFIG_PROC_KCORE) += kcore.o
738 proc-$(CONFIG_PROC_VMCORE) += vmcore.o
739 proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
740 +
741 +proc-$(CONFIG_SAKURA) += ccs_proc.o
742 +proc-$(CONFIG_TOMOYO) += ccs_proc.o
743 diff -ubBpEr linux-2.6.16.27-0.6/fs/proc/proc_misc.c linux-2.6.16.27-0.6-ccs/fs/proc/proc_misc.c
744 --- linux-2.6.16.27-0.6/fs/proc/proc_misc.c 2006-12-26 10:45:12.000000000 +0900
745 +++ linux-2.6.16.27-0.6-ccs/fs/proc/proc_misc.c 2006-12-26 10:46:26.000000000 +0900
746 @@ -782,4 +782,13 @@ void __init proc_misc_init(void)
747 if (entry)
748 entry->proc_fops = &proc_sysrq_trigger_operations;
749 #endif
750 + /***** CCS start. *****/
751 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
752 + {
753 + extern void __init CCSProc_Init(void);
754 + CCSProc_Init();
755 + printk("Hook version: 2.6.16.27-0.6_SUSE 2006/12/26\n");
756 + }
757 +#endif
758 + /***** CCS end. *****/
759 }
760 diff -ubBpEr linux-2.6.16.27-0.6/include/linux/init_task.h linux-2.6.16.27-0.6-ccs/include/linux/init_task.h
761 --- linux-2.6.16.27-0.6/include/linux/init_task.h 2006-12-26 10:45:12.000000000 +0900
762 +++ linux-2.6.16.27-0.6-ccs/include/linux/init_task.h 2006-12-26 10:45:19.000000000 +0900
763 @@ -123,6 +123,12 @@ extern struct group_info init_groups;
764 .map_base = __TASK_UNMAPPED_BASE, \
765 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
766 .fs_excl = ATOMIC_INIT(0), \
767 + /***** TOMOYO Linux start. *****/ \
768 + .domain_info = &KERNEL_DOMAIN, \
769 + /***** TOMOYO Linux end. *****/ \
770 + /***** SAKURA Linux start. *****/ \
771 + .dropped_capability = 0, \
772 + /***** SAKURA Linux end. *****/ \
773 INIT_TASK_PAGG(tsk) \
774 }
775
776 diff -ubBpEr linux-2.6.16.27-0.6/include/linux/sched.h linux-2.6.16.27-0.6-ccs/include/linux/sched.h
777 --- linux-2.6.16.27-0.6/include/linux/sched.h 2006-12-26 10:45:12.000000000 +0900
778 +++ linux-2.6.16.27-0.6-ccs/include/linux/sched.h 2006-12-26 10:45:19.000000000 +0900
779 @@ -40,6 +40,11 @@
780
781 struct exec_domain;
782
783 +/***** TOMOYO Linux start. *****/
784 +struct domain_info;
785 +extern struct domain_info KERNEL_DOMAIN;
786 +/***** TOMOYO Linux end. *****/
787 +
788 /*
789 * cloning flags:
790 */
791 @@ -904,6 +909,12 @@ struct task_struct {
792 #endif
793 atomic_t fs_excl; /* holding fs exclusive resources */
794 struct rcu_head rcu;
795 + /***** TOMOYO Linux start. *****/
796 + struct domain_info *domain_info;
797 + /***** TOMOYO Linux end. *****/
798 + /***** SAKURA Linux start. *****/
799 + unsigned int dropped_capability;
800 + /***** SAKURA Linux end. *****/
801 #ifdef CONFIG_PAGG
802 /* List of pagg (process aggregate) attachments */
803 struct list_head pagg_list;
804 diff -ubBpEr linux-2.6.16.27-0.6/kernel/kexec.c linux-2.6.16.27-0.6-ccs/kernel/kexec.c
805 --- linux-2.6.16.27-0.6/kernel/kexec.c 2006-12-26 10:45:12.000000000 +0900
806 +++ linux-2.6.16.27-0.6-ccs/kernel/kexec.c 2006-12-26 10:45:19.000000000 +0900
807 @@ -26,6 +26,9 @@
808 #include <asm/io.h>
809 #include <asm/system.h>
810 #include <asm/semaphore.h>
811 +/***** TOMOYO Linux start. *****/
812 +#include <linux/tomoyo.h>
813 +/***** TOMOYO Linux end. *****/
814
815 /* Per cpu memory for storing cpu states in case of system crash. */
816 note_buf_t* crash_notes;
817 @@ -922,6 +925,9 @@ asmlinkage long sys_kexec_load(unsigned
818 /* We only trust the superuser with rebooting the system. */
819 if (!capable(CAP_SYS_BOOT))
820 return -EPERM;
821 + /***** TOMOYO Linux start. *****/
822 + if (CheckCapabilityACL(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM;
823 + /***** TOMOYO Linux end. *****/
824
825 /*
826 * Verify we have a legal set of flags
827 diff -ubBpEr linux-2.6.16.27-0.6/kernel/kmod.c linux-2.6.16.27-0.6-ccs/kernel/kmod.c
828 --- linux-2.6.16.27-0.6/kernel/kmod.c 2006-12-26 10:45:12.000000000 +0900
829 +++ linux-2.6.16.27-0.6-ccs/kernel/kmod.c 2006-12-26 10:45:19.000000000 +0900
830 @@ -149,6 +149,13 @@ static int ____call_usermodehelper(void
831 /* We can run anywhere, unlike our parent keventd(). */
832 set_cpus_allowed(current, CPU_MASK_ALL);
833
834 + /***** TOMOYO Linux start. *****/
835 + current->domain_info = &KERNEL_DOMAIN;
836 + /***** TOMOYO Linux start. *****/
837 + /***** SAKURA Linux start. *****/
838 + current->dropped_capability = 0;
839 + /***** SAKURA Linux end. *****/
840 +
841 retval = -EPERM;
842 if (current->fs->root)
843 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
844 diff -ubBpEr linux-2.6.16.27-0.6/kernel/module.c linux-2.6.16.27-0.6-ccs/kernel/module.c
845 --- linux-2.6.16.27-0.6/kernel/module.c 2006-12-26 10:45:12.000000000 +0900
846 +++ linux-2.6.16.27-0.6-ccs/kernel/module.c 2006-12-26 10:45:19.000000000 +0900
847 @@ -42,6 +42,9 @@
848 #include <asm/uaccess.h>
849 #include <asm/semaphore.h>
850 #include <asm/cacheflush.h>
851 +/***** TOMOYO Linux start. *****/
852 +#include <linux/tomoyo.h>
853 +/***** TOMOYO Linux end. *****/
854
855 #if 0
856 #define DEBUGP printk
857 @@ -624,7 +627,9 @@ sys_delete_module(const char __user *nam
858
859 if (!capable(CAP_SYS_MODULE))
860 return -EPERM;
861 -
862 + /***** TOMOYO Linux start. *****/
863 + if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
864 + /***** TOMOYO Linux end. *****/
865 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
866 return -EFAULT;
867 name[MODULE_NAME_LEN-1] = '\0';
868 @@ -1860,7 +1865,9 @@ sys_init_module(void __user *umod,
869 /* Must have permission */
870 if (!capable(CAP_SYS_MODULE))
871 return -EPERM;
872 -
873 + /***** TOMOYO Linux start. *****/
874 + if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM;
875 + /***** TOMOYO Linux end. *****/
876 /* Only one module load at a time, please */
877 if (down_interruptible(&module_mutex) != 0)
878 return -EINTR;
879 diff -ubBpEr linux-2.6.16.27-0.6/kernel/sched.c linux-2.6.16.27-0.6-ccs/kernel/sched.c
880 --- linux-2.6.16.27-0.6/kernel/sched.c 2006-12-26 10:45:12.000000000 +0900
881 +++ linux-2.6.16.27-0.6-ccs/kernel/sched.c 2006-12-26 10:45:19.000000000 +0900
882 @@ -54,6 +54,9 @@
883 #include <asm/tlb.h>
884
885 #include <asm/unistd.h>
886 +/***** TOMOYO Linux start. *****/
887 +#include <linux/tomoyo.h>
888 +/***** TOMOYO Linux end. *****/
889
890 #if defined(CONFIG_LKCD_DUMP) || defined(CONFIG_LKCD_DUMP_MODULE)
891 /* used to soft spin in sched while dump is in progress */
892 @@ -3579,6 +3582,9 @@ asmlinkage long sys_nice(int increment)
893 {
894 int retval;
895 long nice;
896 + /***** TOMOYO Linux start. *****/
897 + if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;
898 + /***** TOMOYO Linux end. *****/
899
900 /*
901 * Setpriority might change our priority at the same moment.
902 diff -ubBpEr linux-2.6.16.27-0.6/kernel/signal.c linux-2.6.16.27-0.6-ccs/kernel/signal.c
903 --- linux-2.6.16.27-0.6/kernel/signal.c 2006-12-26 10:45:12.000000000 +0900
904 +++ linux-2.6.16.27-0.6-ccs/kernel/signal.c 2006-12-26 10:45:19.000000000 +0900
905 @@ -30,6 +30,9 @@
906 #include <asm/uaccess.h>
907 #include <asm/unistd.h>
908 #include <asm/siginfo.h>
909 +/***** TOMOYO Linux start. *****/
910 +#include <linux/tomoyo.h>
911 +/***** TOMOYO Linux end. *****/
912
913 /*
914 * SLAB caches for signal bits.
915 @@ -2337,6 +2340,10 @@ asmlinkage long
916 sys_kill(int pid, int sig)
917 {
918 struct siginfo info;
919 + /***** TOMOYO Linux start. *****/
920 + if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
921 + if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
922 + /***** TOMOYO Linux end. *****/
923
924 info.si_signo = sig;
925 info.si_errno = 0;
926 @@ -2395,6 +2402,10 @@ asmlinkage long sys_tgkill(int tgid, int
927 /* This is only valid for single tasks */
928 if (pid <= 0 || tgid <= 0)
929 return -EINVAL;
930 + /***** TOMOYO Linux start. *****/
931 + if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
932 + if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
933 + /***** TOMOYO Linux end. *****/
934
935 return do_tkill(tgid, pid, sig);
936 }
937 @@ -2408,6 +2419,10 @@ sys_tkill(int pid, int sig)
938 /* This is only valid for single tasks */
939 if (pid <= 0)
940 return -EINVAL;
941 + /***** TOMOYO Linux start. *****/
942 + if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM;
943 + if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM;
944 + /***** TOMOYO Linux end. *****/
945
946 return do_tkill(0, pid, sig);
947 }
948 diff -ubBpEr linux-2.6.16.27-0.6/kernel/sys.c linux-2.6.16.27-0.6-ccs/kernel/sys.c
949 --- linux-2.6.16.27-0.6/kernel/sys.c 2006-12-26 10:45:12.000000000 +0900
950 +++ linux-2.6.16.27-0.6-ccs/kernel/sys.c 2006-12-26 10:45:19.000000000 +0900
951 @@ -38,6 +38,9 @@
952 #include <asm/uaccess.h>
953 #include <asm/io.h>
954 #include <asm/unistd.h>
955 +/***** TOMOYO Linux start. *****/
956 +#include <linux/tomoyo.h>
957 +/***** TOMOYO Linux end. *****/
958
959 #ifndef SET_UNALIGN_CTL
960 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
961 @@ -269,6 +272,9 @@ asmlinkage long sys_setpriority(int whic
962
963 if (which > 2 || which < 0)
964 goto out;
965 + /***** TOMOYO Linux start. *****/
966 + if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM;
967 + /***** TOMOYO Linux end. *****/
968
969 /* normalize: avoid signed division (rounding problems) */
970 error = -ESRCH;
971 @@ -496,6 +502,9 @@ asmlinkage long sys_reboot(int magic1, i
972 magic2 != LINUX_REBOOT_MAGIC2B &&
973 magic2 != LINUX_REBOOT_MAGIC2C))
974 return -EINVAL;
975 + /***** TOMOYO Linux start. *****/
976 + if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM;
977 + /***** TOMOYO Linux end. *****/
978
979 /* Instead of trying to make the power_off code look like
980 * halt when pm_power_off is not set do it the easy way.
981 @@ -1533,6 +1542,9 @@ asmlinkage long sys_sethostname(char __u
982 return -EPERM;
983 if (len < 0 || len > __NEW_UTS_LEN)
984 return -EINVAL;
985 + /***** TOMOYO Linux start. *****/
986 + if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
987 + /***** TOMOYO Linux end. *****/
988 down_write(&uts_sem);
989 errno = -EFAULT;
990 if (!copy_from_user(tmp, name, len)) {
991 @@ -1578,6 +1590,9 @@ asmlinkage long sys_setdomainname(char _
992 return -EPERM;
993 if (len < 0 || len > __NEW_UTS_LEN)
994 return -EINVAL;
995 + /***** TOMOYO Linux start. *****/
996 + if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM;
997 + /***** TOMOYO Linux end. *****/
998
999 down_write(&uts_sem);
1000 errno = -EFAULT;
1001 diff -ubBpEr linux-2.6.16.27-0.6/kernel/sysctl.c linux-2.6.16.27-0.6-ccs/kernel/sysctl.c
1002 --- linux-2.6.16.27-0.6/kernel/sysctl.c 2006-12-26 10:45:12.000000000 +0900
1003 +++ linux-2.6.16.27-0.6-ccs/kernel/sysctl.c 2006-12-26 10:45:19.000000000 +0900
1004 @@ -49,6 +49,9 @@
1005
1006 #include <asm/uaccess.h>
1007 #include <asm/processor.h>
1008 +/***** TOMOYO Linux start. *****/
1009 +#include <linux/tomoyo.h>
1010 +/***** TOMOYO Linux end. *****/
1011
1012 extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
1013 void __user *buffer, size_t *lenp, loff_t *ppos);
1014 @@ -1150,6 +1153,87 @@ void __init sysctl_init(void)
1015 #endif
1016 }
1017
1018 +/***** TOMOYO Linux start. *****/
1019 +static int try_parse_table(int __user *name, int nlen, void __user *oldval, void __user *newval, ctl_table *table)
1020 +{
1021 + int n;
1022 + int error = -ENOMEM;
1023 + int op = 0;
1024 + char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1025 + if (oldval) op |= 004;
1026 + if (newval) op |= 002;
1027 + if (!op) { /* Neither read nor write */
1028 + error = 0;
1029 + goto out;
1030 + }
1031 + if (!buffer) goto out;
1032 + memset(buffer, 0, PAGE_SIZE);
1033 + snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1034 + repeat:
1035 + if (!nlen) {
1036 + error = -ENOTDIR;
1037 + goto out;
1038 + }
1039 + if (get_user(n, name)) {
1040 + error = -EFAULT;
1041 + goto out;
1042 + }
1043 + for ( ; table->ctl_name; table++) {
1044 + if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1045 + int pos = strlen(buffer);
1046 + const char *cp = table->procname;
1047 + error = -ENOMEM;
1048 + if (cp) {
1049 + if (pos + 1 >= PAGE_SIZE - 1) goto out;
1050 + buffer[pos++] = '/';
1051 + while (*cp) {
1052 + const unsigned char c = * (const unsigned char *) cp;
1053 + if (c == '\\') {
1054 + if (pos + 2 >= PAGE_SIZE - 1) goto out;
1055 + buffer[pos++] = '\\';
1056 + buffer[pos++] = '\\';
1057 + } else if (c > ' ' && c < 127) {
1058 + if (pos + 1 >= PAGE_SIZE - 1) goto out;
1059 + buffer[pos++] = c;
1060 + } else {
1061 + if (pos + 4 >= PAGE_SIZE - 1) goto out;
1062 + buffer[pos++] = '\\';
1063 + buffer[pos++] = (c >> 6) + '0';
1064 + buffer[pos++] = ((c >> 3) & 7) + '0';
1065 + buffer[pos++] = (c & 7) + '0';
1066 + }
1067 + cp++;
1068 + }
1069 + } else {
1070 + /* Assume nobody assigns "=\$=" for procname. */
1071 + snprintf(buffer + pos, PAGE_SIZE - pos - 1, "/=%d=", table->ctl_name);
1072 + if (memchr(buffer, '\0', PAGE_SIZE - 2) == NULL) goto out;
1073 + }
1074 + if (table->child) {
1075 + if (table->strategy) {
1076 + /* printk("sysctl='%s'\n", buffer); */
1077 + if (CheckFilePerm(buffer, op, "sysctl")) {
1078 + error = -EPERM;
1079 + goto out;
1080 + }
1081 + }
1082 + name++;
1083 + nlen--;
1084 + table = table->child;
1085 + goto repeat;
1086 + }
1087 + /* printk("sysctl='%s'\n", buffer); */
1088 + error = CheckFilePerm(buffer, op, "sysctl");
1089 + goto out;
1090 + }
1091 + }
1092 + error = -ENOTDIR;
1093 + out:
1094 + kfree(buffer);
1095 + return error;
1096 +}
1097 +/***** TOMOYO Linux end. *****/
1098 +
1099 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1100 void __user *newval, size_t newlen)
1101 {
1102 @@ -1175,6 +1259,9 @@ int do_sysctl(int __user *name, int nlen
1103
1104 spin_unlock(&sysctl_lock);
1105
1106 + /***** TOMOYO Linux start. *****/
1107 + if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0)
1108 + /***** TOMOYO Linux end. *****/
1109 error = parse_table(name, nlen, oldval, oldlenp,
1110 newval, newlen, head->ctl_table,
1111 &context);
1112 @@ -1247,6 +1334,12 @@ repeat:
1113 if (ctl_perm(table, 001))
1114 return -EPERM;
1115 if (table->strategy) {
1116 + /***** TOMOYO Linux start. *****/
1117 + int op = 0;
1118 + if (oldval) op |= 004;
1119 + if (newval) op |= 002;
1120 + if (ctl_perm(table, op)) return -EPERM;
1121 + /***** TOMOYO Linux end. *****/
1122 error = table->strategy(
1123 table, name, nlen,
1124 oldval, oldlenp,
1125 diff -ubBpEr linux-2.6.16.27-0.6/kernel/time.c linux-2.6.16.27-0.6-ccs/kernel/time.c
1126 --- linux-2.6.16.27-0.6/kernel/time.c 2006-12-26 10:45:12.000000000 +0900
1127 +++ linux-2.6.16.27-0.6-ccs/kernel/time.c 2006-12-26 10:45:19.000000000 +0900
1128 @@ -39,6 +39,9 @@
1129
1130 #include <asm/uaccess.h>
1131 #include <asm/unistd.h>
1132 +/***** TOMOYO Linux start. *****/
1133 +#include <linux/tomoyo.h>
1134 +/***** TOMOYO Linux end. *****/
1135
1136 /*
1137 * The timezone where the local system is located. Used as a default by some
1138 @@ -91,6 +94,9 @@ asmlinkage long sys_stime(time_t __user
1139 err = security_settime(&tv, NULL);
1140 if (err)
1141 return err;
1142 + /***** TOMOYO Linux start. *****/
1143 + if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
1144 + /***** TOMOYO Linux end. *****/
1145
1146 do_settimeofday(&tv);
1147 return 0;
1148 @@ -161,6 +167,9 @@ int do_sys_settimeofday(struct timespec
1149 error = security_settime(tv, tz);
1150 if (error)
1151 return error;
1152 + /***** TOMOYO Linux start. *****/
1153 + if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
1154 + /***** TOMOYO Linux end. *****/
1155
1156 if (tz) {
1157 /* SMP safe, global irq locking makes it work. */
1158 @@ -239,6 +248,9 @@ int do_adjtimex(struct timex *txc)
1159 /* In order to modify anything, you gotta be super-user! */
1160 if (txc->modes && !capable(CAP_SYS_TIME))
1161 return -EPERM;
1162 + /***** TOMOYO Linux start. *****/
1163 + if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM;
1164 + /***** TOMOYO Linux end. *****/
1165
1166 /* Now we validate the data before disabling interrupts */
1167
1168 diff -ubBpEr linux-2.6.16.27-0.6/net/ipv4/inet_connection_sock.c linux-2.6.16.27-0.6-ccs/net/ipv4/inet_connection_sock.c
1169 --- linux-2.6.16.27-0.6/net/ipv4/inet_connection_sock.c 2006-12-26 10:45:12.000000000 +0900
1170 +++ linux-2.6.16.27-0.6-ccs/net/ipv4/inet_connection_sock.c 2006-12-26 10:45:19.000000000 +0900
1171 @@ -24,6 +24,9 @@
1172 #include <net/route.h>
1173 #include <net/tcp_states.h>
1174 #include <net/xfrm.h>
1175 +/***** SAKURA Linux start. *****/
1176 +#include <linux/sakura.h>
1177 +/***** SAKURA Linux end. *****/
1178
1179 #ifdef INET_CSK_DEBUG
1180 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1181 @@ -88,6 +91,9 @@ int inet_csk_get_port(struct inet_hashin
1182 do {
1183 head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1184 spin_lock(&head->lock);
1185 + /***** SAKURA Linux start. *****/
1186 + if (SAKURA_MayAutobind(rover) < 0) goto next;
1187 + /***** SAKURA Linux end. *****/
1188 inet_bind_bucket_for_each(tb, node, &head->chain)
1189 if (tb->port == rover)
1190 goto next;
1191 diff -ubBpEr linux-2.6.16.27-0.6/net/ipv4/inet_hashtables.c linux-2.6.16.27-0.6-ccs/net/ipv4/inet_hashtables.c
1192 --- linux-2.6.16.27-0.6/net/ipv4/inet_hashtables.c 2006-12-26 10:45:12.000000000 +0900
1193 +++ linux-2.6.16.27-0.6-ccs/net/ipv4/inet_hashtables.c 2006-12-26 10:45:19.000000000 +0900
1194 @@ -23,6 +23,9 @@
1195 #include <net/inet_connection_sock.h>
1196 #include <net/inet_hashtables.h>
1197 #include <net/ip.h>
1198 +/***** SAKURA Linux start. *****/
1199 +#include <linux/sakura.h>
1200 +/***** SAKURA Linux end. *****/
1201
1202 /*
1203 * Allocate and initialize a new local port bind bucket.
1204 @@ -268,6 +271,9 @@ int inet_hash_connect(struct inet_timewa
1205 local_bh_disable();
1206 for (i = 1; i <= range; i++) {
1207 port = low + (i + offset) % range;
1208 + /***** SAKURA Linux start. *****/
1209 + if (SAKURA_MayAutobind(port) < 0) continue;
1210 + /***** SAKURA Linux end. *****/
1211 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1212 spin_lock(&head->lock);
1213
1214 diff -ubBpEr linux-2.6.16.27-0.6/net/ipv4/udp.c linux-2.6.16.27-0.6-ccs/net/ipv4/udp.c
1215 --- linux-2.6.16.27-0.6/net/ipv4/udp.c 2006-12-26 10:45:12.000000000 +0900
1216 +++ linux-2.6.16.27-0.6-ccs/net/ipv4/udp.c 2006-12-26 10:45:19.000000000 +0900
1217 @@ -109,6 +109,9 @@
1218 #include <net/inet_common.h>
1219 #include <net/checksum.h>
1220 #include <net/xfrm.h>
1221 +/***** SAKURA Linux start. *****/
1222 +#include <linux/sakura.h>
1223 +/***** SAKURA Linux end. *****/
1224
1225 /*
1226 * Snmp MIB for the UDP layer
1227 @@ -140,6 +143,9 @@ static int udp_v4_get_port(struct sock *
1228 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
1229 struct hlist_head *list;
1230 int size;
1231 + /***** SAKURA Linux start. *****/
1232 + if (SAKURA_MayAutobind(result) < 0) continue;
1233 + /***** SAKURA Linux end. *****/
1234
1235 list = &udp_hash[result & (UDP_HTABLE_SIZE - 1)];
1236 if (hlist_empty(list)) {
1237 @@ -163,6 +169,9 @@ static int udp_v4_get_port(struct sock *
1238 result = sysctl_local_port_range[0]
1239 + ((result - sysctl_local_port_range[0]) &
1240 (UDP_HTABLE_SIZE - 1));
1241 + /***** SAKURA Linux start. *****/
1242 + if (SAKURA_MayAutobind(result) < 0) continue;
1243 + /***** SAKURA Linux end. *****/
1244 if (!udp_lport_inuse(result))
1245 break;
1246 }
1247 diff -ubBpEr linux-2.6.16.27-0.6/net/ipv6/inet6_hashtables.c linux-2.6.16.27-0.6-ccs/net/ipv6/inet6_hashtables.c
1248 --- linux-2.6.16.27-0.6/net/ipv6/inet6_hashtables.c 2006-12-26 10:45:12.000000000 +0900
1249 +++ linux-2.6.16.27-0.6-ccs/net/ipv6/inet6_hashtables.c 2006-12-26 10:45:19.000000000 +0900
1250 @@ -22,6 +22,9 @@
1251 #include <net/inet_hashtables.h>
1252 #include <net/inet6_hashtables.h>
1253 #include <net/ip.h>
1254 +/***** SAKURA Linux start. *****/
1255 +#include <linux/sakura.h>
1256 +/***** SAKURA Linux end. *****/
1257
1258 struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
1259 const struct in6_addr *daddr,
1260 @@ -187,6 +190,9 @@ int inet6_hash_connect(struct inet_timew
1261 local_bh_disable();
1262 for (i = 1; i <= range; i++) {
1263 port = low + (i + offset) % range;
1264 + /***** SAKURA Linux start. *****/
1265 + if (SAKURA_MayAutobind(port) < 0) continue;
1266 + /***** SAKURA Linux end. *****/
1267 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1268 spin_lock(&head->lock);
1269
1270 diff -ubBpEr linux-2.6.16.27-0.6/net/ipv6/udp.c linux-2.6.16.27-0.6-ccs/net/ipv6/udp.c
1271 --- linux-2.6.16.27-0.6/net/ipv6/udp.c 2006-12-26 10:45:12.000000000 +0900
1272 +++ linux-2.6.16.27-0.6-ccs/net/ipv6/udp.c 2006-12-26 10:45:19.000000000 +0900
1273 @@ -59,6 +59,9 @@
1274
1275 #include <linux/proc_fs.h>
1276 #include <linux/seq_file.h>
1277 +/***** SAKURA Linux start. *****/
1278 +#include <linux/sakura.h>
1279 +/***** SAKURA Linux end. *****/
1280
1281 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1282
1283 @@ -82,6 +85,9 @@ static int udp_v6_get_port(struct sock *
1284 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
1285 int size;
1286 struct hlist_head *list;
1287 + /***** SAKURA Linux start. *****/
1288 + if (SAKURA_MayAutobind(result) < 0) continue;
1289 + /***** SAKURA Linux end. *****/
1290
1291 list = &udp_hash[result & (UDP_HTABLE_SIZE - 1)];
1292 if (hlist_empty(list)) {
1293 @@ -105,6 +111,9 @@ static int udp_v6_get_port(struct sock *
1294 result = sysctl_local_port_range[0]
1295 + ((result - sysctl_local_port_range[0]) &
1296 (UDP_HTABLE_SIZE - 1));
1297 + /***** SAKURA Linux start. *****/
1298 + if (SAKURA_MayAutobind(result) < 0) continue;
1299 + /***** SAKURA Linux end. *****/
1300 if (!udp_lport_inuse(result))
1301 break;
1302 }
1303 diff -ubBpEr linux-2.6.16.27-0.6/net/socket.c linux-2.6.16.27-0.6-ccs/net/socket.c
1304 --- linux-2.6.16.27-0.6/net/socket.c 2006-12-26 10:45:12.000000000 +0900
1305 +++ linux-2.6.16.27-0.6-ccs/net/socket.c 2006-12-26 10:45:19.000000000 +0900
1306 @@ -97,6 +97,11 @@
1307 #include <net/sock.h>
1308 #include <linux/netfilter.h>
1309
1310 +/***** TOMOYO Linux start. *****/
1311 +#include <linux/tomoyo.h>
1312 +#include <linux/tomoyo_socket.h>
1313 +/***** TOMOYO Linux end. *****/
1314 +
1315 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1316 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1317 size_t size, loff_t pos);
1318 @@ -547,7 +552,9 @@ static inline int __sock_sendmsg(struct
1319 err = security_socket_sendmsg(sock, msg, size);
1320 if (err)
1321 return err;
1322 -
1323 + /***** TOMOYO Linux start. *****/
1324 + if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM;
1325 + /***** TOMOYO Linux start. *****/
1326 return sock->ops->sendmsg(iocb, sock, msg, size);
1327 }
1328
1329 @@ -614,6 +621,11 @@ int sock_recvmsg(struct socket *sock, st
1330 ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
1331 if (-EIOCBQUEUED == ret)
1332 ret = wait_on_sync_kiocb(&iocb);
1333 + /***** TOMOYO Linux start. *****/
1334 + if (ret >= 0 && CheckSocketRecvMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) {
1335 + ret = -EAGAIN; /* Hope less harmful than -EPERM. */
1336 + }
1337 + /***** TOMOYO Linux end. *****/
1338 return ret;
1339 }
1340
1341 @@ -1103,6 +1115,10 @@ static int __sock_create(int family, int
1342 family = PF_PACKET;
1343 }
1344
1345 + /***** TOMOYO Linux start. *****/
1346 + if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err;
1347 + /***** TOMOYO Linux end. *****/
1348 +
1349 err = security_socket_create(family, type, protocol, kern);
1350 if (err)
1351 return err;
1352 @@ -1300,6 +1316,9 @@ asmlinkage long sys_bind(int fd, struct
1353 sockfd_put(sock);
1354 return err;
1355 }
1356 + /***** TOMOYO Linux start. *****/
1357 + if ((err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen)) == 0)
1358 + /***** TOMOYO Linux end. *****/
1359 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1360 }
1361 sockfd_put(sock);
1362 @@ -1330,7 +1349,9 @@ asmlinkage long sys_listen(int fd, int b
1363 sockfd_put(sock);
1364 return err;
1365 }
1366 -
1367 + /***** TOMOYO Linux start. *****/
1368 + if ((err = CheckSocketListenPermission(sock)) == 0)
1369 + /***** TOMOYO Linux end. *****/
1370 err=sock->ops->listen(sock, backlog);
1371 sockfd_put(sock);
1372 }
1373 @@ -1381,6 +1402,12 @@ asmlinkage long sys_accept(int fd, struc
1374 if (err < 0)
1375 goto out_release;
1376
1377 + /***** TOMOYO Linux start. *****/
1378 + if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) {
1379 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1380 + goto out_release;
1381 + }
1382 + /***** TOMOYO Linux end. *****/
1383 if (upeer_sockaddr) {
1384 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1385 err = -ECONNABORTED;
1386 @@ -1436,7 +1463,9 @@ asmlinkage long sys_connect(int fd, stru
1387 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1388 if (err)
1389 goto out_put;
1390 -
1391 + /***** TOMOYO Linux start. *****/
1392 + if ((err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen)) == 0)
1393 + /***** TOMOYO Linux end. *****/
1394 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1395 sock->file->f_flags);
1396 out_put:
1397 diff -ubBpEr linux-2.6.16.27-0.6/net/unix/af_unix.c linux-2.6.16.27-0.6-ccs/net/unix/af_unix.c
1398 --- linux-2.6.16.27-0.6/net/unix/af_unix.c 2006-12-26 10:45:12.000000000 +0900
1399 +++ linux-2.6.16.27-0.6-ccs/net/unix/af_unix.c 2006-12-26 10:45:19.000000000 +0900
1400 @@ -117,6 +117,12 @@
1401 #include <linux/mount.h>
1402 #include <net/checksum.h>
1403 #include <linux/security.h>
1404 +/***** SAKURA Linux start. *****/
1405 +#include <linux/sakura.h>
1406 +/***** SAKURA Linux end. *****/
1407 +/***** TOMOYO Linux start. *****/
1408 +#include <linux/tomoyo.h>
1409 +/***** TOMOYO Linux end. *****/
1410
1411 int sysctl_unix_max_dgram_qlen = 10;
1412
1413 @@ -738,6 +744,10 @@ static int unix_bind(struct socket *sock
1414 err = unix_autobind(sock);
1415 goto out;
1416 }
1417 + /***** TOMOYO Linux start. *****/
1418 + err = -EPERM;
1419 + if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out;
1420 + /***** TOMOYO Linux end. *****/
1421
1422 err = unix_mkname(sunaddr, addr_len, &hash);
1423 if (err < 0)
1424 @@ -781,7 +791,11 @@ static int unix_bind(struct socket *sock
1425 */
1426 mode = S_IFSOCK |
1427 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1428 + /***** TOMOYO Linux start. *****/
1429 + if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0)
1430 + /***** TOMOYO Linux end. *****/
1431 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1432 + if (err == -EROFS) ROFS_Log_from_dentry(dentry, nd.mnt, "unix_bind"); /***** ReadOnly Tracer *****/
1433 if (err)
1434 goto out_mknod_dput;
1435 mutex_unlock(&nd.dentry->d_inode->i_mutex);

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