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

Subversion リポジトリの参照

Annotation of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2858 - (hide annotations) (download) (as text)
Thu Aug 6 06:53:20 2009 UTC (14 years, 9 months ago) by kumaneko
Original Path: branches/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff
File MIME type: text/x-diff
File size: 37744 byte(s)


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

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