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