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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2851 - (hide annotations) (download) (as text)
Wed Aug 5 04:58:04 2009 UTC (14 years, 9 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: 37334 byte(s)


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

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