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

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 2805 - (hide annotations) (download) (as text)
Mon Jul 27 02:00:55 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: 37535 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     kernel/signal.c | 13 +++++++++++++
36     kernel/sys.c | 11 +++++++++++
37     kernel/sysctl.c | 11 +++++++++++
38     kernel/time.c | 7 +++++++
39     net/ipv4/inet_connection_sock.c | 3 +++
40     net/ipv4/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 2805 43 files changed, 288 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 2796 + printk(KERN_INFO "Hook version: 2.6.15-54.77 2009/07/23\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 2796 @@ -2237,6 +2238,10 @@ 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 2282 + if (sig && !ccs_capable(CCS_SYS_KILL))
861 kumaneko 1498 + return -EPERM;
862     + if (sig && ccs_check_signal_acl(sig, pid))
863     + return -EPERM;
864    
865     info.si_signo = sig;
866     info.si_errno = 0;
867 kumaneko 2796 @@ -2295,6 +2300,10 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
868 kumaneko 1498 /* This is only valid for single tasks */
869     if (pid <= 0 || tgid <= 0)
870     return -EINVAL;
871 kumaneko 2282 + if (sig && !ccs_capable(CCS_SYS_KILL))
872 kumaneko 1498 + return -EPERM;
873     + if (sig && ccs_check_signal_acl(sig, pid))
874     + return -EPERM;
875    
876     return do_tkill(tgid, pid, sig);
877     }
878 kumaneko 2796 @@ -2307,6 +2316,10 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
879 kumaneko 1498 /* This is only valid for single tasks */
880     if (pid <= 0)
881     return -EINVAL;
882 kumaneko 2282 + if (sig && !ccs_capable(CCS_SYS_KILL))
883 kumaneko 1498 + return -EPERM;
884     + if (sig && ccs_check_signal_acl(sig, pid))
885     + return -EPERM;
886    
887     return do_tkill(0, pid, sig);
888     }
889 kumaneko 2721 --- linux-2.6.15-54.77.orig/kernel/sys.c
890     +++ linux-2.6.15-54.77/kernel/sys.c
891 kumaneko 2796 @@ -37,6 +37,7 @@
892 kumaneko 1498 #include <asm/uaccess.h>
893     #include <asm/io.h>
894     #include <asm/unistd.h>
895     +#include <linux/tomoyo.h>
896    
897     #ifndef SET_UNALIGN_CTL
898     # define SET_UNALIGN_CTL(a,b) (-EINVAL)
899 kumaneko 2796 @@ -256,6 +257,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
900 kumaneko 1498
901     if (which > 2 || which < 0)
902     goto out;
903 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE)) {
904 kumaneko 1498 + error = -EPERM;
905     + goto out;
906     + }
907    
908     /* normalize: avoid signed division (rounding problems) */
909     error = -ESRCH;
910 kumaneko 2796 @@ -484,6 +489,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
911 kumaneko 1498 magic2 != LINUX_REBOOT_MAGIC2B &&
912     magic2 != LINUX_REBOOT_MAGIC2C))
913     return -EINVAL;
914 kumaneko 2282 + if (!ccs_capable(CCS_SYS_REBOOT))
915 kumaneko 1498 + return -EPERM;
916    
917     lock_kernel();
918     switch (cmd) {
919 kumaneko 2796 @@ -1518,6 +1525,8 @@ SYSCALL_DEFINE2(sethostname, char __user
920 kumaneko 1498 return -EPERM;
921     if (len < 0 || len > __NEW_UTS_LEN)
922     return -EINVAL;
923 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
924 kumaneko 1498 + return -EPERM;
925     down_write(&uts_sem);
926     errno = -EFAULT;
927     if (!copy_from_user(tmp, name, len)) {
928 kumaneko 2796 @@ -1563,6 +1572,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
929 kumaneko 1498 return -EPERM;
930     if (len < 0 || len > __NEW_UTS_LEN)
931     return -EINVAL;
932 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
933 kumaneko 1498 + return -EPERM;
934    
935     down_write(&uts_sem);
936     errno = -EFAULT;
937 kumaneko 2721 --- linux-2.6.15-54.77.orig/kernel/sysctl.c
938     +++ linux-2.6.15-54.77/kernel/sysctl.c
939 kumaneko 2796 @@ -45,6 +45,7 @@
940 kumaneko 1498
941     #include <asm/uaccess.h>
942     #include <asm/processor.h>
943     +#include <linux/tomoyo.h>
944    
945     #ifdef CONFIG_ROOT_NFS
946     #include <linux/nfs_fs.h>
947 kumaneko 2796 @@ -1066,6 +1067,9 @@ int do_sysctl(int __user *name, int nlen
948 kumaneko 1498
949     spin_unlock(&sysctl_lock);
950    
951 kumaneko 2298 + error = ccs_parse_table(name, nlen, oldval, newval,
952 kumaneko 1498 + head->ctl_table);
953     + if (!error)
954     error = parse_table(name, nlen, oldval, oldlenp,
955     newval, newlen, head->ctl_table,
956     &context);
957 kumaneko 2796 @@ -1138,6 +1142,13 @@ repeat:
958 kumaneko 1498 if (ctl_perm(table, 001))
959     return -EPERM;
960     if (table->strategy) {
961     + int op = 0;
962     + if (oldval)
963     + op |= 004;
964     + if (newval)
965     + op |= 002;
966     + if (ctl_perm(table, op))
967     + return -EPERM;
968     error = table->strategy(
969     table, name, nlen,
970     oldval, oldlenp,
971 kumaneko 2721 --- linux-2.6.15-54.77.orig/kernel/time.c
972     +++ linux-2.6.15-54.77/kernel/time.c
973 kumaneko 2796 @@ -38,6 +38,7 @@
974 kumaneko 1498
975     #include <asm/uaccess.h>
976     #include <asm/unistd.h>
977     +#include <linux/tomoyo.h>
978    
979     /*
980     * The timezone where the local system is located. Used as a default by some
981 kumaneko 2796 @@ -90,6 +91,8 @@ SYSCALL_DEFINE1(stime, time_t __user *,
982 kumaneko 1498 err = security_settime(&tv, NULL);
983     if (err)
984     return err;
985 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
986 kumaneko 1498 + return -EPERM;
987    
988     do_settimeofday(&tv);
989     return 0;
990 kumaneko 2796 @@ -158,6 +161,8 @@ int do_sys_settimeofday(struct timespec
991 kumaneko 1498 error = security_settime(tv, tz);
992     if (error)
993     return error;
994 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
995 kumaneko 1498 + return -EPERM;
996    
997     if (tz) {
998     /* SMP safe, global irq locking makes it work. */
999 kumaneko 2796 @@ -236,6 +241,8 @@ int do_adjtimex(struct timex *txc)
1000 kumaneko 1498 /* In order to modify anything, you gotta be super-user! */
1001     if (txc->modes && !capable(CAP_SYS_TIME))
1002     return -EPERM;
1003 kumaneko 2282 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1004 kumaneko 1498 + return -EPERM;
1005    
1006     /* Now we validate the data before disabling interrupts */
1007    
1008 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/ipv4/inet_connection_sock.c
1009     +++ linux-2.6.15-54.77/net/ipv4/inet_connection_sock.c
1010 kumaneko 2796 @@ -24,6 +24,7 @@
1011 kumaneko 1498 #include <net/route.h>
1012     #include <net/tcp_states.h>
1013     #include <net/xfrm.h>
1014     +#include <linux/sakura.h>
1015    
1016     #ifdef INET_CSK_DEBUG
1017     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1018 kumaneko 2796 @@ -83,6 +84,8 @@ int inet_csk_get_port(struct inet_hashin
1019 kumaneko 1498 do {
1020     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1021     spin_lock(&head->lock);
1022 kumaneko 2299 + if (ccs_lport_reserved(rover))
1023 kumaneko 1498 + goto next;
1024     inet_bind_bucket_for_each(tb, node, &head->chain)
1025     if (tb->port == rover)
1026     goto next;
1027 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/ipv4/raw.c
1028     +++ linux-2.6.15-54.77/net/ipv4/raw.c
1029 kumaneko 2796 @@ -79,6 +79,7 @@
1030 kumaneko 2459 #include <linux/seq_file.h>
1031     #include <linux/netfilter.h>
1032     #include <linux/netfilter_ipv4.h>
1033     +#include <linux/tomoyo_socket.h>
1034    
1035     struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1036     DEFINE_RWLOCK(raw_v4_lock);
1037 kumaneko 2796 @@ -591,6 +592,9 @@ static int raw_recvmsg(struct kiocb *ioc
1038 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1039     if (!skb)
1040     goto out;
1041     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1042     + if (err)
1043     + goto out;
1044    
1045     copied = skb->len;
1046     if (len < copied) {
1047 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/ipv4/tcp_ipv4.c
1048     +++ linux-2.6.15-54.77/net/ipv4/tcp_ipv4.c
1049 kumaneko 2796 @@ -76,6 +76,7 @@
1050 kumaneko 1498 #include <linux/stddef.h>
1051     #include <linux/proc_fs.h>
1052     #include <linux/seq_file.h>
1053     +#include <linux/sakura.h>
1054    
1055     int sysctl_tcp_tw_reuse;
1056     int sysctl_tcp_low_latency;
1057 kumaneko 2796 @@ -243,6 +244,8 @@ static inline int tcp_v4_hash_connect(st
1058 kumaneko 1498 local_bh_disable();
1059     for (i = 1; i <= range; i++) {
1060     port = low + (i + offset) % range;
1061 kumaneko 2299 + if (ccs_lport_reserved(port))
1062 kumaneko 1498 + continue;
1063     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1064     spin_lock(&head->lock);
1065    
1066 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/ipv4/udp.c
1067     +++ linux-2.6.15-54.77/net/ipv4/udp.c
1068 kumaneko 2796 @@ -108,6 +108,8 @@
1069 kumaneko 1498 #include <net/inet_common.h>
1070     #include <net/checksum.h>
1071     #include <net/xfrm.h>
1072     +#include <linux/sakura.h>
1073 kumaneko 2459 +#include <linux/tomoyo_socket.h>
1074 kumaneko 1498
1075     /*
1076     * Snmp MIB for the UDP layer
1077 kumaneko 2796 @@ -146,6 +148,8 @@ static int udp_v4_get_port(struct sock *
1078 kumaneko 1498 result = sysctl_local_port_range[0] +
1079     ((result - sysctl_local_port_range[0]) &
1080     (UDP_HTABLE_SIZE - 1));
1081 kumaneko 2299 + if (ccs_lport_reserved(result))
1082 kumaneko 1498 + continue;
1083     goto gotit;
1084     }
1085     size = 0;
1086 kumaneko 2796 @@ -162,6 +166,8 @@ static int udp_v4_get_port(struct sock *
1087 kumaneko 1498 result = sysctl_local_port_range[0]
1088     + ((result - sysctl_local_port_range[0]) &
1089     (UDP_HTABLE_SIZE - 1));
1090 kumaneko 2299 + if (ccs_lport_reserved(result))
1091 kumaneko 1498 + continue;
1092     if (!udp_lport_inuse(result))
1093     break;
1094     }
1095 kumaneko 2796 @@ -796,7 +802,10 @@ try_again:
1096 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1097     if (!skb)
1098     goto out;
1099     -
1100     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1101     + if (err)
1102     + goto out;
1103     +
1104     copied = skb->len - sizeof(struct udphdr);
1105     if (copied > len) {
1106     copied = len;
1107 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/ipv6/raw.c
1108     +++ linux-2.6.15-54.77/net/ipv6/raw.c
1109 kumaneko 2796 @@ -56,6 +56,7 @@
1110 kumaneko 2459
1111     #include <linux/proc_fs.h>
1112     #include <linux/seq_file.h>
1113     +#include <linux/tomoyo_socket.h>
1114    
1115     struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1116     DEFINE_RWLOCK(raw_v6_lock);
1117 kumaneko 2796 @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1118 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1119     if (!skb)
1120     goto out;
1121     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1122     + if (err)
1123     + goto out;
1124    
1125     copied = skb->len;
1126     if (copied > len) {
1127 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/ipv6/tcp_ipv6.c
1128     +++ linux-2.6.15-54.77/net/ipv6/tcp_ipv6.c
1129 kumaneko 2796 @@ -64,6 +64,7 @@
1130 kumaneko 1498
1131     #include <linux/proc_fs.h>
1132     #include <linux/seq_file.h>
1133     +#include <linux/sakura.h>
1134    
1135     static void tcp_v6_send_reset(struct sk_buff *skb);
1136     static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1137 kumaneko 2796 @@ -119,6 +120,8 @@ static int tcp_v6_get_port(struct sock *
1138 kumaneko 1498 do {
1139     head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1140     spin_lock(&head->lock);
1141 kumaneko 2299 + if (ccs_lport_reserved(rover))
1142 kumaneko 1498 + goto next;
1143     inet_bind_bucket_for_each(tb, node, &head->chain)
1144     if (tb->port == rover)
1145     goto next;
1146 kumaneko 2796 @@ -419,6 +422,8 @@ static int tcp_v6_hash_connect(struct so
1147 kumaneko 1498 local_bh_disable();
1148     for (i = 1; i <= range; i++) {
1149     port = low + (i + offset) % range;
1150 kumaneko 2299 + if (ccs_lport_reserved(port))
1151 kumaneko 1498 + continue;
1152     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1153     spin_lock(&head->lock);
1154    
1155 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/ipv6/udp.c
1156     +++ linux-2.6.15-54.77/net/ipv6/udp.c
1157 kumaneko 2796 @@ -58,6 +58,8 @@
1158 kumaneko 1498
1159     #include <linux/proc_fs.h>
1160     #include <linux/seq_file.h>
1161     +#include <linux/sakura.h>
1162 kumaneko 2459 +#include <linux/tomoyo_socket.h>
1163 kumaneko 1498
1164     DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1165    
1166 kumaneko 2796 @@ -88,6 +90,8 @@ static int udp_v6_get_port(struct sock *
1167 kumaneko 1498 result = sysctl_local_port_range[0] +
1168     ((result - sysctl_local_port_range[0]) &
1169     (UDP_HTABLE_SIZE - 1));
1170 kumaneko 2299 + if (ccs_lport_reserved(result))
1171 kumaneko 1498 + continue;
1172     goto gotit;
1173     }
1174     size = 0;
1175 kumaneko 2796 @@ -104,6 +108,8 @@ static int udp_v6_get_port(struct sock *
1176 kumaneko 1498 result = sysctl_local_port_range[0]
1177     + ((result - sysctl_local_port_range[0]) &
1178     (UDP_HTABLE_SIZE - 1));
1179 kumaneko 2299 + if (ccs_lport_reserved(result))
1180 kumaneko 1498 + continue;
1181     if (!udp_lport_inuse(result))
1182     break;
1183     }
1184 kumaneko 2796 @@ -237,6 +243,9 @@ try_again:
1185 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1186     if (!skb)
1187     goto out;
1188     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1189     + if (err)
1190     + goto out;
1191    
1192     copied = skb->len - sizeof(struct udphdr);
1193     if (copied > len) {
1194 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/socket.c
1195     +++ linux-2.6.15-54.77/net/socket.c
1196 kumaneko 2796 @@ -97,6 +97,9 @@
1197 kumaneko 1498 #include <net/sock.h>
1198     #include <linux/netfilter.h>
1199    
1200     +#include <linux/tomoyo.h>
1201     +#include <linux/tomoyo_socket.h>
1202     +
1203     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1204     static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1205     size_t size, loff_t pos);
1206 kumaneko 2805 @@ -544,9 +547,12 @@ static inline int __sock_sendmsg(struct
1207     si->size = size;
1208    
1209 kumaneko 1498 err = security_socket_sendmsg(sock, msg, size);
1210 kumaneko 2805 + if (!err)
1211     + err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)
1212     + msg->msg_name,
1213     + msg->msg_namelen);
1214 kumaneko 1498 if (err)
1215     return err;
1216     -
1217     return sock->ops->sendmsg(iocb, sock, msg, size);
1218     }
1219    
1220 kumaneko 2805 @@ -1100,6 +1106,8 @@ static int __sock_create(int family, int
1221 kumaneko 1498 }
1222    
1223     err = security_socket_create(family, type, protocol, kern);
1224 kumaneko 2805 + if (!err)
1225     + err = ccs_socket_create_permission(family, type, protocol);
1226 kumaneko 1498 if (err)
1227     return err;
1228 kumaneko 2805
1229     @@ -1297,6 +1305,10 @@ SYSCALL_DEFINE3(bind, int, fd, struct so
1230 kumaneko 1498 sockfd_put(sock);
1231     return err;
1232     }
1233     + err = ccs_socket_bind_permission(sock,
1234     + (struct sockaddr *)
1235     + address, addrlen);
1236     + if (!err)
1237     err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1238     }
1239     sockfd_put(sock);
1240 kumaneko 2805 @@ -1327,7 +1339,8 @@ SYSCALL_DEFINE2(listen, int, fd, int, ba
1241 kumaneko 1498 sockfd_put(sock);
1242     return err;
1243     }
1244     -
1245     + err = ccs_socket_listen_permission(sock);
1246     + if (!err)
1247     err=sock->ops->listen(sock, backlog);
1248     sockfd_put(sock);
1249     }
1250 kumaneko 2805 @@ -1379,6 +1392,11 @@ SYSCALL_DEFINE3(accept, int, fd, struct
1251 kumaneko 1498 if (err < 0)
1252     goto out_release;
1253    
1254     + if (ccs_socket_accept_permission(newsock,
1255     + (struct sockaddr *) address)) {
1256     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1257     + goto out_release;
1258     + }
1259     if (upeer_sockaddr) {
1260     if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1261     err = -ECONNABORTED;
1262 kumaneko 2805 @@ -1433,9 +1451,11 @@ SYSCALL_DEFINE3(connect, int, fd, struct
1263     goto out_put;
1264    
1265 kumaneko 1498 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1266 kumaneko 2805 + if (!err)
1267     + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1268     + address, addrlen);
1269 kumaneko 1498 if (err)
1270     goto out_put;
1271     -
1272     err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1273     sock->file->f_flags);
1274     out_put:
1275 kumaneko 2721 --- linux-2.6.15-54.77.orig/net/unix/af_unix.c
1276     +++ linux-2.6.15-54.77/net/unix/af_unix.c
1277 kumaneko 2796 @@ -117,6 +117,7 @@
1278 kumaneko 1498 #include <linux/mount.h>
1279     #include <net/checksum.h>
1280     #include <linux/security.h>
1281     +#include <linux/tomoyo.h>
1282    
1283     int sysctl_unix_max_dgram_qlen = 10;
1284    
1285 kumaneko 2796 @@ -781,6 +782,9 @@ static int unix_bind(struct socket *sock
1286 kumaneko 1498 */
1287     mode = S_IFSOCK |
1288     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1289 kumaneko 2297 + err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
1290     + nd.mnt, mode, 0);
1291 kumaneko 1498 + if (!err)
1292     err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1293     if (err)
1294     goto out_mknod_dput;

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