1 |
This is TOMOYO Linux patch for Ubuntu 9.04. |
2 |
|
3 |
Source code for this patch is "apt-get install linux-source-2.6.28" |
4 |
--- |
5 |
fs/Kconfig | 2 ++ |
6 |
fs/Makefile | 2 ++ |
7 |
fs/attr.c | 3 +++ |
8 |
fs/compat.c | 3 ++- |
9 |
fs/compat_ioctl.c | 7 +++++++ |
10 |
fs/exec.c | 10 +++++++++- |
11 |
fs/fcntl.c | 5 +++++ |
12 |
fs/ioctl.c | 5 +++++ |
13 |
fs/namei.c | 35 +++++++++++++++++++++++++++++++++++ |
14 |
fs/namespace.c | 27 +++++++++++++++++++++++++++ |
15 |
fs/open.c | 15 +++++++++++++++ |
16 |
fs/proc/Makefile | 3 +++ |
17 |
fs/proc/version.c | 7 +++++++ |
18 |
include/linux/init_task.h | 2 ++ |
19 |
include/linux/sched.h | 4 ++++ |
20 |
kernel/compat.c | 3 +++ |
21 |
kernel/kexec.c | 3 +++ |
22 |
kernel/kmod.c | 3 +++ |
23 |
kernel/module.c | 5 +++++ |
24 |
kernel/ptrace.c | 5 +++++ |
25 |
kernel/sched.c | 3 +++ |
26 |
kernel/signal.c | 7 +++++++ |
27 |
kernel/sys.c | 11 +++++++++++ |
28 |
kernel/sysctl.c | 4 ++++ |
29 |
kernel/time.c | 5 +++++ |
30 |
kernel/time/ntp.c | 6 ++++++ |
31 |
net/ipv4/inet_connection_sock.c | 3 +++ |
32 |
net/ipv4/inet_hashtables.c | 3 +++ |
33 |
net/ipv4/raw.c | 4 ++++ |
34 |
net/ipv4/udp.c | 9 ++++++++- |
35 |
net/ipv6/raw.c | 4 ++++ |
36 |
net/ipv6/udp.c | 4 ++++ |
37 |
net/socket.c | 24 ++++++++++++++++++++++++ |
38 |
net/unix/af_unix.c | 4 ++++ |
39 |
34 files changed, 237 insertions(+), 3 deletions(-) |
40 |
|
41 |
--- linux-2.6.28-13.45.orig/fs/Kconfig |
42 |
+++ linux-2.6.28-13.45/fs/Kconfig |
43 |
@@ -1557,4 +1557,6 @@ endif |
44 |
source "fs/nls/Kconfig" |
45 |
source "fs/dlm/Kconfig" |
46 |
|
47 |
+source "fs/Kconfig.ccs" |
48 |
+ |
49 |
endmenu |
50 |
--- linux-2.6.28-13.45.orig/fs/Makefile |
51 |
+++ linux-2.6.28-13.45/fs/Makefile |
52 |
@@ -122,3 +122,5 @@ obj-$(CONFIG_HPPFS) += hppfs/ |
53 |
obj-$(CONFIG_DEBUG_FS) += debugfs/ |
54 |
obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
55 |
obj-$(CONFIG_GFS2_FS) += gfs2/ |
56 |
+ |
57 |
+include $(srctree)/fs/Makefile-2.6.ccs |
58 |
--- linux-2.6.28-13.45.orig/fs/attr.c |
59 |
+++ linux-2.6.28-13.45/fs/attr.c |
60 |
@@ -14,6 +14,7 @@ |
61 |
#include <linux/fcntl.h> |
62 |
#include <linux/quotaops.h> |
63 |
#include <linux/security.h> |
64 |
+#include <linux/tomoyo.h> |
65 |
|
66 |
/* Taken over from the old code... */ |
67 |
|
68 |
@@ -161,6 +162,8 @@ int fnotify_change(struct dentry *dentry |
69 |
return 0; |
70 |
|
71 |
error = security_inode_setattr(dentry, mnt, attr); |
72 |
+ if (!error) |
73 |
+ error = ccs_check_setattr_permission(dentry, attr); |
74 |
if (error) |
75 |
return error; |
76 |
|
77 |
--- linux-2.6.28-13.45.orig/fs/compat.c |
78 |
+++ linux-2.6.28-13.45/fs/compat.c |
79 |
@@ -56,6 +56,7 @@ |
80 |
#include <asm/mmu_context.h> |
81 |
#include <asm/ioctls.h> |
82 |
#include "internal.h" |
83 |
+#include <linux/tomoyo.h> |
84 |
|
85 |
int compat_log = 1; |
86 |
|
87 |
@@ -1437,7 +1438,7 @@ int compat_do_execve(char * filename, |
88 |
if (retval < 0) |
89 |
goto out; |
90 |
|
91 |
- retval = search_binary_handler(bprm, regs); |
92 |
+ retval = ccs_search_binary_handler(bprm, regs); |
93 |
if (retval >= 0) { |
94 |
/* execve success */ |
95 |
security_bprm_free(bprm); |
96 |
--- linux-2.6.28-13.45.orig/fs/compat_ioctl.c |
97 |
+++ linux-2.6.28-13.45/fs/compat_ioctl.c |
98 |
@@ -113,6 +113,7 @@ |
99 |
#ifdef CONFIG_SPARC |
100 |
#include <asm/fbio.h> |
101 |
#endif |
102 |
+#include <linux/tomoyo.h> |
103 |
|
104 |
static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
105 |
unsigned long arg, struct file *f) |
106 |
@@ -2788,6 +2789,8 @@ asmlinkage long compat_sys_ioctl(unsigne |
107 |
|
108 |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
109 |
error = security_file_ioctl(filp, cmd, arg); |
110 |
+ if (!error) |
111 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
112 |
if (error) |
113 |
goto out_fput; |
114 |
|
115 |
@@ -2812,6 +2815,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
116 |
/*FALL THROUGH*/ |
117 |
|
118 |
default: |
119 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
120 |
+ error = -EPERM; |
121 |
+ goto out_fput; |
122 |
+ } |
123 |
if (filp->f_op && filp->f_op->compat_ioctl) { |
124 |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
125 |
if (error != -ENOIOCTLCMD) |
126 |
--- linux-2.6.28-13.45.orig/fs/exec.c |
127 |
+++ linux-2.6.28-13.45/fs/exec.c |
128 |
@@ -61,6 +61,8 @@ |
129 |
#include <linux/a.out.h> |
130 |
#endif |
131 |
|
132 |
+#include <linux/tomoyo.h> |
133 |
+ |
134 |
int core_uses_pid; |
135 |
char core_pattern[CORENAME_MAX_SIZE] = "core"; |
136 |
int suid_dumpable = 0; |
137 |
@@ -129,6 +131,9 @@ SYSCALL_DEFINE1(uselib, const char __use |
138 |
error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN); |
139 |
if (error) |
140 |
goto exit; |
141 |
+ error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt); |
142 |
+ if (error) |
143 |
+ goto exit; |
144 |
|
145 |
file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
146 |
error = PTR_ERR(file); |
147 |
@@ -682,6 +687,9 @@ struct file *open_exec(const char *name) |
148 |
err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN); |
149 |
if (err) |
150 |
goto out_path_put; |
151 |
+ err = ccs_check_open_exec_permission(nd.path.dentry, nd.path.mnt); |
152 |
+ if (err) |
153 |
+ goto out_path_put; |
154 |
|
155 |
file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
156 |
if (IS_ERR(file)) |
157 |
@@ -1340,7 +1348,7 @@ int do_execve(char * filename, |
158 |
goto out; |
159 |
|
160 |
current->flags &= ~PF_KTHREAD; |
161 |
- retval = search_binary_handler(bprm,regs); |
162 |
+ retval = ccs_search_binary_handler(bprm, regs); |
163 |
if (retval >= 0) { |
164 |
/* execve success */ |
165 |
security_bprm_free(bprm); |
166 |
--- linux-2.6.28-13.45.orig/fs/fcntl.c |
167 |
+++ linux-2.6.28-13.45/fs/fcntl.c |
168 |
@@ -24,6 +24,7 @@ |
169 |
#include <asm/poll.h> |
170 |
#include <asm/siginfo.h> |
171 |
#include <asm/uaccess.h> |
172 |
+#include <linux/tomoyo.h> |
173 |
|
174 |
void set_close_on_exec(unsigned int fd, int flag) |
175 |
{ |
176 |
@@ -155,6 +156,10 @@ static int setfl(int fd, struct file * f |
177 |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
178 |
return -EPERM; |
179 |
|
180 |
+ if (((arg ^ filp->f_flags) & O_APPEND) && |
181 |
+ ccs_check_rewrite_permission(filp)) |
182 |
+ return -EPERM; |
183 |
+ |
184 |
/* O_NOATIME can only be set by the owner or superuser */ |
185 |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
186 |
if (!is_owner_or_cap(inode)) |
187 |
--- linux-2.6.28-13.45.orig/fs/ioctl.c |
188 |
+++ linux-2.6.28-13.45/fs/ioctl.c |
189 |
@@ -17,6 +17,7 @@ |
190 |
#include <linux/buffer_head.h> |
191 |
|
192 |
#include <asm/ioctls.h> |
193 |
+#include <linux/tomoyo.h> |
194 |
|
195 |
/* So that the fiemap access checks can't overflow on 32 bit machines. */ |
196 |
#define FIEMAP_MAX_EXTENTS (UINT_MAX / sizeof(struct fiemap_extent)) |
197 |
@@ -40,6 +41,8 @@ static long vfs_ioctl(struct file *filp, |
198 |
|
199 |
if (!filp->f_op) |
200 |
goto out; |
201 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
202 |
+ return -EPERM; |
203 |
|
204 |
if (filp->f_op->unlocked_ioctl) { |
205 |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
206 |
@@ -483,6 +486,8 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd, |
207 |
goto out; |
208 |
|
209 |
error = security_file_ioctl(filp, cmd, arg); |
210 |
+ if (!error) |
211 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
212 |
if (error) |
213 |
goto out_fput; |
214 |
|
215 |
--- linux-2.6.28-13.45.orig/fs/namei.c |
216 |
+++ linux-2.6.28-13.45/fs/namei.c |
217 |
@@ -35,6 +35,8 @@ |
218 |
|
219 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
220 |
|
221 |
+#include <linux/tomoyo.h> |
222 |
+ |
223 |
/* [Feb-1997 T. Schoebel-Theuer] |
224 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
225 |
* were necessary because of omirr. The reason is that omirr needs |
226 |
@@ -1550,6 +1552,11 @@ int may_open(struct nameidata *nd, int a |
227 |
if (!is_owner_or_cap(inode)) |
228 |
return -EPERM; |
229 |
|
230 |
+ /* includes O_APPEND and O_TRUNC checks */ |
231 |
+ error = ccs_check_open_permission(dentry, nd->path.mnt, flag); |
232 |
+ if (error) |
233 |
+ return error; |
234 |
+ |
235 |
/* |
236 |
* Ensure there are no outstanding leases on the file. |
237 |
*/ |
238 |
@@ -1596,6 +1603,9 @@ static int __open_namei_create(struct na |
239 |
|
240 |
if (!IS_POSIXACL(dir->d_inode)) |
241 |
mode &= ~current->fs->umask; |
242 |
+ error = ccs_check_mknod_permission(dir->d_inode, path->dentry, |
243 |
+ nd->path.mnt, mode, 0); |
244 |
+ if (!error) |
245 |
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
246 |
mutex_unlock(&dir->d_inode->i_mutex); |
247 |
dput(nd->path.dentry); |
248 |
@@ -1606,6 +1616,7 @@ static int __open_namei_create(struct na |
249 |
return may_open(nd, 0, flag & ~O_TRUNC); |
250 |
} |
251 |
|
252 |
+#include <linux/tomoyo_vfs.h> |
253 |
/* |
254 |
* Note that while the flag value (low two bits) for sys_open means: |
255 |
* 00 - read-only |
256 |
@@ -2010,6 +2021,10 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const |
257 |
error = mnt_want_write(nd.path.mnt); |
258 |
if (error) |
259 |
goto out_dput; |
260 |
+ error = ccs_check_mknod_permission(nd.path.dentry->d_inode, dentry, |
261 |
+ nd.path.mnt, mode, |
262 |
+ new_decode_dev(dev)); |
263 |
+ if (!error) |
264 |
switch (mode & S_IFMT) { |
265 |
case 0: case S_IFREG: |
266 |
error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); |
267 |
@@ -2083,6 +2098,9 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const |
268 |
error = mnt_want_write(nd.path.mnt); |
269 |
if (error) |
270 |
goto out_dput; |
271 |
+ error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry, |
272 |
+ nd.path.mnt, mode); |
273 |
+ if (!error) |
274 |
error = vfs_mkdir(nd.path.dentry->d_inode, dentry, nd.path.mnt, mode); |
275 |
mnt_drop_write(nd.path.mnt); |
276 |
out_dput: |
277 |
@@ -2194,6 +2212,9 @@ static long do_rmdir(int dfd, const char |
278 |
error = mnt_want_write(nd.path.mnt); |
279 |
if (error) |
280 |
goto exit3; |
281 |
+ error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry, |
282 |
+ nd.path.mnt); |
283 |
+ if (!error) |
284 |
error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
285 |
mnt_drop_write(nd.path.mnt); |
286 |
exit3: |
287 |
@@ -2279,6 +2300,9 @@ static long do_unlinkat(int dfd, const c |
288 |
error = mnt_want_write(nd.path.mnt); |
289 |
if (error) |
290 |
goto exit2; |
291 |
+ error = ccs_check_unlink_permission(nd.path.dentry->d_inode, |
292 |
+ dentry, nd.path.mnt); |
293 |
+ if (!error) |
294 |
error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
295 |
mnt_drop_write(nd.path.mnt); |
296 |
exit2: |
297 |
@@ -2361,6 +2385,9 @@ SYSCALL_DEFINE3(symlinkat, const char __ |
298 |
error = mnt_want_write(nd.path.mnt); |
299 |
if (error) |
300 |
goto out_dput; |
301 |
+ error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry, |
302 |
+ nd.path.mnt, from); |
303 |
+ if (!error) |
304 |
error = vfs_symlink(nd.path.dentry->d_inode, dentry, nd.path.mnt, from); |
305 |
mnt_drop_write(nd.path.mnt); |
306 |
out_dput: |
307 |
@@ -2458,6 +2485,10 @@ SYSCALL_DEFINE5(linkat, int, olddfd, con |
308 |
error = mnt_want_write(nd.path.mnt); |
309 |
if (error) |
310 |
goto out_dput; |
311 |
+ error = ccs_check_link_permission(old_path.dentry, |
312 |
+ nd.path.dentry->d_inode, new_dentry, |
313 |
+ nd.path.mnt); |
314 |
+ if (!error) |
315 |
error = vfs_link(old_path.dentry, old_path.mnt, |
316 |
nd.path.dentry->d_inode, |
317 |
new_dentry, nd.path.mnt); |
318 |
@@ -2703,6 +2734,10 @@ SYSCALL_DEFINE4(renameat, int, olddfd, c |
319 |
error = mnt_want_write(oldnd.path.mnt); |
320 |
if (error) |
321 |
goto exit5; |
322 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
323 |
+ new_dir->d_inode, new_dentry, |
324 |
+ newnd.path.mnt); |
325 |
+ if (!error) |
326 |
error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt, |
327 |
new_dir->d_inode, new_dentry, newnd.path.mnt); |
328 |
mnt_drop_write(oldnd.path.mnt); |
329 |
--- linux-2.6.28-13.45.orig/fs/namespace.c |
330 |
+++ linux-2.6.28-13.45/fs/namespace.c |
331 |
@@ -31,6 +31,8 @@ |
332 |
#include <asm/unistd.h> |
333 |
#include "pnode.h" |
334 |
#include "internal.h" |
335 |
+#include <linux/sakura.h> |
336 |
+#include <linux/tomoyo.h> |
337 |
|
338 |
#define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head)) |
339 |
#define HASH_SIZE (1UL << HASH_SHIFT) |
340 |
@@ -1041,6 +1043,9 @@ static int do_umount(struct vfsmount *mn |
341 |
if (retval) |
342 |
return retval; |
343 |
|
344 |
+ if (ccs_may_umount(mnt)) |
345 |
+ return -EPERM; |
346 |
+ |
347 |
/* |
348 |
* Allow userspace to request a mountpoint be expired rather than |
349 |
* unmounting unconditionally. Unmount only happens if: |
350 |
@@ -1132,6 +1137,8 @@ SYSCALL_DEFINE2(umount, char __user *, n |
351 |
{ |
352 |
struct path path; |
353 |
int retval; |
354 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
355 |
+ return -EPERM; |
356 |
|
357 |
retval = user_path(name, &path); |
358 |
if (retval) |
359 |
@@ -1480,6 +1487,9 @@ static int do_loopback(struct path *path |
360 |
|
361 |
if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
362 |
goto out; |
363 |
+ err = -EPERM; |
364 |
+ if (ccs_may_mount(path)) |
365 |
+ goto out; |
366 |
|
367 |
err = -ENOMEM; |
368 |
if (recurse) |
369 |
@@ -1591,6 +1601,9 @@ static int do_move_mount(struct path *pa |
370 |
if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
371 |
goto out; |
372 |
|
373 |
+ err = -EPERM; |
374 |
+ if (ccs_may_umount(old_path.mnt) || ccs_may_mount(path)) |
375 |
+ goto out; |
376 |
err = -ENOENT; |
377 |
mutex_lock(&path->dentry->d_inode->i_mutex); |
378 |
if (IS_DEADDIR(path->dentry->d_inode)) |
379 |
@@ -1694,6 +1707,9 @@ int do_add_mount(struct vfsmount *newmnt |
380 |
err = -EINVAL; |
381 |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
382 |
goto unlock; |
383 |
+ err = -EPERM; |
384 |
+ if (ccs_may_mount(path)) |
385 |
+ goto unlock; |
386 |
|
387 |
newmnt->mnt_flags = mnt_flags; |
388 |
if ((err = graft_tree(newmnt, path))) |
389 |
@@ -1917,6 +1933,13 @@ long do_mount(char *dev_name, char *dir_ |
390 |
if (data_page) |
391 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
392 |
|
393 |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
394 |
+ return -EPERM; |
395 |
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
396 |
+ &flags); |
397 |
+ if (retval) |
398 |
+ return retval; |
399 |
+ |
400 |
/* Separate the per-mountpoint flags */ |
401 |
if (flags & MS_NOSUID) |
402 |
mnt_flags |= MNT_NOSUID; |
403 |
@@ -2180,6 +2203,8 @@ SYSCALL_DEFINE2(pivot_root, const char _ |
404 |
|
405 |
if (!capable(CAP_SYS_ADMIN)) |
406 |
return -EPERM; |
407 |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
408 |
+ return -EPERM; |
409 |
|
410 |
error = user_path_dir(new_root, &new); |
411 |
if (error) |
412 |
@@ -2193,6 +2218,8 @@ SYSCALL_DEFINE2(pivot_root, const char _ |
413 |
goto out1; |
414 |
|
415 |
error = security_sb_pivotroot(&old, &new); |
416 |
+ if (!error) |
417 |
+ error = ccs_check_pivot_root_permission(&old, &new); |
418 |
if (error) { |
419 |
path_put(&old); |
420 |
goto out1; |
421 |
--- linux-2.6.28-13.45.orig/fs/open.c |
422 |
+++ linux-2.6.28-13.45/fs/open.c |
423 |
@@ -29,6 +29,8 @@ |
424 |
#include <linux/rcupdate.h> |
425 |
#include <linux/audit.h> |
426 |
#include <linux/falloc.h> |
427 |
+#include <linux/sakura.h> |
428 |
+#include <linux/tomoyo.h> |
429 |
|
430 |
#include <trace/fs.h> |
431 |
|
432 |
@@ -272,6 +274,9 @@ static long do_sys_truncate(const char _ |
433 |
if (error) |
434 |
goto put_write_and_out; |
435 |
|
436 |
+ error = ccs_check_truncate_permission(path.dentry, path.mnt, length, 0); |
437 |
+ if (error) |
438 |
+ goto put_write_and_out; |
439 |
error = locks_verify_truncate(inode, NULL, length); |
440 |
if (!error) { |
441 |
DQUOT_INIT(inode); |
442 |
@@ -328,6 +333,10 @@ static long do_sys_ftruncate(unsigned in |
443 |
if (IS_APPEND(inode)) |
444 |
goto out_putf; |
445 |
|
446 |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
447 |
+ 0); |
448 |
+ if (error) |
449 |
+ goto out_putf; |
450 |
error = locks_verify_truncate(inode, file, length); |
451 |
if (!error) |
452 |
error = do_truncate(dentry, file->f_path.mnt, length, |
453 |
@@ -594,6 +603,10 @@ SYSCALL_DEFINE1(chroot, const char __use |
454 |
error = -EPERM; |
455 |
if (!capable(CAP_SYS_CHROOT)) |
456 |
goto dput_and_out; |
457 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
458 |
+ goto dput_and_out; |
459 |
+ if (ccs_check_chroot_permission(&path)) |
460 |
+ goto dput_and_out; |
461 |
|
462 |
set_fs_root(current->fs, &path); |
463 |
error = 0; |
464 |
@@ -1165,6 +1178,8 @@ EXPORT_SYMBOL(sys_close); |
465 |
*/ |
466 |
SYSCALL_DEFINE0(vhangup) |
467 |
{ |
468 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
469 |
+ return -EPERM; |
470 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
471 |
tty_vhangup_self(); |
472 |
return 0; |
473 |
--- linux-2.6.28-13.45.orig/fs/proc/Makefile |
474 |
+++ linux-2.6.28-13.45/fs/proc/Makefile |
475 |
@@ -26,3 +26,6 @@ proc-$(CONFIG_PROC_DEVICETREE) += proc_d |
476 |
proc-$(CONFIG_PRINTK) += kmsg.o |
477 |
proc-$(CONFIG_PROC_PAGE_MONITOR) += page.o |
478 |
proc-y += version_signature.o |
479 |
+ |
480 |
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
481 |
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
482 |
--- linux-2.6.28-13.45.orig/fs/proc/version.c |
483 |
+++ linux-2.6.28-13.45/fs/proc/version.c |
484 |
@@ -32,3 +32,10 @@ static int __init proc_version_init(void |
485 |
return 0; |
486 |
} |
487 |
module_init(proc_version_init); |
488 |
+ |
489 |
+static int __init ccs_show_version(void) |
490 |
+{ |
491 |
+ printk(KERN_INFO "Hook version: 2.6.28-13.45 2009/08/05\n"); |
492 |
+ return 0; |
493 |
+} |
494 |
+module_init(ccs_show_version); |
495 |
--- linux-2.6.28-13.45.orig/include/linux/init_task.h |
496 |
+++ linux-2.6.28-13.45/include/linux/init_task.h |
497 |
@@ -180,6 +180,8 @@ extern struct group_info init_groups; |
498 |
INIT_IDS \ |
499 |
INIT_TRACE_IRQFLAGS \ |
500 |
INIT_LOCKDEP \ |
501 |
+ .ccs_domain_info = NULL, \ |
502 |
+ .ccs_flags = 0, \ |
503 |
} |
504 |
|
505 |
|
506 |
--- linux-2.6.28-13.45.orig/include/linux/sched.h |
507 |
+++ linux-2.6.28-13.45/include/linux/sched.h |
508 |
@@ -29,6 +29,8 @@ |
509 |
#define CLONE_NEWNET 0x40000000 /* New network namespace */ |
510 |
#define CLONE_IO 0x80000000 /* Clone io context */ |
511 |
|
512 |
+struct ccs_domain_info; |
513 |
+ |
514 |
/* |
515 |
* Scheduling policies |
516 |
*/ |
517 |
@@ -1355,6 +1357,8 @@ struct task_struct { |
518 |
unsigned long default_timer_slack_ns; |
519 |
|
520 |
struct list_head *scm_work_list; |
521 |
+ struct ccs_domain_info *ccs_domain_info; |
522 |
+ u32 ccs_flags; |
523 |
}; |
524 |
|
525 |
/* |
526 |
--- linux-2.6.28-13.45.orig/kernel/compat.c |
527 |
+++ linux-2.6.28-13.45/kernel/compat.c |
528 |
@@ -26,6 +26,7 @@ |
529 |
#include <linux/times.h> |
530 |
|
531 |
#include <asm/uaccess.h> |
532 |
+#include <linux/tomoyo.h> |
533 |
|
534 |
/* |
535 |
* Note that the native side is already converted to a timespec, because |
536 |
@@ -901,6 +902,8 @@ asmlinkage long compat_sys_stime(compat_ |
537 |
err = security_settime(&tv, NULL); |
538 |
if (err) |
539 |
return err; |
540 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
541 |
+ return -EPERM; |
542 |
|
543 |
do_settimeofday(&tv); |
544 |
return 0; |
545 |
--- linux-2.6.28-13.45.orig/kernel/kexec.c |
546 |
+++ linux-2.6.28-13.45/kernel/kexec.c |
547 |
@@ -37,6 +37,7 @@ |
548 |
#include <asm/io.h> |
549 |
#include <asm/system.h> |
550 |
#include <asm/sections.h> |
551 |
+#include <linux/tomoyo.h> |
552 |
|
553 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
554 |
note_buf_t* crash_notes; |
555 |
@@ -943,6 +944,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon |
556 |
/* We only trust the superuser with rebooting the system. */ |
557 |
if (!capable(CAP_SYS_BOOT)) |
558 |
return -EPERM; |
559 |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
560 |
+ return -EPERM; |
561 |
|
562 |
/* |
563 |
* Verify we have a legal set of flags |
564 |
--- linux-2.6.28-13.45.orig/kernel/kmod.c |
565 |
+++ linux-2.6.28-13.45/kernel/kmod.c |
566 |
@@ -174,6 +174,9 @@ static int ____call_usermodehelper(void |
567 |
*/ |
568 |
set_user_nice(current, 0); |
569 |
|
570 |
+ current->ccs_domain_info = NULL; |
571 |
+ current->ccs_flags = 0; |
572 |
+ |
573 |
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
574 |
|
575 |
/* Exec failed? */ |
576 |
--- linux-2.6.28-13.45.orig/kernel/module.c |
577 |
+++ linux-2.6.28-13.45/kernel/module.c |
578 |
@@ -51,6 +51,7 @@ |
579 |
#include <asm/sections.h> |
580 |
#include <linux/tracepoint.h> |
581 |
#include <linux/ftrace.h> |
582 |
+#include <linux/tomoyo.h> |
583 |
|
584 |
#if 0 |
585 |
#define DEBUGP printk |
586 |
@@ -752,6 +753,8 @@ SYSCALL_DEFINE2(delete_module, const cha |
587 |
|
588 |
if (!capable(CAP_SYS_MODULE)) |
589 |
return -EPERM; |
590 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
591 |
+ return -EPERM; |
592 |
|
593 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
594 |
return -EFAULT; |
595 |
@@ -2297,6 +2300,8 @@ SYSCALL_DEFINE3(init_module, void __user |
596 |
/* Must have permission */ |
597 |
if (!capable(CAP_SYS_MODULE)) |
598 |
return -EPERM; |
599 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
600 |
+ return -EPERM; |
601 |
|
602 |
/* Only one module load at a time, please */ |
603 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
604 |
--- linux-2.6.28-13.45.orig/kernel/ptrace.c |
605 |
+++ linux-2.6.28-13.45/kernel/ptrace.c |
606 |
@@ -24,6 +24,7 @@ |
607 |
|
608 |
#include <asm/pgtable.h> |
609 |
#include <asm/uaccess.h> |
610 |
+#include <linux/tomoyo.h> |
611 |
|
612 |
/* |
613 |
* ptrace a task: make the debugger its new parent and |
614 |
@@ -549,6 +550,8 @@ SYSCALL_DEFINE4(ptrace, long, request, l |
615 |
{ |
616 |
struct task_struct *child; |
617 |
long ret; |
618 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
619 |
+ return -EPERM; |
620 |
|
621 |
/* |
622 |
* This lock_kernel fixes a subtle race with suid exec |
623 |
@@ -672,6 +675,8 @@ asmlinkage long compat_sys_ptrace(compat |
624 |
{ |
625 |
struct task_struct *child; |
626 |
long ret; |
627 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
628 |
+ return -EPERM; |
629 |
|
630 |
/* |
631 |
* This lock_kernel fixes a subtle race with suid exec |
632 |
--- linux-2.6.28-13.45.orig/kernel/sched.c |
633 |
+++ linux-2.6.28-13.45/kernel/sched.c |
634 |
@@ -76,6 +76,7 @@ |
635 |
|
636 |
#include <asm/tlb.h> |
637 |
#include <asm/irq_regs.h> |
638 |
+#include <linux/tomoyo.h> |
639 |
|
640 |
#include "sched_cpupri.h" |
641 |
|
642 |
@@ -5028,6 +5029,8 @@ int can_nice(const struct task_struct *p |
643 |
SYSCALL_DEFINE1(nice, int, increment) |
644 |
{ |
645 |
long nice, retval; |
646 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
647 |
+ return -EPERM; |
648 |
|
649 |
/* |
650 |
* Setpriority might change our priority at the same moment. |
651 |
--- linux-2.6.28-13.45.orig/kernel/signal.c |
652 |
+++ linux-2.6.28-13.45/kernel/signal.c |
653 |
@@ -34,6 +34,7 @@ |
654 |
#include <asm/unistd.h> |
655 |
#include <asm/siginfo.h> |
656 |
#include "audit.h" /* audit_signal_info() */ |
657 |
+#include <linux/tomoyo.h> |
658 |
|
659 |
/* |
660 |
* SLAB caches for signal bits. |
661 |
@@ -2202,6 +2203,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s |
662 |
SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) |
663 |
{ |
664 |
struct siginfo info; |
665 |
+ if (ccs_kill_permission(pid, sig)) |
666 |
+ return -EPERM; |
667 |
|
668 |
info.si_signo = sig; |
669 |
info.si_errno = 0; |
670 |
@@ -2263,6 +2266,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid |
671 |
/* This is only valid for single tasks */ |
672 |
if (pid <= 0 || tgid <= 0) |
673 |
return -EINVAL; |
674 |
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
675 |
+ return -EPERM; |
676 |
|
677 |
return do_tkill(tgid, pid, sig); |
678 |
} |
679 |
@@ -2275,6 +2280,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int, |
680 |
/* This is only valid for single tasks */ |
681 |
if (pid <= 0) |
682 |
return -EINVAL; |
683 |
+ if (ccs_tkill_permission(pid, sig)) |
684 |
+ return -EPERM; |
685 |
|
686 |
return do_tkill(0, pid, sig); |
687 |
} |
688 |
--- linux-2.6.28-13.45.orig/kernel/sys.c |
689 |
+++ linux-2.6.28-13.45/kernel/sys.c |
690 |
@@ -42,6 +42,7 @@ |
691 |
#include <asm/uaccess.h> |
692 |
#include <asm/io.h> |
693 |
#include <asm/unistd.h> |
694 |
+#include <linux/tomoyo.h> |
695 |
|
696 |
#ifndef SET_UNALIGN_CTL |
697 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
698 |
@@ -146,6 +147,10 @@ SYSCALL_DEFINE3(setpriority, int, which, |
699 |
|
700 |
if (which > PRIO_USER || which < PRIO_PROCESS) |
701 |
goto out; |
702 |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
703 |
+ error = -EPERM; |
704 |
+ goto out; |
705 |
+ } |
706 |
|
707 |
/* normalize: avoid signed division (rounding problems) */ |
708 |
error = -ESRCH; |
709 |
@@ -363,6 +368,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int |
710 |
magic2 != LINUX_REBOOT_MAGIC2B && |
711 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
712 |
return -EINVAL; |
713 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
714 |
+ return -EPERM; |
715 |
|
716 |
/* Instead of trying to make the power_off code look like |
717 |
* halt when pm_power_off is not set do it the easy way. |
718 |
@@ -1337,6 +1344,8 @@ SYSCALL_DEFINE2(sethostname, char __user |
719 |
return -EPERM; |
720 |
if (len < 0 || len > __NEW_UTS_LEN) |
721 |
return -EINVAL; |
722 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
723 |
+ return -EPERM; |
724 |
down_write(&uts_sem); |
725 |
errno = -EFAULT; |
726 |
if (!copy_from_user(tmp, name, len)) { |
727 |
@@ -1386,6 +1395,8 @@ SYSCALL_DEFINE2(setdomainname, char __us |
728 |
return -EPERM; |
729 |
if (len < 0 || len > __NEW_UTS_LEN) |
730 |
return -EINVAL; |
731 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
732 |
+ return -EPERM; |
733 |
|
734 |
down_write(&uts_sem); |
735 |
errno = -EFAULT; |
736 |
--- linux-2.6.28-13.45.orig/kernel/sysctl.c |
737 |
+++ linux-2.6.28-13.45/kernel/sysctl.c |
738 |
@@ -51,6 +51,7 @@ |
739 |
|
740 |
#include <asm/uaccess.h> |
741 |
#include <asm/processor.h> |
742 |
+#include <linux/tomoyo.h> |
743 |
|
744 |
#ifdef CONFIG_X86 |
745 |
#include <asm/nmi.h> |
746 |
@@ -1639,6 +1640,9 @@ int do_sysctl(int __user *name, int nlen |
747 |
|
748 |
for (head = sysctl_head_next(NULL); head; |
749 |
head = sysctl_head_next(head)) { |
750 |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
751 |
+ head->ctl_table); |
752 |
+ if (!error) |
753 |
error = parse_table(name, nlen, oldval, oldlenp, |
754 |
newval, newlen, |
755 |
head->root, head->ctl_table); |
756 |
--- linux-2.6.28-13.45.orig/kernel/time.c |
757 |
+++ linux-2.6.28-13.45/kernel/time.c |
758 |
@@ -40,6 +40,7 @@ |
759 |
|
760 |
#include <asm/uaccess.h> |
761 |
#include <asm/unistd.h> |
762 |
+#include <linux/tomoyo.h> |
763 |
|
764 |
#include "timeconst.h" |
765 |
|
766 |
@@ -90,6 +91,8 @@ SYSCALL_DEFINE1(stime, time_t __user *, |
767 |
err = security_settime(&tv, NULL); |
768 |
if (err) |
769 |
return err; |
770 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
771 |
+ return -EPERM; |
772 |
|
773 |
do_settimeofday(&tv); |
774 |
return 0; |
775 |
@@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec |
776 |
error = security_settime(tv, tz); |
777 |
if (error) |
778 |
return error; |
779 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
780 |
+ return -EPERM; |
781 |
|
782 |
if (tz) { |
783 |
/* SMP safe, global irq locking makes it work. */ |
784 |
--- linux-2.6.28-13.45.orig/kernel/time/ntp.c |
785 |
+++ linux-2.6.28-13.45/kernel/time/ntp.c |
786 |
@@ -18,6 +18,7 @@ |
787 |
#include <linux/clocksource.h> |
788 |
#include <linux/workqueue.h> |
789 |
#include <asm/timex.h> |
790 |
+#include <linux/tomoyo.h> |
791 |
|
792 |
/* |
793 |
* Timekeeping variables |
794 |
@@ -286,10 +287,15 @@ int do_adjtimex(struct timex *txc) |
795 |
if (!(txc->modes & ADJ_OFFSET_READONLY) && |
796 |
!capable(CAP_SYS_TIME)) |
797 |
return -EPERM; |
798 |
+ if (!(txc->modes & ADJ_OFFSET_READONLY) && |
799 |
+ !ccs_capable(CCS_SYS_SETTIME)) |
800 |
+ return -EPERM; |
801 |
} else { |
802 |
/* In order to modify anything, you gotta be super-user! */ |
803 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
804 |
return -EPERM; |
805 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
806 |
+ return -EPERM; |
807 |
|
808 |
/* if the quartz is off by more than 10% something is VERY wrong! */ |
809 |
if (txc->modes & ADJ_TICK && |
810 |
--- linux-2.6.28-13.45.orig/net/ipv4/inet_connection_sock.c |
811 |
+++ linux-2.6.28-13.45/net/ipv4/inet_connection_sock.c |
812 |
@@ -23,6 +23,7 @@ |
813 |
#include <net/route.h> |
814 |
#include <net/tcp_states.h> |
815 |
#include <net/xfrm.h> |
816 |
+#include <linux/sakura.h> |
817 |
|
818 |
#ifdef INET_CSK_DEBUG |
819 |
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
820 |
@@ -108,6 +109,8 @@ int inet_csk_get_port(struct sock *sk, u |
821 |
head = &hashinfo->bhash[inet_bhashfn(net, rover, |
822 |
hashinfo->bhash_size)]; |
823 |
spin_lock(&head->lock); |
824 |
+ if (ccs_lport_reserved(rover)) |
825 |
+ goto next; |
826 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
827 |
if (tb->ib_net == net && tb->port == rover) |
828 |
goto next; |
829 |
--- linux-2.6.28-13.45.orig/net/ipv4/inet_hashtables.c |
830 |
+++ linux-2.6.28-13.45/net/ipv4/inet_hashtables.c |
831 |
@@ -22,6 +22,7 @@ |
832 |
#include <net/inet_connection_sock.h> |
833 |
#include <net/inet_hashtables.h> |
834 |
#include <net/ip.h> |
835 |
+#include <linux/sakura.h> |
836 |
|
837 |
/* |
838 |
* Allocate and initialize a new local port bind bucket. |
839 |
@@ -440,6 +441,8 @@ int __inet_hash_connect(struct inet_time |
840 |
local_bh_disable(); |
841 |
for (i = 1; i <= remaining; i++) { |
842 |
port = low + (i + offset) % remaining; |
843 |
+ if (ccs_lport_reserved(port)) |
844 |
+ continue; |
845 |
head = &hinfo->bhash[inet_bhashfn(net, port, |
846 |
hinfo->bhash_size)]; |
847 |
spin_lock(&head->lock); |
848 |
--- linux-2.6.28-13.45.orig/net/ipv4/raw.c |
849 |
+++ linux-2.6.28-13.45/net/ipv4/raw.c |
850 |
@@ -77,6 +77,7 @@ |
851 |
#include <linux/seq_file.h> |
852 |
#include <linux/netfilter.h> |
853 |
#include <linux/netfilter_ipv4.h> |
854 |
+#include <linux/tomoyo_socket.h> |
855 |
|
856 |
static struct raw_hashinfo raw_v4_hashinfo = { |
857 |
.lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock), |
858 |
@@ -665,6 +666,9 @@ static int raw_recvmsg(struct kiocb *ioc |
859 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
860 |
if (!skb) |
861 |
goto out; |
862 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
863 |
+ if (err) |
864 |
+ goto out; |
865 |
|
866 |
copied = skb->len; |
867 |
if (len < copied) { |
868 |
--- linux-2.6.28-13.45.orig/net/ipv4/udp.c |
869 |
+++ linux-2.6.28-13.45/net/ipv4/udp.c |
870 |
@@ -103,6 +103,8 @@ |
871 |
#include <net/checksum.h> |
872 |
#include <net/xfrm.h> |
873 |
#include "udp_impl.h" |
874 |
+#include <linux/sakura.h> |
875 |
+#include <linux/tomoyo_socket.h> |
876 |
|
877 |
/* |
878 |
* Snmp MIB for the UDP layer |
879 |
@@ -172,7 +174,9 @@ int udp_lib_get_port(struct sock *sk, un |
880 |
snum = first = rand % remaining + low; |
881 |
rand |= 1; |
882 |
while (udp_lib_lport_inuse(net, snum, udptable, sk, |
883 |
- saddr_comp)) { |
884 |
+ saddr_comp) |
885 |
+ || ccs_lport_reserved(snum) |
886 |
+ ) { |
887 |
do { |
888 |
snum = snum + rand; |
889 |
} while (snum < low || snum > high); |
890 |
@@ -841,6 +845,9 @@ try_again: |
891 |
&peeked, &err); |
892 |
if (!skb) |
893 |
goto out; |
894 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
895 |
+ if (err) |
896 |
+ goto out; |
897 |
|
898 |
ulen = skb->len - sizeof(struct udphdr); |
899 |
copied = len; |
900 |
--- linux-2.6.28-13.45.orig/net/ipv6/raw.c |
901 |
+++ linux-2.6.28-13.45/net/ipv6/raw.c |
902 |
@@ -59,6 +59,7 @@ |
903 |
|
904 |
#include <linux/proc_fs.h> |
905 |
#include <linux/seq_file.h> |
906 |
+#include <linux/tomoyo_socket.h> |
907 |
|
908 |
static struct raw_hashinfo raw_v6_hashinfo = { |
909 |
.lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock), |
910 |
@@ -465,6 +466,9 @@ static int rawv6_recvmsg(struct kiocb *i |
911 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
912 |
if (!skb) |
913 |
goto out; |
914 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
915 |
+ if (err) |
916 |
+ goto out; |
917 |
|
918 |
copied = skb->len; |
919 |
if (copied > len) { |
920 |
--- linux-2.6.28-13.45.orig/net/ipv6/udp.c |
921 |
+++ linux-2.6.28-13.45/net/ipv6/udp.c |
922 |
@@ -48,6 +48,7 @@ |
923 |
#include <linux/proc_fs.h> |
924 |
#include <linux/seq_file.h> |
925 |
#include "udp_impl.h" |
926 |
+#include <linux/tomoyo_socket.h> |
927 |
|
928 |
int udp_v6_get_port(struct sock *sk, unsigned short snum) |
929 |
{ |
930 |
@@ -151,6 +152,9 @@ try_again: |
931 |
&peeked, &err); |
932 |
if (!skb) |
933 |
goto out; |
934 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
935 |
+ if (err) |
936 |
+ goto out; |
937 |
|
938 |
ulen = skb->len - sizeof(struct udphdr); |
939 |
copied = len; |
940 |
--- linux-2.6.28-13.45.orig/net/socket.c |
941 |
+++ linux-2.6.28-13.45/net/socket.c |
942 |
@@ -97,6 +97,9 @@ |
943 |
#include <net/sock.h> |
944 |
#include <linux/netfilter.h> |
945 |
|
946 |
+#include <linux/tomoyo.h> |
947 |
+#include <linux/tomoyo_socket.h> |
948 |
+ |
949 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
950 |
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, |
951 |
unsigned long nr_segs, loff_t pos); |
952 |
@@ -558,6 +561,10 @@ static inline int __sock_sendmsg(struct |
953 |
si->size = size; |
954 |
|
955 |
err = security_socket_sendmsg(sock, msg, size); |
956 |
+ if (!err) |
957 |
+ err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *) |
958 |
+ msg->msg_name, |
959 |
+ msg->msg_namelen); |
960 |
if (err) |
961 |
return err; |
962 |
|
963 |
@@ -1123,6 +1130,8 @@ static int __sock_create(struct net *net |
964 |
} |
965 |
|
966 |
err = security_socket_create(family, type, protocol, kern); |
967 |
+ if (!err) |
968 |
+ err = ccs_socket_create_permission(family, type, protocol); |
969 |
if (err) |
970 |
return err; |
971 |
|
972 |
@@ -1378,6 +1387,11 @@ SYSCALL_DEFINE3(bind, int, fd, struct so |
973 |
(struct sockaddr *)&address, |
974 |
addrlen); |
975 |
if (!err) |
976 |
+ err = ccs_socket_bind_permission(sock, |
977 |
+ (struct sockaddr *) |
978 |
+ &address, |
979 |
+ addrlen); |
980 |
+ if (!err) |
981 |
err = sock->ops->bind(sock, |
982 |
(struct sockaddr *) |
983 |
&address, addrlen); |
984 |
@@ -1407,6 +1421,8 @@ SYSCALL_DEFINE2(listen, int, fd, int, ba |
985 |
|
986 |
err = security_socket_listen(sock, backlog); |
987 |
if (!err) |
988 |
+ err = ccs_socket_listen_permission(sock); |
989 |
+ if (!err) |
990 |
err = sock->ops->listen(sock, backlog); |
991 |
|
992 |
fput_light(sock->file, fput_needed); |
993 |
@@ -1476,6 +1492,11 @@ SYSCALL_DEFINE4(accept4, int, fd, struct |
994 |
if (err < 0) |
995 |
goto out_fd; |
996 |
|
997 |
+ if (ccs_socket_accept_permission(newsock, |
998 |
+ (struct sockaddr *) &address)) { |
999 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1000 |
+ goto out_fd; |
1001 |
+ } |
1002 |
if (upeer_sockaddr) { |
1003 |
if (newsock->ops->getname(newsock, (struct sockaddr *)&address, |
1004 |
&len, 2) < 0) { |
1005 |
@@ -1544,6 +1565,9 @@ SYSCALL_DEFINE3(connect, int, fd, struct |
1006 |
|
1007 |
err = |
1008 |
security_socket_connect(sock, (struct sockaddr *)&address, addrlen); |
1009 |
+ if (!err) |
1010 |
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) |
1011 |
+ &address, addrlen); |
1012 |
if (err) |
1013 |
goto out_put; |
1014 |
|
1015 |
--- linux-2.6.28-13.45.orig/net/unix/af_unix.c |
1016 |
+++ linux-2.6.28-13.45/net/unix/af_unix.c |
1017 |
@@ -114,6 +114,7 @@ |
1018 |
#include <linux/mount.h> |
1019 |
#include <net/checksum.h> |
1020 |
#include <linux/security.h> |
1021 |
+#include <linux/tomoyo.h> |
1022 |
|
1023 |
static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; |
1024 |
static DEFINE_SPINLOCK(unix_table_lock); |
1025 |
@@ -829,6 +830,9 @@ static int unix_bind(struct socket *sock |
1026 |
err = mnt_want_write(nd.path.mnt); |
1027 |
if (err) |
1028 |
goto out_mknod_dput; |
1029 |
+ err = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
1030 |
+ dentry, nd.path.mnt, mode, 0); |
1031 |
+ if (!err) |
1032 |
err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt, |
1033 |
mode, 0); |
1034 |
mnt_drop_write(nd.path.mnt); |