1 |
kumaneko |
3372 |
This is TOMOYO Linux patch for CAT-760. |
2 |
|
|
|
3 |
|
|
Source code for this patch is linux-2.6.15-cat_20080502.tgz |
4 |
|
|
--- |
5 |
|
|
arch/alpha/kernel/ptrace.c | 3 +++ |
6 |
|
|
arch/ia64/ia32/sys_ia32.c | 3 +++ |
7 |
|
|
arch/ia64/kernel/ptrace.c | 3 +++ |
8 |
|
|
arch/m32r/kernel/ptrace.c | 3 +++ |
9 |
|
|
arch/mips/kernel/ptrace32.c | 3 +++ |
10 |
|
|
arch/powerpc/kernel/ptrace32.c | 3 +++ |
11 |
|
|
arch/s390/kernel/ptrace.c | 3 +++ |
12 |
|
|
arch/sparc/kernel/ptrace.c | 5 +++++ |
13 |
|
|
arch/sparc64/kernel/ptrace.c | 5 +++++ |
14 |
|
|
arch/x86_64/ia32/ptrace32.c | 3 +++ |
15 |
|
|
fs/compat.c | 9 ++++++++- |
16 |
|
|
fs/exec.c | 12 +++++++++++- |
17 |
|
|
fs/fcntl.c | 4 ++++ |
18 |
kumaneko |
3854 |
fs/ioctl.c | 3 +++ |
19 |
|
|
fs/namei.c | 31 +++++++++++++++++++++++++++++++ |
20 |
kumaneko |
3856 |
fs/namespace.c | 9 +++++++++ |
21 |
kumaneko |
3464 |
fs/open.c | 27 ++++++++++++++++++++++++++- |
22 |
kumaneko |
3372 |
fs/proc/proc_misc.c | 1 + |
23 |
|
|
include/linux/init_task.h | 9 +++++++++ |
24 |
|
|
include/linux/sched.h | 6 ++++++ |
25 |
|
|
kernel/compat.c | 3 +++ |
26 |
|
|
kernel/kexec.c | 3 +++ |
27 |
|
|
kernel/kmod.c | 5 +++++ |
28 |
|
|
kernel/module.c | 7 +++++-- |
29 |
|
|
kernel/ptrace.c | 3 +++ |
30 |
|
|
kernel/sched.c | 3 +++ |
31 |
|
|
kernel/signal.c | 9 +++++++++ |
32 |
|
|
kernel/sys.c | 11 +++++++++++ |
33 |
|
|
kernel/sysctl.c | 11 +++++++++++ |
34 |
|
|
kernel/time.c | 7 +++++++ |
35 |
|
|
net/ipv4/inet_connection_sock.c | 3 +++ |
36 |
kumaneko |
3831 |
net/ipv4/raw.c | 12 +++++++++--- |
37 |
kumaneko |
3372 |
net/ipv4/tcp_ipv4.c | 3 +++ |
38 |
kumaneko |
3831 |
net/ipv4/udp.c | 14 +++++++++++++- |
39 |
|
|
net/ipv6/raw.c | 12 +++++++++--- |
40 |
kumaneko |
3372 |
net/ipv6/tcp_ipv6.c | 5 +++++ |
41 |
kumaneko |
3831 |
net/ipv6/udp.c | 14 +++++++++++++- |
42 |
kumaneko |
3372 |
net/socket.c | 23 ++++++++++++++++++++--- |
43 |
|
|
net/unix/af_unix.c | 4 ++++ |
44 |
|
|
security/Kconfig | 2 ++ |
45 |
|
|
security/Makefile | 3 +++ |
46 |
kumaneko |
3856 |
41 files changed, 286 insertions(+), 16 deletions(-) |
47 |
kumaneko |
3372 |
|
48 |
|
|
--- linux-2.6.15-cat.orig/arch/alpha/kernel/ptrace.c |
49 |
|
|
+++ linux-2.6.15-cat/arch/alpha/kernel/ptrace.c |
50 |
|
|
@@ -20,6 +20,7 @@ |
51 |
|
|
#include <asm/pgtable.h> |
52 |
|
|
#include <asm/system.h> |
53 |
|
|
#include <asm/fpu.h> |
54 |
|
|
+#include <linux/ccsecurity.h> |
55 |
|
|
|
56 |
|
|
#include "proto.h" |
57 |
|
|
|
58 |
|
|
@@ -261,6 +262,8 @@ do_sys_ptrace(long request, long pid, lo |
59 |
|
|
unsigned long tmp; |
60 |
|
|
size_t copied; |
61 |
|
|
long ret; |
62 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
63 |
|
|
+ return -EPERM; |
64 |
|
|
|
65 |
|
|
lock_kernel(); |
66 |
|
|
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
67 |
|
|
--- linux-2.6.15-cat.orig/arch/ia64/ia32/sys_ia32.c |
68 |
|
|
+++ linux-2.6.15-cat/arch/ia64/ia32/sys_ia32.c |
69 |
|
|
@@ -57,6 +57,7 @@ |
70 |
|
|
#include <asm/types.h> |
71 |
|
|
#include <asm/uaccess.h> |
72 |
|
|
#include <asm/unistd.h> |
73 |
|
|
+#include <linux/ccsecurity.h> |
74 |
|
|
|
75 |
|
|
#include "ia32priv.h" |
76 |
|
|
|
77 |
|
|
@@ -1758,6 +1759,8 @@ sys32_ptrace (int request, pid_t pid, un |
78 |
|
|
struct task_struct *child; |
79 |
|
|
unsigned int value, tmp; |
80 |
|
|
long i, ret; |
81 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
82 |
|
|
+ return -EPERM; |
83 |
|
|
|
84 |
|
|
lock_kernel(); |
85 |
|
|
if (request == PTRACE_TRACEME) { |
86 |
|
|
--- linux-2.6.15-cat.orig/arch/ia64/kernel/ptrace.c |
87 |
|
|
+++ linux-2.6.15-cat/arch/ia64/kernel/ptrace.c |
88 |
|
|
@@ -29,6 +29,7 @@ |
89 |
|
|
#ifdef CONFIG_PERFMON |
90 |
|
|
#include <asm/perfmon.h> |
91 |
|
|
#endif |
92 |
|
|
+#include <linux/ccsecurity.h> |
93 |
|
|
|
94 |
|
|
#include "entry.h" |
95 |
|
|
|
96 |
|
|
@@ -1418,6 +1419,8 @@ sys_ptrace (long request, pid_t pid, uns |
97 |
|
|
struct task_struct *child; |
98 |
|
|
struct switch_stack *sw; |
99 |
|
|
long ret; |
100 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
101 |
|
|
+ return -EPERM; |
102 |
|
|
|
103 |
|
|
lock_kernel(); |
104 |
|
|
ret = -EPERM; |
105 |
|
|
--- linux-2.6.15-cat.orig/arch/m32r/kernel/ptrace.c |
106 |
|
|
+++ linux-2.6.15-cat/arch/m32r/kernel/ptrace.c |
107 |
|
|
@@ -33,6 +33,7 @@ |
108 |
|
|
#include <asm/system.h> |
109 |
|
|
#include <asm/processor.h> |
110 |
|
|
#include <asm/mmu_context.h> |
111 |
|
|
+#include <linux/ccsecurity.h> |
112 |
|
|
|
113 |
|
|
/* |
114 |
|
|
* Get the address of the live pt_regs for the specified task. |
115 |
|
|
@@ -760,6 +761,8 @@ asmlinkage long sys_ptrace(long request, |
116 |
|
|
{ |
117 |
|
|
struct task_struct *child; |
118 |
|
|
int ret; |
119 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
120 |
|
|
+ return -EPERM; |
121 |
|
|
|
122 |
|
|
lock_kernel(); |
123 |
|
|
ret = -EPERM; |
124 |
|
|
--- linux-2.6.15-cat.orig/arch/mips/kernel/ptrace32.c |
125 |
|
|
+++ linux-2.6.15-cat/arch/mips/kernel/ptrace32.c |
126 |
|
|
@@ -35,6 +35,7 @@ |
127 |
|
|
#include <asm/system.h> |
128 |
|
|
#include <asm/uaccess.h> |
129 |
|
|
#include <asm/bootinfo.h> |
130 |
|
|
+#include <linux/ccsecurity.h> |
131 |
|
|
|
132 |
|
|
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
133 |
|
|
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
134 |
|
|
@@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request, |
135 |
|
|
{ |
136 |
|
|
struct task_struct *child; |
137 |
|
|
int ret; |
138 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
139 |
|
|
+ return -EPERM; |
140 |
|
|
|
141 |
|
|
#if 0 |
142 |
|
|
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
143 |
|
|
--- linux-2.6.15-cat.orig/arch/powerpc/kernel/ptrace32.c |
144 |
|
|
+++ linux-2.6.15-cat/arch/powerpc/kernel/ptrace32.c |
145 |
|
|
@@ -33,6 +33,7 @@ |
146 |
|
|
#include <asm/page.h> |
147 |
|
|
#include <asm/pgtable.h> |
148 |
|
|
#include <asm/system.h> |
149 |
|
|
+#include <linux/ccsecurity.h> |
150 |
|
|
|
151 |
|
|
#include "ptrace-common.h" |
152 |
|
|
|
153 |
|
|
@@ -46,6 +47,8 @@ long compat_sys_ptrace(int request, int |
154 |
|
|
{ |
155 |
|
|
struct task_struct *child; |
156 |
|
|
int ret = -EPERM; |
157 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
158 |
|
|
+ return -EPERM; |
159 |
|
|
|
160 |
|
|
lock_kernel(); |
161 |
|
|
if (request == PTRACE_TRACEME) { |
162 |
|
|
--- linux-2.6.15-cat.orig/arch/s390/kernel/ptrace.c |
163 |
|
|
+++ linux-2.6.15-cat/arch/s390/kernel/ptrace.c |
164 |
|
|
@@ -41,6 +41,7 @@ |
165 |
|
|
#include <asm/system.h> |
166 |
|
|
#include <asm/uaccess.h> |
167 |
|
|
#include <asm/unistd.h> |
168 |
|
|
+#include <linux/ccsecurity.h> |
169 |
|
|
|
170 |
|
|
#ifdef CONFIG_S390_SUPPORT |
171 |
|
|
#include "compat_ptrace.h" |
172 |
|
|
@@ -711,6 +712,8 @@ sys_ptrace(long request, long pid, long |
173 |
|
|
struct task_struct *child; |
174 |
|
|
int ret; |
175 |
|
|
|
176 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
177 |
|
|
+ return -EPERM; |
178 |
|
|
lock_kernel(); |
179 |
|
|
|
180 |
|
|
if (request == PTRACE_TRACEME) { |
181 |
|
|
--- linux-2.6.15-cat.orig/arch/sparc/kernel/ptrace.c |
182 |
|
|
+++ linux-2.6.15-cat/arch/sparc/kernel/ptrace.c |
183 |
|
|
@@ -23,6 +23,7 @@ |
184 |
|
|
#include <asm/pgtable.h> |
185 |
|
|
#include <asm/system.h> |
186 |
|
|
#include <asm/uaccess.h> |
187 |
|
|
+#include <linux/ccsecurity.h> |
188 |
|
|
|
189 |
|
|
#define MAGIC_CONSTANT 0x80000000 |
190 |
|
|
|
191 |
|
|
@@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs |
192 |
|
|
unsigned long addr2 = regs->u_regs[UREG_I4]; |
193 |
|
|
struct task_struct *child; |
194 |
|
|
int ret; |
195 |
|
|
+ if (ccs_ptrace_permission(request, pid)) { |
196 |
|
|
+ pt_error_return(regs, EPERM); |
197 |
|
|
+ return; |
198 |
|
|
+ } |
199 |
|
|
|
200 |
|
|
lock_kernel(); |
201 |
|
|
#ifdef DEBUG_PTRACE |
202 |
|
|
--- linux-2.6.15-cat.orig/arch/sparc64/kernel/ptrace.c |
203 |
|
|
+++ linux-2.6.15-cat/arch/sparc64/kernel/ptrace.c |
204 |
|
|
@@ -32,6 +32,7 @@ |
205 |
|
|
#include <asm/spitfire.h> |
206 |
|
|
#include <asm/page.h> |
207 |
|
|
#include <asm/cpudata.h> |
208 |
|
|
+#include <linux/ccsecurity.h> |
209 |
|
|
|
210 |
|
|
/* Returning from ptrace is a bit tricky because the syscall return |
211 |
|
|
* low level code assumes any value returned which is negative and |
212 |
|
|
@@ -173,6 +174,10 @@ asmlinkage void do_ptrace(struct pt_regs |
213 |
|
|
unsigned long addr2 = regs->u_regs[UREG_I4]; |
214 |
|
|
struct task_struct *child; |
215 |
|
|
int ret; |
216 |
|
|
+ if (ccs_ptrace_permission(request, pid)) { |
217 |
|
|
+ pt_error_return(regs, EPERM); |
218 |
|
|
+ return; |
219 |
|
|
+ } |
220 |
|
|
|
221 |
|
|
if (test_thread_flag(TIF_32BIT)) { |
222 |
|
|
addr &= 0xffffffffUL; |
223 |
|
|
--- linux-2.6.15-cat.orig/arch/x86_64/ia32/ptrace32.c |
224 |
|
|
+++ linux-2.6.15-cat/arch/x86_64/ia32/ptrace32.c |
225 |
|
|
@@ -27,6 +27,7 @@ |
226 |
|
|
#include <asm/debugreg.h> |
227 |
|
|
#include <asm/i387.h> |
228 |
|
|
#include <asm/fpu32.h> |
229 |
|
|
+#include <linux/ccsecurity.h> |
230 |
|
|
|
231 |
|
|
/* determines which flags the user has access to. */ |
232 |
|
|
/* 1 = access 0 = no access */ |
233 |
|
|
@@ -233,6 +234,8 @@ asmlinkage long sys32_ptrace(long reques |
234 |
|
|
void __user *datap = compat_ptr(data); |
235 |
|
|
int ret; |
236 |
|
|
__u32 val; |
237 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
238 |
|
|
+ return -EPERM; |
239 |
|
|
|
240 |
|
|
switch (request) { |
241 |
|
|
default: |
242 |
|
|
--- linux-2.6.15-cat.orig/fs/compat.c |
243 |
|
|
+++ linux-2.6.15-cat/fs/compat.c |
244 |
|
|
@@ -52,6 +52,7 @@ |
245 |
|
|
#include <asm/uaccess.h> |
246 |
|
|
#include <asm/mmu_context.h> |
247 |
|
|
#include <asm/ioctls.h> |
248 |
|
|
+#include <linux/ccsecurity.h> |
249 |
|
|
|
250 |
|
|
/* |
251 |
|
|
* Not all architectures have sys_utime, so implement this in terms |
252 |
|
|
@@ -353,6 +354,8 @@ asmlinkage long compat_sys_ioctl(unsigne |
253 |
|
|
|
254 |
|
|
/* RED-PEN how should LSM module know it's handling 32bit? */ |
255 |
|
|
error = security_file_ioctl(filp, cmd, arg); |
256 |
|
|
+ if (!error) |
257 |
kumaneko |
3556 |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
258 |
kumaneko |
3372 |
if (error) |
259 |
|
|
goto out_fput; |
260 |
|
|
|
261 |
|
|
@@ -377,6 +380,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
262 |
|
|
/*FALL THROUGH*/ |
263 |
|
|
|
264 |
|
|
default: |
265 |
|
|
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
266 |
|
|
+ error = -EPERM; |
267 |
|
|
+ goto out_fput; |
268 |
|
|
+ } |
269 |
|
|
if (filp->f_op && filp->f_op->compat_ioctl) { |
270 |
|
|
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
271 |
|
|
if (error != -ENOIOCTLCMD) |
272 |
|
|
@@ -1476,7 +1483,7 @@ int compat_do_execve(char * filename, |
273 |
|
|
if (retval < 0) |
274 |
|
|
goto out; |
275 |
|
|
|
276 |
|
|
- retval = search_binary_handler(bprm, regs); |
277 |
|
|
+ retval = ccs_search_binary_handler(bprm, regs); |
278 |
|
|
if (retval >= 0) { |
279 |
|
|
free_arg_pages(bprm); |
280 |
|
|
|
281 |
|
|
--- linux-2.6.15-cat.orig/fs/exec.c |
282 |
|
|
+++ linux-2.6.15-cat/fs/exec.c |
283 |
|
|
@@ -57,6 +57,8 @@ |
284 |
|
|
#include <linux/kmod.h> |
285 |
|
|
#endif |
286 |
|
|
|
287 |
|
|
+#include <linux/ccsecurity.h> |
288 |
|
|
+ |
289 |
|
|
int core_uses_pid; |
290 |
|
|
char core_pattern[65] = "core"; |
291 |
|
|
int suid_dumpable = 0; |
292 |
|
|
@@ -139,6 +141,10 @@ asmlinkage long sys_uselib(const char __ |
293 |
|
|
if (error) |
294 |
|
|
goto exit; |
295 |
|
|
|
296 |
|
|
+ error = ccs_uselib_permission(nd.dentry, nd.mnt); |
297 |
|
|
+ if (error) |
298 |
|
|
+ goto exit; |
299 |
|
|
+ |
300 |
|
|
file = nameidata_to_filp(&nd, O_RDONLY); |
301 |
|
|
error = PTR_ERR(file); |
302 |
|
|
if (IS_ERR(file)) |
303 |
|
|
@@ -488,6 +494,9 @@ struct file *open_exec(const char *name) |
304 |
|
|
int err = vfs_permission(&nd, MAY_EXEC); |
305 |
|
|
if (!err && !(inode->i_mode & 0111)) |
306 |
|
|
err = -EACCES; |
307 |
|
|
+ if (!err) |
308 |
|
|
+ err = ccs_open_exec_permission(nd.dentry, |
309 |
|
|
+ nd.mnt); |
310 |
|
|
file = ERR_PTR(err); |
311 |
|
|
if (!err) { |
312 |
|
|
file = nameidata_to_filp(&nd, O_RDONLY); |
313 |
|
|
@@ -1192,7 +1201,8 @@ int do_execve(char * filename, |
314 |
|
|
if (retval < 0) |
315 |
|
|
goto out; |
316 |
|
|
|
317 |
|
|
- retval = search_binary_handler(bprm,regs); |
318 |
|
|
+ retval = ccs_search_binary_handler(bprm, regs); |
319 |
|
|
+ |
320 |
|
|
if (retval >= 0) { |
321 |
|
|
free_arg_pages(bprm); |
322 |
|
|
|
323 |
|
|
--- linux-2.6.15-cat.orig/fs/fcntl.c |
324 |
|
|
+++ linux-2.6.15-cat/fs/fcntl.c |
325 |
|
|
@@ -21,6 +21,7 @@ |
326 |
|
|
#include <asm/poll.h> |
327 |
|
|
#include <asm/siginfo.h> |
328 |
|
|
#include <asm/uaccess.h> |
329 |
|
|
+#include <linux/ccsecurity.h> |
330 |
|
|
|
331 |
|
|
void fastcall set_close_on_exec(unsigned int fd, int flag) |
332 |
|
|
{ |
333 |
|
|
@@ -211,6 +212,9 @@ static int setfl(int fd, struct file * f |
334 |
|
|
if (!(arg & O_APPEND) && IS_APPEND(inode)) |
335 |
|
|
return -EPERM; |
336 |
|
|
|
337 |
|
|
+ if (!(arg & O_APPEND) && ccs_rewrite_permission(filp)) |
338 |
|
|
+ return -EPERM; |
339 |
|
|
+ |
340 |
|
|
/* O_NOATIME can only be set by the owner or superuser */ |
341 |
|
|
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
342 |
|
|
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
343 |
|
|
--- linux-2.6.15-cat.orig/fs/ioctl.c |
344 |
|
|
+++ linux-2.6.15-cat/fs/ioctl.c |
345 |
|
|
@@ -15,6 +15,7 @@ |
346 |
|
|
|
347 |
|
|
#include <asm/uaccess.h> |
348 |
|
|
#include <asm/ioctls.h> |
349 |
|
|
+#include <linux/ccsecurity.h> |
350 |
|
|
|
351 |
|
|
static long do_ioctl(struct file *filp, unsigned int cmd, |
352 |
|
|
unsigned long arg) |
353 |
kumaneko |
3854 |
@@ -167,6 +168,8 @@ asmlinkage long sys_ioctl(unsigned int f |
354 |
kumaneko |
3372 |
goto out; |
355 |
|
|
|
356 |
|
|
error = security_file_ioctl(filp, cmd, arg); |
357 |
|
|
+ if (!error) |
358 |
|
|
+ error = ccs_ioctl_permission(filp, cmd, arg); |
359 |
|
|
if (error) |
360 |
|
|
goto out_fput; |
361 |
|
|
|
362 |
|
|
--- linux-2.6.15-cat.orig/fs/namei.c |
363 |
|
|
+++ linux-2.6.15-cat/fs/namei.c |
364 |
|
|
@@ -34,6 +34,8 @@ |
365 |
|
|
|
366 |
|
|
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
367 |
|
|
|
368 |
|
|
+#include <linux/ccsecurity.h> |
369 |
|
|
+ |
370 |
|
|
/* [Feb-1997 T. Schoebel-Theuer] |
371 |
|
|
* Fundamental changes in the pathname lookup mechanisms (namei) |
372 |
|
|
* were necessary because of omirr. The reason is that omirr needs |
373 |
|
|
@@ -1472,6 +1474,11 @@ int may_open(struct nameidata *nd, int a |
374 |
|
|
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
375 |
|
|
return -EPERM; |
376 |
|
|
|
377 |
|
|
+ /* includes O_APPEND and O_TRUNC checks */ |
378 |
|
|
+ error = ccs_open_permission(dentry, nd->mnt, flag); |
379 |
|
|
+ if (error) |
380 |
|
|
+ return error; |
381 |
|
|
+ |
382 |
|
|
/* |
383 |
|
|
* Ensure there are no outstanding leases on the file. |
384 |
|
|
*/ |
385 |
kumaneko |
3854 |
@@ -1578,6 +1585,9 @@ do_last: |
386 |
kumaneko |
3372 |
if (!path.dentry->d_inode) { |
387 |
|
|
if (!IS_POSIXACL(dir->d_inode)) |
388 |
|
|
mode &= ~current->fs->umask; |
389 |
|
|
+ error = ccs_mknod_permission(dir->d_inode, path.dentry, |
390 |
|
|
+ nd->mnt, mode, 0); |
391 |
|
|
+ if (!error) |
392 |
|
|
error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
393 |
|
|
up(&dir->d_inode->i_sem); |
394 |
|
|
dput(nd->dentry); |
395 |
kumaneko |
3854 |
@@ -1765,6 +1775,9 @@ asmlinkage long sys_mknod(const char __u |
396 |
kumaneko |
3372 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
397 |
|
|
mode &= ~current->fs->umask; |
398 |
|
|
if (!IS_ERR(dentry)) { |
399 |
|
|
+ error = ccs_mknod_permission(nd.dentry->d_inode, dentry, |
400 |
|
|
+ nd.mnt, mode, dev); |
401 |
|
|
+ if (!error) |
402 |
|
|
switch (mode & S_IFMT) { |
403 |
|
|
case 0: case S_IFREG: |
404 |
|
|
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
405 |
kumaneko |
3854 |
@@ -1833,6 +1846,9 @@ asmlinkage long sys_mkdir(const char __u |
406 |
kumaneko |
3372 |
if (!IS_ERR(dentry)) { |
407 |
|
|
if (!IS_POSIXACL(nd.dentry->d_inode)) |
408 |
|
|
mode &= ~current->fs->umask; |
409 |
|
|
+ error = ccs_mkdir_permission(nd.dentry->d_inode, |
410 |
|
|
+ dentry, nd.mnt, mode); |
411 |
|
|
+ if (!error) |
412 |
|
|
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
413 |
|
|
dput(dentry); |
414 |
|
|
} |
415 |
kumaneko |
3854 |
@@ -1936,6 +1952,9 @@ asmlinkage long sys_rmdir(const char __u |
416 |
kumaneko |
3372 |
dentry = lookup_hash(&nd); |
417 |
|
|
error = PTR_ERR(dentry); |
418 |
|
|
if (!IS_ERR(dentry)) { |
419 |
|
|
+ error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, |
420 |
|
|
+ nd.mnt); |
421 |
|
|
+ if (!error) |
422 |
|
|
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
423 |
|
|
dput(dentry); |
424 |
|
|
} |
425 |
kumaneko |
3854 |
@@ -2011,6 +2030,9 @@ asmlinkage long sys_unlink(const char __ |
426 |
kumaneko |
3372 |
inode = dentry->d_inode; |
427 |
|
|
if (inode) |
428 |
|
|
atomic_inc(&inode->i_count); |
429 |
|
|
+ error = ccs_unlink_permission(nd.dentry->d_inode, dentry, |
430 |
|
|
+ nd.mnt); |
431 |
|
|
+ if (!error) |
432 |
|
|
error = vfs_unlink(nd.dentry->d_inode, dentry); |
433 |
|
|
exit2: |
434 |
|
|
dput(dentry); |
435 |
kumaneko |
3854 |
@@ -2072,6 +2094,9 @@ asmlinkage long sys_symlink(const char _ |
436 |
kumaneko |
3372 |
dentry = lookup_create(&nd, 0); |
437 |
|
|
error = PTR_ERR(dentry); |
438 |
|
|
if (!IS_ERR(dentry)) { |
439 |
|
|
+ error = ccs_symlink_permission(nd.dentry->d_inode, |
440 |
|
|
+ dentry, nd.mnt, from); |
441 |
|
|
+ if (!error) |
442 |
|
|
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
443 |
|
|
dput(dentry); |
444 |
|
|
} |
445 |
kumaneko |
3854 |
@@ -2154,6 +2179,9 @@ asmlinkage long sys_link(const char __us |
446 |
kumaneko |
3372 |
new_dentry = lookup_create(&nd, 0); |
447 |
|
|
error = PTR_ERR(new_dentry); |
448 |
|
|
if (!IS_ERR(new_dentry)) { |
449 |
|
|
+ error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode, |
450 |
|
|
+ new_dentry, nd.mnt); |
451 |
|
|
+ if (!error) |
452 |
|
|
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
453 |
|
|
dput(new_dentry); |
454 |
|
|
} |
455 |
kumaneko |
3854 |
@@ -2374,6 +2402,9 @@ static inline int do_rename(const char * |
456 |
kumaneko |
3372 |
if (new_dentry == trap) |
457 |
|
|
goto exit5; |
458 |
|
|
|
459 |
|
|
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
460 |
|
|
+ new_dir->d_inode, new_dentry, newnd.mnt); |
461 |
|
|
+ if (!error) |
462 |
|
|
error = vfs_rename(old_dir->d_inode, old_dentry, |
463 |
|
|
new_dir->d_inode, new_dentry); |
464 |
|
|
exit5: |
465 |
|
|
--- linux-2.6.15-cat.orig/fs/namespace.c |
466 |
|
|
+++ linux-2.6.15-cat/fs/namespace.c |
467 |
|
|
@@ -25,6 +25,7 @@ |
468 |
|
|
#include <asm/uaccess.h> |
469 |
|
|
#include <asm/unistd.h> |
470 |
|
|
#include "pnode.h" |
471 |
|
|
+#include <linux/ccsecurity.h> |
472 |
|
|
|
473 |
|
|
extern int __init init_rootfs(void); |
474 |
|
|
|
475 |
|
|
@@ -501,6 +502,8 @@ static int do_umount(struct vfsmount *mn |
476 |
|
|
LIST_HEAD(umount_list); |
477 |
|
|
|
478 |
|
|
retval = security_sb_umount(mnt, flags); |
479 |
|
|
+ if (!retval) |
480 |
|
|
+ retval = ccs_umount_permission(mnt, flags); |
481 |
|
|
if (retval) |
482 |
|
|
return retval; |
483 |
|
|
|
484 |
kumaneko |
3856 |
@@ -1261,6 +1264,7 @@ int copy_mount_options(const void __user |
485 |
kumaneko |
3372 |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
486 |
|
|
unsigned long flags, void *data_page) |
487 |
|
|
{ |
488 |
|
|
+ const unsigned long original_flags = flags; |
489 |
|
|
struct nameidata nd; |
490 |
|
|
int retval = 0; |
491 |
|
|
int mnt_flags = 0; |
492 |
kumaneko |
3856 |
@@ -1294,6 +1298,9 @@ long do_mount(char *dev_name, char *dir_ |
493 |
kumaneko |
3372 |
return retval; |
494 |
|
|
|
495 |
|
|
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
496 |
|
|
+ if (!retval) |
497 |
kumaneko |
3584 |
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
498 |
|
|
+ original_flags, data_page); |
499 |
kumaneko |
3372 |
if (retval) |
500 |
|
|
goto dput_out; |
501 |
|
|
|
502 |
kumaneko |
3856 |
@@ -1559,6 +1566,8 @@ asmlinkage long sys_pivot_root(const cha |
503 |
kumaneko |
3372 |
goto out1; |
504 |
|
|
|
505 |
|
|
error = security_sb_pivotroot(&old_nd, &new_nd); |
506 |
|
|
+ if (!error) |
507 |
kumaneko |
3584 |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
508 |
kumaneko |
3372 |
if (error) { |
509 |
|
|
path_release(&old_nd); |
510 |
|
|
goto out1; |
511 |
|
|
--- linux-2.6.15-cat.orig/fs/open.c |
512 |
|
|
+++ linux-2.6.15-cat/fs/open.c |
513 |
|
|
@@ -28,6 +28,8 @@ |
514 |
|
|
|
515 |
|
|
#include <asm/unistd.h> |
516 |
|
|
|
517 |
|
|
+#include <linux/ccsecurity.h> |
518 |
|
|
+ |
519 |
|
|
int vfs_statfs(struct super_block *sb, struct kstatfs *buf) |
520 |
|
|
{ |
521 |
|
|
int retval = -ENODEV; |
522 |
|
|
@@ -263,6 +265,8 @@ static inline long do_sys_truncate(const |
523 |
|
|
if (error) |
524 |
|
|
goto dput_and_out; |
525 |
|
|
|
526 |
kumaneko |
3854 |
+ error = ccs_truncate_permission(nd.dentry, nd.mnt); |
527 |
kumaneko |
3372 |
+ if (!error) |
528 |
|
|
error = locks_verify_truncate(inode, NULL, length); |
529 |
|
|
if (!error) { |
530 |
|
|
DQUOT_INIT(inode); |
531 |
|
|
@@ -315,7 +319,9 @@ static inline long do_sys_ftruncate(unsi |
532 |
|
|
error = -EPERM; |
533 |
|
|
if (IS_APPEND(inode)) |
534 |
|
|
goto out_putf; |
535 |
|
|
- |
536 |
kumaneko |
3854 |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt); |
537 |
kumaneko |
3372 |
+ if (error) |
538 |
|
|
+ goto out_putf; |
539 |
|
|
error = locks_verify_truncate(inode, file, length); |
540 |
|
|
if (!error) |
541 |
|
|
error = do_truncate(dentry, length, file); |
542 |
kumaneko |
3464 |
@@ -588,6 +594,8 @@ asmlinkage long sys_chroot(const char __ |
543 |
kumaneko |
3372 |
error = -EPERM; |
544 |
|
|
if (!capable(CAP_SYS_CHROOT)) |
545 |
|
|
goto dput_and_out; |
546 |
kumaneko |
3584 |
+ if (ccs_chroot_permission(&nd)) |
547 |
kumaneko |
3372 |
+ goto dput_and_out; |
548 |
|
|
|
549 |
|
|
set_fs_root(current->fs, nd.mnt, nd.dentry); |
550 |
|
|
set_fs_altroot(); |
551 |
kumaneko |
3464 |
@@ -619,6 +627,9 @@ asmlinkage long sys_fchmod(unsigned int |
552 |
kumaneko |
3372 |
err = -EPERM; |
553 |
|
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
554 |
|
|
goto out_putf; |
555 |
|
|
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
556 |
|
|
+ if (err) |
557 |
|
|
+ goto out_putf; |
558 |
|
|
down(&inode->i_sem); |
559 |
|
|
if (mode == (mode_t) -1) |
560 |
|
|
mode = inode->i_mode; |
561 |
kumaneko |
3464 |
@@ -652,6 +663,9 @@ asmlinkage long sys_chmod(const char __u |
562 |
kumaneko |
3372 |
error = -EPERM; |
563 |
|
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
564 |
|
|
goto dput_and_out; |
565 |
|
|
+ error = ccs_chmod_permission(nd.dentry, nd.mnt, mode); |
566 |
|
|
+ if (error) |
567 |
|
|
+ goto dput_and_out; |
568 |
|
|
|
569 |
|
|
down(&inode->i_sem); |
570 |
|
|
if (mode == (mode_t) -1) |
571 |
kumaneko |
3464 |
@@ -709,6 +723,8 @@ asmlinkage long sys_chown(const char __u |
572 |
kumaneko |
3372 |
|
573 |
|
|
error = user_path_walk(filename, &nd); |
574 |
|
|
if (!error) { |
575 |
|
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
576 |
|
|
+ if (!error) |
577 |
|
|
error = chown_common(nd.dentry, user, group); |
578 |
|
|
path_release(&nd); |
579 |
|
|
} |
580 |
kumaneko |
3464 |
@@ -722,6 +738,8 @@ asmlinkage long sys_lchown(const char __ |
581 |
kumaneko |
3372 |
|
582 |
|
|
error = user_path_walk_link(filename, &nd); |
583 |
|
|
if (!error) { |
584 |
|
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
585 |
|
|
+ if (!error) |
586 |
|
|
error = chown_common(nd.dentry, user, group); |
587 |
|
|
path_release(&nd); |
588 |
|
|
} |
589 |
kumaneko |
3464 |
@@ -736,6 +754,9 @@ asmlinkage long sys_fchown(unsigned int |
590 |
kumaneko |
3372 |
|
591 |
|
|
file = fget(fd); |
592 |
|
|
if (file) { |
593 |
|
|
+ error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt, |
594 |
|
|
+ user, group); |
595 |
|
|
+ if (!error) |
596 |
|
|
error = chown_common(file->f_dentry, user, group); |
597 |
|
|
fput(file); |
598 |
|
|
} |
599 |
kumaneko |
3464 |
@@ -827,7 +848,9 @@ struct file *filp_open(const char * file |
600 |
kumaneko |
3372 |
if ((namei_flags+1) & O_ACCMODE) |
601 |
|
|
namei_flags++; |
602 |
|
|
|
603 |
|
|
+ ccs_save_open_mode(flags); |
604 |
|
|
error = open_namei(filename, namei_flags, mode, &nd); |
605 |
|
|
+ ccs_clear_open_mode(); |
606 |
|
|
if (!error) |
607 |
|
|
return nameidata_to_filp(&nd, flags); |
608 |
|
|
|
609 |
kumaneko |
3464 |
@@ -1119,6 +1142,8 @@ EXPORT_SYMBOL(sys_close); |
610 |
kumaneko |
3372 |
*/ |
611 |
|
|
asmlinkage long sys_vhangup(void) |
612 |
|
|
{ |
613 |
|
|
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
614 |
|
|
+ return -EPERM; |
615 |
|
|
if (capable(CAP_SYS_TTY_CONFIG)) { |
616 |
|
|
tty_vhangup(current->signal->tty); |
617 |
|
|
return 0; |
618 |
|
|
--- linux-2.6.15-cat.orig/fs/proc/proc_misc.c |
619 |
|
|
+++ linux-2.6.15-cat/fs/proc/proc_misc.c |
620 |
|
|
@@ -629,4 +629,5 @@ void __init proc_misc_init(void) |
621 |
|
|
if (entry) |
622 |
|
|
entry->proc_fops = &proc_sysrq_trigger_operations; |
623 |
|
|
#endif |
624 |
kumaneko |
3854 |
+ printk(KERN_INFO "Hook version: 2.6.15-cat_20080502 2010/07/26\n"); |
625 |
kumaneko |
3372 |
} |
626 |
|
|
--- linux-2.6.15-cat.orig/include/linux/init_task.h |
627 |
|
|
+++ linux-2.6.15-cat/include/linux/init_task.h |
628 |
|
|
@@ -72,6 +72,14 @@ |
629 |
|
|
|
630 |
|
|
extern struct group_info init_groups; |
631 |
|
|
|
632 |
|
|
+#ifdef CONFIG_CCSECURITY |
633 |
|
|
+#define INIT_CCSECURITY \ |
634 |
|
|
+ .ccs_domain_info = NULL, \ |
635 |
|
|
+ .ccs_flags = 0, |
636 |
|
|
+#else |
637 |
|
|
+#define INIT_CCSECURITY |
638 |
|
|
+#endif |
639 |
|
|
+ |
640 |
|
|
/* |
641 |
|
|
* INIT_TASK is used to set up the first task table, touch at |
642 |
|
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
643 |
|
|
@@ -121,6 +129,7 @@ extern struct group_info init_groups; |
644 |
|
|
.journal_info = NULL, \ |
645 |
|
|
.cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
646 |
|
|
.fs_excl = ATOMIC_INIT(0), \ |
647 |
|
|
+ INIT_CCSECURITY \ |
648 |
|
|
} |
649 |
|
|
|
650 |
|
|
|
651 |
|
|
--- linux-2.6.15-cat.orig/include/linux/sched.h |
652 |
|
|
+++ linux-2.6.15-cat/include/linux/sched.h |
653 |
|
|
@@ -165,6 +165,8 @@ struct sched_param { |
654 |
|
|
|
655 |
|
|
#ifdef __KERNEL__ |
656 |
|
|
|
657 |
|
|
+struct ccs_domain_info; |
658 |
|
|
+ |
659 |
|
|
#include <linux/spinlock.h> |
660 |
|
|
|
661 |
|
|
/* |
662 |
|
|
@@ -857,6 +859,10 @@ struct task_struct { |
663 |
|
|
int cpuset_mems_generation; |
664 |
|
|
#endif |
665 |
|
|
atomic_t fs_excl; /* holding fs exclusive resources */ |
666 |
|
|
+#ifdef CONFIG_CCSECURITY |
667 |
|
|
+ struct ccs_domain_info *ccs_domain_info; |
668 |
|
|
+ u32 ccs_flags; |
669 |
|
|
+#endif |
670 |
|
|
}; |
671 |
|
|
|
672 |
|
|
static inline pid_t process_group(struct task_struct *tsk) |
673 |
|
|
--- linux-2.6.15-cat.orig/kernel/compat.c |
674 |
|
|
+++ linux-2.6.15-cat/kernel/compat.c |
675 |
|
|
@@ -24,6 +24,7 @@ |
676 |
|
|
|
677 |
|
|
#include <asm/uaccess.h> |
678 |
|
|
#include <asm/bug.h> |
679 |
|
|
+#include <linux/ccsecurity.h> |
680 |
|
|
|
681 |
|
|
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
682 |
|
|
{ |
683 |
|
|
@@ -849,6 +850,8 @@ asmlinkage long compat_sys_stime(compat_ |
684 |
|
|
err = security_settime(&tv, NULL); |
685 |
|
|
if (err) |
686 |
|
|
return err; |
687 |
|
|
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
688 |
|
|
+ return -EPERM; |
689 |
|
|
|
690 |
|
|
do_settimeofday(&tv); |
691 |
|
|
return 0; |
692 |
|
|
--- linux-2.6.15-cat.orig/kernel/kexec.c |
693 |
|
|
+++ linux-2.6.15-cat/kernel/kexec.c |
694 |
|
|
@@ -25,6 +25,7 @@ |
695 |
|
|
#include <asm/io.h> |
696 |
|
|
#include <asm/system.h> |
697 |
|
|
#include <asm/semaphore.h> |
698 |
|
|
+#include <linux/ccsecurity.h> |
699 |
|
|
|
700 |
|
|
/* Location of the reserved area for the crash kernel */ |
701 |
|
|
struct resource crashk_res = { |
702 |
|
|
@@ -918,6 +919,8 @@ asmlinkage long sys_kexec_load(unsigned |
703 |
|
|
/* We only trust the superuser with rebooting the system. */ |
704 |
|
|
if (!capable(CAP_SYS_BOOT)) |
705 |
|
|
return -EPERM; |
706 |
|
|
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
707 |
|
|
+ return -EPERM; |
708 |
|
|
|
709 |
|
|
/* |
710 |
|
|
* Verify we have a legal set of flags |
711 |
|
|
--- linux-2.6.15-cat.orig/kernel/kmod.c |
712 |
|
|
+++ linux-2.6.15-cat/kernel/kmod.c |
713 |
|
|
@@ -149,6 +149,11 @@ static int ____call_usermodehelper(void |
714 |
|
|
/* We can run anywhere, unlike our parent keventd(). */ |
715 |
|
|
set_cpus_allowed(current, CPU_MASK_ALL); |
716 |
|
|
|
717 |
|
|
+#ifdef CONFIG_CCSECURITY |
718 |
|
|
+ current->ccs_domain_info = NULL; |
719 |
|
|
+ current->ccs_flags = 0; |
720 |
|
|
+#endif |
721 |
|
|
+ |
722 |
|
|
retval = -EPERM; |
723 |
|
|
if (current->fs->root) |
724 |
|
|
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
725 |
|
|
--- linux-2.6.15-cat.orig/kernel/module.c |
726 |
|
|
+++ linux-2.6.15-cat/kernel/module.c |
727 |
|
|
@@ -41,6 +41,7 @@ |
728 |
|
|
#include <asm/uaccess.h> |
729 |
|
|
#include <asm/semaphore.h> |
730 |
|
|
#include <asm/cacheflush.h> |
731 |
|
|
+#include <linux/ccsecurity.h> |
732 |
|
|
|
733 |
|
|
#if 0 |
734 |
|
|
#define DEBUGP printk |
735 |
|
|
@@ -577,7 +578,8 @@ sys_delete_module(const char __user *nam |
736 |
|
|
|
737 |
|
|
if (!capable(CAP_SYS_MODULE)) |
738 |
|
|
return -EPERM; |
739 |
|
|
- |
740 |
|
|
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
741 |
|
|
+ return -EPERM; |
742 |
|
|
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
743 |
|
|
return -EFAULT; |
744 |
|
|
name[MODULE_NAME_LEN-1] = '\0'; |
745 |
|
|
@@ -1886,7 +1888,8 @@ sys_init_module(void __user *umod, |
746 |
|
|
/* Must have permission */ |
747 |
|
|
if (!capable(CAP_SYS_MODULE)) |
748 |
|
|
return -EPERM; |
749 |
|
|
- |
750 |
|
|
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
751 |
|
|
+ return -EPERM; |
752 |
|
|
/* Only one module load at a time, please */ |
753 |
|
|
if (down_interruptible(&module_mutex) != 0) |
754 |
|
|
return -EINTR; |
755 |
|
|
--- linux-2.6.15-cat.orig/kernel/ptrace.c |
756 |
|
|
+++ linux-2.6.15-cat/kernel/ptrace.c |
757 |
|
|
@@ -20,6 +20,7 @@ |
758 |
|
|
|
759 |
|
|
#include <asm/pgtable.h> |
760 |
|
|
#include <asm/uaccess.h> |
761 |
|
|
+#include <linux/ccsecurity.h> |
762 |
|
|
|
763 |
|
|
/* |
764 |
|
|
* ptrace a task: make the debugger its new parent and |
765 |
|
|
@@ -464,6 +465,8 @@ asmlinkage long sys_ptrace(long request, |
766 |
|
|
/* |
767 |
|
|
* This lock_kernel fixes a subtle race with suid exec |
768 |
|
|
*/ |
769 |
|
|
+ if (ccs_ptrace_permission(request, pid)) |
770 |
|
|
+ return -EPERM; |
771 |
|
|
lock_kernel(); |
772 |
|
|
ret = ptrace_get_task_struct(request, pid, &child); |
773 |
|
|
if (!child) |
774 |
|
|
--- linux-2.6.15-cat.orig/kernel/sched.c |
775 |
|
|
+++ linux-2.6.15-cat/kernel/sched.c |
776 |
|
|
@@ -50,6 +50,7 @@ |
777 |
|
|
#include <asm/tlb.h> |
778 |
|
|
|
779 |
|
|
#include <asm/unistd.h> |
780 |
|
|
+#include <linux/ccsecurity.h> |
781 |
|
|
|
782 |
|
|
/* |
783 |
|
|
* Convert user-nice values [ -20 ... 0 ... 19 ] |
784 |
|
|
@@ -3603,6 +3604,8 @@ asmlinkage long sys_nice(int increment) |
785 |
|
|
{ |
786 |
|
|
int retval; |
787 |
|
|
long nice; |
788 |
|
|
+ if (!ccs_capable(CCS_SYS_NICE)) |
789 |
|
|
+ return -EPERM; |
790 |
|
|
|
791 |
|
|
/* |
792 |
|
|
* Setpriority might change our priority at the same moment. |
793 |
|
|
--- linux-2.6.15-cat.orig/kernel/signal.c |
794 |
|
|
+++ linux-2.6.15-cat/kernel/signal.c |
795 |
|
|
@@ -29,6 +29,7 @@ |
796 |
|
|
#include <asm/uaccess.h> |
797 |
|
|
#include <asm/unistd.h> |
798 |
|
|
#include <asm/siginfo.h> |
799 |
|
|
+#include <linux/ccsecurity.h> |
800 |
|
|
|
801 |
|
|
/* |
802 |
|
|
* SLAB caches for signal bits. |
803 |
|
|
@@ -2241,6 +2242,8 @@ asmlinkage long |
804 |
|
|
sys_kill(int pid, int sig) |
805 |
|
|
{ |
806 |
|
|
struct siginfo info; |
807 |
|
|
+ if (ccs_kill_permission(pid, sig)) |
808 |
|
|
+ return -EPERM; |
809 |
|
|
|
810 |
|
|
info.si_signo = sig; |
811 |
|
|
info.si_errno = 0; |
812 |
|
|
@@ -2299,6 +2302,8 @@ asmlinkage long sys_tgkill(int tgid, int |
813 |
|
|
/* This is only valid for single tasks */ |
814 |
|
|
if (pid <= 0 || tgid <= 0) |
815 |
|
|
return -EINVAL; |
816 |
|
|
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
817 |
|
|
+ return -EPERM; |
818 |
|
|
|
819 |
|
|
return do_tkill(tgid, pid, sig); |
820 |
|
|
} |
821 |
|
|
@@ -2312,6 +2317,8 @@ sys_tkill(int pid, int sig) |
822 |
|
|
/* This is only valid for single tasks */ |
823 |
|
|
if (pid <= 0) |
824 |
|
|
return -EINVAL; |
825 |
|
|
+ if (ccs_tkill_permission(pid, sig)) |
826 |
|
|
+ return -EPERM; |
827 |
|
|
|
828 |
|
|
return do_tkill(0, pid, sig); |
829 |
|
|
} |
830 |
|
|
@@ -2329,6 +2336,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
831 |
|
|
if (info.si_code >= 0) |
832 |
|
|
return -EPERM; |
833 |
|
|
info.si_signo = sig; |
834 |
|
|
+ if (ccs_sigqueue_permission(pid, sig)) |
835 |
|
|
+ return -EPERM; |
836 |
|
|
|
837 |
|
|
/* POSIX.1b doesn't mention process groups. */ |
838 |
|
|
return kill_proc_info(sig, &info, pid); |
839 |
|
|
--- linux-2.6.15-cat.orig/kernel/sys.c |
840 |
|
|
+++ linux-2.6.15-cat/kernel/sys.c |
841 |
|
|
@@ -37,6 +37,7 @@ |
842 |
|
|
#include <asm/uaccess.h> |
843 |
|
|
#include <asm/io.h> |
844 |
|
|
#include <asm/unistd.h> |
845 |
|
|
+#include <linux/ccsecurity.h> |
846 |
|
|
|
847 |
|
|
#ifndef SET_UNALIGN_CTL |
848 |
|
|
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
849 |
|
|
@@ -256,6 +257,10 @@ asmlinkage long sys_setpriority(int whic |
850 |
|
|
|
851 |
|
|
if (which > 2 || which < 0) |
852 |
|
|
goto out; |
853 |
|
|
+ if (!ccs_capable(CCS_SYS_NICE)) { |
854 |
|
|
+ error = -EPERM; |
855 |
|
|
+ goto out; |
856 |
|
|
+ } |
857 |
|
|
|
858 |
|
|
/* normalize: avoid signed division (rounding problems) */ |
859 |
|
|
error = -ESRCH; |
860 |
|
|
@@ -488,6 +493,8 @@ asmlinkage long sys_reboot(int magic1, i |
861 |
|
|
magic2 != LINUX_REBOOT_MAGIC2B && |
862 |
|
|
magic2 != LINUX_REBOOT_MAGIC2C)) |
863 |
|
|
return -EINVAL; |
864 |
|
|
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
865 |
|
|
+ return -EPERM; |
866 |
|
|
|
867 |
|
|
lock_kernel(); |
868 |
|
|
switch (cmd) { |
869 |
|
|
@@ -1520,6 +1527,8 @@ asmlinkage long sys_sethostname(char __u |
870 |
|
|
return -EPERM; |
871 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
872 |
|
|
return -EINVAL; |
873 |
|
|
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
874 |
|
|
+ return -EPERM; |
875 |
|
|
down_write(&uts_sem); |
876 |
|
|
errno = -EFAULT; |
877 |
|
|
if (!copy_from_user(tmp, name, len)) { |
878 |
|
|
@@ -1565,6 +1574,8 @@ asmlinkage long sys_setdomainname(char _ |
879 |
|
|
return -EPERM; |
880 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
881 |
|
|
return -EINVAL; |
882 |
|
|
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
883 |
|
|
+ return -EPERM; |
884 |
|
|
|
885 |
|
|
down_write(&uts_sem); |
886 |
|
|
errno = -EFAULT; |
887 |
|
|
--- linux-2.6.15-cat.orig/kernel/sysctl.c |
888 |
|
|
+++ linux-2.6.15-cat/kernel/sysctl.c |
889 |
|
|
@@ -45,6 +45,7 @@ |
890 |
|
|
|
891 |
|
|
#include <asm/uaccess.h> |
892 |
|
|
#include <asm/processor.h> |
893 |
|
|
+#include <linux/ccsecurity.h> |
894 |
|
|
|
895 |
|
|
#ifdef CONFIG_ROOT_NFS |
896 |
|
|
#include <linux/nfs_fs.h> |
897 |
|
|
@@ -1066,6 +1067,9 @@ int do_sysctl(int __user *name, int nlen |
898 |
|
|
|
899 |
|
|
spin_unlock(&sysctl_lock); |
900 |
|
|
|
901 |
|
|
+ error = ccs_parse_table(name, nlen, oldval, newval, |
902 |
|
|
+ head->ctl_table); |
903 |
|
|
+ if (!error) |
904 |
|
|
error = parse_table(name, nlen, oldval, oldlenp, |
905 |
|
|
newval, newlen, head->ctl_table, |
906 |
|
|
&context); |
907 |
|
|
@@ -1138,6 +1142,13 @@ repeat: |
908 |
|
|
if (ctl_perm(table, 001)) |
909 |
|
|
return -EPERM; |
910 |
|
|
if (table->strategy) { |
911 |
|
|
+ int op = 0; |
912 |
|
|
+ if (oldval) |
913 |
|
|
+ op |= 004; |
914 |
|
|
+ if (newval) |
915 |
|
|
+ op |= 002; |
916 |
|
|
+ if (ctl_perm(table, op)) |
917 |
|
|
+ return -EPERM; |
918 |
|
|
error = table->strategy( |
919 |
|
|
table, name, nlen, |
920 |
|
|
oldval, oldlenp, |
921 |
|
|
--- linux-2.6.15-cat.orig/kernel/time.c |
922 |
|
|
+++ linux-2.6.15-cat/kernel/time.c |
923 |
|
|
@@ -38,6 +38,7 @@ |
924 |
|
|
|
925 |
|
|
#include <asm/uaccess.h> |
926 |
|
|
#include <asm/unistd.h> |
927 |
|
|
+#include <linux/ccsecurity.h> |
928 |
|
|
|
929 |
|
|
/* |
930 |
|
|
* The timezone where the local system is located. Used as a default by some |
931 |
|
|
@@ -90,6 +91,8 @@ asmlinkage long sys_stime(time_t __user |
932 |
|
|
err = security_settime(&tv, NULL); |
933 |
|
|
if (err) |
934 |
|
|
return err; |
935 |
|
|
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
936 |
|
|
+ return -EPERM; |
937 |
|
|
|
938 |
|
|
do_settimeofday(&tv); |
939 |
|
|
return 0; |
940 |
|
|
@@ -157,6 +160,8 @@ int do_sys_settimeofday(struct timespec |
941 |
|
|
error = security_settime(tv, tz); |
942 |
|
|
if (error) |
943 |
|
|
return error; |
944 |
|
|
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
945 |
|
|
+ return -EPERM; |
946 |
|
|
|
947 |
|
|
if (tz) { |
948 |
|
|
/* SMP safe, global irq locking makes it work. */ |
949 |
|
|
@@ -235,6 +240,8 @@ int do_adjtimex(struct timex *txc) |
950 |
|
|
/* In order to modify anything, you gotta be super-user! */ |
951 |
|
|
if (txc->modes && !capable(CAP_SYS_TIME)) |
952 |
|
|
return -EPERM; |
953 |
|
|
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
954 |
|
|
+ return -EPERM; |
955 |
|
|
|
956 |
|
|
/* Now we validate the data before disabling interrupts */ |
957 |
|
|
|
958 |
|
|
--- linux-2.6.15-cat.orig/net/ipv4/inet_connection_sock.c |
959 |
|
|
+++ linux-2.6.15-cat/net/ipv4/inet_connection_sock.c |
960 |
|
|
@@ -24,6 +24,7 @@ |
961 |
|
|
#include <net/route.h> |
962 |
|
|
#include <net/tcp_states.h> |
963 |
|
|
#include <net/xfrm.h> |
964 |
|
|
+#include <linux/ccsecurity.h> |
965 |
|
|
|
966 |
|
|
#ifdef INET_CSK_DEBUG |
967 |
|
|
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
968 |
|
|
@@ -83,6 +84,8 @@ int inet_csk_get_port(struct inet_hashin |
969 |
|
|
do { |
970 |
|
|
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
971 |
|
|
spin_lock(&head->lock); |
972 |
|
|
+ if (ccs_lport_reserved(rover)) |
973 |
|
|
+ goto next; |
974 |
|
|
inet_bind_bucket_for_each(tb, node, &head->chain) |
975 |
|
|
if (tb->port == rover) |
976 |
|
|
goto next; |
977 |
|
|
--- linux-2.6.15-cat.orig/net/ipv4/raw.c |
978 |
|
|
+++ linux-2.6.15-cat/net/ipv4/raw.c |
979 |
|
|
@@ -79,6 +79,7 @@ |
980 |
|
|
#include <linux/seq_file.h> |
981 |
|
|
#include <linux/netfilter.h> |
982 |
|
|
#include <linux/netfilter_ipv4.h> |
983 |
|
|
+#include <linux/ccsecurity.h> |
984 |
|
|
|
985 |
|
|
struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; |
986 |
|
|
DEFINE_RWLOCK(raw_v4_lock); |
987 |
kumaneko |
3831 |
@@ -588,9 +589,14 @@ static int raw_recvmsg(struct kiocb *ioc |
988 |
kumaneko |
3372 |
goto out; |
989 |
kumaneko |
3831 |
} |
990 |
kumaneko |
3372 |
|
991 |
kumaneko |
3831 |
- skb = skb_recv_datagram(sk, flags, noblock, &err); |
992 |
|
|
- if (!skb) |
993 |
|
|
- goto out; |
994 |
|
|
+ for (;;) { |
995 |
|
|
+ skb = skb_recv_datagram(sk, flags, noblock, &err); |
996 |
|
|
+ if (!skb) |
997 |
|
|
+ goto out; |
998 |
|
|
+ if (!ccs_socket_post_recvmsg_permission(sk, skb)) |
999 |
|
|
+ break; |
1000 |
|
|
+ skb_kill_datagram(sk, skb, flags); |
1001 |
|
|
+ } |
1002 |
|
|
|
1003 |
kumaneko |
3372 |
copied = skb->len; |
1004 |
|
|
if (len < copied) { |
1005 |
|
|
--- linux-2.6.15-cat.orig/net/ipv4/tcp_ipv4.c |
1006 |
|
|
+++ linux-2.6.15-cat/net/ipv4/tcp_ipv4.c |
1007 |
|
|
@@ -76,6 +76,7 @@ |
1008 |
|
|
#include <linux/stddef.h> |
1009 |
|
|
#include <linux/proc_fs.h> |
1010 |
|
|
#include <linux/seq_file.h> |
1011 |
|
|
+#include <linux/ccsecurity.h> |
1012 |
|
|
|
1013 |
|
|
int sysctl_tcp_tw_reuse; |
1014 |
|
|
int sysctl_tcp_low_latency; |
1015 |
|
|
@@ -243,6 +244,8 @@ static inline int tcp_v4_hash_connect(st |
1016 |
|
|
local_bh_disable(); |
1017 |
|
|
for (i = 1; i <= range; i++) { |
1018 |
|
|
port = low + (i + offset) % range; |
1019 |
|
|
+ if (ccs_lport_reserved(port)) |
1020 |
|
|
+ continue; |
1021 |
|
|
head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)]; |
1022 |
|
|
spin_lock(&head->lock); |
1023 |
|
|
|
1024 |
|
|
--- linux-2.6.15-cat.orig/net/ipv4/udp.c |
1025 |
|
|
+++ linux-2.6.15-cat/net/ipv4/udp.c |
1026 |
|
|
@@ -108,6 +108,7 @@ |
1027 |
|
|
#include <net/inet_common.h> |
1028 |
|
|
#include <net/checksum.h> |
1029 |
|
|
#include <net/xfrm.h> |
1030 |
|
|
+#include <linux/ccsecurity.h> |
1031 |
|
|
|
1032 |
|
|
/* |
1033 |
|
|
* Snmp MIB for the UDP layer |
1034 |
|
|
@@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock * |
1035 |
|
|
result = sysctl_local_port_range[0] + |
1036 |
|
|
((result - sysctl_local_port_range[0]) & |
1037 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1038 |
|
|
+ if (ccs_lport_reserved(result)) |
1039 |
|
|
+ continue; |
1040 |
|
|
goto gotit; |
1041 |
|
|
} |
1042 |
|
|
size = 0; |
1043 |
|
|
@@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock * |
1044 |
|
|
result = sysctl_local_port_range[0] |
1045 |
|
|
+ ((result - sysctl_local_port_range[0]) & |
1046 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1047 |
|
|
+ if (ccs_lport_reserved(result)) |
1048 |
|
|
+ continue; |
1049 |
|
|
if (!udp_lport_inuse(result)) |
1050 |
|
|
break; |
1051 |
|
|
} |
1052 |
kumaneko |
3831 |
@@ -782,6 +787,7 @@ static int udp_recvmsg(struct kiocb *ioc |
1053 |
|
|
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; |
1054 |
|
|
struct sk_buff *skb; |
1055 |
|
|
int copied, err; |
1056 |
|
|
+ _Bool update_stat; |
1057 |
|
|
|
1058 |
|
|
/* |
1059 |
|
|
* Check any passed addresses |
1060 |
|
|
@@ -796,6 +802,11 @@ try_again: |
1061 |
kumaneko |
3372 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1062 |
|
|
if (!skb) |
1063 |
|
|
goto out; |
1064 |
kumaneko |
3831 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1065 |
|
|
+ update_stat = 0; |
1066 |
|
|
+ goto csum_copy_err; |
1067 |
|
|
+ } |
1068 |
|
|
+ update_stat = 1; |
1069 |
kumaneko |
3372 |
|
1070 |
|
|
copied = skb->len - sizeof(struct udphdr); |
1071 |
|
|
if (copied > len) { |
1072 |
kumaneko |
3831 |
@@ -844,7 +855,8 @@ out: |
1073 |
|
|
return err; |
1074 |
|
|
|
1075 |
|
|
csum_copy_err: |
1076 |
|
|
- UDP_INC_STATS_BH(UDP_MIB_INERRORS); |
1077 |
|
|
+ if (update_stat) |
1078 |
|
|
+ UDP_INC_STATS_BH(UDP_MIB_INERRORS); |
1079 |
|
|
|
1080 |
|
|
/* Clear queue. */ |
1081 |
|
|
if (flags&MSG_PEEK) { |
1082 |
kumaneko |
3372 |
--- linux-2.6.15-cat.orig/net/ipv6/raw.c |
1083 |
|
|
+++ linux-2.6.15-cat/net/ipv6/raw.c |
1084 |
|
|
@@ -56,6 +56,7 @@ |
1085 |
|
|
|
1086 |
|
|
#include <linux/proc_fs.h> |
1087 |
|
|
#include <linux/seq_file.h> |
1088 |
|
|
+#include <linux/ccsecurity.h> |
1089 |
|
|
|
1090 |
|
|
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1091 |
|
|
DEFINE_RWLOCK(raw_v6_lock); |
1092 |
kumaneko |
3831 |
@@ -384,9 +385,14 @@ static int rawv6_recvmsg(struct kiocb *i |
1093 |
|
|
if (flags & MSG_ERRQUEUE) |
1094 |
|
|
return ipv6_recv_error(sk, msg, len); |
1095 |
kumaneko |
3372 |
|
1096 |
kumaneko |
3831 |
- skb = skb_recv_datagram(sk, flags, noblock, &err); |
1097 |
|
|
- if (!skb) |
1098 |
|
|
- goto out; |
1099 |
|
|
+ for (;;) { |
1100 |
|
|
+ skb = skb_recv_datagram(sk, flags, noblock, &err); |
1101 |
|
|
+ if (!skb) |
1102 |
|
|
+ goto out; |
1103 |
|
|
+ if (!ccs_socket_post_recvmsg_permission(sk, skb)) |
1104 |
|
|
+ break; |
1105 |
|
|
+ skb_kill_datagram(sk, skb, flags); |
1106 |
|
|
+ } |
1107 |
|
|
|
1108 |
kumaneko |
3372 |
copied = skb->len; |
1109 |
|
|
if (copied > len) { |
1110 |
|
|
--- linux-2.6.15-cat.orig/net/ipv6/tcp_ipv6.c |
1111 |
|
|
+++ linux-2.6.15-cat/net/ipv6/tcp_ipv6.c |
1112 |
|
|
@@ -64,6 +64,7 @@ |
1113 |
|
|
|
1114 |
|
|
#include <linux/proc_fs.h> |
1115 |
|
|
#include <linux/seq_file.h> |
1116 |
|
|
+#include <linux/ccsecurity.h> |
1117 |
|
|
|
1118 |
|
|
static void tcp_v6_send_reset(struct sk_buff *skb); |
1119 |
|
|
static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); |
1120 |
|
|
@@ -119,6 +120,8 @@ static int tcp_v6_get_port(struct sock * |
1121 |
|
|
do { |
1122 |
|
|
head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)]; |
1123 |
|
|
spin_lock(&head->lock); |
1124 |
|
|
+ if (ccs_lport_reserved(rover)) |
1125 |
|
|
+ goto next; |
1126 |
|
|
inet_bind_bucket_for_each(tb, node, &head->chain) |
1127 |
|
|
if (tb->port == rover) |
1128 |
|
|
goto next; |
1129 |
|
|
@@ -419,6 +422,8 @@ static int tcp_v6_hash_connect(struct so |
1130 |
|
|
local_bh_disable(); |
1131 |
|
|
for (i = 1; i <= range; i++) { |
1132 |
|
|
port = low + (i + offset) % range; |
1133 |
|
|
+ if (ccs_lport_reserved(port)) |
1134 |
|
|
+ continue; |
1135 |
|
|
head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)]; |
1136 |
|
|
spin_lock(&head->lock); |
1137 |
|
|
|
1138 |
|
|
--- linux-2.6.15-cat.orig/net/ipv6/udp.c |
1139 |
|
|
+++ linux-2.6.15-cat/net/ipv6/udp.c |
1140 |
|
|
@@ -58,6 +58,7 @@ |
1141 |
|
|
|
1142 |
|
|
#include <linux/proc_fs.h> |
1143 |
|
|
#include <linux/seq_file.h> |
1144 |
|
|
+#include <linux/ccsecurity.h> |
1145 |
|
|
|
1146 |
|
|
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
1147 |
|
|
|
1148 |
|
|
@@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock * |
1149 |
|
|
result = sysctl_local_port_range[0] + |
1150 |
|
|
((result - sysctl_local_port_range[0]) & |
1151 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1152 |
|
|
+ if (ccs_lport_reserved(result)) |
1153 |
|
|
+ continue; |
1154 |
|
|
goto gotit; |
1155 |
|
|
} |
1156 |
|
|
size = 0; |
1157 |
|
|
@@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock * |
1158 |
|
|
result = sysctl_local_port_range[0] |
1159 |
|
|
+ ((result - sysctl_local_port_range[0]) & |
1160 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1161 |
|
|
+ if (ccs_lport_reserved(result)) |
1162 |
|
|
+ continue; |
1163 |
|
|
if (!udp_lport_inuse(result)) |
1164 |
|
|
break; |
1165 |
|
|
} |
1166 |
kumaneko |
3831 |
@@ -226,6 +231,7 @@ static int udpv6_recvmsg(struct kiocb *i |
1167 |
|
|
struct sk_buff *skb; |
1168 |
|
|
size_t copied; |
1169 |
|
|
int err; |
1170 |
|
|
+ _Bool update_stat; |
1171 |
|
|
|
1172 |
|
|
if (addr_len) |
1173 |
|
|
*addr_len=sizeof(struct sockaddr_in6); |
1174 |
|
|
@@ -237,6 +243,11 @@ try_again: |
1175 |
kumaneko |
3372 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1176 |
|
|
if (!skb) |
1177 |
|
|
goto out; |
1178 |
kumaneko |
3831 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1179 |
|
|
+ update_stat = 0; |
1180 |
|
|
+ goto csum_copy_err; |
1181 |
|
|
+ } |
1182 |
|
|
+ update_stat = 1; |
1183 |
kumaneko |
3372 |
|
1184 |
|
|
copied = skb->len - sizeof(struct udphdr); |
1185 |
|
|
if (copied > len) { |
1186 |
kumaneko |
3831 |
@@ -316,7 +327,8 @@ csum_copy_err: |
1187 |
|
|
skb_free_datagram(sk, skb); |
1188 |
|
|
|
1189 |
|
|
if (flags & MSG_DONTWAIT) { |
1190 |
|
|
- UDP6_INC_STATS_USER(UDP_MIB_INERRORS); |
1191 |
|
|
+ if (update_stat) |
1192 |
|
|
+ UDP6_INC_STATS_USER(UDP_MIB_INERRORS); |
1193 |
|
|
return -EAGAIN; |
1194 |
|
|
} |
1195 |
|
|
goto try_again; |
1196 |
kumaneko |
3372 |
--- linux-2.6.15-cat.orig/net/socket.c |
1197 |
|
|
+++ linux-2.6.15-cat/net/socket.c |
1198 |
|
|
@@ -97,6 +97,8 @@ |
1199 |
|
|
#include <net/sock.h> |
1200 |
|
|
#include <linux/netfilter.h> |
1201 |
|
|
|
1202 |
|
|
+#include <linux/ccsecurity.h> |
1203 |
|
|
+ |
1204 |
|
|
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1205 |
|
|
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
1206 |
|
|
size_t size, loff_t pos); |
1207 |
|
|
@@ -544,9 +546,10 @@ static inline int __sock_sendmsg(struct |
1208 |
|
|
si->size = size; |
1209 |
|
|
|
1210 |
|
|
err = security_socket_sendmsg(sock, msg, size); |
1211 |
|
|
+ if (!err) |
1212 |
|
|
+ err = ccs_socket_sendmsg_permission(sock, msg, size); |
1213 |
|
|
if (err) |
1214 |
|
|
return err; |
1215 |
|
|
- |
1216 |
|
|
return sock->ops->sendmsg(iocb, sock, msg, size); |
1217 |
|
|
} |
1218 |
|
|
|
1219 |
|
|
@@ -1100,6 +1103,8 @@ static int __sock_create(int family, int |
1220 |
|
|
} |
1221 |
|
|
|
1222 |
|
|
err = security_socket_create(family, type, protocol, kern); |
1223 |
|
|
+ if (!err) |
1224 |
|
|
+ err = ccs_socket_create_permission(family, type, protocol); |
1225 |
|
|
if (err) |
1226 |
|
|
return err; |
1227 |
|
|
|
1228 |
|
|
@@ -1296,6 +1301,10 @@ asmlinkage long sys_bind(int fd, struct |
1229 |
|
|
sockfd_put(sock); |
1230 |
|
|
return err; |
1231 |
|
|
} |
1232 |
|
|
+ err = ccs_socket_bind_permission(sock, |
1233 |
|
|
+ (struct sockaddr *) |
1234 |
|
|
+ address, addrlen); |
1235 |
|
|
+ if (!err) |
1236 |
|
|
err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen); |
1237 |
|
|
} |
1238 |
|
|
sockfd_put(sock); |
1239 |
|
|
@@ -1326,7 +1335,8 @@ asmlinkage long sys_listen(int fd, int b |
1240 |
|
|
sockfd_put(sock); |
1241 |
|
|
return err; |
1242 |
|
|
} |
1243 |
|
|
- |
1244 |
|
|
+ err = ccs_socket_listen_permission(sock); |
1245 |
|
|
+ if (!err) |
1246 |
|
|
err=sock->ops->listen(sock, backlog); |
1247 |
|
|
sockfd_put(sock); |
1248 |
|
|
} |
1249 |
kumaneko |
3831 |
@@ -1356,6 +1366,7 @@ asmlinkage long sys_accept(int fd, struc |
1250 |
|
|
if (!sock) |
1251 |
|
|
goto out; |
1252 |
|
|
|
1253 |
|
|
+retry: |
1254 |
|
|
err = -ENFILE; |
1255 |
|
|
if (!(newsock = sock_alloc())) |
1256 |
|
|
goto out_put; |
1257 |
|
|
@@ -1377,6 +1388,10 @@ asmlinkage long sys_accept(int fd, struc |
1258 |
kumaneko |
3372 |
if (err < 0) |
1259 |
|
|
goto out_release; |
1260 |
|
|
|
1261 |
kumaneko |
3831 |
+ if (ccs_socket_post_accept_permission(sock, newsock)) { |
1262 |
|
|
+ sock_release(newsock); |
1263 |
|
|
+ goto retry; |
1264 |
kumaneko |
3372 |
+ } |
1265 |
|
|
if (upeer_sockaddr) { |
1266 |
|
|
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
1267 |
|
|
err = -ECONNABORTED; |
1268 |
|
|
@@ -1430,9 +1445,11 @@ asmlinkage long sys_connect(int fd, stru |
1269 |
|
|
goto out_put; |
1270 |
|
|
|
1271 |
|
|
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1272 |
|
|
+ if (!err) |
1273 |
|
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) |
1274 |
|
|
+ address, addrlen); |
1275 |
|
|
if (err) |
1276 |
|
|
goto out_put; |
1277 |
|
|
- |
1278 |
|
|
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
1279 |
|
|
sock->file->f_flags); |
1280 |
|
|
out_put: |
1281 |
|
|
--- linux-2.6.15-cat.orig/net/unix/af_unix.c |
1282 |
|
|
+++ linux-2.6.15-cat/net/unix/af_unix.c |
1283 |
|
|
@@ -117,6 +117,7 @@ |
1284 |
|
|
#include <linux/mount.h> |
1285 |
|
|
#include <net/checksum.h> |
1286 |
|
|
#include <linux/security.h> |
1287 |
|
|
+#include <linux/ccsecurity.h> |
1288 |
|
|
|
1289 |
|
|
int sysctl_unix_max_dgram_qlen = 10; |
1290 |
|
|
|
1291 |
|
|
@@ -781,6 +782,9 @@ static int unix_bind(struct socket *sock |
1292 |
|
|
*/ |
1293 |
|
|
mode = S_IFSOCK | |
1294 |
|
|
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1295 |
|
|
+ err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt, |
1296 |
|
|
+ mode, 0); |
1297 |
|
|
+ if (!err) |
1298 |
|
|
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1299 |
|
|
if (err) |
1300 |
|
|
goto out_mknod_dput; |
1301 |
|
|
--- linux-2.6.15-cat.orig/security/Kconfig |
1302 |
|
|
+++ linux-2.6.15-cat/security/Kconfig |
1303 |
|
|
@@ -88,5 +88,7 @@ config SECURITY_SECLVL |
1304 |
|
|
|
1305 |
|
|
source security/selinux/Kconfig |
1306 |
|
|
|
1307 |
|
|
+source security/ccsecurity/Kconfig |
1308 |
|
|
+ |
1309 |
|
|
endmenu |
1310 |
|
|
|
1311 |
|
|
--- linux-2.6.15-cat.orig/security/Makefile |
1312 |
|
|
+++ linux-2.6.15-cat/security/Makefile |
1313 |
|
|
@@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin |
1314 |
|
|
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |
1315 |
|
|
obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o |
1316 |
|
|
obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o |
1317 |
|
|
+ |
1318 |
|
|
+subdir-$(CONFIG_CCSECURITY)+= ccsecurity |
1319 |
|
|
+obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o |