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

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.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.18-debian-etch.diff
File MIME type: text/x-diff
File size: 39720 byte(s)


1 This is TOMOYO Linux patch for Debian Etch.
2
3 Source code for this patch is "apt-get install linux-source-2.6.18"
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/inet_hashtables.c | 3 +++
38 net/ipv4/raw.c | 4 ++++
39 net/ipv4/udp.c | 10 +++++++++-
40 net/ipv6/inet6_hashtables.c | 5 ++++-
41 net/ipv6/raw.c | 4 ++++
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, 281 insertions(+), 9 deletions(-)
48
49 --- linux-2.6.18-24etch2.orig/arch/alpha/kernel/ptrace.c
50 +++ linux-2.6.18-24etch2/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.18-24etch2.orig/arch/ia64/ia32/sys_ia32.c
69 +++ linux-2.6.18-24etch2/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 @@ -1741,6 +1742,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.18-24etch2.orig/arch/ia64/kernel/ptrace.c
88 +++ linux-2.6.18-24etch2/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 @@ -1417,6 +1418,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.18-24etch2.orig/arch/m32r/kernel/ptrace.c
107 +++ linux-2.6.18-24etch2/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.18-24etch2.orig/arch/mips/kernel/ptrace32.c
126 +++ linux-2.6.18-24etch2/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.18-24etch2.orig/arch/powerpc/kernel/ptrace32.c
145 +++ linux-2.6.18-24etch2/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.18-24etch2.orig/arch/s390/kernel/ptrace.c
164 +++ linux-2.6.18-24etch2/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 @@ -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 if (request == PTRACE_TRACEME) {
181 ret = ptrace_traceme();
182 --- linux-2.6.18-24etch2.orig/arch/sparc/kernel/ptrace.c
183 +++ linux-2.6.18-24etch2/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.18-24etch2.orig/arch/sparc64/kernel/ptrace.c
204 +++ linux-2.6.18-24etch2/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.18-24etch2.orig/arch/x86_64/ia32/ptrace32.c
225 +++ linux-2.6.18-24etch2/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 @@ -230,6 +231,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.18-24etch2.orig/fs/attr.c
244 +++ linux-2.6.18-24etch2/fs/attr.c
245 @@ -15,6 +15,7 @@
246 #include <linux/fcntl.h>
247 #include <linux/quotaops.h>
248 #include <linux/security.h>
249 +#include <linux/ccsecurity.h>
250
251 /* Taken over from the old code... */
252
253 @@ -146,11 +147,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.18-24etch2.orig/fs/compat.c
270 +++ linux-2.6.18-24etch2/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 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
278
279 @@ -397,6 +398,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 @@ -421,6 +424,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 @@ -1567,7 +1574,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.18-24etch2.orig/fs/exec.c
309 +++ linux-2.6.18-24etch2/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 @@ asmlinkage long sys_uselib(const char __
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 @@ -486,6 +492,9 @@ struct file *open_exec(const char *name)
331 if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
332 S_ISREG(inode->i_mode)) {
333 int err = vfs_permission(&nd, MAY_EXEC);
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 @@ -1188,7 +1197,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.18-24etch2.orig/fs/fcntl.c
351 +++ linux-2.6.18-24etch2/fs/fcntl.c
352 @@ -22,6 +22,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 @@ -214,6 +215,9 @@ static int setfl(int fd, struct file * f
361 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
362 return -EPERM;
363
364 + if (((arg ^ filp->f_flags) & 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.18-24etch2.orig/fs/ioctl.c
371 +++ linux-2.6.18-24etch2/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 @@ asmlinkage long sys_ioctl(unsigned int f
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.18-24etch2.orig/fs/namei.c
399 +++ linux-2.6.18-24etch2/fs/namei.c
400 @@ -37,6 +37,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 @@ -1536,6 +1538,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 @@ -1567,6 +1574,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 @@ -1650,6 +1658,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 mutex_unlock(&dir->d_inode->i_mutex);
438 dput(nd->dentry);
439 @@ -1848,6 +1859,9 @@ asmlinkage long sys_mknodat(int dfd, con
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 @@ -1921,6 +1935,9 @@ asmlinkage long sys_mkdirat(int dfd, con
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 @@ -2029,6 +2046,9 @@ static long do_rmdir(int dfd, const char
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 @@ -2109,6 +2129,9 @@ static long do_unlinkat(int dfd, const c
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 @@ -2187,6 +2210,9 @@ asmlinkage long sys_symlinkat(const char
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 @@ -2281,6 +2307,9 @@ asmlinkage long sys_linkat(int olddfd, c
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 @@ -2507,6 +2536,9 @@ static int do_rename(int olddfd, const c
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.18-24etch2.orig/fs/namespace.c
510 +++ linux-2.6.18-24etch2/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 @@ -553,6 +554,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 @@ -641,6 +645,8 @@ asmlinkage long sys_umount(char __user *
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 @@ -925,6 +931,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 @@ -1009,7 +1018,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 mutex_lock(&nd->dentry->d_inode->i_mutex);
558 if (IS_DEADDIR(nd->dentry->d_inode))
559 @@ -1111,6 +1122,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 @@ -1402,6 +1416,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 @@ -1691,6 +1709,8 @@ asmlinkage long sys_pivot_root(const cha
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 @@ -1707,6 +1727,8 @@ asmlinkage long sys_pivot_root(const cha
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.18-24etch2.orig/fs/open.c
599 +++ linux-2.6.18-24etch2/fs/open.c
600 @@ -30,6 +30,7 @@
601 #include <linux/audit.h>
602
603 #include <asm/unistd.h>
604 +#include <linux/ccsecurity.h>
605
606 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
607 {
608 @@ -267,6 +268,8 @@ static long do_sys_truncate(const char _
609 if (error)
610 goto dput_and_out;
611
612 + error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
613 + if (!error)
614 error = locks_verify_truncate(inode, NULL, length);
615 if (!error) {
616 DQUOT_INIT(inode);
617 @@ -320,6 +323,9 @@ static long do_sys_ftruncate(unsigned in
618 if (IS_APPEND(inode))
619 goto out_putf;
620
621 + error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
622 + if (error)
623 + goto out_putf;
624 error = locks_verify_truncate(inode, file, length);
625 if (!error)
626 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
627 @@ -608,6 +614,10 @@ asmlinkage long sys_chroot(const char __
628 error = -EPERM;
629 if (!capable(CAP_SYS_CHROOT))
630 goto dput_and_out;
631 + if (!ccs_capable(CCS_SYS_CHROOT))
632 + goto dput_and_out;
633 + if (ccs_chroot_permission(&nd))
634 + goto dput_and_out;
635
636 set_fs_root(current->fs, nd.mnt, nd.dentry);
637 set_fs_altroot();
638 @@ -641,6 +651,9 @@ asmlinkage long sys_fchmod(unsigned int
639 err = -EPERM;
640 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
641 goto out_putf;
642 + err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
643 + if (err)
644 + goto out_putf;
645 mutex_lock(&inode->i_mutex);
646 if (mode == (mode_t) -1)
647 mode = inode->i_mode;
648 @@ -675,6 +688,9 @@ asmlinkage long sys_fchmodat(int dfd, co
649 error = -EPERM;
650 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
651 goto dput_and_out;
652 + error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
653 + if (error)
654 + goto dput_and_out;
655
656 mutex_lock(&inode->i_mutex);
657 if (mode == (mode_t) -1)
658 @@ -737,6 +753,8 @@ asmlinkage long sys_chown(const char __u
659
660 error = user_path_walk(filename, &nd);
661 if (!error) {
662 + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
663 + if (!error)
664 error = chown_common(nd.dentry, user, group);
665 path_release(&nd);
666 }
667 @@ -756,6 +774,8 @@ asmlinkage long sys_fchownat(int dfd, co
668 follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
669 error = __user_walk_fd(dfd, filename, follow, &nd);
670 if (!error) {
671 + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
672 + if (!error)
673 error = chown_common(nd.dentry, user, group);
674 path_release(&nd);
675 }
676 @@ -770,6 +790,8 @@ asmlinkage long sys_lchown(const char __
677
678 error = user_path_walk_link(filename, &nd);
679 if (!error) {
680 + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
681 + if (!error)
682 error = chown_common(nd.dentry, user, group);
683 path_release(&nd);
684 }
685 @@ -787,6 +809,9 @@ asmlinkage long sys_fchown(unsigned int
686 struct dentry * dentry;
687 dentry = file->f_dentry;
688 audit_inode(NULL, dentry->d_inode);
689 + error = ccs_chown_permission(dentry, file->f_vfsmnt, user,
690 + group);
691 + if (!error)
692 error = chown_common(dentry, user, group);
693 fput(file);
694 }
695 @@ -1199,6 +1224,8 @@ EXPORT_SYMBOL(sys_close);
696 */
697 asmlinkage long sys_vhangup(void)
698 {
699 + if (!ccs_capable(CCS_SYS_VHANGUP))
700 + return -EPERM;
701 if (capable(CAP_SYS_TTY_CONFIG)) {
702 tty_vhangup(current->signal->tty);
703 return 0;
704 --- linux-2.6.18-24etch2.orig/fs/proc/proc_misc.c
705 +++ linux-2.6.18-24etch2/fs/proc/proc_misc.c
706 @@ -723,4 +723,5 @@ void __init proc_misc_init(void)
707 if (entry)
708 entry->proc_fops = &proc_sysrq_trigger_operations;
709 #endif
710 + printk(KERN_INFO "Hook version: 2.6.18-24etch2 2009/08/08\n");
711 }
712 --- linux-2.6.18-24etch2.orig/include/linux/init_task.h
713 +++ linux-2.6.18-24etch2/include/linux/init_task.h
714 @@ -128,6 +128,8 @@ extern struct group_info init_groups;
715 .pi_lock = SPIN_LOCK_UNLOCKED, \
716 INIT_TRACE_IRQFLAGS \
717 INIT_LOCKDEP \
718 + .ccs_domain_info = NULL, \
719 + .ccs_flags = 0, \
720 }
721
722
723 --- linux-2.6.18-24etch2.orig/include/linux/sched.h
724 +++ linux-2.6.18-24etch2/include/linux/sched.h
725 @@ -25,6 +25,8 @@
726 #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
727 #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
728
729 +struct ccs_domain_info;
730 +
731 /*
732 * Scheduling policies
733 */
734 @@ -996,6 +998,8 @@ struct task_struct {
735 #ifdef CONFIG_TASK_DELAY_ACCT
736 struct task_delay_info *delays;
737 #endif
738 + struct ccs_domain_info *ccs_domain_info;
739 + u32 ccs_flags;
740 };
741
742 static inline pid_t process_group(struct task_struct *tsk)
743 --- linux-2.6.18-24etch2.orig/kernel/compat.c
744 +++ linux-2.6.18-24etch2/kernel/compat.c
745 @@ -24,6 +24,7 @@
746 #include <linux/migrate.h>
747
748 #include <asm/uaccess.h>
749 +#include <linux/ccsecurity.h>
750
751 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
752 {
753 @@ -836,6 +837,8 @@ asmlinkage long compat_sys_stime(compat_
754 err = security_settime(&tv, NULL);
755 if (err)
756 return err;
757 + if (!ccs_capable(CCS_SYS_SETTIME))
758 + return -EPERM;
759
760 do_settimeofday(&tv);
761 return 0;
762 --- linux-2.6.18-24etch2.orig/kernel/kexec.c
763 +++ linux-2.6.18-24etch2/kernel/kexec.c
764 @@ -26,6 +26,7 @@
765 #include <asm/io.h>
766 #include <asm/system.h>
767 #include <asm/semaphore.h>
768 +#include <linux/ccsecurity.h>
769
770 /* Per cpu memory for storing cpu states in case of system crash. */
771 note_buf_t* crash_notes;
772 @@ -922,6 +923,8 @@ asmlinkage long sys_kexec_load(unsigned
773 /* We only trust the superuser with rebooting the system. */
774 if (!capable(CAP_SYS_BOOT))
775 return -EPERM;
776 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
777 + return -EPERM;
778
779 /*
780 * Verify we have a legal set of flags
781 --- linux-2.6.18-24etch2.orig/kernel/kmod.c
782 +++ linux-2.6.18-24etch2/kernel/kmod.c
783 @@ -148,6 +148,9 @@ static int ____call_usermodehelper(void
784 /* We can run anywhere, unlike our parent keventd(). */
785 set_cpus_allowed(current, CPU_MASK_ALL);
786
787 + current->ccs_domain_info = NULL;
788 + current->ccs_flags = 0;
789 +
790 retval = -EPERM;
791 if (current->fs->root)
792 retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
793 --- linux-2.6.18-24etch2.orig/kernel/module.c
794 +++ linux-2.6.18-24etch2/kernel/module.c
795 @@ -44,6 +44,7 @@
796 #include <asm/semaphore.h>
797 #include <asm/cacheflush.h>
798 #include <linux/license.h>
799 +#include <linux/ccsecurity.h>
800
801 #if 0
802 #define DEBUGP printk
803 @@ -652,7 +653,8 @@ sys_delete_module(const char __user *nam
804
805 if (!capable(CAP_SYS_MODULE))
806 return -EPERM;
807 -
808 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
809 + return -EPERM;
810 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
811 return -EFAULT;
812 name[MODULE_NAME_LEN-1] = '\0';
813 @@ -1884,7 +1886,8 @@ sys_init_module(void __user *umod,
814 /* Must have permission */
815 if (!capable(CAP_SYS_MODULE))
816 return -EPERM;
817 -
818 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
819 + return -EPERM;
820 /* Only one module load at a time, please */
821 if (mutex_lock_interruptible(&module_mutex) != 0)
822 return -EINTR;
823 --- linux-2.6.18-24etch2.orig/kernel/ptrace.c
824 +++ linux-2.6.18-24etch2/kernel/ptrace.c
825 @@ -21,6 +21,7 @@
826
827 #include <asm/pgtable.h>
828 #include <asm/uaccess.h>
829 +#include <linux/ccsecurity.h>
830
831 /*
832 * ptrace a task: make the debugger its new parent and
833 @@ -509,6 +510,8 @@ asmlinkage long sys_ptrace(long request,
834 /*
835 * This lock_kernel fixes a subtle race with suid exec
836 */
837 + if (!ccs_capable(CCS_SYS_PTRACE))
838 + return -EPERM;
839 lock_kernel();
840 if (request == PTRACE_TRACEME) {
841 ret = ptrace_traceme();
842 --- linux-2.6.18-24etch2.orig/kernel/sched.c
843 +++ linux-2.6.18-24etch2/kernel/sched.c
844 @@ -55,6 +55,7 @@
845 #include <asm/tlb.h>
846
847 #include <asm/unistd.h>
848 +#include <linux/ccsecurity.h>
849
850 /*
851 * Convert user-nice values [ -20 ... 0 ... 19 ]
852 @@ -3939,6 +3940,8 @@ int can_nice(const struct task_struct *p
853 asmlinkage long sys_nice(int increment)
854 {
855 long nice, retval;
856 + if (!ccs_capable(CCS_SYS_NICE))
857 + return -EPERM;
858
859 /*
860 * Setpriority might change our priority at the same moment.
861 --- linux-2.6.18-24etch2.orig/kernel/signal.c
862 +++ linux-2.6.18-24etch2/kernel/signal.c
863 @@ -28,6 +28,7 @@
864 #include <asm/unistd.h>
865 #include <asm/siginfo.h>
866 #include "audit.h" /* audit_signal_info() */
867 +#include <linux/ccsecurity.h>
868
869 /*
870 * SLAB caches for signal bits.
871 @@ -2183,6 +2184,8 @@ asmlinkage long
872 sys_kill(int pid, int sig)
873 {
874 struct siginfo info;
875 + if (ccs_kill_permission(pid, sig))
876 + return -EPERM;
877
878 info.si_signo = sig;
879 info.si_errno = 0;
880 @@ -2241,6 +2244,8 @@ asmlinkage long sys_tgkill(int tgid, int
881 /* This is only valid for single tasks */
882 if (pid <= 0 || tgid <= 0)
883 return -EINVAL;
884 + if (ccs_tgkill_permission(tgid, pid, sig))
885 + return -EPERM;
886
887 return do_tkill(tgid, pid, sig);
888 }
889 @@ -2254,6 +2259,8 @@ sys_tkill(int pid, int sig)
890 /* This is only valid for single tasks */
891 if (pid <= 0)
892 return -EINVAL;
893 + if (ccs_tkill_permission(pid, sig))
894 + return -EPERM;
895
896 return do_tkill(0, pid, sig);
897 }
898 @@ -2271,6 +2278,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
899 if (info.si_code >= 0)
900 return -EPERM;
901 info.si_signo = sig;
902 + if (ccs_sigqueue_permission(pid, sig))
903 + return -EPERM;
904
905 /* POSIX.1b doesn't mention process groups. */
906 return kill_proc_info(sig, &info, pid);
907 --- linux-2.6.18-24etch2.orig/kernel/sys.c
908 +++ linux-2.6.18-24etch2/kernel/sys.c
909 @@ -36,6 +36,7 @@
910 #include <asm/uaccess.h>
911 #include <asm/io.h>
912 #include <asm/unistd.h>
913 +#include <linux/ccsecurity.h>
914
915 #ifndef SET_UNALIGN_CTL
916 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
917 @@ -467,6 +468,10 @@ asmlinkage long sys_setpriority(int whic
918
919 if (which > 2 || which < 0)
920 goto out;
921 + if (!ccs_capable(CCS_SYS_NICE)) {
922 + error = -EPERM;
923 + goto out;
924 + }
925
926 /* normalize: avoid signed division (rounding problems) */
927 error = -ESRCH;
928 @@ -693,6 +698,8 @@ asmlinkage long sys_reboot(int magic1, i
929 magic2 != LINUX_REBOOT_MAGIC2B &&
930 magic2 != LINUX_REBOOT_MAGIC2C))
931 return -EINVAL;
932 + if (!ccs_capable(CCS_SYS_REBOOT))
933 + return -EPERM;
934
935 /* Instead of trying to make the power_off code look like
936 * halt when pm_power_off is not set do it the easy way.
937 @@ -1690,6 +1697,8 @@ asmlinkage long sys_sethostname(char __u
938 return -EPERM;
939 if (len < 0 || len > __NEW_UTS_LEN)
940 return -EINVAL;
941 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
942 + return -EPERM;
943 down_write(&uts_sem);
944 errno = -EFAULT;
945 if (!copy_from_user(tmp, name, len)) {
946 @@ -1735,6 +1744,8 @@ asmlinkage long sys_setdomainname(char _
947 return -EPERM;
948 if (len < 0 || len > __NEW_UTS_LEN)
949 return -EINVAL;
950 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
951 + return -EPERM;
952
953 down_write(&uts_sem);
954 errno = -EFAULT;
955 --- linux-2.6.18-24etch2.orig/kernel/sysctl.c
956 +++ linux-2.6.18-24etch2/kernel/sysctl.c
957 @@ -48,6 +48,7 @@
958
959 #include <asm/uaccess.h>
960 #include <asm/processor.h>
961 +#include <linux/ccsecurity.h>
962
963 extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
964 void __user *buffer, size_t *lenp, loff_t *ppos);
965 @@ -1169,6 +1170,9 @@ int do_sysctl(int __user *name, int nlen
966
967 spin_unlock(&sysctl_lock);
968
969 + error = ccs_parse_table(name, nlen, oldval, newval,
970 + head->ctl_table);
971 + if (!error)
972 error = parse_table(name, nlen, oldval, oldlenp,
973 newval, newlen, head->ctl_table,
974 &context);
975 @@ -1241,6 +1245,13 @@ repeat:
976 if (ctl_perm(table, 001))
977 return -EPERM;
978 if (table->strategy) {
979 + int op = 0;
980 + if (oldval)
981 + op |= 004;
982 + if (newval)
983 + op |= 002;
984 + if (ctl_perm(table, op))
985 + return -EPERM;
986 error = table->strategy(
987 table, name, nlen,
988 oldval, oldlenp,
989 --- linux-2.6.18-24etch2.orig/kernel/time.c
990 +++ linux-2.6.18-24etch2/kernel/time.c
991 @@ -39,6 +39,7 @@
992
993 #include <asm/uaccess.h>
994 #include <asm/unistd.h>
995 +#include <linux/ccsecurity.h>
996
997 /*
998 * The timezone where the local system is located. Used as a default by some
999 @@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user
1000 err = security_settime(&tv, NULL);
1001 if (err)
1002 return err;
1003 + if (!ccs_capable(CCS_SYS_SETTIME))
1004 + return -EPERM;
1005
1006 do_settimeofday(&tv);
1007 return 0;
1008 @@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec
1009 error = security_settime(tv, tz);
1010 if (error)
1011 return error;
1012 + if (!ccs_capable(CCS_SYS_SETTIME))
1013 + return -EPERM;
1014
1015 if (tz) {
1016 /* SMP safe, global irq locking makes it work. */
1017 @@ -221,6 +226,8 @@ int do_adjtimex(struct timex *txc)
1018 /* In order to modify anything, you gotta be super-user! */
1019 if (txc->modes && !capable(CAP_SYS_TIME))
1020 return -EPERM;
1021 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1022 + return -EPERM;
1023
1024 /* Now we validate the data before disabling interrupts */
1025
1026 --- linux-2.6.18-24etch2.orig/net/ipv4/inet_connection_sock.c
1027 +++ linux-2.6.18-24etch2/net/ipv4/inet_connection_sock.c
1028 @@ -23,6 +23,7 @@
1029 #include <net/route.h>
1030 #include <net/tcp_states.h>
1031 #include <net/xfrm.h>
1032 +#include <linux/ccsecurity.h>
1033
1034 #ifdef INET_CSK_DEBUG
1035 const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1036 @@ -87,6 +88,8 @@ int inet_csk_get_port(struct inet_hashin
1037 do {
1038 head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1039 spin_lock(&head->lock);
1040 + if (ccs_lport_reserved(rover))
1041 + goto next;
1042 inet_bind_bucket_for_each(tb, node, &head->chain)
1043 if (tb->port == rover)
1044 goto next;
1045 --- linux-2.6.18-24etch2.orig/net/ipv4/inet_hashtables.c
1046 +++ linux-2.6.18-24etch2/net/ipv4/inet_hashtables.c
1047 @@ -22,6 +22,7 @@
1048 #include <net/inet_connection_sock.h>
1049 #include <net/inet_hashtables.h>
1050 #include <net/ip.h>
1051 +#include <linux/ccsecurity.h>
1052
1053 /*
1054 * Allocate and initialize a new local port bind bucket.
1055 @@ -263,6 +264,8 @@ int inet_hash_connect(struct inet_timewa
1056 local_bh_disable();
1057 for (i = 1; i <= range; i++) {
1058 port = low + (i + offset) % range;
1059 + if (ccs_lport_reserved(port))
1060 + continue;
1061 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1062 spin_lock(&head->lock);
1063
1064 --- linux-2.6.18-24etch2.orig/net/ipv4/raw.c
1065 +++ linux-2.6.18-24etch2/net/ipv4/raw.c
1066 @@ -79,6 +79,7 @@
1067 #include <linux/seq_file.h>
1068 #include <linux/netfilter.h>
1069 #include <linux/netfilter_ipv4.h>
1070 +#include <linux/ccsecurity.h>
1071
1072 struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1073 DEFINE_RWLOCK(raw_v4_lock);
1074 @@ -592,6 +593,9 @@ static int raw_recvmsg(struct kiocb *ioc
1075 skb = skb_recv_datagram(sk, flags, noblock, &err);
1076 if (!skb)
1077 goto out;
1078 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1079 + if (err)
1080 + goto out;
1081
1082 copied = skb->len;
1083 if (len < copied) {
1084 --- linux-2.6.18-24etch2.orig/net/ipv4/udp.c
1085 +++ linux-2.6.18-24etch2/net/ipv4/udp.c
1086 @@ -108,6 +108,7 @@
1087 #include <net/inet_common.h>
1088 #include <net/checksum.h>
1089 #include <net/xfrm.h>
1090 +#include <linux/ccsecurity.h>
1091
1092 /*
1093 * Snmp MIB for the UDP layer
1094 @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1095 result = sysctl_local_port_range[0] +
1096 ((result - sysctl_local_port_range[0]) &
1097 (UDP_HTABLE_SIZE - 1));
1098 + if (ccs_lport_reserved(result))
1099 + continue;
1100 goto gotit;
1101 }
1102 size = 0;
1103 @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1104 result = sysctl_local_port_range[0]
1105 + ((result - sysctl_local_port_range[0]) &
1106 (UDP_HTABLE_SIZE - 1));
1107 + if (ccs_lport_reserved(result))
1108 + continue;
1109 if (!udp_lport_inuse(result))
1110 break;
1111 }
1112 @@ -796,7 +801,10 @@ try_again:
1113 skb = skb_recv_datagram(sk, flags, noblock, &err);
1114 if (!skb)
1115 goto out;
1116 -
1117 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1118 + if (err)
1119 + goto out;
1120 +
1121 copied = skb->len - sizeof(struct udphdr);
1122 if (copied > len) {
1123 copied = len;
1124 --- linux-2.6.18-24etch2.orig/net/ipv6/inet6_hashtables.c
1125 +++ linux-2.6.18-24etch2/net/ipv6/inet6_hashtables.c
1126 @@ -21,6 +21,7 @@
1127 #include <net/inet_hashtables.h>
1128 #include <net/inet6_hashtables.h>
1129 #include <net/ip.h>
1130 +#include <linux/ccsecurity.h>
1131
1132 void __inet6_hash(struct inet_hashinfo *hashinfo,
1133 struct sock *sk)
1134 @@ -172,7 +173,7 @@ static int __inet6_check_established(str
1135 const struct in6_addr *saddr = &np->daddr;
1136 const int dif = sk->sk_bound_dev_if;
1137 const u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
1138 - const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr,
1139 + const unsigned int hash = inet6_ehashfn(daddr, lport, saddr,
1140 inet->dport);
1141 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
1142 struct sock *sk2;
1143 @@ -266,6 +267,8 @@ int inet6_hash_connect(struct inet_timew
1144 local_bh_disable();
1145 for (i = 1; i <= range; i++) {
1146 port = low + (i + offset) % range;
1147 + if (ccs_lport_reserved(port))
1148 + continue;
1149 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1150 spin_lock(&head->lock);
1151
1152 --- linux-2.6.18-24etch2.orig/net/ipv6/raw.c
1153 +++ linux-2.6.18-24etch2/net/ipv6/raw.c
1154 @@ -56,6 +56,7 @@
1155
1156 #include <linux/proc_fs.h>
1157 #include <linux/seq_file.h>
1158 +#include <linux/ccsecurity.h>
1159
1160 struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1161 DEFINE_RWLOCK(raw_v6_lock);
1162 @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1163 skb = skb_recv_datagram(sk, flags, noblock, &err);
1164 if (!skb)
1165 goto out;
1166 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1167 + if (err)
1168 + goto out;
1169
1170 copied = skb->len;
1171 if (copied > len) {
1172 --- linux-2.6.18-24etch2.orig/net/ipv6/udp.c
1173 +++ linux-2.6.18-24etch2/net/ipv6/udp.c
1174 @@ -58,6 +58,7 @@
1175
1176 #include <linux/proc_fs.h>
1177 #include <linux/seq_file.h>
1178 +#include <linux/ccsecurity.h>
1179
1180 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1181
1182 @@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1183 result = sysctl_local_port_range[0] +
1184 ((result - sysctl_local_port_range[0]) &
1185 (UDP_HTABLE_SIZE - 1));
1186 + if (ccs_lport_reserved(result))
1187 + continue;
1188 goto gotit;
1189 }
1190 size = 0;
1191 @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1192 result = sysctl_local_port_range[0]
1193 + ((result - sysctl_local_port_range[0]) &
1194 (UDP_HTABLE_SIZE - 1));
1195 + if (ccs_lport_reserved(result))
1196 + continue;
1197 if (!udp_lport_inuse(result))
1198 break;
1199 }
1200 @@ -237,6 +242,9 @@ try_again:
1201 skb = skb_recv_datagram(sk, flags, noblock, &err);
1202 if (!skb)
1203 goto out;
1204 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1205 + if (err)
1206 + goto out;
1207
1208 copied = skb->len - sizeof(struct udphdr);
1209 if (copied > len) {
1210 --- linux-2.6.18-24etch2.orig/net/socket.c
1211 +++ linux-2.6.18-24etch2/net/socket.c
1212 @@ -94,6 +94,8 @@
1213 #include <net/sock.h>
1214 #include <linux/netfilter.h>
1215
1216 +#include <linux/ccsecurity.h>
1217 +
1218 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1219 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1220 size_t size, loff_t pos);
1221 @@ -590,9 +592,12 @@ static inline int __sock_sendmsg(struct
1222 si->size = size;
1223
1224 err = security_socket_sendmsg(sock, msg, size);
1225 + if (!err)
1226 + err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)
1227 + msg->msg_name,
1228 + msg->msg_namelen);
1229 if (err)
1230 return err;
1231 -
1232 return sock->ops->sendmsg(iocb, sock, msg, size);
1233 }
1234
1235 @@ -1149,6 +1154,8 @@ static int __sock_create(int family, int
1236 }
1237
1238 err = security_socket_create(family, type, protocol, kern);
1239 + if (!err)
1240 + err = ccs_socket_create_permission(family, type, protocol);
1241 if (err)
1242 return err;
1243
1244 @@ -1343,6 +1350,11 @@ asmlinkage long sys_bind(int fd, struct
1245 if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
1246 err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);
1247 if (!err)
1248 + err = ccs_socket_bind_permission(sock,
1249 + (struct sockaddr *)
1250 + address,
1251 + addrlen);
1252 + if (!err)
1253 err = sock->ops->bind(sock,
1254 (struct sockaddr *)address, addrlen);
1255 }
1256 @@ -1371,6 +1383,8 @@ asmlinkage long sys_listen(int fd, int b
1257
1258 err = security_socket_listen(sock, backlog);
1259 if (!err)
1260 + err = ccs_socket_listen_permission(sock);
1261 + if (!err)
1262 err = sock->ops->listen(sock, backlog);
1263
1264 fput_light(sock->file, fput_needed);
1265 @@ -1434,6 +1448,11 @@ asmlinkage long sys_accept(int fd, struc
1266 if (err < 0)
1267 goto out_fd;
1268
1269 + if (ccs_socket_accept_permission(newsock,
1270 + (struct sockaddr *) address)) {
1271 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1272 + goto out_fd;
1273 + }
1274 if (upeer_sockaddr) {
1275 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1276 err = -ECONNABORTED;
1277 @@ -1488,9 +1507,11 @@ asmlinkage long sys_connect(int fd, stru
1278 goto out_put;
1279
1280 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1281 + if (!err)
1282 + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1283 + address, addrlen);
1284 if (err)
1285 goto out_put;
1286 -
1287 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1288 sock->file->f_flags);
1289 out_put:
1290 --- linux-2.6.18-24etch2.orig/net/unix/af_unix.c
1291 +++ linux-2.6.18-24etch2/net/unix/af_unix.c
1292 @@ -116,6 +116,7 @@
1293 #include <linux/mount.h>
1294 #include <net/checksum.h>
1295 #include <linux/security.h>
1296 +#include <linux/ccsecurity.h>
1297
1298 int sysctl_unix_max_dgram_qlen = 10;
1299
1300 @@ -807,6 +808,9 @@ static int unix_bind(struct socket *sock
1301 */
1302 mode = S_IFSOCK |
1303 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1304 + err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1305 + mode, 0);
1306 + if (!err)
1307 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1308 if (err)
1309 goto out_mknod_dput;
1310 --- linux-2.6.18-24etch2.orig/security/Kconfig
1311 +++ linux-2.6.18-24etch2/security/Kconfig
1312 @@ -107,5 +107,7 @@ config SECURITY_SECLVL
1313
1314 source security/selinux/Kconfig
1315
1316 +source security/ccsecurity/Kconfig
1317 +
1318 endmenu
1319
1320 --- linux-2.6.18-24etch2.orig/security/Makefile
1321 +++ linux-2.6.18-24etch2/security/Makefile
1322 @@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin
1323 obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o
1324 obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o
1325 obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o
1326 +
1327 +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1328 +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

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