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

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff

Parent Directory Parent Directory | Revision Log Revision Log


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