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

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2926 - (show annotations) (download) (as text)
Thu Aug 20 03:13:40 2009 UTC (14 years, 9 months ago) by kumaneko
Original Path: branches/ccs-patch/patches/ccs-patch-2.6.15-ubuntu-6.06.diff
File MIME type: text/x-diff
File size: 38847 byte(s)


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

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