1 |
--- |
2 |
Makefile | 2 |
3 |
arch/alpha/kernel/ptrace.c | 8 +++ |
4 |
arch/ia64/kernel/ptrace.c | 8 +++ |
5 |
arch/m32r/kernel/ptrace.c | 8 +++ |
6 |
arch/powerpc/kernel/ptrace32.c | 8 +++ |
7 |
arch/s390/kernel/ptrace.c | 8 +++ |
8 |
arch/sh64/kernel/ptrace.c | 8 +++ |
9 |
arch/sparc/kernel/ptrace.c | 8 +++ |
10 |
arch/sparc64/kernel/ptrace.c | 8 +++ |
11 |
arch/x86_64/ia32/ptrace32.c | 8 +++ |
12 |
fs/Kconfig | 2 |
13 |
fs/Makefile | 2 |
14 |
fs/attr.c | 11 +++++ |
15 |
fs/compat.c | 8 +++ |
16 |
fs/exec.c | 14 ++++++ |
17 |
fs/fcntl.c | 7 +++ |
18 |
fs/ioctl.c | 6 ++ |
19 |
fs/namei.c | 60 +++++++++++++++++++++++++++++ |
20 |
fs/namespace.c | 38 ++++++++++++++++++ |
21 |
fs/open.c | 21 ++++++++++ |
22 |
fs/proc/Makefile | 3 + |
23 |
fs/proc/proc_misc.c | 9 ++++ |
24 |
include/linux/init_task.h | 4 + |
25 |
include/linux/sched.h | 9 ++++ |
26 |
kernel/compat.c | 6 ++ |
27 |
kernel/kexec.c | 6 ++ |
28 |
kernel/kmod.c | 5 ++ |
29 |
kernel/module.c | 9 ++++ |
30 |
kernel/ptrace.c | 8 +++ |
31 |
kernel/sched.c | 6 ++ |
32 |
kernel/signal.c | 15 +++++++ |
33 |
kernel/sys.c | 15 +++++++ |
34 |
kernel/sysctl.c | 81 ++++++++++++++++++++++++++++++++++++++++ |
35 |
kernel/time.c | 9 ++++ |
36 |
kernel/time/ntp.c | 6 ++ |
37 |
net/core/datagram.c | 9 ++++ |
38 |
net/ipv4/inet_connection_sock.c | 6 ++ |
39 |
net/ipv4/inet_hashtables.c | 6 ++ |
40 |
net/ipv4/udp.c | 9 ++++ |
41 |
net/ipv6/inet6_hashtables.c | 6 ++ |
42 |
net/socket.c | 28 +++++++++++++ |
43 |
net/unix/af_unix.c | 10 ++++ |
44 |
42 files changed, 505 insertions(+), 3 deletions(-) |
45 |
|
46 |
--- linux-2.6.21.orig/Makefile |
47 |
+++ linux-2.6.21/Makefile |
48 |
@@ -1,7 +1,7 @@ |
49 |
VERSION = 2 |
50 |
PATCHLEVEL = 6 |
51 |
SUBLEVEL = 21 |
52 |
-EXTRAVERSION = |
53 |
+EXTRAVERSION = -ccs |
54 |
NAME = Nocturnal Monster Puppy |
55 |
|
56 |
# *DOCUMENTATION* |
57 |
--- linux-2.6.21.orig/arch/alpha/kernel/ptrace.c |
58 |
+++ linux-2.6.21/arch/alpha/kernel/ptrace.c |
59 |
@@ -20,6 +20,9 @@ |
60 |
#include <asm/pgtable.h> |
61 |
#include <asm/system.h> |
62 |
#include <asm/fpu.h> |
63 |
+/***** TOMOYO Linux start. *****/ |
64 |
+#include <linux/tomoyo.h> |
65 |
+/***** TOMOYO Linux end. *****/ |
66 |
|
67 |
#include "proto.h" |
68 |
|
69 |
@@ -268,6 +271,11 @@ do_sys_ptrace(long request, long pid, lo |
70 |
unsigned long tmp; |
71 |
size_t copied; |
72 |
long ret; |
73 |
+ /***** TOMOYO Linux start. *****/ |
74 |
+#ifdef TOMOYO_SYS_PTRACE |
75 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
76 |
+#endif |
77 |
+ /***** TOMOYO Linux end. *****/ |
78 |
|
79 |
lock_kernel(); |
80 |
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
81 |
--- linux-2.6.21.orig/arch/ia64/kernel/ptrace.c |
82 |
+++ linux-2.6.21/arch/ia64/kernel/ptrace.c |
83 |
@@ -28,6 +28,9 @@ |
84 |
#ifdef CONFIG_PERFMON |
85 |
#include <asm/perfmon.h> |
86 |
#endif |
87 |
+/***** TOMOYO Linux start. *****/ |
88 |
+#include <linux/tomoyo.h> |
89 |
+/***** TOMOYO Linux end. *****/ |
90 |
|
91 |
#include "entry.h" |
92 |
|
93 |
@@ -1418,6 +1421,11 @@ sys_ptrace (long request, pid_t pid, uns |
94 |
struct task_struct *child; |
95 |
struct switch_stack *sw; |
96 |
long ret; |
97 |
+ /***** TOMOYO Linux start. *****/ |
98 |
+#ifdef TOMOYO_SYS_PTRACE |
99 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
100 |
+#endif |
101 |
+ /***** TOMOYO Linux end. *****/ |
102 |
|
103 |
lock_kernel(); |
104 |
ret = -EPERM; |
105 |
--- linux-2.6.21.orig/arch/m32r/kernel/ptrace.c |
106 |
+++ linux-2.6.21/arch/m32r/kernel/ptrace.c |
107 |
@@ -32,6 +32,9 @@ |
108 |
#include <asm/system.h> |
109 |
#include <asm/processor.h> |
110 |
#include <asm/mmu_context.h> |
111 |
+/***** TOMOYO Linux start. *****/ |
112 |
+#include <linux/tomoyo.h> |
113 |
+/***** TOMOYO Linux end. *****/ |
114 |
|
115 |
/* |
116 |
* This routine will get a word off of the process kernel stack. |
117 |
@@ -742,6 +745,11 @@ asmlinkage long sys_ptrace(long request, |
118 |
{ |
119 |
struct task_struct *child; |
120 |
int ret; |
121 |
+ /***** TOMOYO Linux start. *****/ |
122 |
+#ifdef TOMOYO_SYS_PTRACE |
123 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
124 |
+#endif |
125 |
+ /***** TOMOYO Linux end. *****/ |
126 |
|
127 |
lock_kernel(); |
128 |
if (request == PTRACE_TRACEME) { |
129 |
--- linux-2.6.21.orig/arch/s390/kernel/ptrace.c |
130 |
+++ linux-2.6.21/arch/s390/kernel/ptrace.c |
131 |
@@ -41,6 +41,9 @@ |
132 |
#include <asm/system.h> |
133 |
#include <asm/uaccess.h> |
134 |
#include <asm/unistd.h> |
135 |
+/***** TOMOYO Linux start. *****/ |
136 |
+#include <linux/tomoyo.h> |
137 |
+/***** TOMOYO Linux end. *****/ |
138 |
|
139 |
#ifdef CONFIG_COMPAT |
140 |
#include "compat_ptrace.h" |
141 |
@@ -713,6 +716,11 @@ sys_ptrace(long request, long pid, long |
142 |
struct task_struct *child; |
143 |
int ret; |
144 |
|
145 |
+ /***** TOMOYO Linux start. *****/ |
146 |
+#ifdef TOMOYO_SYS_PTRACE |
147 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
148 |
+#endif |
149 |
+ /***** TOMOYO Linux end. *****/ |
150 |
lock_kernel(); |
151 |
if (request == PTRACE_TRACEME) { |
152 |
ret = ptrace_traceme(); |
153 |
--- linux-2.6.21.orig/arch/sparc/kernel/ptrace.c |
154 |
+++ linux-2.6.21/arch/sparc/kernel/ptrace.c |
155 |
@@ -23,6 +23,9 @@ |
156 |
#include <asm/pgtable.h> |
157 |
#include <asm/system.h> |
158 |
#include <asm/uaccess.h> |
159 |
+/***** TOMOYO Linux start. *****/ |
160 |
+#include <linux/tomoyo.h> |
161 |
+/***** TOMOYO Linux end. *****/ |
162 |
|
163 |
#define MAGIC_CONSTANT 0x80000000 |
164 |
|
165 |
@@ -267,6 +270,11 @@ asmlinkage void do_ptrace(struct pt_regs |
166 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
167 |
struct task_struct *child; |
168 |
int ret; |
169 |
+ /***** TOMOYO Linux start. *****/ |
170 |
+#ifdef TOMOYO_SYS_PTRACE |
171 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
172 |
+#endif |
173 |
+ /***** TOMOYO Linux end. *****/ |
174 |
|
175 |
lock_kernel(); |
176 |
#ifdef DEBUG_PTRACE |
177 |
--- linux-2.6.21.orig/arch/sparc64/kernel/ptrace.c |
178 |
+++ linux-2.6.21/arch/sparc64/kernel/ptrace.c |
179 |
@@ -32,6 +32,9 @@ |
180 |
#include <asm/spitfire.h> |
181 |
#include <asm/page.h> |
182 |
#include <asm/cpudata.h> |
183 |
+/***** TOMOYO Linux start. *****/ |
184 |
+#include <linux/tomoyo.h> |
185 |
+/***** TOMOYO Linux end. *****/ |
186 |
|
187 |
/* Returning from ptrace is a bit tricky because the syscall return |
188 |
* low level code assumes any value returned which is negative and |
189 |
@@ -176,6 +179,11 @@ asmlinkage void do_ptrace(struct pt_regs |
190 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
191 |
struct task_struct *child; |
192 |
int ret; |
193 |
+ /***** TOMOYO Linux start. *****/ |
194 |
+#ifdef TOMOYO_SYS_PTRACE |
195 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
196 |
+#endif |
197 |
+ /***** TOMOYO Linux end. *****/ |
198 |
|
199 |
if (test_thread_flag(TIF_32BIT)) { |
200 |
addr &= 0xffffffffUL; |
201 |
--- linux-2.6.21.orig/fs/Kconfig |
202 |
+++ linux-2.6.21/fs/Kconfig |
203 |
@@ -2055,5 +2055,7 @@ endif |
204 |
source "fs/nls/Kconfig" |
205 |
source "fs/dlm/Kconfig" |
206 |
|
207 |
+source "fs/Kconfig.ccs" |
208 |
+ |
209 |
endmenu |
210 |
|
211 |
--- linux-2.6.21.orig/fs/Makefile |
212 |
+++ linux-2.6.21/fs/Makefile |
213 |
@@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS) += hppfs/ |
214 |
obj-$(CONFIG_DEBUG_FS) += debugfs/ |
215 |
obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
216 |
obj-$(CONFIG_GFS2_FS) += gfs2/ |
217 |
+ |
218 |
+include $(srctree)/fs/Makefile-2.6.ccs |
219 |
--- linux-2.6.21.orig/fs/attr.c |
220 |
+++ linux-2.6.21/fs/attr.c |
221 |
@@ -15,6 +15,9 @@ |
222 |
#include <linux/fcntl.h> |
223 |
#include <linux/quotaops.h> |
224 |
#include <linux/security.h> |
225 |
+/***** TOMOYO Linux start. *****/ |
226 |
+#include <linux/tomoyo.h> |
227 |
+/***** TOMOYO Linux end. *****/ |
228 |
|
229 |
/* Taken over from the old code... */ |
230 |
|
231 |
@@ -145,12 +148,20 @@ int notify_change(struct dentry * dentry |
232 |
|
233 |
if (inode->i_op && inode->i_op->setattr) { |
234 |
error = security_inode_setattr(dentry, attr); |
235 |
+ /***** TOMOYO Linux start. *****/ |
236 |
+ if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD); |
237 |
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN); |
238 |
+ /***** TOMOYO Linux end. *****/ |
239 |
if (!error) |
240 |
error = inode->i_op->setattr(dentry, attr); |
241 |
} else { |
242 |
error = inode_change_ok(inode, attr); |
243 |
if (!error) |
244 |
error = security_inode_setattr(dentry, attr); |
245 |
+ /***** TOMOYO Linux start. *****/ |
246 |
+ if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD); |
247 |
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN); |
248 |
+ /***** TOMOYO Linux end. *****/ |
249 |
if (!error) { |
250 |
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
251 |
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
252 |
--- linux-2.6.21.orig/fs/compat.c |
253 |
+++ linux-2.6.21/fs/compat.c |
254 |
@@ -56,6 +56,9 @@ |
255 |
#include <asm/mmu_context.h> |
256 |
#include <asm/ioctls.h> |
257 |
#include "internal.h" |
258 |
+/***** TOMOYO Linux start. *****/ |
259 |
+#include <linux/tomoyo.h> |
260 |
+/***** TOMOYO Linux end. *****/ |
261 |
|
262 |
int compat_log = 1; |
263 |
|
264 |
@@ -422,6 +425,9 @@ asmlinkage long compat_sys_ioctl(unsigne |
265 |
/*FALL THROUGH*/ |
266 |
|
267 |
default: |
268 |
+ /***** TOMOYO Linux start. *****/ |
269 |
+ if ((error = CheckCapabilityACL(TOMOYO_SYS_IOCTL)) < 0) goto out_fput; |
270 |
+ /***** TOMOYO Linux end. *****/ |
271 |
if (filp->f_op && filp->f_op->compat_ioctl) { |
272 |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
273 |
if (error != -ENOIOCTLCMD) |
274 |
@@ -1552,7 +1558,7 @@ int compat_do_execve(char * filename, |
275 |
if (retval < 0) |
276 |
goto out; |
277 |
|
278 |
- retval = search_binary_handler(bprm, regs); |
279 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
280 |
if (retval >= 0) { |
281 |
free_arg_pages(bprm); |
282 |
|
283 |
--- linux-2.6.21.orig/fs/exec.c |
284 |
+++ linux-2.6.21/fs/exec.c |
285 |
@@ -58,6 +58,10 @@ |
286 |
#include <linux/kmod.h> |
287 |
#endif |
288 |
|
289 |
+/***** TOMOYO Linux start. *****/ |
290 |
+#include <linux/tomoyo.h> |
291 |
+/***** TOMOYO Linux end. *****/ |
292 |
+ |
293 |
int core_uses_pid; |
294 |
char core_pattern[128] = "core"; |
295 |
int suid_dumpable = 0; |
296 |
@@ -140,6 +144,11 @@ asmlinkage long sys_uselib(const char __ |
297 |
if (error) |
298 |
goto exit; |
299 |
|
300 |
+ /***** TOMOYO Linux start. *****/ |
301 |
+ error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */ |
302 |
+ if (error) goto exit; |
303 |
+ /***** TOMOYO Linux end. *****/ |
304 |
+ |
305 |
file = nameidata_to_filp(&nd, O_RDONLY); |
306 |
error = PTR_ERR(file); |
307 |
if (IS_ERR(file)) |
308 |
@@ -485,6 +494,9 @@ struct file *open_exec(const char *name) |
309 |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
310 |
S_ISREG(inode->i_mode)) { |
311 |
int err = vfs_permission(&nd, MAY_EXEC); |
312 |
+ /***** TOMOYO Linux start. *****/ |
313 |
+ if (!err && (current->tomoyo_flags & TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) err = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */ |
314 |
+ /***** TOMOYO Linux end. *****/ |
315 |
file = ERR_PTR(err); |
316 |
if (!err) { |
317 |
file = nameidata_to_filp(&nd, O_RDONLY); |
318 |
@@ -1183,7 +1195,7 @@ int do_execve(char * filename, |
319 |
if (retval < 0) |
320 |
goto out; |
321 |
|
322 |
- retval = search_binary_handler(bprm,regs); |
323 |
+ retval = search_binary_handler_with_transition(bprm,regs); |
324 |
if (retval >= 0) { |
325 |
free_arg_pages(bprm); |
326 |
|
327 |
--- linux-2.6.21.orig/fs/fcntl.c |
328 |
+++ linux-2.6.21/fs/fcntl.c |
329 |
@@ -22,6 +22,9 @@ |
330 |
#include <asm/poll.h> |
331 |
#include <asm/siginfo.h> |
332 |
#include <asm/uaccess.h> |
333 |
+/***** TOMOYO Linux start. *****/ |
334 |
+#include <linux/tomoyo.h> |
335 |
+/***** TOMOYO Linux end. *****/ |
336 |
|
337 |
void fastcall set_close_on_exec(unsigned int fd, int flag) |
338 |
{ |
339 |
@@ -213,6 +216,10 @@ static int setfl(int fd, struct file * f |
340 |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
341 |
return -EPERM; |
342 |
|
343 |
+ /***** TOMOYO Linux start. *****/ |
344 |
+ if (((arg ^ filp->f_flags) & O_APPEND) && CheckReWritePermission(filp)) return -EPERM; |
345 |
+ /***** TOMOYO Linux end. *****/ |
346 |
+ |
347 |
/* O_NOATIME can only be set by the owner or superuser */ |
348 |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
349 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
350 |
--- linux-2.6.21.orig/fs/ioctl.c |
351 |
+++ linux-2.6.21/fs/ioctl.c |
352 |
@@ -15,6 +15,9 @@ |
353 |
|
354 |
#include <asm/uaccess.h> |
355 |
#include <asm/ioctls.h> |
356 |
+/***** TOMOYO Linux start. *****/ |
357 |
+#include <linux/tomoyo.h> |
358 |
+/***** TOMOYO Linux end. *****/ |
359 |
|
360 |
static long do_ioctl(struct file *filp, unsigned int cmd, |
361 |
unsigned long arg) |
362 |
@@ -23,6 +26,9 @@ static long do_ioctl(struct file *filp, |
363 |
|
364 |
if (!filp->f_op) |
365 |
goto out; |
366 |
+ /***** TOMOYO Linux start. *****/ |
367 |
+ if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM; |
368 |
+ /***** TOMOYO Linux end. *****/ |
369 |
|
370 |
if (filp->f_op->unlocked_ioctl) { |
371 |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
372 |
--- linux-2.6.21.orig/fs/namei.c |
373 |
+++ linux-2.6.21/fs/namei.c |
374 |
@@ -37,6 +37,10 @@ |
375 |
|
376 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
377 |
|
378 |
+/***** TOMOYO Linux start. *****/ |
379 |
+#include <linux/tomoyo.h> |
380 |
+/***** TOMOYO Linux end. *****/ |
381 |
+ |
382 |
/* [Feb-1997 T. Schoebel-Theuer] |
383 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
384 |
* were necessary because of omirr. The reason is that omirr needs |
385 |
@@ -1506,6 +1510,9 @@ int vfs_create(struct inode *dir, struct |
386 |
error = security_inode_create(dir, dentry, mode); |
387 |
if (error) |
388 |
return error; |
389 |
+ /***** TOMOYO Linux start. *****/ |
390 |
+ if (nd && (error = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error; |
391 |
+ /***** TOMOYO Linux end. *****/ |
392 |
DQUOT_INIT(dir); |
393 |
error = dir->i_op->create(dir, dentry, mode, nd); |
394 |
if (!error) |
395 |
@@ -1561,6 +1568,11 @@ int may_open(struct nameidata *nd, int a |
396 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
397 |
return -EPERM; |
398 |
|
399 |
+ /***** TOMOYO Linux start. *****/ |
400 |
+ error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */ |
401 |
+ if (error) return error; |
402 |
+ /***** TOMOYO Linux end. *****/ |
403 |
+ |
404 |
/* |
405 |
* Ensure there are no outstanding leases on the file. |
406 |
*/ |
407 |
@@ -1610,6 +1622,9 @@ static int open_namei_create(struct name |
408 |
return may_open(nd, 0, flag & ~O_TRUNC); |
409 |
} |
410 |
|
411 |
+/***** TOMOYO Linux start. *****/ |
412 |
+#include <linux/tomoyo_vfs.h> |
413 |
+/***** TOMOYO Linux end. *****/ |
414 |
/* |
415 |
* open_namei() |
416 |
* |
417 |
@@ -1870,6 +1885,12 @@ asmlinkage long sys_mknodat(int dfd, con |
418 |
|
419 |
if (S_ISDIR(mode)) |
420 |
return -EPERM; |
421 |
+ /***** TOMOYO Linux start. *****/ |
422 |
+ if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM; |
423 |
+ if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM; |
424 |
+ if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM; |
425 |
+ if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM; |
426 |
+ /***** TOMOYO Linux end. *****/ |
427 |
tmp = getname(filename); |
428 |
if (IS_ERR(tmp)) |
429 |
return PTR_ERR(tmp); |
430 |
@@ -1888,10 +1909,16 @@ asmlinkage long sys_mknodat(int dfd, con |
431 |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
432 |
break; |
433 |
case S_IFCHR: case S_IFBLK: |
434 |
+ /***** TOMOYO Linux start. *****/ |
435 |
+ if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISCHR(mode) ? TYPE_MKCHAR_ACL : TYPE_MKBLOCK_ACL, dentry, nd.mnt)) == 0) |
436 |
+ /***** TOMOYO Linux end. *****/ |
437 |
error = vfs_mknod(nd.dentry->d_inode,dentry,mode, |
438 |
new_decode_dev(dev)); |
439 |
break; |
440 |
case S_IFIFO: case S_IFSOCK: |
441 |
+ /***** TOMOYO Linux start. *****/ |
442 |
+ if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISFIFO(mode) ? TYPE_MKFIFO_ACL : TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0) |
443 |
+ /***** TOMOYO Linux end. *****/ |
444 |
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0); |
445 |
break; |
446 |
case S_IFDIR: |
447 |
@@ -1959,6 +1986,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
448 |
|
449 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
450 |
mode &= ~current->fs->umask; |
451 |
+ /***** TOMOYO Linux start. *****/ |
452 |
+ if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0) |
453 |
+ /***** TOMOYO Linux end. *****/ |
454 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
455 |
dput(dentry); |
456 |
out_unlock: |
457 |
@@ -2066,6 +2096,9 @@ static long do_rmdir(int dfd, const char |
458 |
error = PTR_ERR(dentry); |
459 |
if (IS_ERR(dentry)) |
460 |
goto exit2; |
461 |
+ /***** TOMOYO Linux start. *****/ |
462 |
+ if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0) |
463 |
+ /***** TOMOYO Linux end. *****/ |
464 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
465 |
dput(dentry); |
466 |
exit2: |
467 |
@@ -2125,6 +2158,9 @@ static long do_unlinkat(int dfd, const c |
468 |
struct dentry *dentry; |
469 |
struct nameidata nd; |
470 |
struct inode *inode = NULL; |
471 |
+ /***** TOMOYO Linux start. *****/ |
472 |
+ if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM; |
473 |
+ /***** TOMOYO Linux end. *****/ |
474 |
|
475 |
name = getname(pathname); |
476 |
if(IS_ERR(name)) |
477 |
@@ -2146,6 +2182,9 @@ static long do_unlinkat(int dfd, const c |
478 |
inode = dentry->d_inode; |
479 |
if (inode) |
480 |
atomic_inc(&inode->i_count); |
481 |
+ /***** TOMOYO Linux start. *****/ |
482 |
+ if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0) |
483 |
+ /***** TOMOYO Linux end. *****/ |
484 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
485 |
exit2: |
486 |
dput(dentry); |
487 |
@@ -2210,6 +2249,9 @@ asmlinkage long sys_symlinkat(const char |
488 |
char * to; |
489 |
struct dentry *dentry; |
490 |
struct nameidata nd; |
491 |
+ /***** TOMOYO Linux start. *****/ |
492 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM; |
493 |
+ /***** TOMOYO Linux end. *****/ |
494 |
|
495 |
from = getname(oldname); |
496 |
if(IS_ERR(from)) |
497 |
@@ -2227,6 +2269,9 @@ asmlinkage long sys_symlinkat(const char |
498 |
if (IS_ERR(dentry)) |
499 |
goto out_unlock; |
500 |
|
501 |
+ /***** TOMOYO Linux start. *****/ |
502 |
+ if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0) |
503 |
+ /***** TOMOYO Linux end. *****/ |
504 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
505 |
dput(dentry); |
506 |
out_unlock: |
507 |
@@ -2299,6 +2344,9 @@ asmlinkage long sys_linkat(int olddfd, c |
508 |
struct nameidata nd, old_nd; |
509 |
int error; |
510 |
char * to; |
511 |
+ /***** TOMOYO Linux start. *****/ |
512 |
+ if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM; |
513 |
+ /***** TOMOYO Linux end. *****/ |
514 |
|
515 |
if ((flags & ~AT_SYMLINK_FOLLOW) != 0) |
516 |
return -EINVAL; |
517 |
@@ -2322,6 +2370,9 @@ asmlinkage long sys_linkat(int olddfd, c |
518 |
error = PTR_ERR(new_dentry); |
519 |
if (IS_ERR(new_dentry)) |
520 |
goto out_unlock; |
521 |
+ /***** TOMOYO Linux start. *****/ |
522 |
+ if ((error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry)) == 0 && (error = CheckDoubleWritePermission(TYPE_LINK_ACL, old_nd.dentry, old_nd.mnt, new_dentry, nd.mnt)) == 0) |
523 |
+ /***** TOMOYO Linux end. *****/ |
524 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
525 |
dput(new_dentry); |
526 |
out_unlock: |
527 |
@@ -2547,6 +2598,12 @@ static int do_rename(int olddfd, const c |
528 |
error = -ENOTEMPTY; |
529 |
if (new_dentry == trap) |
530 |
goto exit5; |
531 |
+ /***** TOMOYO Linux start. *****/ |
532 |
+ if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 || |
533 |
+ (error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) { |
534 |
+ goto exit5; |
535 |
+ } |
536 |
+ /***** TOMOYO Linux end. *****/ |
537 |
|
538 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
539 |
new_dir->d_inode, new_dentry); |
540 |
@@ -2570,6 +2627,9 @@ asmlinkage long sys_renameat(int olddfd, |
541 |
int error; |
542 |
char * from; |
543 |
char * to; |
544 |
+ /***** TOMOYO Linux start. *****/ |
545 |
+ if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM; |
546 |
+ /***** TOMOYO Linux end. *****/ |
547 |
|
548 |
from = getname(oldname); |
549 |
if(IS_ERR(from)) |
550 |
--- linux-2.6.21.orig/fs/namespace.c |
551 |
+++ linux-2.6.21/fs/namespace.c |
552 |
@@ -28,6 +28,12 @@ |
553 |
#include <asm/uaccess.h> |
554 |
#include <asm/unistd.h> |
555 |
#include "pnode.h" |
556 |
+/***** SAKURA Linux start. *****/ |
557 |
+#include <linux/sakura.h> |
558 |
+/***** SAKURA Linux end. *****/ |
559 |
+/***** TOMOYO Linux start. *****/ |
560 |
+#include <linux/tomoyo.h> |
561 |
+/***** TOMOYO Linux end. *****/ |
562 |
|
563 |
/* spinlock for vfsmount related operations, inplace of dcache_lock */ |
564 |
__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); |
565 |
@@ -545,6 +551,10 @@ static int do_umount(struct vfsmount *mn |
566 |
if (retval) |
567 |
return retval; |
568 |
|
569 |
+ /***** SAKURA Linux start. *****/ |
570 |
+ if (SAKURA_MayUmount(mnt) < 0) return -EPERM; |
571 |
+ /***** SAKURA Linux end. *****/ |
572 |
+ |
573 |
/* |
574 |
* Allow userspace to request a mountpoint be expired rather than |
575 |
* unmounting unconditionally. Unmount only happens if: |
576 |
@@ -633,6 +643,9 @@ asmlinkage long sys_umount(char __user * |
577 |
{ |
578 |
struct nameidata nd; |
579 |
int retval; |
580 |
+ /***** TOMOYO Linux start. *****/ |
581 |
+ if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM; |
582 |
+ /***** TOMOYO Linux end. *****/ |
583 |
|
584 |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
585 |
if (retval) |
586 |
@@ -917,6 +930,10 @@ static int do_loopback(struct nameidata |
587 |
|
588 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
589 |
goto out; |
590 |
+ /***** SAKURA Linux start. *****/ |
591 |
+ err = -EPERM; |
592 |
+ if (SAKURA_MayMount(nd) < 0) goto out; |
593 |
+ /***** SAKURA Linux end. *****/ |
594 |
|
595 |
err = -ENOMEM; |
596 |
if (recurse) |
597 |
@@ -1002,6 +1019,10 @@ static int do_move_mount(struct nameidat |
598 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
599 |
goto out; |
600 |
|
601 |
+ /***** SAKURA Linux start. *****/ |
602 |
+ err = -EPERM; |
603 |
+ if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0) goto out; |
604 |
+ /***** SAKURA Linux end. *****/ |
605 |
err = -ENOENT; |
606 |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
607 |
if (IS_DEADDIR(nd->dentry->d_inode)) |
608 |
@@ -1103,6 +1124,10 @@ int do_add_mount(struct vfsmount *newmnt |
609 |
err = -EINVAL; |
610 |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
611 |
goto unlock; |
612 |
+ /***** SAKURA Linux start. *****/ |
613 |
+ err = -EPERM; |
614 |
+ if (SAKURA_MayMount(nd) < 0) goto unlock; |
615 |
+ /***** SAKURA Linux end. *****/ |
616 |
|
617 |
newmnt->mnt_flags = mnt_flags; |
618 |
if ((err = graft_tree(newmnt, nd))) |
619 |
@@ -1394,6 +1419,13 @@ long do_mount(char *dev_name, char *dir_ |
620 |
if (data_page) |
621 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
622 |
|
623 |
+ /***** TOMOYO Linux start. *****/ |
624 |
+ if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM; |
625 |
+ /***** TOMOYO Linux end. *****/ |
626 |
+ /***** SAKURA Linux start. *****/ |
627 |
+ if ((retval = CheckMountPermission(dev_name, dir_name, type_page, &flags)) < 0) return retval; |
628 |
+ /***** SAKURA Linux end. *****/ |
629 |
+ |
630 |
/* Separate the per-mountpoint flags */ |
631 |
if (flags & MS_NOSUID) |
632 |
mnt_flags |= MNT_NOSUID; |
633 |
@@ -1686,6 +1718,9 @@ asmlinkage long sys_pivot_root(const cha |
634 |
|
635 |
if (!capable(CAP_SYS_ADMIN)) |
636 |
return -EPERM; |
637 |
+ /***** TOMOYO Linux start. *****/ |
638 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PIVOT_ROOT)) return -EPERM; |
639 |
+ /***** TOMOYO Linux end. *****/ |
640 |
|
641 |
lock_kernel(); |
642 |
|
643 |
@@ -1702,6 +1737,9 @@ asmlinkage long sys_pivot_root(const cha |
644 |
goto out1; |
645 |
|
646 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
647 |
+ /***** SAKURA Linux start. *****/ |
648 |
+ if (!error) error = CheckPivotRootPermission(&old_nd, &new_nd); |
649 |
+ /***** SAKURA Linux end. *****/ |
650 |
if (error) { |
651 |
path_release(&old_nd); |
652 |
goto out1; |
653 |
--- linux-2.6.21.orig/fs/open.c |
654 |
+++ linux-2.6.21/fs/open.c |
655 |
@@ -27,6 +27,12 @@ |
656 |
#include <linux/syscalls.h> |
657 |
#include <linux/rcupdate.h> |
658 |
#include <linux/audit.h> |
659 |
+/***** SAKURA Linux start. *****/ |
660 |
+#include <linux/sakura.h> |
661 |
+/***** SAKURA Linux end. *****/ |
662 |
+/***** TOMOYO Linux start. *****/ |
663 |
+#include <linux/tomoyo.h> |
664 |
+/***** TOMOYO Linux end. *****/ |
665 |
|
666 |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
667 |
{ |
668 |
@@ -264,6 +270,9 @@ static long do_sys_truncate(const char _ |
669 |
if (error) |
670 |
goto dput_and_out; |
671 |
|
672 |
+ /***** TOMOYO Linux start. *****/ |
673 |
+ if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0) |
674 |
+ /***** TOMOYO Linux end. *****/ |
675 |
error = locks_verify_truncate(inode, NULL, length); |
676 |
if (!error) { |
677 |
DQUOT_INIT(inode); |
678 |
@@ -317,6 +326,9 @@ static long do_sys_ftruncate(unsigned in |
679 |
if (IS_APPEND(inode)) |
680 |
goto out_putf; |
681 |
|
682 |
+ /***** TOMOYO Linux start. *****/ |
683 |
+ if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0) |
684 |
+ /***** TOMOYO Linux end. *****/ |
685 |
error = locks_verify_truncate(inode, file, length); |
686 |
if (!error) |
687 |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
688 |
@@ -481,6 +493,12 @@ asmlinkage long sys_chroot(const char __ |
689 |
error = -EPERM; |
690 |
if (!capable(CAP_SYS_CHROOT)) |
691 |
goto dput_and_out; |
692 |
+ /***** TOMOYO Linux start. *****/ |
693 |
+ if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) goto dput_and_out; |
694 |
+ /***** TOMOYO Linux end. *****/ |
695 |
+ /***** SAKURA Linux start. *****/ |
696 |
+ if (CheckChRootPermission(&nd)) goto dput_and_out; |
697 |
+ /***** SAKURA Linux end. *****/ |
698 |
|
699 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
700 |
set_fs_altroot(); |
701 |
@@ -1085,6 +1103,9 @@ EXPORT_SYMBOL(sys_close); |
702 |
*/ |
703 |
asmlinkage long sys_vhangup(void) |
704 |
{ |
705 |
+ /***** TOMOYO Linux start. *****/ |
706 |
+ if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0) |
707 |
+ /***** TOMOYO Linux end. *****/ |
708 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
709 |
/* XXX: this needs locking */ |
710 |
tty_vhangup(current->signal->tty); |
711 |
--- linux-2.6.21.orig/fs/proc/Makefile |
712 |
+++ linux-2.6.21/fs/proc/Makefile |
713 |
@@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE) += kcore.o |
714 |
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
715 |
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
716 |
proc-$(CONFIG_PRINTK) += kmsg.o |
717 |
+ |
718 |
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
719 |
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
720 |
--- linux-2.6.21.orig/fs/proc/proc_misc.c |
721 |
+++ linux-2.6.21/fs/proc/proc_misc.c |
722 |
@@ -747,4 +747,13 @@ void __init proc_misc_init(void) |
723 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
724 |
} |
725 |
#endif |
726 |
+ /***** CCS start. *****/ |
727 |
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
728 |
+ { |
729 |
+ extern void __init CCSProc_Init(void); |
730 |
+ CCSProc_Init(); |
731 |
+ printk("Hook version: 2.6.21 2008/01/05\n"); |
732 |
+ } |
733 |
+#endif |
734 |
+ /***** CCS end. *****/ |
735 |
} |
736 |
--- linux-2.6.21.orig/include/linux/init_task.h |
737 |
+++ linux-2.6.21/include/linux/init_task.h |
738 |
@@ -141,6 +141,10 @@ extern struct group_info init_groups; |
739 |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
740 |
INIT_TRACE_IRQFLAGS \ |
741 |
INIT_LOCKDEP \ |
742 |
+ /***** TOMOYO Linux start. *****/ \ |
743 |
+ .domain_info = &KERNEL_DOMAIN, \ |
744 |
+ .tomoyo_flags = 0, \ |
745 |
+ /***** TOMOYO Linux end. *****/ \ |
746 |
} |
747 |
|
748 |
|
749 |
--- linux-2.6.21.orig/include/linux/sched.h |
750 |
+++ linux-2.6.21/include/linux/sched.h |
751 |
@@ -27,6 +27,11 @@ |
752 |
#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ |
753 |
#define CLONE_NEWIPC 0x08000000 /* New ipcs */ |
754 |
|
755 |
+/***** TOMOYO Linux start. *****/ |
756 |
+struct domain_info; |
757 |
+extern struct domain_info KERNEL_DOMAIN; |
758 |
+/***** TOMOYO Linux end. *****/ |
759 |
+ |
760 |
/* |
761 |
* Scheduling policies |
762 |
*/ |
763 |
@@ -1052,6 +1057,10 @@ struct task_struct { |
764 |
#ifdef CONFIG_FAULT_INJECTION |
765 |
int make_it_fail; |
766 |
#endif |
767 |
+ /***** TOMOYO Linux start. *****/ |
768 |
+ struct domain_info *domain_info; |
769 |
+ u32 tomoyo_flags; |
770 |
+ /***** TOMOYO Linux end. *****/ |
771 |
}; |
772 |
|
773 |
static inline pid_t process_group(struct task_struct *tsk) |
774 |
--- linux-2.6.21.orig/kernel/compat.c |
775 |
+++ linux-2.6.21/kernel/compat.c |
776 |
@@ -25,6 +25,9 @@ |
777 |
#include <linux/posix-timers.h> |
778 |
|
779 |
#include <asm/uaccess.h> |
780 |
+/***** TOMOYO Linux start. *****/ |
781 |
+#include <linux/tomoyo.h> |
782 |
+/***** TOMOYO Linux end. *****/ |
783 |
|
784 |
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
785 |
{ |
786 |
@@ -869,6 +872,9 @@ asmlinkage long compat_sys_stime(compat_ |
787 |
err = security_settime(&tv, NULL); |
788 |
if (err) |
789 |
return err; |
790 |
+ /***** TOMOYO Linux start. *****/ |
791 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
792 |
+ /***** TOMOYO Linux end. *****/ |
793 |
|
794 |
do_settimeofday(&tv); |
795 |
return 0; |
796 |
--- linux-2.6.21.orig/kernel/kexec.c |
797 |
+++ linux-2.6.21/kernel/kexec.c |
798 |
@@ -28,6 +28,9 @@ |
799 |
#include <asm/io.h> |
800 |
#include <asm/system.h> |
801 |
#include <asm/semaphore.h> |
802 |
+/***** TOMOYO Linux start. *****/ |
803 |
+#include <linux/tomoyo.h> |
804 |
+/***** TOMOYO Linux end. *****/ |
805 |
|
806 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
807 |
note_buf_t* crash_notes; |
808 |
@@ -924,6 +927,9 @@ asmlinkage long sys_kexec_load(unsigned |
809 |
/* We only trust the superuser with rebooting the system. */ |
810 |
if (!capable(CAP_SYS_BOOT)) |
811 |
return -EPERM; |
812 |
+ /***** TOMOYO Linux start. *****/ |
813 |
+ if (CheckCapabilityACL(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM; |
814 |
+ /***** TOMOYO Linux end. *****/ |
815 |
|
816 |
/* |
817 |
* Verify we have a legal set of flags |
818 |
--- linux-2.6.21.orig/kernel/kmod.c |
819 |
+++ linux-2.6.21/kernel/kmod.c |
820 |
@@ -166,6 +166,11 @@ static int ____call_usermodehelper(void |
821 |
/* We can run anywhere, unlike our parent keventd(). */ |
822 |
set_cpus_allowed(current, CPU_MASK_ALL); |
823 |
|
824 |
+ /***** TOMOYO Linux start. *****/ |
825 |
+ current->domain_info = &KERNEL_DOMAIN; |
826 |
+ current->tomoyo_flags = 0; |
827 |
+ /***** TOMOYO Linux end. *****/ |
828 |
+ |
829 |
retval = -EPERM; |
830 |
if (current->fs->root) |
831 |
retval = kernel_execve(sub_info->path, |
832 |
--- linux-2.6.21.orig/kernel/module.c |
833 |
+++ linux-2.6.21/kernel/module.c |
834 |
@@ -44,6 +44,9 @@ |
835 |
#include <asm/semaphore.h> |
836 |
#include <asm/cacheflush.h> |
837 |
#include <linux/license.h> |
838 |
+/***** TOMOYO Linux start. *****/ |
839 |
+#include <linux/tomoyo.h> |
840 |
+/***** TOMOYO Linux end. *****/ |
841 |
|
842 |
#if 0 |
843 |
#define DEBUGP printk |
844 |
@@ -662,6 +665,9 @@ sys_delete_module(const char __user *nam |
845 |
|
846 |
if (!capable(CAP_SYS_MODULE)) |
847 |
return -EPERM; |
848 |
+ /***** TOMOYO Linux start. *****/ |
849 |
+ if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM; |
850 |
+ /***** TOMOYO Linux end. *****/ |
851 |
|
852 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
853 |
return -EFAULT; |
854 |
@@ -1983,6 +1989,9 @@ sys_init_module(void __user *umod, |
855 |
/* Must have permission */ |
856 |
if (!capable(CAP_SYS_MODULE)) |
857 |
return -EPERM; |
858 |
+ /***** TOMOYO Linux start. *****/ |
859 |
+ if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM; |
860 |
+ /***** TOMOYO Linux end. *****/ |
861 |
|
862 |
/* Only one module load at a time, please */ |
863 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
864 |
--- linux-2.6.21.orig/kernel/ptrace.c |
865 |
+++ linux-2.6.21/kernel/ptrace.c |
866 |
@@ -21,6 +21,9 @@ |
867 |
|
868 |
#include <asm/pgtable.h> |
869 |
#include <asm/uaccess.h> |
870 |
+/***** TOMOYO Linux start. *****/ |
871 |
+#include <linux/tomoyo.h> |
872 |
+/***** TOMOYO Linux end. *****/ |
873 |
|
874 |
/* |
875 |
* ptrace a task: make the debugger its new parent and |
876 |
@@ -456,6 +459,11 @@ asmlinkage long sys_ptrace(long request, |
877 |
/* |
878 |
* This lock_kernel fixes a subtle race with suid exec |
879 |
*/ |
880 |
+ /***** TOMOYO Linux start. *****/ |
881 |
+#ifdef TOMOYO_SYS_PTRACE |
882 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
883 |
+#endif |
884 |
+ /***** TOMOYO Linux end. *****/ |
885 |
lock_kernel(); |
886 |
if (request == PTRACE_TRACEME) { |
887 |
ret = ptrace_traceme(); |
888 |
--- linux-2.6.21.orig/kernel/sched.c |
889 |
+++ linux-2.6.21/kernel/sched.c |
890 |
@@ -55,6 +55,9 @@ |
891 |
#include <asm/tlb.h> |
892 |
|
893 |
#include <asm/unistd.h> |
894 |
+/***** TOMOYO Linux start. *****/ |
895 |
+#include <linux/tomoyo.h> |
896 |
+/***** TOMOYO Linux end. *****/ |
897 |
|
898 |
/* |
899 |
* Scheduler clock - returns current time in nanosec units. |
900 |
@@ -3960,6 +3963,9 @@ int can_nice(const struct task_struct *p |
901 |
asmlinkage long sys_nice(int increment) |
902 |
{ |
903 |
long nice, retval; |
904 |
+ /***** TOMOYO Linux start. *****/ |
905 |
+ if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM; |
906 |
+ /***** TOMOYO Linux end. *****/ |
907 |
|
908 |
/* |
909 |
* Setpriority might change our priority at the same moment. |
910 |
--- linux-2.6.21.orig/kernel/signal.c |
911 |
+++ linux-2.6.21/kernel/signal.c |
912 |
@@ -32,6 +32,9 @@ |
913 |
#include <asm/unistd.h> |
914 |
#include <asm/siginfo.h> |
915 |
#include "audit.h" /* audit_signal_info() */ |
916 |
+/***** TOMOYO Linux start. *****/ |
917 |
+#include <linux/tomoyo.h> |
918 |
+/***** TOMOYO Linux end. *****/ |
919 |
|
920 |
/* |
921 |
* SLAB caches for signal bits. |
922 |
@@ -2235,6 +2238,10 @@ asmlinkage long |
923 |
sys_kill(int pid, int sig) |
924 |
{ |
925 |
struct siginfo info; |
926 |
+ /***** TOMOYO Linux start. *****/ |
927 |
+ if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM; |
928 |
+ if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM; |
929 |
+ /***** TOMOYO Linux end. *****/ |
930 |
|
931 |
info.si_signo = sig; |
932 |
info.si_errno = 0; |
933 |
@@ -2293,6 +2300,10 @@ asmlinkage long sys_tgkill(int tgid, int |
934 |
/* This is only valid for single tasks */ |
935 |
if (pid <= 0 || tgid <= 0) |
936 |
return -EINVAL; |
937 |
+ /***** TOMOYO Linux start. *****/ |
938 |
+ if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM; |
939 |
+ if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM; |
940 |
+ /***** TOMOYO Linux end. *****/ |
941 |
|
942 |
return do_tkill(tgid, pid, sig); |
943 |
} |
944 |
@@ -2306,6 +2317,10 @@ sys_tkill(int pid, int sig) |
945 |
/* This is only valid for single tasks */ |
946 |
if (pid <= 0) |
947 |
return -EINVAL; |
948 |
+ /***** TOMOYO Linux start. *****/ |
949 |
+ if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM; |
950 |
+ if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM; |
951 |
+ /***** TOMOYO Linux end. *****/ |
952 |
|
953 |
return do_tkill(0, pid, sig); |
954 |
} |
955 |
--- linux-2.6.21.orig/kernel/sys.c |
956 |
+++ linux-2.6.21/kernel/sys.c |
957 |
@@ -37,6 +37,9 @@ |
958 |
#include <asm/uaccess.h> |
959 |
#include <asm/io.h> |
960 |
#include <asm/unistd.h> |
961 |
+/***** TOMOYO Linux start. *****/ |
962 |
+#include <linux/tomoyo.h> |
963 |
+/***** TOMOYO Linux end. *****/ |
964 |
|
965 |
#ifndef SET_UNALIGN_CTL |
966 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
967 |
@@ -600,6 +603,9 @@ asmlinkage long sys_setpriority(int whic |
968 |
|
969 |
if (which > 2 || which < 0) |
970 |
goto out; |
971 |
+ /***** TOMOYO Linux start. *****/ |
972 |
+ if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM; |
973 |
+ /***** TOMOYO Linux end. *****/ |
974 |
|
975 |
/* normalize: avoid signed division (rounding problems) */ |
976 |
error = -ESRCH; |
977 |
@@ -830,6 +836,9 @@ asmlinkage long sys_reboot(int magic1, i |
978 |
magic2 != LINUX_REBOOT_MAGIC2B && |
979 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
980 |
return -EINVAL; |
981 |
+ /***** TOMOYO Linux start. *****/ |
982 |
+ if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM; |
983 |
+ /***** TOMOYO Linux end. *****/ |
984 |
|
985 |
/* Instead of trying to make the power_off code look like |
986 |
* halt when pm_power_off is not set do it the easy way. |
987 |
@@ -1806,6 +1815,9 @@ asmlinkage long sys_sethostname(char __u |
988 |
return -EPERM; |
989 |
if (len < 0 || len > __NEW_UTS_LEN) |
990 |
return -EINVAL; |
991 |
+ /***** TOMOYO Linux start. *****/ |
992 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM; |
993 |
+ /***** TOMOYO Linux end. *****/ |
994 |
down_write(&uts_sem); |
995 |
errno = -EFAULT; |
996 |
if (!copy_from_user(tmp, name, len)) { |
997 |
@@ -1851,6 +1863,9 @@ asmlinkage long sys_setdomainname(char _ |
998 |
return -EPERM; |
999 |
if (len < 0 || len > __NEW_UTS_LEN) |
1000 |
return -EINVAL; |
1001 |
+ /***** TOMOYO Linux start. *****/ |
1002 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM; |
1003 |
+ /***** TOMOYO Linux end. *****/ |
1004 |
|
1005 |
down_write(&uts_sem); |
1006 |
errno = -EFAULT; |
1007 |
--- linux-2.6.21.orig/kernel/sysctl.c |
1008 |
+++ linux-2.6.21/kernel/sysctl.c |
1009 |
@@ -48,6 +48,9 @@ |
1010 |
|
1011 |
#include <asm/uaccess.h> |
1012 |
#include <asm/processor.h> |
1013 |
+/***** TOMOYO Linux start. *****/ |
1014 |
+#include <linux/tomoyo.h> |
1015 |
+/***** TOMOYO Linux end. *****/ |
1016 |
|
1017 |
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
1018 |
void __user *buffer, size_t *lenp, loff_t *ppos); |
1019 |
@@ -1088,6 +1091,81 @@ struct ctl_table_header *sysctl_head_nex |
1020 |
} |
1021 |
|
1022 |
#ifdef CONFIG_SYSCTL_SYSCALL |
1023 |
+ |
1024 |
+/***** TOMOYO Linux start. *****/ |
1025 |
+static int try_parse_table(int __user *name, int nlen, void __user *oldval, void __user *newval, ctl_table *table) |
1026 |
+{ |
1027 |
+ int n; |
1028 |
+ int error = -ENOMEM; |
1029 |
+ int op = 0; |
1030 |
+ char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); |
1031 |
+ if (oldval) op |= 004; |
1032 |
+ if (newval) op |= 002; |
1033 |
+ if (!op) { /* Neither read nor write */ |
1034 |
+ error = 0; |
1035 |
+ goto out; |
1036 |
+ } |
1037 |
+ if (!buffer) goto out; |
1038 |
+ memset(buffer, 0, PAGE_SIZE); |
1039 |
+ snprintf(buffer, PAGE_SIZE - 1, "/proc/sys"); |
1040 |
+ repeat: |
1041 |
+ if (!nlen) { |
1042 |
+ error = -ENOTDIR; |
1043 |
+ goto out; |
1044 |
+ } |
1045 |
+ if (get_user(n, name)) { |
1046 |
+ error = -EFAULT; |
1047 |
+ goto out; |
1048 |
+ } |
1049 |
+ for ( ; table->ctl_name || table->procname; table++) { |
1050 |
+ if (n == table->ctl_name && n) { |
1051 |
+ int pos = strlen(buffer); |
1052 |
+ const char *cp = table->procname; |
1053 |
+ error = -ENOMEM; |
1054 |
+ if (cp) { |
1055 |
+ if (pos + 1 >= PAGE_SIZE - 1) goto out; |
1056 |
+ buffer[pos++] = '/'; |
1057 |
+ while (*cp) { |
1058 |
+ const unsigned char c = * (const unsigned char *) cp; |
1059 |
+ if (c == '\\') { |
1060 |
+ if (pos + 2 >= PAGE_SIZE - 1) goto out; |
1061 |
+ buffer[pos++] = '\\'; |
1062 |
+ buffer[pos++] = '\\'; |
1063 |
+ } else if (c > ' ' && c < 127) { |
1064 |
+ if (pos + 1 >= PAGE_SIZE - 1) goto out; |
1065 |
+ buffer[pos++] = c; |
1066 |
+ } else { |
1067 |
+ if (pos + 4 >= PAGE_SIZE - 1) goto out; |
1068 |
+ buffer[pos++] = '\\'; |
1069 |
+ buffer[pos++] = (c >> 6) + '0'; |
1070 |
+ buffer[pos++] = ((c >> 3) & 7) + '0'; |
1071 |
+ buffer[pos++] = (c & 7) + '0'; |
1072 |
+ } |
1073 |
+ cp++; |
1074 |
+ } |
1075 |
+ } else { |
1076 |
+ /* Assume nobody assigns "=\$=" for procname. */ |
1077 |
+ snprintf(buffer + pos, PAGE_SIZE - pos - 1, "/=%d=", n); |
1078 |
+ if (memchr(buffer, '\0', PAGE_SIZE - 2) == NULL) goto out; |
1079 |
+ } |
1080 |
+ if (table->child) { |
1081 |
+ name++; |
1082 |
+ nlen--; |
1083 |
+ table = table->child; |
1084 |
+ goto repeat; |
1085 |
+ } |
1086 |
+ /* printk("sysctl='%s'\n", buffer); */ |
1087 |
+ error = CheckFilePerm(buffer, op, "sysctl"); |
1088 |
+ goto out; |
1089 |
+ } |
1090 |
+ } |
1091 |
+ error = -ENOTDIR; |
1092 |
+ out: |
1093 |
+ kfree(buffer); |
1094 |
+ return error; |
1095 |
+} |
1096 |
+/***** TOMOYO Linux end. *****/ |
1097 |
+ |
1098 |
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
1099 |
void __user *newval, size_t newlen) |
1100 |
{ |
1101 |
@@ -1104,6 +1182,9 @@ int do_sysctl(int __user *name, int nlen |
1102 |
|
1103 |
for (head = sysctl_head_next(NULL); head; |
1104 |
head = sysctl_head_next(head)) { |
1105 |
+ /***** TOMOYO Linux start. *****/ |
1106 |
+ if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0) |
1107 |
+ /***** TOMOYO Linux end. *****/ |
1108 |
error = parse_table(name, nlen, oldval, oldlenp, |
1109 |
newval, newlen, head->ctl_table); |
1110 |
if (error != -ENOTDIR) { |
1111 |
--- linux-2.6.21.orig/kernel/time.c |
1112 |
+++ linux-2.6.21/kernel/time.c |
1113 |
@@ -39,6 +39,9 @@ |
1114 |
|
1115 |
#include <asm/uaccess.h> |
1116 |
#include <asm/unistd.h> |
1117 |
+/***** TOMOYO Linux start. *****/ |
1118 |
+#include <linux/tomoyo.h> |
1119 |
+/***** TOMOYO Linux end. *****/ |
1120 |
|
1121 |
/* |
1122 |
* The timezone where the local system is located. Used as a default by some |
1123 |
@@ -91,6 +94,9 @@ asmlinkage long sys_stime(time_t __user |
1124 |
err = security_settime(&tv, NULL); |
1125 |
if (err) |
1126 |
return err; |
1127 |
+ /***** TOMOYO Linux start. *****/ |
1128 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
1129 |
+ /***** TOMOYO Linux end. *****/ |
1130 |
|
1131 |
do_settimeofday(&tv); |
1132 |
return 0; |
1133 |
@@ -161,6 +167,9 @@ int do_sys_settimeofday(struct timespec |
1134 |
error = security_settime(tv, tz); |
1135 |
if (error) |
1136 |
return error; |
1137 |
+ /***** TOMOYO Linux start. *****/ |
1138 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
1139 |
+ /***** TOMOYO Linux end. *****/ |
1140 |
|
1141 |
if (tz) { |
1142 |
/* SMP safe, global irq locking makes it work. */ |
1143 |
--- linux-2.6.21.orig/kernel/time/ntp.c |
1144 |
+++ linux-2.6.21/kernel/time/ntp.c |
1145 |
@@ -14,6 +14,9 @@ |
1146 |
|
1147 |
#include <asm/div64.h> |
1148 |
#include <asm/timex.h> |
1149 |
+/***** TOMOYO Linux start. *****/ |
1150 |
+#include <linux/tomoyo.h> |
1151 |
+/***** TOMOYO Linux end. *****/ |
1152 |
|
1153 |
/* |
1154 |
* Timekeeping variables |
1155 |
@@ -203,6 +206,9 @@ int do_adjtimex(struct timex *txc) |
1156 |
/* In order to modify anything, you gotta be super-user! */ |
1157 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
1158 |
return -EPERM; |
1159 |
+ /***** TOMOYO Linux start. *****/ |
1160 |
+ if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
1161 |
+ /***** TOMOYO Linux end. *****/ |
1162 |
|
1163 |
/* Now we validate the data before disabling interrupts */ |
1164 |
|
1165 |
--- linux-2.6.21.orig/net/core/datagram.c |
1166 |
+++ linux-2.6.21/net/core/datagram.c |
1167 |
@@ -56,6 +56,11 @@ |
1168 |
#include <net/sock.h> |
1169 |
#include <net/tcp_states.h> |
1170 |
|
1171 |
+/***** TOMOYO Linux start. *****/ |
1172 |
+#include <linux/tomoyo.h> |
1173 |
+#include <linux/tomoyo_socket.h> |
1174 |
+/***** TOMOYO Linux end. *****/ |
1175 |
+ |
1176 |
/* |
1177 |
* Is a socket 'connection oriented' ? |
1178 |
*/ |
1179 |
@@ -178,6 +183,10 @@ struct sk_buff *skb_recv_datagram(struct |
1180 |
} else |
1181 |
skb = skb_dequeue(&sk->sk_receive_queue); |
1182 |
|
1183 |
+ /***** TOMOYO Linux start. *****/ |
1184 |
+ if ((error = CheckSocketRecvDatagramPermission(sk, skb, flags)) < 0) goto no_packet; |
1185 |
+ /***** TOMOYO Linux end. *****/ |
1186 |
+ |
1187 |
if (skb) |
1188 |
return skb; |
1189 |
|
1190 |
--- linux-2.6.21.orig/net/ipv4/inet_connection_sock.c |
1191 |
+++ linux-2.6.21/net/ipv4/inet_connection_sock.c |
1192 |
@@ -23,6 +23,9 @@ |
1193 |
#include <net/route.h> |
1194 |
#include <net/tcp_states.h> |
1195 |
#include <net/xfrm.h> |
1196 |
+/***** SAKURA Linux start. *****/ |
1197 |
+#include <linux/sakura.h> |
1198 |
+/***** SAKURA Linux end. *****/ |
1199 |
|
1200 |
#ifdef INET_CSK_DEBUG |
1201 |
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
1202 |
@@ -87,6 +90,9 @@ int inet_csk_get_port(struct inet_hashin |
1203 |
do { |
1204 |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
1205 |
spin_lock(&head->lock); |
1206 |
+ /***** SAKURA Linux start. *****/ |
1207 |
+ if (SAKURA_MayAutobind(rover) < 0) goto next; |
1208 |
+ /***** SAKURA Linux end. *****/ |
1209 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
1210 |
if (tb->port == rover) |
1211 |
goto next; |
1212 |
--- linux-2.6.21.orig/net/ipv4/inet_hashtables.c |
1213 |
+++ linux-2.6.21/net/ipv4/inet_hashtables.c |
1214 |
@@ -22,6 +22,9 @@ |
1215 |
#include <net/inet_connection_sock.h> |
1216 |
#include <net/inet_hashtables.h> |
1217 |
#include <net/ip.h> |
1218 |
+/***** SAKURA Linux start. *****/ |
1219 |
+#include <linux/sakura.h> |
1220 |
+/***** SAKURA Linux end. *****/ |
1221 |
|
1222 |
/* |
1223 |
* Allocate and initialize a new local port bind bucket. |
1224 |
@@ -292,6 +295,9 @@ int inet_hash_connect(struct inet_timewa |
1225 |
local_bh_disable(); |
1226 |
for (i = 1; i <= range; i++) { |
1227 |
port = low + (i + offset) % range; |
1228 |
+ /***** SAKURA Linux start. *****/ |
1229 |
+ if (SAKURA_MayAutobind(port) < 0) continue; |
1230 |
+ /***** SAKURA Linux end. *****/ |
1231 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1232 |
spin_lock(&head->lock); |
1233 |
|
1234 |
--- linux-2.6.21.orig/net/ipv4/udp.c |
1235 |
+++ linux-2.6.21/net/ipv4/udp.c |
1236 |
@@ -102,6 +102,9 @@ |
1237 |
#include <net/checksum.h> |
1238 |
#include <net/xfrm.h> |
1239 |
#include "udp_impl.h" |
1240 |
+/***** SAKURA Linux start. *****/ |
1241 |
+#include <linux/sakura.h> |
1242 |
+/***** SAKURA Linux end. *****/ |
1243 |
|
1244 |
/* |
1245 |
* Snmp MIB for the UDP layer |
1246 |
@@ -162,6 +165,9 @@ int __udp_lib_get_port(struct sock *sk, |
1247 |
result = sysctl_local_port_range[0] + |
1248 |
((result - sysctl_local_port_range[0]) & |
1249 |
(UDP_HTABLE_SIZE - 1)); |
1250 |
+ /***** SAKURA Linux start. *****/ |
1251 |
+ if (SAKURA_MayAutobind(result) < 0) continue; |
1252 |
+ /***** SAKURA Linux end. *****/ |
1253 |
goto gotit; |
1254 |
} |
1255 |
size = 0; |
1256 |
@@ -180,6 +186,9 @@ int __udp_lib_get_port(struct sock *sk, |
1257 |
result = sysctl_local_port_range[0] |
1258 |
+ ((result - sysctl_local_port_range[0]) & |
1259 |
(UDP_HTABLE_SIZE - 1)); |
1260 |
+ /***** SAKURA Linux start. *****/ |
1261 |
+ if (SAKURA_MayAutobind(result) < 0) continue; |
1262 |
+ /***** SAKURA Linux end. *****/ |
1263 |
if (! __udp_lib_lport_inuse(result, udptable)) |
1264 |
break; |
1265 |
} |
1266 |
--- linux-2.6.21.orig/net/ipv6/inet6_hashtables.c |
1267 |
+++ linux-2.6.21/net/ipv6/inet6_hashtables.c |
1268 |
@@ -21,6 +21,9 @@ |
1269 |
#include <net/inet_hashtables.h> |
1270 |
#include <net/inet6_hashtables.h> |
1271 |
#include <net/ip.h> |
1272 |
+/***** SAKURA Linux start. *****/ |
1273 |
+#include <linux/sakura.h> |
1274 |
+/***** SAKURA Linux end. *****/ |
1275 |
|
1276 |
void __inet6_hash(struct inet_hashinfo *hashinfo, |
1277 |
struct sock *sk) |
1278 |
@@ -266,6 +269,9 @@ int inet6_hash_connect(struct inet_timew |
1279 |
local_bh_disable(); |
1280 |
for (i = 1; i <= range; i++) { |
1281 |
port = low + (i + offset) % range; |
1282 |
+ /***** SAKURA Linux start. *****/ |
1283 |
+ if (SAKURA_MayAutobind(port) < 0) continue; |
1284 |
+ /***** SAKURA Linux end. *****/ |
1285 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1286 |
spin_lock(&head->lock); |
1287 |
|
1288 |
--- linux-2.6.21.orig/net/socket.c |
1289 |
+++ linux-2.6.21/net/socket.c |
1290 |
@@ -93,6 +93,11 @@ |
1291 |
#include <net/sock.h> |
1292 |
#include <linux/netfilter.h> |
1293 |
|
1294 |
+/***** TOMOYO Linux start. *****/ |
1295 |
+#include <linux/tomoyo.h> |
1296 |
+#include <linux/tomoyo_socket.h> |
1297 |
+/***** TOMOYO Linux end. *****/ |
1298 |
+ |
1299 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1300 |
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, |
1301 |
unsigned long nr_segs, loff_t pos); |
1302 |
@@ -549,6 +554,9 @@ static inline int __sock_sendmsg(struct |
1303 |
err = security_socket_sendmsg(sock, msg, size); |
1304 |
if (err) |
1305 |
return err; |
1306 |
+ /***** TOMOYO Linux start. *****/ |
1307 |
+ if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM; |
1308 |
+ /***** TOMOYO Linux end. *****/ |
1309 |
|
1310 |
return sock->ops->sendmsg(iocb, sock, msg, size); |
1311 |
} |
1312 |
@@ -1070,6 +1078,10 @@ static int __sock_create(int family, int |
1313 |
family = PF_PACKET; |
1314 |
} |
1315 |
|
1316 |
+ /***** TOMOYO Linux start. *****/ |
1317 |
+ if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err; |
1318 |
+ /***** TOMOYO Linux end. *****/ |
1319 |
+ |
1320 |
err = security_socket_create(family, type, protocol, kern); |
1321 |
if (err) |
1322 |
return err; |
1323 |
@@ -1298,6 +1310,9 @@ asmlinkage long sys_bind(int fd, struct |
1324 |
err = security_socket_bind(sock, |
1325 |
(struct sockaddr *)address, |
1326 |
addrlen); |
1327 |
+ /***** TOMOYO Linux start. *****/ |
1328 |
+ if (!err) err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen); |
1329 |
+ /***** TOMOYO Linux end. *****/ |
1330 |
if (!err) |
1331 |
err = sock->ops->bind(sock, |
1332 |
(struct sockaddr *) |
1333 |
@@ -1327,6 +1342,9 @@ asmlinkage long sys_listen(int fd, int b |
1334 |
backlog = sysctl_somaxconn; |
1335 |
|
1336 |
err = security_socket_listen(sock, backlog); |
1337 |
+ /***** TOMOYO Linux start. *****/ |
1338 |
+ if (!err) err = CheckSocketListenPermission(sock); |
1339 |
+ /***** TOMOYO Linux end. *****/ |
1340 |
if (!err) |
1341 |
err = sock->ops->listen(sock, backlog); |
1342 |
|
1343 |
@@ -1391,6 +1409,12 @@ asmlinkage long sys_accept(int fd, struc |
1344 |
if (err < 0) |
1345 |
goto out_fd; |
1346 |
|
1347 |
+ /***** TOMOYO Linux start. *****/ |
1348 |
+ if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) { |
1349 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1350 |
+ goto out_fd; |
1351 |
+ } |
1352 |
+ /***** TOMOYO Linux end. *****/ |
1353 |
if (upeer_sockaddr) { |
1354 |
if (newsock->ops->getname(newsock, (struct sockaddr *)address, |
1355 |
&len, 2) < 0) { |
1356 |
@@ -1455,6 +1479,10 @@ asmlinkage long sys_connect(int fd, stru |
1357 |
security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1358 |
if (err) |
1359 |
goto out_put; |
1360 |
+ /***** TOMOYO Linux start. *****/ |
1361 |
+ err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen); |
1362 |
+ if (err) goto out_put; |
1363 |
+ /***** TOMOYO Linux end. *****/ |
1364 |
|
1365 |
err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen, |
1366 |
sock->file->f_flags); |
1367 |
--- linux-2.6.21.orig/net/unix/af_unix.c |
1368 |
+++ linux-2.6.21/net/unix/af_unix.c |
1369 |
@@ -116,6 +116,9 @@ |
1370 |
#include <linux/mount.h> |
1371 |
#include <net/checksum.h> |
1372 |
#include <linux/security.h> |
1373 |
+/***** TOMOYO Linux start. *****/ |
1374 |
+#include <linux/tomoyo.h> |
1375 |
+/***** TOMOYO Linux end. *****/ |
1376 |
|
1377 |
int sysctl_unix_max_dgram_qlen __read_mostly = 10; |
1378 |
|
1379 |
@@ -765,6 +768,10 @@ static int unix_bind(struct socket *sock |
1380 |
err = unix_autobind(sock); |
1381 |
goto out; |
1382 |
} |
1383 |
+ /***** TOMOYO Linux start. *****/ |
1384 |
+ err = -EPERM; |
1385 |
+ if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out; |
1386 |
+ /***** TOMOYO Linux end. *****/ |
1387 |
|
1388 |
err = unix_mkname(sunaddr, addr_len, &hash); |
1389 |
if (err < 0) |
1390 |
@@ -808,6 +815,9 @@ static int unix_bind(struct socket *sock |
1391 |
*/ |
1392 |
mode = S_IFSOCK | |
1393 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1394 |
+ /***** TOMOYO Linux start. *****/ |
1395 |
+ if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0) |
1396 |
+ /***** TOMOYO Linux end. *****/ |
1397 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1398 |
if (err) |
1399 |
goto out_mknod_dput; |
1400 |
--- linux-2.6.21.orig/arch/powerpc/kernel/ptrace32.c |
1401 |
+++ linux-2.6.21/arch/powerpc/kernel/ptrace32.c |
1402 |
@@ -32,6 +32,9 @@ |
1403 |
#include <asm/page.h> |
1404 |
#include <asm/pgtable.h> |
1405 |
#include <asm/system.h> |
1406 |
+/***** TOMOYO Linux start. *****/ |
1407 |
+#include <linux/tomoyo.h> |
1408 |
+/***** TOMOYO Linux end. *****/ |
1409 |
|
1410 |
#include "ptrace-common.h" |
1411 |
|
1412 |
@@ -45,6 +48,11 @@ long compat_sys_ptrace(int request, int |
1413 |
{ |
1414 |
struct task_struct *child; |
1415 |
int ret; |
1416 |
+ /***** TOMOYO Linux start. *****/ |
1417 |
+#ifdef TOMOYO_SYS_PTRACE |
1418 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
1419 |
+#endif |
1420 |
+ /***** TOMOYO Linux end. *****/ |
1421 |
|
1422 |
lock_kernel(); |
1423 |
if (request == PTRACE_TRACEME) { |
1424 |
--- linux-2.6.21.orig/arch/sh64/kernel/ptrace.c |
1425 |
+++ linux-2.6.21/arch/sh64/kernel/ptrace.c |
1426 |
@@ -35,6 +35,9 @@ |
1427 |
#include <asm/system.h> |
1428 |
#include <asm/processor.h> |
1429 |
#include <asm/mmu_context.h> |
1430 |
+/***** TOMOYO Linux start. *****/ |
1431 |
+#include <linux/tomoyo.h> |
1432 |
+/***** TOMOYO Linux end. *****/ |
1433 |
|
1434 |
/* This mask defines the bits of the SR which the user is not allowed to |
1435 |
change, which are everything except S, Q, M, PR, SZ, FR. */ |
1436 |
@@ -271,6 +274,11 @@ asmlinkage int sh64_ptrace(long request, |
1437 |
extern void poke_real_address_q(unsigned long long addr, unsigned long long data); |
1438 |
#define WPC_DBRMODE 0x0d104008 |
1439 |
static int first_call = 1; |
1440 |
+ /***** TOMOYO Linux start. *****/ |
1441 |
+#ifdef TOMOYO_SYS_PTRACE |
1442 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
1443 |
+#endif |
1444 |
+ /***** TOMOYO Linux end. *****/ |
1445 |
|
1446 |
lock_kernel(); |
1447 |
if (first_call) { |
1448 |
--- linux-2.6.21.orig/arch/x86_64/ia32/ptrace32.c |
1449 |
+++ linux-2.6.21/arch/x86_64/ia32/ptrace32.c |
1450 |
@@ -26,6 +26,9 @@ |
1451 |
#include <asm/i387.h> |
1452 |
#include <asm/fpu32.h> |
1453 |
#include <asm/ia32.h> |
1454 |
+/***** TOMOYO Linux start. *****/ |
1455 |
+#include <linux/tomoyo.h> |
1456 |
+/***** TOMOYO Linux end. *****/ |
1457 |
|
1458 |
/* |
1459 |
* Determines which flags the user has access to [1 = access, 0 = no access]. |
1460 |
@@ -234,6 +237,11 @@ asmlinkage long sys32_ptrace(long reques |
1461 |
void __user *datap = compat_ptr(data); |
1462 |
int ret; |
1463 |
__u32 val; |
1464 |
+ /***** TOMOYO Linux start. *****/ |
1465 |
+#ifdef TOMOYO_SYS_PTRACE |
1466 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
1467 |
+#endif |
1468 |
+ /***** TOMOYO Linux end. *****/ |
1469 |
|
1470 |
switch (request) { |
1471 |
case PTRACE_TRACEME: |