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