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

Subversion リポジトリの参照

Contents of /trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.12-fedora-core-3.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2851 - (show annotations) (download) (as text)
Wed Aug 5 04:58:04 2009 UTC (14 years, 10 months ago) by kumaneko
File MIME type: text/x-diff
File size: 46618 byte(s)


1 This is TOMOYO Linux patch for Fedora Core 3.
2
3 Source code for this patch is http://ftp.riken.jp/Linux/fedoralegacy/fedora/3/updates/SRPMS/kernel-2.6.12-2.3.legacy_FC3.src.rpm
4 ---
5 arch/alpha/kernel/ptrace.c | 3 ++
6 arch/arm/kernel/ptrace.c | 3 ++
7 arch/arm26/kernel/ptrace.c | 3 ++
8 arch/cris/arch-v10/kernel/ptrace.c | 3 ++
9 arch/frv/kernel/ptrace.c | 3 ++
10 arch/h8300/kernel/ptrace.c | 3 ++
11 arch/i386/kernel/ptrace.c | 3 ++
12 arch/ia64/ia32/sys_ia32.c | 3 ++
13 arch/ia64/kernel/ptrace.c | 3 ++
14 arch/m32r/kernel/ptrace.c | 3 ++
15 arch/m68k/kernel/ptrace.c | 3 ++
16 arch/m68knommu/kernel/ptrace.c | 3 ++
17 arch/mips/kernel/ptrace.c | 3 ++
18 arch/mips/kernel/ptrace32.c | 3 ++
19 arch/parisc/kernel/ptrace.c | 3 ++
20 arch/ppc/kernel/ptrace.c | 3 ++
21 arch/ppc64/kernel/ptrace.c | 3 ++
22 arch/ppc64/kernel/ptrace32.c | 3 ++
23 arch/s390/kernel/ptrace.c | 3 ++
24 arch/sh/kernel/ptrace.c | 3 ++
25 arch/sh64/kernel/ptrace.c | 3 ++
26 arch/sparc/kernel/ptrace.c | 5 ++++
27 arch/sparc64/kernel/ptrace.c | 5 ++++
28 arch/um/kernel/ptrace.c | 3 ++
29 arch/v850/kernel/ptrace.c | 3 ++
30 arch/x86_64/ia32/ptrace32.c | 3 ++
31 arch/x86_64/kernel/ptrace.c | 3 ++
32 fs/Kconfig | 2 +
33 fs/Makefile | 2 +
34 fs/attr.c | 5 ++++
35 fs/compat.c | 9 +++++++-
36 fs/exec.c | 12 ++++++++++-
37 fs/fcntl.c | 4 +++
38 fs/ioctl.c | 5 ++++
39 fs/namei.c | 38 +++++++++++++++++++++++++++++++++++++
40 fs/namespace.c | 30 +++++++++++++++++++++++++++--
41 fs/open.c | 15 ++++++++++++++
42 fs/proc/Makefile | 3 ++
43 fs/proc/proc_misc.c | 1
44 include/linux/init_task.h | 2 +
45 include/linux/sched.h | 4 +++
46 kernel/compat.c | 3 ++
47 kernel/kmod.c | 3 ++
48 kernel/module.c | 7 ++++--
49 kernel/sched.c | 3 ++
50 kernel/signal.c | 7 ++++++
51 kernel/sys.c | 11 ++++++++++
52 kernel/sysctl.c | 13 +++++++++++-
53 kernel/time.c | 7 ++++++
54 net/ipv4/raw.c | 4 +++
55 net/ipv4/tcp_ipv4.c | 5 ++++
56 net/ipv4/udp.c | 11 +++++++++-
57 net/ipv6/raw.c | 4 +++
58 net/ipv6/tcp_ipv6.c | 5 ++++
59 net/ipv6/udp.c | 9 ++++++++
60 net/socket.c | 26 ++++++++++++++++++++++---
61 net/unix/af_unix.c | 4 +++
62 57 files changed, 328 insertions(+), 11 deletions(-)
63
64 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/alpha/kernel/ptrace.c
65 +++ linux-2.6.12-2.3.legacy_FC3/arch/alpha/kernel/ptrace.c
66 @@ -20,6 +20,7 @@
67 #include <asm/pgtable.h>
68 #include <asm/system.h>
69 #include <asm/fpu.h>
70 +#include <linux/tomoyo.h>
71
72 #include "proto.h"
73
74 @@ -261,6 +262,8 @@ do_sys_ptrace(long request, long pid, lo
75 unsigned long tmp;
76 size_t copied;
77 long ret;
78 + if (!ccs_capable(CCS_SYS_PTRACE))
79 + return -EPERM;
80
81 lock_kernel();
82 DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
83 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/arm/kernel/ptrace.c
84 +++ linux-2.6.12-2.3.legacy_FC3/arch/arm/kernel/ptrace.c
85 @@ -25,6 +25,7 @@
86 #include <asm/pgtable.h>
87 #include <asm/system.h>
88 #include <asm/traps.h>
89 +#include <linux/tomoyo.h>
90
91 #include "ptrace.h"
92
93 @@ -786,6 +787,8 @@ asmlinkage int sys_ptrace(long request,
94 {
95 struct task_struct *child;
96 int ret;
97 + if (!ccs_capable(CCS_SYS_PTRACE))
98 + return -EPERM;
99
100 lock_kernel();
101 ret = -EPERM;
102 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/arm26/kernel/ptrace.c
103 +++ linux-2.6.12-2.3.legacy_FC3/arch/arm26/kernel/ptrace.c
104 @@ -24,6 +24,7 @@
105 #include <asm/pgtable.h>
106 #include <asm/system.h>
107 //#include <asm/processor.h>
108 +#include <linux/tomoyo.h>
109
110 #include "ptrace.h"
111
112 @@ -669,6 +670,8 @@ asmlinkage int sys_ptrace(long request,
113 {
114 struct task_struct *child;
115 int ret;
116 + if (!ccs_capable(CCS_SYS_PTRACE))
117 + return -EPERM;
118
119 lock_kernel();
120 ret = -EPERM;
121 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/cris/arch-v10/kernel/ptrace.c
122 +++ linux-2.6.12-2.3.legacy_FC3/arch/cris/arch-v10/kernel/ptrace.c
123 @@ -17,6 +17,7 @@
124 #include <asm/pgtable.h>
125 #include <asm/system.h>
126 #include <asm/processor.h>
127 +#include <linux/tomoyo.h>
128
129 /*
130 * Determines which bits in DCCR the user has access to.
131 @@ -81,6 +82,8 @@ sys_ptrace(long request, long pid, long
132 struct task_struct *child;
133 int ret;
134 unsigned long __user *datap = (unsigned long __user *)data;
135 + if (!ccs_capable(CCS_SYS_PTRACE))
136 + return -EPERM;
137
138 lock_kernel();
139 ret = -EPERM;
140 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/frv/kernel/ptrace.c
141 +++ linux-2.6.12-2.3.legacy_FC3/arch/frv/kernel/ptrace.c
142 @@ -28,6 +28,7 @@
143 #include <asm/system.h>
144 #include <asm/processor.h>
145 #include <asm/unistd.h>
146 +#include <linux/tomoyo.h>
147
148 /*
149 * does not yet catch signals sent when the child dies.
150 @@ -112,6 +113,8 @@ asmlinkage int sys_ptrace(long request,
151 unsigned long tmp;
152 int ret;
153
154 + if (!ccs_capable(CCS_SYS_PTRACE))
155 + return -EPERM;
156 lock_kernel();
157 ret = -EPERM;
158 if (request == PTRACE_TRACEME) {
159 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/h8300/kernel/ptrace.c
160 +++ linux-2.6.12-2.3.legacy_FC3/arch/h8300/kernel/ptrace.c
161 @@ -32,6 +32,7 @@
162 #include <asm/system.h>
163 #include <asm/processor.h>
164 #include <asm/signal.h>
165 +#include <linux/tomoyo.h>
166
167 /* cpu depend functions */
168 extern long h8300_get_reg(struct task_struct *task, int regno);
169 @@ -61,6 +62,8 @@ asmlinkage int sys_ptrace(long request,
170 {
171 struct task_struct *child;
172 int ret;
173 + if (!ccs_capable(CCS_SYS_PTRACE))
174 + return -EPERM;
175
176 lock_kernel();
177 ret = -EPERM;
178 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/i386/kernel/ptrace.c
179 +++ linux-2.6.12-2.3.legacy_FC3/arch/i386/kernel/ptrace.c
180 @@ -26,6 +26,7 @@
181 #include <asm/debugreg.h>
182 #include <asm/ldt.h>
183 #include <asm/desc.h>
184 +#include <linux/tomoyo.h>
185
186 /*
187 * does not yet catch signals sent when the child dies.
188 @@ -358,6 +359,8 @@ asmlinkage int sys_ptrace(long request,
189 struct user * dummy = NULL;
190 int i, ret;
191 unsigned long __user *datap = (unsigned long __user *)data;
192 + if (!ccs_capable(CCS_SYS_PTRACE))
193 + return -EPERM;
194
195 lock_kernel();
196 ret = -EPERM;
197 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/ia64/ia32/sys_ia32.c
198 +++ linux-2.6.12-2.3.legacy_FC3/arch/ia64/ia32/sys_ia32.c
199 @@ -56,6 +56,7 @@
200 #include <asm/types.h>
201 #include <asm/uaccess.h>
202 #include <asm/unistd.h>
203 +#include <linux/tomoyo.h>
204
205 #include "ia32priv.h"
206
207 @@ -1757,6 +1758,8 @@ sys32_ptrace (int request, pid_t pid, un
208 struct task_struct *child;
209 unsigned int value, tmp;
210 long i, ret;
211 + if (!ccs_capable(CCS_SYS_PTRACE))
212 + return -EPERM;
213
214 lock_kernel();
215 if (request == PTRACE_TRACEME) {
216 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/ia64/kernel/ptrace.c
217 +++ linux-2.6.12-2.3.legacy_FC3/arch/ia64/kernel/ptrace.c
218 @@ -29,6 +29,7 @@
219 #ifdef CONFIG_PERFMON
220 #include <asm/perfmon.h>
221 #endif
222 +#include <linux/tomoyo.h>
223
224 #include "entry.h"
225
226 @@ -1404,6 +1405,8 @@ sys_ptrace (long request, pid_t pid, uns
227 struct task_struct *child;
228 struct switch_stack *sw;
229 long ret;
230 + if (!ccs_capable(CCS_SYS_PTRACE))
231 + return -EPERM;
232
233 lock_kernel();
234 ret = -EPERM;
235 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/m32r/kernel/ptrace.c
236 +++ linux-2.6.12-2.3.legacy_FC3/arch/m32r/kernel/ptrace.c
237 @@ -33,6 +33,7 @@
238 #include <asm/system.h>
239 #include <asm/processor.h>
240 #include <asm/mmu_context.h>
241 +#include <linux/tomoyo.h>
242
243 /*
244 * Get the address of the live pt_regs for the specified task.
245 @@ -760,6 +761,8 @@ asmlinkage int sys_ptrace(long request,
246 {
247 struct task_struct *child;
248 int ret;
249 + if (!ccs_capable(CCS_SYS_PTRACE))
250 + return -EPERM;
251
252 lock_kernel();
253 ret = -EPERM;
254 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/m68k/kernel/ptrace.c
255 +++ linux-2.6.12-2.3.legacy_FC3/arch/m68k/kernel/ptrace.c
256 @@ -26,6 +26,7 @@
257 #include <asm/pgtable.h>
258 #include <asm/system.h>
259 #include <asm/processor.h>
260 +#include <linux/tomoyo.h>
261
262 /*
263 * does not yet catch signals sent when the child dies.
264 @@ -121,6 +122,8 @@ asmlinkage int sys_ptrace(long request,
265 {
266 struct task_struct *child;
267 int ret;
268 + if (!ccs_capable(CCS_SYS_PTRACE))
269 + return -EPERM;
270
271 lock_kernel();
272 ret = -EPERM;
273 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/m68knommu/kernel/ptrace.c
274 +++ linux-2.6.12-2.3.legacy_FC3/arch/m68knommu/kernel/ptrace.c
275 @@ -26,6 +26,7 @@
276 #include <asm/pgtable.h>
277 #include <asm/system.h>
278 #include <asm/processor.h>
279 +#include <linux/tomoyo.h>
280
281 /*
282 * does not yet catch signals sent when the child dies.
283 @@ -105,6 +106,8 @@ asmlinkage int sys_ptrace(long request,
284 {
285 struct task_struct *child;
286 int ret;
287 + if (!ccs_capable(CCS_SYS_PTRACE))
288 + return -EPERM;
289
290 lock_kernel();
291 ret = -EPERM;
292 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/mips/kernel/ptrace.c
293 +++ linux-2.6.12-2.3.legacy_FC3/arch/mips/kernel/ptrace.c
294 @@ -36,6 +36,7 @@
295 #include <asm/system.h>
296 #include <asm/uaccess.h>
297 #include <asm/bootinfo.h>
298 +#include <linux/tomoyo.h>
299
300 /*
301 * Called by kernel/ptrace.c when detaching..
302 @@ -51,6 +52,8 @@ asmlinkage int sys_ptrace(long request,
303 {
304 struct task_struct *child;
305 int ret;
306 + if (!ccs_capable(CCS_SYS_PTRACE))
307 + return -EPERM;
308
309 #if 0
310 printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
311 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/mips/kernel/ptrace32.c
312 +++ linux-2.6.12-2.3.legacy_FC3/arch/mips/kernel/ptrace32.c
313 @@ -34,6 +34,7 @@
314 #include <asm/system.h>
315 #include <asm/uaccess.h>
316 #include <asm/bootinfo.h>
317 +#include <linux/tomoyo.h>
318
319 /*
320 * Tracing a 32-bit process with a 64-bit strace and vice versa will not
321 @@ -43,6 +44,8 @@ asmlinkage int sys32_ptrace(int request,
322 {
323 struct task_struct *child;
324 int ret;
325 + if (!ccs_capable(CCS_SYS_PTRACE))
326 + return -EPERM;
327
328 #if 0
329 printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
330 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/parisc/kernel/ptrace.c
331 +++ linux-2.6.12-2.3.legacy_FC3/arch/parisc/kernel/ptrace.c
332 @@ -24,6 +24,7 @@
333 #include <asm/system.h>
334 #include <asm/processor.h>
335 #include <asm/offsets.h>
336 +#include <linux/tomoyo.h>
337
338 /* PSW bits we allow the debugger to modify */
339 #define USER_PSW_BITS (PSW_N | PSW_V | PSW_CB)
340 @@ -85,6 +86,8 @@ long sys_ptrace(long request, pid_t pid,
341 #ifdef DEBUG_PTRACE
342 long oaddr=addr, odata=data;
343 #endif
344 + if (!ccs_capable(CCS_SYS_PTRACE))
345 + return -EPERM;
346
347 lock_kernel();
348 ret = -EPERM;
349 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/ppc/kernel/ptrace.c
350 +++ linux-2.6.12-2.3.legacy_FC3/arch/ppc/kernel/ptrace.c
351 @@ -35,6 +35,7 @@
352 #include <asm/page.h>
353 #include <asm/pgtable.h>
354 #include <asm/system.h>
355 +#include <linux/tomoyo.h>
356
357 /*
358 * Set of msr bits that gdb can change on behalf of a process.
359 @@ -244,6 +245,8 @@ int sys_ptrace(long request, long pid, l
360 {
361 struct task_struct *child;
362 int ret = -EPERM;
363 + if (!ccs_capable(CCS_SYS_PTRACE))
364 + return -EPERM;
365
366 lock_kernel();
367 if (request == PTRACE_TRACEME) {
368 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/ppc64/kernel/ptrace.c
369 +++ linux-2.6.12-2.3.legacy_FC3/arch/ppc64/kernel/ptrace.c
370 @@ -35,6 +35,7 @@
371 #include <asm/pgtable.h>
372 #include <asm/system.h>
373 #include <asm/ptrace-common.h>
374 +#include <linux/tomoyo.h>
375
376 /*
377 * does not yet catch signals sent when the child dies.
378 @@ -56,6 +57,8 @@ int sys_ptrace(long request, long pid, l
379 {
380 struct task_struct *child;
381 int ret = -EPERM;
382 + if (!ccs_capable(CCS_SYS_PTRACE))
383 + return -EPERM;
384
385 lock_kernel();
386 if (request == PTRACE_TRACEME) {
387 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/ppc64/kernel/ptrace32.c
388 +++ linux-2.6.12-2.3.legacy_FC3/arch/ppc64/kernel/ptrace32.c
389 @@ -33,6 +33,7 @@
390 #include <asm/pgtable.h>
391 #include <asm/system.h>
392 #include <asm/ptrace-common.h>
393 +#include <linux/tomoyo.h>
394
395 /*
396 * does not yet catch signals sent when the child dies.
397 @@ -43,6 +44,8 @@ int sys32_ptrace(long request, long pid,
398 {
399 struct task_struct *child;
400 int ret = -EPERM;
401 + if (!ccs_capable(CCS_SYS_PTRACE))
402 + return -EPERM;
403
404 lock_kernel();
405 if (request == PTRACE_TRACEME) {
406 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/s390/kernel/ptrace.c
407 +++ linux-2.6.12-2.3.legacy_FC3/arch/s390/kernel/ptrace.c
408 @@ -41,6 +41,7 @@
409 #include <asm/system.h>
410 #include <asm/uaccess.h>
411 #include <asm/unistd.h>
412 +#include <linux/tomoyo.h>
413
414 #ifdef CONFIG_S390_SUPPORT
415 #include "compat_ptrace.h"
416 @@ -710,6 +711,8 @@ sys_ptrace(long request, long pid, long
417 {
418 struct task_struct *child;
419 int ret;
420 + if (!ccs_capable(CCS_SYS_PTRACE))
421 + return -EPERM;
422
423 lock_kernel();
424
425 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/sh/kernel/ptrace.c
426 +++ linux-2.6.12-2.3.legacy_FC3/arch/sh/kernel/ptrace.c
427 @@ -28,6 +28,7 @@
428 #include <asm/system.h>
429 #include <asm/processor.h>
430 #include <asm/mmu_context.h>
431 +#include <linux/tomoyo.h>
432
433 /*
434 * does not yet catch signals sent when the child dies.
435 @@ -85,6 +86,8 @@ asmlinkage int sys_ptrace(long request,
436 struct task_struct *child;
437 struct user * dummy = NULL;
438 int ret;
439 + if (!ccs_capable(CCS_SYS_PTRACE))
440 + return -EPERM;
441
442 lock_kernel();
443 ret = -EPERM;
444 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/sh64/kernel/ptrace.c
445 +++ linux-2.6.12-2.3.legacy_FC3/arch/sh64/kernel/ptrace.c
446 @@ -35,6 +35,7 @@
447 #include <asm/system.h>
448 #include <asm/processor.h>
449 #include <asm/mmu_context.h>
450 +#include <linux/tomoyo.h>
451
452 /* This mask defines the bits of the SR which the user is not allowed to
453 change, which are everything except S, Q, M, PR, SZ, FR. */
454 @@ -128,6 +129,8 @@ asmlinkage int sys_ptrace(long request,
455 #define WPC_DBRMODE 0x0d104008
456 static int first_call = 1;
457 int ret;
458 + if (!ccs_capable(CCS_SYS_PTRACE))
459 + return -EPERM;
460
461 lock_kernel();
462
463 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/sparc/kernel/ptrace.c
464 +++ linux-2.6.12-2.3.legacy_FC3/arch/sparc/kernel/ptrace.c
465 @@ -23,6 +23,7 @@
466 #include <asm/pgtable.h>
467 #include <asm/system.h>
468 #include <asm/uaccess.h>
469 +#include <linux/tomoyo.h>
470
471 #define MAGIC_CONSTANT 0x80000000
472
473 @@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs
474 unsigned long addr2 = regs->u_regs[UREG_I4];
475 struct task_struct *child;
476 int ret;
477 + if (!ccs_capable(CCS_SYS_PTRACE)) {
478 + pt_error_return(regs, EPERM);
479 + return;
480 + }
481
482 lock_kernel();
483 #ifdef DEBUG_PTRACE
484 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/sparc64/kernel/ptrace.c
485 +++ linux-2.6.12-2.3.legacy_FC3/arch/sparc64/kernel/ptrace.c
486 @@ -28,6 +28,7 @@
487 #include <asm/psrcompat.h>
488 #include <asm/visasm.h>
489 #include <asm/spitfire.h>
490 +#include <linux/tomoyo.h>
491
492 /* Returning from ptrace is a bit tricky because the syscall return
493 * low level code assumes any value returned which is negative and
494 @@ -162,6 +163,10 @@ asmlinkage void do_ptrace(struct pt_regs
495 unsigned long addr2 = regs->u_regs[UREG_I4];
496 struct task_struct *child;
497 int ret;
498 + if (!ccs_capable(CCS_SYS_PTRACE)) {
499 + pt_error_return(regs, EPERM);
500 + return;
501 + }
502
503 if (test_thread_flag(TIF_32BIT)) {
504 addr &= 0xffffffffUL;
505 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/um/kernel/ptrace.c
506 +++ linux-2.6.12-2.3.legacy_FC3/arch/um/kernel/ptrace.c
507 @@ -18,6 +18,7 @@
508 #include "kern_util.h"
509 #include "skas_ptrace.h"
510 #include "sysdep/ptrace.h"
511 +#include <linux/tomoyo.h>
512
513 static inline void set_singlestepping(struct task_struct *child, int on)
514 {
515 @@ -47,6 +48,8 @@ long sys_ptrace(long request, long pid,
516 {
517 struct task_struct *child;
518 int i, ret;
519 + if (!ccs_capable(CCS_SYS_PTRACE))
520 + return -EPERM;
521
522 lock_kernel();
523 ret = -EPERM;
524 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/v850/kernel/ptrace.c
525 +++ linux-2.6.12-2.3.legacy_FC3/arch/v850/kernel/ptrace.c
526 @@ -29,6 +29,7 @@
527 #include <asm/ptrace.h>
528 #include <asm/processor.h>
529 #include <asm/uaccess.h>
530 +#include <linux/tomoyo.h>
531
532 /* Returns the address where the register at REG_OFFS in P is stashed away. */
533 static v850_reg_t *reg_save_addr (unsigned reg_offs, struct task_struct *t)
534 @@ -117,6 +118,8 @@ int sys_ptrace(long request, long pid, l
535 {
536 struct task_struct *child;
537 int rval;
538 + if (!ccs_capable(CCS_SYS_PTRACE))
539 + return -EPERM;
540
541 lock_kernel();
542
543 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/x86_64/ia32/ptrace32.c
544 +++ linux-2.6.12-2.3.legacy_FC3/arch/x86_64/ia32/ptrace32.c
545 @@ -27,6 +27,7 @@
546 #include <asm/debugreg.h>
547 #include <asm/i387.h>
548 #include <asm/fpu32.h>
549 +#include <linux/tomoyo.h>
550
551 /* determines which flags the user has access to. */
552 /* 1 = access 0 = no access */
553 @@ -233,6 +234,8 @@ asmlinkage long sys32_ptrace(long reques
554 void __user *datap = compat_ptr(data);
555 int ret;
556 __u32 val;
557 + if (!ccs_capable(CCS_SYS_PTRACE))
558 + return -EPERM;
559
560 switch (request) {
561 default:
562 --- linux-2.6.12-2.3.legacy_FC3.orig/arch/x86_64/kernel/ptrace.c
563 +++ linux-2.6.12-2.3.legacy_FC3/arch/x86_64/kernel/ptrace.c
564 @@ -30,6 +30,7 @@
565 #include <asm/desc.h>
566 #include <asm/proto.h>
567 #include <asm/ia32.h>
568 +#include <linux/tomoyo.h>
569
570 /*
571 * does not yet catch signals sent when the child dies.
572 @@ -318,6 +319,8 @@ asmlinkage long sys_ptrace(long request,
573 struct task_struct *child;
574 long i, ret;
575 unsigned ui;
576 + if (!ccs_capable(CCS_SYS_PTRACE))
577 + return -EPERM;
578
579 /* This lock_kernel fixes a subtle race with suid exec */
580 lock_kernel();
581 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/Kconfig
582 +++ linux-2.6.12-2.3.legacy_FC3/fs/Kconfig
583 @@ -1725,5 +1725,7 @@ endmenu
584
585 source "fs/nls/Kconfig"
586
587 +source "fs/Kconfig.ccs"
588 +
589 endmenu
590
591 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/Makefile
592 +++ linux-2.6.12-2.3.legacy_FC3/fs/Makefile
593 @@ -95,3 +95,5 @@ obj-$(CONFIG_BEFS_FS) += befs/
594 obj-$(CONFIG_HOSTFS) += hostfs/
595 obj-$(CONFIG_HPPFS) += hppfs/
596 obj-$(CONFIG_DEBUG_FS) += debugfs/
597 +
598 +include $(srctree)/fs/Makefile-2.6.ccs
599 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/attr.c
600 +++ linux-2.6.12-2.3.legacy_FC3/fs/attr.c
601 @@ -15,6 +15,7 @@
602 #include <linux/quotaops.h>
603 #include <linux/security.h>
604 #include <linux/time.h>
605 +#include <linux/tomoyo.h>
606
607 /* Taken over from the old code... */
608
609 @@ -180,11 +181,15 @@ int notify_change(struct dentry * dentry
610 if (inode->i_op && inode->i_op->setattr) {
611 error = security_inode_setattr(dentry, attr);
612 if (!error)
613 + error = ccs_check_setattr_permission(dentry, attr);
614 + if (!error)
615 error = inode->i_op->setattr(dentry, attr);
616 } else {
617 error = inode_change_ok(inode, attr);
618 if (!error)
619 error = security_inode_setattr(dentry, attr);
620 + if (!error)
621 + error = ccs_check_setattr_permission(dentry, attr);
622 if (!error) {
623 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
624 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
625 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/compat.c
626 +++ linux-2.6.12-2.3.legacy_FC3/fs/compat.c
627 @@ -50,6 +50,7 @@
628 #include <asm/uaccess.h>
629 #include <asm/mmu_context.h>
630 #include <asm/ioctls.h>
631 +#include <linux/tomoyo.h>
632
633 /*
634 * Not all architectures have sys_utime, so implement this in terms
635 @@ -442,6 +443,8 @@ asmlinkage long compat_sys_ioctl(unsigne
636
637 /* RED-PEN how should LSM module know it's handling 32bit? */
638 error = security_file_ioctl(filp, cmd, arg);
639 + if (!error)
640 + error = ccs_check_ioctl_permission(filp, cmd, arg);
641 if (error)
642 goto out_fput;
643
644 @@ -466,6 +469,10 @@ asmlinkage long compat_sys_ioctl(unsigne
645 /*FALL THROUGH*/
646
647 default:
648 + if (!ccs_capable(CCS_SYS_IOCTL)) {
649 + error = -EPERM;
650 + goto out_fput;
651 + }
652 if (filp->f_op && filp->f_op->compat_ioctl) {
653 error = filp->f_op->compat_ioctl(filp, cmd, arg);
654 if (error != -ENOIOCTLCMD)
655 @@ -1557,7 +1564,7 @@ int compat_do_execve(char * filename,
656 if (retval < 0)
657 goto out;
658
659 - retval = search_binary_handler(bprm, regs);
660 + retval = ccs_search_binary_handler(bprm, regs);
661 if (retval >= 0) {
662 free_arg_pages(bprm);
663
664 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/exec.c
665 +++ linux-2.6.12-2.3.legacy_FC3/fs/exec.c
666 @@ -56,6 +56,8 @@
667 #include <linux/kmod.h>
668 #endif
669
670 +#include <linux/tomoyo.h>
671 +
672 int core_uses_pid;
673 char core_pattern[65] = "core";
674 /* The maximal length of core_pattern is also specified in sysctl.c */
675 @@ -136,6 +138,10 @@ asmlinkage long sys_uselib(const char __
676 if (error)
677 goto exit;
678
679 + error = ccs_check_uselib_permission(nd.dentry, nd.mnt);
680 + if (error)
681 + goto exit;
682 +
683 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
684 error = PTR_ERR(file);
685 if (IS_ERR(file))
686 @@ -504,6 +510,9 @@ struct file *open_exec(const char *name)
687 int err = permission(inode, MAY_EXEC, &nd);
688 if (!err && !(inode->i_mode & 0111))
689 err = -EACCES;
690 + if (!err)
691 + err = ccs_check_open_exec_permission(nd.dentry,
692 + nd.mnt);
693 file = ERR_PTR(err);
694 if (!err) {
695 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
696 @@ -1189,7 +1198,8 @@ int do_execve(char * filename,
697 if (retval < 0)
698 goto out;
699
700 - retval = search_binary_handler(bprm,regs);
701 + retval = ccs_search_binary_handler(bprm, regs);
702 +
703 if (retval >= 0) {
704 free_arg_pages(bprm);
705
706 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/fcntl.c
707 +++ linux-2.6.12-2.3.legacy_FC3/fs/fcntl.c
708 @@ -20,6 +20,7 @@
709 #include <asm/poll.h>
710 #include <asm/siginfo.h>
711 #include <asm/uaccess.h>
712 +#include <linux/tomoyo.h>
713
714 void fastcall set_close_on_exec(unsigned int fd, int flag)
715 {
716 @@ -195,6 +196,9 @@ static int setfl(int fd, struct file * f
717 if (!(arg & O_APPEND) && IS_APPEND(inode))
718 return -EPERM;
719
720 + if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp))
721 + return -EPERM;
722 +
723 /* O_NOATIME can only be set by the owner or superuser */
724 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
725 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
726 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/ioctl.c
727 +++ linux-2.6.12-2.3.legacy_FC3/fs/ioctl.c
728 @@ -15,6 +15,7 @@
729
730 #include <asm/uaccess.h>
731 #include <asm/ioctls.h>
732 +#include <linux/tomoyo.h>
733
734 static long do_ioctl(struct file *filp, unsigned int cmd,
735 unsigned long arg)
736 @@ -23,6 +24,8 @@ static long do_ioctl(struct file *filp,
737
738 if (!filp->f_op)
739 goto out;
740 + if (!ccs_capable(CCS_SYS_IOCTL))
741 + return -EPERM;
742
743 if (filp->f_op->unlocked_ioctl) {
744 error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
745 @@ -167,6 +170,8 @@ asmlinkage long sys_ioctl(unsigned int f
746 goto out;
747
748 error = security_file_ioctl(filp, cmd, arg);
749 + if (!error)
750 + error = ccs_check_ioctl_permission(filp, cmd, arg);
751 if (error)
752 goto out_fput;
753
754 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/namei.c
755 +++ linux-2.6.12-2.3.legacy_FC3/fs/namei.c
756 @@ -33,6 +33,8 @@
757
758 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
759
760 +#include <linux/tomoyo.h>
761 +
762 /* [Feb-1997 T. Schoebel-Theuer]
763 * Fundamental changes in the pathname lookup mechanisms (namei)
764 * were necessary because of omirr. The reason is that omirr needs
765 @@ -1374,6 +1376,11 @@ int may_open(struct nameidata *nd, int a
766 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
767 return -EPERM;
768
769 + /* includes O_APPEND and O_TRUNC checks */
770 + error = ccs_check_open_permission(dentry, nd->mnt, flag);
771 + if (error)
772 + return error;
773 +
774 /*
775 * Ensure there are no outstanding leases on the file.
776 */
777 @@ -1405,6 +1412,7 @@ int may_open(struct nameidata *nd, int a
778 return 0;
779 }
780
781 +#include <linux/tomoyo_vfs.h>
782 /*
783 * open_namei()
784 *
785 @@ -1480,6 +1488,9 @@ do_last:
786 if (!path.dentry->d_inode) {
787 if (!IS_POSIXACL(dir->d_inode))
788 mode &= ~current->fs->umask;
789 + error = ccs_check_mknod_permission(dir->d_inode, path.dentry,
790 + nd->mnt, mode, 0);
791 + if (!error)
792 error = vfs_create(dir->d_inode, path.dentry, mode, nd);
793 up(&dir->d_inode->i_sem);
794 dput(nd->dentry);
795 @@ -1657,6 +1668,10 @@ asmlinkage long sys_mknod(const char __u
796 if (!IS_POSIXACL(nd.dentry->d_inode))
797 mode &= ~current->fs->umask;
798 if (!IS_ERR(dentry)) {
799 + error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
800 + nd.mnt, mode,
801 + new_decode_dev(dev));
802 + if (!error)
803 switch (mode & S_IFMT) {
804 case 0: case S_IFREG:
805 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
806 @@ -1727,6 +1742,10 @@ asmlinkage long sys_mkdir(const char __u
807 if (!IS_ERR(dentry)) {
808 if (!IS_POSIXACL(nd.dentry->d_inode))
809 mode &= ~current->fs->umask;
810 + error = ccs_check_mkdir_permission(nd.dentry->d_inode,
811 + dentry, nd.mnt,
812 + mode);
813 + if (!error)
814 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
815 dput(dentry);
816 }
817 @@ -1831,6 +1850,9 @@ asmlinkage long sys_rmdir(const char __u
818 dentry = lookup_hash(&nd.last, nd.dentry);
819 error = PTR_ERR(dentry);
820 if (!IS_ERR(dentry)) {
821 + error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry,
822 + nd.mnt);
823 + if (!error)
824 error = vfs_rmdir(nd.dentry->d_inode, dentry);
825 dput(dentry);
826 }
827 @@ -1906,6 +1928,9 @@ asmlinkage long sys_unlink(const char __
828 inode = dentry->d_inode;
829 if (inode)
830 atomic_inc(&inode->i_count);
831 + error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry,
832 + nd.mnt);
833 + if (!error)
834 error = vfs_unlink(nd.dentry->d_inode, dentry);
835 exit2:
836 dput(dentry);
837 @@ -1969,6 +1994,10 @@ asmlinkage long sys_symlink(const char _
838 dentry = lookup_create(&nd, 0);
839 error = PTR_ERR(dentry);
840 if (!IS_ERR(dentry)) {
841 + error = ccs_check_symlink_permission(nd.dentry->d_inode,
842 + dentry, nd.mnt,
843 + from);
844 + if (!error)
845 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
846 dput(dentry);
847 }
848 @@ -2053,6 +2082,10 @@ asmlinkage long sys_link(const char __us
849 new_dentry = lookup_create(&nd, 0);
850 error = PTR_ERR(new_dentry);
851 if (!IS_ERR(new_dentry)) {
852 + error = ccs_check_link_permission(old_nd.dentry,
853 + nd.dentry->d_inode,
854 + new_dentry, nd.mnt);
855 + if (!error)
856 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
857 dput(new_dentry);
858 }
859 @@ -2275,6 +2308,11 @@ static inline int do_rename(const char *
860 if (new_dentry == trap)
861 goto exit5;
862
863 + error = ccs_check_rename_permission(old_dir->d_inode, old_dentry,
864 + new_dir->d_inode, new_dentry,
865 + newnd.mnt);
866 + if (!error)
867 +
868 error = vfs_rename(old_dir->d_inode, old_dentry,
869 new_dir->d_inode, new_dentry);
870 exit5:
871 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/namespace.c
872 +++ linux-2.6.12-2.3.legacy_FC3/fs/namespace.c
873 @@ -24,6 +24,8 @@
874 #include <linux/mount.h>
875 #include <asm/uaccess.h>
876 #include <asm/unistd.h>
877 +#include <linux/sakura.h>
878 +#include <linux/tomoyo.h>
879
880 extern int __init init_rootfs(void);
881
882 @@ -373,6 +375,9 @@ static int do_umount(struct vfsmount *mn
883 if (retval)
884 return retval;
885
886 + if (ccs_may_umount(mnt))
887 + return -EPERM;
888 +
889 /*
890 * Allow userspace to request a mountpoint be expired rather than
891 * unmounting unconditionally. Unmount only happens if:
892 @@ -469,6 +474,8 @@ asmlinkage long sys_umount(char __user *
893 {
894 struct nameidata nd;
895 int retval;
896 + if (!ccs_capable(CCS_SYS_UMOUNT))
897 + return -EPERM;
898
899 retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
900 if (retval)
901 @@ -634,6 +641,9 @@ static int do_loopback(struct nameidata
902 down_write(&current->namespace->sem);
903 err = -EINVAL;
904 if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {
905 + err = -EPERM;
906 + if (ccs_may_mount(nd))
907 + goto out;
908 err = -ENOMEM;
909 if (recurse)
910 mnt = copy_tree(old_nd.mnt, old_nd.dentry);
911 @@ -655,7 +665,7 @@ static int do_loopback(struct nameidata
912 } else
913 mntput(mnt);
914 }
915 -
916 + out:
917 up_write(&current->namespace->sem);
918 path_release(&old_nd);
919 return err;
920 @@ -711,7 +721,9 @@ static int do_move_mount(struct nameidat
921 err = -EINVAL;
922 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
923 goto out;
924 -
925 + err = -EPERM;
926 + if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd))
927 + goto out;
928 err = -ENOENT;
929 down(&nd->dentry->d_inode->i_sem);
930 if (IS_DEADDIR(nd->dentry->d_inode))
931 @@ -805,6 +817,9 @@ int do_add_mount(struct vfsmount *newmnt
932 err = -EINVAL;
933 if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
934 goto unlock;
935 + err = -EPERM;
936 + if (ccs_may_mount(nd))
937 + goto unlock;
938
939 newmnt->mnt_flags = mnt_flags;
940 err = graft_tree(newmnt, nd);
941 @@ -1026,6 +1041,13 @@ long do_mount(char * dev_name, char * di
942 if (data_page)
943 ((char *)data_page)[PAGE_SIZE - 1] = 0;
944
945 + if (!ccs_capable(CCS_SYS_MOUNT))
946 + return -EPERM;
947 + retval = ccs_check_mount_permission(dev_name, dir_name, type_page,
948 + &flags);
949 + if (retval)
950 + return retval;
951 +
952 /* Separate the per-mountpoint flags */
953 if (flags & MS_NOSUID)
954 mnt_flags |= MNT_NOSUID;
955 @@ -1286,6 +1308,8 @@ asmlinkage long sys_pivot_root(const cha
956
957 if (!capable(CAP_SYS_ADMIN))
958 return -EPERM;
959 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
960 + return -EPERM;
961
962 lock_kernel();
963
964 @@ -1301,6 +1325,8 @@ asmlinkage long sys_pivot_root(const cha
965 goto out1;
966
967 error = security_sb_pivotroot(&old_nd, &new_nd);
968 + if (!error)
969 + error = ccs_check_pivot_root_permission(&old_nd, &new_nd);
970 if (error) {
971 path_release(&old_nd);
972 goto out1;
973 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/open.c
974 +++ linux-2.6.12-2.3.legacy_FC3/fs/open.c
975 @@ -26,6 +26,9 @@
976
977 #include <asm/unistd.h>
978
979 +#include <linux/sakura.h>
980 +#include <linux/tomoyo.h>
981 +
982 int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
983 {
984 int retval = -ENODEV;
985 @@ -257,6 +260,8 @@ static inline long do_sys_truncate(const
986 if (error)
987 goto dput_and_out;
988
989 + error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0);
990 + if (!error)
991 error = locks_verify_truncate(inode, NULL, length);
992 if (!error) {
993 DQUOT_INIT(inode);
994 @@ -310,6 +315,10 @@ static inline long do_sys_ftruncate(unsi
995 if (IS_APPEND(inode))
996 goto out_putf;
997
998 + error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
999 + 0);
1000 + if (error)
1001 + goto out_putf;
1002 error = locks_verify_truncate(inode, file, length);
1003 if (!error)
1004 error = do_truncate(dentry, length);
1005 @@ -584,6 +593,10 @@ asmlinkage long sys_chroot(const char __
1006 error = -EPERM;
1007 if (!capable(CAP_SYS_CHROOT))
1008 goto dput_and_out;
1009 + if (!ccs_capable(CCS_SYS_CHROOT))
1010 + goto dput_and_out;
1011 + if (ccs_check_chroot_permission(&nd))
1012 + goto dput_and_out;
1013
1014 set_fs_root(current->fs, nd.mnt, nd.dentry);
1015 set_fs_altroot();
1016 @@ -1044,6 +1057,8 @@ EXPORT_SYMBOL(sys_close);
1017 */
1018 asmlinkage long sys_vhangup(void)
1019 {
1020 + if (!ccs_capable(CCS_SYS_VHANGUP))
1021 + return -EPERM;
1022 if (capable(CAP_SYS_TTY_CONFIG)) {
1023 tty_vhangup(current->signal->tty);
1024 return 0;
1025 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/proc/Makefile
1026 +++ linux-2.6.12-2.3.legacy_FC3/fs/proc/Makefile
1027 @@ -12,3 +12,6 @@ proc-y += inode.o root.o base.o ge
1028
1029 proc-$(CONFIG_PROC_KCORE) += kcore.o
1030 proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
1031 +
1032 +proc-$(CONFIG_SAKURA) += ccs_proc.o
1033 +proc-$(CONFIG_TOMOYO) += ccs_proc.o
1034 --- linux-2.6.12-2.3.legacy_FC3.orig/fs/proc/proc_misc.c
1035 +++ linux-2.6.12-2.3.legacy_FC3/fs/proc/proc_misc.c
1036 @@ -617,4 +617,5 @@ void __init proc_misc_init(void)
1037 entry->proc_fops = &ppc_htab_operations;
1038 }
1039 #endif
1040 + printk(KERN_INFO "Hook version: 2.6.12-2.3.legacy_FC3 2009/08/05\n");
1041 }
1042 --- linux-2.6.12-2.3.legacy_FC3.orig/include/linux/init_task.h
1043 +++ linux-2.6.12-2.3.legacy_FC3/include/linux/init_task.h
1044 @@ -111,6 +111,8 @@ extern struct group_info init_groups;
1045 .switch_lock = SPIN_LOCK_UNLOCKED, \
1046 .journal_info = NULL, \
1047 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
1048 + .ccs_domain_info = NULL, \
1049 + .ccs_flags = 0, \
1050 }
1051
1052
1053 --- linux-2.6.12-2.3.legacy_FC3.orig/include/linux/sched.h
1054 +++ linux-2.6.12-2.3.legacy_FC3/include/linux/sched.h
1055 @@ -39,6 +39,8 @@ struct exec_domain;
1056 extern int exec_shield;
1057 extern int print_fatal_signals;
1058
1059 +struct ccs_domain_info;
1060 +
1061 /*
1062 * cloning flags:
1063 */
1064 @@ -754,6 +756,8 @@ struct task_struct {
1065 nodemask_t mems_allowed;
1066 int cpuset_mems_generation;
1067 #endif
1068 + struct ccs_domain_info *ccs_domain_info;
1069 + u32 ccs_flags;
1070 };
1071
1072 static inline pid_t process_group(struct task_struct *tsk)
1073 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/compat.c
1074 +++ linux-2.6.12-2.3.legacy_FC3/kernel/compat.c
1075 @@ -24,6 +24,7 @@
1076
1077 #include <asm/uaccess.h>
1078 #include <asm/bug.h>
1079 +#include <linux/tomoyo.h>
1080
1081 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
1082 {
1083 @@ -852,6 +853,8 @@ asmlinkage long compat_sys_stime(compat_
1084 err = security_settime(&tv, NULL);
1085 if (err)
1086 return err;
1087 + if (!ccs_capable(CCS_SYS_SETTIME))
1088 + return -EPERM;
1089
1090 do_settimeofday(&tv);
1091 return 0;
1092 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/kmod.c
1093 +++ linux-2.6.12-2.3.legacy_FC3/kernel/kmod.c
1094 @@ -139,6 +139,9 @@ int __exec_usermodehelper(char *path, ch
1095 recalc_sigpending();
1096 spin_unlock_irq(&current->sighand->siglock);
1097
1098 + current->ccs_domain_info = NULL;
1099 + current->ccs_flags = 0;
1100 +
1101 retval = -EPERM;
1102 if (current->fs->root)
1103 retval = execve(path, argv, envp);
1104 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/module.c
1105 +++ linux-2.6.12-2.3.legacy_FC3/kernel/module.c
1106 @@ -39,6 +39,7 @@
1107 #include <asm/semaphore.h>
1108 #include <asm/cacheflush.h>
1109 #include "module-verify.h"
1110 +#include <linux/tomoyo.h>
1111
1112 #if 0
1113 #define DEBUGP printk
1114 @@ -538,7 +539,8 @@ sys_delete_module(const char __user *nam
1115
1116 if (!capable(CAP_SYS_MODULE))
1117 return -EPERM;
1118 -
1119 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1120 + return -EPERM;
1121 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
1122 return -EFAULT;
1123 name[MODULE_NAME_LEN-1] = '\0';
1124 @@ -1777,7 +1779,8 @@ sys_init_module(void __user *umod,
1125 /* Must have permission */
1126 if (!capable(CAP_SYS_MODULE))
1127 return -EPERM;
1128 -
1129 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
1130 + return -EPERM;
1131 /* Only one module load at a time, please */
1132 if (down_interruptible(&module_mutex) != 0)
1133 return -EINTR;
1134 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/sched.c
1135 +++ linux-2.6.12-2.3.legacy_FC3/kernel/sched.c
1136 @@ -50,6 +50,7 @@
1137 #include <asm/tlb.h>
1138
1139 #include <asm/unistd.h>
1140 +#include <linux/tomoyo.h>
1141
1142 /*
1143 * Convert user-nice values [ -20 ... 0 ... 19 ]
1144 @@ -3252,6 +3253,8 @@ asmlinkage long sys_nice(int increment)
1145 {
1146 int retval;
1147 long nice;
1148 + if (!ccs_capable(CCS_SYS_NICE))
1149 + return -EPERM;
1150
1151 /*
1152 * Setpriority might change our priority at the same moment.
1153 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/signal.c
1154 +++ linux-2.6.12-2.3.legacy_FC3/kernel/signal.c
1155 @@ -29,6 +29,7 @@
1156 #include <asm/uaccess.h>
1157 #include <asm/unistd.h>
1158 #include <asm/siginfo.h>
1159 +#include <linux/tomoyo.h>
1160
1161 /*
1162 * SLAB caches for signal bits.
1163 @@ -2288,6 +2289,8 @@ asmlinkage long
1164 sys_kill(int pid, int sig)
1165 {
1166 struct siginfo info;
1167 + if (ccs_kill_permission(pid, sig))
1168 + return -EPERM;
1169
1170 info.si_signo = sig;
1171 info.si_errno = 0;
1172 @@ -2317,6 +2320,8 @@ asmlinkage long sys_tgkill(int tgid, int
1173 /* This is only valid for single tasks */
1174 if (pid <= 0 || tgid <= 0)
1175 return -EINVAL;
1176 + if (ccs_tgkill_permission(tgid, pid, sig))
1177 + return -EPERM;
1178
1179 info.si_signo = sig;
1180 info.si_errno = 0;
1181 @@ -2357,6 +2362,8 @@ sys_tkill(int pid, int sig)
1182 /* This is only valid for single tasks */
1183 if (pid <= 0)
1184 return -EINVAL;
1185 + if (ccs_tkill_permission(pid, sig))
1186 + return -EPERM;
1187
1188 info.si_signo = sig;
1189 info.si_errno = 0;
1190 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/sys.c
1191 +++ linux-2.6.12-2.3.legacy_FC3/kernel/sys.c
1192 @@ -33,6 +33,7 @@
1193 #include <asm/uaccess.h>
1194 #include <asm/io.h>
1195 #include <asm/unistd.h>
1196 +#include <linux/tomoyo.h>
1197
1198 #ifndef SET_UNALIGN_CTL
1199 # define SET_UNALIGN_CTL(a,b) (-EINVAL)
1200 @@ -252,6 +253,10 @@ asmlinkage long sys_setpriority(int whic
1201
1202 if (which > 2 || which < 0)
1203 goto out;
1204 + if (!ccs_capable(CCS_SYS_NICE)) {
1205 + error = -EPERM;
1206 + goto out;
1207 + }
1208
1209 /* normalize: avoid signed division (rounding problems) */
1210 error = -ESRCH;
1211 @@ -383,6 +388,8 @@ asmlinkage long sys_reboot(int magic1, i
1212 magic2 != LINUX_REBOOT_MAGIC2B &&
1213 magic2 != LINUX_REBOOT_MAGIC2C))
1214 return -EINVAL;
1215 + if (!ccs_capable(CCS_SYS_REBOOT))
1216 + return -EPERM;
1217
1218 lock_kernel();
1219 switch (cmd) {
1220 @@ -1385,6 +1392,8 @@ asmlinkage long sys_sethostname(char __u
1221 return -EPERM;
1222 if (len < 0 || len > __NEW_UTS_LEN)
1223 return -EINVAL;
1224 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1225 + return -EPERM;
1226 down_write(&uts_sem);
1227 errno = -EFAULT;
1228 if (!copy_from_user(tmp, name, len)) {
1229 @@ -1430,6 +1439,8 @@ asmlinkage long sys_setdomainname(char _
1230 return -EPERM;
1231 if (len < 0 || len > __NEW_UTS_LEN)
1232 return -EINVAL;
1233 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
1234 + return -EPERM;
1235
1236 down_write(&uts_sem);
1237 errno = -EFAULT;
1238 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/sysctl.c
1239 +++ linux-2.6.12-2.3.legacy_FC3/kernel/sysctl.c
1240 @@ -44,6 +44,7 @@
1241
1242 #include <asm/uaccess.h>
1243 #include <asm/processor.h>
1244 +#include <linux/tomoyo.h>
1245
1246 #ifdef CONFIG_ROOT_NFS
1247 #include <linux/nfs_fs.h>
1248 @@ -1077,6 +1078,9 @@ int do_sysctl(int __user *name, int nlen
1249
1250 spin_unlock(&sysctl_lock);
1251
1252 + error = ccs_parse_table(name, nlen, oldval, newval,
1253 + head->ctl_table);
1254 + if (!error)
1255 error = parse_table(name, nlen, oldval, oldlenp,
1256 newval, newlen, head->ctl_table,
1257 &context);
1258 @@ -1150,6 +1154,13 @@ repeat:
1259 if (ctl_perm(table, 001))
1260 return -EPERM;
1261 if (table->strategy) {
1262 + int op = 0;
1263 + if (oldval)
1264 + op |= 004;
1265 + if (newval)
1266 + op |= 002;
1267 + if (ctl_perm(table, op))
1268 + return -EPERM;
1269 error = table->strategy(
1270 table, name, nlen,
1271 oldval, oldlenp,
1272 @@ -2234,7 +2245,7 @@ int sysctl_string(ctl_table *table, int
1273 len--;
1274 ((char *) table->data)[len] = 0;
1275 }
1276 - return 0;
1277 + return 1;
1278 }
1279
1280 /*
1281 --- linux-2.6.12-2.3.legacy_FC3.orig/kernel/time.c
1282 +++ linux-2.6.12-2.3.legacy_FC3/kernel/time.c
1283 @@ -38,6 +38,7 @@
1284
1285 #include <asm/uaccess.h>
1286 #include <asm/unistd.h>
1287 +#include <linux/tomoyo.h>
1288
1289 /*
1290 * The timezone where the local system is located. Used as a default by some
1291 @@ -90,6 +91,8 @@ asmlinkage long sys_stime(time_t __user
1292 err = security_settime(&tv, NULL);
1293 if (err)
1294 return err;
1295 + if (!ccs_capable(CCS_SYS_SETTIME))
1296 + return -EPERM;
1297
1298 do_settimeofday(&tv);
1299 return 0;
1300 @@ -157,6 +160,8 @@ int do_sys_settimeofday(struct timespec
1301 error = security_settime(tv, tz);
1302 if (error)
1303 return error;
1304 + if (!ccs_capable(CCS_SYS_SETTIME))
1305 + return -EPERM;
1306
1307 if (tz) {
1308 /* SMP safe, global irq locking makes it work. */
1309 @@ -235,6 +240,8 @@ int do_adjtimex(struct timex *txc)
1310 /* In order to modify anything, you gotta be super-user! */
1311 if (txc->modes && !capable(CAP_SYS_TIME))
1312 return -EPERM;
1313 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1314 + return -EPERM;
1315
1316 /* Now we validate the data before disabling interrupts */
1317
1318 --- linux-2.6.12-2.3.legacy_FC3.orig/net/ipv4/raw.c
1319 +++ linux-2.6.12-2.3.legacy_FC3/net/ipv4/raw.c
1320 @@ -79,6 +79,7 @@
1321 #include <linux/seq_file.h>
1322 #include <linux/netfilter.h>
1323 #include <linux/netfilter_ipv4.h>
1324 +#include <linux/tomoyo_socket.h>
1325
1326 struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1327 DEFINE_RWLOCK(raw_v4_lock);
1328 @@ -585,6 +586,9 @@ static int raw_recvmsg(struct kiocb *ioc
1329 skb = skb_recv_datagram(sk, flags, noblock, &err);
1330 if (!skb)
1331 goto out;
1332 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1333 + if (err)
1334 + goto out;
1335
1336 copied = skb->len;
1337 if (len < copied) {
1338 --- linux-2.6.12-2.3.legacy_FC3.orig/net/ipv4/tcp_ipv4.c
1339 +++ linux-2.6.12-2.3.legacy_FC3/net/ipv4/tcp_ipv4.c
1340 @@ -74,6 +74,7 @@
1341 #include <linux/stddef.h>
1342 #include <linux/proc_fs.h>
1343 #include <linux/seq_file.h>
1344 +#include <linux/sakura.h>
1345
1346 extern int sysctl_ip_dynaddr;
1347 int sysctl_tcp_tw_reuse;
1348 @@ -232,6 +233,8 @@ static int tcp_v4_get_port(struct sock *
1349 rover = low;
1350 head = &tcp_bhash[tcp_bhashfn(rover)];
1351 spin_lock(&head->lock);
1352 + if (ccs_lport_reserved(rover))
1353 + goto next;
1354 tb_for_each(tb, node, &head->chain)
1355 if (tb->port == rover)
1356 goto next;
1357 @@ -672,6 +675,8 @@ static inline int tcp_v4_hash_connect(st
1358 local_bh_disable();
1359 for (i = 1; i <= range; i++) {
1360 port = low + (i + offset) % range;
1361 + if (ccs_lport_reserved(port))
1362 + continue;
1363 head = &tcp_bhash[tcp_bhashfn(port)];
1364 spin_lock(&head->lock);
1365
1366 --- linux-2.6.12-2.3.legacy_FC3.orig/net/ipv4/udp.c
1367 +++ linux-2.6.12-2.3.legacy_FC3/net/ipv4/udp.c
1368 @@ -107,6 +107,8 @@
1369 #include <net/inet_common.h>
1370 #include <net/checksum.h>
1371 #include <net/xfrm.h>
1372 +#include <linux/sakura.h>
1373 +#include <linux/tomoyo_socket.h>
1374
1375 /*
1376 * Snmp MIB for the UDP layer
1377 @@ -145,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1378 result = sysctl_local_port_range[0] +
1379 ((result - sysctl_local_port_range[0]) &
1380 (UDP_HTABLE_SIZE - 1));
1381 + if (ccs_lport_reserved(result))
1382 + continue;
1383 goto gotit;
1384 }
1385 size = 0;
1386 @@ -161,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1387 result = sysctl_local_port_range[0]
1388 + ((result - sysctl_local_port_range[0]) &
1389 (UDP_HTABLE_SIZE - 1));
1390 + if (ccs_lport_reserved(result))
1391 + continue;
1392 if (!udp_lport_inuse(result))
1393 break;
1394 }
1395 @@ -795,7 +801,10 @@ try_again:
1396 skb = skb_recv_datagram(sk, flags, noblock, &err);
1397 if (!skb)
1398 goto out;
1399 -
1400 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1401 + if (err)
1402 + goto out;
1403 +
1404 copied = skb->len - sizeof(struct udphdr);
1405 if (copied > len) {
1406 copied = len;
1407 --- linux-2.6.12-2.3.legacy_FC3.orig/net/ipv6/raw.c
1408 +++ linux-2.6.12-2.3.legacy_FC3/net/ipv6/raw.c
1409 @@ -55,6 +55,7 @@
1410
1411 #include <linux/proc_fs.h>
1412 #include <linux/seq_file.h>
1413 +#include <linux/tomoyo_socket.h>
1414
1415 struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1416 DEFINE_RWLOCK(raw_v6_lock);
1417 @@ -385,6 +386,9 @@ static int rawv6_recvmsg(struct kiocb *i
1418 skb = skb_recv_datagram(sk, flags, noblock, &err);
1419 if (!skb)
1420 goto out;
1421 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1422 + if (err)
1423 + goto out;
1424
1425 copied = skb->len;
1426 if (copied > len) {
1427 --- linux-2.6.12-2.3.legacy_FC3.orig/net/ipv6/tcp_ipv6.c
1428 +++ linux-2.6.12-2.3.legacy_FC3/net/ipv6/tcp_ipv6.c
1429 @@ -63,6 +63,7 @@
1430
1431 #include <linux/proc_fs.h>
1432 #include <linux/seq_file.h>
1433 +#include <linux/sakura.h>
1434
1435 static void tcp_v6_send_reset(struct sk_buff *skb);
1436 static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req);
1437 @@ -148,6 +149,8 @@ static int tcp_v6_get_port(struct sock *
1438 rover = low;
1439 head = &tcp_bhash[tcp_bhashfn(rover)];
1440 spin_lock(&head->lock);
1441 + if (ccs_lport_reserved(rover))
1442 + goto next;
1443 tb_for_each(tb, node, &head->chain)
1444 if (tb->port == rover)
1445 goto next;
1446 @@ -551,6 +554,8 @@ static int tcp_v6_hash_connect(struct so
1447 local_bh_disable();
1448 for (i = 1; i <= range; i++) {
1449 port = low + (i + offset) % range;
1450 + if (ccs_lport_reserved(port))
1451 + continue;
1452 head = &tcp_bhash[tcp_bhashfn(port)];
1453 spin_lock(&head->lock);
1454
1455 --- linux-2.6.12-2.3.legacy_FC3.orig/net/ipv6/udp.c
1456 +++ linux-2.6.12-2.3.legacy_FC3/net/ipv6/udp.c
1457 @@ -57,6 +57,8 @@
1458
1459 #include <linux/proc_fs.h>
1460 #include <linux/seq_file.h>
1461 +#include <linux/sakura.h>
1462 +#include <linux/tomoyo_socket.h>
1463
1464 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6);
1465
1466 @@ -87,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1467 result = sysctl_local_port_range[0] +
1468 ((result - sysctl_local_port_range[0]) &
1469 (UDP_HTABLE_SIZE - 1));
1470 + if (ccs_lport_reserved(result))
1471 + continue;
1472 goto gotit;
1473 }
1474 size = 0;
1475 @@ -103,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1476 result = sysctl_local_port_range[0]
1477 + ((result - sysctl_local_port_range[0]) &
1478 (UDP_HTABLE_SIZE - 1));
1479 + if (ccs_lport_reserved(result))
1480 + continue;
1481 if (!udp_lport_inuse(result))
1482 break;
1483 }
1484 @@ -236,6 +242,9 @@ try_again:
1485 skb = skb_recv_datagram(sk, flags, noblock, &err);
1486 if (!skb)
1487 goto out;
1488 + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1489 + if (err)
1490 + goto out;
1491
1492 copied = skb->len - sizeof(struct udphdr);
1493 if (copied > len) {
1494 --- linux-2.6.12-2.3.legacy_FC3.orig/net/socket.c
1495 +++ linux-2.6.12-2.3.legacy_FC3/net/socket.c
1496 @@ -96,6 +96,9 @@
1497 #include <net/sock.h>
1498 #include <linux/netfilter.h>
1499
1500 +#include <linux/tomoyo.h>
1501 +#include <linux/tomoyo_socket.h>
1502 +
1503 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1504 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1505 size_t size, loff_t pos);
1506 @@ -553,9 +556,12 @@ static inline int __sock_sendmsg(struct
1507 si->size = size;
1508
1509 err = security_socket_sendmsg(sock, msg, size);
1510 + if (!err)
1511 + err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)
1512 + msg->msg_name,
1513 + msg->msg_namelen);
1514 if (err)
1515 return err;
1516 -
1517 return sock->ops->sendmsg(iocb, sock, msg, size);
1518 }
1519
1520 @@ -1111,6 +1117,8 @@ static int __sock_create(int family, int
1521 }
1522
1523 err = security_socket_create(family, type, protocol, kern);
1524 + if (!err)
1525 + err = ccs_socket_create_permission(family, type, protocol);
1526 if (err)
1527 return err;
1528
1529 @@ -1304,6 +1312,10 @@ asmlinkage long sys_bind(int fd, struct
1530 sockfd_put(sock);
1531 return err;
1532 }
1533 + err = ccs_socket_bind_permission(sock,
1534 + (struct sockaddr *)
1535 + address, addrlen);
1536 + if (!err)
1537 err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
1538 }
1539 sockfd_put(sock);
1540 @@ -1334,7 +1346,8 @@ asmlinkage long sys_listen(int fd, int b
1541 sockfd_put(sock);
1542 return err;
1543 }
1544 -
1545 + err = ccs_socket_listen_permission(sock);
1546 + if (!err)
1547 err=sock->ops->listen(sock, backlog);
1548 sockfd_put(sock);
1549 }
1550 @@ -1385,6 +1398,11 @@ asmlinkage long sys_accept(int fd, struc
1551 if (err < 0)
1552 goto out_release;
1553
1554 + if (ccs_socket_accept_permission(newsock,
1555 + (struct sockaddr *) address)) {
1556 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1557 + goto out_release;
1558 + }
1559 if (upeer_sockaddr) {
1560 if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1561 err = -ECONNABORTED;
1562 @@ -1438,9 +1456,11 @@ asmlinkage long sys_connect(int fd, stru
1563 goto out_put;
1564
1565 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1566 + if (!err)
1567 + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1568 + address, addrlen);
1569 if (err)
1570 goto out_put;
1571 -
1572 err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1573 sock->file->f_flags);
1574 out_put:
1575 --- linux-2.6.12-2.3.legacy_FC3.orig/net/unix/af_unix.c
1576 +++ linux-2.6.12-2.3.legacy_FC3/net/unix/af_unix.c
1577 @@ -117,6 +117,7 @@
1578 #include <linux/mount.h>
1579 #include <net/checksum.h>
1580 #include <linux/security.h>
1581 +#include <linux/tomoyo.h>
1582
1583 int sysctl_unix_max_dgram_qlen = 10;
1584
1585 @@ -781,6 +782,9 @@ static int unix_bind(struct socket *sock
1586 */
1587 mode = S_IFSOCK |
1588 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1589 + err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry,
1590 + nd.mnt, mode, 0);
1591 + if (!err)
1592 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1593 if (err)
1594 goto out_mknod_dput;

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