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