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

Subversion リポジトリの参照

Annotation of /branches/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3584 - (hide annotations) (download) (as text)
Mon Apr 12 04:23:04 2010 UTC (14 years, 1 month ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff
File MIME type: text/x-diff
File size: 39266 byte(s)


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

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