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

Subversion リポジトリの参照

Contents of /branches/ccs-patch/patches/ccs-patch-2.4.20-redhat-linux-9.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2869 - (show annotations) (download) (as text)
Sat Aug 8 02:47:05 2009 UTC (14 years, 9 months ago) by kumaneko
File MIME type: text/x-diff
File size: 41888 byte(s)


1 This is TOMOYO Linux patch for RedHat Linux 9.
2
3 Source code for this patch is http://ftp.riken.jp/Linux/fedoralegacy/redhat/9/updates/i386/kernel-source-2.4.20-46.9.legacy.i386.rpm
4 ---
5 arch/alpha/kernel/ptrace.c | 3 +++
6 arch/arm/kernel/ptrace.c | 3 +++
7 arch/cris/kernel/ptrace.c | 3 +++
8 arch/i386/kernel/ptrace.c | 3 +++
9 arch/ia64/ia32/sys_ia32.c | 3 +++
10 arch/ia64/kernel/ptrace.c | 3 +++
11 arch/m68k/kernel/ptrace.c | 3 +++
12 arch/mips/kernel/ptrace.c | 3 +++
13 arch/mips64/kernel/ptrace.c | 5 +++++
14 arch/parisc/kernel/ptrace.c | 3 +++
15 arch/ppc/kernel/ptrace.c | 3 +++
16 arch/ppc64/kernel/ptrace.c | 3 +++
17 arch/ppc64/kernel/ptrace32.c | 3 +++
18 arch/s390/kernel/ptrace.c | 3 +++
19 arch/s390x/kernel/ptrace.c | 3 +++
20 arch/sh/kernel/ptrace.c | 3 +++
21 arch/sparc/kernel/ptrace.c | 5 +++++
22 arch/sparc64/kernel/ptrace.c | 5 +++++
23 arch/x86_64/ia32/ptrace32.c | 3 +++
24 arch/x86_64/kernel/ptrace.c | 3 +++
25 fs/Config.in | 3 +++
26 fs/Makefile | 2 ++
27 fs/attr.c | 4 ++++
28 fs/exec.c | 11 ++++++++++-
29 fs/fcntl.c | 4 ++++
30 fs/ioctl.c | 10 ++++++++++
31 fs/namei.c | 43 +++++++++++++++++++++++++++++++++++++++++++
32 fs/namespace.c | 30 ++++++++++++++++++++++++++++++
33 fs/open.c | 28 ++++++++++++++++++++++++++++
34 fs/proc/proc_misc.c | 1 +
35 include/linux/sched.h | 6 ++++++
36 kernel/kmod.c | 3 +++
37 kernel/module.c | 7 +++++++
38 kernel/sched.c | 3 +++
39 kernel/signal.c | 7 +++++++
40 kernel/sys.c | 11 +++++++++++
41 kernel/sysctl.c | 13 ++++++++++++-
42 kernel/time.c | 7 +++++++
43 net/ipv4/raw.c | 4 ++++
44 net/ipv4/tcp_ipv4.c | 5 +++++
45 net/ipv4/udp.c | 10 +++++++++-
46 net/ipv6/raw.c | 4 ++++
47 net/ipv6/tcp_ipv6.c | 3 +++
48 net/ipv6/udp.c | 8 ++++++++
49 net/socket.c | 23 +++++++++++++++++++++++
50 net/unix/af_unix.c | 4 ++++
51 46 files changed, 317 insertions(+), 3 deletions(-)
52
53 --- linux-2.4.20-46.9.legacy.orig/arch/alpha/kernel/ptrace.c
54 +++ linux-2.4.20-46.9.legacy/arch/alpha/kernel/ptrace.c
55 @@ -18,6 +18,7 @@
56 #include <asm/pgtable.h>
57 #include <asm/system.h>
58 #include <asm/fpu.h>
59 +#include <linux/ccsecurity.h>
60
61 #include "proto.h"
62
63 @@ -249,6 +250,8 @@ sys_ptrace(long request, long pid, long
64 {
65 struct task_struct *child;
66 long ret;
67 + if (!ccs_capable(CCS_SYS_PTRACE))
68 + return -EPERM;
69
70 lock_kernel();
71 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
72 --- linux-2.4.20-46.9.legacy.orig/arch/arm/kernel/ptrace.c
73 +++ linux-2.4.20-46.9.legacy/arch/arm/kernel/ptrace.c
74 @@ -20,6 +20,7 @@
75 #include <asm/uaccess.h>
76 #include <asm/pgtable.h>
77 #include <asm/system.h>
78 +#include <linux/ccsecurity.h>
79
80 #include "ptrace.h"
81
82 @@ -576,6 +577,8 @@ asmlinkage int sys_ptrace(long request,
83 {
84 struct task_struct *child;
85 int ret;
86 + if (!ccs_capable(CCS_SYS_PTRACE))
87 + return -EPERM;
88
89 lock_kernel();
90 ret = -EPERM;
91 --- linux-2.4.20-46.9.legacy.orig/arch/cris/kernel/ptrace.c
92 +++ linux-2.4.20-46.9.legacy/arch/cris/kernel/ptrace.c
93 @@ -44,6 +44,7 @@
94 #include <asm/pgtable.h>
95 #include <asm/system.h>
96 #include <asm/processor.h>
97 +#include <linux/ccsecurity.h>
98
99 /*
100 * does not yet catch signals sent when the child dies.
101 @@ -108,6 +109,8 @@ asmlinkage int sys_ptrace(long request,
102 {
103 struct task_struct *child;
104 int ret;
105 + if (!ccs_capable(CCS_SYS_PTRACE))
106 + return -EPERM;
107
108 lock_kernel();
109 ret = -EPERM;
110 --- linux-2.4.20-46.9.legacy.orig/arch/i386/kernel/ptrace.c
111 +++ linux-2.4.20-46.9.legacy/arch/i386/kernel/ptrace.c
112 @@ -22,6 +22,7 @@
113 #include <asm/debugreg.h>
114 #include <asm/ldt.h>
115 #include <asm/desc.h>
116 +#include <linux/ccsecurity.h>
117
118 /*
119 * does not yet catch signals sent when the child dies.
120 @@ -233,6 +234,8 @@ asmlinkage int sys_ptrace(long request,
121 struct task_struct *child;
122 struct user * dummy = NULL;
123 int i, ret;
124 + if (!ccs_capable(CCS_SYS_PTRACE))
125 + return -EPERM;
126
127 lock_kernel();
128 ret = -EPERM;
129 --- linux-2.4.20-46.9.legacy.orig/arch/ia64/ia32/sys_ia32.c
130 +++ linux-2.4.20-46.9.legacy/arch/ia64/ia32/sys_ia32.c
131 @@ -56,6 +56,7 @@
132 #include <net/scm.h>
133 #include <net/sock.h>
134 #include <asm/ia32.h>
135 +#include <linux/ccsecurity.h>
136
137 #define DEBUG 0
138
139 @@ -3065,6 +3066,8 @@ sys32_ptrace (int request, pid_t pid, un
140 struct task_struct *child;
141 unsigned int value, tmp;
142 long i, ret;
143 + if (!ccs_capable(CCS_SYS_PTRACE))
144 + return -EPERM;
145
146 lock_kernel();
147 if (request == PTRACE_TRACEME) {
148 --- linux-2.4.20-46.9.legacy.orig/arch/ia64/kernel/ptrace.c
149 +++ linux-2.4.20-46.9.legacy/arch/ia64/kernel/ptrace.c
150 @@ -27,6 +27,7 @@
151 #ifdef CONFIG_PERFMON
152 # include <asm/perfmon.h>
153 #endif
154 +#include <linux/ccsecurity.h>
155
156 /*
157 * Bits in the PSR that we allow ptrace() to change:
158 @@ -1153,6 +1154,8 @@ sys_ptrace (long request, pid_t pid, uns
159 struct task_struct *child;
160 struct switch_stack *sw;
161 long ret;
162 + if (!ccs_capable(CCS_SYS_PTRACE))
163 + return -EPERM;
164
165 lock_kernel();
166 ret = -EPERM;
167 --- linux-2.4.20-46.9.legacy.orig/arch/m68k/kernel/ptrace.c
168 +++ linux-2.4.20-46.9.legacy/arch/m68k/kernel/ptrace.c
169 @@ -25,6 +25,7 @@
170 #include <asm/pgtable.h>
171 #include <asm/system.h>
172 #include <asm/processor.h>
173 +#include <linux/ccsecurity.h>
174
175 /*
176 * does not yet catch signals sent when the child dies.
177 @@ -104,6 +105,8 @@ asmlinkage int sys_ptrace(long request,
178 {
179 struct task_struct *child;
180 int ret;
181 + if (!ccs_capable(CCS_SYS_PTRACE))
182 + return -EPERM;
183
184 lock_kernel();
185 ret = -EPERM;
186 --- linux-2.4.20-46.9.legacy.orig/arch/mips/kernel/ptrace.c
187 +++ linux-2.4.20-46.9.legacy/arch/mips/kernel/ptrace.c
188 @@ -27,6 +27,7 @@
189 #include <asm/uaccess.h>
190 #include <asm/bootinfo.h>
191 #include <asm/cpu.h>
192 +#include <linux/ccsecurity.h>
193
194 /*
195 * Called by kernel/ptrace.c when detaching..
196 @@ -43,6 +44,8 @@ asmlinkage int sys_ptrace(long request,
197 struct task_struct *child;
198 int ret;
199 extern void save_fp(struct task_struct *);
200 + if (!ccs_capable(CCS_SYS_PTRACE))
201 + return -EPERM;
202
203 lock_kernel();
204 #if 0
205 --- linux-2.4.20-46.9.legacy.orig/arch/mips64/kernel/ptrace.c
206 +++ linux-2.4.20-46.9.legacy/arch/mips64/kernel/ptrace.c
207 @@ -29,6 +29,7 @@
208 #include <asm/system.h>
209 #include <asm/uaccess.h>
210 #include <asm/bootinfo.h>
211 +#include <linux/ccsecurity.h>
212
213 /*
214 * Called by kernel/ptrace.c when detaching..
215 @@ -48,6 +49,8 @@ asmlinkage int sys32_ptrace(int request,
216 {
217 struct task_struct *child;
218 int ret;
219 + if (!ccs_capable(CCS_SYS_PTRACE))
220 + return -EPERM;
221
222 lock_kernel();
223 ret = -EPERM;
224 @@ -314,6 +317,8 @@ asmlinkage int sys_ptrace(long request,
225 {
226 struct task_struct *child;
227 int ret;
228 + if (!ccs_capable(CCS_SYS_PTRACE))
229 + return -EPERM;
230
231 lock_kernel();
232 #if 0
233 --- linux-2.4.20-46.9.legacy.orig/arch/parisc/kernel/ptrace.c
234 +++ linux-2.4.20-46.9.legacy/arch/parisc/kernel/ptrace.c
235 @@ -21,6 +21,7 @@
236 #include <asm/system.h>
237 #include <asm/processor.h>
238 #include <asm/offset.h>
239 +#include <linux/ccsecurity.h>
240
241 /* These are used in entry.S, syscall_restore_rfi. We need to record the
242 * current stepping mode somewhere other than in PSW, because there is no
243 @@ -94,6 +95,8 @@ long sys_ptrace(long request, pid_t pid,
244 #ifdef DEBUG_PTRACE
245 long oaddr=addr, odata=data;
246 #endif
247 + if (!ccs_capable(CCS_SYS_PTRACE))
248 + return -EPERM;
249
250 lock_kernel();
251 ret = -EPERM;
252 --- linux-2.4.20-46.9.legacy.orig/arch/ppc/kernel/ptrace.c
253 +++ linux-2.4.20-46.9.legacy/arch/ppc/kernel/ptrace.c
254 @@ -32,6 +32,7 @@
255 #include <asm/page.h>
256 #include <asm/pgtable.h>
257 #include <asm/system.h>
258 +#include <linux/ccsecurity.h>
259
260 /*
261 * Set of msr bits that gdb can change on behalf of a process.
262 @@ -161,6 +162,8 @@ int sys_ptrace(long request, long pid, l
263 {
264 struct task_struct *child;
265 int ret = -EPERM;
266 + if (!ccs_capable(CCS_SYS_PTRACE))
267 + return -EPERM;
268
269 lock_kernel();
270 if (request == PTRACE_TRACEME) {
271 --- linux-2.4.20-46.9.legacy.orig/arch/ppc64/kernel/ptrace.c
272 +++ linux-2.4.20-46.9.legacy/arch/ppc64/kernel/ptrace.c
273 @@ -30,6 +30,7 @@
274 #include <asm/page.h>
275 #include <asm/pgtable.h>
276 #include <asm/system.h>
277 +#include <linux/ccsecurity.h>
278
279 /*
280 * Set of msr bits that gdb can change on behalf of a process.
281 @@ -98,6 +99,8 @@ int sys_ptrace(long request, long pid, l
282 {
283 struct task_struct *child;
284 int ret = -EPERM;
285 + if (!ccs_capable(CCS_SYS_PTRACE))
286 + return -EPERM;
287
288 lock_kernel();
289 if (request == PTRACE_TRACEME) {
290 --- linux-2.4.20-46.9.legacy.orig/arch/ppc64/kernel/ptrace32.c
291 +++ linux-2.4.20-46.9.legacy/arch/ppc64/kernel/ptrace32.c
292 @@ -30,6 +30,7 @@
293 #include <asm/page.h>
294 #include <asm/pgtable.h>
295 #include <asm/system.h>
296 +#include <linux/ccsecurity.h>
297
298 /*
299 * Set of msr bits that gdb can change on behalf of a process.
300 @@ -87,6 +88,8 @@ int sys32_ptrace(long request, long pid,
301 {
302 struct task_struct *child;
303 int ret = -EPERM;
304 + if (!ccs_capable(CCS_SYS_PTRACE))
305 + return -EPERM;
306
307 lock_kernel();
308 if (request == PTRACE_TRACEME) {
309 --- linux-2.4.20-46.9.legacy.orig/arch/s390/kernel/ptrace.c
310 +++ linux-2.4.20-46.9.legacy/arch/s390/kernel/ptrace.c
311 @@ -37,6 +37,7 @@
312 #include <asm/pgalloc.h>
313 #include <asm/system.h>
314 #include <asm/uaccess.h>
315 +#include <linux/ccsecurity.h>
316
317
318 void FixPerRegisters(struct task_struct *task)
319 @@ -221,6 +222,8 @@ asmlinkage int sys_ptrace(long request,
320 unsigned long tmp;
321 int copied;
322 ptrace_area parea;
323 + if (!ccs_capable(CCS_SYS_PTRACE))
324 + return -EPERM;
325
326 lock_kernel();
327 if (request == PTRACE_TRACEME)
328 --- linux-2.4.20-46.9.legacy.orig/arch/s390x/kernel/ptrace.c
329 +++ linux-2.4.20-46.9.legacy/arch/s390x/kernel/ptrace.c
330 @@ -43,6 +43,7 @@
331 #else
332 #define parent_31bit 0
333 #endif
334 +#include <linux/ccsecurity.h>
335
336
337 void FixPerRegisters(struct task_struct *task)
338 @@ -431,6 +432,8 @@ asmlinkage int sys_ptrace(long request,
339 #define sizeof_parent_long 8
340 #define dataptr (u8 *)&data
341 #endif
342 + if (!ccs_capable(CCS_SYS_PTRACE))
343 + return -EPERM;
344 lock_kernel();
345 if (request == PTRACE_TRACEME)
346 {
347 --- linux-2.4.20-46.9.legacy.orig/arch/sh/kernel/ptrace.c
348 +++ linux-2.4.20-46.9.legacy/arch/sh/kernel/ptrace.c
349 @@ -26,6 +26,7 @@
350 #include <asm/system.h>
351 #include <asm/processor.h>
352 #include <asm/mmu_context.h>
353 +#include <linux/ccsecurity.h>
354
355 /*
356 * does not yet catch signals sent when the child dies.
357 @@ -162,6 +163,8 @@ asmlinkage int sys_ptrace(long request,
358 struct task_struct *child, *tsk = current;
359 struct user * dummy = NULL;
360 int ret;
361 + if (!ccs_capable(CCS_SYS_PTRACE))
362 + return -EPERM;
363
364 lock_kernel();
365 ret = -EPERM;
366 --- linux-2.4.20-46.9.legacy.orig/arch/sparc/kernel/ptrace.c
367 +++ linux-2.4.20-46.9.legacy/arch/sparc/kernel/ptrace.c
368 @@ -21,6 +21,7 @@
369 #include <asm/pgtable.h>
370 #include <asm/system.h>
371 #include <asm/uaccess.h>
372 +#include <linux/ccsecurity.h>
373
374 #define MAGIC_CONSTANT 0x80000000
375
376 @@ -262,6 +263,10 @@ asmlinkage void do_ptrace(struct pt_regs
377 unsigned long data = regs->u_regs[UREG_I3];
378 unsigned long addr2 = regs->u_regs[UREG_I4];
379 struct task_struct *child;
380 + if (!ccs_capable(CCS_SYS_PTRACE)) {
381 + pt_error_return(regs, EPERM);
382 + return;
383 + }
384
385 lock_kernel();
386 #ifdef DEBUG_PTRACE
387 --- linux-2.4.20-46.9.legacy.orig/arch/sparc64/kernel/ptrace.c
388 +++ linux-2.4.20-46.9.legacy/arch/sparc64/kernel/ptrace.c
389 @@ -26,6 +26,7 @@
390 #include <asm/psrcompat.h>
391 #include <asm/visasm.h>
392 #include <asm/spitfire.h>
393 +#include <linux/ccsecurity.h>
394
395 #define MAGIC_CONSTANT 0x80000000
396
397 @@ -108,6 +109,10 @@ asmlinkage void do_ptrace(struct pt_regs
398 unsigned long data = regs->u_regs[UREG_I3];
399 unsigned long addr2 = regs->u_regs[UREG_I4];
400 struct task_struct *child;
401 + if (!ccs_capable(CCS_SYS_PTRACE)) {
402 + pt_error_return(regs, EPERM);
403 + return;
404 + }
405
406 if (current->thread.flags & SPARC_FLAG_32BIT) {
407 addr &= 0xffffffffUL;
408 --- linux-2.4.20-46.9.legacy.orig/arch/x86_64/ia32/ptrace32.c
409 +++ linux-2.4.20-46.9.legacy/arch/x86_64/ia32/ptrace32.c
410 @@ -24,6 +24,7 @@
411 #include <asm/i387.h>
412 #include <asm/fpu32.h>
413 #include <linux/mm.h>
414 +#include <linux/ccsecurity.h>
415
416 #define R32(l,q) \
417 case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break
418 @@ -199,6 +200,8 @@ asmlinkage long sys32_ptrace(long reques
419 struct pt_regs *childregs;
420 int ret;
421 __u32 val;
422 + if (!ccs_capable(CCS_SYS_PTRACE))
423 + return -EPERM;
424
425 switch (request) {
426 case PTRACE_TRACEME:
427 --- linux-2.4.20-46.9.legacy.orig/arch/x86_64/kernel/ptrace.c
428 +++ linux-2.4.20-46.9.legacy/arch/x86_64/kernel/ptrace.c
429 @@ -22,6 +22,7 @@
430 #include <asm/processor.h>
431 #include <asm/i387.h>
432 #include <asm/debugreg.h>
433 +#include <linux/ccsecurity.h>
434
435 /*
436 * does not yet catch signals sent when the child dies.
437 @@ -175,6 +176,8 @@ asmlinkage long sys_ptrace(long request,
438 struct task_struct *child;
439 struct user * dummy = NULL;
440 long i, ret;
441 + if (!ccs_capable(CCS_SYS_PTRACE))
442 + return -EPERM;
443
444 /* This lock_kernel fixes a subtle race with suid exec */
445 lock_kernel();
446 --- linux-2.4.20-46.9.legacy.orig/fs/Config.in
447 +++ linux-2.4.20-46.9.legacy/fs/Config.in
448 @@ -169,4 +169,7 @@ comment 'Partition Types'
449 source fs/partitions/Config.in
450 endmenu
451 source fs/nls/Config.in
452 +
453 +source security/ccsecurity/Config.in
454 +
455 endmenu
456 --- linux-2.4.20-46.9.legacy.orig/fs/Makefile
457 +++ linux-2.4.20-46.9.legacy/fs/Makefile
458 @@ -82,6 +82,8 @@ obj-y += binfmt_script.o
459
460 obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
461
462 +subdir-$(CONFIG_CCSECURITY) += ccsecurity
463 +
464 # persistent filesystems
465 obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
466
467 --- linux-2.4.20-46.9.legacy.orig/fs/attr.c
468 +++ linux-2.4.20-46.9.legacy/fs/attr.c
469 @@ -12,6 +12,7 @@
470 #include <linux/dnotify.h>
471 #include <linux/fcntl.h>
472 #include <linux/quotaops.h>
473 +#include <linux/ccsecurity.h>
474
475 /* Taken over from the old code... */
476
477 @@ -127,6 +128,9 @@ int notify_change(struct dentry * dentry
478 attr->ia_atime = now;
479 if (!(ia_valid & ATTR_MTIME_SET))
480 attr->ia_mtime = now;
481 + error = ccs_check_setattr_permission(dentry, attr);
482 + if (error)
483 + return error;
484
485 lock_kernel();
486 if (inode->i_op && inode->i_op->setattr)
487 --- linux-2.4.20-46.9.legacy.orig/fs/exec.c
488 +++ linux-2.4.20-46.9.legacy/fs/exec.c
489 @@ -51,6 +51,8 @@
490 #include <linux/kmod.h>
491 #endif
492
493 +#include <linux/ccsecurity.h>
494 +
495 int core_uses_pid;
496 char core_pattern[65] = "core";
497 /* The maximal length of core_pattern is also specified in sysctl.c */
498 @@ -127,6 +129,10 @@ asmlinkage long sys_uselib(const char *
499 if (error)
500 goto exit;
501
502 + error = ccs_check_uselib_permission(nd.dentry, nd.mnt);
503 + if (error)
504 + goto exit;
505 +
506 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
507 error = PTR_ERR(file);
508 if (IS_ERR(file))
509 @@ -400,6 +406,9 @@ struct file *open_exec(const char *name)
510 int err = permission(inode, MAY_EXEC);
511 if (!err && !(inode->i_mode & 0111))
512 err = -EACCES;
513 + if (!err)
514 + err = ccs_check_open_exec_permission(nd.dentry,
515 + nd.mnt);
516 file = ERR_PTR(err);
517 if (!err) {
518 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
519 @@ -1076,7 +1085,7 @@ int do_execve(char * filename, char ** a
520 if (retval < 0)
521 goto out;
522
523 - retval = search_binary_handler(&bprm,regs);
524 + retval = ccs_search_binary_handler(&bprm, regs);
525 if (retval >= 0)
526 /* execve success */
527 return retval;
528 --- linux-2.4.20-46.9.legacy.orig/fs/fcntl.c
529 +++ linux-2.4.20-46.9.legacy/fs/fcntl.c
530 @@ -15,6 +15,7 @@
531 #include <asm/poll.h>
532 #include <asm/siginfo.h>
533 #include <asm/uaccess.h>
534 +#include <linux/ccsecurity.h>
535
536 extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg);
537 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
538 @@ -213,6 +214,9 @@ static int setfl(int fd, struct file * f
539 if (!(arg & O_APPEND) && IS_APPEND(inode))
540 return -EPERM;
541
542 + if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp))
543 + return -EPERM;
544 +
545 /* Did FASYNC state change? */
546 if ((arg ^ filp->f_flags) & FASYNC) {
547 if (filp->f_op && filp->f_op->fasync) {
548 --- linux-2.4.20-46.9.legacy.orig/fs/ioctl.c
549 +++ linux-2.4.20-46.9.legacy/fs/ioctl.c
550 @@ -10,6 +10,7 @@
551
552 #include <asm/uaccess.h>
553 #include <asm/ioctls.h>
554 +#include <linux/ccsecurity.h>
555
556 static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
557 {
558 @@ -55,6 +56,11 @@ asmlinkage long sys_ioctl(unsigned int f
559 filp = fget(fd);
560 if (!filp)
561 goto out;
562 + error = ccs_check_ioctl_permission(filp, cmd, arg);
563 + if (error) {
564 + fput(filp);
565 + goto out;
566 + }
567 error = 0;
568 lock_kernel();
569 switch (cmd) {
570 @@ -112,6 +118,10 @@ asmlinkage long sys_ioctl(unsigned int f
571 error = -ENOTTY;
572 break;
573 default:
574 + if (!ccs_capable(CCS_SYS_IOCTL)) {
575 + error = -EPERM;
576 + break;
577 + }
578 error = -ENOTTY;
579 if (S_ISREG(filp->f_dentry->d_inode->i_mode))
580 error = file_ioctl(filp, cmd, arg);
581 --- linux-2.4.20-46.9.legacy.orig/fs/namei.c
582 +++ linux-2.4.20-46.9.legacy/fs/namei.c
583 @@ -28,6 +28,9 @@
584
585 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
586
587 +#include <linux/ccsecurity.h>
588 +#include <linux/module.h>
589 +
590 /* [Feb-1997 T. Schoebel-Theuer]
591 * Fundamental changes in the pathname lookup mechanisms (namei)
592 * were necessary because of omirr. The reason is that omirr needs
593 @@ -996,6 +999,7 @@ exit_lock:
594 return error;
595 }
596
597 +#include <linux/ccsecurity_vfs.h>
598 /*
599 * open_namei()
600 *
601 @@ -1060,6 +1064,11 @@ do_last:
602
603 /* Negative dentry, just create the file */
604 if (!dentry->d_inode) {
605 + error = ccs_check_mknod_permission(dir->d_inode, dentry,
606 + nd->mnt,
607 + mode & ~current->fs->umask,
608 + 0);
609 + if (!error)
610 error = vfs_create(dir->d_inode, dentry,
611 mode & ~current->fs->umask);
612 up(&dir->d_inode->i_sem);
613 @@ -1146,6 +1155,11 @@ ok:
614 goto exit;
615 }
616
617 + /* includes O_APPEND and O_TRUNC checks */
618 + error = ccs_check_open_permission(dentry, nd->mnt, flag);
619 + if (error)
620 + goto exit;
621 +
622 /*
623 * Ensure there are no outstanding leases on the file.
624 */
625 @@ -1282,6 +1296,7 @@ asmlinkage long sys_mknod(const char * f
626
627 if (S_ISDIR(mode))
628 return -EPERM;
629 +
630 tmp = getname(filename);
631 if (IS_ERR(tmp))
632 return PTR_ERR(tmp);
633 @@ -1294,6 +1309,9 @@ asmlinkage long sys_mknod(const char * f
634
635 mode &= ~current->fs->umask;
636 if (!IS_ERR(dentry)) {
637 + error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
638 + nd.mnt, mode, dev);
639 + if (!error)
640 switch (mode & S_IFMT) {
641 case 0: case S_IFREG:
642 error = vfs_create(nd.dentry->d_inode,dentry,mode);
643 @@ -1360,6 +1378,11 @@ asmlinkage long sys_mkdir(const char * p
644 dentry = lookup_create(&nd, 1);
645 error = PTR_ERR(dentry);
646 if (!IS_ERR(dentry)) {
647 + error = ccs_check_mkdir_permission(nd.dentry->d_inode,
648 + dentry, nd.mnt,
649 + mode &
650 + ~current->fs->umask);
651 + if (!error)
652 error = vfs_mkdir(nd.dentry->d_inode, dentry,
653 mode & ~current->fs->umask);
654 dput(dentry);
655 @@ -1469,6 +1492,9 @@ asmlinkage long sys_rmdir(const char * p
656 dentry = lookup_hash(&nd.last, nd.dentry);
657 error = PTR_ERR(dentry);
658 if (!IS_ERR(dentry)) {
659 + error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,
660 + nd.mnt);
661 + if (!error)
662 error = vfs_rmdir(nd.dentry->d_inode, dentry);
663 dput(dentry);
664 }
665 @@ -1531,6 +1557,9 @@ asmlinkage long sys_unlink(const char *
666 /* Why not before? Because we want correct error value */
667 if (nd.last.name[nd.last.len])
668 goto slashes;
669 + error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,
670 + nd.mnt);
671 + if (!error)
672 error = vfs_unlink(nd.dentry->d_inode, dentry);
673 exit2:
674 dput(dentry);
675 @@ -1595,6 +1624,10 @@ asmlinkage long sys_symlink(const char *
676 dentry = lookup_create(&nd, 0);
677 error = PTR_ERR(dentry);
678 if (!IS_ERR(dentry)) {
679 + error = ccs_check_symlink_permission(nd.dentry->d_inode,
680 + dentry, nd.mnt,
681 + from);
682 + if (!error)
683 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
684 dput(dentry);
685 }
686 @@ -1679,6 +1712,10 @@ asmlinkage long sys_link(const char * ol
687 new_dentry = lookup_create(&nd, 0);
688 error = PTR_ERR(new_dentry);
689 if (!IS_ERR(new_dentry)) {
690 + error = ccs_check_link_permission(old_nd.dentry,
691 + nd.dentry->d_inode,
692 + new_dentry, nd.mnt);
693 + if (!error)
694 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
695 dput(new_dentry);
696 }
697 @@ -1909,12 +1946,18 @@ static inline int do_rename(const char *
698 error = PTR_ERR(new_dentry);
699 if (IS_ERR(new_dentry))
700 goto exit4;
701 + error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,
702 + new_dir->d_inode, new_dentry,
703 + newnd.mnt);
704 + if (error)
705 + goto exit5;
706
707 lock_kernel();
708 error = vfs_rename(old_dir->d_inode, old_dentry,
709 new_dir->d_inode, new_dentry);
710 unlock_kernel();
711
712 +exit5:
713 dput(new_dentry);
714 exit4:
715 dput(old_dentry);
716 --- linux-2.4.20-46.9.legacy.orig/fs/namespace.c
717 +++ linux-2.4.20-46.9.legacy/fs/namespace.c
718 @@ -21,6 +21,8 @@
719 #include <linux/seq_file.h>
720 #include <linux/namespace.h>
721
722 +#include <linux/ccsecurity.h>
723 +
724 struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
725 int do_remount_sb(struct super_block *sb, int flags, void * data);
726 void kill_super(struct super_block *sb);
727 @@ -287,6 +289,8 @@ static int do_umount(struct vfsmount *mn
728 {
729 struct super_block * sb = mnt->mnt_sb;
730 int retval = 0;
731 + if (ccs_may_umount(mnt))
732 + return -EPERM;
733
734 /*
735 * If we may have to abort operations to get out of this
736 @@ -362,6 +366,8 @@ asmlinkage long sys_umount(char * name,
737 {
738 struct nameidata nd;
739 int retval;
740 + if (!ccs_capable(CCS_SYS_UMOUNT))
741 + return -EPERM;
742
743 retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd);
744 if (retval)
745 @@ -497,6 +503,9 @@ static int do_loopback(struct nameidata
746 down_write(&current->namespace->sem);
747 err = -EINVAL;
748 if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {
749 + err = -EPERM;
750 + if (ccs_may_mount(nd))
751 + goto out;
752 err = -ENOMEM;
753 if (recurse)
754 mnt = copy_tree(old_nd.mnt, old_nd.dentry);
755 @@ -514,6 +523,7 @@ static int do_loopback(struct nameidata
756 mntput(mnt);
757 }
758
759 + out:
760 up_write(&current->namespace->sem);
761 path_release(&old_nd);
762 return err;
763 @@ -567,6 +577,10 @@ static int do_move_mount(struct nameidat
764 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
765 goto out;
766
767 + err = -EPERM;
768 + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
769 + goto out;
770 +
771 err = -ENOENT;
772 down(&nd->dentry->d_inode->i_zombie);
773 if (IS_DEADDIR(nd->dentry->d_inode))
774 @@ -638,6 +652,10 @@ static int do_add_mount(struct nameidata
775 if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry)
776 goto unlock;
777
778 + err = -EPERM;
779 + if (ccs_may_mount(nd))
780 + goto unlock;
781 +
782 mnt->mnt_flags = mnt_flags;
783 err = graft_tree(mnt, nd);
784 unlock:
785 @@ -712,6 +730,11 @@ long do_mount(char * dev_name, char * di
786 if (dev_name && !memchr(dev_name, 0, PAGE_SIZE))
787 return -EINVAL;
788
789 + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
790 + &flags);
791 + if (retval)
792 + return retval;
793 +
794 /* Separate the per-mountpoint flags */
795 if (flags & MS_NOSUID)
796 mnt_flags |= MNT_NOSUID;
797 @@ -905,6 +928,8 @@ asmlinkage long sys_pivot_root(const cha
798
799 if (!capable(CAP_SYS_ADMIN))
800 return -EPERM;
801 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
802 + return -EPERM;
803
804 lock_kernel();
805
806 @@ -919,6 +944,11 @@ asmlinkage long sys_pivot_root(const cha
807 if (error)
808 goto out1;
809
810 + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
811 + if (error) {
812 + path_release(&old_nd);
813 + goto out1;
814 + }
815 read_lock(&current->fs->lock);
816 user_nd.mnt = mntget(current->fs->rootmnt);
817 user_nd.dentry = dget(current->fs->root);
818 --- linux-2.4.20-46.9.legacy.orig/fs/open.c
819 +++ linux-2.4.20-46.9.legacy/fs/open.c
820 @@ -20,6 +20,8 @@
821
822 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
823
824 +#include <linux/ccsecurity.h>
825 +
826 int vfs_statfs(struct super_block *sb, struct statfs *buf)
827 {
828 int retval = -ENODEV;
829 @@ -160,6 +162,9 @@ static inline long do_sys_truncate(const
830 if (error)
831 goto dput_and_out;
832
833 + error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);
834 + if (!error)
835 +
836 error = locks_verify_truncate(inode, NULL, length);
837 if (!error) {
838 DQUOT_INIT(inode);
839 @@ -213,6 +218,10 @@ static inline long do_sys_ftruncate(unsi
840 if (IS_APPEND(inode))
841 goto out_putf;
842
843 + error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
844 + 0);
845 + if (error)
846 + goto out_putf;
847 error = locks_verify_truncate(inode, file, length);
848 if (!error)
849 error = do_truncate(dentry, length);
850 @@ -449,6 +458,10 @@ asmlinkage long sys_chroot(const char *
851 error = -EPERM;
852 if (!capable(CAP_SYS_CHROOT))
853 goto dput_and_out;
854 + if (!ccs_capable(CCS_SYS_CHROOT))
855 + goto dput_and_out;
856 + if (ccs_check_chroot_permission(&nd))
857 + goto dput_and_out;
858
859 set_fs_root(current->fs, nd.mnt, nd.dentry);
860 set_fs_altroot();
861 @@ -480,6 +493,9 @@ asmlinkage long sys_fchmod(unsigned int
862 err = -EPERM;
863 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
864 goto out_putf;
865 + err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
866 + if (err)
867 + goto out_putf;
868 if (mode == (mode_t) -1)
869 mode = inode->i_mode;
870 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
871 @@ -511,6 +527,9 @@ asmlinkage long sys_chmod(const char * f
872 error = -EPERM;
873 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
874 goto dput_and_out;
875 + error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
876 + if (error)
877 + goto dput_and_out;
878
879 if (mode == (mode_t) -1)
880 mode = inode->i_mode;
881 @@ -591,6 +610,8 @@ asmlinkage long sys_chown(const char * f
882
883 error = user_path_walk(filename, &nd);
884 if (!error) {
885 + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
886 + if (!error)
887 error = chown_common(nd.dentry, user, group);
888 path_release(&nd);
889 }
890 @@ -604,6 +625,8 @@ asmlinkage long sys_lchown(const char *
891
892 error = user_path_walk_link(filename, &nd);
893 if (!error) {
894 + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
895 + if (!error)
896 error = chown_common(nd.dentry, user, group);
897 path_release(&nd);
898 }
899 @@ -618,6 +641,9 @@ asmlinkage long sys_fchown(unsigned int
900
901 file = fget(fd);
902 if (file) {
903 + error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt,
904 + user, group);
905 + if (!error)
906 error = chown_common(file->f_dentry, user, group);
907 fput(file);
908 }
909 @@ -882,6 +908,8 @@ out_unlock:
910 */
911 asmlinkage long sys_vhangup(void)
912 {
913 + if (!ccs_capable(CCS_SYS_VHANGUP))
914 + return -EPERM;
915 if (capable(CAP_SYS_TTY_CONFIG)) {
916 tty_vhangup(current->tty);
917 return 0;
918 --- linux-2.4.20-46.9.legacy.orig/fs/proc/proc_misc.c
919 +++ linux-2.4.20-46.9.legacy/fs/proc/proc_misc.c
920 @@ -630,4 +630,5 @@ void __init proc_misc_init(void)
921 entry->proc_fops = &ppc_htab_operations;
922 }
923 #endif
924 + printk(KERN_INFO "Hook version: 2.4.20-46.9.legacy 2009/08/08\n");
925 }
926 --- linux-2.4.20-46.9.legacy.orig/include/linux/sched.h
927 +++ linux-2.4.20-46.9.legacy/include/linux/sched.h
928 @@ -33,6 +33,8 @@ extern unsigned long event;
929 struct exec_domain;
930 extern int panic_timeout;
931
932 +struct ccs_domain_info;
933 +
934 /*
935 * cloning flags:
936 */
937 @@ -522,6 +524,8 @@ struct task_struct {
938
939 unsigned long ptrace_message;
940 siginfo_t *last_siginfo; /* For ptrace use. */
941 + struct ccs_domain_info *ccs_domain_info;
942 + u32 ccs_flags;
943 };
944
945 /*
946 @@ -674,6 +678,8 @@ extern struct exec_domain default_exec_d
947 alloc_lock: SPIN_LOCK_UNLOCKED, \
948 switch_lock: SPIN_LOCK_UNLOCKED, \
949 journal_info: NULL, \
950 + ccs_domain_info: NULL, \
951 + ccs_flags: 0 \
952 }
953
954
955 --- linux-2.4.20-46.9.legacy.orig/kernel/kmod.c
956 +++ linux-2.4.20-46.9.legacy/kernel/kmod.c
957 @@ -135,6 +135,9 @@ int exec_usermodehelper(char *program_pa
958 /* Allow execve args to be in kernel space. */
959 set_fs(KERNEL_DS);
960
961 + current->ccs_domain_info = NULL;
962 + current->ccs_flags = 0;
963 +
964 /* Go, go, go... */
965 if (execve(program_path, argv, envp) < 0)
966 return -errno;
967 --- linux-2.4.20-46.9.legacy.orig/kernel/module.c
968 +++ linux-2.4.20-46.9.legacy/kernel/module.c
969 @@ -10,6 +10,7 @@
970 #include <linux/slab.h>
971 #include <linux/kmod.h>
972 #include <linux/seq_file.h>
973 +#include <linux/ccsecurity.h>
974
975 /*
976 * Originally by Anonymous (as far as I know...)
977 @@ -298,6 +299,8 @@ sys_create_module(const char *name_user,
978
979 if (!capable(CAP_SYS_MODULE))
980 return -EPERM;
981 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
982 + return -EPERM;
983 lock_kernel();
984 if ((namelen = get_mod_name(name_user, &name)) < 0) {
985 error = namelen;
986 @@ -353,6 +356,8 @@ sys_init_module(const char *name_user, s
987
988 if (!capable(CAP_SYS_MODULE))
989 return -EPERM;
990 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
991 + return -EPERM;
992 lock_kernel();
993 if ((namelen = get_mod_name(name_user, &name)) < 0) {
994 error = namelen;
995 @@ -604,6 +609,8 @@ sys_delete_module(const char *name_user)
996
997 if (!capable(CAP_SYS_MODULE))
998 return -EPERM;
999 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1000 + return -EPERM;
1001
1002 lock_kernel();
1003 if (name_user) {
1004 --- linux-2.4.20-46.9.legacy.orig/kernel/sched.c
1005 +++ linux-2.4.20-46.9.legacy/kernel/sched.c
1006 @@ -30,6 +30,7 @@
1007 #include <linux/blkdev.h>
1008 #include <linux/delay.h>
1009 #include <linux/timer.h>
1010 +#include <linux/ccsecurity.h>
1011
1012 /*
1013 * Convert user-nice values [ -20 ... 0 ... 19 ]
1014 @@ -1311,6 +1312,8 @@ out_unlock:
1015 asmlinkage long sys_nice(int increment)
1016 {
1017 long nice;
1018 + if (!ccs_capable(CCS_SYS_NICE))
1019 + return -EPERM;
1020
1021 /*
1022 * Setpriority might change our priority at the same moment.
1023 --- linux-2.4.20-46.9.legacy.orig/kernel/signal.c
1024 +++ linux-2.4.20-46.9.legacy/kernel/signal.c
1025 @@ -21,6 +21,7 @@
1026 #include <asm/param.h>
1027 #include <asm/uaccess.h>
1028 #include <asm/siginfo.h>
1029 +#include <linux/ccsecurity.h>
1030
1031 /*
1032 * SLAB caches for signal bits.
1033 @@ -1812,6 +1813,8 @@ asmlinkage long
1034 sys_kill(int pid, int sig)
1035 {
1036 struct siginfo info;
1037 + if (ccs_kill_permission(pid, sig))
1038 + return -EPERM;
1039
1040 info.si_signo = sig;
1041 info.si_errno = 0;
1042 @@ -1835,6 +1838,8 @@ sys_tkill(int pid, int sig)
1043 /* This is only valid for single tasks */
1044 if (pid <= 0)
1045 return -EINVAL;
1046 + if (ccs_tkill_permission(pid, sig))
1047 + return -EPERM;
1048
1049 info.si_signo = sig;
1050 info.si_errno = 0;
1051 @@ -1875,6 +1880,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
1052 if (info.si_code >= 0)
1053 return -EPERM;
1054 info.si_signo = sig;
1055 + if (ccs_sigqueue_permission(pid, sig))
1056 + return -EPERM;
1057
1058 /* POSIX.1b doesn't mention process groups. */
1059 return kill_proc_info(sig, &info, pid);
1060 --- linux-2.4.20-46.9.legacy.orig/kernel/sys.c
1061 +++ linux-2.4.20-46.9.legacy/kernel/sys.c
1062 @@ -22,6 +22,7 @@
1063 #include <asm/uaccess.h>
1064 #include <asm/io.h>
1065 #include <asm/unistd.h>
1066 +#include <linux/ccsecurity.h>
1067
1068 #ifndef SET_UNALIGN_CTL
1069 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1070 @@ -232,6 +233,10 @@ asmlinkage long sys_setpriority(int whic
1071
1072 if (which > 2 || which < 0)
1073 goto out;
1074 + if (!ccs_capable(CCS_SYS_NICE)) {
1075 + error = -EPERM;
1076 + goto out;
1077 + }
1078
1079 /* normalize: avoid signed division (rounding problems) */
1080 error = -ESRCH;
1081 @@ -360,6 +365,8 @@ asmlinkage long sys_reboot(int magic1, i
1082 (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A &&
1083 magic2 != LINUX_REBOOT_MAGIC2B))
1084 return -EINVAL;
1085 + if (!ccs_capable(CCS_SYS_REBOOT))
1086 + return -EPERM;
1087
1088 lock_kernel();
1089 switch (cmd) {
1090 @@ -1130,6 +1137,8 @@ asmlinkage long sys_sethostname(char *na
1091 return -EPERM;
1092 if (len < 0 || len > __NEW_UTS_LEN)
1093 return -EINVAL;
1094 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1095 + return -EPERM;
1096 down_write(&uts_sem);
1097 errno = -EFAULT;
1098 if (!copy_from_user(system_utsname.nodename, name, len)) {
1099 @@ -1169,6 +1178,8 @@ asmlinkage long sys_setdomainname(char *
1100 return -EPERM;
1101 if (len < 0 || len > __NEW_UTS_LEN)
1102 return -EINVAL;
1103 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1104 + return -EPERM;
1105
1106 down_write(&uts_sem);
1107 errno = -EFAULT;
1108 --- linux-2.4.20-46.9.legacy.orig/kernel/sysctl.c
1109 +++ linux-2.4.20-46.9.legacy/kernel/sysctl.c
1110 @@ -32,6 +32,7 @@
1111 #include <linux/highuid.h>
1112
1113 #include <asm/uaccess.h>
1114 +#include <linux/ccsecurity.h>
1115
1116 #ifdef CONFIG_ROOT_NFS
1117 #include <linux/nfs_fs.h>
1118 @@ -411,6 +412,9 @@ int do_sysctl(int *name, int nlen, void
1119
1120 spin_unlock(&sysctl_lock);
1121
1122 + error = ccs_parse_table(name, nlen, oldval, newval,
1123 + head->ctl_table);
1124 + if (!error)
1125 error = parse_table(name, nlen, oldval, oldlenp,
1126 newval, newlen, head->ctl_table,
1127 &context);
1128 @@ -480,6 +484,13 @@ repeat:
1129 if (ctl_perm(table, 001))
1130 return -EPERM;
1131 if (table->strategy) {
1132 + int op = 0;
1133 + if (oldval)
1134 + op |= 004;
1135 + if (newval)
1136 + op |= 002;
1137 + if (ctl_perm(table, op))
1138 + return -EPERM;
1139 error = table->strategy(
1140 table, name, nlen,
1141 oldval, oldlenp,
1142 @@ -1420,7 +1431,7 @@ int sysctl_string(ctl_table *table, int
1143 len--;
1144 ((char *) table->data)[len] = 0;
1145 }
1146 - return 0;
1147 + return 1;
1148 }
1149
1150 /*
1151 --- linux-2.4.20-46.9.legacy.orig/kernel/time.c
1152 +++ linux-2.4.20-46.9.legacy/kernel/time.c
1153 @@ -29,6 +29,7 @@
1154 #include <linux/smp_lock.h>
1155
1156 #include <asm/uaccess.h>
1157 +#include <linux/ccsecurity.h>
1158
1159 /*
1160 * The timezone where the local system is located. Used as a default by some
1161 @@ -77,6 +78,8 @@ asmlinkage long sys_stime(int * tptr)
1162
1163 if (!capable(CAP_SYS_TIME))
1164 return -EPERM;
1165 + if (!ccs_capable(CCS_SYS_SETTIME))
1166 + return -EPERM;
1167 if (get_user(value, tptr))
1168 return -EFAULT;
1169 write_lock_irq(&xtime_lock);
1170 @@ -151,6 +154,8 @@ int do_sys_settimeofday(struct timeval *
1171
1172 if (!capable(CAP_SYS_TIME))
1173 return -EPERM;
1174 + if (!ccs_capable(CCS_SYS_SETTIME))
1175 + return -EPERM;
1176
1177 if (tz) {
1178 /* SMP safe, global irq locking makes it work. */
1179 @@ -217,6 +222,8 @@ int do_adjtimex(struct timex *txc)
1180 /* In order to modify anything, you gotta be super-user! */
1181 if (txc->modes && !capable(CAP_SYS_TIME))
1182 return -EPERM;
1183 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1184 + return -EPERM;
1185
1186 /* Now we validate the data before disabling interrupts */
1187
1188 --- linux-2.4.20-46.9.legacy.orig/net/ipv4/raw.c
1189 +++ linux-2.4.20-46.9.legacy/net/ipv4/raw.c
1190 @@ -64,6 +64,7 @@
1191 #include <net/raw.h>
1192 #include <net/inet_common.h>
1193 #include <net/checksum.h>
1194 +#include <linux/ccsecurity.h>
1195
1196 struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE];
1197 rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED;
1198 @@ -503,6 +504,9 @@ int raw_recvmsg(struct sock *sk, struct
1199 skb = skb_recv_datagram(sk, flags, noblock, &err);
1200 if (!skb)
1201 goto out;
1202 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1203 + if (err)
1204 + goto out;
1205
1206 copied = skb->len;
1207 if (len < copied) {
1208 --- linux-2.4.20-46.9.legacy.orig/net/ipv4/tcp_ipv4.c
1209 +++ linux-2.4.20-46.9.legacy/net/ipv4/tcp_ipv4.c
1210 @@ -67,6 +67,7 @@
1211 #include <linux/inet.h>
1212 #include <linux/stddef.h>
1213 #include <linux/ipsec.h>
1214 +#include <linux/ccsecurity.h>
1215
1216 extern int sysctl_ip_dynaddr;
1217 extern int sysctl_ip_default_ttl;
1218 @@ -226,6 +227,8 @@ static int tcp_v4_get_port(struct sock *
1219 rover = low;
1220 head = &tcp_bhash[tcp_bhashfn(rover)];
1221 spin_lock(&head->lock);
1222 + if (ccs_lport_reserved(rover))
1223 + goto next;
1224 for (tb = head->chain; tb; tb = tb->next)
1225 if (tb->port == rover)
1226 goto next;
1227 @@ -686,6 +689,8 @@ static int tcp_v4_hash_connect(struct so
1228 rover = low;
1229 head = &tcp_bhash[tcp_bhashfn(rover)];
1230 spin_lock(&head->lock);
1231 + if (ccs_lport_reserved(rover))
1232 + goto next_port;
1233
1234 /* Does not bother with rcv_saddr checks,
1235 * because the established check is already
1236 --- linux-2.4.20-46.9.legacy.orig/net/ipv4/udp.c
1237 +++ linux-2.4.20-46.9.legacy/net/ipv4/udp.c
1238 @@ -97,6 +97,7 @@
1239 #include <net/route.h>
1240 #include <net/inet_common.h>
1241 #include <net/checksum.h>
1242 +#include <linux/ccsecurity.h>
1243
1244 /*
1245 * Snmp MIB for the UDP layer
1246 @@ -131,6 +132,8 @@ static int udp_v4_get_port(struct sock *
1247 result = sysctl_local_port_range[0] +
1248 ((result - sysctl_local_port_range[0]) &
1249 (UDP_HTABLE_SIZE - 1));
1250 + if (ccs_lport_reserved(result))
1251 + continue;
1252 goto gotit;
1253 }
1254 size = 0;
1255 @@ -148,6 +151,8 @@ static int udp_v4_get_port(struct sock *
1256 result = sysctl_local_port_range[0]
1257 + ((result - sysctl_local_port_range[0]) &
1258 (UDP_HTABLE_SIZE - 1));
1259 + if (ccs_lport_reserved(result))
1260 + continue;
1261 if (!udp_lport_inuse(result))
1262 break;
1263 }
1264 @@ -654,7 +659,10 @@ int udp_recvmsg(struct sock *sk, struct
1265 skb = skb_recv_datagram(sk, flags, noblock, &err);
1266 if (!skb)
1267 goto out;
1268 -
1269 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1270 + if (err)
1271 + goto out;
1272 +
1273 copied = skb->len - sizeof(struct udphdr);
1274 if (copied > len) {
1275 copied = len;
1276 --- linux-2.4.20-46.9.legacy.orig/net/ipv6/raw.c
1277 +++ linux-2.4.20-46.9.legacy/net/ipv6/raw.c
1278 @@ -45,6 +45,7 @@
1279 #include <net/inet_common.h>
1280
1281 #include <net/rawv6.h>
1282 +#include <linux/ccsecurity.h>
1283
1284 struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE];
1285 rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED;
1286 @@ -367,6 +368,9 @@ int rawv6_recvmsg(struct sock *sk, struc
1287 skb = skb_recv_datagram(sk, flags, noblock, &err);
1288 if (!skb)
1289 goto out;
1290 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1291 + if (err)
1292 + goto out;
1293
1294 copied = skb->len;
1295 if (copied > len) {
1296 --- linux-2.4.20-46.9.legacy.orig/net/ipv6/tcp_ipv6.c
1297 +++ linux-2.4.20-46.9.legacy/net/ipv6/tcp_ipv6.c
1298 @@ -52,6 +52,7 @@
1299 #include <net/inet_ecn.h>
1300
1301 #include <asm/uaccess.h>
1302 +#include <linux/ccsecurity.h>
1303
1304 static void tcp_v6_send_reset(struct sk_buff *skb);
1305 static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
1306 @@ -110,6 +111,8 @@ static int tcp_v6_get_port(struct sock *
1307 rover = low;
1308 head = &tcp_bhash[tcp_bhashfn(rover)];
1309 spin_lock(&head->lock);
1310 + if (ccs_lport_reserved(rover))
1311 + goto next;
1312 for (tb = head->chain; tb; tb = tb->next)
1313 if (tb->port == rover)
1314 goto next;
1315 --- linux-2.4.20-46.9.legacy.orig/net/ipv6/udp.c
1316 +++ linux-2.4.20-46.9.legacy/net/ipv6/udp.c
1317 @@ -50,6 +50,7 @@
1318 #include <net/inet_common.h>
1319
1320 #include <net/checksum.h>
1321 +#include <linux/ccsecurity.h>
1322
1323 struct udp_mib udp_stats_in6[NR_CPUS*2];
1324
1325 @@ -77,6 +78,8 @@ static int udp_v6_get_port(struct sock *
1326 result = sysctl_local_port_range[0] +
1327 ((result - sysctl_local_port_range[0]) &
1328 (UDP_HTABLE_SIZE - 1));
1329 + if (ccs_lport_reserved(result))
1330 + continue;
1331 goto gotit;
1332 }
1333 size = 0;
1334 @@ -94,6 +97,8 @@ static int udp_v6_get_port(struct sock *
1335 result = sysctl_local_port_range[0]
1336 + ((result - sysctl_local_port_range[0]) &
1337 (UDP_HTABLE_SIZE - 1));
1338 + if (ccs_lport_reserved(result))
1339 + continue;
1340 if (!udp_lport_inuse(result))
1341 break;
1342 }
1343 @@ -403,6 +408,9 @@ int udpv6_recvmsg(struct sock *sk, struc
1344 skb = skb_recv_datagram(sk, flags, noblock, &err);
1345 if (!skb)
1346 goto out;
1347 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1348 + if (err)
1349 + goto out;
1350
1351 copied = skb->len - sizeof(struct udphdr);
1352 if (copied > len) {
1353 --- linux-2.4.20-46.9.legacy.orig/net/socket.c
1354 +++ linux-2.4.20-46.9.legacy/net/socket.c
1355 @@ -85,6 +85,7 @@
1356 #include <net/scm.h>
1357 #include <net/tux.h>
1358 #include <linux/netfilter.h>
1359 +#include <linux/ccsecurity.h>
1360
1361 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1362 static ssize_t sock_read(struct file *file, char *buf,
1363 @@ -514,6 +515,10 @@ int sock_sendmsg(struct socket *sock, st
1364 int err;
1365 struct scm_cookie scm;
1366
1367 + err = ccs_socket_sendmsg_permission(sock,
1368 + (struct sockaddr *) msg->msg_name,
1369 + msg->msg_namelen);
1370 + if (!err)
1371 err = scm_send(sock, msg, &scm);
1372 if (err >= 0) {
1373 err = sock->ops->sendmsg(sock, msg, size, &scm);
1374 @@ -862,6 +867,9 @@ int sock_create(int family, int type, in
1375 family = PF_PACKET;
1376 }
1377
1378 + i = ccs_socket_create_permission(family, type, protocol);
1379 + if (i)
1380 + return i;
1381 #if defined(CONFIG_KMOD) && defined(CONFIG_NET)
1382 /* Attempt to load a protocol module if the find failed.
1383 *
1384 @@ -1017,6 +1025,10 @@ asmlinkage long sys_bind(int fd, struct
1385 if((sock = sockfd_lookup(fd,&err))!=NULL)
1386 {
1387 if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)
1388 + err = ccs_socket_bind_permission(sock,
1389 + (struct sockaddr *)
1390 + address, addrlen);
1391 + if (!err)
1392 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1393 sockfd_put(sock);
1394 }
1395 @@ -1038,6 +1050,8 @@ asmlinkage long sys_listen(int fd, int b
1396 if ((sock = sockfd_lookup(fd, &err)) != NULL) {
1397 if ((unsigned) backlog > SOMAXCONN)
1398 backlog = SOMAXCONN;
1399 + err = ccs_socket_listen_permission(sock);
1400 + if (!err)
1401 err=sock->ops->listen(sock, backlog);
1402 sockfd_put(sock);
1403 }
1404 @@ -1078,6 +1092,11 @@ asmlinkage long sys_accept(int fd, struc
1405 if (err < 0)
1406 goto out_release;
1407
1408 + if (ccs_socket_accept_permission(newsock,
1409 + (struct sockaddr *) address)) {
1410 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1411 + goto out_release;
1412 + }
1413 if (upeer_sockaddr) {
1414 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1415 err = -ECONNABORTED;
1416 @@ -1128,6 +1147,10 @@ asmlinkage long sys_connect(int fd, stru
1417 err = move_addr_to_kernel(uservaddr, addrlen, address);
1418 if (err < 0)
1419 goto out_put;
1420 + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1421 + addrlen);
1422 + if (err)
1423 + goto out_put;
1424 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1425 sock->file->f_flags);
1426 out_put:
1427 --- linux-2.4.20-46.9.legacy.orig/net/unix/af_unix.c
1428 +++ linux-2.4.20-46.9.legacy/net/unix/af_unix.c
1429 @@ -111,6 +111,7 @@
1430 #include <linux/rtnetlink.h>
1431
1432 #include <asm/checksum.h>
1433 +#include <linux/ccsecurity.h>
1434
1435 int sysctl_unix_max_dgram_qlen = 10;
1436
1437 @@ -725,6 +726,9 @@ static int unix_bind(struct socket *sock
1438 * All right, let's create it.
1439 */
1440 mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask);
1441 + err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
1442 + nd.mnt, mode, 0);
1443 + if (!err)
1444 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1445 if (err)
1446 goto out_mknod_dput;

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