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