Open-Source-Software-Entwicklung und Downloads

Browse Subversion Repository

Contents of /trunk/1.5.x/ccs-patch/patches/ccs-patch-2.6.24.3-ubuntu1.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1191 - (show annotations) (download) (as text)
Fri May 9 01:46:04 2008 UTC (16 years ago) by kumaneko
File MIME type: text/x-diff
File size: 50962 byte(s)


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

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