1 |
kumaneko |
1498 |
This is TOMOYO Linux patch for VineLinux 4.2. |
2 |
|
|
|
3 |
|
|
Source code for this patch is http://updates.vinelinux.org/Vine-4.2/updates/SRPMS/kernel-2.6.16-76.39vl4.src.rpm |
4 |
|
|
--- |
5 |
|
|
arch/alpha/kernel/ptrace.c | 9 +++ |
6 |
|
|
arch/ia64/ia32/sys_ia32.c | 9 +++ |
7 |
|
|
arch/ia64/kernel/ptrace.c | 9 +++ |
8 |
|
|
arch/m32r/kernel/ptrace.c | 9 +++ |
9 |
|
|
arch/mips/kernel/ptrace32.c | 9 +++ |
10 |
|
|
arch/powerpc/kernel/ptrace32.c | 9 +++ |
11 |
|
|
arch/s390/kernel/ptrace.c | 9 +++ |
12 |
|
|
arch/sparc/kernel/ptrace.c | 11 +++ |
13 |
|
|
arch/sparc64/kernel/ptrace.c | 11 +++ |
14 |
|
|
arch/x86_64/ia32/ptrace32.c | 9 +++ |
15 |
|
|
fs/Kconfig | 2 |
16 |
|
|
fs/Makefile | 2 |
17 |
|
|
fs/attr.c | 19 ++++++ |
18 |
|
|
fs/compat.c | 11 +++ |
19 |
|
|
fs/exec.c | 21 ++++++- |
20 |
|
|
fs/fcntl.c | 9 +++ |
21 |
|
|
fs/ioctl.c | 7 ++ |
22 |
|
|
fs/namei.c | 118 ++++++++++++++++++++++++++++++++++++++++ |
23 |
|
|
fs/namespace.c | 50 ++++++++++++++++ |
24 |
|
|
fs/open.c | 29 +++++++++ |
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 | 13 +++- |
33 |
|
|
kernel/ptrace.c | 9 +++ |
34 |
|
|
kernel/sched.c | 7 ++ |
35 |
|
|
kernel/signal.c | 21 +++++++ |
36 |
|
|
kernel/sys.c | 21 +++++++ |
37 |
|
|
kernel/sysctl.c | 111 +++++++++++++++++++++++++++++++++++++ |
38 |
|
|
kernel/time.c | 15 +++++ |
39 |
|
|
net/core/datagram.c | 11 +++ |
40 |
|
|
net/ipv4/inet_connection_sock.c | 7 ++ |
41 |
|
|
net/ipv4/inet_hashtables.c | 7 ++ |
42 |
|
|
net/ipv4/udp.c | 11 +++ |
43 |
|
|
net/ipv6/inet6_hashtables.c | 9 ++- |
44 |
|
|
net/ipv6/udp.c | 11 +++ |
45 |
|
|
net/socket.c | 43 +++++++++++++- |
46 |
|
|
net/unix/af_unix.c | 15 +++++ |
47 |
kumaneko |
1766 |
42 files changed, 703 insertions(+), 10 deletions(-) |
48 |
kumaneko |
1498 |
|
49 |
|
|
--- linux-2.6.16-76.39vl4.orig/arch/alpha/kernel/ptrace.c |
50 |
|
|
+++ linux-2.6.16-76.39vl4/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.16-76.39vl4.orig/arch/ia64/ia32/sys_ia32.c |
75 |
|
|
+++ linux-2.6.16-76.39vl4/arch/ia64/ia32/sys_ia32.c |
76 |
|
|
@@ -58,6 +58,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 |
|
|
@@ -1755,6 +1758,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.16-76.39vl4.orig/arch/ia64/kernel/ptrace.c |
100 |
|
|
+++ linux-2.6.16-76.39vl4/arch/ia64/kernel/ptrace.c |
101 |
|
|
@@ -29,6 +29,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.16-76.39vl4.orig/arch/m32r/kernel/ptrace.c |
125 |
|
|
+++ linux-2.6.16-76.39vl4/arch/m32r/kernel/ptrace.c |
126 |
|
|
@@ -33,6 +33,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 |
|
|
@@ -743,6 +746,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.16-76.39vl4.orig/arch/mips/kernel/ptrace32.c |
150 |
|
|
+++ linux-2.6.16-76.39vl4/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.16-76.39vl4.orig/arch/powerpc/kernel/ptrace32.c |
175 |
|
|
+++ linux-2.6.16-76.39vl4/arch/powerpc/kernel/ptrace32.c |
176 |
|
|
@@ -33,6 +33,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 |
|
|
@@ -46,6 +49,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.16-76.39vl4.orig/arch/s390/kernel/ptrace.c |
200 |
|
|
+++ linux-2.6.16-76.39vl4/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 |
|
|
@@ -711,6 +714,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.16-76.39vl4.orig/arch/sparc/kernel/ptrace.c |
225 |
|
|
+++ linux-2.6.16-76.39vl4/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.16-76.39vl4.orig/arch/sparc64/kernel/ptrace.c |
252 |
|
|
+++ linux-2.6.16-76.39vl4/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 |
|
|
@@ -173,6 +176,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.16-76.39vl4.orig/arch/x86_64/ia32/ptrace32.c |
279 |
|
|
+++ linux-2.6.16-76.39vl4/arch/x86_64/ia32/ptrace32.c |
280 |
|
|
@@ -27,6 +27,9 @@ |
281 |
|
|
#include <asm/debugreg.h> |
282 |
|
|
#include <asm/i387.h> |
283 |
|
|
#include <asm/fpu32.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 |
|
|
@@ -206,6 +209,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 |
|
|
default: |
303 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/Kconfig |
304 |
|
|
+++ linux-2.6.16-76.39vl4/fs/Kconfig |
305 |
|
|
@@ -1906,5 +1906,7 @@ endmenu |
306 |
|
|
|
307 |
|
|
source "fs/nls/Kconfig" |
308 |
|
|
|
309 |
|
|
+source "fs/Kconfig.ccs" |
310 |
|
|
+ |
311 |
|
|
endmenu |
312 |
|
|
|
313 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/Makefile |
314 |
|
|
+++ linux-2.6.16-76.39vl4/fs/Makefile |
315 |
|
|
@@ -106,3 +106,5 @@ obj-$(CONFIG_CONFIGFS_FS) += configfs/ |
316 |
|
|
obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
317 |
|
|
obj-$(CONFIG_SUPERMOUNT) += supermount/ |
318 |
|
|
obj-$(CONFIG_UNION_FS) += unionfs/ |
319 |
|
|
+ |
320 |
|
|
+include $(srctree)/fs/Makefile-2.6.ccs |
321 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/attr.c |
322 |
|
|
+++ linux-2.6.16-76.39vl4/fs/attr.c |
323 |
|
|
@@ -15,6 +15,9 @@ |
324 |
|
|
#include <linux/fcntl.h> |
325 |
|
|
#include <linux/quotaops.h> |
326 |
|
|
#include <linux/security.h> |
327 |
|
|
+/***** TOMOYO Linux start. *****/ |
328 |
|
|
+#include <linux/tomoyo.h> |
329 |
|
|
+/***** TOMOYO Linux end. *****/ |
330 |
|
|
|
331 |
|
|
/* Taken over from the old code... */ |
332 |
|
|
|
333 |
|
|
@@ -145,12 +148,28 @@ int notify_change(struct dentry * dentry |
334 |
|
|
|
335 |
|
|
if (inode->i_op && inode->i_op->setattr) { |
336 |
|
|
error = security_inode_setattr(dentry, attr); |
337 |
|
|
+ /***** TOMOYO Linux start. *****/ |
338 |
|
|
+ if (!error && (ia_valid & ATTR_MODE) && |
339 |
|
|
+ !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. *****/ |
345 |
|
|
if (!error) |
346 |
|
|
error = inode->i_op->setattr(dentry, attr); |
347 |
|
|
} else { |
348 |
|
|
error = inode_change_ok(inode, attr); |
349 |
|
|
if (!error) |
350 |
|
|
error = security_inode_setattr(dentry, attr); |
351 |
|
|
+ /***** TOMOYO Linux start. *****/ |
352 |
|
|
+ if (!error && (ia_valid & ATTR_MODE) && |
353 |
|
|
+ !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. *****/ |
359 |
|
|
if (!error) { |
360 |
|
|
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
361 |
|
|
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
362 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/compat.c |
363 |
|
|
+++ linux-2.6.16-76.39vl4/fs/compat.c |
364 |
|
|
@@ -52,6 +52,9 @@ |
365 |
|
|
#include <asm/uaccess.h> |
366 |
|
|
#include <asm/mmu_context.h> |
367 |
|
|
#include <asm/ioctls.h> |
368 |
|
|
+/***** TOMOYO Linux start. *****/ |
369 |
|
|
+#include <linux/tomoyo.h> |
370 |
|
|
+/***** TOMOYO Linux end. *****/ |
371 |
|
|
|
372 |
|
|
extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
373 |
|
|
|
374 |
|
|
@@ -405,6 +408,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
375 |
|
|
/*FALL THROUGH*/ |
376 |
|
|
|
377 |
|
|
default: |
378 |
|
|
+ /***** TOMOYO Linux start. *****/ |
379 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_IOCTL)) { |
380 |
|
|
+ error = -EPERM; |
381 |
|
|
+ goto out_fput; |
382 |
|
|
+ } |
383 |
|
|
+ /***** TOMOYO Linux end. *****/ |
384 |
|
|
if (filp->f_op && filp->f_op->compat_ioctl) { |
385 |
|
|
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
386 |
|
|
if (error != -ENOIOCTLCMD) |
387 |
|
|
@@ -1532,7 +1541,7 @@ int compat_do_execve(char * filename, |
388 |
|
|
if (retval < 0) |
389 |
|
|
goto out; |
390 |
|
|
|
391 |
|
|
- retval = search_binary_handler(bprm, regs); |
392 |
|
|
+ retval = search_binary_handler_with_transition(bprm, regs); |
393 |
|
|
if (retval >= 0) { |
394 |
|
|
free_arg_pages(bprm); |
395 |
|
|
|
396 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/exec.c |
397 |
|
|
+++ linux-2.6.16-76.39vl4/fs/exec.c |
398 |
|
|
@@ -57,6 +57,10 @@ |
399 |
|
|
#include <linux/kmod.h> |
400 |
|
|
#endif |
401 |
|
|
|
402 |
|
|
+/***** TOMOYO Linux start. *****/ |
403 |
|
|
+#include <linux/tomoyo.h> |
404 |
|
|
+/***** TOMOYO Linux end. *****/ |
405 |
|
|
+ |
406 |
|
|
int core_uses_pid; |
407 |
|
|
char core_pattern[65] = "core"; |
408 |
|
|
int suid_dumpable = 0; |
409 |
|
|
@@ -139,6 +143,13 @@ asmlinkage long sys_uselib(const char __ |
410 |
|
|
if (error) |
411 |
|
|
goto exit; |
412 |
|
|
|
413 |
|
|
+ /***** TOMOYO Linux start. *****/ |
414 |
|
|
+ /* 01 means "read". */ |
415 |
|
|
+ error = ccs_check_open_permission(nd.dentry, nd.mnt, 01); |
416 |
|
|
+ if (error) |
417 |
|
|
+ goto exit; |
418 |
|
|
+ /***** TOMOYO Linux end. *****/ |
419 |
|
|
+ |
420 |
|
|
file = nameidata_to_filp(&nd, O_RDONLY); |
421 |
|
|
error = PTR_ERR(file); |
422 |
|
|
if (IS_ERR(file)) |
423 |
|
|
@@ -488,6 +499,13 @@ struct file *open_exec(const char *name) |
424 |
|
|
int err = vfs_permission(&nd, MAY_EXEC); |
425 |
|
|
if (!err && !(inode->i_mode & 0111)) |
426 |
|
|
err = -EACCES; |
427 |
|
|
+ /***** TOMOYO Linux start. *****/ |
428 |
|
|
+ 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. *****/ |
434 |
|
|
file = ERR_PTR(err); |
435 |
|
|
if (!err) { |
436 |
|
|
file = nameidata_to_filp(&nd, O_RDONLY); |
437 |
|
|
@@ -1201,7 +1219,8 @@ int do_execve(char * filename, |
438 |
|
|
if (retval < 0) |
439 |
|
|
goto out; |
440 |
|
|
|
441 |
|
|
- retval = search_binary_handler(bprm,regs); |
442 |
|
|
+ retval = search_binary_handler_with_transition(bprm, regs); |
443 |
|
|
+ |
444 |
|
|
if (retval >= 0) { |
445 |
|
|
free_arg_pages(bprm); |
446 |
|
|
|
447 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/fcntl.c |
448 |
|
|
+++ linux-2.6.16-76.39vl4/fs/fcntl.c |
449 |
|
|
@@ -22,6 +22,9 @@ |
450 |
|
|
#include <asm/poll.h> |
451 |
|
|
#include <asm/siginfo.h> |
452 |
|
|
#include <asm/uaccess.h> |
453 |
|
|
+/***** TOMOYO Linux start. *****/ |
454 |
|
|
+#include <linux/tomoyo.h> |
455 |
|
|
+/***** TOMOYO Linux end. *****/ |
456 |
|
|
|
457 |
|
|
void fastcall set_close_on_exec(unsigned int fd, int flag) |
458 |
|
|
{ |
459 |
|
|
@@ -215,6 +218,12 @@ static int setfl(int fd, struct file * f |
460 |
|
|
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
461 |
|
|
return -EPERM; |
462 |
|
|
|
463 |
|
|
+ /***** TOMOYO Linux start. *****/ |
464 |
|
|
+ if (((arg ^ filp->f_flags) & O_APPEND) && |
465 |
|
|
+ ccs_check_rewrite_permission(filp)) |
466 |
|
|
+ return -EPERM; |
467 |
|
|
+ /***** TOMOYO Linux end. *****/ |
468 |
|
|
+ |
469 |
|
|
/* O_NOATIME can only be set by the owner or superuser */ |
470 |
|
|
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
471 |
|
|
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
472 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/ioctl.c |
473 |
|
|
+++ linux-2.6.16-76.39vl4/fs/ioctl.c |
474 |
|
|
@@ -16,6 +16,9 @@ |
475 |
|
|
|
476 |
|
|
#include <asm/uaccess.h> |
477 |
|
|
#include <asm/ioctls.h> |
478 |
|
|
+/***** TOMOYO Linux start. *****/ |
479 |
|
|
+#include <linux/tomoyo.h> |
480 |
|
|
+/***** TOMOYO Linux end. *****/ |
481 |
|
|
|
482 |
|
|
static long do_ioctl(struct file *filp, unsigned int cmd, |
483 |
|
|
unsigned long arg) |
484 |
|
|
@@ -24,6 +27,10 @@ static long do_ioctl(struct file *filp, |
485 |
|
|
|
486 |
|
|
if (!filp->f_op) |
487 |
|
|
goto out; |
488 |
|
|
+ /***** TOMOYO Linux start. *****/ |
489 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_IOCTL)) |
490 |
|
|
+ return -EPERM; |
491 |
|
|
+ /***** TOMOYO Linux end. *****/ |
492 |
|
|
|
493 |
|
|
if (filp->f_op->unlocked_ioctl) { |
494 |
|
|
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
495 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/namei.c |
496 |
|
|
+++ linux-2.6.16-76.39vl4/fs/namei.c |
497 |
|
|
@@ -37,6 +37,10 @@ |
498 |
|
|
|
499 |
|
|
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
500 |
|
|
|
501 |
|
|
+/***** TOMOYO Linux start. *****/ |
502 |
|
|
+#include <linux/tomoyo.h> |
503 |
|
|
+/***** TOMOYO Linux end. *****/ |
504 |
|
|
+ |
505 |
|
|
/* [Feb-1997 T. Schoebel-Theuer] |
506 |
|
|
* Fundamental changes in the pathname lookup mechanisms (namei) |
507 |
|
|
* were necessary because of omirr. The reason is that omirr needs |
508 |
|
|
@@ -1470,6 +1474,13 @@ int vfs_create(struct inode *dir, struct |
509 |
|
|
error = security_inode_create(dir, dentry, mode); |
510 |
|
|
if (error) |
511 |
|
|
return error; |
512 |
|
|
+ /***** TOMOYO Linux start. *****/ |
513 |
|
|
+ if (nd) { |
514 |
|
|
+ error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt); |
515 |
|
|
+ if (error) |
516 |
|
|
+ return error; |
517 |
|
|
+ } |
518 |
|
|
+ /***** TOMOYO Linux end. *****/ |
519 |
|
|
DQUOT_INIT(dir); |
520 |
|
|
error = dir->i_op->create(dir, dentry, mode, nd); |
521 |
|
|
if (!error) |
522 |
|
|
@@ -1525,6 +1536,13 @@ int may_open(struct nameidata *nd, int a |
523 |
|
|
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
524 |
|
|
return -EPERM; |
525 |
|
|
|
526 |
|
|
+ /***** TOMOYO Linux start. *****/ |
527 |
|
|
+ /* includes O_APPEND and O_TRUNC checks */ |
528 |
|
|
+ error = ccs_check_open_permission(dentry, nd->mnt, flag); |
529 |
|
|
+ if (error) |
530 |
|
|
+ return error; |
531 |
|
|
+ /***** TOMOYO Linux end. *****/ |
532 |
|
|
+ |
533 |
|
|
/* |
534 |
|
|
* Ensure there are no outstanding leases on the file. |
535 |
|
|
*/ |
536 |
|
|
@@ -1556,6 +1574,9 @@ int may_open(struct nameidata *nd, int a |
537 |
|
|
return 0; |
538 |
|
|
} |
539 |
|
|
|
540 |
|
|
+/***** TOMOYO Linux start. *****/ |
541 |
|
|
+#include <linux/tomoyo_vfs.h> |
542 |
|
|
+/***** TOMOYO Linux end. *****/ |
543 |
|
|
/* |
544 |
|
|
* open_namei() |
545 |
|
|
* |
546 |
|
|
@@ -1820,6 +1841,16 @@ asmlinkage long sys_mknodat(int dfd, con |
547 |
|
|
|
548 |
|
|
if (S_ISDIR(mode)) |
549 |
|
|
return -EPERM; |
550 |
|
|
+ /***** TOMOYO Linux start. *****/ |
551 |
|
|
+ if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV)) |
552 |
|
|
+ return -EPERM; |
553 |
|
|
+ if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV)) |
554 |
|
|
+ return -EPERM; |
555 |
|
|
+ if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO)) |
556 |
|
|
+ return -EPERM; |
557 |
|
|
+ if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) |
558 |
|
|
+ return -EPERM; |
559 |
|
|
+ /***** TOMOYO Linux end. *****/ |
560 |
|
|
tmp = getname(filename); |
561 |
|
|
if (IS_ERR(tmp)) |
562 |
|
|
return PTR_ERR(tmp); |
563 |
|
|
@@ -1838,10 +1869,32 @@ asmlinkage long sys_mknodat(int dfd, con |
564 |
|
|
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
565 |
|
|
break; |
566 |
|
|
case S_IFCHR: case S_IFBLK: |
567 |
|
|
+ /***** TOMOYO Linux start. *****/ |
568 |
|
|
+ error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
569 |
|
|
+ if (error) |
570 |
|
|
+ break; |
571 |
|
|
+ error = ccs_check_1path_perm(S_ISCHR(mode) ? |
572 |
|
|
+ TYPE_MKCHAR_ACL : |
573 |
|
|
+ TYPE_MKBLOCK_ACL, |
574 |
|
|
+ dentry, nd.mnt); |
575 |
|
|
+ if (error) |
576 |
|
|
+ break; |
577 |
|
|
+ /***** TOMOYO Linux end. *****/ |
578 |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode, |
579 |
|
|
new_decode_dev(dev)); |
580 |
|
|
break; |
581 |
|
|
case S_IFIFO: case S_IFSOCK: |
582 |
|
|
+ /***** TOMOYO Linux start. *****/ |
583 |
|
|
+ error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
584 |
|
|
+ if (error) |
585 |
|
|
+ break; |
586 |
|
|
+ error = ccs_check_1path_perm(S_ISFIFO(mode) ? |
587 |
|
|
+ TYPE_MKFIFO_ACL : |
588 |
|
|
+ TYPE_MKSOCK_ACL, |
589 |
|
|
+ dentry, nd.mnt); |
590 |
|
|
+ if (error) |
591 |
|
|
+ break; |
592 |
|
|
+ /***** TOMOYO Linux end. *****/ |
593 |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0); |
594 |
|
|
break; |
595 |
|
|
case S_IFDIR: |
596 |
|
|
@@ -1906,6 +1959,13 @@ asmlinkage long sys_mkdirat(int dfd, con |
597 |
|
|
if (!IS_ERR(dentry)) { |
598 |
|
|
if (!IS_POSIXACL(nd.dentry->d_inode)) |
599 |
|
|
mode &= ~current->fs->umask; |
600 |
|
|
+ /***** TOMOYO Linux start. *****/ |
601 |
|
|
+ error = pre_vfs_mkdir(nd.dentry->d_inode, dentry); |
602 |
|
|
+ if (!error) |
603 |
|
|
+ error = ccs_check_1path_perm(TYPE_MKDIR_ACL, |
604 |
|
|
+ dentry, nd.mnt); |
605 |
|
|
+ if (!error) |
606 |
|
|
+ /***** TOMOYO Linux end. *****/ |
607 |
|
|
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
608 |
|
|
dput(dentry); |
609 |
|
|
} |
610 |
|
|
@@ -2014,6 +2074,13 @@ static long do_rmdir(int dfd, const char |
611 |
|
|
dentry = lookup_hash(&nd); |
612 |
|
|
error = PTR_ERR(dentry); |
613 |
|
|
if (!IS_ERR(dentry)) { |
614 |
|
|
+ /***** TOMOYO Linux start. *****/ |
615 |
|
|
+ error = pre_vfs_rmdir(nd.dentry->d_inode, dentry); |
616 |
|
|
+ if (!error) |
617 |
|
|
+ error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, |
618 |
|
|
+ nd.mnt); |
619 |
|
|
+ if (!error) |
620 |
|
|
+ /***** TOMOYO Linux end. *****/ |
621 |
|
|
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
622 |
|
|
dput(dentry); |
623 |
|
|
} |
624 |
|
|
@@ -2073,6 +2140,10 @@ static long do_unlinkat(int dfd, const c |
625 |
|
|
struct dentry *dentry; |
626 |
|
|
struct nameidata nd; |
627 |
|
|
struct inode *inode = NULL; |
628 |
|
|
+ /***** TOMOYO Linux start. *****/ |
629 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_UNLINK)) |
630 |
|
|
+ return -EPERM; |
631 |
|
|
+ /***** TOMOYO Linux end. *****/ |
632 |
|
|
|
633 |
|
|
name = getname(pathname); |
634 |
|
|
if(IS_ERR(name)) |
635 |
|
|
@@ -2094,6 +2165,14 @@ static long do_unlinkat(int dfd, const c |
636 |
|
|
inode = dentry->d_inode; |
637 |
|
|
if (inode) |
638 |
|
|
atomic_inc(&inode->i_count); |
639 |
|
|
+ /***** TOMOYO Linux start. *****/ |
640 |
|
|
+ error = pre_vfs_unlink(nd.dentry->d_inode, dentry); |
641 |
|
|
+ if (error) |
642 |
|
|
+ goto exit2; |
643 |
|
|
+ error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt); |
644 |
|
|
+ if (error) |
645 |
|
|
+ goto exit2; |
646 |
|
|
+ /***** TOMOYO Linux end. *****/ |
647 |
|
|
error = vfs_unlink(nd.dentry->d_inode, dentry); |
648 |
|
|
exit2: |
649 |
|
|
dput(dentry); |
650 |
|
|
@@ -2156,6 +2235,10 @@ asmlinkage long sys_symlinkat(const char |
651 |
|
|
int error = 0; |
652 |
|
|
char * from; |
653 |
|
|
char * to; |
654 |
|
|
+ /***** TOMOYO Linux start. *****/ |
655 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SYMLINK)) |
656 |
|
|
+ return -EPERM; |
657 |
|
|
+ /***** TOMOYO Linux end. *****/ |
658 |
|
|
|
659 |
|
|
from = getname(oldname); |
660 |
|
|
if(IS_ERR(from)) |
661 |
|
|
@@ -2172,6 +2255,13 @@ asmlinkage long sys_symlinkat(const char |
662 |
|
|
dentry = lookup_create(&nd, 0); |
663 |
|
|
error = PTR_ERR(dentry); |
664 |
|
|
if (!IS_ERR(dentry)) { |
665 |
|
|
+ /***** TOMOYO Linux start. *****/ |
666 |
|
|
+ error = pre_vfs_symlink(nd.dentry->d_inode, dentry); |
667 |
|
|
+ if (!error) |
668 |
|
|
+ error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, |
669 |
|
|
+ dentry, nd.mnt); |
670 |
|
|
+ if (!error) |
671 |
|
|
+ /***** TOMOYO Linux end. *****/ |
672 |
|
|
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
673 |
|
|
dput(dentry); |
674 |
|
|
} |
675 |
|
|
@@ -2244,6 +2334,10 @@ asmlinkage long sys_linkat(int olddfd, c |
676 |
|
|
struct nameidata nd, old_nd; |
677 |
|
|
int error; |
678 |
|
|
char * to; |
679 |
|
|
+ /***** TOMOYO Linux start. *****/ |
680 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_LINK)) |
681 |
|
|
+ return -EPERM; |
682 |
|
|
+ /***** TOMOYO Linux end. *****/ |
683 |
|
|
|
684 |
|
|
if (flags != 0) |
685 |
|
|
return -EINVAL; |
686 |
|
|
@@ -2264,6 +2358,15 @@ asmlinkage long sys_linkat(int olddfd, c |
687 |
|
|
new_dentry = lookup_create(&nd, 0); |
688 |
|
|
error = PTR_ERR(new_dentry); |
689 |
|
|
if (!IS_ERR(new_dentry)) { |
690 |
|
|
+ /***** TOMOYO Linux start. *****/ |
691 |
|
|
+ error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, |
692 |
|
|
+ new_dentry); |
693 |
|
|
+ if (!error) |
694 |
|
|
+ error = ccs_check_2path_perm(TYPE_LINK_ACL, |
695 |
|
|
+ old_nd.dentry, old_nd.mnt, |
696 |
|
|
+ new_dentry, nd.mnt); |
697 |
|
|
+ if (!error) |
698 |
|
|
+ /***** TOMOYO Linux end. *****/ |
699 |
|
|
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
700 |
|
|
dput(new_dentry); |
701 |
|
|
} |
702 |
|
|
@@ -2490,6 +2593,17 @@ static int do_rename(int olddfd, const c |
703 |
|
|
if (new_dentry == trap) |
704 |
|
|
goto exit5; |
705 |
|
|
|
706 |
|
|
+ /***** TOMOYO Linux start. *****/ |
707 |
|
|
+ error = pre_vfs_rename(old_dir->d_inode, old_dentry, |
708 |
|
|
+ new_dir->d_inode, new_dentry); |
709 |
|
|
+ if (error) |
710 |
|
|
+ goto exit5; |
711 |
|
|
+ error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, |
712 |
|
|
+ new_dentry, newnd.mnt); |
713 |
|
|
+ if (error) |
714 |
|
|
+ goto exit5; |
715 |
|
|
+ /***** TOMOYO Linux end. *****/ |
716 |
|
|
+ |
717 |
|
|
error = vfs_rename(old_dir->d_inode, old_dentry, |
718 |
|
|
new_dir->d_inode, new_dentry); |
719 |
|
|
exit5: |
720 |
|
|
@@ -2512,6 +2626,10 @@ asmlinkage long sys_renameat(int olddfd, |
721 |
|
|
int error; |
722 |
|
|
char * from; |
723 |
|
|
char * to; |
724 |
|
|
+ /***** TOMOYO Linux start. *****/ |
725 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_RENAME)) |
726 |
|
|
+ return -EPERM; |
727 |
|
|
+ /***** TOMOYO Linux end. *****/ |
728 |
|
|
|
729 |
|
|
from = getname(oldname); |
730 |
|
|
if(IS_ERR(from)) |
731 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/namespace.c |
732 |
|
|
+++ linux-2.6.16-76.39vl4/fs/namespace.c |
733 |
|
|
@@ -26,6 +26,12 @@ |
734 |
|
|
#include <asm/uaccess.h> |
735 |
|
|
#include <asm/unistd.h> |
736 |
|
|
#include "pnode.h" |
737 |
|
|
+/***** SAKURA Linux start. *****/ |
738 |
|
|
+#include <linux/sakura.h> |
739 |
|
|
+/***** SAKURA Linux end. *****/ |
740 |
|
|
+/***** TOMOYO Linux start. *****/ |
741 |
|
|
+#include <linux/tomoyo.h> |
742 |
|
|
+/***** TOMOYO Linux end. *****/ |
743 |
|
|
|
744 |
|
|
extern int __init init_rootfs(void); |
745 |
|
|
|
746 |
|
|
@@ -509,6 +515,11 @@ static int do_umount(struct vfsmount *mn |
747 |
|
|
if (retval) |
748 |
|
|
return retval; |
749 |
|
|
|
750 |
|
|
+ /***** SAKURA Linux start. *****/ |
751 |
|
|
+ if (ccs_may_umount(mnt)) |
752 |
|
|
+ return -EPERM; |
753 |
|
|
+ /***** SAKURA Linux end. *****/ |
754 |
|
|
+ |
755 |
|
|
/* |
756 |
|
|
* Allow userspace to request a mountpoint be expired rather than |
757 |
|
|
* unmounting unconditionally. Unmount only happens if: |
758 |
|
|
@@ -597,6 +608,10 @@ asmlinkage long sys_umount(char __user * |
759 |
|
|
{ |
760 |
|
|
struct nameidata nd; |
761 |
|
|
int retval; |
762 |
|
|
+ /***** TOMOYO Linux start. *****/ |
763 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_UMOUNT)) |
764 |
|
|
+ return -EPERM; |
765 |
|
|
+ /***** TOMOYO Linux end. *****/ |
766 |
|
|
|
767 |
|
|
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
768 |
|
|
if (retval) |
769 |
|
|
@@ -881,6 +896,11 @@ static int do_loopback(struct nameidata |
770 |
|
|
|
771 |
|
|
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
772 |
|
|
goto out; |
773 |
|
|
+ /***** SAKURA Linux start. *****/ |
774 |
|
|
+ err = -EPERM; |
775 |
|
|
+ if (ccs_may_mount(nd)) |
776 |
|
|
+ goto out; |
777 |
|
|
+ /***** SAKURA Linux end. *****/ |
778 |
|
|
|
779 |
|
|
err = -ENOMEM; |
780 |
|
|
if (recurse) |
781 |
|
|
@@ -965,7 +985,11 @@ static int do_move_mount(struct nameidat |
782 |
|
|
err = -EINVAL; |
783 |
|
|
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
784 |
|
|
goto out; |
785 |
|
|
- |
786 |
|
|
+ /***** SAKURA Linux start. *****/ |
787 |
|
|
+ err = -EPERM; |
788 |
|
|
+ if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd)) |
789 |
|
|
+ goto out; |
790 |
|
|
+ /***** SAKURA Linux end. *****/ |
791 |
|
|
err = -ENOENT; |
792 |
|
|
mutex_lock(&nd->dentry->d_inode->i_mutex); |
793 |
|
|
if (IS_DEADDIR(nd->dentry->d_inode)) |
794 |
|
|
@@ -1067,6 +1091,11 @@ int do_add_mount(struct vfsmount *newmnt |
795 |
|
|
err = -EINVAL; |
796 |
|
|
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
797 |
|
|
goto unlock; |
798 |
|
|
+ /***** SAKURA Linux start. *****/ |
799 |
|
|
+ err = -EPERM; |
800 |
|
|
+ if (ccs_may_mount(nd)) |
801 |
|
|
+ goto unlock; |
802 |
|
|
+ /***** SAKURA Linux end. *****/ |
803 |
|
|
|
804 |
|
|
newmnt->mnt_flags = mnt_flags; |
805 |
|
|
if ((err = graft_tree(newmnt, nd))) |
806 |
|
|
@@ -1284,6 +1313,17 @@ long do_mount(char *dev_name, char *dir_ |
807 |
|
|
if (data_page) |
808 |
|
|
((char *)data_page)[PAGE_SIZE - 1] = 0; |
809 |
|
|
|
810 |
|
|
+ /***** TOMOYO Linux start. *****/ |
811 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_MOUNT)) |
812 |
|
|
+ return -EPERM; |
813 |
|
|
+ /***** TOMOYO Linux end. *****/ |
814 |
|
|
+ /***** SAKURA Linux start. *****/ |
815 |
|
|
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
816 |
|
|
+ &flags); |
817 |
|
|
+ if (retval) |
818 |
|
|
+ return retval; |
819 |
|
|
+ /***** SAKURA Linux end. *****/ |
820 |
|
|
+ |
821 |
|
|
/* Separate the per-mountpoint flags */ |
822 |
|
|
if (flags & MS_NOSUID) |
823 |
|
|
mnt_flags |= MNT_NOSUID; |
824 |
|
|
@@ -1582,6 +1622,10 @@ asmlinkage long sys_pivot_root(const cha |
825 |
|
|
|
826 |
|
|
if (!capable(CAP_SYS_ADMIN)) |
827 |
|
|
return -EPERM; |
828 |
|
|
+ /***** TOMOYO Linux start. *****/ |
829 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT)) |
830 |
|
|
+ return -EPERM; |
831 |
|
|
+ /***** TOMOYO Linux end. *****/ |
832 |
|
|
|
833 |
|
|
lock_kernel(); |
834 |
|
|
|
835 |
|
|
@@ -1598,6 +1642,10 @@ asmlinkage long sys_pivot_root(const cha |
836 |
|
|
goto out1; |
837 |
|
|
|
838 |
|
|
error = security_sb_pivotroot(&old_nd, &new_nd); |
839 |
|
|
+ /***** SAKURA Linux start. *****/ |
840 |
|
|
+ if (!error) |
841 |
|
|
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
842 |
|
|
+ /***** SAKURA Linux end. *****/ |
843 |
|
|
if (error) { |
844 |
|
|
path_release(&old_nd); |
845 |
|
|
goto out1; |
846 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/open.c |
847 |
|
|
+++ linux-2.6.16-76.39vl4/fs/open.c |
848 |
|
|
@@ -30,6 +30,13 @@ |
849 |
|
|
|
850 |
|
|
#include <asm/unistd.h> |
851 |
|
|
|
852 |
|
|
+/***** SAKURA Linux start. *****/ |
853 |
|
|
+#include <linux/sakura.h> |
854 |
|
|
+/***** SAKURA Linux end. *****/ |
855 |
|
|
+/***** TOMOYO Linux start. *****/ |
856 |
|
|
+#include <linux/tomoyo.h> |
857 |
|
|
+/***** TOMOYO Linux end. *****/ |
858 |
|
|
+ |
859 |
|
|
int vfs_statfs(struct super_block *sb, struct kstatfs *buf) |
860 |
|
|
{ |
861 |
|
|
int retval = -ENODEV; |
862 |
|
|
@@ -266,6 +273,10 @@ static long do_sys_truncate(const char _ |
863 |
|
|
if (error) |
864 |
|
|
goto dput_and_out; |
865 |
|
|
|
866 |
|
|
+ /***** TOMOYO Linux start. *****/ |
867 |
|
|
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt); |
868 |
|
|
+ if (!error) |
869 |
|
|
+ /***** TOMOYO Linux end. *****/ |
870 |
|
|
error = locks_verify_truncate(inode, NULL, length); |
871 |
|
|
if (!error) { |
872 |
|
|
DQUOT_INIT(inode); |
873 |
|
|
@@ -318,7 +329,11 @@ static long do_sys_ftruncate(unsigned in |
874 |
|
|
error = -EPERM; |
875 |
|
|
if (IS_APPEND(inode)) |
876 |
|
|
goto out_putf; |
877 |
|
|
- |
878 |
|
|
+ /***** TOMOYO Linux start. *****/ |
879 |
|
|
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt); |
880 |
|
|
+ if (error) |
881 |
|
|
+ goto out_putf; |
882 |
|
|
+ /***** TOMOYO Linux end. *****/ |
883 |
|
|
error = locks_verify_truncate(inode, file, length); |
884 |
|
|
if (!error) |
885 |
|
|
error = do_truncate(dentry, length, 0, file); |
886 |
|
|
@@ -607,6 +622,14 @@ asmlinkage long sys_chroot(const char __ |
887 |
|
|
error = -EPERM; |
888 |
|
|
if (!capable(CAP_SYS_CHROOT)) |
889 |
|
|
goto dput_and_out; |
890 |
|
|
+ /***** TOMOYO Linux start. *****/ |
891 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_CHROOT)) |
892 |
|
|
+ goto dput_and_out; |
893 |
|
|
+ /***** TOMOYO Linux end. *****/ |
894 |
|
|
+ /***** SAKURA Linux start. *****/ |
895 |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
896 |
|
|
+ goto dput_and_out; |
897 |
|
|
+ /***** SAKURA Linux end. *****/ |
898 |
|
|
|
899 |
|
|
set_fs_root(current->fs, nd.mnt, nd.dentry); |
900 |
|
|
set_fs_altroot(); |
901 |
|
|
@@ -1189,6 +1212,10 @@ EXPORT_SYMBOL(sys_close); |
902 |
|
|
*/ |
903 |
|
|
asmlinkage long sys_vhangup(void) |
904 |
|
|
{ |
905 |
|
|
+ /***** TOMOYO Linux start. *****/ |
906 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_VHANGUP)) |
907 |
|
|
+ return -EPERM; |
908 |
|
|
+ /***** TOMOYO Linux end. *****/ |
909 |
|
|
if (capable(CAP_SYS_TTY_CONFIG)) { |
910 |
|
|
tty_vhangup(current->signal->tty); |
911 |
|
|
return 0; |
912 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/proc/Makefile |
913 |
|
|
+++ linux-2.6.16-76.39vl4/fs/proc/Makefile |
914 |
|
|
@@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge |
915 |
|
|
proc-$(CONFIG_PROC_KCORE) += kcore.o |
916 |
|
|
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
917 |
|
|
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
918 |
|
|
+ |
919 |
|
|
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
920 |
|
|
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
921 |
|
|
--- linux-2.6.16-76.39vl4.orig/fs/proc/proc_misc.c |
922 |
|
|
+++ linux-2.6.16-76.39vl4/fs/proc/proc_misc.c |
923 |
|
|
@@ -682,4 +682,9 @@ void __init proc_misc_init(void) |
924 |
|
|
if (entry) |
925 |
|
|
entry->proc_fops = &proc_sysrq_trigger_operations; |
926 |
|
|
#endif |
927 |
|
|
+ /***** CCS start. *****/ |
928 |
|
|
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
929 |
kumaneko |
1766 |
+ printk(KERN_INFO "Hook version: 2.6.16-76.39vl4 2008/10/30\n"); |
930 |
kumaneko |
1498 |
+#endif |
931 |
|
|
+ /***** CCS end. *****/ |
932 |
|
|
} |
933 |
|
|
--- linux-2.6.16-76.39vl4.orig/include/linux/init_task.h |
934 |
|
|
+++ linux-2.6.16-76.39vl4/include/linux/init_task.h |
935 |
|
|
@@ -121,6 +121,10 @@ extern struct group_info init_groups; |
936 |
|
|
.journal_info = NULL, \ |
937 |
|
|
.cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
938 |
|
|
.fs_excl = ATOMIC_INIT(0), \ |
939 |
|
|
+ /***** TOMOYO Linux start. *****/ \ |
940 |
|
|
+ .domain_info = &KERNEL_DOMAIN, \ |
941 |
|
|
+ .tomoyo_flags = 0, \ |
942 |
|
|
+ /***** TOMOYO Linux end. *****/ \ |
943 |
|
|
} |
944 |
|
|
|
945 |
|
|
|
946 |
|
|
--- linux-2.6.16-76.39vl4.orig/include/linux/sched.h |
947 |
|
|
+++ linux-2.6.16-76.39vl4/include/linux/sched.h |
948 |
|
|
@@ -40,6 +40,11 @@ |
949 |
|
|
|
950 |
|
|
struct exec_domain; |
951 |
|
|
|
952 |
|
|
+/***** TOMOYO Linux start. *****/ |
953 |
|
|
+struct domain_info; |
954 |
|
|
+extern struct domain_info KERNEL_DOMAIN; |
955 |
|
|
+/***** TOMOYO Linux end. *****/ |
956 |
|
|
+ |
957 |
|
|
/* |
958 |
|
|
* cloning flags: |
959 |
|
|
*/ |
960 |
|
|
@@ -871,6 +876,10 @@ struct task_struct { |
961 |
|
|
#endif |
962 |
|
|
atomic_t fs_excl; /* holding fs exclusive resources */ |
963 |
|
|
struct rcu_head rcu; |
964 |
|
|
+ /***** TOMOYO Linux start. *****/ |
965 |
|
|
+ struct domain_info *domain_info; |
966 |
|
|
+ u32 tomoyo_flags; |
967 |
|
|
+ /***** TOMOYO Linux end. *****/ |
968 |
|
|
}; |
969 |
|
|
|
970 |
|
|
static inline pid_t process_group(struct task_struct *tsk) |
971 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/compat.c |
972 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/compat.c |
973 |
|
|
@@ -23,6 +23,9 @@ |
974 |
|
|
#include <linux/security.h> |
975 |
|
|
|
976 |
|
|
#include <asm/uaccess.h> |
977 |
|
|
+/***** TOMOYO Linux start. *****/ |
978 |
|
|
+#include <linux/tomoyo.h> |
979 |
|
|
+/***** TOMOYO Linux end. *****/ |
980 |
|
|
|
981 |
|
|
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
982 |
|
|
{ |
983 |
|
|
@@ -864,6 +867,10 @@ asmlinkage long compat_sys_stime(compat_ |
984 |
|
|
err = security_settime(&tv, NULL); |
985 |
|
|
if (err) |
986 |
|
|
return err; |
987 |
|
|
+ /***** TOMOYO Linux start. *****/ |
988 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
989 |
|
|
+ return -EPERM; |
990 |
|
|
+ /***** TOMOYO Linux end. *****/ |
991 |
|
|
|
992 |
|
|
do_settimeofday(&tv); |
993 |
|
|
return 0; |
994 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/kexec.c |
995 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/kexec.c |
996 |
|
|
@@ -26,6 +26,9 @@ |
997 |
|
|
#include <asm/io.h> |
998 |
|
|
#include <asm/system.h> |
999 |
|
|
#include <asm/semaphore.h> |
1000 |
|
|
+/***** TOMOYO Linux start. *****/ |
1001 |
|
|
+#include <linux/tomoyo.h> |
1002 |
|
|
+/***** TOMOYO Linux end. *****/ |
1003 |
|
|
|
1004 |
|
|
/* Per cpu memory for storing cpu states in case of system crash. */ |
1005 |
|
|
note_buf_t* crash_notes; |
1006 |
|
|
@@ -922,6 +925,10 @@ asmlinkage long sys_kexec_load(unsigned |
1007 |
|
|
/* We only trust the superuser with rebooting the system. */ |
1008 |
|
|
if (!capable(CAP_SYS_BOOT)) |
1009 |
|
|
return -EPERM; |
1010 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1011 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD)) |
1012 |
|
|
+ return -EPERM; |
1013 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1014 |
|
|
|
1015 |
|
|
/* |
1016 |
|
|
* Verify we have a legal set of flags |
1017 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/kmod.c |
1018 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/kmod.c |
1019 |
|
|
@@ -150,6 +150,11 @@ static int ____call_usermodehelper(void |
1020 |
|
|
/* We can run anywhere, unlike our parent keventd(). */ |
1021 |
|
|
set_cpus_allowed(current, CPU_MASK_ALL); |
1022 |
|
|
|
1023 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1024 |
|
|
+ current->domain_info = &KERNEL_DOMAIN; |
1025 |
|
|
+ current->tomoyo_flags = 0; |
1026 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1027 |
|
|
+ |
1028 |
|
|
retval = -EPERM; |
1029 |
|
|
if (current->fs->root) |
1030 |
|
|
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
1031 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/module.c |
1032 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/module.c |
1033 |
|
|
@@ -42,6 +42,9 @@ |
1034 |
|
|
#include <asm/uaccess.h> |
1035 |
|
|
#include <asm/semaphore.h> |
1036 |
|
|
#include <asm/cacheflush.h> |
1037 |
|
|
+/***** TOMOYO Linux start. *****/ |
1038 |
|
|
+#include <linux/tomoyo.h> |
1039 |
|
|
+/***** TOMOYO Linux end. *****/ |
1040 |
|
|
|
1041 |
|
|
#if 0 |
1042 |
|
|
#define DEBUGP printk |
1043 |
|
|
@@ -578,7 +581,10 @@ sys_delete_module(const char __user *nam |
1044 |
|
|
|
1045 |
|
|
if (!capable(CAP_SYS_MODULE)) |
1046 |
|
|
return -EPERM; |
1047 |
|
|
- |
1048 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1049 |
|
|
+ if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) |
1050 |
|
|
+ return -EPERM; |
1051 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1052 |
|
|
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
1053 |
|
|
return -EFAULT; |
1054 |
|
|
name[MODULE_NAME_LEN-1] = '\0'; |
1055 |
|
|
@@ -1931,7 +1937,10 @@ sys_init_module(void __user *umod, |
1056 |
|
|
/* Must have permission */ |
1057 |
|
|
if (!capable(CAP_SYS_MODULE)) |
1058 |
|
|
return -EPERM; |
1059 |
|
|
- |
1060 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1061 |
|
|
+ if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) |
1062 |
|
|
+ return -EPERM; |
1063 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1064 |
|
|
/* Only one module load at a time, please */ |
1065 |
|
|
if (down_interruptible(&module_mutex) != 0) |
1066 |
|
|
return -EINTR; |
1067 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/ptrace.c |
1068 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/ptrace.c |
1069 |
|
|
@@ -21,6 +21,9 @@ |
1070 |
|
|
|
1071 |
|
|
#include <asm/pgtable.h> |
1072 |
|
|
#include <asm/uaccess.h> |
1073 |
|
|
+/***** TOMOYO Linux start. *****/ |
1074 |
|
|
+#include <linux/tomoyo.h> |
1075 |
|
|
+/***** TOMOYO Linux end. *****/ |
1076 |
|
|
|
1077 |
|
|
/* |
1078 |
|
|
* ptrace a task: make the debugger its new parent and |
1079 |
|
|
@@ -495,6 +498,12 @@ asmlinkage long sys_ptrace(long request, |
1080 |
|
|
/* |
1081 |
|
|
* This lock_kernel fixes a subtle race with suid exec |
1082 |
|
|
*/ |
1083 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1084 |
|
|
+#ifdef TOMOYO_SYS_PTRACE |
1085 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
1086 |
|
|
+ return -EPERM; |
1087 |
|
|
+#endif |
1088 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1089 |
|
|
lock_kernel(); |
1090 |
|
|
if (request == PTRACE_TRACEME) { |
1091 |
|
|
ret = ptrace_traceme(); |
1092 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/sched.c |
1093 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/sched.c |
1094 |
|
|
@@ -52,6 +52,9 @@ |
1095 |
|
|
#include <asm/tlb.h> |
1096 |
|
|
|
1097 |
|
|
#include <asm/unistd.h> |
1098 |
|
|
+/***** TOMOYO Linux start. *****/ |
1099 |
|
|
+#include <linux/tomoyo.h> |
1100 |
|
|
+/***** TOMOYO Linux end. *****/ |
1101 |
|
|
|
1102 |
|
|
/* |
1103 |
|
|
* Convert user-nice values [ -20 ... 0 ... 19 ] |
1104 |
|
|
@@ -3545,6 +3548,10 @@ asmlinkage long sys_nice(int increment) |
1105 |
|
|
{ |
1106 |
|
|
int retval; |
1107 |
|
|
long nice; |
1108 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1109 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_NICE)) |
1110 |
|
|
+ return -EPERM; |
1111 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1112 |
|
|
|
1113 |
|
|
/* |
1114 |
|
|
* Setpriority might change our priority at the same moment. |
1115 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/signal.c |
1116 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/signal.c |
1117 |
|
|
@@ -30,6 +30,9 @@ |
1118 |
|
|
#include <asm/uaccess.h> |
1119 |
|
|
#include <asm/unistd.h> |
1120 |
|
|
#include <asm/siginfo.h> |
1121 |
|
|
+/***** TOMOYO Linux start. *****/ |
1122 |
|
|
+#include <linux/tomoyo.h> |
1123 |
|
|
+/***** TOMOYO Linux end. *****/ |
1124 |
|
|
|
1125 |
|
|
/* |
1126 |
|
|
* SLAB caches for signal bits. |
1127 |
|
|
@@ -2336,6 +2339,12 @@ asmlinkage long |
1128 |
|
|
sys_kill(int pid, int sig) |
1129 |
|
|
{ |
1130 |
|
|
struct siginfo info; |
1131 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1132 |
|
|
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
1133 |
|
|
+ return -EPERM; |
1134 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1135 |
|
|
+ return -EPERM; |
1136 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1137 |
|
|
|
1138 |
|
|
info.si_signo = sig; |
1139 |
|
|
info.si_errno = 0; |
1140 |
|
|
@@ -2394,6 +2403,12 @@ asmlinkage long sys_tgkill(int tgid, int |
1141 |
|
|
/* This is only valid for single tasks */ |
1142 |
|
|
if (pid <= 0 || tgid <= 0) |
1143 |
|
|
return -EINVAL; |
1144 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1145 |
|
|
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
1146 |
|
|
+ return -EPERM; |
1147 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1148 |
|
|
+ return -EPERM; |
1149 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1150 |
|
|
|
1151 |
|
|
return do_tkill(tgid, pid, sig); |
1152 |
|
|
} |
1153 |
|
|
@@ -2407,6 +2422,12 @@ sys_tkill(int pid, int sig) |
1154 |
|
|
/* This is only valid for single tasks */ |
1155 |
|
|
if (pid <= 0) |
1156 |
|
|
return -EINVAL; |
1157 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1158 |
|
|
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
1159 |
|
|
+ return -EPERM; |
1160 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1161 |
|
|
+ return -EPERM; |
1162 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1163 |
|
|
|
1164 |
|
|
return do_tkill(0, pid, sig); |
1165 |
|
|
} |
1166 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/sys.c |
1167 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/sys.c |
1168 |
|
|
@@ -38,6 +38,9 @@ |
1169 |
|
|
#include <asm/uaccess.h> |
1170 |
|
|
#include <asm/io.h> |
1171 |
|
|
#include <asm/unistd.h> |
1172 |
|
|
+/***** TOMOYO Linux start. *****/ |
1173 |
|
|
+#include <linux/tomoyo.h> |
1174 |
|
|
+/***** TOMOYO Linux end. *****/ |
1175 |
|
|
|
1176 |
|
|
#ifndef SET_UNALIGN_CTL |
1177 |
|
|
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
1178 |
|
|
@@ -269,6 +272,12 @@ asmlinkage long sys_setpriority(int whic |
1179 |
|
|
|
1180 |
|
|
if (which > 2 || which < 0) |
1181 |
|
|
goto out; |
1182 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1183 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_NICE)) { |
1184 |
|
|
+ error = -EPERM; |
1185 |
|
|
+ goto out; |
1186 |
|
|
+ } |
1187 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1188 |
|
|
|
1189 |
|
|
/* normalize: avoid signed division (rounding problems) */ |
1190 |
|
|
error = -ESRCH; |
1191 |
|
|
@@ -496,6 +505,10 @@ asmlinkage long sys_reboot(int magic1, i |
1192 |
|
|
magic2 != LINUX_REBOOT_MAGIC2B && |
1193 |
|
|
magic2 != LINUX_REBOOT_MAGIC2C)) |
1194 |
|
|
return -EINVAL; |
1195 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1196 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_REBOOT)) |
1197 |
|
|
+ return -EPERM; |
1198 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1199 |
|
|
|
1200 |
|
|
/* Instead of trying to make the power_off code look like |
1201 |
|
|
* halt when pm_power_off is not set do it the easy way. |
1202 |
|
|
@@ -1533,6 +1546,10 @@ asmlinkage long sys_sethostname(char __u |
1203 |
|
|
return -EPERM; |
1204 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
1205 |
|
|
return -EINVAL; |
1206 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1207 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) |
1208 |
|
|
+ return -EPERM; |
1209 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1210 |
|
|
down_write(&uts_sem); |
1211 |
|
|
errno = -EFAULT; |
1212 |
|
|
if (!copy_from_user(tmp, name, len)) { |
1213 |
|
|
@@ -1578,6 +1595,10 @@ asmlinkage long sys_setdomainname(char _ |
1214 |
|
|
return -EPERM; |
1215 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
1216 |
|
|
return -EINVAL; |
1217 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1218 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) |
1219 |
|
|
+ return -EPERM; |
1220 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1221 |
|
|
|
1222 |
|
|
down_write(&uts_sem); |
1223 |
|
|
errno = -EFAULT; |
1224 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/sysctl.c |
1225 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/sysctl.c |
1226 |
|
|
@@ -49,6 +49,9 @@ |
1227 |
|
|
|
1228 |
|
|
#include <asm/uaccess.h> |
1229 |
|
|
#include <asm/processor.h> |
1230 |
|
|
+/***** TOMOYO Linux start. *****/ |
1231 |
|
|
+#include <linux/tomoyo.h> |
1232 |
|
|
+/***** TOMOYO Linux end. *****/ |
1233 |
|
|
|
1234 |
|
|
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
1235 |
|
|
void __user *buffer, size_t *lenp, loff_t *ppos); |
1236 |
|
|
@@ -1108,6 +1111,100 @@ void __init sysctl_init(void) |
1237 |
|
|
#endif |
1238 |
|
|
} |
1239 |
|
|
|
1240 |
|
|
+/***** TOMOYO Linux start. *****/ |
1241 |
|
|
+static int try_parse_table(int __user *name, int nlen, void __user *oldval, |
1242 |
|
|
+ void __user *newval, ctl_table *table) |
1243 |
|
|
+{ |
1244 |
|
|
+ int n; |
1245 |
|
|
+ int error = -ENOMEM; |
1246 |
|
|
+ int op = 0; |
1247 |
|
|
+ char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); |
1248 |
|
|
+ if (oldval) |
1249 |
|
|
+ op |= 004; |
1250 |
|
|
+ if (newval) |
1251 |
|
|
+ op |= 002; |
1252 |
|
|
+ if (!op) { /* Neither read nor write */ |
1253 |
|
|
+ error = 0; |
1254 |
|
|
+ goto out; |
1255 |
|
|
+ } |
1256 |
|
|
+ if (!buffer) |
1257 |
|
|
+ goto out; |
1258 |
|
|
+ memset(buffer, 0, PAGE_SIZE); |
1259 |
|
|
+ snprintf(buffer, PAGE_SIZE - 1, "/proc/sys"); |
1260 |
|
|
+ repeat: |
1261 |
|
|
+ if (!nlen) { |
1262 |
|
|
+ error = -ENOTDIR; |
1263 |
|
|
+ goto out; |
1264 |
|
|
+ } |
1265 |
|
|
+ if (get_user(n, name)) { |
1266 |
|
|
+ error = -EFAULT; |
1267 |
|
|
+ goto out; |
1268 |
|
|
+ } |
1269 |
|
|
+ for ( ; table->ctl_name; table++) { |
1270 |
|
|
+ if (n == table->ctl_name || table->ctl_name == CTL_ANY) { |
1271 |
|
|
+ int pos = strlen(buffer); |
1272 |
|
|
+ const char *cp = table->procname; |
1273 |
|
|
+ error = -ENOMEM; |
1274 |
|
|
+ if (cp) { |
1275 |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
1276 |
|
|
+ goto out; |
1277 |
|
|
+ buffer[pos++] = '/'; |
1278 |
|
|
+ while (*cp) { |
1279 |
|
|
+ const unsigned char c |
1280 |
|
|
+ = *(const unsigned char *) cp; |
1281 |
|
|
+ if (c == '\\') { |
1282 |
|
|
+ if (pos + 2 >= PAGE_SIZE - 1) |
1283 |
|
|
+ goto out; |
1284 |
|
|
+ buffer[pos++] = '\\'; |
1285 |
|
|
+ buffer[pos++] = '\\'; |
1286 |
|
|
+ } else if (c > ' ' && c < 127) { |
1287 |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
1288 |
|
|
+ goto out; |
1289 |
|
|
+ buffer[pos++] = c; |
1290 |
|
|
+ } else { |
1291 |
|
|
+ if (pos + 4 >= PAGE_SIZE - 1) |
1292 |
|
|
+ goto out; |
1293 |
|
|
+ buffer[pos++] = '\\'; |
1294 |
|
|
+ buffer[pos++] = (c >> 6) + '0'; |
1295 |
|
|
+ buffer[pos++] = ((c >> 3) & 7) |
1296 |
|
|
+ + '0'; |
1297 |
|
|
+ buffer[pos++] = (c & 7) + '0'; |
1298 |
|
|
+ } |
1299 |
|
|
+ cp++; |
1300 |
|
|
+ } |
1301 |
|
|
+ } else { |
1302 |
|
|
+ /* Assume nobody assigns "=\$=" for procname. */ |
1303 |
|
|
+ snprintf(buffer + pos, PAGE_SIZE - pos - 1, |
1304 |
|
|
+ "/=%d=", table->ctl_name); |
1305 |
|
|
+ if (!memchr(buffer, '\0', PAGE_SIZE - 2)) |
1306 |
|
|
+ goto out; |
1307 |
|
|
+ } |
1308 |
|
|
+ if (table->child) { |
1309 |
|
|
+ if (table->strategy) { |
1310 |
|
|
+ /* printk("sysctl='%s'\n", buffer); */ |
1311 |
|
|
+ if (ccs_check_file_perm(buffer, op, |
1312 |
|
|
+ "sysctl")) { |
1313 |
|
|
+ error = -EPERM; |
1314 |
|
|
+ goto out; |
1315 |
|
|
+ } |
1316 |
|
|
+ } |
1317 |
|
|
+ name++; |
1318 |
|
|
+ nlen--; |
1319 |
|
|
+ table = table->child; |
1320 |
|
|
+ goto repeat; |
1321 |
|
|
+ } |
1322 |
|
|
+ /* printk("sysctl='%s'\n", buffer); */ |
1323 |
|
|
+ error = ccs_check_file_perm(buffer, op, "sysctl"); |
1324 |
|
|
+ goto out; |
1325 |
|
|
+ } |
1326 |
|
|
+ } |
1327 |
|
|
+ error = -ENOTDIR; |
1328 |
|
|
+ out: |
1329 |
|
|
+ kfree(buffer); |
1330 |
|
|
+ return error; |
1331 |
|
|
+} |
1332 |
|
|
+/***** TOMOYO Linux end. *****/ |
1333 |
|
|
+ |
1334 |
|
|
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
1335 |
|
|
void __user *newval, size_t newlen) |
1336 |
|
|
{ |
1337 |
|
|
@@ -1133,6 +1230,11 @@ int do_sysctl(int __user *name, int nlen |
1338 |
|
|
|
1339 |
|
|
spin_unlock(&sysctl_lock); |
1340 |
|
|
|
1341 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1342 |
|
|
+ error = try_parse_table(name, nlen, oldval, newval, |
1343 |
|
|
+ head->ctl_table); |
1344 |
|
|
+ if (!error) |
1345 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1346 |
|
|
error = parse_table(name, nlen, oldval, oldlenp, |
1347 |
|
|
newval, newlen, head->ctl_table, |
1348 |
|
|
&context); |
1349 |
|
|
@@ -1205,6 +1307,15 @@ repeat: |
1350 |
|
|
if (ctl_perm(table, 001)) |
1351 |
|
|
return -EPERM; |
1352 |
|
|
if (table->strategy) { |
1353 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1354 |
|
|
+ int op = 0; |
1355 |
|
|
+ if (oldval) |
1356 |
|
|
+ op |= 004; |
1357 |
|
|
+ if (newval) |
1358 |
|
|
+ op |= 002; |
1359 |
|
|
+ if (ctl_perm(table, op)) |
1360 |
|
|
+ return -EPERM; |
1361 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1362 |
|
|
error = table->strategy( |
1363 |
|
|
table, name, nlen, |
1364 |
|
|
oldval, oldlenp, |
1365 |
|
|
--- linux-2.6.16-76.39vl4.orig/kernel/time.c |
1366 |
|
|
+++ linux-2.6.16-76.39vl4/kernel/time.c |
1367 |
|
|
@@ -39,6 +39,9 @@ |
1368 |
|
|
|
1369 |
|
|
#include <asm/uaccess.h> |
1370 |
|
|
#include <asm/unistd.h> |
1371 |
|
|
+/***** TOMOYO Linux start. *****/ |
1372 |
|
|
+#include <linux/tomoyo.h> |
1373 |
|
|
+/***** TOMOYO Linux end. *****/ |
1374 |
|
|
|
1375 |
|
|
/* |
1376 |
|
|
* The timezone where the local system is located. Used as a default by some |
1377 |
|
|
@@ -91,6 +94,10 @@ asmlinkage long sys_stime(time_t __user |
1378 |
|
|
err = security_settime(&tv, NULL); |
1379 |
|
|
if (err) |
1380 |
|
|
return err; |
1381 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1382 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
1383 |
|
|
+ return -EPERM; |
1384 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1385 |
|
|
|
1386 |
|
|
do_settimeofday(&tv); |
1387 |
|
|
return 0; |
1388 |
|
|
@@ -161,6 +168,10 @@ int do_sys_settimeofday(struct timespec |
1389 |
|
|
error = security_settime(tv, tz); |
1390 |
|
|
if (error) |
1391 |
|
|
return error; |
1392 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1393 |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
1394 |
|
|
+ return -EPERM; |
1395 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1396 |
|
|
|
1397 |
|
|
if (tz) { |
1398 |
|
|
/* SMP safe, global irq locking makes it work. */ |
1399 |
|
|
@@ -239,6 +250,10 @@ int do_adjtimex(struct timex *txc) |
1400 |
|
|
/* In order to modify anything, you gotta be super-user! */ |
1401 |
|
|
if (txc->modes && !capable(CAP_SYS_TIME)) |
1402 |
|
|
return -EPERM; |
1403 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1404 |
|
|
+ if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME)) |
1405 |
|
|
+ return -EPERM; |
1406 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1407 |
|
|
|
1408 |
|
|
/* Now we validate the data before disabling interrupts */ |
1409 |
|
|
|
1410 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/core/datagram.c |
1411 |
|
|
+++ linux-2.6.16-76.39vl4/net/core/datagram.c |
1412 |
|
|
@@ -56,6 +56,11 @@ |
1413 |
|
|
#include <net/sock.h> |
1414 |
|
|
#include <net/tcp_states.h> |
1415 |
|
|
|
1416 |
|
|
+/***** TOMOYO Linux start. *****/ |
1417 |
|
|
+#include <linux/tomoyo.h> |
1418 |
|
|
+#include <linux/tomoyo_socket.h> |
1419 |
|
|
+/***** TOMOYO Linux end. *****/ |
1420 |
|
|
+ |
1421 |
|
|
/* |
1422 |
|
|
* Is a socket 'connection oriented' ? |
1423 |
|
|
*/ |
1424 |
|
|
@@ -178,6 +183,12 @@ struct sk_buff *skb_recv_datagram(struct |
1425 |
|
|
} else |
1426 |
|
|
skb = skb_dequeue(&sk->sk_receive_queue); |
1427 |
|
|
|
1428 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1429 |
|
|
+ error = ccs_socket_recv_datagram_permission(sk, skb, flags); |
1430 |
|
|
+ if (error) |
1431 |
|
|
+ goto no_packet; |
1432 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1433 |
|
|
+ |
1434 |
|
|
if (skb) |
1435 |
|
|
return skb; |
1436 |
|
|
|
1437 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/ipv4/inet_connection_sock.c |
1438 |
|
|
+++ linux-2.6.16-76.39vl4/net/ipv4/inet_connection_sock.c |
1439 |
|
|
@@ -24,6 +24,9 @@ |
1440 |
|
|
#include <net/route.h> |
1441 |
|
|
#include <net/tcp_states.h> |
1442 |
|
|
#include <net/xfrm.h> |
1443 |
|
|
+/***** SAKURA Linux start. *****/ |
1444 |
|
|
+#include <linux/sakura.h> |
1445 |
|
|
+/***** SAKURA Linux end. *****/ |
1446 |
|
|
|
1447 |
|
|
#ifdef INET_CSK_DEBUG |
1448 |
|
|
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
1449 |
|
|
@@ -88,6 +91,10 @@ int inet_csk_get_port(struct inet_hashin |
1450 |
|
|
do { |
1451 |
|
|
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
1452 |
|
|
spin_lock(&head->lock); |
1453 |
|
|
+ /***** SAKURA Linux start. *****/ |
1454 |
|
|
+ if (ccs_may_autobind(rover)) |
1455 |
|
|
+ goto next; |
1456 |
|
|
+ /***** SAKURA Linux end. *****/ |
1457 |
|
|
inet_bind_bucket_for_each(tb, node, &head->chain) |
1458 |
|
|
if (tb->port == rover) |
1459 |
|
|
goto next; |
1460 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/ipv4/inet_hashtables.c |
1461 |
|
|
+++ linux-2.6.16-76.39vl4/net/ipv4/inet_hashtables.c |
1462 |
|
|
@@ -23,6 +23,9 @@ |
1463 |
|
|
#include <net/inet_connection_sock.h> |
1464 |
|
|
#include <net/inet_hashtables.h> |
1465 |
|
|
#include <net/ip.h> |
1466 |
|
|
+/***** SAKURA Linux start. *****/ |
1467 |
|
|
+#include <linux/sakura.h> |
1468 |
|
|
+/***** SAKURA Linux end. *****/ |
1469 |
|
|
|
1470 |
|
|
/* |
1471 |
|
|
* Allocate and initialize a new local port bind bucket. |
1472 |
|
|
@@ -268,6 +271,10 @@ int inet_hash_connect(struct inet_timewa |
1473 |
|
|
local_bh_disable(); |
1474 |
|
|
for (i = 1; i <= range; i++) { |
1475 |
|
|
port = low + (i + offset) % range; |
1476 |
|
|
+ /***** SAKURA Linux start. *****/ |
1477 |
|
|
+ if (ccs_may_autobind(port)) |
1478 |
|
|
+ continue; |
1479 |
|
|
+ /***** SAKURA Linux end. *****/ |
1480 |
|
|
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1481 |
|
|
spin_lock(&head->lock); |
1482 |
|
|
|
1483 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/ipv4/udp.c |
1484 |
|
|
+++ linux-2.6.16-76.39vl4/net/ipv4/udp.c |
1485 |
|
|
@@ -109,6 +109,9 @@ |
1486 |
|
|
#include <net/inet_common.h> |
1487 |
|
|
#include <net/checksum.h> |
1488 |
|
|
#include <net/xfrm.h> |
1489 |
|
|
+/***** SAKURA Linux start. *****/ |
1490 |
|
|
+#include <linux/sakura.h> |
1491 |
|
|
+/***** SAKURA Linux end. *****/ |
1492 |
|
|
|
1493 |
|
|
/* |
1494 |
|
|
* Snmp MIB for the UDP layer |
1495 |
|
|
@@ -147,6 +150,10 @@ static int udp_v4_get_port(struct sock * |
1496 |
|
|
result = sysctl_local_port_range[0] + |
1497 |
|
|
((result - sysctl_local_port_range[0]) & |
1498 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1499 |
|
|
+ /***** SAKURA Linux start. *****/ |
1500 |
|
|
+ if (ccs_may_autobind(result)) |
1501 |
|
|
+ continue; |
1502 |
|
|
+ /***** SAKURA Linux end. *****/ |
1503 |
|
|
goto gotit; |
1504 |
|
|
} |
1505 |
|
|
size = 0; |
1506 |
|
|
@@ -163,6 +170,10 @@ static int udp_v4_get_port(struct sock * |
1507 |
|
|
result = sysctl_local_port_range[0] |
1508 |
|
|
+ ((result - sysctl_local_port_range[0]) & |
1509 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1510 |
|
|
+ /***** SAKURA Linux start. *****/ |
1511 |
|
|
+ if (ccs_may_autobind(result)) |
1512 |
|
|
+ continue; |
1513 |
|
|
+ /***** SAKURA Linux end. *****/ |
1514 |
|
|
if (!udp_lport_inuse(result)) |
1515 |
|
|
break; |
1516 |
|
|
} |
1517 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/ipv6/inet6_hashtables.c |
1518 |
|
|
+++ linux-2.6.16-76.39vl4/net/ipv6/inet6_hashtables.c |
1519 |
|
|
@@ -22,6 +22,9 @@ |
1520 |
|
|
#include <net/inet_hashtables.h> |
1521 |
|
|
#include <net/inet6_hashtables.h> |
1522 |
|
|
#include <net/ip.h> |
1523 |
|
|
+/***** SAKURA Linux start. *****/ |
1524 |
|
|
+#include <linux/sakura.h> |
1525 |
|
|
+/***** SAKURA Linux end. *****/ |
1526 |
|
|
|
1527 |
|
|
struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, |
1528 |
|
|
const struct in6_addr *daddr, |
1529 |
|
|
@@ -93,7 +96,7 @@ static int __inet6_check_established(str |
1530 |
|
|
const struct in6_addr *saddr = &np->daddr; |
1531 |
|
|
const int dif = sk->sk_bound_dev_if; |
1532 |
|
|
const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
1533 |
|
|
- const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, |
1534 |
|
|
+ const unsigned int hash = inet6_ehashfn(daddr, lport, saddr, |
1535 |
|
|
inet->dport); |
1536 |
|
|
struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); |
1537 |
|
|
struct sock *sk2; |
1538 |
|
|
@@ -187,6 +190,10 @@ int inet6_hash_connect(struct inet_timew |
1539 |
|
|
local_bh_disable(); |
1540 |
|
|
for (i = 1; i <= range; i++) { |
1541 |
|
|
port = low + (i + offset) % range; |
1542 |
|
|
+ /***** SAKURA Linux start. *****/ |
1543 |
|
|
+ if (ccs_may_autobind(port)) |
1544 |
|
|
+ continue; |
1545 |
|
|
+ /***** SAKURA Linux end. *****/ |
1546 |
|
|
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1547 |
|
|
spin_lock(&head->lock); |
1548 |
|
|
|
1549 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/ipv6/udp.c |
1550 |
|
|
+++ linux-2.6.16-76.39vl4/net/ipv6/udp.c |
1551 |
|
|
@@ -59,6 +59,9 @@ |
1552 |
|
|
|
1553 |
|
|
#include <linux/proc_fs.h> |
1554 |
|
|
#include <linux/seq_file.h> |
1555 |
|
|
+/***** SAKURA Linux start. *****/ |
1556 |
|
|
+#include <linux/sakura.h> |
1557 |
|
|
+/***** SAKURA Linux end. *****/ |
1558 |
|
|
|
1559 |
|
|
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
1560 |
|
|
|
1561 |
|
|
@@ -89,6 +92,10 @@ static int udp_v6_get_port(struct sock * |
1562 |
|
|
result = sysctl_local_port_range[0] + |
1563 |
|
|
((result - sysctl_local_port_range[0]) & |
1564 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1565 |
|
|
+ /***** SAKURA Linux start. *****/ |
1566 |
|
|
+ if (ccs_may_autobind(result)) |
1567 |
|
|
+ continue; |
1568 |
|
|
+ /***** SAKURA Linux end. *****/ |
1569 |
|
|
goto gotit; |
1570 |
|
|
} |
1571 |
|
|
size = 0; |
1572 |
|
|
@@ -105,6 +112,10 @@ static int udp_v6_get_port(struct sock * |
1573 |
|
|
result = sysctl_local_port_range[0] |
1574 |
|
|
+ ((result - sysctl_local_port_range[0]) & |
1575 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1576 |
|
|
+ /***** SAKURA Linux start. *****/ |
1577 |
|
|
+ if (ccs_may_autobind(result)) |
1578 |
|
|
+ continue; |
1579 |
|
|
+ /***** SAKURA Linux end. *****/ |
1580 |
|
|
if (!udp_lport_inuse(result)) |
1581 |
|
|
break; |
1582 |
|
|
} |
1583 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/socket.c |
1584 |
|
|
+++ linux-2.6.16-76.39vl4/net/socket.c |
1585 |
|
|
@@ -97,6 +97,11 @@ |
1586 |
|
|
#include <net/sock.h> |
1587 |
|
|
#include <linux/netfilter.h> |
1588 |
|
|
|
1589 |
|
|
+/***** TOMOYO Linux start. *****/ |
1590 |
|
|
+#include <linux/tomoyo.h> |
1591 |
|
|
+#include <linux/tomoyo_socket.h> |
1592 |
|
|
+/***** TOMOYO Linux end. *****/ |
1593 |
|
|
+ |
1594 |
|
|
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1595 |
|
|
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
1596 |
|
|
size_t size, loff_t pos); |
1597 |
|
|
@@ -546,7 +551,12 @@ static inline int __sock_sendmsg(struct |
1598 |
|
|
err = security_socket_sendmsg(sock, msg, size); |
1599 |
|
|
if (err) |
1600 |
|
|
return err; |
1601 |
|
|
- |
1602 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1603 |
|
|
+ if (ccs_socket_sendmsg_permission(sock, |
1604 |
|
|
+ (struct sockaddr *) msg->msg_name, |
1605 |
|
|
+ msg->msg_namelen)) |
1606 |
|
|
+ return -EPERM; |
1607 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1608 |
|
|
return sock->ops->sendmsg(iocb, sock, msg, size); |
1609 |
|
|
} |
1610 |
|
|
|
1611 |
|
|
@@ -1102,6 +1112,12 @@ static int __sock_create(int family, int |
1612 |
|
|
family = PF_PACKET; |
1613 |
|
|
} |
1614 |
|
|
|
1615 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1616 |
|
|
+ err = ccs_socket_create_permission(family, type, protocol); |
1617 |
|
|
+ if (err) |
1618 |
|
|
+ return err; |
1619 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1620 |
|
|
+ |
1621 |
|
|
err = security_socket_create(family, type, protocol, kern); |
1622 |
|
|
if (err) |
1623 |
|
|
return err; |
1624 |
|
|
@@ -1299,6 +1315,12 @@ asmlinkage long sys_bind(int fd, struct |
1625 |
|
|
sockfd_put(sock); |
1626 |
|
|
return err; |
1627 |
|
|
} |
1628 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1629 |
|
|
+ err = ccs_socket_bind_permission(sock, |
1630 |
|
|
+ (struct sockaddr *) |
1631 |
|
|
+ address, addrlen); |
1632 |
|
|
+ if (!err) |
1633 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1634 |
|
|
err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen); |
1635 |
|
|
} |
1636 |
|
|
sockfd_put(sock); |
1637 |
|
|
@@ -1329,7 +1351,10 @@ asmlinkage long sys_listen(int fd, int b |
1638 |
|
|
sockfd_put(sock); |
1639 |
|
|
return err; |
1640 |
|
|
} |
1641 |
|
|
- |
1642 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1643 |
|
|
+ err = ccs_socket_listen_permission(sock); |
1644 |
|
|
+ if (!err) |
1645 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1646 |
|
|
err=sock->ops->listen(sock, backlog); |
1647 |
|
|
sockfd_put(sock); |
1648 |
|
|
} |
1649 |
|
|
@@ -1380,6 +1405,13 @@ asmlinkage long sys_accept(int fd, struc |
1650 |
|
|
if (err < 0) |
1651 |
|
|
goto out_release; |
1652 |
|
|
|
1653 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1654 |
|
|
+ if (ccs_socket_accept_permission(newsock, |
1655 |
|
|
+ (struct sockaddr *) address)) { |
1656 |
|
|
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1657 |
|
|
+ goto out_release; |
1658 |
|
|
+ } |
1659 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1660 |
|
|
if (upeer_sockaddr) { |
1661 |
|
|
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
1662 |
|
|
err = -ECONNABORTED; |
1663 |
|
|
@@ -1435,7 +1467,12 @@ asmlinkage long sys_connect(int fd, stru |
1664 |
|
|
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1665 |
|
|
if (err) |
1666 |
|
|
goto out_put; |
1667 |
|
|
- |
1668 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1669 |
|
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, |
1670 |
|
|
+ addrlen); |
1671 |
|
|
+ if (err) |
1672 |
|
|
+ goto out_put; |
1673 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1674 |
|
|
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
1675 |
|
|
sock->file->f_flags); |
1676 |
|
|
out_put: |
1677 |
|
|
--- linux-2.6.16-76.39vl4.orig/net/unix/af_unix.c |
1678 |
|
|
+++ linux-2.6.16-76.39vl4/net/unix/af_unix.c |
1679 |
|
|
@@ -117,6 +117,9 @@ |
1680 |
|
|
#include <linux/mount.h> |
1681 |
|
|
#include <net/checksum.h> |
1682 |
|
|
#include <linux/security.h> |
1683 |
|
|
+/***** TOMOYO Linux start. *****/ |
1684 |
|
|
+#include <linux/tomoyo.h> |
1685 |
|
|
+/***** TOMOYO Linux end. *****/ |
1686 |
|
|
|
1687 |
|
|
int sysctl_unix_max_dgram_qlen = 10; |
1688 |
|
|
|
1689 |
|
|
@@ -738,6 +741,11 @@ static int unix_bind(struct socket *sock |
1690 |
|
|
err = unix_autobind(sock); |
1691 |
|
|
goto out; |
1692 |
|
|
} |
1693 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1694 |
|
|
+ err = -EPERM; |
1695 |
|
|
+ if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) |
1696 |
|
|
+ goto out; |
1697 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1698 |
|
|
|
1699 |
|
|
err = unix_mkname(sunaddr, addr_len, &hash); |
1700 |
|
|
if (err < 0) |
1701 |
|
|
@@ -781,6 +789,13 @@ static int unix_bind(struct socket *sock |
1702 |
|
|
*/ |
1703 |
|
|
mode = S_IFSOCK | |
1704 |
|
|
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1705 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1706 |
|
|
+ err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
1707 |
|
|
+ if (!err) |
1708 |
|
|
+ err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry, |
1709 |
|
|
+ nd.mnt); |
1710 |
|
|
+ if (!err) |
1711 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1712 |
|
|
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1713 |
|
|
if (err) |
1714 |
|
|
goto out_mknod_dput; |