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

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 3054 - (hide annotations) (download) (as text)
Fri Sep 18 04:30:43 2009 UTC (14 years, 8 months ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff
File MIME type: text/x-diff
File size: 39315 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/attr.c | 5 +++++
16     fs/compat.c | 9 ++++++++-
17     fs/exec.c | 12 +++++++++++-
18     fs/fcntl.c | 4 ++++
19     fs/ioctl.c | 5 +++++
20 kumaneko 2922 fs/namei.c | 32 ++++++++++++++++++++++++++++++++
21 kumaneko 3052 fs/namespace.c | 23 ++++++++++++++++++++++-
22 kumaneko 2950 fs/open.c | 29 ++++++++++++++++++++++++++++-
23 kumaneko 2796 fs/proc/proc_misc.c | 1 +
24 kumaneko 2926 include/linux/init_task.h | 9 +++++++++
25     include/linux/sched.h | 6 ++++++
26 kumaneko 2796 kernel/compat.c | 3 +++
27     kernel/kexec.c | 3 +++
28 kumaneko 2926 kernel/kmod.c | 5 +++++
29 kumaneko 2796 kernel/module.c | 7 +++++--
30     kernel/ptrace.c | 3 +++
31     kernel/sched.c | 3 +++
32 kumaneko 2869 kernel/signal.c | 9 +++++++++
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/raw.c | 4 ++++
38     net/ipv4/tcp_ipv4.c | 3 +++
39 kumaneko 2859 net/ipv4/udp.c | 10 +++++++++-
40 kumaneko 2796 net/ipv6/raw.c | 4 ++++
41     net/ipv6/tcp_ipv6.c | 5 +++++
42 kumaneko 2859 net/ipv6/udp.c | 8 ++++++++
43     net/socket.c | 25 ++++++++++++++++++++++---
44 kumaneko 2796 net/unix/af_unix.c | 4 ++++
45 kumaneko 2858 security/Kconfig | 2 ++
46     security/Makefile | 3 +++
47 kumaneko 3052 42 files changed, 292 insertions(+), 10 deletions(-)
48 kumaneko 1498
49 kumaneko 2927 --- linux-2.6.15-54.79.orig/arch/alpha/kernel/ptrace.c
50     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
56 kumaneko 1498
57     #include "proto.h"
58    
59 kumaneko 2796 @@ -261,6 +262,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 2927 --- linux-2.6.15-54.79.orig/arch/ia64/ia32/sys_ia32.c
69     +++ linux-2.6.15-54.79/arch/ia64/ia32/sys_ia32.c
70 kumaneko 2796 @@ -57,6 +57,7 @@
71 kumaneko 1498 #include <asm/types.h>
72     #include <asm/uaccess.h>
73     #include <asm/unistd.h>
74 kumaneko 2859 +#include <linux/ccsecurity.h>
75 kumaneko 1498
76     #include "ia32priv.h"
77    
78 kumaneko 2796 @@ -1758,6 +1759,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 2927 --- linux-2.6.15-54.79.orig/arch/ia64/kernel/ptrace.c
88     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
94 kumaneko 1498
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 2927 --- linux-2.6.15-54.79.orig/arch/m32r/kernel/ptrace.c
107     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
113 kumaneko 1498
114     /*
115     * Get the address of the live pt_regs for the specified task.
116 kumaneko 2796 @@ -760,6 +761,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     ret = -EPERM;
125 kumaneko 2927 --- linux-2.6.15-54.79.orig/arch/mips/kernel/ptrace32.c
126     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
132 kumaneko 1498
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 2927 --- linux-2.6.15-54.79.orig/arch/powerpc/kernel/ptrace32.c
145     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
151 kumaneko 1498
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 = -EPERM;
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 2927 --- linux-2.6.15-54.79.orig/arch/s390/kernel/ptrace.c
164     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
170 kumaneko 1498
171     #ifdef CONFIG_S390_SUPPORT
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    
181     if (request == PTRACE_TRACEME) {
182 kumaneko 2927 --- linux-2.6.15-54.79.orig/arch/sparc/kernel/ptrace.c
183     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
189 kumaneko 1498
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 2927 --- linux-2.6.15-54.79.orig/arch/sparc64/kernel/ptrace.c
204     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
210 kumaneko 1498
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 @@ -176,6 +177,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 2927 --- linux-2.6.15-54.79.orig/arch/x86_64/ia32/ptrace32.c
225     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
231 kumaneko 1498
232     /* determines which flags the user has access to. */
233     /* 1 = access 0 = no access */
234 kumaneko 2796 @@ -233,6 +234,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 2927 --- linux-2.6.15-54.79.orig/fs/attr.c
244     +++ linux-2.6.15-54.79/fs/attr.c
245 kumaneko 2796 @@ -15,6 +15,7 @@
246 kumaneko 1498 #include <linux/quotaops.h>
247     #include <linux/security.h>
248     #include <linux/time.h>
249 kumaneko 2859 +#include <linux/ccsecurity.h>
250 kumaneko 1498
251     /* Taken over from the old code... */
252    
253 kumaneko 2796 @@ -154,11 +155,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 kumaneko 2922 + error = ccs_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 kumaneko 2922 + error = ccs_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 2927 --- linux-2.6.15-54.79.orig/fs/compat.c
270     +++ linux-2.6.15-54.79/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 kumaneko 2859 +#include <linux/ccsecurity.h>
276 kumaneko 1498
277     /*
278     * Not all architectures have sys_utime, so implement this in terms
279 kumaneko 2796 @@ -353,6 +354,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 @@ -377,6 +380,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 @@ -1480,7 +1487,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 2927 --- linux-2.6.15-54.79.orig/fs/exec.c
309     +++ linux-2.6.15-54.79/fs/exec.c
310 kumaneko 2796 @@ -57,6 +57,8 @@
311 kumaneko 1498 #include <linux/kmod.h>
312     #endif
313    
314 kumaneko 2859 +#include <linux/ccsecurity.h>
315 kumaneko 1498 +
316     int core_uses_pid;
317     char core_pattern[65] = "core";
318     int suid_dumpable = 0;
319 kumaneko 2796 @@ -139,6 +141,10 @@ SYSCALL_DEFINE1(uselib, const char __use
320 kumaneko 1498 if (error)
321     goto exit;
322    
323 kumaneko 2922 + error = ccs_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 kumaneko 2922 + err = ccs_open_exec_permission(nd.dentry,
336 kumaneko 2306 + nd.mnt);
337 kumaneko 1498 file = ERR_PTR(err);
338     if (!err) {
339     file = nameidata_to_filp(&nd, O_RDONLY);
340 kumaneko 2796 @@ -1197,7 +1206,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 2927 --- linux-2.6.15-54.79.orig/fs/fcntl.c
351     +++ linux-2.6.15-54.79/fs/fcntl.c
352 kumaneko 2796 @@ -21,6 +21,7 @@
353 kumaneko 1498 #include <asm/poll.h>
354     #include <asm/siginfo.h>
355     #include <asm/uaccess.h>
356 kumaneko 2859 +#include <linux/ccsecurity.h>
357 kumaneko 1498
358     void fastcall set_close_on_exec(unsigned int fd, int flag)
359     {
360 kumaneko 2796 @@ -211,6 +212,9 @@ static int setfl(int fd, struct file * f
361 kumaneko 1498 if (!(arg & O_APPEND) && IS_APPEND(inode))
362     return -EPERM;
363    
364 kumaneko 2922 + if (!(arg & O_APPEND) && ccs_rewrite_permission(filp))
365 kumaneko 1498 + return -EPERM;
366     +
367     /* O_NOATIME can only be set by the owner or superuser */
368     if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
369     if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
370 kumaneko 2927 --- linux-2.6.15-54.79.orig/fs/ioctl.c
371     +++ linux-2.6.15-54.79/fs/ioctl.c
372 kumaneko 2796 @@ -15,6 +15,7 @@
373 kumaneko 1498
374     #include <asm/uaccess.h>
375     #include <asm/ioctls.h>
376 kumaneko 2859 +#include <linux/ccsecurity.h>
377 kumaneko 1498
378     static long do_ioctl(struct file *filp, unsigned int cmd,
379     unsigned long arg)
380 kumaneko 2796 @@ -23,6 +24,8 @@ static long do_ioctl(struct file *filp,
381 kumaneko 1498
382     if (!filp->f_op)
383     goto out;
384 kumaneko 2282 + if (!ccs_capable(CCS_SYS_IOCTL))
385 kumaneko 1498 + return -EPERM;
386    
387     if (filp->f_op->unlocked_ioctl) {
388     error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
389 kumaneko 2796 @@ -167,6 +170,8 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd,
390 kumaneko 2279 goto out;
391    
392     error = security_file_ioctl(filp, cmd, arg);
393     + if (!error)
394 kumaneko 2922 + error = ccs_ioctl_permission(filp, cmd, arg);
395 kumaneko 2279 if (error)
396     goto out_fput;
397    
398 kumaneko 2927 --- linux-2.6.15-54.79.orig/fs/namei.c
399     +++ linux-2.6.15-54.79/fs/namei.c
400 kumaneko 2796 @@ -34,6 +34,8 @@
401 kumaneko 1498
402     #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
403    
404 kumaneko 2859 +#include <linux/ccsecurity.h>
405 kumaneko 1498 +
406     /* [Feb-1997 T. Schoebel-Theuer]
407     * Fundamental changes in the pathname lookup mechanisms (namei)
408     * were necessary because of omirr. The reason is that omirr needs
409 kumaneko 2796 @@ -1488,6 +1490,11 @@ int may_open(struct nameidata *nd, int a
410 kumaneko 1498 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
411     return -EPERM;
412    
413     + /* includes O_APPEND and O_TRUNC checks */
414 kumaneko 2922 + error = ccs_open_permission(dentry, nd->mnt, flag);
415 kumaneko 1498 + if (error)
416     + return error;
417     +
418     /*
419     * Ensure there are no outstanding leases on the file.
420     */
421 kumaneko 2796 @@ -1519,6 +1526,7 @@ int may_open(struct nameidata *nd, int a
422 kumaneko 1498 return 0;
423     }
424    
425 kumaneko 2859 +#include <linux/ccsecurity_vfs.h>
426 kumaneko 1498 /*
427     * open_namei()
428     *
429 kumaneko 2796 @@ -1594,6 +1602,9 @@ do_last:
430 kumaneko 2297 if (!path.dentry->d_inode) {
431     if (!IS_POSIXACL(dir->d_inode))
432     mode &= ~current->fs->umask;
433 kumaneko 2922 + error = ccs_mknod_permission(dir->d_inode, path.dentry,
434     + nd->mnt, mode, 0);
435 kumaneko 2297 + if (!error)
436     error = vfs_create(dir->d_inode, path.dentry, mode, nd);
437     up(&dir->d_inode->i_sem);
438     dput(nd->dentry);
439 kumaneko 2922 @@ -1781,6 +1792,9 @@ SYSCALL_DEFINE3(mknod, const char __user
440 kumaneko 2297 if (!IS_POSIXACL(nd.dentry->d_inode))
441     mode &= ~current->fs->umask;
442     if (!IS_ERR(dentry)) {
443 kumaneko 2922 + error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
444     + nd.mnt, mode, dev);
445 kumaneko 2297 + if (!error)
446     switch (mode & S_IFMT) {
447     case 0: case S_IFREG:
448 kumaneko 1498 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
449 kumaneko 2922 @@ -1849,6 +1863,9 @@ SYSCALL_DEFINE2(mkdir, const char __user
450 kumaneko 1498 if (!IS_ERR(dentry)) {
451     if (!IS_POSIXACL(nd.dentry->d_inode))
452     mode &= ~current->fs->umask;
453 kumaneko 2922 + error = ccs_mkdir_permission(nd.dentry->d_inode,
454     + dentry, nd.mnt, mode);
455 kumaneko 1498 + if (!error)
456     error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
457     dput(dentry);
458     }
459 kumaneko 2922 @@ -1952,6 +1969,9 @@ SYSCALL_DEFINE1(rmdir, const char __user
460 kumaneko 1498 dentry = lookup_hash(&nd);
461     error = PTR_ERR(dentry);
462     if (!IS_ERR(dentry)) {
463 kumaneko 2922 + error = ccs_rmdir_permission(nd.dentry->d_inode, dentry,
464     + nd.mnt);
465 kumaneko 1498 + if (!error)
466     error = vfs_rmdir(nd.dentry->d_inode, dentry);
467     dput(dentry);
468     }
469 kumaneko 2922 @@ -2027,6 +2047,9 @@ SYSCALL_DEFINE1(unlink, const char __use
470 kumaneko 1498 inode = dentry->d_inode;
471     if (inode)
472     atomic_inc(&inode->i_count);
473 kumaneko 2922 + error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
474     + nd.mnt);
475 kumaneko 2297 + if (!error)
476 kumaneko 1498 error = vfs_unlink(nd.dentry->d_inode, dentry);
477     exit2:
478     dput(dentry);
479 kumaneko 2922 @@ -2089,6 +2112,9 @@ SYSCALL_DEFINE2(symlink, const char __us
480 kumaneko 1498 dentry = lookup_create(&nd, 0);
481     error = PTR_ERR(dentry);
482     if (!IS_ERR(dentry)) {
483 kumaneko 2922 + error = ccs_symlink_permission(nd.dentry->d_inode,
484     + dentry, nd.mnt, from);
485 kumaneko 1498 + if (!error)
486     error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
487     dput(dentry);
488     }
489 kumaneko 2922 @@ -2172,6 +2198,9 @@ SYSCALL_DEFINE2(link, const char __user
490 kumaneko 1498 new_dentry = lookup_create(&nd, 0);
491     error = PTR_ERR(new_dentry);
492     if (!IS_ERR(new_dentry)) {
493 kumaneko 2922 + error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode,
494     + new_dentry, nd.mnt);
495 kumaneko 1498 + if (!error)
496     error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
497     dput(new_dentry);
498     }
499 kumaneko 2922 @@ -2392,6 +2421,9 @@ static inline int do_rename(const char *
500 kumaneko 1498 if (new_dentry == trap)
501     goto exit5;
502    
503 kumaneko 2922 + error = ccs_rename_permission(old_dir->d_inode, old_dentry,
504     + new_dir->d_inode, new_dentry, newnd.mnt);
505 kumaneko 2297 + if (!error)
506 kumaneko 1498 error = vfs_rename(old_dir->d_inode, old_dentry,
507     new_dir->d_inode, new_dentry);
508     exit5:
509 kumaneko 2927 --- linux-2.6.15-54.79.orig/fs/namespace.c
510     +++ linux-2.6.15-54.79/fs/namespace.c
511 kumaneko 2859 @@ -25,6 +25,7 @@
512 kumaneko 1498 #include <asm/uaccess.h>
513     #include <asm/unistd.h>
514     #include "pnode.h"
515 kumaneko 2859 +#include <linux/ccsecurity.h>
516 kumaneko 1498
517     extern int __init init_rootfs(void);
518    
519 kumaneko 3052 @@ -501,6 +502,8 @@ static int do_umount(struct vfsmount *mn
520     LIST_HEAD(umount_list);
521    
522     retval = security_sb_umount(mnt, flags);
523     + if (!retval)
524     + retval = ccs_umount_permission(mnt, flags);
525 kumaneko 1498 if (retval)
526     return retval;
527    
528 kumaneko 3052 @@ -592,6 +595,8 @@ SYSCALL_DEFINE2(umount, char __user *, n
529 kumaneko 1498 {
530     struct nameidata nd;
531     int retval;
532 kumaneko 2282 + if (!ccs_capable(CCS_SYS_UMOUNT))
533 kumaneko 1498 + return -EPERM;
534    
535     retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
536     if (retval)
537 kumaneko 3052 @@ -879,6 +884,9 @@ static int do_loopback(struct nameidata
538 kumaneko 1498
539     if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
540     goto out;
541     + err = -EPERM;
542     + if (ccs_may_mount(nd))
543     + goto out;
544    
545     err = -ENOMEM;
546     if (recurse)
547 kumaneko 3052 @@ -963,7 +971,9 @@ static int do_move_mount(struct nameidat
548 kumaneko 1498 err = -EINVAL;
549     if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
550     goto out;
551     -
552     + err = -EPERM;
553 kumaneko 3009 + if (ccs_may_mount(nd))
554 kumaneko 1498 + goto out;
555     err = -ENOENT;
556     down(&nd->dentry->d_inode->i_sem);
557     if (IS_DEADDIR(nd->dentry->d_inode))
558 kumaneko 3052 @@ -1065,6 +1075,9 @@ int do_add_mount(struct vfsmount *newmnt
559 kumaneko 1498 err = -EINVAL;
560     if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
561     goto unlock;
562     + err = -EPERM;
563     + if (ccs_may_mount(nd))
564     + goto unlock;
565    
566     newmnt->mnt_flags = mnt_flags;
567     if ((err = graft_tree(newmnt, nd)))
568 kumaneko 3052 @@ -1264,6 +1277,7 @@ int copy_mount_options(const void __user
569     long do_mount(char *dev_name, char *dir_name, char *type_page,
570     unsigned long flags, void *data_page)
571     {
572     + const unsigned long original_flags = flags;
573     struct nameidata nd;
574     int retval = 0;
575     int mnt_flags = 0;
576     @@ -1297,6 +1311,9 @@ long do_mount(char *dev_name, char *dir_
577     return retval;
578 kumaneko 1498
579 kumaneko 3052 retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
580     + if (!retval)
581     + retval = ccs_mount_permission(dev_name, &nd, type_page,
582     + original_flags, data_page);
583     if (retval)
584     goto dput_out;
585 kumaneko 1498
586 kumaneko 3052 @@ -1545,6 +1562,8 @@ SYSCALL_DEFINE2(pivot_root, const char _
587    
588 kumaneko 1498 if (!capable(CAP_SYS_ADMIN))
589     return -EPERM;
590 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
591 kumaneko 1498 + return -EPERM;
592    
593     lock_kernel();
594    
595 kumaneko 3052 @@ -1561,6 +1580,8 @@ SYSCALL_DEFINE2(pivot_root, const char _
596 kumaneko 1498 goto out1;
597    
598     error = security_sb_pivotroot(&old_nd, &new_nd);
599     + if (!error)
600 kumaneko 2922 + error = ccs_pivot_root_permission(&old_nd, &new_nd);
601 kumaneko 1498 if (error) {
602     path_release(&old_nd);
603     goto out1;
604 kumaneko 2927 --- linux-2.6.15-54.79.orig/fs/open.c
605     +++ linux-2.6.15-54.79/fs/open.c
606 kumaneko 2859 @@ -28,6 +28,8 @@
607 kumaneko 1498
608     #include <asm/unistd.h>
609    
610 kumaneko 2859 +#include <linux/ccsecurity.h>
611 kumaneko 1498 +
612     int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
613     {
614     int retval = -ENODEV;
615 kumaneko 2859 @@ -287,6 +289,8 @@ static inline long do_sys_truncate(const
616 kumaneko 1498 if (error)
617     goto dput_and_out;
618    
619 kumaneko 2922 + error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
620 kumaneko 1498 + if (!error)
621     error = locks_verify_truncate(inode, NULL, length);
622     if (!error) {
623     DQUOT_INIT(inode);
624 kumaneko 2922 @@ -339,7 +343,9 @@ static inline long do_sys_ftruncate(unsi
625 kumaneko 1498 error = -EPERM;
626     if (IS_APPEND(inode))
627     goto out_putf;
628     -
629 kumaneko 2922 + error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
630 kumaneko 1498 + if (error)
631     + goto out_putf;
632     error = locks_verify_truncate(inode, file, length);
633     if (!error)
634     error = do_truncate(dentry, length, file);
635 kumaneko 2922 @@ -627,6 +633,10 @@ SYSCALL_DEFINE1(chroot, const char __use
636 kumaneko 1498 error = -EPERM;
637     if (!capable(CAP_SYS_CHROOT))
638     goto dput_and_out;
639 kumaneko 2282 + if (!ccs_capable(CCS_SYS_CHROOT))
640 kumaneko 1498 + goto dput_and_out;
641 kumaneko 2922 + if (ccs_chroot_permission(&nd))
642 kumaneko 1498 + goto dput_and_out;
643    
644     set_fs_root(current->fs, nd.mnt, nd.dentry);
645     set_fs_altroot();
646 kumaneko 2922 @@ -658,6 +668,9 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd
647 kumaneko 2869 err = -EPERM;
648     if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
649     goto out_putf;
650     + err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
651     + if (err)
652     + goto out_putf;
653     down(&inode->i_sem);
654     if (mode == (mode_t) -1)
655     mode = inode->i_mode;
656 kumaneko 2922 @@ -691,6 +704,9 @@ SYSCALL_DEFINE2(chmod, const char __user
657 kumaneko 2869 error = -EPERM;
658     if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
659     goto dput_and_out;
660     + error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
661     + if (error)
662     + goto dput_and_out;
663    
664     down(&inode->i_sem);
665     if (mode == (mode_t) -1)
666 kumaneko 2922 @@ -748,6 +764,8 @@ SYSCALL_DEFINE3(chown, const char __user
667 kumaneko 2869
668     error = user_path_walk(filename, &nd);
669     if (!error) {
670     + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
671     + if (!error)
672     error = chown_common(nd.dentry, user, group);
673     path_release(&nd);
674     }
675 kumaneko 2922 @@ -762,6 +780,8 @@ SYSCALL_DEFINE3(lchown, const char __use
676 kumaneko 2869
677     error = user_path_walk_link(filename, &nd);
678     if (!error) {
679     + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
680     + if (!error)
681     error = chown_common(nd.dentry, user, group);
682     path_release(&nd);
683     }
684 kumaneko 2922 @@ -776,6 +796,9 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd
685 kumaneko 2869
686     file = fget(fd);
687     if (file) {
688     + error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt,
689     + user, group);
690     + if (!error)
691     error = chown_common(file->f_dentry, user, group);
692     fput(file);
693     }
694 kumaneko 2950 @@ -867,7 +890,9 @@ struct file *filp_open(const char * file
695     if ((namei_flags+1) & O_ACCMODE)
696     namei_flags++;
697    
698     + ccs_save_open_mode(flags);
699     error = open_namei(filename, namei_flags, mode, &nd);
700     + ccs_clear_open_mode();
701     if (!error)
702     return nameidata_to_filp(&nd, flags);
703    
704     @@ -1159,6 +1184,8 @@ EXPORT_SYMBOL(sys_close);
705 kumaneko 1498 */
706 kumaneko 2404 SYSCALL_DEFINE0(vhangup)
707 kumaneko 1498 {
708 kumaneko 2282 + if (!ccs_capable(CCS_SYS_VHANGUP))
709 kumaneko 1498 + return -EPERM;
710     if (capable(CAP_SYS_TTY_CONFIG)) {
711     tty_vhangup(current->signal->tty);
712     return 0;
713 kumaneko 2927 --- linux-2.6.15-54.79.orig/fs/proc/proc_misc.c
714     +++ linux-2.6.15-54.79/fs/proc/proc_misc.c
715 kumaneko 2796 @@ -629,4 +629,5 @@ void __init proc_misc_init(void)
716 kumaneko 1498 if (entry)
717     entry->proc_fops = &proc_sysrq_trigger_operations;
718     #endif
719 kumaneko 3054 + printk(KERN_INFO "Hook version: 2.6.15-54.79 2009/09/17\n");
720 kumaneko 1498 }
721 kumaneko 2927 --- linux-2.6.15-54.79.orig/include/linux/init_task.h
722     +++ linux-2.6.15-54.79/include/linux/init_task.h
723 kumaneko 2926 @@ -72,6 +72,14 @@
724    
725     extern struct group_info init_groups;
726    
727     +#ifdef CONFIG_CCSECURITY
728     +#define INIT_CCSECURITY \
729     + .ccs_domain_info = NULL, \
730     + .ccs_flags = 0,
731     +#else
732     +#define INIT_CCSECURITY
733     +#endif
734     +
735     /*
736     * INIT_TASK is used to set up the first task table, touch at
737     * your own risk!. Base=0, limit=0x1fffff (=2MB)
738     @@ -121,6 +129,7 @@ extern struct group_info init_groups;
739 kumaneko 1498 .journal_info = NULL, \
740     .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
741     .fs_excl = ATOMIC_INIT(0), \
742 kumaneko 2926 + INIT_CCSECURITY \
743 kumaneko 1498 }
744    
745    
746 kumaneko 2927 --- linux-2.6.15-54.79.orig/include/linux/sched.h
747     +++ linux-2.6.15-54.79/include/linux/sched.h
748 kumaneko 2796 @@ -39,6 +39,8 @@
749 kumaneko 1498
750     struct exec_domain;
751    
752 kumaneko 2282 +struct ccs_domain_info;
753 kumaneko 1498 +
754     /*
755     * cloning flags:
756     */
757 kumaneko 2926 @@ -858,6 +860,10 @@ struct task_struct {
758 kumaneko 1498 #endif
759     atomic_t fs_excl; /* holding fs exclusive resources */
760 kumaneko 1896 struct list_head *scm_work_list;
761 kumaneko 2926 +#ifdef CONFIG_CCSECURITY
762 kumaneko 2282 + struct ccs_domain_info *ccs_domain_info;
763     + u32 ccs_flags;
764 kumaneko 2926 +#endif
765 kumaneko 1498 };
766    
767     static inline pid_t process_group(struct task_struct *tsk)
768 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/compat.c
769     +++ linux-2.6.15-54.79/kernel/compat.c
770 kumaneko 2796 @@ -24,6 +24,7 @@
771 kumaneko 1498
772     #include <asm/uaccess.h>
773     #include <asm/bug.h>
774 kumaneko 2859 +#include <linux/ccsecurity.h>
775 kumaneko 1498
776     int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
777     {
778 kumaneko 2796 @@ -849,6 +850,8 @@ asmlinkage long compat_sys_stime(compat_
779 kumaneko 1498 err = security_settime(&tv, NULL);
780     if (err)
781     return err;
782 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
783 kumaneko 1498 + return -EPERM;
784    
785     do_settimeofday(&tv);
786     return 0;
787 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/kexec.c
788     +++ linux-2.6.15-54.79/kernel/kexec.c
789 kumaneko 2796 @@ -25,6 +25,7 @@
790 kumaneko 1498 #include <asm/io.h>
791     #include <asm/system.h>
792     #include <asm/semaphore.h>
793 kumaneko 2859 +#include <linux/ccsecurity.h>
794 kumaneko 1498
795     /* Location of the reserved area for the crash kernel */
796     struct resource crashk_res = {
797 kumaneko 2796 @@ -917,6 +918,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon
798 kumaneko 1498 /* We only trust the superuser with rebooting the system. */
799     if (!capable(CAP_SYS_BOOT))
800     return -EPERM;
801 kumaneko 2282 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
802 kumaneko 1498 + return -EPERM;
803    
804     /*
805     * Verify we have a legal set of flags
806 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/kmod.c
807     +++ linux-2.6.15-54.79/kernel/kmod.c
808 kumaneko 2926 @@ -149,6 +149,11 @@ static int ____call_usermodehelper(void
809 kumaneko 1498 /* We can run anywhere, unlike our parent keventd(). */
810     set_cpus_allowed(current, CPU_MASK_ALL);
811    
812 kumaneko 2926 +#ifdef CONFIG_CCSECURITY
813 kumaneko 2282 + current->ccs_domain_info = NULL;
814     + current->ccs_flags = 0;
815 kumaneko 2926 +#endif
816 kumaneko 1498 +
817     retval = -EPERM;
818     if (current->fs->root)
819     retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
820 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/module.c
821     +++ linux-2.6.15-54.79/kernel/module.c
822 kumaneko 2796 @@ -41,6 +41,7 @@
823 kumaneko 1498 #include <asm/uaccess.h>
824     #include <asm/semaphore.h>
825     #include <asm/cacheflush.h>
826 kumaneko 2859 +#include <linux/ccsecurity.h>
827 kumaneko 1498
828     #if 0
829     #define DEBUGP printk
830 kumaneko 2796 @@ -577,7 +578,8 @@ SYSCALL_DEFINE2(delete_module, const cha
831 kumaneko 1498
832     if (!capable(CAP_SYS_MODULE))
833     return -EPERM;
834     -
835 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
836 kumaneko 1498 + return -EPERM;
837     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
838     return -EFAULT;
839     name[MODULE_NAME_LEN-1] = '\0';
840 kumaneko 2796 @@ -1884,7 +1886,8 @@ SYSCALL_DEFINE3(init_module, void __user
841 kumaneko 1498 /* Must have permission */
842     if (!capable(CAP_SYS_MODULE))
843     return -EPERM;
844     -
845 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
846 kumaneko 1498 + return -EPERM;
847     /* Only one module load at a time, please */
848     if (down_interruptible(&module_mutex) != 0)
849     return -EINTR;
850 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/ptrace.c
851     +++ linux-2.6.15-54.79/kernel/ptrace.c
852 kumaneko 2796 @@ -21,6 +21,7 @@
853 kumaneko 1498
854     #include <asm/pgtable.h>
855     #include <asm/uaccess.h>
856 kumaneko 2859 +#include <linux/ccsecurity.h>
857 kumaneko 1498
858     /*
859     * ptrace a task: make the debugger its new parent and
860 kumaneko 2796 @@ -493,6 +494,8 @@ SYSCALL_DEFINE4(ptrace, long, request, l
861 kumaneko 1498 /*
862     * This lock_kernel fixes a subtle race with suid exec
863     */
864 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
865 kumaneko 1498 + return -EPERM;
866     lock_kernel();
867     ret = ptrace_get_task_struct(request, pid, &child);
868     if (!child)
869 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/sched.c
870     +++ linux-2.6.15-54.79/kernel/sched.c
871 kumaneko 2796 @@ -50,6 +50,7 @@
872 kumaneko 1498 #include <asm/tlb.h>
873    
874     #include <asm/unistd.h>
875 kumaneko 2859 +#include <linux/ccsecurity.h>
876 kumaneko 1498
877     /*
878     * Convert user-nice values [ -20 ... 0 ... 19 ]
879 kumaneko 2796 @@ -3603,6 +3604,8 @@ SYSCALL_DEFINE1(nice, int, increment)
880 kumaneko 1498 {
881     int retval;
882     long nice;
883 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE))
884 kumaneko 1498 + return -EPERM;
885    
886     /*
887     * Setpriority might change our priority at the same moment.
888 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/signal.c
889     +++ linux-2.6.15-54.79/kernel/signal.c
890 kumaneko 2796 @@ -29,6 +29,7 @@
891 kumaneko 1498 #include <asm/uaccess.h>
892     #include <asm/unistd.h>
893     #include <asm/siginfo.h>
894 kumaneko 2859 +#include <linux/ccsecurity.h>
895 kumaneko 1498
896     /*
897     * SLAB caches for signal bits.
898 kumaneko 2851 @@ -2237,6 +2238,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s
899 kumaneko 2404 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
900 kumaneko 1498 {
901     struct siginfo info;
902 kumaneko 2851 + if (ccs_kill_permission(pid, sig))
903 kumaneko 1498 + return -EPERM;
904    
905     info.si_signo = sig;
906     info.si_errno = 0;
907 kumaneko 2851 @@ -2295,6 +2298,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
908 kumaneko 1498 /* This is only valid for single tasks */
909     if (pid <= 0 || tgid <= 0)
910     return -EINVAL;
911 kumaneko 2851 + if (ccs_tgkill_permission(tgid, pid, sig))
912 kumaneko 1498 + return -EPERM;
913    
914     return do_tkill(tgid, pid, sig);
915     }
916 kumaneko 2851 @@ -2307,6 +2312,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
917 kumaneko 1498 /* This is only valid for single tasks */
918     if (pid <= 0)
919     return -EINVAL;
920 kumaneko 2851 + if (ccs_tkill_permission(pid, sig))
921 kumaneko 1498 + return -EPERM;
922    
923     return do_tkill(0, pid, sig);
924     }
925 kumaneko 2869 @@ -2324,6 +2331,8 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t,
926     if (info.si_code >= 0)
927     return -EPERM;
928     info.si_signo = sig;
929     + if (ccs_sigqueue_permission(pid, sig))
930     + return -EPERM;
931    
932     /* POSIX.1b doesn't mention process groups. */
933     return kill_proc_info(sig, &info, pid);
934 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/sys.c
935     +++ linux-2.6.15-54.79/kernel/sys.c
936 kumaneko 2796 @@ -37,6 +37,7 @@
937 kumaneko 1498 #include <asm/uaccess.h>
938     #include <asm/io.h>
939     #include <asm/unistd.h>
940 kumaneko 2859 +#include <linux/ccsecurity.h>
941 kumaneko 1498
942     #ifndef SET_UNALIGN_CTL
943     # define SET_UNALIGN_CTL(a,b) (-EINVAL)
944 kumaneko 2796 @@ -256,6 +257,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
945 kumaneko 1498
946     if (which > 2 || which < 0)
947     goto out;
948 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE)) {
949 kumaneko 1498 + error = -EPERM;
950     + goto out;
951     + }
952    
953     /* normalize: avoid signed division (rounding problems) */
954     error = -ESRCH;
955 kumaneko 2796 @@ -484,6 +489,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
956 kumaneko 1498 magic2 != LINUX_REBOOT_MAGIC2B &&
957     magic2 != LINUX_REBOOT_MAGIC2C))
958     return -EINVAL;
959 kumaneko 2282 + if (!ccs_capable(CCS_SYS_REBOOT))
960 kumaneko 1498 + return -EPERM;
961    
962     lock_kernel();
963     switch (cmd) {
964 kumaneko 2796 @@ -1518,6 +1525,8 @@ SYSCALL_DEFINE2(sethostname, char __user
965 kumaneko 1498 return -EPERM;
966     if (len < 0 || len > __NEW_UTS_LEN)
967     return -EINVAL;
968 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
969 kumaneko 1498 + return -EPERM;
970     down_write(&uts_sem);
971     errno = -EFAULT;
972     if (!copy_from_user(tmp, name, len)) {
973 kumaneko 2796 @@ -1563,6 +1572,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
974 kumaneko 1498 return -EPERM;
975     if (len < 0 || len > __NEW_UTS_LEN)
976     return -EINVAL;
977 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
978 kumaneko 1498 + return -EPERM;
979    
980     down_write(&uts_sem);
981     errno = -EFAULT;
982 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/sysctl.c
983     +++ linux-2.6.15-54.79/kernel/sysctl.c
984 kumaneko 2796 @@ -45,6 +45,7 @@
985 kumaneko 1498
986     #include <asm/uaccess.h>
987     #include <asm/processor.h>
988 kumaneko 2859 +#include <linux/ccsecurity.h>
989 kumaneko 1498
990     #ifdef CONFIG_ROOT_NFS
991     #include <linux/nfs_fs.h>
992 kumaneko 2796 @@ -1066,6 +1067,9 @@ int do_sysctl(int __user *name, int nlen
993 kumaneko 1498
994     spin_unlock(&sysctl_lock);
995    
996 kumaneko 2298 + error = ccs_parse_table(name, nlen, oldval, newval,
997 kumaneko 1498 + head->ctl_table);
998     + if (!error)
999     error = parse_table(name, nlen, oldval, oldlenp,
1000     newval, newlen, head->ctl_table,
1001     &context);
1002 kumaneko 2796 @@ -1138,6 +1142,13 @@ repeat:
1003 kumaneko 1498 if (ctl_perm(table, 001))
1004     return -EPERM;
1005     if (table->strategy) {
1006     + int op = 0;
1007     + if (oldval)
1008     + op |= 004;
1009     + if (newval)
1010     + op |= 002;
1011     + if (ctl_perm(table, op))
1012     + return -EPERM;
1013     error = table->strategy(
1014     table, name, nlen,
1015     oldval, oldlenp,
1016 kumaneko 2927 --- linux-2.6.15-54.79.orig/kernel/time.c
1017     +++ linux-2.6.15-54.79/kernel/time.c
1018 kumaneko 2796 @@ -38,6 +38,7 @@
1019 kumaneko 1498
1020     #include <asm/uaccess.h>
1021     #include <asm/unistd.h>
1022 kumaneko 2859 +#include <linux/ccsecurity.h>
1023 kumaneko 1498
1024     /*
1025     * The timezone where the local system is located. Used as a default by some
1026 kumaneko 2796 @@ -90,6 +91,8 @@ SYSCALL_DEFINE1(stime, time_t __user *,
1027 kumaneko 1498 err = security_settime(&tv, NULL);
1028     if (err)
1029     return err;
1030 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1031 kumaneko 1498 + return -EPERM;
1032    
1033     do_settimeofday(&tv);
1034     return 0;
1035 kumaneko 2796 @@ -158,6 +161,8 @@ int do_sys_settimeofday(struct timespec
1036 kumaneko 1498 error = security_settime(tv, tz);
1037     if (error)
1038     return error;
1039 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1040 kumaneko 1498 + return -EPERM;
1041    
1042     if (tz) {
1043     /* SMP safe, global irq locking makes it work. */
1044 kumaneko 2796 @@ -236,6 +241,8 @@ int do_adjtimex(struct timex *txc)
1045 kumaneko 1498 /* In order to modify anything, you gotta be super-user! */
1046     if (txc->modes && !capable(CAP_SYS_TIME))
1047     return -EPERM;
1048 kumaneko 2282 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1049 kumaneko 1498 + return -EPERM;
1050    
1051     /* Now we validate the data before disabling interrupts */
1052    
1053 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/ipv4/inet_connection_sock.c
1054     +++ linux-2.6.15-54.79/net/ipv4/inet_connection_sock.c
1055 kumaneko 2796 @@ -24,6 +24,7 @@
1056 kumaneko 1498 #include <net/route.h>
1057     #include <net/tcp_states.h>
1058     #include <net/xfrm.h>
1059 kumaneko 2859 +#include <linux/ccsecurity.h>
1060 kumaneko 1498
1061     #ifdef INET_CSK_DEBUG
1062     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1063 kumaneko 2796 @@ -83,6 +84,8 @@ int inet_csk_get_port(struct inet_hashin
1064 kumaneko 1498 do {
1065     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1066     spin_lock(&head->lock);
1067 kumaneko 2299 + if (ccs_lport_reserved(rover))
1068 kumaneko 1498 + goto next;
1069     inet_bind_bucket_for_each(tb, node, &head->chain)
1070     if (tb->port == rover)
1071     goto next;
1072 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/ipv4/raw.c
1073     +++ linux-2.6.15-54.79/net/ipv4/raw.c
1074 kumaneko 2796 @@ -79,6 +79,7 @@
1075 kumaneko 2459 #include <linux/seq_file.h>
1076     #include <linux/netfilter.h>
1077     #include <linux/netfilter_ipv4.h>
1078 kumaneko 2859 +#include <linux/ccsecurity.h>
1079 kumaneko 2459
1080     struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1081     DEFINE_RWLOCK(raw_v4_lock);
1082 kumaneko 2796 @@ -591,6 +592,9 @@ static int raw_recvmsg(struct kiocb *ioc
1083 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1084     if (!skb)
1085     goto out;
1086     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1087     + if (err)
1088     + goto out;
1089    
1090     copied = skb->len;
1091     if (len < copied) {
1092 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/ipv4/tcp_ipv4.c
1093     +++ linux-2.6.15-54.79/net/ipv4/tcp_ipv4.c
1094 kumaneko 2796 @@ -76,6 +76,7 @@
1095 kumaneko 1498 #include <linux/stddef.h>
1096     #include <linux/proc_fs.h>
1097     #include <linux/seq_file.h>
1098 kumaneko 2859 +#include <linux/ccsecurity.h>
1099 kumaneko 1498
1100     int sysctl_tcp_tw_reuse;
1101     int sysctl_tcp_low_latency;
1102 kumaneko 2796 @@ -243,6 +244,8 @@ static inline int tcp_v4_hash_connect(st
1103 kumaneko 1498 local_bh_disable();
1104     for (i = 1; i <= range; i++) {
1105     port = low + (i + offset) % range;
1106 kumaneko 2299 + if (ccs_lport_reserved(port))
1107 kumaneko 1498 + continue;
1108     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1109     spin_lock(&head->lock);
1110    
1111 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/ipv4/udp.c
1112     +++ linux-2.6.15-54.79/net/ipv4/udp.c
1113 kumaneko 2859 @@ -108,6 +108,7 @@
1114 kumaneko 1498 #include <net/inet_common.h>
1115     #include <net/checksum.h>
1116     #include <net/xfrm.h>
1117 kumaneko 2859 +#include <linux/ccsecurity.h>
1118 kumaneko 1498
1119     /*
1120     * Snmp MIB for the UDP layer
1121 kumaneko 2859 @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1122 kumaneko 1498 result = sysctl_local_port_range[0] +
1123     ((result - sysctl_local_port_range[0]) &
1124     (UDP_HTABLE_SIZE - 1));
1125 kumaneko 2299 + if (ccs_lport_reserved(result))
1126 kumaneko 1498 + continue;
1127     goto gotit;
1128     }
1129     size = 0;
1130 kumaneko 2859 @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1131 kumaneko 1498 result = sysctl_local_port_range[0]
1132     + ((result - sysctl_local_port_range[0]) &
1133     (UDP_HTABLE_SIZE - 1));
1134 kumaneko 2299 + if (ccs_lport_reserved(result))
1135 kumaneko 1498 + continue;
1136     if (!udp_lport_inuse(result))
1137     break;
1138     }
1139 kumaneko 2859 @@ -796,7 +801,10 @@ try_again:
1140 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1141     if (!skb)
1142     goto out;
1143     -
1144     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1145     + if (err)
1146     + goto out;
1147     +
1148     copied = skb->len - sizeof(struct udphdr);
1149     if (copied > len) {
1150     copied = len;
1151 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/ipv6/raw.c
1152     +++ linux-2.6.15-54.79/net/ipv6/raw.c
1153 kumaneko 2796 @@ -56,6 +56,7 @@
1154 kumaneko 2459
1155     #include <linux/proc_fs.h>
1156     #include <linux/seq_file.h>
1157 kumaneko 2859 +#include <linux/ccsecurity.h>
1158 kumaneko 2459
1159     struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1160     DEFINE_RWLOCK(raw_v6_lock);
1161 kumaneko 2796 @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1162 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1163     if (!skb)
1164     goto out;
1165     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1166     + if (err)
1167     + goto out;
1168    
1169     copied = skb->len;
1170     if (copied > len) {
1171 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/ipv6/tcp_ipv6.c
1172     +++ linux-2.6.15-54.79/net/ipv6/tcp_ipv6.c
1173 kumaneko 2796 @@ -64,6 +64,7 @@
1174 kumaneko 1498
1175     #include <linux/proc_fs.h>
1176     #include <linux/seq_file.h>
1177 kumaneko 2859 +#include <linux/ccsecurity.h>
1178 kumaneko 1498
1179     static void tcp_v6_send_reset(struct sk_buff *skb);
1180     static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1181 kumaneko 2796 @@ -119,6 +120,8 @@ static int tcp_v6_get_port(struct sock *
1182 kumaneko 1498 do {
1183     head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1184     spin_lock(&head->lock);
1185 kumaneko 2299 + if (ccs_lport_reserved(rover))
1186 kumaneko 1498 + goto next;
1187     inet_bind_bucket_for_each(tb, node, &head->chain)
1188     if (tb->port == rover)
1189     goto next;
1190 kumaneko 2796 @@ -419,6 +422,8 @@ static int tcp_v6_hash_connect(struct so
1191 kumaneko 1498 local_bh_disable();
1192     for (i = 1; i <= range; i++) {
1193     port = low + (i + offset) % range;
1194 kumaneko 2299 + if (ccs_lport_reserved(port))
1195 kumaneko 1498 + continue;
1196     head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1197     spin_lock(&head->lock);
1198    
1199 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/ipv6/udp.c
1200     +++ linux-2.6.15-54.79/net/ipv6/udp.c
1201 kumaneko 2859 @@ -58,6 +58,7 @@
1202 kumaneko 1498
1203     #include <linux/proc_fs.h>
1204     #include <linux/seq_file.h>
1205 kumaneko 2859 +#include <linux/ccsecurity.h>
1206 kumaneko 1498
1207     DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1208    
1209 kumaneko 2859 @@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1210 kumaneko 1498 result = sysctl_local_port_range[0] +
1211     ((result - sysctl_local_port_range[0]) &
1212     (UDP_HTABLE_SIZE - 1));
1213 kumaneko 2299 + if (ccs_lport_reserved(result))
1214 kumaneko 1498 + continue;
1215     goto gotit;
1216     }
1217     size = 0;
1218 kumaneko 2859 @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1219 kumaneko 1498 result = sysctl_local_port_range[0]
1220     + ((result - sysctl_local_port_range[0]) &
1221     (UDP_HTABLE_SIZE - 1));
1222 kumaneko 2299 + if (ccs_lport_reserved(result))
1223 kumaneko 1498 + continue;
1224     if (!udp_lport_inuse(result))
1225     break;
1226     }
1227 kumaneko 2859 @@ -237,6 +242,9 @@ try_again:
1228 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1229     if (!skb)
1230     goto out;
1231     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1232     + if (err)
1233     + goto out;
1234    
1235     copied = skb->len - sizeof(struct udphdr);
1236     if (copied > len) {
1237 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/socket.c
1238     +++ linux-2.6.15-54.79/net/socket.c
1239 kumaneko 2859 @@ -97,6 +97,8 @@
1240 kumaneko 1498 #include <net/sock.h>
1241     #include <linux/netfilter.h>
1242    
1243 kumaneko 2859 +#include <linux/ccsecurity.h>
1244 kumaneko 1498 +
1245     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1246     static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1247     size_t size, loff_t pos);
1248 kumaneko 2859 @@ -544,9 +546,12 @@ static inline int __sock_sendmsg(struct
1249 kumaneko 2805 si->size = size;
1250    
1251 kumaneko 1498 err = security_socket_sendmsg(sock, msg, size);
1252 kumaneko 2805 + if (!err)
1253     + err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)
1254     + msg->msg_name,
1255     + msg->msg_namelen);
1256 kumaneko 1498 if (err)
1257     return err;
1258     -
1259     return sock->ops->sendmsg(iocb, sock, msg, size);
1260     }
1261    
1262 kumaneko 2927 @@ -1103,6 +1108,8 @@ static int __sock_create(int family, int
1263 kumaneko 1498 }
1264    
1265     err = security_socket_create(family, type, protocol, kern);
1266 kumaneko 2805 + if (!err)
1267     + err = ccs_socket_create_permission(family, type, protocol);
1268 kumaneko 1498 if (err)
1269     return err;
1270 kumaneko 2805
1271 kumaneko 2927 @@ -1300,6 +1307,10 @@ SYSCALL_DEFINE3(bind, int, fd, struct so
1272 kumaneko 1498 sockfd_put(sock);
1273     return err;
1274     }
1275     + err = ccs_socket_bind_permission(sock,
1276     + (struct sockaddr *)
1277     + address, addrlen);
1278     + if (!err)
1279     err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1280     }
1281     sockfd_put(sock);
1282 kumaneko 2927 @@ -1330,7 +1341,8 @@ SYSCALL_DEFINE2(listen, int, fd, int, ba
1283 kumaneko 1498 sockfd_put(sock);
1284     return err;
1285     }
1286     -
1287     + err = ccs_socket_listen_permission(sock);
1288     + if (!err)
1289     err=sock->ops->listen(sock, backlog);
1290     sockfd_put(sock);
1291     }
1292 kumaneko 2927 @@ -1382,6 +1394,11 @@ SYSCALL_DEFINE3(accept, int, fd, struct
1293 kumaneko 1498 if (err < 0)
1294     goto out_release;
1295    
1296     + if (ccs_socket_accept_permission(newsock,
1297     + (struct sockaddr *) address)) {
1298     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1299     + goto out_release;
1300     + }
1301     if (upeer_sockaddr) {
1302     if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1303     err = -ECONNABORTED;
1304 kumaneko 2927 @@ -1436,9 +1453,11 @@ SYSCALL_DEFINE3(connect, int, fd, struct
1305 kumaneko 2805 goto out_put;
1306    
1307 kumaneko 1498 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1308 kumaneko 2805 + if (!err)
1309     + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1310     + address, addrlen);
1311 kumaneko 1498 if (err)
1312     goto out_put;
1313     -
1314     err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1315     sock->file->f_flags);
1316     out_put:
1317 kumaneko 2927 --- linux-2.6.15-54.79.orig/net/unix/af_unix.c
1318     +++ linux-2.6.15-54.79/net/unix/af_unix.c
1319 kumaneko 2796 @@ -117,6 +117,7 @@
1320 kumaneko 1498 #include <linux/mount.h>
1321     #include <net/checksum.h>
1322     #include <linux/security.h>
1323 kumaneko 2859 +#include <linux/ccsecurity.h>
1324 kumaneko 1498
1325     int sysctl_unix_max_dgram_qlen = 10;
1326    
1327 kumaneko 2796 @@ -781,6 +782,9 @@ static int unix_bind(struct socket *sock
1328 kumaneko 1498 */
1329     mode = S_IFSOCK |
1330     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1331 kumaneko 2922 + err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1332     + mode, 0);
1333 kumaneko 1498 + if (!err)
1334     err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1335     if (err)
1336     goto out_mknod_dput;
1337 kumaneko 2927 --- linux-2.6.15-54.79.orig/security/Kconfig
1338     +++ linux-2.6.15-54.79/security/Kconfig
1339 kumaneko 2858 @@ -94,5 +94,7 @@ config SECURITY_SECLVL
1340    
1341     source security/selinux/Kconfig
1342    
1343     +source security/ccsecurity/Kconfig
1344     +
1345     endmenu
1346    
1347 kumaneko 2927 --- linux-2.6.15-54.79.orig/security/Makefile
1348     +++ linux-2.6.15-54.79/security/Makefile
1349 kumaneko 2858 @@ -19,3 +19,6 @@ obj-$(CONFIG_SECURITY_ROOTPLUG) += comm
1350     obj-$(CONFIG_SECURITY_REALTIME) += commoncap.o realcap.o
1351    
1352     obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o
1353     +
1354     +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1355     +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

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