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

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2282 - (show annotations) (download) (as text)
Thu Mar 19 04:46:42 2009 UTC (15 years, 2 months ago) by kumaneko
Original Path: trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff
File MIME type: text/x-diff
File size: 50551 byte(s)
Remove KERNEL_DOMAIN from ccs-patch-\*.diff
1 This is TOMOYO Linux patch for Ubuntu 6.06.
2
3 Source code for this patch is "apt-get install linux-source-2.6.15"
4 ---
5 arch/alpha/kernel/ptrace.c | 7 ++
6 arch/ia64/ia32/sys_ia32.c | 7 ++
7 arch/ia64/kernel/ptrace.c | 7 ++
8 arch/m32r/kernel/ptrace.c | 7 ++
9 arch/mips/kernel/ptrace32.c | 7 ++
10 arch/powerpc/kernel/ptrace32.c | 7 ++
11 arch/s390/kernel/ptrace.c | 7 ++
12 arch/sparc/kernel/ptrace.c | 9 +++
13 arch/sparc64/kernel/ptrace.c | 9 +++
14 arch/x86_64/ia32/ptrace32.c | 7 ++
15 fs/Kconfig | 2
16 fs/Makefile | 2
17 fs/attr.c | 19 ++++++
18 fs/compat.c | 15 ++++-
19 fs/exec.c | 21 ++++++-
20 fs/fcntl.c | 8 ++
21 fs/ioctl.c | 11 +++
22 fs/namei.c | 118 ++++++++++++++++++++++++++++++++++++++++
23 fs/namespace.c | 50 ++++++++++++++++
24 fs/open.c | 29 +++++++++
25 fs/proc/Makefile | 3 +
26 fs/proc/proc_misc.c | 5 +
27 include/linux/init_task.h | 4 +
28 include/linux/sched.h | 8 ++
29 kernel/compat.c | 7 ++
30 kernel/kexec.c | 7 ++
31 kernel/kmod.c | 5 +
32 kernel/module.c | 13 +++-
33 kernel/ptrace.c | 7 ++
34 kernel/sched.c | 7 ++
35 kernel/signal.c | 21 +++++++
36 kernel/sys.c | 21 +++++++
37 kernel/sysctl.c | 111 +++++++++++++++++++++++++++++++++++++
38 kernel/time.c | 15 +++++
39 net/core/datagram.c | 11 +++
40 net/ipv4/inet_connection_sock.c | 7 ++
41 net/ipv4/tcp_ipv4.c | 7 ++
42 net/ipv4/udp.c | 11 +++
43 net/ipv6/tcp_ipv6.c | 11 +++
44 net/ipv6/udp.c | 11 +++
45 net/socket.c | 43 +++++++++++++-
46 net/unix/af_unix.c | 15 +++++
47 42 files changed, 690 insertions(+), 9 deletions(-)
48
49 --- linux-2.6.15-53.75.orig/arch/alpha/kernel/ptrace.c
50 +++ linux-2.6.15-53.75/arch/alpha/kernel/ptrace.c
51 @@ -20,6 +20,9 @@
52 #include <asm/pgtable.h>
53 #include <asm/system.h>
54 #include <asm/fpu.h>
55 +/***** TOMOYO Linux start. *****/
56 +#include <linux/tomoyo.h>
57 +/***** TOMOYO Linux end. *****/
58
59 #include "proto.h"
60
61 @@ -261,6 +264,10 @@ do_sys_ptrace(long request, long pid, lo
62 unsigned long tmp;
63 size_t copied;
64 long ret;
65 + /***** TOMOYO Linux start. *****/
66 + if (!ccs_capable(CCS_SYS_PTRACE))
67 + return -EPERM;
68 + /***** TOMOYO Linux end. *****/
69
70 lock_kernel();
71 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
72 --- linux-2.6.15-53.75.orig/arch/ia64/ia32/sys_ia32.c
73 +++ linux-2.6.15-53.75/arch/ia64/ia32/sys_ia32.c
74 @@ -57,6 +57,9 @@
75 #include <asm/types.h>
76 #include <asm/uaccess.h>
77 #include <asm/unistd.h>
78 +/***** TOMOYO Linux start. *****/
79 +#include <linux/tomoyo.h>
80 +/***** TOMOYO Linux end. *****/
81
82 #include "ia32priv.h"
83
84 @@ -1758,6 +1761,10 @@ sys32_ptrace (int request, pid_t pid, un
85 struct task_struct *child;
86 unsigned int value, tmp;
87 long i, ret;
88 + /***** TOMOYO Linux start. *****/
89 + if (!ccs_capable(CCS_SYS_PTRACE))
90 + return -EPERM;
91 + /***** TOMOYO Linux end. *****/
92
93 lock_kernel();
94 if (request == PTRACE_TRACEME) {
95 --- linux-2.6.15-53.75.orig/arch/ia64/kernel/ptrace.c
96 +++ linux-2.6.15-53.75/arch/ia64/kernel/ptrace.c
97 @@ -29,6 +29,9 @@
98 #ifdef CONFIG_PERFMON
99 #include <asm/perfmon.h>
100 #endif
101 +/***** TOMOYO Linux start. *****/
102 +#include <linux/tomoyo.h>
103 +/***** TOMOYO Linux end. *****/
104
105 #include "entry.h"
106
107 @@ -1418,6 +1421,10 @@ sys_ptrace (long request, pid_t pid, uns
108 struct task_struct *child;
109 struct switch_stack *sw;
110 long ret;
111 + /***** TOMOYO Linux start. *****/
112 + if (!ccs_capable(CCS_SYS_PTRACE))
113 + return -EPERM;
114 + /***** TOMOYO Linux end. *****/
115
116 lock_kernel();
117 ret = -EPERM;
118 --- linux-2.6.15-53.75.orig/arch/m32r/kernel/ptrace.c
119 +++ linux-2.6.15-53.75/arch/m32r/kernel/ptrace.c
120 @@ -33,6 +33,9 @@
121 #include <asm/system.h>
122 #include <asm/processor.h>
123 #include <asm/mmu_context.h>
124 +/***** TOMOYO Linux start. *****/
125 +#include <linux/tomoyo.h>
126 +/***** TOMOYO Linux end. *****/
127
128 /*
129 * Get the address of the live pt_regs for the specified task.
130 @@ -760,6 +763,10 @@ asmlinkage long sys_ptrace(long request,
131 {
132 struct task_struct *child;
133 int ret;
134 + /***** TOMOYO Linux start. *****/
135 + if (!ccs_capable(CCS_SYS_PTRACE))
136 + return -EPERM;
137 + /***** TOMOYO Linux end. *****/
138
139 lock_kernel();
140 ret = -EPERM;
141 --- linux-2.6.15-53.75.orig/arch/mips/kernel/ptrace32.c
142 +++ linux-2.6.15-53.75/arch/mips/kernel/ptrace32.c
143 @@ -35,6 +35,9 @@
144 #include <asm/system.h>
145 #include <asm/uaccess.h>
146 #include <asm/bootinfo.h>
147 +/***** TOMOYO Linux start. *****/
148 +#include <linux/tomoyo.h>
149 +/***** TOMOYO Linux end. *****/
150
151 int ptrace_getregs (struct task_struct *child, __s64 __user *data);
152 int ptrace_setregs (struct task_struct *child, __s64 __user *data);
153 @@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request,
154 {
155 struct task_struct *child;
156 int ret;
157 + /***** TOMOYO Linux start. *****/
158 + if (!ccs_capable(CCS_SYS_PTRACE))
159 + return -EPERM;
160 + /***** TOMOYO Linux end. *****/
161
162 #if 0
163 printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
164 --- linux-2.6.15-53.75.orig/arch/powerpc/kernel/ptrace32.c
165 +++ linux-2.6.15-53.75/arch/powerpc/kernel/ptrace32.c
166 @@ -33,6 +33,9 @@
167 #include <asm/page.h>
168 #include <asm/pgtable.h>
169 #include <asm/system.h>
170 +/***** TOMOYO Linux start. *****/
171 +#include <linux/tomoyo.h>
172 +/***** TOMOYO Linux end. *****/
173
174 #include "ptrace-common.h"
175
176 @@ -46,6 +49,10 @@ long compat_sys_ptrace(int request, int
177 {
178 struct task_struct *child;
179 int ret = -EPERM;
180 + /***** TOMOYO Linux start. *****/
181 + if (!ccs_capable(CCS_SYS_PTRACE))
182 + return -EPERM;
183 + /***** TOMOYO Linux end. *****/
184
185 lock_kernel();
186 if (request == PTRACE_TRACEME) {
187 --- linux-2.6.15-53.75.orig/arch/s390/kernel/ptrace.c
188 +++ linux-2.6.15-53.75/arch/s390/kernel/ptrace.c
189 @@ -41,6 +41,9 @@
190 #include <asm/system.h>
191 #include <asm/uaccess.h>
192 #include <asm/unistd.h>
193 +/***** TOMOYO Linux start. *****/
194 +#include <linux/tomoyo.h>
195 +/***** TOMOYO Linux end. *****/
196
197 #ifdef CONFIG_S390_SUPPORT
198 #include "compat_ptrace.h"
199 @@ -711,6 +714,10 @@ sys_ptrace(long request, long pid, long
200 struct task_struct *child;
201 int ret;
202
203 + /***** TOMOYO Linux start. *****/
204 + if (!ccs_capable(CCS_SYS_PTRACE))
205 + return -EPERM;
206 + /***** TOMOYO Linux end. *****/
207 lock_kernel();
208
209 if (request == PTRACE_TRACEME) {
210 --- linux-2.6.15-53.75.orig/arch/sparc/kernel/ptrace.c
211 +++ linux-2.6.15-53.75/arch/sparc/kernel/ptrace.c
212 @@ -23,6 +23,9 @@
213 #include <asm/pgtable.h>
214 #include <asm/system.h>
215 #include <asm/uaccess.h>
216 +/***** TOMOYO Linux start. *****/
217 +#include <linux/tomoyo.h>
218 +/***** TOMOYO Linux end. *****/
219
220 #define MAGIC_CONSTANT 0x80000000
221
222 @@ -267,6 +270,12 @@ asmlinkage void do_ptrace(struct pt_regs
223 unsigned long addr2 = regs->u_regs[UREG_I4];
224 struct task_struct *child;
225 int ret;
226 + /***** TOMOYO Linux start. *****/
227 + if (!ccs_capable(CCS_SYS_PTRACE)) {
228 + pt_error_return(regs, EPERM);
229 + return;
230 + }
231 + /***** TOMOYO Linux end. *****/
232
233 lock_kernel();
234 #ifdef DEBUG_PTRACE
235 --- linux-2.6.15-53.75.orig/arch/sparc64/kernel/ptrace.c
236 +++ linux-2.6.15-53.75/arch/sparc64/kernel/ptrace.c
237 @@ -32,6 +32,9 @@
238 #include <asm/spitfire.h>
239 #include <asm/page.h>
240 #include <asm/cpudata.h>
241 +/***** TOMOYO Linux start. *****/
242 +#include <linux/tomoyo.h>
243 +/***** TOMOYO Linux end. *****/
244
245 /* Returning from ptrace is a bit tricky because the syscall return
246 * low level code assumes any value returned which is negative and
247 @@ -176,6 +179,12 @@ asmlinkage void do_ptrace(struct pt_regs
248 unsigned long addr2 = regs->u_regs[UREG_I4];
249 struct task_struct *child;
250 int ret;
251 + /***** TOMOYO Linux start. *****/
252 + if (!ccs_capable(CCS_SYS_PTRACE)) {
253 + pt_error_return(regs, EPERM);
254 + return;
255 + }
256 + /***** TOMOYO Linux end. *****/
257
258 if (test_thread_flag(TIF_32BIT)) {
259 addr &= 0xffffffffUL;
260 --- linux-2.6.15-53.75.orig/arch/x86_64/ia32/ptrace32.c
261 +++ linux-2.6.15-53.75/arch/x86_64/ia32/ptrace32.c
262 @@ -27,6 +27,9 @@
263 #include <asm/debugreg.h>
264 #include <asm/i387.h>
265 #include <asm/fpu32.h>
266 +/***** TOMOYO Linux start. *****/
267 +#include <linux/tomoyo.h>
268 +/***** TOMOYO Linux end. *****/
269
270 /* determines which flags the user has access to. */
271 /* 1 = access 0 = no access */
272 @@ -233,6 +236,10 @@ asmlinkage long sys32_ptrace(long reques
273 void __user *datap = compat_ptr(data);
274 int ret;
275 __u32 val;
276 + /***** TOMOYO Linux start. *****/
277 + if (!ccs_capable(CCS_SYS_PTRACE))
278 + return -EPERM;
279 + /***** TOMOYO Linux end. *****/
280
281 switch (request) {
282 default:
283 --- linux-2.6.15-53.75.orig/fs/Kconfig
284 +++ linux-2.6.15-53.75/fs/Kconfig
285 @@ -1910,5 +1910,7 @@ endmenu
286
287 source "fs/nls/Kconfig"
288
289 +source "fs/Kconfig.ccs"
290 +
291 endmenu
292
293 --- linux-2.6.15-53.75.orig/fs/Makefile
294 +++ linux-2.6.15-53.75/fs/Makefile
295 @@ -108,3 +108,5 @@ obj-$(CONFIG_CONFIGFS_FS) += configfs/
296 obj-$(CONFIG_OCFS2_FS) += ocfs2/
297 obj-$(CONFIG_UNION_FS) += unionfs/
298 obj-$(CONFIG_DAZUKO) += dazuko/
299 +
300 +include $(srctree)/fs/Makefile-2.6.ccs
301 --- linux-2.6.15-53.75.orig/fs/attr.c
302 +++ linux-2.6.15-53.75/fs/attr.c
303 @@ -15,6 +15,9 @@
304 #include <linux/quotaops.h>
305 #include <linux/security.h>
306 #include <linux/time.h>
307 +/***** TOMOYO Linux start. *****/
308 +#include <linux/tomoyo.h>
309 +/***** TOMOYO Linux end. *****/
310
311 /* Taken over from the old code... */
312
313 @@ -153,12 +156,28 @@ int notify_change(struct dentry * dentry
314
315 if (inode->i_op && inode->i_op->setattr) {
316 error = security_inode_setattr(dentry, attr);
317 + /***** TOMOYO Linux start. *****/
318 + if (!error && (ia_valid & ATTR_MODE) &&
319 + !ccs_capable(CCS_SYS_CHMOD))
320 + error = -EPERM;
321 + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
322 + !ccs_capable(CCS_SYS_CHOWN))
323 + error = -EPERM;
324 + /***** TOMOYO Linux end. *****/
325 if (!error)
326 error = inode->i_op->setattr(dentry, attr);
327 } else {
328 error = inode_change_ok(inode, attr);
329 if (!error)
330 error = security_inode_setattr(dentry, attr);
331 + /***** TOMOYO Linux start. *****/
332 + if (!error && (ia_valid & ATTR_MODE) &&
333 + !ccs_capable(CCS_SYS_CHMOD))
334 + error = -EPERM;
335 + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
336 + !ccs_capable(CCS_SYS_CHOWN))
337 + error = -EPERM;
338 + /***** TOMOYO Linux end. *****/
339 if (!error) {
340 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
341 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
342 --- linux-2.6.15-53.75.orig/fs/compat.c
343 +++ linux-2.6.15-53.75/fs/compat.c
344 @@ -52,6 +52,9 @@
345 #include <asm/uaccess.h>
346 #include <asm/mmu_context.h>
347 #include <asm/ioctls.h>
348 +/***** TOMOYO Linux start. *****/
349 +#include <linux/tomoyo.h>
350 +/***** TOMOYO Linux end. *****/
351
352 /*
353 * Not all architectures have sys_utime, so implement this in terms
354 @@ -353,6 +356,10 @@ asmlinkage long compat_sys_ioctl(unsigne
355
356 /* RED-PEN how should LSM module know it's handling 32bit? */
357 error = security_file_ioctl(filp, cmd, arg);
358 + /***** TOMOYO Linux start. *****/
359 + if (!error)
360 + error = ccs_check_ioctl_permission(filp, cmd, arg);
361 + /***** TOMOYO Linux end. *****/
362 if (error)
363 goto out_fput;
364
365 @@ -377,6 +384,12 @@ asmlinkage long compat_sys_ioctl(unsigne
366 /*FALL THROUGH*/
367
368 default:
369 + /***** TOMOYO Linux start. *****/
370 + if (!ccs_capable(CCS_SYS_IOCTL)) {
371 + error = -EPERM;
372 + goto out_fput;
373 + }
374 + /***** TOMOYO Linux end. *****/
375 if (filp->f_op && filp->f_op->compat_ioctl) {
376 error = filp->f_op->compat_ioctl(filp, cmd, arg);
377 if (error != -ENOIOCTLCMD)
378 @@ -1480,7 +1493,7 @@ int compat_do_execve(char * filename,
379 if (retval < 0)
380 goto out;
381
382 - retval = search_binary_handler(bprm, regs);
383 + retval = search_binary_handler_with_transition(bprm, regs);
384 if (retval >= 0) {
385 free_arg_pages(bprm);
386
387 --- linux-2.6.15-53.75.orig/fs/exec.c
388 +++ linux-2.6.15-53.75/fs/exec.c
389 @@ -57,6 +57,10 @@
390 #include <linux/kmod.h>
391 #endif
392
393 +/***** TOMOYO Linux start. *****/
394 +#include <linux/tomoyo.h>
395 +/***** TOMOYO Linux end. *****/
396 +
397 int core_uses_pid;
398 char core_pattern[65] = "core";
399 int suid_dumpable = 0;
400 @@ -139,6 +143,13 @@ asmlinkage long sys_uselib(const char __
401 if (error)
402 goto exit;
403
404 + /***** TOMOYO Linux start. *****/
405 + /* 01 means "read". */
406 + error = ccs_check_open_permission(nd.dentry, nd.mnt, 01);
407 + if (error)
408 + goto exit;
409 + /***** TOMOYO Linux end. *****/
410 +
411 file = nameidata_to_filp(&nd, O_RDONLY);
412 error = PTR_ERR(file);
413 if (IS_ERR(file))
414 @@ -488,6 +499,13 @@ struct file *open_exec(const char *name)
415 int err = vfs_permission(&nd, MAY_EXEC);
416 if (!err && !(inode->i_mode & 0111))
417 err = -EACCES;
418 + /***** TOMOYO Linux start. *****/
419 + if (!err && (current->ccs_flags &
420 + CCS_CHECK_READ_FOR_OPEN_EXEC))
421 + /* 01 means "read". */
422 + err = ccs_check_open_permission(nd.dentry,
423 + nd.mnt, 01);
424 + /***** TOMOYO Linux end. *****/
425 file = ERR_PTR(err);
426 if (!err) {
427 file = nameidata_to_filp(&nd, O_RDONLY);
428 @@ -1197,7 +1215,8 @@ int do_execve(char * filename,
429 if (retval < 0)
430 goto out;
431
432 - retval = search_binary_handler(bprm,regs);
433 + retval = search_binary_handler_with_transition(bprm, regs);
434 +
435 if (retval >= 0) {
436 free_arg_pages(bprm);
437
438 --- linux-2.6.15-53.75.orig/fs/fcntl.c
439 +++ linux-2.6.15-53.75/fs/fcntl.c
440 @@ -21,6 +21,9 @@
441 #include <asm/poll.h>
442 #include <asm/siginfo.h>
443 #include <asm/uaccess.h>
444 +/***** TOMOYO Linux start. *****/
445 +#include <linux/tomoyo.h>
446 +/***** TOMOYO Linux end. *****/
447
448 void fastcall set_close_on_exec(unsigned int fd, int flag)
449 {
450 @@ -211,6 +214,11 @@ static int setfl(int fd, struct file * f
451 if (!(arg & O_APPEND) && IS_APPEND(inode))
452 return -EPERM;
453
454 + /***** TOMOYO Linux start. *****/
455 + if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp))
456 + return -EPERM;
457 + /***** TOMOYO Linux end. *****/
458 +
459 /* O_NOATIME can only be set by the owner or superuser */
460 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
461 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
462 --- linux-2.6.15-53.75.orig/fs/ioctl.c
463 +++ linux-2.6.15-53.75/fs/ioctl.c
464 @@ -15,6 +15,9 @@
465
466 #include <asm/uaccess.h>
467 #include <asm/ioctls.h>
468 +/***** TOMOYO Linux start. *****/
469 +#include <linux/tomoyo.h>
470 +/***** TOMOYO Linux end. *****/
471
472 static long do_ioctl(struct file *filp, unsigned int cmd,
473 unsigned long arg)
474 @@ -23,6 +26,10 @@ static long do_ioctl(struct file *filp,
475
476 if (!filp->f_op)
477 goto out;
478 + /***** TOMOYO Linux start. *****/
479 + if (!ccs_capable(CCS_SYS_IOCTL))
480 + return -EPERM;
481 + /***** TOMOYO Linux end. *****/
482
483 if (filp->f_op->unlocked_ioctl) {
484 error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
485 @@ -167,6 +174,10 @@ asmlinkage long sys_ioctl(unsigned int f
486 goto out;
487
488 error = security_file_ioctl(filp, cmd, arg);
489 + /***** TOMOYO Linux start. *****/
490 + if (!error)
491 + error = ccs_check_ioctl_permission(filp, cmd, arg);
492 + /***** TOMOYO Linux end. *****/
493 if (error)
494 goto out_fput;
495
496 --- linux-2.6.15-53.75.orig/fs/namei.c
497 +++ linux-2.6.15-53.75/fs/namei.c
498 @@ -34,6 +34,10 @@
499
500 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
501
502 +/***** TOMOYO Linux start. *****/
503 +#include <linux/tomoyo.h>
504 +/***** TOMOYO Linux end. *****/
505 +
506 /* [Feb-1997 T. Schoebel-Theuer]
507 * Fundamental changes in the pathname lookup mechanisms (namei)
508 * were necessary because of omirr. The reason is that omirr needs
509 @@ -1433,6 +1437,13 @@ int vfs_create(struct inode *dir, struct
510 error = security_inode_create(dir, dentry, mode);
511 if (error)
512 return error;
513 + /***** TOMOYO Linux start. *****/
514 + if (nd) {
515 + error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt);
516 + if (error)
517 + return error;
518 + }
519 + /***** TOMOYO Linux end. *****/
520 DQUOT_INIT(dir);
521 error = dir->i_op->create(dir, dentry, mode, nd);
522 if (!error)
523 @@ -1488,6 +1499,13 @@ int may_open(struct nameidata *nd, int a
524 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
525 return -EPERM;
526
527 + /***** TOMOYO Linux start. *****/
528 + /* includes O_APPEND and O_TRUNC checks */
529 + error = ccs_check_open_permission(dentry, nd->mnt, flag);
530 + if (error)
531 + return error;
532 + /***** TOMOYO Linux end. *****/
533 +
534 /*
535 * Ensure there are no outstanding leases on the file.
536 */
537 @@ -1519,6 +1537,9 @@ int may_open(struct nameidata *nd, int a
538 return 0;
539 }
540
541 +/***** TOMOYO Linux start. *****/
542 +#include <linux/tomoyo_vfs.h>
543 +/***** TOMOYO Linux end. *****/
544 /*
545 * open_namei()
546 *
547 @@ -1768,6 +1789,16 @@ asmlinkage long sys_mknod(const char __u
548
549 if (S_ISDIR(mode))
550 return -EPERM;
551 + /***** TOMOYO Linux start. *****/
552 + if (S_ISCHR(mode) && !ccs_capable(CCS_CREATE_CHAR_DEV))
553 + return -EPERM;
554 + if (S_ISBLK(mode) && !ccs_capable(CCS_CREATE_BLOCK_DEV))
555 + return -EPERM;
556 + if (S_ISFIFO(mode) && !ccs_capable(CCS_CREATE_FIFO))
557 + return -EPERM;
558 + if (S_ISSOCK(mode) && !ccs_capable(CCS_CREATE_UNIX_SOCKET))
559 + return -EPERM;
560 + /***** TOMOYO Linux end. *****/
561 tmp = getname(filename);
562 if (IS_ERR(tmp))
563 return PTR_ERR(tmp);
564 @@ -1786,10 +1817,32 @@ asmlinkage long sys_mknod(const char __u
565 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
566 break;
567 case S_IFCHR: case S_IFBLK:
568 + /***** TOMOYO Linux start. *****/
569 + error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
570 + if (error)
571 + break;
572 + error = ccs_check_1path_perm(S_ISCHR(mode) ?
573 + TYPE_MKCHAR_ACL :
574 + TYPE_MKBLOCK_ACL,
575 + dentry, nd.mnt);
576 + if (error)
577 + break;
578 + /***** TOMOYO Linux end. *****/
579 error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
580 new_decode_dev(dev));
581 break;
582 case S_IFIFO: case S_IFSOCK:
583 + /***** TOMOYO Linux start. *****/
584 + error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
585 + if (error)
586 + break;
587 + error = ccs_check_1path_perm(S_ISFIFO(mode) ?
588 + TYPE_MKFIFO_ACL :
589 + TYPE_MKSOCK_ACL,
590 + dentry, nd.mnt);
591 + if (error)
592 + break;
593 + /***** TOMOYO Linux end. *****/
594 error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
595 break;
596 case S_IFDIR:
597 @@ -1849,6 +1902,13 @@ asmlinkage long sys_mkdir(const char __u
598 if (!IS_ERR(dentry)) {
599 if (!IS_POSIXACL(nd.dentry->d_inode))
600 mode &= ~current->fs->umask;
601 + /***** TOMOYO Linux start. *****/
602 + error = pre_vfs_mkdir(nd.dentry->d_inode, dentry);
603 + if (!error)
604 + error = ccs_check_1path_perm(TYPE_MKDIR_ACL,
605 + dentry, nd.mnt);
606 + if (!error)
607 + /***** TOMOYO Linux end. *****/
608 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
609 dput(dentry);
610 }
611 @@ -1952,6 +2012,13 @@ asmlinkage long sys_rmdir(const char __u
612 dentry = lookup_hash(&nd);
613 error = PTR_ERR(dentry);
614 if (!IS_ERR(dentry)) {
615 + /***** TOMOYO Linux start. *****/
616 + error = pre_vfs_rmdir(nd.dentry->d_inode, dentry);
617 + if (!error)
618 + error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry,
619 + nd.mnt);
620 + if (!error)
621 + /***** TOMOYO Linux end. *****/
622 error = vfs_rmdir(nd.dentry->d_inode, dentry);
623 dput(dentry);
624 }
625 @@ -2006,6 +2073,10 @@ asmlinkage long sys_unlink(const char __
626 struct dentry *dentry;
627 struct nameidata nd;
628 struct inode *inode = NULL;
629 + /***** TOMOYO Linux start. *****/
630 + if (!ccs_capable(CCS_SYS_UNLINK))
631 + return -EPERM;
632 + /***** TOMOYO Linux end. *****/
633
634 name = getname(pathname);
635 if(IS_ERR(name))
636 @@ -2027,6 +2098,14 @@ asmlinkage long sys_unlink(const char __
637 inode = dentry->d_inode;
638 if (inode)
639 atomic_inc(&inode->i_count);
640 + /***** TOMOYO Linux start. *****/
641 + error = pre_vfs_unlink(nd.dentry->d_inode, dentry);
642 + if (error)
643 + goto exit2;
644 + error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt);
645 + if (error)
646 + goto exit2;
647 + /***** TOMOYO Linux end. *****/
648 error = vfs_unlink(nd.dentry->d_inode, dentry);
649 exit2:
650 dput(dentry);
651 @@ -2072,6 +2151,10 @@ asmlinkage long sys_symlink(const char _
652 int error = 0;
653 char * from;
654 char * to;
655 + /***** TOMOYO Linux start. *****/
656 + if (!ccs_capable(CCS_SYS_SYMLINK))
657 + return -EPERM;
658 + /***** TOMOYO Linux end. *****/
659
660 from = getname(oldname);
661 if(IS_ERR(from))
662 @@ -2088,6 +2171,13 @@ asmlinkage long sys_symlink(const char _
663 dentry = lookup_create(&nd, 0);
664 error = PTR_ERR(dentry);
665 if (!IS_ERR(dentry)) {
666 + /***** TOMOYO Linux start. *****/
667 + error = pre_vfs_symlink(nd.dentry->d_inode, dentry);
668 + if (!error)
669 + error = ccs_check_1path_perm(TYPE_SYMLINK_ACL,
670 + dentry, nd.mnt);
671 + if (!error)
672 + /***** TOMOYO Linux end. *****/
673 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
674 dput(dentry);
675 }
676 @@ -2153,6 +2243,10 @@ asmlinkage long sys_link(const char __us
677 struct nameidata nd, old_nd;
678 int error;
679 char * to;
680 + /***** TOMOYO Linux start. *****/
681 + if (!ccs_capable(CCS_SYS_LINK))
682 + return -EPERM;
683 + /***** TOMOYO Linux end. *****/
684
685 to = getname(newname);
686 if (IS_ERR(to))
687 @@ -2170,6 +2264,15 @@ asmlinkage long sys_link(const char __us
688 new_dentry = lookup_create(&nd, 0);
689 error = PTR_ERR(new_dentry);
690 if (!IS_ERR(new_dentry)) {
691 + /***** TOMOYO Linux start. *****/
692 + error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode,
693 + new_dentry);
694 + if (!error)
695 + error = ccs_check_2path_perm(TYPE_LINK_ACL,
696 + old_nd.dentry, old_nd.mnt,
697 + new_dentry, nd.mnt);
698 + if (!error)
699 + /***** TOMOYO Linux end. *****/
700 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
701 dput(new_dentry);
702 }
703 @@ -2390,6 +2493,17 @@ static inline int do_rename(const char *
704 if (new_dentry == trap)
705 goto exit5;
706
707 + /***** TOMOYO Linux start. *****/
708 + error = pre_vfs_rename(old_dir->d_inode, old_dentry,
709 + new_dir->d_inode, new_dentry);
710 + if (error)
711 + goto exit5;
712 + error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt,
713 + new_dentry, newnd.mnt);
714 + if (error)
715 + goto exit5;
716 + /***** TOMOYO Linux end. *****/
717 +
718 error = vfs_rename(old_dir->d_inode, old_dentry,
719 new_dir->d_inode, new_dentry);
720 exit5:
721 @@ -2411,6 +2525,10 @@ asmlinkage long sys_rename(const char __
722 int error;
723 char * from;
724 char * to;
725 + /***** TOMOYO Linux start. *****/
726 + if (!ccs_capable(CCS_SYS_RENAME))
727 + return -EPERM;
728 + /***** TOMOYO Linux end. *****/
729
730 from = getname(oldname);
731 if(IS_ERR(from))
732 --- linux-2.6.15-53.75.orig/fs/namespace.c
733 +++ linux-2.6.15-53.75/fs/namespace.c
734 @@ -25,6 +25,12 @@
735 #include <asm/uaccess.h>
736 #include <asm/unistd.h>
737 #include "pnode.h"
738 +/***** SAKURA Linux start. *****/
739 +#include <linux/sakura.h>
740 +/***** SAKURA Linux end. *****/
741 +/***** TOMOYO Linux start. *****/
742 +#include <linux/tomoyo.h>
743 +/***** TOMOYO Linux end. *****/
744
745 extern int __init init_rootfs(void);
746
747 @@ -504,6 +510,11 @@ static int do_umount(struct vfsmount *mn
748 if (retval)
749 return retval;
750
751 + /***** SAKURA Linux start. *****/
752 + if (ccs_may_umount(mnt))
753 + return -EPERM;
754 + /***** SAKURA Linux end. *****/
755 +
756 /*
757 * Allow userspace to request a mountpoint be expired rather than
758 * unmounting unconditionally. Unmount only happens if:
759 @@ -592,6 +603,10 @@ asmlinkage long sys_umount(char __user *
760 {
761 struct nameidata nd;
762 int retval;
763 + /***** TOMOYO Linux start. *****/
764 + if (!ccs_capable(CCS_SYS_UMOUNT))
765 + return -EPERM;
766 + /***** TOMOYO Linux end. *****/
767
768 retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
769 if (retval)
770 @@ -879,6 +894,11 @@ static int do_loopback(struct nameidata
771
772 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
773 goto out;
774 + /***** SAKURA Linux start. *****/
775 + err = -EPERM;
776 + if (ccs_may_mount(nd))
777 + goto out;
778 + /***** SAKURA Linux end. *****/
779
780 err = -ENOMEM;
781 if (recurse)
782 @@ -963,7 +983,11 @@ static int do_move_mount(struct nameidat
783 err = -EINVAL;
784 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
785 goto out;
786 -
787 + /***** SAKURA Linux start. *****/
788 + err = -EPERM;
789 + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
790 + goto out;
791 + /***** SAKURA Linux end. *****/
792 err = -ENOENT;
793 down(&nd->dentry->d_inode->i_sem);
794 if (IS_DEADDIR(nd->dentry->d_inode))
795 @@ -1065,6 +1089,11 @@ int do_add_mount(struct vfsmount *newmnt
796 err = -EINVAL;
797 if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
798 goto unlock;
799 + /***** SAKURA Linux start. *****/
800 + err = -EPERM;
801 + if (ccs_may_mount(nd))
802 + goto unlock;
803 + /***** SAKURA Linux end. *****/
804
805 newmnt->mnt_flags = mnt_flags;
806 if ((err = graft_tree(newmnt, nd)))
807 @@ -1282,6 +1311,17 @@ long do_mount(char *dev_name, char *dir_
808 if (data_page)
809 ((char *)data_page)[PAGE_SIZE - 1] = 0;
810
811 + /***** TOMOYO Linux start. *****/
812 + if (!ccs_capable(CCS_SYS_MOUNT))
813 + return -EPERM;
814 + /***** TOMOYO Linux end. *****/
815 + /***** SAKURA Linux start. *****/
816 + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
817 + &flags);
818 + if (retval)
819 + return retval;
820 + /***** SAKURA Linux end. *****/
821 +
822 /* Separate the per-mountpoint flags */
823 if (flags & MS_NOSUID)
824 mnt_flags |= MNT_NOSUID;
825 @@ -1546,6 +1586,10 @@ asmlinkage long sys_pivot_root(const cha
826
827 if (!capable(CAP_SYS_ADMIN))
828 return -EPERM;
829 + /***** TOMOYO Linux start. *****/
830 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
831 + return -EPERM;
832 + /***** TOMOYO Linux end. *****/
833
834 lock_kernel();
835
836 @@ -1562,6 +1606,10 @@ asmlinkage long sys_pivot_root(const cha
837 goto out1;
838
839 error = security_sb_pivotroot(&old_nd, &new_nd);
840 + /***** SAKURA Linux start. *****/
841 + if (!error)
842 + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
843 + /***** SAKURA Linux end. *****/
844 if (error) {
845 path_release(&old_nd);
846 goto out1;
847 --- linux-2.6.15-53.75.orig/fs/open.c
848 +++ linux-2.6.15-53.75/fs/open.c
849 @@ -28,6 +28,13 @@
850
851 #include <asm/unistd.h>
852
853 +/***** SAKURA Linux start. *****/
854 +#include <linux/sakura.h>
855 +/***** SAKURA Linux end. *****/
856 +/***** TOMOYO Linux start. *****/
857 +#include <linux/tomoyo.h>
858 +/***** TOMOYO Linux end. *****/
859 +
860 int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
861 {
862 int retval = -ENODEV;
863 @@ -285,6 +292,10 @@ static inline long do_sys_truncate(const
864 if (error)
865 goto dput_and_out;
866
867 + /***** TOMOYO Linux start. *****/
868 + error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt);
869 + if (!error)
870 + /***** TOMOYO Linux end. *****/
871 error = locks_verify_truncate(inode, NULL, length);
872 if (!error) {
873 DQUOT_INIT(inode);
874 @@ -337,7 +348,11 @@ static inline long do_sys_ftruncate(unsi
875 error = -EPERM;
876 if (IS_APPEND(inode))
877 goto out_putf;
878 -
879 + /***** TOMOYO Linux start. *****/
880 + error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt);
881 + if (error)
882 + goto out_putf;
883 + /***** TOMOYO Linux end. *****/
884 error = locks_verify_truncate(inode, file, length);
885 if (!error)
886 error = do_truncate(dentry, length, file);
887 @@ -610,6 +625,14 @@ asmlinkage long sys_chroot(const char __
888 error = -EPERM;
889 if (!capable(CAP_SYS_CHROOT))
890 goto dput_and_out;
891 + /***** TOMOYO Linux start. *****/
892 + if (!ccs_capable(CCS_SYS_CHROOT))
893 + goto dput_and_out;
894 + /***** TOMOYO Linux end. *****/
895 + /***** SAKURA Linux start. *****/
896 + if (ccs_check_chroot_permission(&nd))
897 + goto dput_and_out;
898 + /***** SAKURA Linux end. *****/
899
900 set_fs_root(current->fs, nd.mnt, nd.dentry);
901 set_fs_altroot();
902 @@ -1141,6 +1164,10 @@ EXPORT_SYMBOL(sys_close);
903 */
904 asmlinkage long sys_vhangup(void)
905 {
906 + /***** TOMOYO Linux start. *****/
907 + if (!ccs_capable(CCS_SYS_VHANGUP))
908 + return -EPERM;
909 + /***** TOMOYO Linux end. *****/
910 if (capable(CAP_SYS_TTY_CONFIG)) {
911 tty_vhangup(current->signal->tty);
912 return 0;
913 --- linux-2.6.15-53.75.orig/fs/proc/Makefile
914 +++ linux-2.6.15-53.75/fs/proc/Makefile
915 @@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge
916 proc-$(CONFIG_PROC_KCORE) += kcore.o
917 proc-$(CONFIG_PROC_VMCORE) += vmcore.o
918 proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
919 +
920 +proc-$(CONFIG_SAKURA) += ccs_proc.o
921 +proc-$(CONFIG_TOMOYO) += ccs_proc.o
922 --- linux-2.6.15-53.75.orig/fs/proc/proc_misc.c
923 +++ linux-2.6.15-53.75/fs/proc/proc_misc.c
924 @@ -629,4 +629,9 @@ void __init proc_misc_init(void)
925 if (entry)
926 entry->proc_fops = &proc_sysrq_trigger_operations;
927 #endif
928 + /***** CCS start. *****/
929 +#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
930 + printk(KERN_INFO "Hook version: 2.6.15-53.75 2009/03/18\n");
931 +#endif
932 + /***** CCS end. *****/
933 }
934 --- linux-2.6.15-53.75.orig/include/linux/init_task.h
935 +++ linux-2.6.15-53.75/include/linux/init_task.h
936 @@ -121,6 +121,10 @@ extern struct group_info init_groups;
937 .journal_info = NULL, \
938 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
939 .fs_excl = ATOMIC_INIT(0), \
940 + /***** TOMOYO Linux start. *****/ \
941 + .ccs_domain_info = NULL, \
942 + .ccs_flags = 0, \
943 + /***** TOMOYO Linux end. *****/ \
944 }
945
946
947 --- linux-2.6.15-53.75.orig/include/linux/sched.h
948 +++ linux-2.6.15-53.75/include/linux/sched.h
949 @@ -39,6 +39,10 @@
950
951 struct exec_domain;
952
953 +/***** TOMOYO Linux start. *****/
954 +struct ccs_domain_info;
955 +/***** TOMOYO Linux end. *****/
956 +
957 /*
958 * cloning flags:
959 */
960 @@ -858,6 +862,10 @@ struct task_struct {
961 #endif
962 atomic_t fs_excl; /* holding fs exclusive resources */
963 struct list_head *scm_work_list;
964 + /***** TOMOYO Linux start. *****/
965 + struct ccs_domain_info *ccs_domain_info;
966 + u32 ccs_flags;
967 + /***** TOMOYO Linux end. *****/
968 };
969
970 static inline pid_t process_group(struct task_struct *tsk)
971 --- linux-2.6.15-53.75.orig/kernel/compat.c
972 +++ linux-2.6.15-53.75/kernel/compat.c
973 @@ -24,6 +24,9 @@
974
975 #include <asm/uaccess.h>
976 #include <asm/bug.h>
977 +/***** TOMOYO Linux start. *****/
978 +#include <linux/tomoyo.h>
979 +/***** TOMOYO Linux end. *****/
980
981 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
982 {
983 @@ -849,6 +852,10 @@ asmlinkage long compat_sys_stime(compat_
984 err = security_settime(&tv, NULL);
985 if (err)
986 return err;
987 + /***** TOMOYO Linux start. *****/
988 + if (!ccs_capable(CCS_SYS_SETTIME))
989 + return -EPERM;
990 + /***** TOMOYO Linux end. *****/
991
992 do_settimeofday(&tv);
993 return 0;
994 --- linux-2.6.15-53.75.orig/kernel/kexec.c
995 +++ linux-2.6.15-53.75/kernel/kexec.c
996 @@ -25,6 +25,9 @@
997 #include <asm/io.h>
998 #include <asm/system.h>
999 #include <asm/semaphore.h>
1000 +/***** TOMOYO Linux start. *****/
1001 +#include <linux/tomoyo.h>
1002 +/***** TOMOYO Linux end. *****/
1003
1004 /* Location of the reserved area for the crash kernel */
1005 struct resource crashk_res = {
1006 @@ -918,6 +921,10 @@ asmlinkage long sys_kexec_load(unsigned
1007 /* We only trust the superuser with rebooting the system. */
1008 if (!capable(CAP_SYS_BOOT))
1009 return -EPERM;
1010 + /***** TOMOYO Linux start. *****/
1011 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
1012 + return -EPERM;
1013 + /***** TOMOYO Linux end. *****/
1014
1015 /*
1016 * Verify we have a legal set of flags
1017 --- linux-2.6.15-53.75.orig/kernel/kmod.c
1018 +++ linux-2.6.15-53.75/kernel/kmod.c
1019 @@ -149,6 +149,11 @@ static int ____call_usermodehelper(void
1020 /* We can run anywhere, unlike our parent keventd(). */
1021 set_cpus_allowed(current, CPU_MASK_ALL);
1022
1023 + /***** TOMOYO Linux start. *****/
1024 + current->ccs_domain_info = NULL;
1025 + current->ccs_flags = 0;
1026 + /***** TOMOYO Linux end. *****/
1027 +
1028 retval = -EPERM;
1029 if (current->fs->root)
1030 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
1031 --- linux-2.6.15-53.75.orig/kernel/module.c
1032 +++ linux-2.6.15-53.75/kernel/module.c
1033 @@ -41,6 +41,9 @@
1034 #include <asm/uaccess.h>
1035 #include <asm/semaphore.h>
1036 #include <asm/cacheflush.h>
1037 +/***** TOMOYO Linux start. *****/
1038 +#include <linux/tomoyo.h>
1039 +/***** TOMOYO Linux end. *****/
1040
1041 #if 0
1042 #define DEBUGP printk
1043 @@ -577,7 +580,10 @@ sys_delete_module(const char __user *nam
1044
1045 if (!capable(CAP_SYS_MODULE))
1046 return -EPERM;
1047 -
1048 + /***** TOMOYO Linux start. *****/
1049 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1050 + return -EPERM;
1051 + /***** TOMOYO Linux end. *****/
1052 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
1053 return -EFAULT;
1054 name[MODULE_NAME_LEN-1] = '\0';
1055 @@ -1886,7 +1892,10 @@ sys_init_module(void __user *umod,
1056 /* Must have permission */
1057 if (!capable(CAP_SYS_MODULE))
1058 return -EPERM;
1059 -
1060 + /***** TOMOYO Linux start. *****/
1061 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1062 + return -EPERM;
1063 + /***** TOMOYO Linux end. *****/
1064 /* Only one module load at a time, please */
1065 if (down_interruptible(&module_mutex) != 0)
1066 return -EINTR;
1067 --- linux-2.6.15-53.75.orig/kernel/ptrace.c
1068 +++ linux-2.6.15-53.75/kernel/ptrace.c
1069 @@ -20,6 +20,9 @@
1070
1071 #include <asm/pgtable.h>
1072 #include <asm/uaccess.h>
1073 +/***** TOMOYO Linux start. *****/
1074 +#include <linux/tomoyo.h>
1075 +/***** TOMOYO Linux end. *****/
1076
1077 /*
1078 * ptrace a task: make the debugger its new parent and
1079 @@ -492,6 +495,10 @@ asmlinkage long sys_ptrace(long request,
1080 /*
1081 * This lock_kernel fixes a subtle race with suid exec
1082 */
1083 + /***** TOMOYO Linux start. *****/
1084 + if (!ccs_capable(CCS_SYS_PTRACE))
1085 + return -EPERM;
1086 + /***** TOMOYO Linux end. *****/
1087 lock_kernel();
1088 ret = ptrace_get_task_struct(request, pid, &child);
1089 if (!child)
1090 --- linux-2.6.15-53.75.orig/kernel/sched.c
1091 +++ linux-2.6.15-53.75/kernel/sched.c
1092 @@ -50,6 +50,9 @@
1093 #include <asm/tlb.h>
1094
1095 #include <asm/unistd.h>
1096 +/***** TOMOYO Linux start. *****/
1097 +#include <linux/tomoyo.h>
1098 +/***** TOMOYO Linux end. *****/
1099
1100 /*
1101 * Convert user-nice values [ -20 ... 0 ... 19 ]
1102 @@ -3603,6 +3606,10 @@ asmlinkage long sys_nice(int increment)
1103 {
1104 int retval;
1105 long nice;
1106 + /***** TOMOYO Linux start. *****/
1107 + if (!ccs_capable(CCS_SYS_NICE))
1108 + return -EPERM;
1109 + /***** TOMOYO Linux end. *****/
1110
1111 /*
1112 * Setpriority might change our priority at the same moment.
1113 --- linux-2.6.15-53.75.orig/kernel/signal.c
1114 +++ linux-2.6.15-53.75/kernel/signal.c
1115 @@ -29,6 +29,9 @@
1116 #include <asm/uaccess.h>
1117 #include <asm/unistd.h>
1118 #include <asm/siginfo.h>
1119 +/***** TOMOYO Linux start. *****/
1120 +#include <linux/tomoyo.h>
1121 +/***** TOMOYO Linux end. *****/
1122
1123 /*
1124 * SLAB caches for signal bits.
1125 @@ -2241,6 +2244,12 @@ asmlinkage long
1126 sys_kill(int pid, int sig)
1127 {
1128 struct siginfo info;
1129 + /***** TOMOYO Linux start. *****/
1130 + if (sig && !ccs_capable(CCS_SYS_KILL))
1131 + return -EPERM;
1132 + if (sig && ccs_check_signal_acl(sig, pid))
1133 + return -EPERM;
1134 + /***** TOMOYO Linux end. *****/
1135
1136 info.si_signo = sig;
1137 info.si_errno = 0;
1138 @@ -2299,6 +2308,12 @@ asmlinkage long sys_tgkill(int tgid, int
1139 /* This is only valid for single tasks */
1140 if (pid <= 0 || tgid <= 0)
1141 return -EINVAL;
1142 + /***** TOMOYO Linux start. *****/
1143 + if (sig && !ccs_capable(CCS_SYS_KILL))
1144 + return -EPERM;
1145 + if (sig && ccs_check_signal_acl(sig, pid))
1146 + return -EPERM;
1147 + /***** TOMOYO Linux end. *****/
1148
1149 return do_tkill(tgid, pid, sig);
1150 }
1151 @@ -2312,6 +2327,12 @@ sys_tkill(int pid, int sig)
1152 /* This is only valid for single tasks */
1153 if (pid <= 0)
1154 return -EINVAL;
1155 + /***** TOMOYO Linux start. *****/
1156 + if (sig && !ccs_capable(CCS_SYS_KILL))
1157 + return -EPERM;
1158 + if (sig && ccs_check_signal_acl(sig, pid))
1159 + return -EPERM;
1160 + /***** TOMOYO Linux end. *****/
1161
1162 return do_tkill(0, pid, sig);
1163 }
1164 --- linux-2.6.15-53.75.orig/kernel/sys.c
1165 +++ linux-2.6.15-53.75/kernel/sys.c
1166 @@ -37,6 +37,9 @@
1167 #include <asm/uaccess.h>
1168 #include <asm/io.h>
1169 #include <asm/unistd.h>
1170 +/***** TOMOYO Linux start. *****/
1171 +#include <linux/tomoyo.h>
1172 +/***** TOMOYO Linux end. *****/
1173
1174 #ifndef SET_UNALIGN_CTL
1175 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1176 @@ -256,6 +259,12 @@ asmlinkage long sys_setpriority(int whic
1177
1178 if (which > 2 || which < 0)
1179 goto out;
1180 + /***** TOMOYO Linux start. *****/
1181 + if (!ccs_capable(CCS_SYS_NICE)) {
1182 + error = -EPERM;
1183 + goto out;
1184 + }
1185 + /***** TOMOYO Linux end. *****/
1186
1187 /* normalize: avoid signed division (rounding problems) */
1188 error = -ESRCH;
1189 @@ -483,6 +492,10 @@ asmlinkage long sys_reboot(int magic1, i
1190 magic2 != LINUX_REBOOT_MAGIC2B &&
1191 magic2 != LINUX_REBOOT_MAGIC2C))
1192 return -EINVAL;
1193 + /***** TOMOYO Linux start. *****/
1194 + if (!ccs_capable(CCS_SYS_REBOOT))
1195 + return -EPERM;
1196 + /***** TOMOYO Linux end. *****/
1197
1198 lock_kernel();
1199 switch (cmd) {
1200 @@ -1515,6 +1528,10 @@ asmlinkage long sys_sethostname(char __u
1201 return -EPERM;
1202 if (len < 0 || len > __NEW_UTS_LEN)
1203 return -EINVAL;
1204 + /***** TOMOYO Linux start. *****/
1205 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1206 + return -EPERM;
1207 + /***** TOMOYO Linux end. *****/
1208 down_write(&uts_sem);
1209 errno = -EFAULT;
1210 if (!copy_from_user(tmp, name, len)) {
1211 @@ -1560,6 +1577,10 @@ asmlinkage long sys_setdomainname(char _
1212 return -EPERM;
1213 if (len < 0 || len > __NEW_UTS_LEN)
1214 return -EINVAL;
1215 + /***** TOMOYO Linux start. *****/
1216 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1217 + return -EPERM;
1218 + /***** TOMOYO Linux end. *****/
1219
1220 down_write(&uts_sem);
1221 errno = -EFAULT;
1222 --- linux-2.6.15-53.75.orig/kernel/sysctl.c
1223 +++ linux-2.6.15-53.75/kernel/sysctl.c
1224 @@ -45,6 +45,9 @@
1225
1226 #include <asm/uaccess.h>
1227 #include <asm/processor.h>
1228 +/***** TOMOYO Linux start. *****/
1229 +#include <linux/tomoyo.h>
1230 +/***** TOMOYO Linux end. *****/
1231
1232 #ifdef CONFIG_ROOT_NFS
1233 #include <linux/nfs_fs.h>
1234 @@ -1041,6 +1044,100 @@ void __init sysctl_init(void)
1235 #endif
1236 }
1237
1238 +/***** TOMOYO Linux start. *****/
1239 +static int try_parse_table(int __user *name, int nlen, void __user *oldval,
1240 + void __user *newval, ctl_table *table)
1241 +{
1242 + int n;
1243 + int error = -ENOMEM;
1244 + int op = 0;
1245 + char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1246 + if (oldval)
1247 + op |= 004;
1248 + if (newval)
1249 + op |= 002;
1250 + if (!op) { /* Neither read nor write */
1251 + error = 0;
1252 + goto out;
1253 + }
1254 + if (!buffer)
1255 + goto out;
1256 + memset(buffer, 0, PAGE_SIZE);
1257 + snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1258 + repeat:
1259 + if (!nlen) {
1260 + error = -ENOTDIR;
1261 + goto out;
1262 + }
1263 + if (get_user(n, name)) {
1264 + error = -EFAULT;
1265 + goto out;
1266 + }
1267 + for ( ; table->ctl_name; table++) {
1268 + if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1269 + int pos = strlen(buffer);
1270 + const char *cp = table->procname;
1271 + error = -ENOMEM;
1272 + if (cp) {
1273 + if (pos + 1 >= PAGE_SIZE - 1)
1274 + goto out;
1275 + buffer[pos++] = '/';
1276 + while (*cp) {
1277 + const unsigned char c
1278 + = *(const unsigned char *) cp;
1279 + if (c == '\\') {
1280 + if (pos + 2 >= PAGE_SIZE - 1)
1281 + goto out;
1282 + buffer[pos++] = '\\';
1283 + buffer[pos++] = '\\';
1284 + } else if (c > ' ' && c < 127) {
1285 + if (pos + 1 >= PAGE_SIZE - 1)
1286 + goto out;
1287 + buffer[pos++] = c;
1288 + } else {
1289 + if (pos + 4 >= PAGE_SIZE - 1)
1290 + goto out;
1291 + buffer[pos++] = '\\';
1292 + buffer[pos++] = (c >> 6) + '0';
1293 + buffer[pos++] = ((c >> 3) & 7)
1294 + + '0';
1295 + buffer[pos++] = (c & 7) + '0';
1296 + }
1297 + cp++;
1298 + }
1299 + } else {
1300 + /* Assume nobody assigns "=\$=" for procname. */
1301 + snprintf(buffer + pos, PAGE_SIZE - pos - 1,
1302 + "/=%d=", table->ctl_name);
1303 + if (!memchr(buffer, '\0', PAGE_SIZE - 2))
1304 + goto out;
1305 + }
1306 + if (table->child) {
1307 + if (table->strategy) {
1308 + /* printk("sysctl='%s'\n", buffer); */
1309 + if (ccs_check_file_perm(buffer, op,
1310 + "sysctl")) {
1311 + error = -EPERM;
1312 + goto out;
1313 + }
1314 + }
1315 + name++;
1316 + nlen--;
1317 + table = table->child;
1318 + goto repeat;
1319 + }
1320 + /* printk("sysctl='%s'\n", buffer); */
1321 + error = ccs_check_file_perm(buffer, op, "sysctl");
1322 + goto out;
1323 + }
1324 + }
1325 + error = -ENOTDIR;
1326 + out:
1327 + kfree(buffer);
1328 + return error;
1329 +}
1330 +/***** TOMOYO Linux end. *****/
1331 +
1332 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1333 void __user *newval, size_t newlen)
1334 {
1335 @@ -1066,6 +1163,11 @@ int do_sysctl(int __user *name, int nlen
1336
1337 spin_unlock(&sysctl_lock);
1338
1339 + /***** TOMOYO Linux start. *****/
1340 + error = try_parse_table(name, nlen, oldval, newval,
1341 + head->ctl_table);
1342 + if (!error)
1343 + /***** TOMOYO Linux end. *****/
1344 error = parse_table(name, nlen, oldval, oldlenp,
1345 newval, newlen, head->ctl_table,
1346 &context);
1347 @@ -1138,6 +1240,15 @@ repeat:
1348 if (ctl_perm(table, 001))
1349 return -EPERM;
1350 if (table->strategy) {
1351 + /***** TOMOYO Linux start. *****/
1352 + int op = 0;
1353 + if (oldval)
1354 + op |= 004;
1355 + if (newval)
1356 + op |= 002;
1357 + if (ctl_perm(table, op))
1358 + return -EPERM;
1359 + /***** TOMOYO Linux end. *****/
1360 error = table->strategy(
1361 table, name, nlen,
1362 oldval, oldlenp,
1363 --- linux-2.6.15-53.75.orig/kernel/time.c
1364 +++ linux-2.6.15-53.75/kernel/time.c
1365 @@ -38,6 +38,9 @@
1366
1367 #include <asm/uaccess.h>
1368 #include <asm/unistd.h>
1369 +/***** TOMOYO Linux start. *****/
1370 +#include <linux/tomoyo.h>
1371 +/***** TOMOYO Linux end. *****/
1372
1373 /*
1374 * The timezone where the local system is located. Used as a default by some
1375 @@ -90,6 +93,10 @@ asmlinkage long sys_stime(time_t __user
1376 err = security_settime(&tv, NULL);
1377 if (err)
1378 return err;
1379 + /***** TOMOYO Linux start. *****/
1380 + if (!ccs_capable(CCS_SYS_SETTIME))
1381 + return -EPERM;
1382 + /***** TOMOYO Linux end. *****/
1383
1384 do_settimeofday(&tv);
1385 return 0;
1386 @@ -157,6 +164,10 @@ int do_sys_settimeofday(struct timespec
1387 error = security_settime(tv, tz);
1388 if (error)
1389 return error;
1390 + /***** TOMOYO Linux start. *****/
1391 + if (!ccs_capable(CCS_SYS_SETTIME))
1392 + return -EPERM;
1393 + /***** TOMOYO Linux end. *****/
1394
1395 if (tz) {
1396 /* SMP safe, global irq locking makes it work. */
1397 @@ -235,6 +246,10 @@ int do_adjtimex(struct timex *txc)
1398 /* In order to modify anything, you gotta be super-user! */
1399 if (txc->modes && !capable(CAP_SYS_TIME))
1400 return -EPERM;
1401 + /***** TOMOYO Linux start. *****/
1402 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1403 + return -EPERM;
1404 + /***** TOMOYO Linux end. *****/
1405
1406 /* Now we validate the data before disabling interrupts */
1407
1408 --- linux-2.6.15-53.75.orig/net/core/datagram.c
1409 +++ linux-2.6.15-53.75/net/core/datagram.c
1410 @@ -55,6 +55,11 @@
1411 #include <net/sock.h>
1412 #include <net/tcp_states.h>
1413
1414 +/***** TOMOYO Linux start. *****/
1415 +#include <linux/tomoyo.h>
1416 +#include <linux/tomoyo_socket.h>
1417 +/***** TOMOYO Linux end. *****/
1418 +
1419 /*
1420 * Is a socket 'connection oriented' ?
1421 */
1422 @@ -177,6 +182,12 @@ struct sk_buff *skb_recv_datagram(struct
1423 } else
1424 skb = skb_dequeue(&sk->sk_receive_queue);
1425
1426 + /***** TOMOYO Linux start. *****/
1427 + error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1428 + if (error)
1429 + goto no_packet;
1430 + /***** TOMOYO Linux end. *****/
1431 +
1432 if (skb)
1433 return skb;
1434
1435 --- linux-2.6.15-53.75.orig/net/ipv4/inet_connection_sock.c
1436 +++ linux-2.6.15-53.75/net/ipv4/inet_connection_sock.c
1437 @@ -24,6 +24,9 @@
1438 #include <net/route.h>
1439 #include <net/tcp_states.h>
1440 #include <net/xfrm.h>
1441 +/***** SAKURA Linux start. *****/
1442 +#include <linux/sakura.h>
1443 +/***** SAKURA Linux end. *****/
1444
1445 #ifdef INET_CSK_DEBUG
1446 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1447 @@ -83,6 +86,10 @@ int inet_csk_get_port(struct inet_hashin
1448 do {
1449 head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1450 spin_lock(&head->lock);
1451 + /***** SAKURA Linux start. *****/
1452 + if (ccs_may_autobind(rover))
1453 + goto next;
1454 + /***** SAKURA Linux end. *****/
1455 inet_bind_bucket_for_each(tb, node, &head->chain)
1456 if (tb->port == rover)
1457 goto next;
1458 --- linux-2.6.15-53.75.orig/net/ipv4/tcp_ipv4.c
1459 +++ linux-2.6.15-53.75/net/ipv4/tcp_ipv4.c
1460 @@ -76,6 +76,9 @@
1461 #include <linux/stddef.h>
1462 #include <linux/proc_fs.h>
1463 #include <linux/seq_file.h>
1464 +/***** SAKURA Linux start. *****/
1465 +#include <linux/sakura.h>
1466 +/***** SAKURA Linux end. *****/
1467
1468 int sysctl_tcp_tw_reuse;
1469 int sysctl_tcp_low_latency;
1470 @@ -243,6 +246,10 @@ static inline int tcp_v4_hash_connect(st
1471 local_bh_disable();
1472 for (i = 1; i <= range; i++) {
1473 port = low + (i + offset) % range;
1474 + /***** SAKURA Linux start. *****/
1475 + if (ccs_may_autobind(port))
1476 + continue;
1477 + /***** SAKURA Linux end. *****/
1478 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1479 spin_lock(&head->lock);
1480
1481 --- linux-2.6.15-53.75.orig/net/ipv4/udp.c
1482 +++ linux-2.6.15-53.75/net/ipv4/udp.c
1483 @@ -108,6 +108,9 @@
1484 #include <net/inet_common.h>
1485 #include <net/checksum.h>
1486 #include <net/xfrm.h>
1487 +/***** SAKURA Linux start. *****/
1488 +#include <linux/sakura.h>
1489 +/***** SAKURA Linux end. *****/
1490
1491 /*
1492 * Snmp MIB for the UDP layer
1493 @@ -146,6 +149,10 @@ static int udp_v4_get_port(struct sock *
1494 result = sysctl_local_port_range[0] +
1495 ((result - sysctl_local_port_range[0]) &
1496 (UDP_HTABLE_SIZE - 1));
1497 + /***** SAKURA Linux start. *****/
1498 + if (ccs_may_autobind(result))
1499 + continue;
1500 + /***** SAKURA Linux end. *****/
1501 goto gotit;
1502 }
1503 size = 0;
1504 @@ -162,6 +169,10 @@ static int udp_v4_get_port(struct sock *
1505 result = sysctl_local_port_range[0]
1506 + ((result - sysctl_local_port_range[0]) &
1507 (UDP_HTABLE_SIZE - 1));
1508 + /***** SAKURA Linux start. *****/
1509 + if (ccs_may_autobind(result))
1510 + continue;
1511 + /***** SAKURA Linux end. *****/
1512 if (!udp_lport_inuse(result))
1513 break;
1514 }
1515 --- linux-2.6.15-53.75.orig/net/ipv6/tcp_ipv6.c
1516 +++ linux-2.6.15-53.75/net/ipv6/tcp_ipv6.c
1517 @@ -64,6 +64,9 @@
1518
1519 #include <linux/proc_fs.h>
1520 #include <linux/seq_file.h>
1521 +/***** SAKURA Linux start. *****/
1522 +#include <linux/sakura.h>
1523 +/***** SAKURA Linux end. *****/
1524
1525 static void tcp_v6_send_reset(struct sk_buff *skb);
1526 static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1527 @@ -119,6 +122,10 @@ static int tcp_v6_get_port(struct sock *
1528 do {
1529 head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1530 spin_lock(&head->lock);
1531 + /***** SAKURA Linux start. *****/
1532 + if (ccs_may_autobind(rover))
1533 + goto next;
1534 + /***** SAKURA Linux end. *****/
1535 inet_bind_bucket_for_each(tb, node, &head->chain)
1536 if (tb->port == rover)
1537 goto next;
1538 @@ -419,6 +426,10 @@ static int tcp_v6_hash_connect(struct so
1539 local_bh_disable();
1540 for (i = 1; i <= range; i++) {
1541 port = low + (i + offset) % range;
1542 + /***** SAKURA Linux start. *****/
1543 + if (ccs_may_autobind(port))
1544 + continue;
1545 + /***** SAKURA Linux end. *****/
1546 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1547 spin_lock(&head->lock);
1548
1549 --- linux-2.6.15-53.75.orig/net/ipv6/udp.c
1550 +++ linux-2.6.15-53.75/net/ipv6/udp.c
1551 @@ -58,6 +58,9 @@
1552
1553 #include <linux/proc_fs.h>
1554 #include <linux/seq_file.h>
1555 +/***** SAKURA Linux start. *****/
1556 +#include <linux/sakura.h>
1557 +/***** SAKURA Linux end. *****/
1558
1559 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1560
1561 @@ -88,6 +91,10 @@ static int udp_v6_get_port(struct sock *
1562 result = sysctl_local_port_range[0] +
1563 ((result - sysctl_local_port_range[0]) &
1564 (UDP_HTABLE_SIZE - 1));
1565 + /***** SAKURA Linux start. *****/
1566 + if (ccs_may_autobind(result))
1567 + continue;
1568 + /***** SAKURA Linux end. *****/
1569 goto gotit;
1570 }
1571 size = 0;
1572 @@ -104,6 +111,10 @@ static int udp_v6_get_port(struct sock *
1573 result = sysctl_local_port_range[0]
1574 + ((result - sysctl_local_port_range[0]) &
1575 (UDP_HTABLE_SIZE - 1));
1576 + /***** SAKURA Linux start. *****/
1577 + if (ccs_may_autobind(result))
1578 + continue;
1579 + /***** SAKURA Linux end. *****/
1580 if (!udp_lport_inuse(result))
1581 break;
1582 }
1583 --- linux-2.6.15-53.75.orig/net/socket.c
1584 +++ linux-2.6.15-53.75/net/socket.c
1585 @@ -97,6 +97,11 @@
1586 #include <net/sock.h>
1587 #include <linux/netfilter.h>
1588
1589 +/***** TOMOYO Linux start. *****/
1590 +#include <linux/tomoyo.h>
1591 +#include <linux/tomoyo_socket.h>
1592 +/***** TOMOYO Linux end. *****/
1593 +
1594 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1595 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1596 size_t size, loff_t pos);
1597 @@ -546,7 +551,12 @@ static inline int __sock_sendmsg(struct
1598 err = security_socket_sendmsg(sock, msg, size);
1599 if (err)
1600 return err;
1601 -
1602 + /***** TOMOYO Linux start. *****/
1603 + if (ccs_socket_sendmsg_permission(sock,
1604 + (struct sockaddr *) msg->msg_name,
1605 + msg->msg_namelen))
1606 + return -EPERM;
1607 + /***** TOMOYO Linux end. *****/
1608 return sock->ops->sendmsg(iocb, sock, msg, size);
1609 }
1610
1611 @@ -1099,6 +1109,12 @@ static int __sock_create(int family, int
1612 family = PF_PACKET;
1613 }
1614
1615 + /***** TOMOYO Linux start. *****/
1616 + err = ccs_socket_create_permission(family, type, protocol);
1617 + if (err)
1618 + return err;
1619 + /***** TOMOYO Linux end. *****/
1620 +
1621 err = security_socket_create(family, type, protocol, kern);
1622 if (err)
1623 return err;
1624 @@ -1296,6 +1312,12 @@ asmlinkage long sys_bind(int fd, struct
1625 sockfd_put(sock);
1626 return err;
1627 }
1628 + /***** TOMOYO Linux start. *****/
1629 + err = ccs_socket_bind_permission(sock,
1630 + (struct sockaddr *)
1631 + address, addrlen);
1632 + if (!err)
1633 + /***** TOMOYO Linux end. *****/
1634 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1635 }
1636 sockfd_put(sock);
1637 @@ -1326,7 +1348,10 @@ asmlinkage long sys_listen(int fd, int b
1638 sockfd_put(sock);
1639 return err;
1640 }
1641 -
1642 + /***** TOMOYO Linux start. *****/
1643 + err = ccs_socket_listen_permission(sock);
1644 + if (!err)
1645 + /***** TOMOYO Linux end. *****/
1646 err=sock->ops->listen(sock, backlog);
1647 sockfd_put(sock);
1648 }
1649 @@ -1377,6 +1402,13 @@ asmlinkage long sys_accept(int fd, struc
1650 if (err < 0)
1651 goto out_release;
1652
1653 + /***** TOMOYO Linux start. *****/
1654 + if (ccs_socket_accept_permission(newsock,
1655 + (struct sockaddr *) address)) {
1656 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1657 + goto out_release;
1658 + }
1659 + /***** TOMOYO Linux end. *****/
1660 if (upeer_sockaddr) {
1661 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1662 err = -ECONNABORTED;
1663 @@ -1432,7 +1464,12 @@ asmlinkage long sys_connect(int fd, stru
1664 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1665 if (err)
1666 goto out_put;
1667 -
1668 + /***** TOMOYO Linux start. *****/
1669 + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1670 + addrlen);
1671 + if (err)
1672 + goto out_put;
1673 + /***** TOMOYO Linux end. *****/
1674 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1675 sock->file->f_flags);
1676 out_put:
1677 --- linux-2.6.15-53.75.orig/net/unix/af_unix.c
1678 +++ linux-2.6.15-53.75/net/unix/af_unix.c
1679 @@ -117,6 +117,9 @@
1680 #include <linux/mount.h>
1681 #include <net/checksum.h>
1682 #include <linux/security.h>
1683 +/***** TOMOYO Linux start. *****/
1684 +#include <linux/tomoyo.h>
1685 +/***** TOMOYO Linux end. *****/
1686
1687 int sysctl_unix_max_dgram_qlen = 10;
1688
1689 @@ -738,6 +741,11 @@ static int unix_bind(struct socket *sock
1690 err = unix_autobind(sock);
1691 goto out;
1692 }
1693 + /***** TOMOYO Linux start. *****/
1694 + err = -EPERM;
1695 + if (sunaddr->sun_path[0] && !ccs_capable(CCS_CREATE_UNIX_SOCKET))
1696 + goto out;
1697 + /***** TOMOYO Linux end. *****/
1698
1699 err = unix_mkname(sunaddr, addr_len, &hash);
1700 if (err < 0)
1701 @@ -781,6 +789,13 @@ static int unix_bind(struct socket *sock
1702 */
1703 mode = S_IFSOCK |
1704 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1705 + /***** TOMOYO Linux start. *****/
1706 + err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
1707 + if (!err)
1708 + err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry,
1709 + nd.mnt);
1710 + if (!err)
1711 + /***** TOMOYO Linux end. *****/
1712 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1713 if (err)
1714 goto out_mknod_dput;

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