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