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

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.24-ubuntu-8.04.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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