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

Subversion リポジトリの参照

Annotation of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.20.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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