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