2 |
|
|
3 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.7.tar.bz2 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.7.tar.bz2 |
4 |
--- |
--- |
5 |
arch/alpha/kernel/ptrace.c | 9 +++ |
arch/alpha/kernel/ptrace.c | 7 +++++ |
6 |
arch/ia64/ia32/sys_ia32.c | 9 +++ |
arch/ia64/ia32/sys_ia32.c | 7 +++++ |
7 |
arch/ia64/kernel/ptrace.c | 9 +++ |
arch/ia64/kernel/ptrace.c | 7 +++++ |
8 |
arch/m32r/kernel/ptrace.c | 9 +++ |
arch/m32r/kernel/ptrace.c | 7 +++++ |
9 |
arch/mips/kernel/ptrace32.c | 9 +++ |
arch/mips/kernel/ptrace32.c | 7 +++++ |
10 |
arch/powerpc/kernel/ptrace32.c | 9 +++ |
arch/powerpc/kernel/ptrace32.c | 7 +++++ |
11 |
arch/s390/kernel/ptrace.c | 9 +++ |
arch/s390/kernel/ptrace.c | 7 +++++ |
12 |
arch/sparc/kernel/ptrace.c | 11 +++ |
arch/sparc/kernel/ptrace.c | 9 ++++++ |
13 |
arch/sparc64/kernel/ptrace.c | 11 +++ |
arch/sparc64/kernel/ptrace.c | 9 ++++++ |
14 |
arch/x86_64/ia32/ptrace32.c | 9 +++ |
arch/x86_64/ia32/ptrace32.c | 7 +++++ |
15 |
fs/Kconfig | 2 |
fs/Kconfig | 2 + |
16 |
fs/Makefile | 2 |
fs/Makefile | 2 + |
17 |
fs/attr.c | 19 ++++++ |
fs/attr.c | 11 ++++++++ |
18 |
fs/compat.c | 11 +++ |
fs/compat.c | 15 ++++++++++ |
19 |
fs/exec.c | 20 ++++++- |
fs/exec.c | 17 +++++++++++- |
20 |
fs/fcntl.c | 9 +++ |
fs/fcntl.c | 9 ++++++ |
21 |
fs/ioctl.c | 7 ++ |
fs/ioctl.c | 11 ++++++++ |
22 |
fs/namei.c | 112 ++++++++++++++++++++++++++++++++++++++++ |
fs/namei.c | 55 ++++++++++++++++++++++++++++++++++++++++ |
23 |
fs/namespace.c | 49 +++++++++++++++++ |
fs/namespace.c | 49 +++++++++++++++++++++++++++++++++++ |
24 |
fs/open.c | 27 +++++++++ |
fs/open.c | 28 ++++++++++++++++++++ |
25 |
fs/proc/Makefile | 3 + |
fs/proc/Makefile | 3 ++ |
26 |
fs/proc/proc_misc.c | 5 + |
fs/proc/proc_misc.c | 5 +++ |
27 |
include/linux/init_task.h | 4 + |
include/linux/init_task.h | 4 ++ |
28 |
include/linux/sched.h | 9 +++ |
include/linux/sched.h | 8 +++++ |
29 |
kernel/compat.c | 7 ++ |
kernel/compat.c | 7 +++++ |
30 |
kernel/kexec.c | 7 ++ |
kernel/kexec.c | 7 +++++ |
31 |
kernel/kmod.c | 5 + |
kernel/kmod.c | 5 +++ |
32 |
kernel/module.c | 11 +++ |
kernel/module.c | 11 ++++++++ |
33 |
kernel/ptrace.c | 9 +++ |
kernel/ptrace.c | 7 +++++ |
34 |
kernel/sched.c | 7 ++ |
kernel/sched.c | 7 +++++ |
35 |
kernel/signal.c | 21 +++++++ |
kernel/signal.c | 21 +++++++++++++++ |
36 |
kernel/sys.c | 21 +++++++ |
kernel/sys.c | 21 +++++++++++++++ |
37 |
kernel/sysctl.c | 95 +++++++++++++++++++++++++++++++++ |
kernel/sysctl.c | 9 ++++++ |
38 |
kernel/time.c | 11 +++ |
kernel/time.c | 11 ++++++++ |
39 |
kernel/time/ntp.c | 7 ++ |
kernel/time/ntp.c | 7 +++++ |
40 |
net/core/datagram.c | 11 +++ |
net/ipv4/inet_connection_sock.c | 7 +++++ |
41 |
net/ipv4/inet_connection_sock.c | 7 ++ |
net/ipv4/inet_hashtables.c | 7 +++++ |
42 |
net/ipv4/inet_hashtables.c | 7 ++ |
net/ipv4/raw.c | 8 +++++ |
43 |
net/ipv4/udp.c | 11 +++ |
net/ipv4/udp.c | 19 +++++++++++++ |
44 |
net/ipv6/inet6_hashtables.c | 7 ++ |
net/ipv6/inet6_hashtables.c | 7 +++++ |
45 |
net/socket.c | 41 ++++++++++++++ |
net/ipv6/raw.c | 8 +++++ |
46 |
net/unix/af_unix.c | 15 +++++ |
net/ipv6/udp.c | 8 +++++ |
47 |
42 files changed, 671 insertions(+), 2 deletions(-) |
net/socket.c | 41 +++++++++++++++++++++++++++++ |
48 |
|
net/unix/af_unix.c | 8 +++++ |
49 |
|
44 files changed, 517 insertions(+), 2 deletions(-) |
50 |
|
|
51 |
--- linux-2.6.21.7.orig/arch/alpha/kernel/ptrace.c |
--- linux-2.6.21.7.orig/arch/alpha/kernel/ptrace.c |
52 |
+++ linux-2.6.21.7/arch/alpha/kernel/ptrace.c |
+++ linux-2.6.21.7/arch/alpha/kernel/ptrace.c |
60 |
|
|
61 |
#include "proto.h" |
#include "proto.h" |
62 |
|
|
63 |
@@ -268,6 +271,12 @@ do_sys_ptrace(long request, long pid, lo |
@@ -268,6 +271,10 @@ do_sys_ptrace(long request, long pid, lo |
64 |
unsigned long tmp; |
unsigned long tmp; |
65 |
size_t copied; |
size_t copied; |
66 |
long ret; |
long ret; |
67 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
68 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
69 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
70 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
71 |
|
|
72 |
lock_kernel(); |
lock_kernel(); |
83 |
|
|
84 |
#include "ia32priv.h" |
#include "ia32priv.h" |
85 |
|
|
86 |
@@ -1758,6 +1761,12 @@ sys32_ptrace (int request, pid_t pid, un |
@@ -1758,6 +1761,10 @@ sys32_ptrace (int request, pid_t pid, un |
87 |
struct task_struct *child; |
struct task_struct *child; |
88 |
unsigned int value, tmp; |
unsigned int value, tmp; |
89 |
long i, ret; |
long i, ret; |
90 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
91 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
92 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
93 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
94 |
|
|
95 |
lock_kernel(); |
lock_kernel(); |
106 |
|
|
107 |
#include "entry.h" |
#include "entry.h" |
108 |
|
|
109 |
@@ -1418,6 +1421,12 @@ sys_ptrace (long request, pid_t pid, uns |
@@ -1418,6 +1421,10 @@ sys_ptrace (long request, pid_t pid, uns |
110 |
struct task_struct *child; |
struct task_struct *child; |
111 |
struct switch_stack *sw; |
struct switch_stack *sw; |
112 |
long ret; |
long ret; |
113 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
114 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
115 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
116 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
117 |
|
|
118 |
lock_kernel(); |
lock_kernel(); |
129 |
|
|
130 |
/* |
/* |
131 |
* This routine will get a word off of the process kernel stack. |
* This routine will get a word off of the process kernel stack. |
132 |
@@ -742,6 +745,12 @@ asmlinkage long sys_ptrace(long request, |
@@ -742,6 +745,10 @@ asmlinkage long sys_ptrace(long request, |
133 |
{ |
{ |
134 |
struct task_struct *child; |
struct task_struct *child; |
135 |
int ret; |
int ret; |
136 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
137 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
138 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
139 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
140 |
|
|
141 |
lock_kernel(); |
lock_kernel(); |
152 |
|
|
153 |
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
154 |
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
155 |
@@ -50,6 +53,12 @@ asmlinkage int sys32_ptrace(int request, |
@@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request, |
156 |
{ |
{ |
157 |
struct task_struct *child; |
struct task_struct *child; |
158 |
int ret; |
int ret; |
159 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
160 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
161 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
162 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
163 |
|
|
164 |
#if 0 |
#if 0 |
175 |
|
|
176 |
#include "ptrace-common.h" |
#include "ptrace-common.h" |
177 |
|
|
178 |
@@ -45,6 +48,12 @@ long compat_sys_ptrace(int request, int |
@@ -45,6 +48,10 @@ long compat_sys_ptrace(int request, int |
179 |
{ |
{ |
180 |
struct task_struct *child; |
struct task_struct *child; |
181 |
int ret; |
int ret; |
182 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
183 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
184 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
185 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
186 |
|
|
187 |
lock_kernel(); |
lock_kernel(); |
198 |
|
|
199 |
#ifdef CONFIG_COMPAT |
#ifdef CONFIG_COMPAT |
200 |
#include "compat_ptrace.h" |
#include "compat_ptrace.h" |
201 |
@@ -713,6 +716,12 @@ sys_ptrace(long request, long pid, long |
@@ -713,6 +716,10 @@ sys_ptrace(long request, long pid, long |
202 |
struct task_struct *child; |
struct task_struct *child; |
203 |
int ret; |
int ret; |
204 |
|
|
205 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
206 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
207 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
208 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
209 |
lock_kernel(); |
lock_kernel(); |
210 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
221 |
|
|
222 |
#define MAGIC_CONSTANT 0x80000000 |
#define MAGIC_CONSTANT 0x80000000 |
223 |
|
|
224 |
@@ -267,6 +270,14 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -267,6 +270,12 @@ asmlinkage void do_ptrace(struct pt_regs |
225 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
226 |
struct task_struct *child; |
struct task_struct *child; |
227 |
int ret; |
int ret; |
228 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
229 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) { |
|
230 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
231 |
+ return; |
+ return; |
232 |
+ } |
+ } |
|
+#endif |
|
233 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
234 |
|
|
235 |
lock_kernel(); |
lock_kernel(); |
246 |
|
|
247 |
/* Returning from ptrace is a bit tricky because the syscall return |
/* Returning from ptrace is a bit tricky because the syscall return |
248 |
* low level code assumes any value returned which is negative and |
* low level code assumes any value returned which is negative and |
249 |
@@ -176,6 +179,14 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -176,6 +179,12 @@ asmlinkage void do_ptrace(struct pt_regs |
250 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
251 |
struct task_struct *child; |
struct task_struct *child; |
252 |
int ret; |
int ret; |
253 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
254 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) { |
|
255 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
256 |
+ return; |
+ return; |
257 |
+ } |
+ } |
|
+#endif |
|
258 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
259 |
|
|
260 |
if (test_thread_flag(TIF_32BIT)) { |
if (test_thread_flag(TIF_32BIT)) { |
271 |
|
|
272 |
/* |
/* |
273 |
* Determines which flags the user has access to [1 = access, 0 = no access]. |
* Determines which flags the user has access to [1 = access, 0 = no access]. |
274 |
@@ -234,6 +237,12 @@ asmlinkage long sys32_ptrace(long reques |
@@ -234,6 +237,10 @@ asmlinkage long sys32_ptrace(long reques |
275 |
void __user *datap = compat_ptr(data); |
void __user *datap = compat_ptr(data); |
276 |
int ret; |
int ret; |
277 |
__u32 val; |
__u32 val; |
278 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
279 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
280 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
281 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
282 |
|
|
283 |
switch (request) { |
switch (request) { |
312 |
|
|
313 |
/* Taken over from the old code... */ |
/* Taken over from the old code... */ |
314 |
|
|
315 |
@@ -145,12 +148,28 @@ int notify_change(struct dentry * dentry |
@@ -145,12 +148,20 @@ int notify_change(struct dentry * dentry |
316 |
|
|
317 |
if (inode->i_op && inode->i_op->setattr) { |
if (inode->i_op && inode->i_op->setattr) { |
318 |
error = security_inode_setattr(dentry, attr); |
error = security_inode_setattr(dentry, attr); |
319 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
320 |
+ if (!error && (ia_valid & ATTR_MODE) && |
+ if (!error) |
321 |
+ !ccs_capable(TOMOYO_SYS_CHMOD)) |
+ error = ccs_check_setattr_permission(dentry, attr); |
|
+ error = -EPERM; |
|
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && |
|
|
+ !ccs_capable(TOMOYO_SYS_CHOWN)) |
|
|
+ error = -EPERM; |
|
322 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
323 |
if (!error) |
if (!error) |
324 |
error = inode->i_op->setattr(dentry, attr); |
error = inode->i_op->setattr(dentry, attr); |
327 |
if (!error) |
if (!error) |
328 |
error = security_inode_setattr(dentry, attr); |
error = security_inode_setattr(dentry, attr); |
329 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
330 |
+ if (!error && (ia_valid & ATTR_MODE) && |
+ if (!error) |
331 |
+ !ccs_capable(TOMOYO_SYS_CHMOD)) |
+ error = ccs_check_setattr_permission(dentry, attr); |
|
+ error = -EPERM; |
|
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && |
|
|
+ !ccs_capable(TOMOYO_SYS_CHOWN)) |
|
|
+ error = -EPERM; |
|
332 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
333 |
if (!error) { |
if (!error) { |
334 |
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
345 |
|
|
346 |
int compat_log = 1; |
int compat_log = 1; |
347 |
|
|
348 |
@@ -422,6 +425,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
@@ -398,6 +401,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
349 |
|
|
350 |
|
/* RED-PEN how should LSM module know it's handling 32bit? */ |
351 |
|
error = security_file_ioctl(filp, cmd, arg); |
352 |
|
+ /***** TOMOYO Linux start. *****/ |
353 |
|
+ if (!error) |
354 |
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
355 |
|
+ /***** TOMOYO Linux end. *****/ |
356 |
|
if (error) |
357 |
|
goto out_fput; |
358 |
|
|
359 |
|
@@ -422,6 +429,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
360 |
/*FALL THROUGH*/ |
/*FALL THROUGH*/ |
361 |
|
|
362 |
default: |
default: |
363 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
364 |
+ if (!ccs_capable(TOMOYO_SYS_IOCTL)) { |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
365 |
+ error = -EPERM; |
+ error = -EPERM; |
366 |
+ goto out_fput; |
+ goto out_fput; |
367 |
+ } |
+ } |
369 |
if (filp->f_op && filp->f_op->compat_ioctl) { |
if (filp->f_op && filp->f_op->compat_ioctl) { |
370 |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
371 |
if (error != -ENOIOCTLCMD) |
if (error != -ENOIOCTLCMD) |
372 |
@@ -1552,7 +1561,7 @@ int compat_do_execve(char * filename, |
@@ -1552,7 +1565,7 @@ int compat_do_execve(char * filename, |
373 |
if (retval < 0) |
if (retval < 0) |
374 |
goto out; |
goto out; |
375 |
|
|
376 |
- retval = search_binary_handler(bprm, regs); |
- retval = search_binary_handler(bprm, regs); |
377 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
378 |
if (retval >= 0) { |
if (retval >= 0) { |
379 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
380 |
|
|
391 |
int core_uses_pid; |
int core_uses_pid; |
392 |
char core_pattern[128] = "core"; |
char core_pattern[128] = "core"; |
393 |
int suid_dumpable = 0; |
int suid_dumpable = 0; |
394 |
@@ -140,6 +144,13 @@ asmlinkage long sys_uselib(const char __ |
@@ -140,6 +144,12 @@ asmlinkage long sys_uselib(const char __ |
395 |
if (error) |
if (error) |
396 |
goto exit; |
goto exit; |
397 |
|
|
398 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
399 |
+ /* 01 means "read". */ |
+ error = ccs_check_uselib_permission(nd.dentry, nd.mnt); |
|
+ error = ccs_check_open_permission(nd.dentry, nd.mnt, 01); |
|
400 |
+ if (error) |
+ if (error) |
401 |
+ goto exit; |
+ goto exit; |
402 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
404 |
file = nameidata_to_filp(&nd, O_RDONLY); |
file = nameidata_to_filp(&nd, O_RDONLY); |
405 |
error = PTR_ERR(file); |
error = PTR_ERR(file); |
406 |
if (IS_ERR(file)) |
if (IS_ERR(file)) |
407 |
@@ -485,6 +496,13 @@ struct file *open_exec(const char *name) |
@@ -485,6 +495,11 @@ struct file *open_exec(const char *name) |
408 |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
409 |
S_ISREG(inode->i_mode)) { |
S_ISREG(inode->i_mode)) { |
410 |
int err = vfs_permission(&nd, MAY_EXEC); |
int err = vfs_permission(&nd, MAY_EXEC); |
411 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
412 |
+ if (!err && (current->tomoyo_flags & |
+ if (!err) |
413 |
+ TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) |
+ err = ccs_check_open_exec_permission(nd.dentry, |
414 |
+ /* 01 means "read". */ |
+ nd.mnt); |
|
+ err = ccs_check_open_permission(nd.dentry, |
|
|
+ nd.mnt, 01); |
|
415 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
416 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
417 |
if (!err) { |
if (!err) { |
418 |
file = nameidata_to_filp(&nd, O_RDONLY); |
file = nameidata_to_filp(&nd, O_RDONLY); |
419 |
@@ -1183,7 +1201,7 @@ int do_execve(char * filename, |
@@ -1183,7 +1198,7 @@ int do_execve(char * filename, |
420 |
if (retval < 0) |
if (retval < 0) |
421 |
goto out; |
goto out; |
422 |
|
|
423 |
- retval = search_binary_handler(bprm,regs); |
- retval = search_binary_handler(bprm,regs); |
424 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
425 |
if (retval >= 0) { |
if (retval >= 0) { |
426 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
427 |
|
|
467 |
if (!filp->f_op) |
if (!filp->f_op) |
468 |
goto out; |
goto out; |
469 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
470 |
+ if (!ccs_capable(TOMOYO_SYS_IOCTL)) |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
471 |
+ return -EPERM; |
+ return -EPERM; |
472 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
473 |
|
|
474 |
if (filp->f_op->unlocked_ioctl) { |
if (filp->f_op->unlocked_ioctl) { |
475 |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
476 |
|
@@ -167,6 +174,10 @@ asmlinkage long sys_ioctl(unsigned int f |
477 |
|
goto out; |
478 |
|
|
479 |
|
error = security_file_ioctl(filp, cmd, arg); |
480 |
|
+ /***** TOMOYO Linux start. *****/ |
481 |
|
+ if (!error) |
482 |
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
483 |
|
+ /***** TOMOYO Linux end. *****/ |
484 |
|
if (error) |
485 |
|
goto out_fput; |
486 |
|
|
487 |
--- linux-2.6.21.7.orig/fs/namei.c |
--- linux-2.6.21.7.orig/fs/namei.c |
488 |
+++ linux-2.6.21.7/fs/namei.c |
+++ linux-2.6.21.7/fs/namei.c |
489 |
@@ -37,6 +37,10 @@ |
@@ -37,6 +37,10 @@ |
497 |
/* [Feb-1997 T. Schoebel-Theuer] |
/* [Feb-1997 T. Schoebel-Theuer] |
498 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
* Fundamental changes in the pathname lookup mechanisms (namei) |
499 |
* were necessary because of omirr. The reason is that omirr needs |
* were necessary because of omirr. The reason is that omirr needs |
500 |
@@ -1506,6 +1510,13 @@ int vfs_create(struct inode *dir, struct |
@@ -1561,6 +1565,13 @@ int may_open(struct nameidata *nd, int a |
|
error = security_inode_create(dir, dentry, mode); |
|
|
if (error) |
|
|
return error; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (nd) { |
|
|
+ error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt); |
|
|
+ if (error) |
|
|
+ return error; |
|
|
+ } |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
DQUOT_INIT(dir); |
|
|
error = dir->i_op->create(dir, dentry, mode, nd); |
|
|
if (!error) |
|
|
@@ -1561,6 +1572,13 @@ int may_open(struct nameidata *nd, int a |
|
501 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
502 |
return -EPERM; |
return -EPERM; |
503 |
|
|
511 |
/* |
/* |
512 |
* Ensure there are no outstanding leases on the file. |
* Ensure there are no outstanding leases on the file. |
513 |
*/ |
*/ |
514 |
@@ -1610,6 +1628,9 @@ static int open_namei_create(struct name |
@@ -1600,6 +1611,11 @@ static int open_namei_create(struct name |
515 |
|
|
516 |
|
if (!IS_POSIXACL(dir->d_inode)) |
517 |
|
mode &= ~current->fs->umask; |
518 |
|
+ /***** TOMOYO Linux start. *****/ |
519 |
|
+ error = ccs_check_mknod_permission(dir->d_inode, path->dentry, nd->mnt, |
520 |
|
+ mode, 0); |
521 |
|
+ if (!error) |
522 |
|
+ /***** TOMOYO Linux end. *****/ |
523 |
|
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
524 |
|
mutex_unlock(&dir->d_inode->i_mutex); |
525 |
|
dput(nd->dentry); |
526 |
|
@@ -1610,6 +1626,9 @@ static int open_namei_create(struct name |
527 |
return may_open(nd, 0, flag & ~O_TRUNC); |
return may_open(nd, 0, flag & ~O_TRUNC); |
528 |
} |
} |
529 |
|
|
533 |
/* |
/* |
534 |
* open_namei() |
* open_namei() |
535 |
* |
* |
536 |
@@ -1870,6 +1891,16 @@ asmlinkage long sys_mknodat(int dfd, con |
@@ -1883,6 +1902,12 @@ asmlinkage long sys_mknodat(int dfd, con |
537 |
|
if (!IS_POSIXACL(nd.dentry->d_inode)) |
538 |
if (S_ISDIR(mode)) |
mode &= ~current->fs->umask; |
539 |
return -EPERM; |
if (!IS_ERR(dentry)) { |
540 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
541 |
+ if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV)) |
+ error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
542 |
+ return -EPERM; |
+ nd.mnt, mode, |
543 |
+ if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV)) |
+ new_decode_dev(dev)); |
544 |
+ return -EPERM; |
+ if (!error) |
545 |
+ if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO)) |
+ /***** TOMOYO Linux end. *****/ |
546 |
+ return -EPERM; |
switch (mode & S_IFMT) { |
547 |
+ if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) |
case 0: case S_IFREG: |
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
tmp = getname(filename); |
|
|
if (IS_ERR(tmp)) |
|
|
return PTR_ERR(tmp); |
|
|
@@ -1888,10 +1919,32 @@ asmlinkage long sys_mknodat(int dfd, con |
|
548 |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
549 |
break; |
@@ -1959,6 +1984,11 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
case S_IFCHR: case S_IFBLK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ error = ccs_check_1path_perm(S_ISCHR(mode) ? |
|
|
+ TYPE_MKCHAR_ACL : |
|
|
+ TYPE_MKBLOCK_ACL, |
|
|
+ dentry, nd.mnt); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode, |
|
|
new_decode_dev(dev)); |
|
|
break; |
|
|
case S_IFIFO: case S_IFSOCK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ error = ccs_check_1path_perm(S_ISFIFO(mode) ? |
|
|
+ TYPE_MKFIFO_ACL : |
|
|
+ TYPE_MKSOCK_ACL, |
|
|
+ dentry, nd.mnt); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0); |
|
|
break; |
|
|
case S_IFDIR: |
|
|
@@ -1959,6 +2012,12 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
550 |
|
|
551 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
552 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
553 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
554 |
+ error = pre_vfs_mkdir(nd.dentry->d_inode, dentry); |
+ error = ccs_check_mkdir_permission(nd.dentry->d_inode, dentry, nd.mnt, |
555 |
+ if (!error) |
+ mode); |
|
+ error = ccs_check_1path_perm(TYPE_MKDIR_ACL, dentry, nd.mnt); |
|
556 |
+ if (!error) |
+ if (!error) |
557 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
558 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
559 |
dput(dentry); |
dput(dentry); |
560 |
out_unlock: |
out_unlock: |
561 |
@@ -2066,6 +2125,12 @@ static long do_rmdir(int dfd, const char |
@@ -2066,6 +2096,10 @@ static long do_rmdir(int dfd, const char |
562 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
563 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
564 |
goto exit2; |
goto exit2; |
565 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
566 |
+ error = pre_vfs_rmdir(nd.dentry->d_inode, dentry); |
+ error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry, nd.mnt); |
|
+ if (!error) |
|
|
+ error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, nd.mnt); |
|
567 |
+ if (!error) |
+ if (!error) |
568 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
569 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
570 |
dput(dentry); |
dput(dentry); |
571 |
exit2: |
exit2: |
572 |
@@ -2125,6 +2190,10 @@ static long do_unlinkat(int dfd, const c |
@@ -2146,6 +2180,11 @@ static long do_unlinkat(int dfd, const c |
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
struct inode *inode = NULL; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_UNLINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
name = getname(pathname); |
|
|
if(IS_ERR(name)) |
|
|
@@ -2146,6 +2215,14 @@ static long do_unlinkat(int dfd, const c |
|
573 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
574 |
if (inode) |
if (inode) |
575 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
576 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
577 |
+ error = pre_vfs_unlink(nd.dentry->d_inode, dentry); |
+ error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry, |
578 |
+ if (error) |
+ nd.mnt); |
579 |
+ goto exit2; |
+ if (!error) |
|
+ error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt); |
|
|
+ if (error) |
|
|
+ goto exit2; |
|
580 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
581 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
582 |
exit2: |
exit2: |
583 |
dput(dentry); |
dput(dentry); |
584 |
@@ -2210,6 +2287,10 @@ asmlinkage long sys_symlinkat(const char |
@@ -2227,6 +2266,11 @@ asmlinkage long sys_symlinkat(const char |
|
char * to; |
|
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SYMLINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
|
@@ -2227,6 +2308,12 @@ asmlinkage long sys_symlinkat(const char |
|
585 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
586 |
goto out_unlock; |
goto out_unlock; |
587 |
|
|
588 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
589 |
+ error = pre_vfs_symlink(nd.dentry->d_inode, dentry); |
+ error = ccs_check_symlink_permission(nd.dentry->d_inode, dentry, |
590 |
+ if (!error) |
+ nd.mnt, from); |
|
+ error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, dentry, nd.mnt); |
|
591 |
+ if (!error) |
+ if (!error) |
592 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
593 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
594 |
dput(dentry); |
dput(dentry); |
595 |
out_unlock: |
out_unlock: |
596 |
@@ -2299,6 +2386,10 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2322,6 +2366,11 @@ asmlinkage long sys_linkat(int olddfd, c |
|
struct nameidata nd, old_nd; |
|
|
int error; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_LINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
if ((flags & ~AT_SYMLINK_FOLLOW) != 0) |
|
|
return -EINVAL; |
|
|
@@ -2322,6 +2413,13 @@ asmlinkage long sys_linkat(int olddfd, c |
|
597 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
598 |
if (IS_ERR(new_dentry)) |
if (IS_ERR(new_dentry)) |
599 |
goto out_unlock; |
goto out_unlock; |
600 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
601 |
+ error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
+ error = ccs_check_link_permission(old_nd.dentry, nd.dentry->d_inode, |
602 |
+ if (!error) |
+ new_dentry, nd.mnt); |
|
+ error = ccs_check_2path_perm(TYPE_LINK_ACL, old_nd.dentry, |
|
|
+ old_nd.mnt, new_dentry, nd.mnt); |
|
603 |
+ if (!error) |
+ if (!error) |
604 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
605 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
606 |
dput(new_dentry); |
dput(new_dentry); |
607 |
out_unlock: |
out_unlock: |
608 |
@@ -2547,6 +2645,16 @@ static int do_rename(int olddfd, const c |
@@ -2547,6 +2596,12 @@ static int do_rename(int olddfd, const c |
609 |
error = -ENOTEMPTY; |
error = -ENOTEMPTY; |
610 |
if (new_dentry == trap) |
if (new_dentry == trap) |
611 |
goto exit5; |
goto exit5; |
612 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
613 |
+ error = pre_vfs_rename(old_dir->d_inode, old_dentry, |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
614 |
+ new_dir->d_inode, new_dentry); |
+ new_dir->d_inode, new_dentry, |
615 |
+ if (error) |
+ newnd.mnt); |
616 |
+ goto exit5; |
+ if (!error) |
|
+ error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, |
|
|
+ new_dentry, newnd.mnt); |
|
|
+ if (error) |
|
|
+ goto exit5; |
|
617 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
618 |
|
|
619 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
error = vfs_rename(old_dir->d_inode, old_dentry, |
620 |
new_dir->d_inode, new_dentry); |
new_dir->d_inode, new_dentry); |
|
@@ -2570,6 +2678,10 @@ asmlinkage long sys_renameat(int olddfd, |
|
|
int error; |
|
|
char * from; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_RENAME)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
621 |
--- linux-2.6.21.7.orig/fs/namespace.c |
--- linux-2.6.21.7.orig/fs/namespace.c |
622 |
+++ linux-2.6.21.7/fs/namespace.c |
+++ linux-2.6.21.7/fs/namespace.c |
623 |
@@ -28,6 +28,12 @@ |
@@ -28,6 +28,12 @@ |
650 |
struct nameidata nd; |
struct nameidata nd; |
651 |
int retval; |
int retval; |
652 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
653 |
+ if (!ccs_capable(TOMOYO_SYS_UMOUNT)) |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
654 |
+ return -EPERM; |
+ return -EPERM; |
655 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
656 |
|
|
697 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
698 |
|
|
699 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
700 |
+ if (!ccs_capable(TOMOYO_SYS_MOUNT)) |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
701 |
+ return -EPERM; |
+ return -EPERM; |
702 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
703 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
715 |
if (!capable(CAP_SYS_ADMIN)) |
if (!capable(CAP_SYS_ADMIN)) |
716 |
return -EPERM; |
return -EPERM; |
717 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
718 |
+ if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT)) |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
719 |
+ return -EPERM; |
+ return -EPERM; |
720 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
721 |
|
|
752 |
goto dput_and_out; |
goto dput_and_out; |
753 |
|
|
754 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
755 |
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt); |
+ error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0); |
756 |
+ if (!error) |
+ if (!error) |
757 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
758 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
759 |
if (!error) { |
if (!error) { |
760 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
761 |
@@ -317,6 +327,11 @@ static long do_sys_ftruncate(unsigned in |
@@ -317,6 +327,12 @@ static long do_sys_ftruncate(unsigned in |
762 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
763 |
goto out_putf; |
goto out_putf; |
764 |
|
|
765 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
766 |
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt); |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
767 |
|
+ 0); |
768 |
+ if (error) |
+ if (error) |
769 |
+ goto out_putf; |
+ goto out_putf; |
770 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
771 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
772 |
if (!error) |
if (!error) |
773 |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
774 |
@@ -481,6 +496,14 @@ asmlinkage long sys_chroot(const char __ |
@@ -481,6 +497,14 @@ asmlinkage long sys_chroot(const char __ |
775 |
error = -EPERM; |
error = -EPERM; |
776 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
777 |
goto dput_and_out; |
goto dput_and_out; |
778 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
779 |
+ if (!ccs_capable(TOMOYO_SYS_CHROOT)) |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
780 |
+ goto dput_and_out; |
+ goto dput_and_out; |
781 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
782 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
786 |
|
|
787 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
788 |
set_fs_altroot(); |
set_fs_altroot(); |
789 |
@@ -1085,6 +1108,10 @@ EXPORT_SYMBOL(sys_close); |
@@ -1085,6 +1109,10 @@ EXPORT_SYMBOL(sys_close); |
790 |
*/ |
*/ |
791 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
792 |
{ |
{ |
793 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
794 |
+ if (!ccs_capable(TOMOYO_SYS_VHANGUP)) |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
795 |
+ return -EPERM; |
+ return -EPERM; |
796 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
797 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
814 |
#endif |
#endif |
815 |
+ /***** CCS start. *****/ |
+ /***** CCS start. *****/ |
816 |
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
817 |
+ printk(KERN_INFO "Hook version: 2.6.21.7 2008/10/30\n"); |
+ printk(KERN_INFO "Hook version: 2.6.21.7 2009/04/20\n"); |
818 |
+#endif |
+#endif |
819 |
+ /***** CCS end. *****/ |
+ /***** CCS end. *****/ |
820 |
} |
} |
825 |
INIT_TRACE_IRQFLAGS \ |
INIT_TRACE_IRQFLAGS \ |
826 |
INIT_LOCKDEP \ |
INIT_LOCKDEP \ |
827 |
+ /***** TOMOYO Linux start. *****/ \ |
+ /***** TOMOYO Linux start. *****/ \ |
828 |
+ .domain_info = &KERNEL_DOMAIN, \ |
+ .ccs_domain_info = NULL, \ |
829 |
+ .tomoyo_flags = 0, \ |
+ .ccs_flags = 0, \ |
830 |
+ /***** TOMOYO Linux end. *****/ \ |
+ /***** TOMOYO Linux end. *****/ \ |
831 |
} |
} |
832 |
|
|
833 |
|
|
834 |
--- linux-2.6.21.7.orig/include/linux/sched.h |
--- linux-2.6.21.7.orig/include/linux/sched.h |
835 |
+++ linux-2.6.21.7/include/linux/sched.h |
+++ linux-2.6.21.7/include/linux/sched.h |
836 |
@@ -27,6 +27,11 @@ |
@@ -27,6 +27,10 @@ |
837 |
#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ |
#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ |
838 |
#define CLONE_NEWIPC 0x08000000 /* New ipcs */ |
#define CLONE_NEWIPC 0x08000000 /* New ipcs */ |
839 |
|
|
840 |
+/***** TOMOYO Linux start. *****/ |
+/***** TOMOYO Linux start. *****/ |
841 |
+struct domain_info; |
+struct ccs_domain_info; |
|
+extern struct domain_info KERNEL_DOMAIN; |
|
842 |
+/***** TOMOYO Linux end. *****/ |
+/***** TOMOYO Linux end. *****/ |
843 |
+ |
+ |
844 |
/* |
/* |
845 |
* Scheduling policies |
* Scheduling policies |
846 |
*/ |
*/ |
847 |
@@ -1052,6 +1057,10 @@ struct task_struct { |
@@ -1052,6 +1056,10 @@ struct task_struct { |
848 |
#ifdef CONFIG_FAULT_INJECTION |
#ifdef CONFIG_FAULT_INJECTION |
849 |
int make_it_fail; |
int make_it_fail; |
850 |
#endif |
#endif |
851 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
852 |
+ struct domain_info *domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
853 |
+ u32 tomoyo_flags; |
+ u32 ccs_flags; |
854 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
855 |
}; |
}; |
856 |
|
|
872 |
if (err) |
if (err) |
873 |
return err; |
return err; |
874 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
875 |
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
876 |
+ return -EPERM; |
+ return -EPERM; |
877 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
878 |
|
|
895 |
if (!capable(CAP_SYS_BOOT)) |
if (!capable(CAP_SYS_BOOT)) |
896 |
return -EPERM; |
return -EPERM; |
897 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
898 |
+ if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD)) |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
899 |
+ return -EPERM; |
+ return -EPERM; |
900 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
901 |
|
|
908 |
set_cpus_allowed(current, CPU_MASK_ALL); |
set_cpus_allowed(current, CPU_MASK_ALL); |
909 |
|
|
910 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
911 |
+ current->domain_info = &KERNEL_DOMAIN; |
+ current->ccs_domain_info = NULL; |
912 |
+ current->tomoyo_flags = 0; |
+ current->ccs_flags = 0; |
913 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
914 |
+ |
+ |
915 |
retval = -EPERM; |
retval = -EPERM; |
932 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
933 |
return -EPERM; |
return -EPERM; |
934 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
935 |
+ if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
936 |
+ return -EPERM; |
+ return -EPERM; |
937 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
938 |
|
|
943 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
944 |
return -EPERM; |
return -EPERM; |
945 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
946 |
+ if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
947 |
+ return -EPERM; |
+ return -EPERM; |
948 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
949 |
|
|
961 |
|
|
962 |
/* |
/* |
963 |
* ptrace a task: make the debugger its new parent and |
* ptrace a task: make the debugger its new parent and |
964 |
@@ -456,6 +459,12 @@ asmlinkage long sys_ptrace(long request, |
@@ -456,6 +459,10 @@ asmlinkage long sys_ptrace(long request, |
965 |
/* |
/* |
966 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
967 |
*/ |
*/ |
968 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
969 |
+#ifdef TOMOYO_SYS_PTRACE |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
|
970 |
+ return -EPERM; |
+ return -EPERM; |
|
+#endif |
|
971 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
972 |
lock_kernel(); |
lock_kernel(); |
973 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
989 |
{ |
{ |
990 |
long nice, retval; |
long nice, retval; |
991 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
992 |
+ if (!ccs_capable(TOMOYO_SYS_NICE)) |
+ if (!ccs_capable(CCS_SYS_NICE)) |
993 |
+ return -EPERM; |
+ return -EPERM; |
994 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
995 |
|
|
1012 |
{ |
{ |
1013 |
struct siginfo info; |
struct siginfo info; |
1014 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1015 |
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
1016 |
+ return -EPERM; |
+ return -EPERM; |
1017 |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1018 |
+ return -EPERM; |
+ return -EPERM; |
1025 |
if (pid <= 0 || tgid <= 0) |
if (pid <= 0 || tgid <= 0) |
1026 |
return -EINVAL; |
return -EINVAL; |
1027 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1028 |
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
1029 |
+ return -EPERM; |
+ return -EPERM; |
1030 |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1031 |
+ return -EPERM; |
+ return -EPERM; |
1038 |
if (pid <= 0) |
if (pid <= 0) |
1039 |
return -EINVAL; |
return -EINVAL; |
1040 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1041 |
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
1042 |
+ return -EPERM; |
+ return -EPERM; |
1043 |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1044 |
+ return -EPERM; |
+ return -EPERM; |
1063 |
if (which > 2 || which < 0) |
if (which > 2 || which < 0) |
1064 |
goto out; |
goto out; |
1065 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1066 |
+ if (!ccs_capable(TOMOYO_SYS_NICE)) { |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
1067 |
+ error = -EPERM; |
+ error = -EPERM; |
1068 |
+ goto out; |
+ goto out; |
1069 |
+ } |
+ } |
1076 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
magic2 != LINUX_REBOOT_MAGIC2C)) |
1077 |
return -EINVAL; |
return -EINVAL; |
1078 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1079 |
+ if (!ccs_capable(TOMOYO_SYS_REBOOT)) |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
1080 |
+ return -EPERM; |
+ return -EPERM; |
1081 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1082 |
|
|
1087 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
1088 |
return -EINVAL; |
return -EINVAL; |
1089 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1090 |
+ if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
1091 |
+ return -EPERM; |
+ return -EPERM; |
1092 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1093 |
down_write(&uts_sem); |
down_write(&uts_sem); |
1098 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
1099 |
return -EINVAL; |
return -EINVAL; |
1100 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1101 |
+ if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
1102 |
+ return -EPERM; |
+ return -EPERM; |
1103 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1104 |
|
|
1116 |
|
|
1117 |
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
1118 |
void __user *buffer, size_t *lenp, loff_t *ppos); |
void __user *buffer, size_t *lenp, loff_t *ppos); |
1119 |
@@ -1088,6 +1091,93 @@ struct ctl_table_header *sysctl_head_nex |
@@ -1088,6 +1091,7 @@ struct ctl_table_header *sysctl_head_nex |
1120 |
} |
} |
1121 |
|
|
1122 |
#ifdef CONFIG_SYSCTL_SYSCALL |
#ifdef CONFIG_SYSCTL_SYSCALL |
1123 |
+ |
+ |
|
+/***** TOMOYO Linux start. *****/ |
|
|
+static int try_parse_table(int __user *name, int nlen, void __user *oldval, |
|
|
+ void __user *newval, ctl_table *table) |
|
|
+{ |
|
|
+ int n; |
|
|
+ int error = -ENOMEM; |
|
|
+ int op = 0; |
|
|
+ char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); |
|
|
+ if (oldval) |
|
|
+ op |= 004; |
|
|
+ if (newval) |
|
|
+ op |= 002; |
|
|
+ if (!op) { /* Neither read nor write */ |
|
|
+ error = 0; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (!buffer) |
|
|
+ goto out; |
|
|
+ memset(buffer, 0, PAGE_SIZE); |
|
|
+ snprintf(buffer, PAGE_SIZE - 1, "/proc/sys"); |
|
|
+ repeat: |
|
|
+ if (!nlen) { |
|
|
+ error = -ENOTDIR; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (get_user(n, name)) { |
|
|
+ error = -EFAULT; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ for ( ; table->ctl_name || table->procname; table++) { |
|
|
+ if (n == table->ctl_name && n) { |
|
|
+ int pos = strlen(buffer); |
|
|
+ const char *cp = table->procname; |
|
|
+ error = -ENOMEM; |
|
|
+ if (cp) { |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '/'; |
|
|
+ while (*cp) { |
|
|
+ const unsigned char c |
|
|
+ = *(const unsigned char *) cp; |
|
|
+ if (c == '\\') { |
|
|
+ if (pos + 2 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ } else if (c > ' ' && c < 127) { |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = c; |
|
|
+ } else { |
|
|
+ if (pos + 4 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ buffer[pos++] = (c >> 6) + '0'; |
|
|
+ buffer[pos++] = ((c >> 3) & 7) |
|
|
+ + '0'; |
|
|
+ buffer[pos++] = (c & 7) + '0'; |
|
|
+ } |
|
|
+ cp++; |
|
|
+ } |
|
|
+ } else { |
|
|
+ /* Assume nobody assigns "=\$=" for procname. */ |
|
|
+ snprintf(buffer + pos, PAGE_SIZE - pos - 1, |
|
|
+ "/=%d=", n); |
|
|
+ if (!memchr(buffer, '\0', PAGE_SIZE - 2)) |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (table->child) { |
|
|
+ name++; |
|
|
+ nlen--; |
|
|
+ table = table->child; |
|
|
+ goto repeat; |
|
|
+ } |
|
|
+ /* printk("sysctl='%s'\n", buffer); */ |
|
|
+ error = ccs_check_file_perm(buffer, op, "sysctl"); |
|
|
+ goto out; |
|
|
+ } |
|
|
+ } |
|
|
+ error = -ENOTDIR; |
|
|
+ out: |
|
|
+ kfree(buffer); |
|
|
+ return error; |
|
|
+} |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
+ |
|
1124 |
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
1125 |
void __user *newval, size_t newlen) |
void __user *newval, size_t newlen) |
1126 |
{ |
{ |
1127 |
@@ -1104,6 +1194,11 @@ int do_sysctl(int __user *name, int nlen |
@@ -1104,6 +1108,11 @@ int do_sysctl(int __user *name, int nlen |
1128 |
|
|
1129 |
for (head = sysctl_head_next(NULL); head; |
for (head = sysctl_head_next(NULL); head; |
1130 |
head = sysctl_head_next(head)) { |
head = sysctl_head_next(head)) { |
1131 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1132 |
+ error = try_parse_table(name, nlen, oldval, newval, |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
1133 |
+ head->ctl_table); |
+ head->ctl_table); |
1134 |
+ if (!error) |
+ if (!error) |
1135 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1153 |
if (err) |
if (err) |
1154 |
return err; |
return err; |
1155 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1156 |
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1157 |
+ return -EPERM; |
+ return -EPERM; |
1158 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1159 |
|
|
1164 |
if (error) |
if (error) |
1165 |
return error; |
return error; |
1166 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1167 |
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1168 |
+ return -EPERM; |
+ return -EPERM; |
1169 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1170 |
|
|
1187 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
if (txc->modes && !capable(CAP_SYS_TIME)) |
1188 |
return -EPERM; |
return -EPERM; |
1189 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1190 |
+ if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
1191 |
+ return -EPERM; |
+ return -EPERM; |
1192 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1193 |
|
|
1194 |
/* Now we validate the data before disabling interrupts */ |
/* Now we validate the data before disabling interrupts */ |
1195 |
|
|
|
--- linux-2.6.21.7.orig/net/core/datagram.c |
|
|
+++ linux-2.6.21.7/net/core/datagram.c |
|
|
@@ -56,6 +56,11 @@ |
|
|
#include <net/sock.h> |
|
|
#include <net/tcp_states.h> |
|
|
|
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+#include <linux/tomoyo_socket.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
+ |
|
|
/* |
|
|
* Is a socket 'connection oriented' ? |
|
|
*/ |
|
|
@@ -178,6 +183,12 @@ struct sk_buff *skb_recv_datagram(struct |
|
|
} else |
|
|
skb = skb_dequeue(&sk->sk_receive_queue); |
|
|
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = ccs_socket_recv_datagram_permission(sk, skb, flags); |
|
|
+ if (error) |
|
|
+ goto no_packet; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ |
|
|
if (skb) |
|
|
return skb; |
|
|
|
|
1196 |
--- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c |
--- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c |
1197 |
+++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c |
+++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c |
1198 |
@@ -23,6 +23,9 @@ |
@@ -23,6 +23,9 @@ |
1210 |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
1211 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1212 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1213 |
+ if (ccs_may_autobind(rover)) |
+ if (ccs_lport_reserved(rover)) |
1214 |
+ goto next; |
+ goto next; |
1215 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1216 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
inet_bind_bucket_for_each(tb, node, &head->chain) |
1233 |
for (i = 1; i <= range; i++) { |
for (i = 1; i <= range; i++) { |
1234 |
port = low + (i + offset) % range; |
port = low + (i + offset) % range; |
1235 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1236 |
+ if (ccs_may_autobind(port)) |
+ if (ccs_lport_reserved(port)) |
1237 |
+ continue; |
+ continue; |
1238 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1239 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1240 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1241 |
|
|
1242 |
|
--- linux-2.6.21.7.orig/net/ipv4/raw.c |
1243 |
|
+++ linux-2.6.21.7/net/ipv4/raw.c |
1244 |
|
@@ -78,6 +78,9 @@ |
1245 |
|
#include <linux/seq_file.h> |
1246 |
|
#include <linux/netfilter.h> |
1247 |
|
#include <linux/netfilter_ipv4.h> |
1248 |
|
+/***** TOMOYO Linux start. *****/ |
1249 |
|
+#include <linux/tomoyo_socket.h> |
1250 |
|
+/***** TOMOYO Linux end. *****/ |
1251 |
|
|
1252 |
|
struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; |
1253 |
|
DEFINE_RWLOCK(raw_v4_lock); |
1254 |
|
@@ -597,6 +600,11 @@ static int raw_recvmsg(struct kiocb *ioc |
1255 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1256 |
|
if (!skb) |
1257 |
|
goto out; |
1258 |
|
+ /***** TOMOYO Linux start. *****/ |
1259 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1260 |
|
+ if (err) |
1261 |
|
+ goto out; |
1262 |
|
+ /***** TOMOYO Linux end. *****/ |
1263 |
|
|
1264 |
|
copied = skb->len; |
1265 |
|
if (len < copied) { |
1266 |
--- linux-2.6.21.7.orig/net/ipv4/udp.c |
--- linux-2.6.21.7.orig/net/ipv4/udp.c |
1267 |
+++ linux-2.6.21.7/net/ipv4/udp.c |
+++ linux-2.6.21.7/net/ipv4/udp.c |
1268 |
@@ -102,6 +102,9 @@ |
@@ -102,6 +102,12 @@ |
1269 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1270 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1271 |
#include "udp_impl.h" |
#include "udp_impl.h" |
1272 |
+/***** SAKURA Linux start. *****/ |
+/***** SAKURA Linux start. *****/ |
1273 |
+#include <linux/sakura.h> |
+#include <linux/sakura.h> |
1274 |
+/***** SAKURA Linux end. *****/ |
+/***** SAKURA Linux end. *****/ |
1275 |
|
+/***** TOMOYO Linux start. *****/ |
1276 |
|
+#include <linux/tomoyo_socket.h> |
1277 |
|
+/***** TOMOYO Linux end. *****/ |
1278 |
|
|
1279 |
/* |
/* |
1280 |
* Snmp MIB for the UDP layer |
* Snmp MIB for the UDP layer |
1281 |
@@ -162,6 +165,10 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -162,6 +168,10 @@ int __udp_lib_get_port(struct sock *sk, |
1282 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1283 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1284 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1285 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1286 |
+ if (ccs_may_autobind(result)) |
+ if (ccs_lport_reserved(result)) |
1287 |
+ continue; |
+ continue; |
1288 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1289 |
goto gotit; |
goto gotit; |
1290 |
} |
} |
1291 |
size = 0; |
size = 0; |
1292 |
@@ -180,6 +187,10 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -180,6 +190,10 @@ int __udp_lib_get_port(struct sock *sk, |
1293 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1294 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1295 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1296 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1297 |
+ if (ccs_may_autobind(result)) |
+ if (ccs_lport_reserved(result)) |
1298 |
+ continue; |
+ continue; |
1299 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1300 |
if (! __udp_lib_lport_inuse(result, udptable)) |
if (! __udp_lib_lport_inuse(result, udptable)) |
1301 |
break; |
break; |
1302 |
} |
} |
1303 |
|
@@ -825,6 +839,11 @@ try_again: |
1304 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1305 |
|
if (!skb) |
1306 |
|
goto out; |
1307 |
|
+ /***** TOMOYO Linux start. *****/ |
1308 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1309 |
|
+ if (err) |
1310 |
|
+ goto out; |
1311 |
|
+ /***** TOMOYO Linux end. *****/ |
1312 |
|
|
1313 |
|
copied = skb->len - sizeof(struct udphdr); |
1314 |
|
if (copied > len) { |
1315 |
--- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c |
--- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c |
1316 |
+++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c |
+++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c |
1317 |
@@ -21,6 +21,9 @@ |
@@ -21,6 +21,9 @@ |
1329 |
for (i = 1; i <= range; i++) { |
for (i = 1; i <= range; i++) { |
1330 |
port = low + (i + offset) % range; |
port = low + (i + offset) % range; |
1331 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1332 |
+ if (ccs_may_autobind(port)) |
+ if (ccs_lport_reserved(port)) |
1333 |
+ continue; |
+ continue; |
1334 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1335 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1336 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1337 |
|
|
1338 |
|
--- linux-2.6.21.7.orig/net/ipv6/raw.c |
1339 |
|
+++ linux-2.6.21.7/net/ipv6/raw.c |
1340 |
|
@@ -58,6 +58,9 @@ |
1341 |
|
|
1342 |
|
#include <linux/proc_fs.h> |
1343 |
|
#include <linux/seq_file.h> |
1344 |
|
+/***** TOMOYO Linux start. *****/ |
1345 |
|
+#include <linux/tomoyo_socket.h> |
1346 |
|
+/***** TOMOYO Linux end. *****/ |
1347 |
|
|
1348 |
|
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1349 |
|
DEFINE_RWLOCK(raw_v6_lock); |
1350 |
|
@@ -413,6 +416,11 @@ static int rawv6_recvmsg(struct kiocb *i |
1351 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1352 |
|
if (!skb) |
1353 |
|
goto out; |
1354 |
|
+ /***** TOMOYO Linux start. *****/ |
1355 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1356 |
|
+ if (err) |
1357 |
|
+ goto out; |
1358 |
|
+ /***** TOMOYO Linux end. *****/ |
1359 |
|
|
1360 |
|
copied = skb->len; |
1361 |
|
if (copied > len) { |
1362 |
|
--- linux-2.6.21.7.orig/net/ipv6/udp.c |
1363 |
|
+++ linux-2.6.21.7/net/ipv6/udp.c |
1364 |
|
@@ -49,6 +49,9 @@ |
1365 |
|
#include <linux/proc_fs.h> |
1366 |
|
#include <linux/seq_file.h> |
1367 |
|
#include "udp_impl.h" |
1368 |
|
+/***** TOMOYO Linux start. *****/ |
1369 |
|
+#include <linux/tomoyo_socket.h> |
1370 |
|
+/***** TOMOYO Linux end. *****/ |
1371 |
|
|
1372 |
|
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
1373 |
|
|
1374 |
|
@@ -133,6 +136,11 @@ try_again: |
1375 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1376 |
|
if (!skb) |
1377 |
|
goto out; |
1378 |
|
+ /***** TOMOYO Linux start. *****/ |
1379 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1380 |
|
+ if (err) |
1381 |
|
+ goto out; |
1382 |
|
+ /***** TOMOYO Linux end. *****/ |
1383 |
|
|
1384 |
|
copied = skb->len - sizeof(struct udphdr); |
1385 |
|
if (copied > len) { |
1386 |
--- linux-2.6.21.7.orig/net/socket.c |
--- linux-2.6.21.7.orig/net/socket.c |
1387 |
+++ linux-2.6.21.7/net/socket.c |
+++ linux-2.6.21.7/net/socket.c |
1388 |
@@ -93,6 +93,11 @@ |
@@ -93,6 +93,11 @@ |
1487 |
|
|
1488 |
int sysctl_unix_max_dgram_qlen __read_mostly = 10; |
int sysctl_unix_max_dgram_qlen __read_mostly = 10; |
1489 |
|
|
1490 |
@@ -765,6 +768,11 @@ static int unix_bind(struct socket *sock |
@@ -808,6 +811,11 @@ static int unix_bind(struct socket *sock |
|
err = unix_autobind(sock); |
|
|
goto out; |
|
|
} |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = -EPERM; |
|
|
+ if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) |
|
|
+ goto out; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
err = unix_mkname(sunaddr, addr_len, &hash); |
|
|
if (err < 0) |
|
|
@@ -808,6 +816,13 @@ static int unix_bind(struct socket *sock |
|
1491 |
*/ |
*/ |
1492 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1493 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1494 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1495 |
+ err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
+ err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
1496 |
+ if (!err) |
+ nd.mnt, mode, 0); |
|
+ err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry, |
|
|
+ nd.mnt); |
|
1497 |
+ if (!err) |
+ if (!err) |
1498 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1499 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |