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

Subversion リポジトリの参照

Contents of /branches/ccs-patch/patches/ccs-patch-2.4.37.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2921 - (show annotations) (download) (as text)
Wed Aug 19 00:34:46 2009 UTC (14 years, 9 months ago) by kumaneko
File MIME type: text/x-diff
File size: 41426 byte(s)


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

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