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

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.21.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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