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

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 2922 - (show annotations) (download) (as text)
Wed Aug 19 04:26:56 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: 38457 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 | 2 ++
25 include/linux/sched.h | 4 ++++
26 kernel/compat.c | 3 +++
27 kernel/kexec.c | 3 +++
28 kernel/kmod.c | 3 +++
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, 280 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/09\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 @@ -121,6 +121,8 @@ extern struct group_info init_groups;
708 .journal_info = NULL, \
709 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
710 .fs_excl = ATOMIC_INIT(0), \
711 + .ccs_domain_info = NULL, \
712 + .ccs_flags = 0, \
713 }
714
715
716 --- linux-2.6.15-54.78.orig/include/linux/sched.h
717 +++ linux-2.6.15-54.78/include/linux/sched.h
718 @@ -39,6 +39,8 @@
719
720 struct exec_domain;
721
722 +struct ccs_domain_info;
723 +
724 /*
725 * cloning flags:
726 */
727 @@ -858,6 +860,8 @@ struct task_struct {
728 #endif
729 atomic_t fs_excl; /* holding fs exclusive resources */
730 struct list_head *scm_work_list;
731 + struct ccs_domain_info *ccs_domain_info;
732 + u32 ccs_flags;
733 };
734
735 static inline pid_t process_group(struct task_struct *tsk)
736 --- linux-2.6.15-54.78.orig/kernel/compat.c
737 +++ linux-2.6.15-54.78/kernel/compat.c
738 @@ -24,6 +24,7 @@
739
740 #include <asm/uaccess.h>
741 #include <asm/bug.h>
742 +#include <linux/ccsecurity.h>
743
744 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
745 {
746 @@ -849,6 +850,8 @@ asmlinkage long compat_sys_stime(compat_
747 err = security_settime(&tv, NULL);
748 if (err)
749 return err;
750 + if (!ccs_capable(CCS_SYS_SETTIME))
751 + return -EPERM;
752
753 do_settimeofday(&tv);
754 return 0;
755 --- linux-2.6.15-54.78.orig/kernel/kexec.c
756 +++ linux-2.6.15-54.78/kernel/kexec.c
757 @@ -25,6 +25,7 @@
758 #include <asm/io.h>
759 #include <asm/system.h>
760 #include <asm/semaphore.h>
761 +#include <linux/ccsecurity.h>
762
763 /* Location of the reserved area for the crash kernel */
764 struct resource crashk_res = {
765 @@ -917,6 +918,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon
766 /* We only trust the superuser with rebooting the system. */
767 if (!capable(CAP_SYS_BOOT))
768 return -EPERM;
769 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
770 + return -EPERM;
771
772 /*
773 * Verify we have a legal set of flags
774 --- linux-2.6.15-54.78.orig/kernel/kmod.c
775 +++ linux-2.6.15-54.78/kernel/kmod.c
776 @@ -149,6 +149,9 @@ static int ____call_usermodehelper(void
777 /* We can run anywhere, unlike our parent keventd(). */
778 set_cpus_allowed(current, CPU_MASK_ALL);
779
780 + current->ccs_domain_info = NULL;
781 + current->ccs_flags = 0;
782 +
783 retval = -EPERM;
784 if (current->fs->root)
785 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
786 --- linux-2.6.15-54.78.orig/kernel/module.c
787 +++ linux-2.6.15-54.78/kernel/module.c
788 @@ -41,6 +41,7 @@
789 #include <asm/uaccess.h>
790 #include <asm/semaphore.h>
791 #include <asm/cacheflush.h>
792 +#include <linux/ccsecurity.h>
793
794 #if 0
795 #define DEBUGP printk
796 @@ -577,7 +578,8 @@ SYSCALL_DEFINE2(delete_module, const cha
797
798 if (!capable(CAP_SYS_MODULE))
799 return -EPERM;
800 -
801 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
802 + return -EPERM;
803 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
804 return -EFAULT;
805 name[MODULE_NAME_LEN-1] = '\0';
806 @@ -1884,7 +1886,8 @@ SYSCALL_DEFINE3(init_module, void __user
807 /* Must have permission */
808 if (!capable(CAP_SYS_MODULE))
809 return -EPERM;
810 -
811 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
812 + return -EPERM;
813 /* Only one module load at a time, please */
814 if (down_interruptible(&module_mutex) != 0)
815 return -EINTR;
816 --- linux-2.6.15-54.78.orig/kernel/ptrace.c
817 +++ linux-2.6.15-54.78/kernel/ptrace.c
818 @@ -21,6 +21,7 @@
819
820 #include <asm/pgtable.h>
821 #include <asm/uaccess.h>
822 +#include <linux/ccsecurity.h>
823
824 /*
825 * ptrace a task: make the debugger its new parent and
826 @@ -493,6 +494,8 @@ SYSCALL_DEFINE4(ptrace, long, request, l
827 /*
828 * This lock_kernel fixes a subtle race with suid exec
829 */
830 + if (!ccs_capable(CCS_SYS_PTRACE))
831 + return -EPERM;
832 lock_kernel();
833 ret = ptrace_get_task_struct(request, pid, &child);
834 if (!child)
835 --- linux-2.6.15-54.78.orig/kernel/sched.c
836 +++ linux-2.6.15-54.78/kernel/sched.c
837 @@ -50,6 +50,7 @@
838 #include <asm/tlb.h>
839
840 #include <asm/unistd.h>
841 +#include <linux/ccsecurity.h>
842
843 /*
844 * Convert user-nice values [ -20 ... 0 ... 19 ]
845 @@ -3603,6 +3604,8 @@ SYSCALL_DEFINE1(nice, int, increment)
846 {
847 int retval;
848 long nice;
849 + if (!ccs_capable(CCS_SYS_NICE))
850 + return -EPERM;
851
852 /*
853 * Setpriority might change our priority at the same moment.
854 --- linux-2.6.15-54.78.orig/kernel/signal.c
855 +++ linux-2.6.15-54.78/kernel/signal.c
856 @@ -29,6 +29,7 @@
857 #include <asm/uaccess.h>
858 #include <asm/unistd.h>
859 #include <asm/siginfo.h>
860 +#include <linux/ccsecurity.h>
861
862 /*
863 * SLAB caches for signal bits.
864 @@ -2237,6 +2238,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s
865 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
866 {
867 struct siginfo info;
868 + if (ccs_kill_permission(pid, sig))
869 + return -EPERM;
870
871 info.si_signo = sig;
872 info.si_errno = 0;
873 @@ -2295,6 +2298,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
874 /* This is only valid for single tasks */
875 if (pid <= 0 || tgid <= 0)
876 return -EINVAL;
877 + if (ccs_tgkill_permission(tgid, pid, sig))
878 + return -EPERM;
879
880 return do_tkill(tgid, pid, sig);
881 }
882 @@ -2307,6 +2312,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
883 /* This is only valid for single tasks */
884 if (pid <= 0)
885 return -EINVAL;
886 + if (ccs_tkill_permission(pid, sig))
887 + return -EPERM;
888
889 return do_tkill(0, pid, sig);
890 }
891 @@ -2324,6 +2331,8 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t,
892 if (info.si_code >= 0)
893 return -EPERM;
894 info.si_signo = sig;
895 + if (ccs_sigqueue_permission(pid, sig))
896 + return -EPERM;
897
898 /* POSIX.1b doesn't mention process groups. */
899 return kill_proc_info(sig, &info, pid);
900 --- linux-2.6.15-54.78.orig/kernel/sys.c
901 +++ linux-2.6.15-54.78/kernel/sys.c
902 @@ -37,6 +37,7 @@
903 #include <asm/uaccess.h>
904 #include <asm/io.h>
905 #include <asm/unistd.h>
906 +#include <linux/ccsecurity.h>
907
908 #ifndef SET_UNALIGN_CTL
909 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
910 @@ -256,6 +257,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
911
912 if (which > 2 || which < 0)
913 goto out;
914 + if (!ccs_capable(CCS_SYS_NICE)) {
915 + error = -EPERM;
916 + goto out;
917 + }
918
919 /* normalize: avoid signed division (rounding problems) */
920 error = -ESRCH;
921 @@ -484,6 +489,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
922 magic2 != LINUX_REBOOT_MAGIC2B &&
923 magic2 != LINUX_REBOOT_MAGIC2C))
924 return -EINVAL;
925 + if (!ccs_capable(CCS_SYS_REBOOT))
926 + return -EPERM;
927
928 lock_kernel();
929 switch (cmd) {
930 @@ -1518,6 +1525,8 @@ SYSCALL_DEFINE2(sethostname, char __user
931 return -EPERM;
932 if (len < 0 || len > __NEW_UTS_LEN)
933 return -EINVAL;
934 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
935 + return -EPERM;
936 down_write(&uts_sem);
937 errno = -EFAULT;
938 if (!copy_from_user(tmp, name, len)) {
939 @@ -1563,6 +1572,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
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
946 down_write(&uts_sem);
947 errno = -EFAULT;
948 --- linux-2.6.15-54.78.orig/kernel/sysctl.c
949 +++ linux-2.6.15-54.78/kernel/sysctl.c
950 @@ -45,6 +45,7 @@
951
952 #include <asm/uaccess.h>
953 #include <asm/processor.h>
954 +#include <linux/ccsecurity.h>
955
956 #ifdef CONFIG_ROOT_NFS
957 #include <linux/nfs_fs.h>
958 @@ -1066,6 +1067,9 @@ int do_sysctl(int __user *name, int nlen
959
960 spin_unlock(&sysctl_lock);
961
962 + error = ccs_parse_table(name, nlen, oldval, newval,
963 + head->ctl_table);
964 + if (!error)
965 error = parse_table(name, nlen, oldval, oldlenp,
966 newval, newlen, head->ctl_table,
967 &context);
968 @@ -1138,6 +1142,13 @@ repeat:
969 if (ctl_perm(table, 001))
970 return -EPERM;
971 if (table->strategy) {
972 + int op = 0;
973 + if (oldval)
974 + op |= 004;
975 + if (newval)
976 + op |= 002;
977 + if (ctl_perm(table, op))
978 + return -EPERM;
979 error = table->strategy(
980 table, name, nlen,
981 oldval, oldlenp,
982 --- linux-2.6.15-54.78.orig/kernel/time.c
983 +++ linux-2.6.15-54.78/kernel/time.c
984 @@ -38,6 +38,7 @@
985
986 #include <asm/uaccess.h>
987 #include <asm/unistd.h>
988 +#include <linux/ccsecurity.h>
989
990 /*
991 * The timezone where the local system is located. Used as a default by some
992 @@ -90,6 +91,8 @@ SYSCALL_DEFINE1(stime, time_t __user *,
993 err = security_settime(&tv, NULL);
994 if (err)
995 return err;
996 + if (!ccs_capable(CCS_SYS_SETTIME))
997 + return -EPERM;
998
999 do_settimeofday(&tv);
1000 return 0;
1001 @@ -158,6 +161,8 @@ int do_sys_settimeofday(struct timespec
1002 error = security_settime(tv, tz);
1003 if (error)
1004 return error;
1005 + if (!ccs_capable(CCS_SYS_SETTIME))
1006 + return -EPERM;
1007
1008 if (tz) {
1009 /* SMP safe, global irq locking makes it work. */
1010 @@ -236,6 +241,8 @@ int do_adjtimex(struct timex *txc)
1011 /* In order to modify anything, you gotta be super-user! */
1012 if (txc->modes && !capable(CAP_SYS_TIME))
1013 return -EPERM;
1014 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1015 + return -EPERM;
1016
1017 /* Now we validate the data before disabling interrupts */
1018
1019 --- linux-2.6.15-54.78.orig/net/ipv4/inet_connection_sock.c
1020 +++ linux-2.6.15-54.78/net/ipv4/inet_connection_sock.c
1021 @@ -24,6 +24,7 @@
1022 #include <net/route.h>
1023 #include <net/tcp_states.h>
1024 #include <net/xfrm.h>
1025 +#include <linux/ccsecurity.h>
1026
1027 #ifdef INET_CSK_DEBUG
1028 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1029 @@ -83,6 +84,8 @@ int inet_csk_get_port(struct inet_hashin
1030 do {
1031 head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1032 spin_lock(&head->lock);
1033 + if (ccs_lport_reserved(rover))
1034 + goto next;
1035 inet_bind_bucket_for_each(tb, node, &head->chain)
1036 if (tb->port == rover)
1037 goto next;
1038 --- linux-2.6.15-54.78.orig/net/ipv4/raw.c
1039 +++ linux-2.6.15-54.78/net/ipv4/raw.c
1040 @@ -79,6 +79,7 @@
1041 #include <linux/seq_file.h>
1042 #include <linux/netfilter.h>
1043 #include <linux/netfilter_ipv4.h>
1044 +#include <linux/ccsecurity.h>
1045
1046 struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1047 DEFINE_RWLOCK(raw_v4_lock);
1048 @@ -591,6 +592,9 @@ static int raw_recvmsg(struct kiocb *ioc
1049 skb = skb_recv_datagram(sk, flags, noblock, &err);
1050 if (!skb)
1051 goto out;
1052 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1053 + if (err)
1054 + goto out;
1055
1056 copied = skb->len;
1057 if (len < copied) {
1058 --- linux-2.6.15-54.78.orig/net/ipv4/tcp_ipv4.c
1059 +++ linux-2.6.15-54.78/net/ipv4/tcp_ipv4.c
1060 @@ -76,6 +76,7 @@
1061 #include <linux/stddef.h>
1062 #include <linux/proc_fs.h>
1063 #include <linux/seq_file.h>
1064 +#include <linux/ccsecurity.h>
1065
1066 int sysctl_tcp_tw_reuse;
1067 int sysctl_tcp_low_latency;
1068 @@ -243,6 +244,8 @@ static inline int tcp_v4_hash_connect(st
1069 local_bh_disable();
1070 for (i = 1; i <= range; i++) {
1071 port = low + (i + offset) % range;
1072 + if (ccs_lport_reserved(port))
1073 + continue;
1074 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1075 spin_lock(&head->lock);
1076
1077 --- linux-2.6.15-54.78.orig/net/ipv4/udp.c
1078 +++ linux-2.6.15-54.78/net/ipv4/udp.c
1079 @@ -108,6 +108,7 @@
1080 #include <net/inet_common.h>
1081 #include <net/checksum.h>
1082 #include <net/xfrm.h>
1083 +#include <linux/ccsecurity.h>
1084
1085 /*
1086 * Snmp MIB for the UDP layer
1087 @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1088 result = sysctl_local_port_range[0] +
1089 ((result - sysctl_local_port_range[0]) &
1090 (UDP_HTABLE_SIZE - 1));
1091 + if (ccs_lport_reserved(result))
1092 + continue;
1093 goto gotit;
1094 }
1095 size = 0;
1096 @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1097 result = sysctl_local_port_range[0]
1098 + ((result - sysctl_local_port_range[0]) &
1099 (UDP_HTABLE_SIZE - 1));
1100 + if (ccs_lport_reserved(result))
1101 + continue;
1102 if (!udp_lport_inuse(result))
1103 break;
1104 }
1105 @@ -796,7 +801,10 @@ try_again:
1106 skb = skb_recv_datagram(sk, flags, noblock, &err);
1107 if (!skb)
1108 goto out;
1109 -
1110 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1111 + if (err)
1112 + goto out;
1113 +
1114 copied = skb->len - sizeof(struct udphdr);
1115 if (copied > len) {
1116 copied = len;
1117 --- linux-2.6.15-54.78.orig/net/ipv6/raw.c
1118 +++ linux-2.6.15-54.78/net/ipv6/raw.c
1119 @@ -56,6 +56,7 @@
1120
1121 #include <linux/proc_fs.h>
1122 #include <linux/seq_file.h>
1123 +#include <linux/ccsecurity.h>
1124
1125 struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1126 DEFINE_RWLOCK(raw_v6_lock);
1127 @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1128 skb = skb_recv_datagram(sk, flags, noblock, &err);
1129 if (!skb)
1130 goto out;
1131 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1132 + if (err)
1133 + goto out;
1134
1135 copied = skb->len;
1136 if (copied > len) {
1137 --- linux-2.6.15-54.78.orig/net/ipv6/tcp_ipv6.c
1138 +++ linux-2.6.15-54.78/net/ipv6/tcp_ipv6.c
1139 @@ -64,6 +64,7 @@
1140
1141 #include <linux/proc_fs.h>
1142 #include <linux/seq_file.h>
1143 +#include <linux/ccsecurity.h>
1144
1145 static void tcp_v6_send_reset(struct sk_buff *skb);
1146 static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
1147 @@ -119,6 +120,8 @@ static int tcp_v6_get_port(struct sock *
1148 do {
1149 head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)];
1150 spin_lock(&head->lock);
1151 + if (ccs_lport_reserved(rover))
1152 + goto next;
1153 inet_bind_bucket_for_each(tb, node, &head->chain)
1154 if (tb->port == rover)
1155 goto next;
1156 @@ -419,6 +422,8 @@ static int tcp_v6_hash_connect(struct so
1157 local_bh_disable();
1158 for (i = 1; i <= range; i++) {
1159 port = low + (i + offset) % range;
1160 + if (ccs_lport_reserved(port))
1161 + continue;
1162 head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)];
1163 spin_lock(&head->lock);
1164
1165 --- linux-2.6.15-54.78.orig/net/ipv6/udp.c
1166 +++ linux-2.6.15-54.78/net/ipv6/udp.c
1167 @@ -58,6 +58,7 @@
1168
1169 #include <linux/proc_fs.h>
1170 #include <linux/seq_file.h>
1171 +#include <linux/ccsecurity.h>
1172
1173 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1174
1175 @@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1176 result = sysctl_local_port_range[0] +
1177 ((result - sysctl_local_port_range[0]) &
1178 (UDP_HTABLE_SIZE - 1));
1179 + if (ccs_lport_reserved(result))
1180 + continue;
1181 goto gotit;
1182 }
1183 size = 0;
1184 @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1185 result = sysctl_local_port_range[0]
1186 + ((result - sysctl_local_port_range[0]) &
1187 (UDP_HTABLE_SIZE - 1));
1188 + if (ccs_lport_reserved(result))
1189 + continue;
1190 if (!udp_lport_inuse(result))
1191 break;
1192 }
1193 @@ -237,6 +242,9 @@ try_again:
1194 skb = skb_recv_datagram(sk, flags, noblock, &err);
1195 if (!skb)
1196 goto out;
1197 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1198 + if (err)
1199 + goto out;
1200
1201 copied = skb->len - sizeof(struct udphdr);
1202 if (copied > len) {
1203 --- linux-2.6.15-54.78.orig/net/socket.c
1204 +++ linux-2.6.15-54.78/net/socket.c
1205 @@ -97,6 +97,8 @@
1206 #include <net/sock.h>
1207 #include <linux/netfilter.h>
1208
1209 +#include <linux/ccsecurity.h>
1210 +
1211 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1212 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1213 size_t size, loff_t pos);
1214 @@ -544,9 +546,12 @@ static inline int __sock_sendmsg(struct
1215 si->size = size;
1216
1217 err = security_socket_sendmsg(sock, msg, size);
1218 + if (!err)
1219 + err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)
1220 + msg->msg_name,
1221 + msg->msg_namelen);
1222 if (err)
1223 return err;
1224 -
1225 return sock->ops->sendmsg(iocb, sock, msg, size);
1226 }
1227
1228 @@ -1100,6 +1105,8 @@ static int __sock_create(int family, int
1229 }
1230
1231 err = security_socket_create(family, type, protocol, kern);
1232 + if (!err)
1233 + err = ccs_socket_create_permission(family, type, protocol);
1234 if (err)
1235 return err;
1236
1237 @@ -1297,6 +1304,10 @@ SYSCALL_DEFINE3(bind, int, fd, struct so
1238 sockfd_put(sock);
1239 return err;
1240 }
1241 + err = ccs_socket_bind_permission(sock,
1242 + (struct sockaddr *)
1243 + address, addrlen);
1244 + if (!err)
1245 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1246 }
1247 sockfd_put(sock);
1248 @@ -1327,7 +1338,8 @@ SYSCALL_DEFINE2(listen, int, fd, int, ba
1249 sockfd_put(sock);
1250 return err;
1251 }
1252 -
1253 + err = ccs_socket_listen_permission(sock);
1254 + if (!err)
1255 err=sock->ops->listen(sock, backlog);
1256 sockfd_put(sock);
1257 }
1258 @@ -1379,6 +1391,11 @@ SYSCALL_DEFINE3(accept, int, fd, struct
1259 if (err < 0)
1260 goto out_release;
1261
1262 + if (ccs_socket_accept_permission(newsock,
1263 + (struct sockaddr *) address)) {
1264 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1265 + goto out_release;
1266 + }
1267 if (upeer_sockaddr) {
1268 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1269 err = -ECONNABORTED;
1270 @@ -1433,9 +1450,11 @@ SYSCALL_DEFINE3(connect, int, fd, struct
1271 goto out_put;
1272
1273 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1274 + if (!err)
1275 + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1276 + address, addrlen);
1277 if (err)
1278 goto out_put;
1279 -
1280 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1281 sock->file->f_flags);
1282 out_put:
1283 --- linux-2.6.15-54.78.orig/net/unix/af_unix.c
1284 +++ linux-2.6.15-54.78/net/unix/af_unix.c
1285 @@ -117,6 +117,7 @@
1286 #include <linux/mount.h>
1287 #include <net/checksum.h>
1288 #include <linux/security.h>
1289 +#include <linux/ccsecurity.h>
1290
1291 int sysctl_unix_max_dgram_qlen = 10;
1292
1293 @@ -781,6 +782,9 @@ static int unix_bind(struct socket *sock
1294 */
1295 mode = S_IFSOCK |
1296 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1297 + err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1298 + mode, 0);
1299 + if (!err)
1300 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1301 if (err)
1302 goto out_mknod_dput;
1303 --- linux-2.6.15-54.78.orig/security/Kconfig
1304 +++ linux-2.6.15-54.78/security/Kconfig
1305 @@ -94,5 +94,7 @@ config SECURITY_SECLVL
1306
1307 source security/selinux/Kconfig
1308
1309 +source security/ccsecurity/Kconfig
1310 +
1311 endmenu
1312
1313 --- linux-2.6.15-54.78.orig/security/Makefile
1314 +++ linux-2.6.15-54.78/security/Makefile
1315 @@ -19,3 +19,6 @@ obj-$(CONFIG_SECURITY_ROOTPLUG) += comm
1316 obj-$(CONFIG_SECURITY_REALTIME) += commoncap.o realcap.o
1317
1318 obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o
1319 +
1320 +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1321 +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

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