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