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