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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2279 - (show annotations) (download) (as text)
Wed Mar 18 09:16:37 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: 50738 byte(s)
Fix misplaced ccs_capable() for kernel 2.6.8 and kernel 2.6.9 . Add ccs_check_ioctl_permission() for TOMOYO 1.6.7 . 
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 | 9 +++
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, 691 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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_SYS_CHMOD))
320 + error = -EPERM;
321 + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
322 + !ccs_capable(TOMOYO_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(TOMOYO_SYS_CHMOD))
334 + error = -EPERM;
335 + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
336 + !ccs_capable(TOMOYO_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(TOMOYO_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->tomoyo_flags &
420 + TOMOYO_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(TOMOYO_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(TOMOYO_CREATE_CHAR_DEV))
553 + return -EPERM;
554 + if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV))
555 + return -EPERM;
556 + if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO))
557 + return -EPERM;
558 + if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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(TOMOYO_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 + .domain_info = &KERNEL_DOMAIN, \
942 + .tomoyo_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,11 @@
950
951 struct exec_domain;
952
953 +/***** TOMOYO Linux start. *****/
954 +struct domain_info;
955 +extern struct domain_info KERNEL_DOMAIN;
956 +/***** TOMOYO Linux end. *****/
957 +
958 /*
959 * cloning flags:
960 */
961 @@ -858,6 +863,10 @@ struct task_struct {
962 #endif
963 atomic_t fs_excl; /* holding fs exclusive resources */
964 struct list_head *scm_work_list;
965 + /***** TOMOYO Linux start. *****/
966 + struct domain_info *domain_info;
967 + u32 tomoyo_flags;
968 + /***** TOMOYO Linux end. *****/
969 };
970
971 static inline pid_t process_group(struct task_struct *tsk)
972 --- linux-2.6.15-53.75.orig/kernel/compat.c
973 +++ linux-2.6.15-53.75/kernel/compat.c
974 @@ -24,6 +24,9 @@
975
976 #include <asm/uaccess.h>
977 #include <asm/bug.h>
978 +/***** TOMOYO Linux start. *****/
979 +#include <linux/tomoyo.h>
980 +/***** TOMOYO Linux end. *****/
981
982 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
983 {
984 @@ -849,6 +852,10 @@ asmlinkage long compat_sys_stime(compat_
985 err = security_settime(&tv, NULL);
986 if (err)
987 return err;
988 + /***** TOMOYO Linux start. *****/
989 + if (!ccs_capable(TOMOYO_SYS_SETTIME))
990 + return -EPERM;
991 + /***** TOMOYO Linux end. *****/
992
993 do_settimeofday(&tv);
994 return 0;
995 --- linux-2.6.15-53.75.orig/kernel/kexec.c
996 +++ linux-2.6.15-53.75/kernel/kexec.c
997 @@ -25,6 +25,9 @@
998 #include <asm/io.h>
999 #include <asm/system.h>
1000 #include <asm/semaphore.h>
1001 +/***** TOMOYO Linux start. *****/
1002 +#include <linux/tomoyo.h>
1003 +/***** TOMOYO Linux end. *****/
1004
1005 /* Location of the reserved area for the crash kernel */
1006 struct resource crashk_res = {
1007 @@ -918,6 +921,10 @@ asmlinkage long sys_kexec_load(unsigned
1008 /* We only trust the superuser with rebooting the system. */
1009 if (!capable(CAP_SYS_BOOT))
1010 return -EPERM;
1011 + /***** TOMOYO Linux start. *****/
1012 + if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD))
1013 + return -EPERM;
1014 + /***** TOMOYO Linux end. *****/
1015
1016 /*
1017 * Verify we have a legal set of flags
1018 --- linux-2.6.15-53.75.orig/kernel/kmod.c
1019 +++ linux-2.6.15-53.75/kernel/kmod.c
1020 @@ -149,6 +149,11 @@ static int ____call_usermodehelper(void
1021 /* We can run anywhere, unlike our parent keventd(). */
1022 set_cpus_allowed(current, CPU_MASK_ALL);
1023
1024 + /***** TOMOYO Linux start. *****/
1025 + current->domain_info = &KERNEL_DOMAIN;
1026 + current->tomoyo_flags = 0;
1027 + /***** TOMOYO Linux end. *****/
1028 +
1029 retval = -EPERM;
1030 if (current->fs->root)
1031 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
1032 --- linux-2.6.15-53.75.orig/kernel/module.c
1033 +++ linux-2.6.15-53.75/kernel/module.c
1034 @@ -41,6 +41,9 @@
1035 #include <asm/uaccess.h>
1036 #include <asm/semaphore.h>
1037 #include <asm/cacheflush.h>
1038 +/***** TOMOYO Linux start. *****/
1039 +#include <linux/tomoyo.h>
1040 +/***** TOMOYO Linux end. *****/
1041
1042 #if 0
1043 #define DEBUGP printk
1044 @@ -577,7 +580,10 @@ sys_delete_module(const char __user *nam
1045
1046 if (!capable(CAP_SYS_MODULE))
1047 return -EPERM;
1048 -
1049 + /***** TOMOYO Linux start. *****/
1050 + if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1051 + return -EPERM;
1052 + /***** TOMOYO Linux end. *****/
1053 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
1054 return -EFAULT;
1055 name[MODULE_NAME_LEN-1] = '\0';
1056 @@ -1886,7 +1892,10 @@ sys_init_module(void __user *umod,
1057 /* Must have permission */
1058 if (!capable(CAP_SYS_MODULE))
1059 return -EPERM;
1060 -
1061 + /***** TOMOYO Linux start. *****/
1062 + if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE))
1063 + return -EPERM;
1064 + /***** TOMOYO Linux end. *****/
1065 /* Only one module load at a time, please */
1066 if (down_interruptible(&module_mutex) != 0)
1067 return -EINTR;
1068 --- linux-2.6.15-53.75.orig/kernel/ptrace.c
1069 +++ linux-2.6.15-53.75/kernel/ptrace.c
1070 @@ -20,6 +20,9 @@
1071
1072 #include <asm/pgtable.h>
1073 #include <asm/uaccess.h>
1074 +/***** TOMOYO Linux start. *****/
1075 +#include <linux/tomoyo.h>
1076 +/***** TOMOYO Linux end. *****/
1077
1078 /*
1079 * ptrace a task: make the debugger its new parent and
1080 @@ -492,6 +495,10 @@ asmlinkage long sys_ptrace(long request,
1081 /*
1082 * This lock_kernel fixes a subtle race with suid exec
1083 */
1084 + /***** TOMOYO Linux start. *****/
1085 + if (!ccs_capable(TOMOYO_SYS_PTRACE))
1086 + return -EPERM;
1087 + /***** TOMOYO Linux end. *****/
1088 lock_kernel();
1089 ret = ptrace_get_task_struct(request, pid, &child);
1090 if (!child)
1091 --- linux-2.6.15-53.75.orig/kernel/sched.c
1092 +++ linux-2.6.15-53.75/kernel/sched.c
1093 @@ -50,6 +50,9 @@
1094 #include <asm/tlb.h>
1095
1096 #include <asm/unistd.h>
1097 +/***** TOMOYO Linux start. *****/
1098 +#include <linux/tomoyo.h>
1099 +/***** TOMOYO Linux end. *****/
1100
1101 /*
1102 * Convert user-nice values [ -20 ... 0 ... 19 ]
1103 @@ -3603,6 +3606,10 @@ asmlinkage long sys_nice(int increment)
1104 {
1105 int retval;
1106 long nice;
1107 + /***** TOMOYO Linux start. *****/
1108 + if (!ccs_capable(TOMOYO_SYS_NICE))
1109 + return -EPERM;
1110 + /***** TOMOYO Linux end. *****/
1111
1112 /*
1113 * Setpriority might change our priority at the same moment.
1114 --- linux-2.6.15-53.75.orig/kernel/signal.c
1115 +++ linux-2.6.15-53.75/kernel/signal.c
1116 @@ -29,6 +29,9 @@
1117 #include <asm/uaccess.h>
1118 #include <asm/unistd.h>
1119 #include <asm/siginfo.h>
1120 +/***** TOMOYO Linux start. *****/
1121 +#include <linux/tomoyo.h>
1122 +/***** TOMOYO Linux end. *****/
1123
1124 /*
1125 * SLAB caches for signal bits.
1126 @@ -2241,6 +2244,12 @@ asmlinkage long
1127 sys_kill(int pid, int sig)
1128 {
1129 struct siginfo info;
1130 + /***** TOMOYO Linux start. *****/
1131 + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1132 + return -EPERM;
1133 + if (sig && ccs_check_signal_acl(sig, pid))
1134 + return -EPERM;
1135 + /***** TOMOYO Linux end. *****/
1136
1137 info.si_signo = sig;
1138 info.si_errno = 0;
1139 @@ -2299,6 +2308,12 @@ asmlinkage long sys_tgkill(int tgid, int
1140 /* This is only valid for single tasks */
1141 if (pid <= 0 || tgid <= 0)
1142 return -EINVAL;
1143 + /***** TOMOYO Linux start. *****/
1144 + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1145 + return -EPERM;
1146 + if (sig && ccs_check_signal_acl(sig, pid))
1147 + return -EPERM;
1148 + /***** TOMOYO Linux end. *****/
1149
1150 return do_tkill(tgid, pid, sig);
1151 }
1152 @@ -2312,6 +2327,12 @@ sys_tkill(int pid, int sig)
1153 /* This is only valid for single tasks */
1154 if (pid <= 0)
1155 return -EINVAL;
1156 + /***** TOMOYO Linux start. *****/
1157 + if (sig && !ccs_capable(TOMOYO_SYS_KILL))
1158 + return -EPERM;
1159 + if (sig && ccs_check_signal_acl(sig, pid))
1160 + return -EPERM;
1161 + /***** TOMOYO Linux end. *****/
1162
1163 return do_tkill(0, pid, sig);
1164 }
1165 --- linux-2.6.15-53.75.orig/kernel/sys.c
1166 +++ linux-2.6.15-53.75/kernel/sys.c
1167 @@ -37,6 +37,9 @@
1168 #include <asm/uaccess.h>
1169 #include <asm/io.h>
1170 #include <asm/unistd.h>
1171 +/***** TOMOYO Linux start. *****/
1172 +#include <linux/tomoyo.h>
1173 +/***** TOMOYO Linux end. *****/
1174
1175 #ifndef SET_UNALIGN_CTL
1176 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1177 @@ -256,6 +259,12 @@ asmlinkage long sys_setpriority(int whic
1178
1179 if (which > 2 || which < 0)
1180 goto out;
1181 + /***** TOMOYO Linux start. *****/
1182 + if (!ccs_capable(TOMOYO_SYS_NICE)) {
1183 + error = -EPERM;
1184 + goto out;
1185 + }
1186 + /***** TOMOYO Linux end. *****/
1187
1188 /* normalize: avoid signed division (rounding problems) */
1189 error = -ESRCH;
1190 @@ -483,6 +492,10 @@ asmlinkage long sys_reboot(int magic1, i
1191 magic2 != LINUX_REBOOT_MAGIC2B &&
1192 magic2 != LINUX_REBOOT_MAGIC2C))
1193 return -EINVAL;
1194 + /***** TOMOYO Linux start. *****/
1195 + if (!ccs_capable(TOMOYO_SYS_REBOOT))
1196 + return -EPERM;
1197 + /***** TOMOYO Linux end. *****/
1198
1199 lock_kernel();
1200 switch (cmd) {
1201 @@ -1515,6 +1528,10 @@ asmlinkage long sys_sethostname(char __u
1202 return -EPERM;
1203 if (len < 0 || len > __NEW_UTS_LEN)
1204 return -EINVAL;
1205 + /***** TOMOYO Linux start. *****/
1206 + if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1207 + return -EPERM;
1208 + /***** TOMOYO Linux end. *****/
1209 down_write(&uts_sem);
1210 errno = -EFAULT;
1211 if (!copy_from_user(tmp, name, len)) {
1212 @@ -1560,6 +1577,10 @@ asmlinkage long sys_setdomainname(char _
1213 return -EPERM;
1214 if (len < 0 || len > __NEW_UTS_LEN)
1215 return -EINVAL;
1216 + /***** TOMOYO Linux start. *****/
1217 + if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME))
1218 + return -EPERM;
1219 + /***** TOMOYO Linux end. *****/
1220
1221 down_write(&uts_sem);
1222 errno = -EFAULT;
1223 --- linux-2.6.15-53.75.orig/kernel/sysctl.c
1224 +++ linux-2.6.15-53.75/kernel/sysctl.c
1225 @@ -45,6 +45,9 @@
1226
1227 #include <asm/uaccess.h>
1228 #include <asm/processor.h>
1229 +/***** TOMOYO Linux start. *****/
1230 +#include <linux/tomoyo.h>
1231 +/***** TOMOYO Linux end. *****/
1232
1233 #ifdef CONFIG_ROOT_NFS
1234 #include <linux/nfs_fs.h>
1235 @@ -1041,6 +1044,100 @@ void __init sysctl_init(void)
1236 #endif
1237 }
1238
1239 +/***** TOMOYO Linux start. *****/
1240 +static int try_parse_table(int __user *name, int nlen, void __user *oldval,
1241 + void __user *newval, ctl_table *table)
1242 +{
1243 + int n;
1244 + int error = -ENOMEM;
1245 + int op = 0;
1246 + char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
1247 + if (oldval)
1248 + op |= 004;
1249 + if (newval)
1250 + op |= 002;
1251 + if (!op) { /* Neither read nor write */
1252 + error = 0;
1253 + goto out;
1254 + }
1255 + if (!buffer)
1256 + goto out;
1257 + memset(buffer, 0, PAGE_SIZE);
1258 + snprintf(buffer, PAGE_SIZE - 1, "/proc/sys");
1259 + repeat:
1260 + if (!nlen) {
1261 + error = -ENOTDIR;
1262 + goto out;
1263 + }
1264 + if (get_user(n, name)) {
1265 + error = -EFAULT;
1266 + goto out;
1267 + }
1268 + for ( ; table->ctl_name; table++) {
1269 + if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1270 + int pos = strlen(buffer);
1271 + const char *cp = table->procname;
1272 + error = -ENOMEM;
1273 + if (cp) {
1274 + if (pos + 1 >= PAGE_SIZE - 1)
1275 + goto out;
1276 + buffer[pos++] = '/';
1277 + while (*cp) {
1278 + const unsigned char c
1279 + = *(const unsigned char *) cp;
1280 + if (c == '\\') {
1281 + if (pos + 2 >= PAGE_SIZE - 1)
1282 + goto out;
1283 + buffer[pos++] = '\\';
1284 + buffer[pos++] = '\\';
1285 + } else if (c > ' ' && c < 127) {
1286 + if (pos + 1 >= PAGE_SIZE - 1)
1287 + goto out;
1288 + buffer[pos++] = c;
1289 + } else {
1290 + if (pos + 4 >= PAGE_SIZE - 1)
1291 + goto out;
1292 + buffer[pos++] = '\\';
1293 + buffer[pos++] = (c >> 6) + '0';
1294 + buffer[pos++] = ((c >> 3) & 7)
1295 + + '0';
1296 + buffer[pos++] = (c & 7) + '0';
1297 + }
1298 + cp++;
1299 + }
1300 + } else {
1301 + /* Assume nobody assigns "=\$=" for procname. */
1302 + snprintf(buffer + pos, PAGE_SIZE - pos - 1,
1303 + "/=%d=", table->ctl_name);
1304 + if (!memchr(buffer, '\0', PAGE_SIZE - 2))
1305 + goto out;
1306 + }
1307 + if (table->child) {
1308 + if (table->strategy) {
1309 + /* printk("sysctl='%s'\n", buffer); */
1310 + if (ccs_check_file_perm(buffer, op,
1311 + "sysctl")) {
1312 + error = -EPERM;
1313 + goto out;
1314 + }
1315 + }
1316 + name++;
1317 + nlen--;
1318 + table = table->child;
1319 + goto repeat;
1320 + }
1321 + /* printk("sysctl='%s'\n", buffer); */
1322 + error = ccs_check_file_perm(buffer, op, "sysctl");
1323 + goto out;
1324 + }
1325 + }
1326 + error = -ENOTDIR;
1327 + out:
1328 + kfree(buffer);
1329 + return error;
1330 +}
1331 +/***** TOMOYO Linux end. *****/
1332 +
1333 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1334 void __user *newval, size_t newlen)
1335 {
1336 @@ -1066,6 +1163,11 @@ int do_sysctl(int __user *name, int nlen
1337
1338 spin_unlock(&sysctl_lock);
1339
1340 + /***** TOMOYO Linux start. *****/
1341 + error = try_parse_table(name, nlen, oldval, newval,
1342 + head->ctl_table);
1343 + if (!error)
1344 + /***** TOMOYO Linux end. *****/
1345 error = parse_table(name, nlen, oldval, oldlenp,
1346 newval, newlen, head->ctl_table,
1347 &context);
1348 @@ -1138,6 +1240,15 @@ repeat:
1349 if (ctl_perm(table, 001))
1350 return -EPERM;
1351 if (table->strategy) {
1352 + /***** TOMOYO Linux start. *****/
1353 + int op = 0;
1354 + if (oldval)
1355 + op |= 004;
1356 + if (newval)
1357 + op |= 002;
1358 + if (ctl_perm(table, op))
1359 + return -EPERM;
1360 + /***** TOMOYO Linux end. *****/
1361 error = table->strategy(
1362 table, name, nlen,
1363 oldval, oldlenp,
1364 --- linux-2.6.15-53.75.orig/kernel/time.c
1365 +++ linux-2.6.15-53.75/kernel/time.c
1366 @@ -38,6 +38,9 @@
1367
1368 #include <asm/uaccess.h>
1369 #include <asm/unistd.h>
1370 +/***** TOMOYO Linux start. *****/
1371 +#include <linux/tomoyo.h>
1372 +/***** TOMOYO Linux end. *****/
1373
1374 /*
1375 * The timezone where the local system is located. Used as a default by some
1376 @@ -90,6 +93,10 @@ asmlinkage long sys_stime(time_t __user
1377 err = security_settime(&tv, NULL);
1378 if (err)
1379 return err;
1380 + /***** TOMOYO Linux start. *****/
1381 + if (!ccs_capable(TOMOYO_SYS_SETTIME))
1382 + return -EPERM;
1383 + /***** TOMOYO Linux end. *****/
1384
1385 do_settimeofday(&tv);
1386 return 0;
1387 @@ -157,6 +164,10 @@ int do_sys_settimeofday(struct timespec
1388 error = security_settime(tv, tz);
1389 if (error)
1390 return error;
1391 + /***** TOMOYO Linux start. *****/
1392 + if (!ccs_capable(TOMOYO_SYS_SETTIME))
1393 + return -EPERM;
1394 + /***** TOMOYO Linux end. *****/
1395
1396 if (tz) {
1397 /* SMP safe, global irq locking makes it work. */
1398 @@ -235,6 +246,10 @@ int do_adjtimex(struct timex *txc)
1399 /* In order to modify anything, you gotta be super-user! */
1400 if (txc->modes && !capable(CAP_SYS_TIME))
1401 return -EPERM;
1402 + /***** TOMOYO Linux start. *****/
1403 + if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME))
1404 + return -EPERM;
1405 + /***** TOMOYO Linux end. *****/
1406
1407 /* Now we validate the data before disabling interrupts */
1408
1409 --- linux-2.6.15-53.75.orig/net/core/datagram.c
1410 +++ linux-2.6.15-53.75/net/core/datagram.c
1411 @@ -55,6 +55,11 @@
1412 #include <net/sock.h>
1413 #include <net/tcp_states.h>
1414
1415 +/***** TOMOYO Linux start. *****/
1416 +#include <linux/tomoyo.h>
1417 +#include <linux/tomoyo_socket.h>
1418 +/***** TOMOYO Linux end. *****/
1419 +
1420 /*
1421 * Is a socket 'connection oriented' ?
1422 */
1423 @@ -177,6 +182,12 @@ struct sk_buff *skb_recv_datagram(struct
1424 } else
1425 skb = skb_dequeue(&sk->sk_receive_queue);
1426
1427 + /***** TOMOYO Linux start. *****/
1428 + error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1429 + if (error)
1430 + goto no_packet;
1431 + /***** TOMOYO Linux end. *****/
1432 +
1433 if (skb)
1434 return skb;
1435
1436 --- linux-2.6.15-53.75.orig/net/ipv4/inet_connection_sock.c
1437 +++ linux-2.6.15-53.75/net/ipv4/inet_connection_sock.c
1438 @@ -24,6 +24,9 @@
1439 #include <net/route.h>
1440 #include <net/tcp_states.h>
1441 #include <net/xfrm.h>
1442 +/***** SAKURA Linux start. *****/
1443 +#include <linux/sakura.h>
1444 +/***** SAKURA Linux end. *****/
1445
1446 #ifdef INET_CSK_DEBUG
1447 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1448 @@ -83,6 +86,10 @@ int inet_csk_get_port(struct inet_hashin
1449 do {
1450 head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1451 spin_lock(&head->lock);
1452 + /***** SAKURA Linux start. *****/
1453 + if (ccs_may_autobind(rover))
1454 + goto next;
1455 + /***** SAKURA Linux end. *****/
1456 inet_bind_bucket_for_each(tb, node, &head->chain)
1457 if (tb->port == rover)
1458 goto next;
1459 --- linux-2.6.15-53.75.orig/net/ipv4/tcp_ipv4.c
1460 +++ linux-2.6.15-53.75/net/ipv4/tcp_ipv4.c
1461 @@ -76,6 +76,9 @@
1462 #include <linux/stddef.h>
1463 #include <linux/proc_fs.h>
1464 #include <linux/seq_file.h>
1465 +/***** SAKURA Linux start. *****/
1466 +#include <linux/sakura.h>
1467 +/***** SAKURA Linux end. *****/
1468
1469 int sysctl_tcp_tw_reuse;
1470 int sysctl_tcp_low_latency;
1471 @@ -243,6 +246,10 @@ static inline int tcp_v4_hash_connect(st
1472 local_bh_disable();
1473 for (i = 1; i <= range; i++) {
1474 port = low + (i + offset) % range;
1475 + /***** SAKURA Linux start. *****/
1476 + if (ccs_may_autobind(port))
1477 + continue;
1478 + /***** SAKURA Linux end. *****/
1479 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1480 spin_lock(&head->lock);
1481
1482 --- linux-2.6.15-53.75.orig/net/ipv4/udp.c
1483 +++ linux-2.6.15-53.75/net/ipv4/udp.c
1484 @@ -108,6 +108,9 @@
1485 #include <net/inet_common.h>
1486 #include <net/checksum.h>
1487 #include <net/xfrm.h>
1488 +/***** SAKURA Linux start. *****/
1489 +#include <linux/sakura.h>
1490 +/***** SAKURA Linux end. *****/
1491
1492 /*
1493 * Snmp MIB for the UDP layer
1494 @@ -146,6 +149,10 @@ static int udp_v4_get_port(struct sock *
1495 result = sysctl_local_port_range[0] +
1496 ((result - sysctl_local_port_range[0]) &
1497 (UDP_HTABLE_SIZE - 1));
1498 + /***** SAKURA Linux start. *****/
1499 + if (ccs_may_autobind(result))
1500 + continue;
1501 + /***** SAKURA Linux end. *****/
1502 goto gotit;
1503 }
1504 size = 0;
1505 @@ -162,6 +169,10 @@ static int udp_v4_get_port(struct sock *
1506 result = sysctl_local_port_range[0]
1507 + ((result - sysctl_local_port_range[0]) &
1508 (UDP_HTABLE_SIZE - 1));
1509 + /***** SAKURA Linux start. *****/
1510 + if (ccs_may_autobind(result))
1511 + continue;
1512 + /***** SAKURA Linux end. *****/
1513 if (!udp_lport_inuse(result))
1514 break;
1515 }
1516 --- linux-2.6.15-53.75.orig/net/ipv6/tcp_ipv6.c
1517 +++ linux-2.6.15-53.75/net/ipv6/tcp_ipv6.c
1518 @@ -64,6 +64,9 @@
1519
1520 #include <linux/proc_fs.h>
1521 #include <linux/seq_file.h>
1522 +/***** SAKURA Linux start. *****/
1523 +#include <linux/sakura.h>
1524 +/***** SAKURA Linux end. *****/
1525
1526 static void tcp_v6_send_reset(struct sk_buff *skb);
1527 static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1528 @@ -119,6 +122,10 @@ static int tcp_v6_get_port(struct sock *
1529 do {
1530 head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1531 spin_lock(&head->lock);
1532 + /***** SAKURA Linux start. *****/
1533 + if (ccs_may_autobind(rover))
1534 + goto next;
1535 + /***** SAKURA Linux end. *****/
1536 inet_bind_bucket_for_each(tb, node, &head->chain)
1537 if (tb->port == rover)
1538 goto next;
1539 @@ -419,6 +426,10 @@ static int tcp_v6_hash_connect(struct so
1540 local_bh_disable();
1541 for (i = 1; i <= range; i++) {
1542 port = low + (i + offset) % range;
1543 + /***** SAKURA Linux start. *****/
1544 + if (ccs_may_autobind(port))
1545 + continue;
1546 + /***** SAKURA Linux end. *****/
1547 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1548 spin_lock(&head->lock);
1549
1550 --- linux-2.6.15-53.75.orig/net/ipv6/udp.c
1551 +++ linux-2.6.15-53.75/net/ipv6/udp.c
1552 @@ -58,6 +58,9 @@
1553
1554 #include <linux/proc_fs.h>
1555 #include <linux/seq_file.h>
1556 +/***** SAKURA Linux start. *****/
1557 +#include <linux/sakura.h>
1558 +/***** SAKURA Linux end. *****/
1559
1560 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1561
1562 @@ -88,6 +91,10 @@ static int udp_v6_get_port(struct sock *
1563 result = sysctl_local_port_range[0] +
1564 ((result - sysctl_local_port_range[0]) &
1565 (UDP_HTABLE_SIZE - 1));
1566 + /***** SAKURA Linux start. *****/
1567 + if (ccs_may_autobind(result))
1568 + continue;
1569 + /***** SAKURA Linux end. *****/
1570 goto gotit;
1571 }
1572 size = 0;
1573 @@ -104,6 +111,10 @@ static int udp_v6_get_port(struct sock *
1574 result = sysctl_local_port_range[0]
1575 + ((result - sysctl_local_port_range[0]) &
1576 (UDP_HTABLE_SIZE - 1));
1577 + /***** SAKURA Linux start. *****/
1578 + if (ccs_may_autobind(result))
1579 + continue;
1580 + /***** SAKURA Linux end. *****/
1581 if (!udp_lport_inuse(result))
1582 break;
1583 }
1584 --- linux-2.6.15-53.75.orig/net/socket.c
1585 +++ linux-2.6.15-53.75/net/socket.c
1586 @@ -97,6 +97,11 @@
1587 #include <net/sock.h>
1588 #include <linux/netfilter.h>
1589
1590 +/***** TOMOYO Linux start. *****/
1591 +#include <linux/tomoyo.h>
1592 +#include <linux/tomoyo_socket.h>
1593 +/***** TOMOYO Linux end. *****/
1594 +
1595 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1596 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1597 size_t size, loff_t pos);
1598 @@ -546,7 +551,12 @@ static inline int __sock_sendmsg(struct
1599 err = security_socket_sendmsg(sock, msg, size);
1600 if (err)
1601 return err;
1602 -
1603 + /***** TOMOYO Linux start. *****/
1604 + if (ccs_socket_sendmsg_permission(sock,
1605 + (struct sockaddr *) msg->msg_name,
1606 + msg->msg_namelen))
1607 + return -EPERM;
1608 + /***** TOMOYO Linux end. *****/
1609 return sock->ops->sendmsg(iocb, sock, msg, size);
1610 }
1611
1612 @@ -1099,6 +1109,12 @@ static int __sock_create(int family, int
1613 family = PF_PACKET;
1614 }
1615
1616 + /***** TOMOYO Linux start. *****/
1617 + err = ccs_socket_create_permission(family, type, protocol);
1618 + if (err)
1619 + return err;
1620 + /***** TOMOYO Linux end. *****/
1621 +
1622 err = security_socket_create(family, type, protocol, kern);
1623 if (err)
1624 return err;
1625 @@ -1296,6 +1312,12 @@ asmlinkage long sys_bind(int fd, struct
1626 sockfd_put(sock);
1627 return err;
1628 }
1629 + /***** TOMOYO Linux start. *****/
1630 + err = ccs_socket_bind_permission(sock,
1631 + (struct sockaddr *)
1632 + address, addrlen);
1633 + if (!err)
1634 + /***** TOMOYO Linux end. *****/
1635 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1636 }
1637 sockfd_put(sock);
1638 @@ -1326,7 +1348,10 @@ asmlinkage long sys_listen(int fd, int b
1639 sockfd_put(sock);
1640 return err;
1641 }
1642 -
1643 + /***** TOMOYO Linux start. *****/
1644 + err = ccs_socket_listen_permission(sock);
1645 + if (!err)
1646 + /***** TOMOYO Linux end. *****/
1647 err=sock->ops->listen(sock, backlog);
1648 sockfd_put(sock);
1649 }
1650 @@ -1377,6 +1402,13 @@ asmlinkage long sys_accept(int fd, struc
1651 if (err < 0)
1652 goto out_release;
1653
1654 + /***** TOMOYO Linux start. *****/
1655 + if (ccs_socket_accept_permission(newsock,
1656 + (struct sockaddr *) address)) {
1657 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1658 + goto out_release;
1659 + }
1660 + /***** TOMOYO Linux end. *****/
1661 if (upeer_sockaddr) {
1662 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1663 err = -ECONNABORTED;
1664 @@ -1432,7 +1464,12 @@ asmlinkage long sys_connect(int fd, stru
1665 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1666 if (err)
1667 goto out_put;
1668 -
1669 + /***** TOMOYO Linux start. *****/
1670 + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1671 + addrlen);
1672 + if (err)
1673 + goto out_put;
1674 + /***** TOMOYO Linux end. *****/
1675 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1676 sock->file->f_flags);
1677 out_put:
1678 --- linux-2.6.15-53.75.orig/net/unix/af_unix.c
1679 +++ linux-2.6.15-53.75/net/unix/af_unix.c
1680 @@ -117,6 +117,9 @@
1681 #include <linux/mount.h>
1682 #include <net/checksum.h>
1683 #include <linux/security.h>
1684 +/***** TOMOYO Linux start. *****/
1685 +#include <linux/tomoyo.h>
1686 +/***** TOMOYO Linux end. *****/
1687
1688 int sysctl_unix_max_dgram_qlen = 10;
1689
1690 @@ -738,6 +741,11 @@ static int unix_bind(struct socket *sock
1691 err = unix_autobind(sock);
1692 goto out;
1693 }
1694 + /***** TOMOYO Linux start. *****/
1695 + err = -EPERM;
1696 + if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET))
1697 + goto out;
1698 + /***** TOMOYO Linux end. *****/
1699
1700 err = unix_mkname(sunaddr, addr_len, &hash);
1701 if (err < 0)
1702 @@ -781,6 +789,13 @@ static int unix_bind(struct socket *sock
1703 */
1704 mode = S_IFSOCK |
1705 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1706 + /***** TOMOYO Linux start. *****/
1707 + err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode);
1708 + if (!err)
1709 + err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry,
1710 + nd.mnt);
1711 + if (!err)
1712 + /***** TOMOYO Linux end. *****/
1713 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1714 if (err)
1715 goto out_mknod_dput;

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