オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2805 - (show annotations) (download) (as text)
Mon Jul 27 02:00:55 2009 UTC (14 years, 10 months ago) by kumaneko
Original Path: trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff
File MIME type: text/x-diff
File size: 38185 byte(s)


1 This is TOMOYO Linux patch for VineLinux 4.2.
2
3 Source code for this patch is http://updates.vinelinux.org/Vine-4.2/updates/SRPMS/kernel-2.6.16-76.49vl4.src.rpm
4 ---
5 arch/alpha/kernel/ptrace.c | 3 +++
6 arch/ia64/ia32/sys_ia32.c | 3 +++
7 arch/ia64/kernel/ptrace.c | 3 +++
8 arch/m32r/kernel/ptrace.c | 3 +++
9 arch/mips/kernel/ptrace32.c | 3 +++
10 arch/powerpc/kernel/ptrace32.c | 3 +++
11 arch/s390/kernel/ptrace.c | 3 +++
12 arch/sparc/kernel/ptrace.c | 5 +++++
13 arch/sparc64/kernel/ptrace.c | 5 +++++
14 arch/x86_64/ia32/ptrace32.c | 3 +++
15 fs/Kconfig | 2 ++
16 fs/Makefile | 2 ++
17 fs/attr.c | 5 +++++
18 fs/compat.c | 9 ++++++++-
19 fs/exec.c | 12 +++++++++++-
20 fs/fcntl.c | 5 +++++
21 fs/ioctl.c | 5 +++++
22 fs/namei.c | 38 ++++++++++++++++++++++++++++++++++++++
23 fs/namespace.c | 28 +++++++++++++++++++++++++++-
24 fs/open.c | 16 +++++++++++++++-
25 fs/proc/Makefile | 3 +++
26 fs/proc/proc_misc.c | 1 +
27 include/linux/init_task.h | 2 ++
28 include/linux/sched.h | 4 ++++
29 kernel/compat.c | 3 +++
30 kernel/kexec.c | 3 +++
31 kernel/kmod.c | 3 +++
32 kernel/module.c | 7 +++++--
33 kernel/ptrace.c | 3 +++
34 kernel/sched.c | 3 +++
35 kernel/signal.c | 13 +++++++++++++
36 kernel/sys.c | 11 +++++++++++
37 kernel/sysctl.c | 11 +++++++++++
38 kernel/time.c | 7 +++++++
39 net/ipv4/inet_connection_sock.c | 3 +++
40 net/ipv4/inet_hashtables.c | 3 +++
41 net/ipv4/raw.c | 4 ++++
42 net/ipv4/udp.c | 11 ++++++++++-
43 net/ipv6/inet6_hashtables.c | 5 ++++-
44 net/ipv6/raw.c | 4 ++++
45 net/ipv6/udp.c | 9 +++++++++
46 net/socket.c | 26 +++++++++++++++++++++++---
47 net/unix/af_unix.c | 4 ++++
48 43 files changed, 288 insertions(+), 11 deletions(-)
49
50 --- linux-2.6.16-76.49vl4.orig/arch/alpha/kernel/ptrace.c
51 +++ linux-2.6.16-76.49vl4/arch/alpha/kernel/ptrace.c
52 @@ -20,6 +20,7 @@
53 #include <asm/pgtable.h>
54 #include <asm/system.h>
55 #include <asm/fpu.h>
56 +#include <linux/tomoyo.h>
57
58 #include "proto.h"
59
60 @@ -268,6 +269,8 @@ do_sys_ptrace(long request, long pid, lo
61 unsigned long tmp;
62 size_t copied;
63 long ret;
64 + if (!ccs_capable(CCS_SYS_PTRACE))
65 + return -EPERM;
66
67 lock_kernel();
68 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
69 --- linux-2.6.16-76.49vl4.orig/arch/ia64/ia32/sys_ia32.c
70 +++ linux-2.6.16-76.49vl4/arch/ia64/ia32/sys_ia32.c
71 @@ -58,6 +58,7 @@
72 #include <asm/types.h>
73 #include <asm/uaccess.h>
74 #include <asm/unistd.h>
75 +#include <linux/tomoyo.h>
76
77 #include "ia32priv.h"
78
79 @@ -1755,6 +1756,8 @@ sys32_ptrace (int request, pid_t pid, un
80 struct task_struct *child;
81 unsigned int value, tmp;
82 long i, ret;
83 + if (!ccs_capable(CCS_SYS_PTRACE))
84 + return -EPERM;
85
86 lock_kernel();
87 if (request == PTRACE_TRACEME) {
88 --- linux-2.6.16-76.49vl4.orig/arch/ia64/kernel/ptrace.c
89 +++ linux-2.6.16-76.49vl4/arch/ia64/kernel/ptrace.c
90 @@ -29,6 +29,7 @@
91 #ifdef CONFIG_PERFMON
92 #include <asm/perfmon.h>
93 #endif
94 +#include <linux/tomoyo.h>
95
96 #include "entry.h"
97
98 @@ -1418,6 +1419,8 @@ sys_ptrace (long request, pid_t pid, uns
99 struct task_struct *child;
100 struct switch_stack *sw;
101 long ret;
102 + if (!ccs_capable(CCS_SYS_PTRACE))
103 + return -EPERM;
104
105 lock_kernel();
106 ret = -EPERM;
107 --- linux-2.6.16-76.49vl4.orig/arch/m32r/kernel/ptrace.c
108 +++ linux-2.6.16-76.49vl4/arch/m32r/kernel/ptrace.c
109 @@ -33,6 +33,7 @@
110 #include <asm/system.h>
111 #include <asm/processor.h>
112 #include <asm/mmu_context.h>
113 +#include <linux/tomoyo.h>
114
115 /*
116 * This routine will get a word off of the process kernel stack.
117 @@ -743,6 +744,8 @@ asmlinkage long sys_ptrace(long request,
118 {
119 struct task_struct *child;
120 int ret;
121 + if (!ccs_capable(CCS_SYS_PTRACE))
122 + return -EPERM;
123
124 lock_kernel();
125 if (request == PTRACE_TRACEME) {
126 --- linux-2.6.16-76.49vl4.orig/arch/mips/kernel/ptrace32.c
127 +++ linux-2.6.16-76.49vl4/arch/mips/kernel/ptrace32.c
128 @@ -35,6 +35,7 @@
129 #include <asm/system.h>
130 #include <asm/uaccess.h>
131 #include <asm/bootinfo.h>
132 +#include <linux/tomoyo.h>
133
134 int ptrace_getregs (struct task_struct *child, __s64 __user *data);
135 int ptrace_setregs (struct task_struct *child, __s64 __user *data);
136 @@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request,
137 {
138 struct task_struct *child;
139 int ret;
140 + if (!ccs_capable(CCS_SYS_PTRACE))
141 + return -EPERM;
142
143 #if 0
144 printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
145 --- linux-2.6.16-76.49vl4.orig/arch/powerpc/kernel/ptrace32.c
146 +++ linux-2.6.16-76.49vl4/arch/powerpc/kernel/ptrace32.c
147 @@ -33,6 +33,7 @@
148 #include <asm/page.h>
149 #include <asm/pgtable.h>
150 #include <asm/system.h>
151 +#include <linux/tomoyo.h>
152
153 #include "ptrace-common.h"
154
155 @@ -46,6 +47,8 @@ long compat_sys_ptrace(int request, int
156 {
157 struct task_struct *child;
158 int ret;
159 + if (!ccs_capable(CCS_SYS_PTRACE))
160 + return -EPERM;
161
162 lock_kernel();
163 if (request == PTRACE_TRACEME) {
164 --- linux-2.6.16-76.49vl4.orig/arch/s390/kernel/ptrace.c
165 +++ linux-2.6.16-76.49vl4/arch/s390/kernel/ptrace.c
166 @@ -41,6 +41,7 @@
167 #include <asm/system.h>
168 #include <asm/uaccess.h>
169 #include <asm/unistd.h>
170 +#include <linux/tomoyo.h>
171
172 #ifdef CONFIG_COMPAT
173 #include "compat_ptrace.h"
174 @@ -711,6 +712,8 @@ sys_ptrace(long request, long pid, long
175 struct task_struct *child;
176 int ret;
177
178 + if (!ccs_capable(CCS_SYS_PTRACE))
179 + return -EPERM;
180 lock_kernel();
181 if (request == PTRACE_TRACEME) {
182 ret = ptrace_traceme();
183 --- linux-2.6.16-76.49vl4.orig/arch/sparc/kernel/ptrace.c
184 +++ linux-2.6.16-76.49vl4/arch/sparc/kernel/ptrace.c
185 @@ -23,6 +23,7 @@
186 #include <asm/pgtable.h>
187 #include <asm/system.h>
188 #include <asm/uaccess.h>
189 +#include <linux/tomoyo.h>
190
191 #define MAGIC_CONSTANT 0x80000000
192
193 @@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs
194 unsigned long addr2 = regs->u_regs[UREG_I4];
195 struct task_struct *child;
196 int ret;
197 + if (!ccs_capable(CCS_SYS_PTRACE)) {
198 + pt_error_return(regs, EPERM);
199 + return;
200 + }
201
202 lock_kernel();
203 #ifdef DEBUG_PTRACE
204 --- linux-2.6.16-76.49vl4.orig/arch/sparc64/kernel/ptrace.c
205 +++ linux-2.6.16-76.49vl4/arch/sparc64/kernel/ptrace.c
206 @@ -32,6 +32,7 @@
207 #include <asm/spitfire.h>
208 #include <asm/page.h>
209 #include <asm/cpudata.h>
210 +#include <linux/tomoyo.h>
211
212 /* Returning from ptrace is a bit tricky because the syscall return
213 * low level code assumes any value returned which is negative and
214 @@ -173,6 +174,10 @@ asmlinkage void do_ptrace(struct pt_regs
215 unsigned long addr2 = regs->u_regs[UREG_I4];
216 struct task_struct *child;
217 int ret;
218 + if (!ccs_capable(CCS_SYS_PTRACE)) {
219 + pt_error_return(regs, EPERM);
220 + return;
221 + }
222
223 if (test_thread_flag(TIF_32BIT)) {
224 addr &= 0xffffffffUL;
225 --- linux-2.6.16-76.49vl4.orig/arch/x86_64/ia32/ptrace32.c
226 +++ linux-2.6.16-76.49vl4/arch/x86_64/ia32/ptrace32.c
227 @@ -27,6 +27,7 @@
228 #include <asm/debugreg.h>
229 #include <asm/i387.h>
230 #include <asm/fpu32.h>
231 +#include <linux/tomoyo.h>
232
233 /*
234 * Determines which flags the user has access to [1 = access, 0 = no access].
235 @@ -206,6 +207,8 @@ asmlinkage long sys32_ptrace(long reques
236 void __user *datap = compat_ptr(data);
237 int ret;
238 __u32 val;
239 + if (!ccs_capable(CCS_SYS_PTRACE))
240 + return -EPERM;
241
242 switch (request) {
243 default:
244 --- linux-2.6.16-76.49vl4.orig/fs/Kconfig
245 +++ linux-2.6.16-76.49vl4/fs/Kconfig
246 @@ -1906,5 +1906,7 @@ endmenu
247
248 source "fs/nls/Kconfig"
249
250 +source "fs/Kconfig.ccs"
251 +
252 endmenu
253
254 --- linux-2.6.16-76.49vl4.orig/fs/Makefile
255 +++ linux-2.6.16-76.49vl4/fs/Makefile
256 @@ -106,3 +106,5 @@ obj-$(CONFIG_CONFIGFS_FS) += configfs/
257 obj-$(CONFIG_OCFS2_FS) += ocfs2/
258 obj-$(CONFIG_SUPERMOUNT) += supermount/
259 obj-$(CONFIG_UNION_FS) += unionfs/
260 +
261 +include $(srctree)/fs/Makefile-2.6.ccs
262 --- linux-2.6.16-76.49vl4.orig/fs/attr.c
263 +++ linux-2.6.16-76.49vl4/fs/attr.c
264 @@ -15,6 +15,7 @@
265 #include <linux/fcntl.h>
266 #include <linux/quotaops.h>
267 #include <linux/security.h>
268 +#include <linux/tomoyo.h>
269
270 /* Taken over from the old code... */
271
272 @@ -146,11 +147,15 @@ int notify_change(struct dentry * dentry
273 if (inode->i_op && inode->i_op->setattr) {
274 error = security_inode_setattr(dentry, attr);
275 if (!error)
276 + error = ccs_check_setattr_permission(dentry, attr);
277 + if (!error)
278 error = inode->i_op->setattr(dentry, attr);
279 } else {
280 error = inode_change_ok(inode, attr);
281 if (!error)
282 error = security_inode_setattr(dentry, attr);
283 + if (!error)
284 + error = ccs_check_setattr_permission(dentry, attr);
285 if (!error) {
286 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
287 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
288 --- linux-2.6.16-76.49vl4.orig/fs/compat.c
289 +++ linux-2.6.16-76.49vl4/fs/compat.c
290 @@ -52,6 +52,7 @@
291 #include <asm/uaccess.h>
292 #include <asm/mmu_context.h>
293 #include <asm/ioctls.h>
294 +#include <linux/tomoyo.h>
295
296 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
297
298 @@ -381,6 +382,8 @@ asmlinkage long compat_sys_ioctl(unsigne
299
300 /* RED-PEN how should LSM module know it's handling 32bit? */
301 error = security_file_ioctl(filp, cmd, arg);
302 + if (!error)
303 + error = ccs_check_ioctl_permission(filp, cmd, arg);
304 if (error)
305 goto out_fput;
306
307 @@ -405,6 +408,10 @@ asmlinkage long compat_sys_ioctl(unsigne
308 /*FALL THROUGH*/
309
310 default:
311 + if (!ccs_capable(CCS_SYS_IOCTL)) {
312 + error = -EPERM;
313 + goto out_fput;
314 + }
315 if (filp->f_op && filp->f_op->compat_ioctl) {
316 error = filp->f_op->compat_ioctl(filp, cmd, arg);
317 if (error != -ENOIOCTLCMD)
318 @@ -1532,7 +1539,7 @@ int compat_do_execve(char * filename,
319 if (retval < 0)
320 goto out;
321
322 - retval = search_binary_handler(bprm, regs);
323 + retval = ccs_search_binary_handler(bprm, regs);
324 if (retval >= 0) {
325 free_arg_pages(bprm);
326
327 --- linux-2.6.16-76.49vl4.orig/fs/exec.c
328 +++ linux-2.6.16-76.49vl4/fs/exec.c
329 @@ -57,6 +57,8 @@
330 #include <linux/kmod.h>
331 #endif
332
333 +#include <linux/tomoyo.h>
334 +
335 int core_uses_pid;
336 char core_pattern[65] = "core";
337 int suid_dumpable = 0;
338 @@ -139,6 +141,10 @@ asmlinkage long sys_uselib(const char __
339 if (error)
340 goto exit;
341
342 + error = ccs_check_uselib_permission(nd.dentry, nd.mnt);
343 + if (error)
344 + goto exit;
345 +
346 file = nameidata_to_filp(&nd, O_RDONLY);
347 error = PTR_ERR(file);
348 if (IS_ERR(file))
349 @@ -488,6 +494,9 @@ struct file *open_exec(const char *name)
350 int err = vfs_permission(&nd, MAY_EXEC);
351 if (!err && !(inode->i_mode & 0111))
352 err = -EACCES;
353 + if (!err)
354 + err = ccs_check_open_exec_permission(nd.dentry,
355 + nd.mnt);
356 file = ERR_PTR(err);
357 if (!err) {
358 file = nameidata_to_filp(&nd, O_RDONLY);
359 @@ -1201,7 +1210,8 @@ int do_execve(char * filename,
360 if (retval < 0)
361 goto out;
362
363 - retval = search_binary_handler(bprm,regs);
364 + retval = ccs_search_binary_handler(bprm, regs);
365 +
366 if (retval >= 0) {
367 free_arg_pages(bprm);
368
369 --- linux-2.6.16-76.49vl4.orig/fs/fcntl.c
370 +++ linux-2.6.16-76.49vl4/fs/fcntl.c
371 @@ -22,6 +22,7 @@
372 #include <asm/poll.h>
373 #include <asm/siginfo.h>
374 #include <asm/uaccess.h>
375 +#include <linux/tomoyo.h>
376
377 void fastcall set_close_on_exec(unsigned int fd, int flag)
378 {
379 @@ -215,6 +216,10 @@ static int setfl(int fd, struct file * f
380 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
381 return -EPERM;
382
383 + if (((arg ^ filp->f_flags) & O_APPEND) &&
384 + ccs_check_rewrite_permission(filp))
385 + return -EPERM;
386 +
387 /* O_NOATIME can only be set by the owner or superuser */
388 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
389 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
390 --- linux-2.6.16-76.49vl4.orig/fs/ioctl.c
391 +++ linux-2.6.16-76.49vl4/fs/ioctl.c
392 @@ -16,6 +16,7 @@
393
394 #include <asm/uaccess.h>
395 #include <asm/ioctls.h>
396 +#include <linux/tomoyo.h>
397
398 static long do_ioctl(struct file *filp, unsigned int cmd,
399 unsigned long arg)
400 @@ -24,6 +25,8 @@ static long do_ioctl(struct file *filp,
401
402 if (!filp->f_op)
403 goto out;
404 + if (!ccs_capable(CCS_SYS_IOCTL))
405 + return -EPERM;
406
407 if (filp->f_op->unlocked_ioctl) {
408 error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
409 @@ -168,6 +171,8 @@ asmlinkage long sys_ioctl(unsigned int f
410 goto out;
411
412 error = security_file_ioctl(filp, cmd, arg);
413 + if (!error)
414 + error = ccs_check_ioctl_permission(filp, cmd, arg);
415 if (error)
416 goto out_fput;
417
418 --- linux-2.6.16-76.49vl4.orig/fs/namei.c
419 +++ linux-2.6.16-76.49vl4/fs/namei.c
420 @@ -37,6 +37,8 @@
421
422 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
423
424 +#include <linux/tomoyo.h>
425 +
426 /* [Feb-1997 T. Schoebel-Theuer]
427 * Fundamental changes in the pathname lookup mechanisms (namei)
428 * were necessary because of omirr. The reason is that omirr needs
429 @@ -1539,6 +1541,11 @@ int may_open(struct nameidata *nd, int a
430 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
431 return -EPERM;
432
433 + /* includes O_APPEND and O_TRUNC checks */
434 + error = ccs_check_open_permission(dentry, nd->mnt, flag);
435 + if (error)
436 + return error;
437 +
438 /*
439 * Ensure there are no outstanding leases on the file.
440 */
441 @@ -1570,6 +1577,7 @@ int may_open(struct nameidata *nd, int a
442 return 0;
443 }
444
445 +#include <linux/tomoyo_vfs.h>
446 /*
447 * open_namei()
448 *
449 @@ -1653,6 +1661,9 @@ do_last:
450 if (!path.dentry->d_inode) {
451 if (!IS_POSIXACL(dir->d_inode))
452 mode &= ~current->fs->umask;
453 + error = ccs_check_mknod_permission(dir->d_inode, path.dentry,
454 + nd->mnt, mode, 0);
455 + if (!error)
456 error = vfs_create(dir->d_inode, path.dentry, mode, nd);
457 mutex_unlock(&dir->d_inode->i_mutex);
458 dput(nd->dentry);
459 @@ -1847,6 +1858,10 @@ asmlinkage long sys_mknodat(int dfd, con
460 if (!IS_POSIXACL(nd.dentry->d_inode))
461 mode &= ~current->fs->umask;
462 if (!IS_ERR(dentry)) {
463 + error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
464 + nd.mnt, mode,
465 + new_decode_dev(dev));
466 + if (!error)
467 switch (mode & S_IFMT) {
468 case 0: case S_IFREG:
469 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
470 @@ -1920,6 +1935,10 @@ asmlinkage long sys_mkdirat(int dfd, con
471 if (!IS_ERR(dentry)) {
472 if (!IS_POSIXACL(nd.dentry->d_inode))
473 mode &= ~current->fs->umask;
474 + error = ccs_check_mkdir_permission(nd.dentry->d_inode,
475 + dentry, nd.mnt,
476 + mode);
477 + if (!error)
478 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
479 dput(dentry);
480 }
481 @@ -2028,6 +2047,9 @@ static long do_rmdir(int dfd, const char
482 dentry = lookup_hash(&nd);
483 error = PTR_ERR(dentry);
484 if (!IS_ERR(dentry)) {
485 + error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,
486 + nd.mnt);
487 + if (!error)
488 error = vfs_rmdir(nd.dentry->d_inode, dentry);
489 dput(dentry);
490 }
491 @@ -2108,6 +2130,9 @@ static long do_unlinkat(int dfd, const c
492 inode = dentry->d_inode;
493 if (inode)
494 atomic_inc(&inode->i_count);
495 + error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,
496 + nd.mnt);
497 + if (!error)
498 error = vfs_unlink(nd.dentry->d_inode, dentry);
499 exit2:
500 dput(dentry);
501 @@ -2186,6 +2211,10 @@ asmlinkage long sys_symlinkat(const char
502 dentry = lookup_create(&nd, 0);
503 error = PTR_ERR(dentry);
504 if (!IS_ERR(dentry)) {
505 + error = ccs_check_symlink_permission(nd.dentry->d_inode,
506 + dentry, nd.mnt,
507 + from);
508 + if (!error)
509 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
510 dput(dentry);
511 }
512 @@ -2278,6 +2307,10 @@ asmlinkage long sys_linkat(int olddfd, c
513 new_dentry = lookup_create(&nd, 0);
514 error = PTR_ERR(new_dentry);
515 if (!IS_ERR(new_dentry)) {
516 + error = ccs_check_link_permission(old_nd.dentry,
517 + nd.dentry->d_inode,
518 + new_dentry, nd.mnt);
519 + if (!error)
520 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
521 dput(new_dentry);
522 }
523 @@ -2504,6 +2537,11 @@ static int do_rename(int olddfd, const c
524 if (new_dentry == trap)
525 goto exit5;
526
527 + error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,
528 + new_dir->d_inode, new_dentry,
529 + newnd.mnt);
530 + if (!error)
531 +
532 error = vfs_rename(old_dir->d_inode, old_dentry,
533 new_dir->d_inode, new_dentry);
534 exit5:
535 --- linux-2.6.16-76.49vl4.orig/fs/namespace.c
536 +++ linux-2.6.16-76.49vl4/fs/namespace.c
537 @@ -26,6 +26,8 @@
538 #include <asm/uaccess.h>
539 #include <asm/unistd.h>
540 #include "pnode.h"
541 +#include <linux/sakura.h>
542 +#include <linux/tomoyo.h>
543
544 extern int __init init_rootfs(void);
545
546 @@ -509,6 +511,9 @@ static int do_umount(struct vfsmount *mn
547 if (retval)
548 return retval;
549
550 + if (ccs_may_umount(mnt))
551 + return -EPERM;
552 +
553 /*
554 * Allow userspace to request a mountpoint be expired rather than
555 * unmounting unconditionally. Unmount only happens if:
556 @@ -597,6 +602,8 @@ asmlinkage long sys_umount(char __user *
557 {
558 struct nameidata nd;
559 int retval;
560 + if (!ccs_capable(CCS_SYS_UMOUNT))
561 + return -EPERM;
562
563 retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
564 if (retval)
565 @@ -884,6 +891,9 @@ static int do_loopback(struct nameidata
566
567 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
568 goto out;
569 + err = -EPERM;
570 + if (ccs_may_mount(nd))
571 + goto out;
572
573 err = -ENOMEM;
574 if (recurse)
575 @@ -968,7 +978,9 @@ static int do_move_mount(struct nameidat
576 err = -EINVAL;
577 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
578 goto out;
579 -
580 + err = -EPERM;
581 + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
582 + goto out;
583 err = -ENOENT;
584 mutex_lock(&nd->dentry->d_inode->i_mutex);
585 if (IS_DEADDIR(nd->dentry->d_inode))
586 @@ -1070,6 +1082,9 @@ int do_add_mount(struct vfsmount *newmnt
587 err = -EINVAL;
588 if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
589 goto unlock;
590 + err = -EPERM;
591 + if (ccs_may_mount(nd))
592 + goto unlock;
593
594 newmnt->mnt_flags = mnt_flags;
595 if ((err = graft_tree(newmnt, nd)))
596 @@ -1287,6 +1302,13 @@ long do_mount(char *dev_name, char *dir_
597 if (data_page)
598 ((char *)data_page)[PAGE_SIZE - 1] = 0;
599
600 + if (!ccs_capable(CCS_SYS_MOUNT))
601 + return -EPERM;
602 + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
603 + &flags);
604 + if (retval)
605 + return retval;
606 +
607 /* Separate the per-mountpoint flags */
608 if (flags & MS_NOSUID)
609 mnt_flags |= MNT_NOSUID;
610 @@ -1585,6 +1607,8 @@ asmlinkage long sys_pivot_root(const cha
611
612 if (!capable(CAP_SYS_ADMIN))
613 return -EPERM;
614 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
615 + return -EPERM;
616
617 lock_kernel();
618
619 @@ -1601,6 +1625,8 @@ asmlinkage long sys_pivot_root(const cha
620 goto out1;
621
622 error = security_sb_pivotroot(&old_nd, &new_nd);
623 + if (!error)
624 + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
625 if (error) {
626 path_release(&old_nd);
627 goto out1;
628 --- linux-2.6.16-76.49vl4.orig/fs/open.c
629 +++ linux-2.6.16-76.49vl4/fs/open.c
630 @@ -30,6 +30,9 @@
631
632 #include <asm/unistd.h>
633
634 +#include <linux/sakura.h>
635 +#include <linux/tomoyo.h>
636 +
637 int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
638 {
639 int retval = -ENODEV;
640 @@ -269,6 +272,8 @@ static long do_sys_truncate(const char _
641 if (error)
642 goto dput_and_out;
643
644 + error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);
645 + if (!error)
646 error = locks_verify_truncate(inode, NULL, length);
647 if (!error) {
648 DQUOT_INIT(inode);
649 @@ -321,7 +326,10 @@ static long do_sys_ftruncate(unsigned in
650 error = -EPERM;
651 if (IS_APPEND(inode))
652 goto out_putf;
653 -
654 + error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
655 + 0);
656 + if (error)
657 + goto out_putf;
658 error = locks_verify_truncate(inode, file, length);
659 if (!error)
660 error = do_truncate(dentry, length, 0, file);
661 @@ -610,6 +618,10 @@ asmlinkage long sys_chroot(const char __
662 error = -EPERM;
663 if (!capable(CAP_SYS_CHROOT))
664 goto dput_and_out;
665 + if (!ccs_capable(CCS_SYS_CHROOT))
666 + goto dput_and_out;
667 + if (ccs_check_chroot_permission(&nd))
668 + goto dput_and_out;
669
670 set_fs_root(current->fs, nd.mnt, nd.dentry);
671 set_fs_altroot();
672 @@ -1192,6 +1204,8 @@ EXPORT_SYMBOL(sys_close);
673 */
674 asmlinkage long sys_vhangup(void)
675 {
676 + if (!ccs_capable(CCS_SYS_VHANGUP))
677 + return -EPERM;
678 if (capable(CAP_SYS_TTY_CONFIG)) {
679 tty_vhangup(current->signal->tty);
680 return 0;
681 --- linux-2.6.16-76.49vl4.orig/fs/proc/Makefile
682 +++ linux-2.6.16-76.49vl4/fs/proc/Makefile
683 @@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge
684 proc-$(CONFIG_PROC_KCORE) += kcore.o
685 proc-$(CONFIG_PROC_VMCORE) += vmcore.o
686 proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
687 +
688 +proc-$(CONFIG_SAKURA) += ccs_proc.o
689 +proc-$(CONFIG_TOMOYO) += ccs_proc.o
690 --- linux-2.6.16-76.49vl4.orig/fs/proc/proc_misc.c
691 +++ linux-2.6.16-76.49vl4/fs/proc/proc_misc.c
692 @@ -682,4 +682,5 @@ void __init proc_misc_init(void)
693 if (entry)
694 entry->proc_fops = &proc_sysrq_trigger_operations;
695 #endif
696 + printk(KERN_INFO "Hook version: 2.6.16-76.49vl4 2009/07/23\n");
697 }
698 --- linux-2.6.16-76.49vl4.orig/include/linux/init_task.h
699 +++ linux-2.6.16-76.49vl4/include/linux/init_task.h
700 @@ -121,6 +121,8 @@ extern struct group_info init_groups;
701 .journal_info = NULL, \
702 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
703 .fs_excl = ATOMIC_INIT(0), \
704 + .ccs_domain_info = NULL, \
705 + .ccs_flags = 0, \
706 }
707
708
709 --- linux-2.6.16-76.49vl4.orig/include/linux/sched.h
710 +++ linux-2.6.16-76.49vl4/include/linux/sched.h
711 @@ -40,6 +40,8 @@
712
713 struct exec_domain;
714
715 +struct ccs_domain_info;
716 +
717 /*
718 * cloning flags:
719 */
720 @@ -873,6 +875,8 @@ struct task_struct {
721 struct rcu_head rcu;
722
723 struct list_head *scm_work_list;
724 + struct ccs_domain_info *ccs_domain_info;
725 + u32 ccs_flags;
726 };
727
728 static inline pid_t process_group(struct task_struct *tsk)
729 --- linux-2.6.16-76.49vl4.orig/kernel/compat.c
730 +++ linux-2.6.16-76.49vl4/kernel/compat.c
731 @@ -23,6 +23,7 @@
732 #include <linux/security.h>
733
734 #include <asm/uaccess.h>
735 +#include <linux/tomoyo.h>
736
737 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
738 {
739 @@ -864,6 +865,8 @@ asmlinkage long compat_sys_stime(compat_
740 err = security_settime(&tv, NULL);
741 if (err)
742 return err;
743 + if (!ccs_capable(CCS_SYS_SETTIME))
744 + return -EPERM;
745
746 do_settimeofday(&tv);
747 return 0;
748 --- linux-2.6.16-76.49vl4.orig/kernel/kexec.c
749 +++ linux-2.6.16-76.49vl4/kernel/kexec.c
750 @@ -26,6 +26,7 @@
751 #include <asm/io.h>
752 #include <asm/system.h>
753 #include <asm/semaphore.h>
754 +#include <linux/tomoyo.h>
755
756 /* Per cpu memory for storing cpu states in case of system crash. */
757 note_buf_t* crash_notes;
758 @@ -922,6 +923,8 @@ asmlinkage long sys_kexec_load(unsigned
759 /* We only trust the superuser with rebooting the system. */
760 if (!capable(CAP_SYS_BOOT))
761 return -EPERM;
762 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
763 + return -EPERM;
764
765 /*
766 * Verify we have a legal set of flags
767 --- linux-2.6.16-76.49vl4.orig/kernel/kmod.c
768 +++ linux-2.6.16-76.49vl4/kernel/kmod.c
769 @@ -150,6 +150,9 @@ static int ____call_usermodehelper(void
770 /* We can run anywhere, unlike our parent keventd(). */
771 set_cpus_allowed(current, CPU_MASK_ALL);
772
773 + current->ccs_domain_info = NULL;
774 + current->ccs_flags = 0;
775 +
776 retval = -EPERM;
777 if (current->fs->root)
778 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
779 --- linux-2.6.16-76.49vl4.orig/kernel/module.c
780 +++ linux-2.6.16-76.49vl4/kernel/module.c
781 @@ -42,6 +42,7 @@
782 #include <asm/uaccess.h>
783 #include <asm/semaphore.h>
784 #include <asm/cacheflush.h>
785 +#include <linux/tomoyo.h>
786
787 #if 0
788 #define DEBUGP printk
789 @@ -578,7 +579,8 @@ sys_delete_module(const char __user *nam
790
791 if (!capable(CAP_SYS_MODULE))
792 return -EPERM;
793 -
794 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
795 + return -EPERM;
796 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
797 return -EFAULT;
798 name[MODULE_NAME_LEN-1] = '\0';
799 @@ -1931,7 +1933,8 @@ sys_init_module(void __user *umod,
800 /* Must have permission */
801 if (!capable(CAP_SYS_MODULE))
802 return -EPERM;
803 -
804 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
805 + return -EPERM;
806 /* Only one module load at a time, please */
807 if (down_interruptible(&module_mutex) != 0)
808 return -EINTR;
809 --- linux-2.6.16-76.49vl4.orig/kernel/ptrace.c
810 +++ linux-2.6.16-76.49vl4/kernel/ptrace.c
811 @@ -21,6 +21,7 @@
812
813 #include <asm/pgtable.h>
814 #include <asm/uaccess.h>
815 +#include <linux/tomoyo.h>
816
817 /*
818 * ptrace a task: make the debugger its new parent and
819 @@ -495,6 +496,8 @@ asmlinkage long sys_ptrace(long request,
820 /*
821 * This lock_kernel fixes a subtle race with suid exec
822 */
823 + if (!ccs_capable(CCS_SYS_PTRACE))
824 + return -EPERM;
825 lock_kernel();
826 if (request == PTRACE_TRACEME) {
827 ret = ptrace_traceme();
828 --- linux-2.6.16-76.49vl4.orig/kernel/sched.c
829 +++ linux-2.6.16-76.49vl4/kernel/sched.c
830 @@ -52,6 +52,7 @@
831 #include <asm/tlb.h>
832
833 #include <asm/unistd.h>
834 +#include <linux/tomoyo.h>
835
836 /*
837 * Convert user-nice values [ -20 ... 0 ... 19 ]
838 @@ -3545,6 +3546,8 @@ asmlinkage long sys_nice(int increment)
839 {
840 int retval;
841 long nice;
842 + if (!ccs_capable(CCS_SYS_NICE))
843 + return -EPERM;
844
845 /*
846 * Setpriority might change our priority at the same moment.
847 --- linux-2.6.16-76.49vl4.orig/kernel/signal.c
848 +++ linux-2.6.16-76.49vl4/kernel/signal.c
849 @@ -30,6 +30,7 @@
850 #include <asm/uaccess.h>
851 #include <asm/unistd.h>
852 #include <asm/siginfo.h>
853 +#include <linux/tomoyo.h>
854
855 /*
856 * SLAB caches for signal bits.
857 @@ -2336,6 +2337,10 @@ asmlinkage long
858 sys_kill(int pid, int sig)
859 {
860 struct siginfo info;
861 + if (sig && !ccs_capable(CCS_SYS_KILL))
862 + return -EPERM;
863 + if (sig && ccs_check_signal_acl(sig, pid))
864 + return -EPERM;
865
866 info.si_signo = sig;
867 info.si_errno = 0;
868 @@ -2394,6 +2399,10 @@ asmlinkage long sys_tgkill(int tgid, int
869 /* This is only valid for single tasks */
870 if (pid <= 0 || tgid <= 0)
871 return -EINVAL;
872 + if (sig && !ccs_capable(CCS_SYS_KILL))
873 + return -EPERM;
874 + if (sig && ccs_check_signal_acl(sig, pid))
875 + return -EPERM;
876
877 return do_tkill(tgid, pid, sig);
878 }
879 @@ -2407,6 +2416,10 @@ sys_tkill(int pid, int sig)
880 /* This is only valid for single tasks */
881 if (pid <= 0)
882 return -EINVAL;
883 + if (sig && !ccs_capable(CCS_SYS_KILL))
884 + return -EPERM;
885 + if (sig && ccs_check_signal_acl(sig, pid))
886 + return -EPERM;
887
888 return do_tkill(0, pid, sig);
889 }
890 --- linux-2.6.16-76.49vl4.orig/kernel/sys.c
891 +++ linux-2.6.16-76.49vl4/kernel/sys.c
892 @@ -38,6 +38,7 @@
893 #include <asm/uaccess.h>
894 #include <asm/io.h>
895 #include <asm/unistd.h>
896 +#include <linux/tomoyo.h>
897
898 #ifndef SET_UNALIGN_CTL
899 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
900 @@ -269,6 +270,10 @@ asmlinkage long sys_setpriority(int whic
901
902 if (which > 2 || which < 0)
903 goto out;
904 + if (!ccs_capable(CCS_SYS_NICE)) {
905 + error = -EPERM;
906 + goto out;
907 + }
908
909 /* normalize: avoid signed division (rounding problems) */
910 error = -ESRCH;
911 @@ -496,6 +501,8 @@ asmlinkage long sys_reboot(int magic1, i
912 magic2 != LINUX_REBOOT_MAGIC2B &&
913 magic2 != LINUX_REBOOT_MAGIC2C))
914 return -EINVAL;
915 + if (!ccs_capable(CCS_SYS_REBOOT))
916 + return -EPERM;
917
918 /* Instead of trying to make the power_off code look like
919 * halt when pm_power_off is not set do it the easy way.
920 @@ -1533,6 +1540,8 @@ asmlinkage long sys_sethostname(char __u
921 return -EPERM;
922 if (len < 0 || len > __NEW_UTS_LEN)
923 return -EINVAL;
924 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
925 + return -EPERM;
926 down_write(&uts_sem);
927 errno = -EFAULT;
928 if (!copy_from_user(tmp, name, len)) {
929 @@ -1578,6 +1587,8 @@ asmlinkage long sys_setdomainname(char _
930 return -EPERM;
931 if (len < 0 || len > __NEW_UTS_LEN)
932 return -EINVAL;
933 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
934 + return -EPERM;
935
936 down_write(&uts_sem);
937 errno = -EFAULT;
938 --- linux-2.6.16-76.49vl4.orig/kernel/sysctl.c
939 +++ linux-2.6.16-76.49vl4/kernel/sysctl.c
940 @@ -49,6 +49,7 @@
941
942 #include <asm/uaccess.h>
943 #include <asm/processor.h>
944 +#include <linux/tomoyo.h>
945
946 extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
947 void __user *buffer, size_t *lenp, loff_t *ppos);
948 @@ -1133,6 +1134,9 @@ int do_sysctl(int __user *name, int nlen
949
950 spin_unlock(&sysctl_lock);
951
952 + error = ccs_parse_table(name, nlen, oldval, newval,
953 + head->ctl_table);
954 + if (!error)
955 error = parse_table(name, nlen, oldval, oldlenp,
956 newval, newlen, head->ctl_table,
957 &context);
958 @@ -1205,6 +1209,13 @@ repeat:
959 if (ctl_perm(table, 001))
960 return -EPERM;
961 if (table->strategy) {
962 + int op = 0;
963 + if (oldval)
964 + op |= 004;
965 + if (newval)
966 + op |= 002;
967 + if (ctl_perm(table, op))
968 + return -EPERM;
969 error = table->strategy(
970 table, name, nlen,
971 oldval, oldlenp,
972 --- linux-2.6.16-76.49vl4.orig/kernel/time.c
973 +++ linux-2.6.16-76.49vl4/kernel/time.c
974 @@ -39,6 +39,7 @@
975
976 #include <asm/uaccess.h>
977 #include <asm/unistd.h>
978 +#include <linux/tomoyo.h>
979
980 /*
981 * The timezone where the local system is located. Used as a default by some
982 @@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user
983 err = security_settime(&tv, NULL);
984 if (err)
985 return err;
986 + if (!ccs_capable(CCS_SYS_SETTIME))
987 + return -EPERM;
988
989 do_settimeofday(&tv);
990 return 0;
991 @@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec
992 error = security_settime(tv, tz);
993 if (error)
994 return error;
995 + if (!ccs_capable(CCS_SYS_SETTIME))
996 + return -EPERM;
997
998 if (tz) {
999 /* SMP safe, global irq locking makes it work. */
1000 @@ -239,6 +244,8 @@ int do_adjtimex(struct timex *txc)
1001 /* In order to modify anything, you gotta be super-user! */
1002 if (txc->modes && !capable(CAP_SYS_TIME))
1003 return -EPERM;
1004 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1005 + return -EPERM;
1006
1007 /* Now we validate the data before disabling interrupts */
1008
1009 --- linux-2.6.16-76.49vl4.orig/net/ipv4/inet_connection_sock.c
1010 +++ linux-2.6.16-76.49vl4/net/ipv4/inet_connection_sock.c
1011 @@ -24,6 +24,7 @@
1012 #include <net/route.h>
1013 #include <net/tcp_states.h>
1014 #include <net/xfrm.h>
1015 +#include <linux/sakura.h>
1016
1017 #ifdef INET_CSK_DEBUG
1018 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1019 @@ -88,6 +89,8 @@ int inet_csk_get_port(struct inet_hashin
1020 do {
1021 head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1022 spin_lock(&head->lock);
1023 + if (ccs_lport_reserved(rover))
1024 + goto next;
1025 inet_bind_bucket_for_each(tb, node, &head->chain)
1026 if (tb->port == rover)
1027 goto next;
1028 --- linux-2.6.16-76.49vl4.orig/net/ipv4/inet_hashtables.c
1029 +++ linux-2.6.16-76.49vl4/net/ipv4/inet_hashtables.c
1030 @@ -23,6 +23,7 @@
1031 #include <net/inet_connection_sock.h>
1032 #include <net/inet_hashtables.h>
1033 #include <net/ip.h>
1034 +#include <linux/sakura.h>
1035
1036 /*
1037 * Allocate and initialize a new local port bind bucket.
1038 @@ -268,6 +269,8 @@ int inet_hash_connect(struct inet_timewa
1039 local_bh_disable();
1040 for (i = 1; i <= range; i++) {
1041 port = low + (i + offset) % range;
1042 + if (ccs_lport_reserved(port))
1043 + continue;
1044 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1045 spin_lock(&head->lock);
1046
1047 --- linux-2.6.16-76.49vl4.orig/net/ipv4/raw.c
1048 +++ linux-2.6.16-76.49vl4/net/ipv4/raw.c
1049 @@ -79,6 +79,7 @@
1050 #include <linux/seq_file.h>
1051 #include <linux/netfilter.h>
1052 #include <linux/netfilter_ipv4.h>
1053 +#include <linux/tomoyo_socket.h>
1054
1055 struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1056 DEFINE_RWLOCK(raw_v4_lock);
1057 @@ -592,6 +593,9 @@ static int raw_recvmsg(struct kiocb *ioc
1058 skb = skb_recv_datagram(sk, flags, noblock, &err);
1059 if (!skb)
1060 goto out;
1061 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1062 + if (err)
1063 + goto out;
1064
1065 copied = skb->len;
1066 if (len < copied) {
1067 --- linux-2.6.16-76.49vl4.orig/net/ipv4/udp.c
1068 +++ linux-2.6.16-76.49vl4/net/ipv4/udp.c
1069 @@ -109,6 +109,8 @@
1070 #include <net/inet_common.h>
1071 #include <net/checksum.h>
1072 #include <net/xfrm.h>
1073 +#include <linux/sakura.h>
1074 +#include <linux/tomoyo_socket.h>
1075
1076 /*
1077 * Snmp MIB for the UDP layer
1078 @@ -147,6 +149,8 @@ static int udp_v4_get_port(struct sock *
1079 result = sysctl_local_port_range[0] +
1080 ((result - sysctl_local_port_range[0]) &
1081 (UDP_HTABLE_SIZE - 1));
1082 + if (ccs_lport_reserved(result))
1083 + continue;
1084 goto gotit;
1085 }
1086 size = 0;
1087 @@ -163,6 +167,8 @@ static int udp_v4_get_port(struct sock *
1088 result = sysctl_local_port_range[0]
1089 + ((result - sysctl_local_port_range[0]) &
1090 (UDP_HTABLE_SIZE - 1));
1091 + if (ccs_lport_reserved(result))
1092 + continue;
1093 if (!udp_lport_inuse(result))
1094 break;
1095 }
1096 @@ -797,7 +803,10 @@ try_again:
1097 skb = skb_recv_datagram(sk, flags, noblock, &err);
1098 if (!skb)
1099 goto out;
1100 -
1101 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1102 + if (err)
1103 + goto out;
1104 +
1105 copied = skb->len - sizeof(struct udphdr);
1106 if (copied > len) {
1107 copied = len;
1108 --- linux-2.6.16-76.49vl4.orig/net/ipv6/inet6_hashtables.c
1109 +++ linux-2.6.16-76.49vl4/net/ipv6/inet6_hashtables.c
1110 @@ -22,6 +22,7 @@
1111 #include <net/inet_hashtables.h>
1112 #include <net/inet6_hashtables.h>
1113 #include <net/ip.h>
1114 +#include <linux/sakura.h>
1115
1116 struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
1117 const struct in6_addr *daddr,
1118 @@ -93,7 +94,7 @@ static int __inet6_check_established(str
1119 const struct in6_addr *saddr = &np->daddr;
1120 const int dif = sk->sk_bound_dev_if;
1121 const u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
1122 - const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr,
1123 + const unsigned int hash = inet6_ehashfn(daddr, lport, saddr,
1124 inet->dport);
1125 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
1126 struct sock *sk2;
1127 @@ -187,6 +188,8 @@ int inet6_hash_connect(struct inet_timew
1128 local_bh_disable();
1129 for (i = 1; i <= range; i++) {
1130 port = low + (i + offset) % range;
1131 + if (ccs_lport_reserved(port))
1132 + continue;
1133 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1134 spin_lock(&head->lock);
1135
1136 --- linux-2.6.16-76.49vl4.orig/net/ipv6/raw.c
1137 +++ linux-2.6.16-76.49vl4/net/ipv6/raw.c
1138 @@ -56,6 +56,7 @@
1139
1140 #include <linux/proc_fs.h>
1141 #include <linux/seq_file.h>
1142 +#include <linux/tomoyo_socket.h>
1143
1144 struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1145 DEFINE_RWLOCK(raw_v6_lock);
1146 @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1147 skb = skb_recv_datagram(sk, flags, noblock, &err);
1148 if (!skb)
1149 goto out;
1150 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1151 + if (err)
1152 + goto out;
1153
1154 copied = skb->len;
1155 if (copied > len) {
1156 --- linux-2.6.16-76.49vl4.orig/net/ipv6/udp.c
1157 +++ linux-2.6.16-76.49vl4/net/ipv6/udp.c
1158 @@ -59,6 +59,8 @@
1159
1160 #include <linux/proc_fs.h>
1161 #include <linux/seq_file.h>
1162 +#include <linux/sakura.h>
1163 +#include <linux/tomoyo_socket.h>
1164
1165 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1166
1167 @@ -89,6 +91,8 @@ static int udp_v6_get_port(struct sock *
1168 result = sysctl_local_port_range[0] +
1169 ((result - sysctl_local_port_range[0]) &
1170 (UDP_HTABLE_SIZE - 1));
1171 + if (ccs_lport_reserved(result))
1172 + continue;
1173 goto gotit;
1174 }
1175 size = 0;
1176 @@ -105,6 +109,8 @@ static int udp_v6_get_port(struct sock *
1177 result = sysctl_local_port_range[0]
1178 + ((result - sysctl_local_port_range[0]) &
1179 (UDP_HTABLE_SIZE - 1));
1180 + if (ccs_lport_reserved(result))
1181 + continue;
1182 if (!udp_lport_inuse(result))
1183 break;
1184 }
1185 @@ -238,6 +244,9 @@ try_again:
1186 skb = skb_recv_datagram(sk, flags, noblock, &err);
1187 if (!skb)
1188 goto out;
1189 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1190 + if (err)
1191 + goto out;
1192
1193 copied = skb->len - sizeof(struct udphdr);
1194 if (copied > len) {
1195 --- linux-2.6.16-76.49vl4.orig/net/socket.c
1196 +++ linux-2.6.16-76.49vl4/net/socket.c
1197 @@ -97,6 +97,9 @@
1198 #include <net/sock.h>
1199 #include <linux/netfilter.h>
1200
1201 +#include <linux/tomoyo.h>
1202 +#include <linux/tomoyo_socket.h>
1203 +
1204 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1205 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1206 size_t size, loff_t pos);
1207 @@ -544,9 +547,12 @@ static inline int __sock_sendmsg(struct
1208 si->size = size;
1209
1210 err = security_socket_sendmsg(sock, msg, size);
1211 + if (!err)
1212 + err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)
1213 + msg->msg_name,
1214 + msg->msg_namelen);
1215 if (err)
1216 return err;
1217 -
1218 return sock->ops->sendmsg(iocb, sock, msg, size);
1219 }
1220
1221 @@ -1103,6 +1109,8 @@ static int __sock_create(int family, int
1222 }
1223
1224 err = security_socket_create(family, type, protocol, kern);
1225 + if (!err)
1226 + err = ccs_socket_create_permission(family, type, protocol);
1227 if (err)
1228 return err;
1229
1230 @@ -1299,6 +1307,10 @@ asmlinkage long sys_bind(int fd, struct
1231 sockfd_put(sock);
1232 return err;
1233 }
1234 + err = ccs_socket_bind_permission(sock,
1235 + (struct sockaddr *)
1236 + address, addrlen);
1237 + if (!err)
1238 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1239 }
1240 sockfd_put(sock);
1241 @@ -1329,7 +1341,8 @@ asmlinkage long sys_listen(int fd, int b
1242 sockfd_put(sock);
1243 return err;
1244 }
1245 -
1246 + err = ccs_socket_listen_permission(sock);
1247 + if (!err)
1248 err=sock->ops->listen(sock, backlog);
1249 sockfd_put(sock);
1250 }
1251 @@ -1380,6 +1393,11 @@ asmlinkage long sys_accept(int fd, struc
1252 if (err < 0)
1253 goto out_release;
1254
1255 + if (ccs_socket_accept_permission(newsock,
1256 + (struct sockaddr *) address)) {
1257 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1258 + goto out_release;
1259 + }
1260 if (upeer_sockaddr) {
1261 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1262 err = -ECONNABORTED;
1263 @@ -1433,9 +1451,11 @@ asmlinkage long sys_connect(int fd, stru
1264 goto out_put;
1265
1266 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1267 + if (!err)
1268 + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1269 + address, addrlen);
1270 if (err)
1271 goto out_put;
1272 -
1273 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1274 sock->file->f_flags);
1275 out_put:
1276 --- linux-2.6.16-76.49vl4.orig/net/unix/af_unix.c
1277 +++ linux-2.6.16-76.49vl4/net/unix/af_unix.c
1278 @@ -117,6 +117,7 @@
1279 #include <linux/mount.h>
1280 #include <net/checksum.h>
1281 #include <linux/security.h>
1282 +#include <linux/tomoyo.h>
1283
1284 int sysctl_unix_max_dgram_qlen = 10;
1285
1286 @@ -782,6 +783,9 @@ static int unix_bind(struct socket *sock
1287 */
1288 mode = S_IFSOCK |
1289 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1290 + err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
1291 + nd.mnt, mode, 0);
1292 + if (!err)
1293 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1294 if (err)
1295 goto out_mknod_dput;

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