1 |
kumaneko |
2781 |
This is TOMOYO Linux patch for kernel 2.4.37.3. |
2 |
kumaneko |
1603 |
|
3 |
kumaneko |
2781 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.3.tar.bz2 |
4 |
kumaneko |
1603 |
--- |
5 |
kumaneko |
2298 |
Documentation/Configure.help | 86 +++++++++++++++++++++++++++++++++++++++++++ |
6 |
|
|
arch/alpha/kernel/ptrace.c | 7 +++ |
7 |
|
|
arch/arm/kernel/ptrace.c | 7 +++ |
8 |
|
|
arch/cris/kernel/ptrace.c | 7 +++ |
9 |
|
|
arch/i386/kernel/ptrace.c | 7 +++ |
10 |
|
|
arch/ia64/ia32/sys_ia32.c | 7 +++ |
11 |
|
|
arch/ia64/kernel/ptrace.c | 7 +++ |
12 |
|
|
arch/m68k/kernel/ptrace.c | 7 +++ |
13 |
|
|
arch/mips/kernel/ptrace.c | 7 +++ |
14 |
|
|
arch/mips64/kernel/ptrace.c | 11 +++++ |
15 |
|
|
arch/parisc/kernel/ptrace.c | 7 +++ |
16 |
|
|
arch/ppc/kernel/ptrace.c | 7 +++ |
17 |
|
|
arch/ppc64/kernel/ptrace.c | 7 +++ |
18 |
|
|
arch/ppc64/kernel/ptrace32.c | 7 +++ |
19 |
|
|
arch/s390/kernel/ptrace.c | 7 +++ |
20 |
|
|
arch/s390x/kernel/ptrace.c | 7 +++ |
21 |
|
|
arch/sh/kernel/ptrace.c | 7 +++ |
22 |
|
|
arch/sh64/kernel/ptrace.c | 7 +++ |
23 |
|
|
arch/sparc/kernel/ptrace.c | 9 ++++ |
24 |
|
|
arch/sparc64/kernel/ptrace.c | 9 ++++ |
25 |
|
|
arch/x86_64/ia32/ptrace32.c | 7 +++ |
26 |
|
|
arch/x86_64/kernel/ptrace.c | 7 +++ |
27 |
kumaneko |
1603 |
fs/Config.in | 3 + |
28 |
kumaneko |
2298 |
fs/Makefile | 2 - |
29 |
|
|
fs/attr.c | 10 +++++ |
30 |
kumaneko |
2306 |
fs/exec.c | 18 ++++++++- |
31 |
kumaneko |
2298 |
fs/fcntl.c | 8 ++++ |
32 |
|
|
fs/ioctl.c | 16 ++++++++ |
33 |
|
|
fs/namei.c | 71 +++++++++++++++++++++++++++++++++++ |
34 |
|
|
fs/namespace.c | 58 ++++++++++++++++++++++++++++- |
35 |
|
|
fs/open.c | 30 +++++++++++++++ |
36 |
|
|
fs/proc/Makefile | 4 ++ |
37 |
|
|
fs/proc/proc_misc.c | 5 ++ |
38 |
|
|
include/linux/sched.h | 12 ++++++ |
39 |
|
|
kernel/kmod.c | 5 ++ |
40 |
|
|
kernel/module.c | 15 +++++++ |
41 |
|
|
kernel/sched.c | 7 +++ |
42 |
|
|
kernel/signal.c | 15 +++++++ |
43 |
|
|
kernel/sys.c | 19 +++++++++ |
44 |
|
|
kernel/sysctl.c | 19 +++++++++ |
45 |
|
|
kernel/time.c | 15 +++++++ |
46 |
kumaneko |
2459 |
net/ipv4/raw.c | 8 ++++ |
47 |
kumaneko |
2298 |
net/ipv4/tcp_ipv4.c | 11 +++++ |
48 |
kumaneko |
2459 |
net/ipv4/udp.c | 19 +++++++++ |
49 |
|
|
net/ipv6/raw.c | 8 ++++ |
50 |
kumaneko |
2298 |
net/ipv6/tcp_ipv6.c | 7 +++ |
51 |
kumaneko |
2459 |
net/ipv6/udp.c | 19 +++++++++ |
52 |
kumaneko |
2298 |
net/socket.c | 40 +++++++++++++++++++- |
53 |
|
|
net/unix/af_unix.c | 8 ++++ |
54 |
kumaneko |
2459 |
49 files changed, 687 insertions(+), 6 deletions(-) |
55 |
kumaneko |
1603 |
|
56 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/Documentation/Configure.help |
57 |
|
|
+++ linux-2.4.37.3/Documentation/Configure.help |
58 |
kumaneko |
1811 |
@@ -29158,6 +29158,92 @@ CONFIG_SOUND_WM97XX |
59 |
kumaneko |
1603 |
|
60 |
|
|
If unsure, say N. |
61 |
|
|
|
62 |
|
|
+CONFIG_SAKURA |
63 |
|
|
+ Say Y here to support the Domain-Free Mandatory Access Control. |
64 |
|
|
+ |
65 |
|
|
+ SAKURA stands for |
66 |
|
|
+ "Security Advancement Know-how Upon Read-only Approach". |
67 |
|
|
+ As the name shows, SAKURA was originally a methodology to make |
68 |
|
|
+ root fs read-only to avoid tampering the system files. |
69 |
|
|
+ But now, SAKURA is not only a methodology but also a kernel patch |
70 |
|
|
+ that improves the system security with less effort. |
71 |
|
|
+ |
72 |
|
|
+ SAKURA can restrict operations that affect systemwide. |
73 |
|
|
+ |
74 |
|
|
+CONFIG_TOMOYO |
75 |
|
|
+ Say Y here to support the Domain-Based Mandatory Access Control. |
76 |
|
|
+ |
77 |
|
|
+ TOMOYO stands for "Task Oriented Management Obviates Your Onus". |
78 |
|
|
+ TOMOYO is intended to provide the Domain-Based MAC |
79 |
|
|
+ utilizing task_struct. |
80 |
|
|
+ |
81 |
|
|
+ The word "domain" in TOMOYO is a class that a process |
82 |
|
|
+ (i.e. task_struct) belong to. |
83 |
|
|
+ The domain of a process changes whenever the process |
84 |
|
|
+ executes a program. |
85 |
|
|
+ This allows you to classify at the finest level. |
86 |
|
|
+ The access permission is granted to domains, not to processes. |
87 |
|
|
+ Policy is defined as "Which domain can access to which resource.". |
88 |
|
|
+ |
89 |
|
|
+ The biggest feature of TOMOYO is that TOMOYO has "learning mode". |
90 |
|
|
+ The learning mode can automatically generate policy definition, |
91 |
|
|
+ and dramatically reduces the policy definition labors. |
92 |
|
|
+ |
93 |
|
|
+ TOMOYO is applicable to figuring out the system's behavior, for |
94 |
|
|
+ TOMOYO uses the canonicalized absolute pathnames and |
95 |
|
|
+ TreeView style domain transitions. |
96 |
|
|
+ |
97 |
|
|
+ You can make custom root fs with minimum files |
98 |
|
|
+ to run minimum applications with TOMOYO. |
99 |
|
|
+ |
100 |
|
|
+CONFIG_TOMOYO_MAX_ACCEPT_ENTRY |
101 |
|
|
+ This is the default value for maximal ACL entries |
102 |
|
|
+ that are automatically appended into policy at "learning mode". |
103 |
|
|
+ Some programs access thousands of objects, so running |
104 |
|
|
+ such programs in "learning mode" dulls the system response |
105 |
|
|
+ and consumes much memory. |
106 |
|
|
+ This is the safeguard for such programs. |
107 |
|
|
+ |
108 |
|
|
+CONFIG_TOMOYO_MAX_GRANT_LOG |
109 |
|
|
+ This is the default value for maximal entries for |
110 |
|
|
+ access grant logs that the kernel can hold on memory. |
111 |
|
|
+ You can read the log via /proc/ccs/grant_log. |
112 |
|
|
+ If you don't need access grant logs, |
113 |
|
|
+ you may set this value to 0. |
114 |
|
|
+ |
115 |
|
|
+CONFIG_TOMOYO_MAX_REJECT_LOG |
116 |
|
|
+ This is the default value for maximal entries for |
117 |
|
|
+ access reject logs that the kernel can hold on memory. |
118 |
|
|
+ You can read the log via /proc/ccs/reject_log. |
119 |
|
|
+ If you don't need access reject logs, |
120 |
|
|
+ you may set this value to 0. |
121 |
|
|
+ |
122 |
|
|
+CONFIG_SYAORAN |
123 |
|
|
+ Say Y or M here to support the Tamper-Proof Device Filesystem. |
124 |
|
|
+ |
125 |
|
|
+ SYAORAN stands for |
126 |
|
|
+ "Simple Yet All-important Object Realizing Abiding Nexus". |
127 |
|
|
+ SYAORAN is a filesystem for /dev with Mandatory Access Control. |
128 |
|
|
+ |
129 |
|
|
+ SAKURA can make root fs read-only, but the system can't work |
130 |
|
|
+ if /dev is read-only. Therefore you need to mount a writable |
131 |
|
|
+ filesystem (such as tmpfs) for /dev if root fs is read-only. |
132 |
|
|
+ |
133 |
|
|
+ But the writable /dev means that files on /dev might be tampered. |
134 |
|
|
+ For example, if /dev/null is deleted and re-created as a symbolic |
135 |
|
|
+ link to /dev/hda by an attacker, the contents of the IDE HDD |
136 |
|
|
+ will be destroyed at a blow. |
137 |
|
|
+ |
138 |
|
|
+ Also, TOMOYO controls file access by pathnames, |
139 |
|
|
+ not by security labels. |
140 |
|
|
+ Therefore /dev/null, for example, might be tampered |
141 |
|
|
+ if a process have write permission to /dev/null . |
142 |
|
|
+ |
143 |
|
|
+ SYAORAN can ensure /dev/null is a character device file |
144 |
|
|
+ with major=1 minor=3. |
145 |
|
|
+ |
146 |
|
|
+ You can use SAKURA to make /dev not unmountable. |
147 |
|
|
+ |
148 |
|
|
# |
149 |
|
|
# A couple of things I keep forgetting: |
150 |
|
|
# capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet, |
151 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/alpha/kernel/ptrace.c |
152 |
|
|
+++ linux-2.4.37.3/arch/alpha/kernel/ptrace.c |
153 |
kumaneko |
1603 |
@@ -18,6 +18,9 @@ |
154 |
|
|
#include <asm/pgtable.h> |
155 |
|
|
#include <asm/system.h> |
156 |
|
|
#include <asm/fpu.h> |
157 |
|
|
+/***** TOMOYO Linux start. *****/ |
158 |
|
|
+#include <linux/tomoyo.h> |
159 |
|
|
+/***** TOMOYO Linux end. *****/ |
160 |
|
|
|
161 |
|
|
#include "proto.h" |
162 |
|
|
|
163 |
kumaneko |
2278 |
@@ -251,6 +254,10 @@ sys_ptrace(long request, long pid, long |
164 |
kumaneko |
1603 |
{ |
165 |
|
|
struct task_struct *child; |
166 |
|
|
long ret; |
167 |
|
|
+ /***** TOMOYO Linux start. *****/ |
168 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
169 |
kumaneko |
1603 |
+ return -EPERM; |
170 |
|
|
+ /***** TOMOYO Linux end. *****/ |
171 |
|
|
|
172 |
|
|
lock_kernel(); |
173 |
|
|
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
174 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/arm/kernel/ptrace.c |
175 |
|
|
+++ linux-2.4.37.3/arch/arm/kernel/ptrace.c |
176 |
kumaneko |
1603 |
@@ -22,6 +22,9 @@ |
177 |
|
|
#include <asm/uaccess.h> |
178 |
|
|
#include <asm/pgtable.h> |
179 |
|
|
#include <asm/system.h> |
180 |
|
|
+/***** TOMOYO Linux start. *****/ |
181 |
|
|
+#include <linux/tomoyo.h> |
182 |
|
|
+/***** TOMOYO Linux end. *****/ |
183 |
|
|
|
184 |
|
|
#include "ptrace.h" |
185 |
|
|
|
186 |
kumaneko |
2278 |
@@ -695,6 +698,10 @@ asmlinkage int sys_ptrace(long request, |
187 |
kumaneko |
1603 |
{ |
188 |
|
|
struct task_struct *child; |
189 |
|
|
int ret; |
190 |
|
|
+ /***** TOMOYO Linux start. *****/ |
191 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
192 |
kumaneko |
1603 |
+ return -EPERM; |
193 |
|
|
+ /***** TOMOYO Linux end. *****/ |
194 |
|
|
|
195 |
|
|
lock_kernel(); |
196 |
|
|
ret = -EPERM; |
197 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/cris/kernel/ptrace.c |
198 |
|
|
+++ linux-2.4.37.3/arch/cris/kernel/ptrace.c |
199 |
kumaneko |
1603 |
@@ -48,6 +48,9 @@ |
200 |
|
|
#include <asm/pgtable.h> |
201 |
|
|
#include <asm/system.h> |
202 |
|
|
#include <asm/processor.h> |
203 |
|
|
+/***** TOMOYO Linux start. *****/ |
204 |
|
|
+#include <linux/tomoyo.h> |
205 |
|
|
+/***** TOMOYO Linux end. *****/ |
206 |
|
|
|
207 |
|
|
/* |
208 |
|
|
* does not yet catch signals sent when the child dies. |
209 |
kumaneko |
2278 |
@@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request, |
210 |
kumaneko |
1603 |
{ |
211 |
|
|
struct task_struct *child; |
212 |
|
|
int ret; |
213 |
|
|
+ /***** TOMOYO Linux start. *****/ |
214 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
215 |
kumaneko |
1603 |
+ return -EPERM; |
216 |
|
|
+ /***** TOMOYO Linux end. *****/ |
217 |
|
|
|
218 |
|
|
lock_kernel(); |
219 |
|
|
ret = -EPERM; |
220 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/i386/kernel/ptrace.c |
221 |
|
|
+++ linux-2.4.37.3/arch/i386/kernel/ptrace.c |
222 |
kumaneko |
1603 |
@@ -20,6 +20,9 @@ |
223 |
|
|
#include <asm/processor.h> |
224 |
|
|
#include <asm/i387.h> |
225 |
|
|
#include <asm/debugreg.h> |
226 |
|
|
+/***** TOMOYO Linux start. *****/ |
227 |
|
|
+#include <linux/tomoyo.h> |
228 |
|
|
+/***** TOMOYO Linux end. *****/ |
229 |
|
|
|
230 |
|
|
/* |
231 |
|
|
* does not yet catch signals sent when the child dies. |
232 |
kumaneko |
2278 |
@@ -152,6 +155,10 @@ asmlinkage int sys_ptrace(long request, |
233 |
kumaneko |
1603 |
struct task_struct *child; |
234 |
|
|
struct user * dummy = NULL; |
235 |
|
|
int i, ret; |
236 |
|
|
+ /***** TOMOYO Linux start. *****/ |
237 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
238 |
kumaneko |
1603 |
+ return -EPERM; |
239 |
|
|
+ /***** TOMOYO Linux end. *****/ |
240 |
|
|
|
241 |
|
|
lock_kernel(); |
242 |
|
|
ret = -EPERM; |
243 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/ia64/ia32/sys_ia32.c |
244 |
|
|
+++ linux-2.4.37.3/arch/ia64/ia32/sys_ia32.c |
245 |
kumaneko |
1603 |
@@ -57,6 +57,9 @@ |
246 |
|
|
#include <net/scm.h> |
247 |
|
|
#include <net/sock.h> |
248 |
|
|
#include <asm/ia32.h> |
249 |
|
|
+/***** TOMOYO Linux start. *****/ |
250 |
|
|
+#include <linux/tomoyo.h> |
251 |
|
|
+/***** TOMOYO Linux end. *****/ |
252 |
|
|
|
253 |
|
|
#define DEBUG 0 |
254 |
|
|
|
255 |
kumaneko |
2278 |
@@ -3131,6 +3134,10 @@ sys32_ptrace (int request, pid_t pid, un |
256 |
kumaneko |
1603 |
struct task_struct *child; |
257 |
|
|
unsigned int value, tmp; |
258 |
|
|
long i, ret; |
259 |
|
|
+ /***** TOMOYO Linux start. *****/ |
260 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
261 |
kumaneko |
1603 |
+ return -EPERM; |
262 |
|
|
+ /***** TOMOYO Linux end. *****/ |
263 |
|
|
|
264 |
|
|
lock_kernel(); |
265 |
|
|
if (request == PTRACE_TRACEME) { |
266 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/ia64/kernel/ptrace.c |
267 |
|
|
+++ linux-2.4.37.3/arch/ia64/kernel/ptrace.c |
268 |
kumaneko |
1603 |
@@ -27,6 +27,9 @@ |
269 |
|
|
#ifdef CONFIG_PERFMON |
270 |
|
|
#include <asm/perfmon.h> |
271 |
|
|
#endif |
272 |
|
|
+/***** TOMOYO Linux start. *****/ |
273 |
|
|
+#include <linux/tomoyo.h> |
274 |
|
|
+/***** TOMOYO Linux end. *****/ |
275 |
|
|
|
276 |
|
|
#define offsetof(type,field) ((unsigned long) &((type *) 0)->field) |
277 |
|
|
|
278 |
kumaneko |
2278 |
@@ -1273,6 +1276,10 @@ sys_ptrace (long request, pid_t pid, uns |
279 |
kumaneko |
1603 |
struct task_struct *child; |
280 |
|
|
struct switch_stack *sw; |
281 |
|
|
long ret; |
282 |
|
|
+ /***** TOMOYO Linux start. *****/ |
283 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
284 |
kumaneko |
1603 |
+ return -EPERM; |
285 |
|
|
+ /***** TOMOYO Linux end. *****/ |
286 |
|
|
|
287 |
|
|
lock_kernel(); |
288 |
|
|
ret = -EPERM; |
289 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/m68k/kernel/ptrace.c |
290 |
|
|
+++ linux-2.4.37.3/arch/m68k/kernel/ptrace.c |
291 |
kumaneko |
1603 |
@@ -25,6 +25,9 @@ |
292 |
|
|
#include <asm/pgtable.h> |
293 |
|
|
#include <asm/system.h> |
294 |
|
|
#include <asm/processor.h> |
295 |
|
|
+/***** TOMOYO Linux start. *****/ |
296 |
|
|
+#include <linux/tomoyo.h> |
297 |
|
|
+/***** TOMOYO Linux end. *****/ |
298 |
|
|
|
299 |
|
|
/* |
300 |
|
|
* does not yet catch signals sent when the child dies. |
301 |
kumaneko |
2278 |
@@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request, |
302 |
kumaneko |
1603 |
{ |
303 |
|
|
struct task_struct *child; |
304 |
|
|
int ret; |
305 |
|
|
+ /***** TOMOYO Linux start. *****/ |
306 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
307 |
kumaneko |
1603 |
+ return -EPERM; |
308 |
|
|
+ /***** TOMOYO Linux end. *****/ |
309 |
|
|
|
310 |
|
|
lock_kernel(); |
311 |
|
|
ret = -EPERM; |
312 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/mips/kernel/ptrace.c |
313 |
|
|
+++ linux-2.4.37.3/arch/mips/kernel/ptrace.c |
314 |
kumaneko |
1603 |
@@ -28,6 +28,9 @@ |
315 |
|
|
#include <asm/bootinfo.h> |
316 |
|
|
#include <asm/cpu.h> |
317 |
|
|
#include <asm/fpu.h> |
318 |
|
|
+/***** TOMOYO Linux start. *****/ |
319 |
|
|
+#include <linux/tomoyo.h> |
320 |
|
|
+/***** TOMOYO Linux end. *****/ |
321 |
|
|
|
322 |
|
|
/* |
323 |
|
|
* Called by kernel/ptrace.c when detaching.. |
324 |
kumaneko |
2278 |
@@ -43,6 +46,10 @@ asmlinkage int sys_ptrace(long request, |
325 |
kumaneko |
1603 |
{ |
326 |
|
|
struct task_struct *child; |
327 |
|
|
int ret; |
328 |
|
|
+ /***** TOMOYO Linux start. *****/ |
329 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
330 |
kumaneko |
1603 |
+ return -EPERM; |
331 |
|
|
+ /***** TOMOYO Linux end. *****/ |
332 |
|
|
|
333 |
|
|
lock_kernel(); |
334 |
|
|
#if 0 |
335 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/mips64/kernel/ptrace.c |
336 |
|
|
+++ linux-2.4.37.3/arch/mips64/kernel/ptrace.c |
337 |
kumaneko |
1603 |
@@ -30,6 +30,9 @@ |
338 |
|
|
#include <asm/system.h> |
339 |
|
|
#include <asm/uaccess.h> |
340 |
|
|
#include <asm/bootinfo.h> |
341 |
|
|
+/***** TOMOYO Linux start. *****/ |
342 |
|
|
+#include <linux/tomoyo.h> |
343 |
|
|
+/***** TOMOYO Linux end. *****/ |
344 |
|
|
|
345 |
|
|
/* |
346 |
|
|
* Called by kernel/ptrace.c when detaching.. |
347 |
kumaneko |
2278 |
@@ -49,6 +52,10 @@ asmlinkage int sys32_ptrace(int request, |
348 |
kumaneko |
1603 |
{ |
349 |
|
|
struct task_struct *child; |
350 |
|
|
int ret; |
351 |
|
|
+ /***** TOMOYO Linux start. *****/ |
352 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
353 |
kumaneko |
1603 |
+ return -EPERM; |
354 |
|
|
+ /***** TOMOYO Linux end. *****/ |
355 |
|
|
|
356 |
|
|
lock_kernel(); |
357 |
|
|
ret = -EPERM; |
358 |
kumaneko |
2278 |
@@ -288,6 +295,10 @@ asmlinkage int sys_ptrace(long request, |
359 |
kumaneko |
1603 |
{ |
360 |
|
|
struct task_struct *child; |
361 |
|
|
int ret; |
362 |
|
|
+ /***** TOMOYO Linux start. *****/ |
363 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
364 |
kumaneko |
1603 |
+ return -EPERM; |
365 |
|
|
+ /***** TOMOYO Linux end. *****/ |
366 |
|
|
|
367 |
|
|
lock_kernel(); |
368 |
|
|
#if 0 |
369 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/parisc/kernel/ptrace.c |
370 |
|
|
+++ linux-2.4.37.3/arch/parisc/kernel/ptrace.c |
371 |
kumaneko |
1603 |
@@ -21,6 +21,9 @@ |
372 |
|
|
#include <asm/system.h> |
373 |
|
|
#include <asm/processor.h> |
374 |
|
|
#include <asm/offset.h> |
375 |
|
|
+/***** TOMOYO Linux start. *****/ |
376 |
|
|
+#include <linux/tomoyo.h> |
377 |
|
|
+/***** TOMOYO Linux end. *****/ |
378 |
|
|
|
379 |
|
|
/* These are used in entry.S, syscall_restore_rfi. We need to record the |
380 |
|
|
* current stepping mode somewhere other than in PSW, because there is no |
381 |
kumaneko |
2278 |
@@ -94,6 +97,10 @@ long sys_ptrace(long request, pid_t pid, |
382 |
kumaneko |
1603 |
#ifdef DEBUG_PTRACE |
383 |
|
|
long oaddr=addr, odata=data; |
384 |
|
|
#endif |
385 |
|
|
+ /***** TOMOYO Linux start. *****/ |
386 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
387 |
kumaneko |
1603 |
+ return -EPERM; |
388 |
|
|
+ /***** TOMOYO Linux end. *****/ |
389 |
|
|
|
390 |
|
|
lock_kernel(); |
391 |
|
|
ret = -EPERM; |
392 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/ppc/kernel/ptrace.c |
393 |
|
|
+++ linux-2.4.37.3/arch/ppc/kernel/ptrace.c |
394 |
kumaneko |
1603 |
@@ -29,6 +29,9 @@ |
395 |
|
|
#include <asm/page.h> |
396 |
|
|
#include <asm/pgtable.h> |
397 |
|
|
#include <asm/system.h> |
398 |
|
|
+/***** TOMOYO Linux start. *****/ |
399 |
|
|
+#include <linux/tomoyo.h> |
400 |
|
|
+/***** TOMOYO Linux end. *****/ |
401 |
|
|
|
402 |
|
|
/* |
403 |
|
|
* Set of msr bits that gdb can change on behalf of a process. |
404 |
kumaneko |
2278 |
@@ -171,6 +174,10 @@ int sys_ptrace(long request, long pid, l |
405 |
kumaneko |
1603 |
{ |
406 |
|
|
struct task_struct *child; |
407 |
|
|
int ret = -EPERM; |
408 |
|
|
+ /***** TOMOYO Linux start. *****/ |
409 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
410 |
kumaneko |
1603 |
+ return -EPERM; |
411 |
|
|
+ /***** TOMOYO Linux end. *****/ |
412 |
|
|
|
413 |
|
|
lock_kernel(); |
414 |
|
|
if (request == PTRACE_TRACEME) { |
415 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/ppc64/kernel/ptrace.c |
416 |
|
|
+++ linux-2.4.37.3/arch/ppc64/kernel/ptrace.c |
417 |
kumaneko |
1603 |
@@ -30,6 +30,9 @@ |
418 |
|
|
#include <asm/page.h> |
419 |
|
|
#include <asm/pgtable.h> |
420 |
|
|
#include <asm/system.h> |
421 |
|
|
+/***** TOMOYO Linux start. *****/ |
422 |
|
|
+#include <linux/tomoyo.h> |
423 |
|
|
+/***** TOMOYO Linux end. *****/ |
424 |
|
|
|
425 |
|
|
/* |
426 |
|
|
* Set of msr bits that gdb can change on behalf of a process. |
427 |
kumaneko |
2278 |
@@ -120,6 +123,10 @@ int sys_ptrace(long request, long pid, l |
428 |
kumaneko |
1603 |
{ |
429 |
|
|
struct task_struct *child; |
430 |
|
|
int ret = -EPERM; |
431 |
|
|
+ /***** TOMOYO Linux start. *****/ |
432 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
433 |
kumaneko |
1603 |
+ return -EPERM; |
434 |
|
|
+ /***** TOMOYO Linux end. *****/ |
435 |
|
|
|
436 |
|
|
lock_kernel(); |
437 |
|
|
if (request == PTRACE_TRACEME) { |
438 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/ppc64/kernel/ptrace32.c |
439 |
|
|
+++ linux-2.4.37.3/arch/ppc64/kernel/ptrace32.c |
440 |
kumaneko |
1603 |
@@ -30,6 +30,9 @@ |
441 |
|
|
#include <asm/page.h> |
442 |
|
|
#include <asm/pgtable.h> |
443 |
|
|
#include <asm/system.h> |
444 |
|
|
+/***** TOMOYO Linux start. *****/ |
445 |
|
|
+#include <linux/tomoyo.h> |
446 |
|
|
+/***** TOMOYO Linux end. *****/ |
447 |
|
|
|
448 |
|
|
#ifdef CONFIG_ALTIVEC |
449 |
|
|
/* |
450 |
kumaneko |
2278 |
@@ -121,6 +124,10 @@ int sys32_ptrace(long request, long pid, |
451 |
kumaneko |
1603 |
{ |
452 |
|
|
struct task_struct *child; |
453 |
|
|
int ret = -EPERM; |
454 |
|
|
+ /***** TOMOYO Linux start. *****/ |
455 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
456 |
kumaneko |
1603 |
+ return -EPERM; |
457 |
|
|
+ /***** TOMOYO Linux end. *****/ |
458 |
|
|
|
459 |
|
|
lock_kernel(); |
460 |
|
|
if (request == PTRACE_TRACEME) { |
461 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/s390/kernel/ptrace.c |
462 |
|
|
+++ linux-2.4.37.3/arch/s390/kernel/ptrace.c |
463 |
kumaneko |
1603 |
@@ -37,6 +37,9 @@ |
464 |
|
|
#include <asm/pgalloc.h> |
465 |
|
|
#include <asm/system.h> |
466 |
|
|
#include <asm/uaccess.h> |
467 |
|
|
+/***** TOMOYO Linux start. *****/ |
468 |
|
|
+#include <linux/tomoyo.h> |
469 |
|
|
+/***** TOMOYO Linux end. *****/ |
470 |
|
|
|
471 |
|
|
|
472 |
|
|
void FixPerRegisters(struct task_struct *task) |
473 |
kumaneko |
2278 |
@@ -221,6 +224,10 @@ asmlinkage int sys_ptrace(long request, |
474 |
kumaneko |
1603 |
unsigned long tmp; |
475 |
|
|
int copied; |
476 |
|
|
ptrace_area parea; |
477 |
|
|
+ /***** TOMOYO Linux start. *****/ |
478 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
479 |
kumaneko |
1603 |
+ return -EPERM; |
480 |
|
|
+ /***** TOMOYO Linux end. *****/ |
481 |
|
|
|
482 |
|
|
lock_kernel(); |
483 |
|
|
if (request == PTRACE_TRACEME) |
484 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/s390x/kernel/ptrace.c |
485 |
|
|
+++ linux-2.4.37.3/arch/s390x/kernel/ptrace.c |
486 |
kumaneko |
1603 |
@@ -43,6 +43,9 @@ |
487 |
|
|
#else |
488 |
|
|
#define parent_31bit 0 |
489 |
|
|
#endif |
490 |
|
|
+/***** TOMOYO Linux start. *****/ |
491 |
|
|
+#include <linux/tomoyo.h> |
492 |
|
|
+/***** TOMOYO Linux end. *****/ |
493 |
|
|
|
494 |
|
|
|
495 |
|
|
void FixPerRegisters(struct task_struct *task) |
496 |
kumaneko |
2278 |
@@ -431,6 +434,10 @@ asmlinkage int sys_ptrace(long request, |
497 |
kumaneko |
1603 |
#define sizeof_parent_long 8 |
498 |
|
|
#define dataptr (u8 *)&data |
499 |
|
|
#endif |
500 |
|
|
+ /***** TOMOYO Linux start. *****/ |
501 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
502 |
kumaneko |
1603 |
+ return -EPERM; |
503 |
|
|
+ /***** TOMOYO Linux end. *****/ |
504 |
|
|
lock_kernel(); |
505 |
|
|
if (request == PTRACE_TRACEME) |
506 |
|
|
{ |
507 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/sh/kernel/ptrace.c |
508 |
|
|
+++ linux-2.4.37.3/arch/sh/kernel/ptrace.c |
509 |
kumaneko |
1603 |
@@ -26,6 +26,9 @@ |
510 |
|
|
#include <asm/system.h> |
511 |
|
|
#include <asm/processor.h> |
512 |
|
|
#include <asm/mmu_context.h> |
513 |
|
|
+/***** TOMOYO Linux start. *****/ |
514 |
|
|
+#include <linux/tomoyo.h> |
515 |
|
|
+/***** TOMOYO Linux end. *****/ |
516 |
|
|
|
517 |
|
|
/* |
518 |
|
|
* does not yet catch signals sent when the child dies. |
519 |
kumaneko |
2278 |
@@ -144,6 +147,10 @@ asmlinkage int sys_ptrace(long request, |
520 |
kumaneko |
1603 |
struct task_struct *child, *tsk = current; |
521 |
|
|
struct user * dummy = NULL; |
522 |
|
|
int ret; |
523 |
|
|
+ /***** TOMOYO Linux start. *****/ |
524 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
525 |
kumaneko |
1603 |
+ return -EPERM; |
526 |
|
|
+ /***** TOMOYO Linux end. *****/ |
527 |
|
|
|
528 |
|
|
lock_kernel(); |
529 |
|
|
ret = -EPERM; |
530 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/sh64/kernel/ptrace.c |
531 |
|
|
+++ linux-2.4.37.3/arch/sh64/kernel/ptrace.c |
532 |
kumaneko |
1603 |
@@ -32,6 +32,9 @@ |
533 |
|
|
#include <asm/system.h> |
534 |
|
|
#include <asm/processor.h> |
535 |
|
|
#include <asm/mmu_context.h> |
536 |
|
|
+/***** TOMOYO Linux start. *****/ |
537 |
|
|
+#include <linux/tomoyo.h> |
538 |
|
|
+/***** TOMOYO Linux end. *****/ |
539 |
|
|
|
540 |
|
|
/* This mask defines the bits of the SR which the user is not allowed to |
541 |
|
|
change, which are everything except S, Q, M, PR, SZ, FR. */ |
542 |
kumaneko |
2278 |
@@ -122,6 +125,10 @@ asmlinkage int sys_ptrace(long request, |
543 |
kumaneko |
1603 |
{ |
544 |
|
|
struct task_struct *child, *tsk = current; |
545 |
|
|
int ret; |
546 |
|
|
+ /***** TOMOYO Linux start. *****/ |
547 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
548 |
kumaneko |
1603 |
+ return -EPERM; |
549 |
|
|
+ /***** TOMOYO Linux end. *****/ |
550 |
|
|
|
551 |
|
|
lock_kernel(); |
552 |
|
|
ret = -EPERM; |
553 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/sparc/kernel/ptrace.c |
554 |
|
|
+++ linux-2.4.37.3/arch/sparc/kernel/ptrace.c |
555 |
kumaneko |
1603 |
@@ -21,6 +21,9 @@ |
556 |
|
|
#include <asm/pgtable.h> |
557 |
|
|
#include <asm/system.h> |
558 |
|
|
#include <asm/uaccess.h> |
559 |
|
|
+/***** TOMOYO Linux start. *****/ |
560 |
|
|
+#include <linux/tomoyo.h> |
561 |
|
|
+/***** TOMOYO Linux end. *****/ |
562 |
|
|
|
563 |
|
|
#define MAGIC_CONSTANT 0x80000000 |
564 |
|
|
|
565 |
kumaneko |
2278 |
@@ -262,6 +265,12 @@ asmlinkage void do_ptrace(struct pt_regs |
566 |
kumaneko |
1603 |
unsigned long data = regs->u_regs[UREG_I3]; |
567 |
|
|
unsigned long addr2 = regs->u_regs[UREG_I4]; |
568 |
|
|
struct task_struct *child; |
569 |
|
|
+ /***** TOMOYO Linux start. *****/ |
570 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
571 |
kumaneko |
1603 |
+ pt_error_return(regs, EPERM); |
572 |
|
|
+ return; |
573 |
|
|
+ } |
574 |
|
|
+ /***** TOMOYO Linux end. *****/ |
575 |
|
|
|
576 |
|
|
lock_kernel(); |
577 |
|
|
#ifdef DEBUG_PTRACE |
578 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/sparc64/kernel/ptrace.c |
579 |
|
|
+++ linux-2.4.37.3/arch/sparc64/kernel/ptrace.c |
580 |
kumaneko |
1603 |
@@ -26,6 +26,9 @@ |
581 |
|
|
#include <asm/psrcompat.h> |
582 |
|
|
#include <asm/visasm.h> |
583 |
|
|
#include <asm/spitfire.h> |
584 |
|
|
+/***** TOMOYO Linux start. *****/ |
585 |
|
|
+#include <linux/tomoyo.h> |
586 |
|
|
+/***** TOMOYO Linux end. *****/ |
587 |
|
|
|
588 |
|
|
#define MAGIC_CONSTANT 0x80000000 |
589 |
|
|
|
590 |
kumaneko |
2278 |
@@ -108,6 +111,12 @@ asmlinkage void do_ptrace(struct pt_regs |
591 |
kumaneko |
1603 |
unsigned long data = regs->u_regs[UREG_I3]; |
592 |
|
|
unsigned long addr2 = regs->u_regs[UREG_I4]; |
593 |
|
|
struct task_struct *child; |
594 |
|
|
+ /***** TOMOYO Linux start. *****/ |
595 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
596 |
kumaneko |
1603 |
+ pt_error_return(regs, EPERM); |
597 |
|
|
+ return; |
598 |
|
|
+ } |
599 |
|
|
+ /***** TOMOYO Linux end. *****/ |
600 |
|
|
|
601 |
|
|
if (current->thread.flags & SPARC_FLAG_32BIT) { |
602 |
|
|
addr &= 0xffffffffUL; |
603 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/x86_64/ia32/ptrace32.c |
604 |
|
|
+++ linux-2.4.37.3/arch/x86_64/ia32/ptrace32.c |
605 |
kumaneko |
1603 |
@@ -24,6 +24,9 @@ |
606 |
|
|
#include <asm/i387.h> |
607 |
|
|
#include <asm/fpu32.h> |
608 |
|
|
#include <linux/mm.h> |
609 |
|
|
+/***** TOMOYO Linux start. *****/ |
610 |
|
|
+#include <linux/tomoyo.h> |
611 |
|
|
+/***** TOMOYO Linux end. *****/ |
612 |
|
|
|
613 |
|
|
/* determines which flags the user has access to. */ |
614 |
|
|
/* 1 = access 0 = no access */ |
615 |
kumaneko |
2278 |
@@ -203,6 +206,10 @@ asmlinkage long sys32_ptrace(long reques |
616 |
kumaneko |
1603 |
struct pt_regs *childregs; |
617 |
|
|
int ret; |
618 |
|
|
__u32 val; |
619 |
|
|
+ /***** TOMOYO Linux start. *****/ |
620 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
621 |
kumaneko |
1603 |
+ return -EPERM; |
622 |
|
|
+ /***** TOMOYO Linux end. *****/ |
623 |
|
|
|
624 |
|
|
switch (request) { |
625 |
|
|
case PTRACE_TRACEME: |
626 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/arch/x86_64/kernel/ptrace.c |
627 |
|
|
+++ linux-2.4.37.3/arch/x86_64/kernel/ptrace.c |
628 |
kumaneko |
1603 |
@@ -22,6 +22,9 @@ |
629 |
|
|
#include <asm/processor.h> |
630 |
|
|
#include <asm/i387.h> |
631 |
|
|
#include <asm/debugreg.h> |
632 |
|
|
+/***** TOMOYO Linux start. *****/ |
633 |
|
|
+#include <linux/tomoyo.h> |
634 |
|
|
+/***** TOMOYO Linux end. *****/ |
635 |
|
|
|
636 |
|
|
/* |
637 |
|
|
* does not yet catch signals sent when the child dies. |
638 |
kumaneko |
2278 |
@@ -180,6 +183,10 @@ asmlinkage long sys_ptrace(long request, |
639 |
kumaneko |
1603 |
struct task_struct *child; |
640 |
|
|
struct user * dummy = NULL; |
641 |
|
|
long i, ret; |
642 |
|
|
+ /***** TOMOYO Linux start. *****/ |
643 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
644 |
kumaneko |
1603 |
+ return -EPERM; |
645 |
|
|
+ /***** TOMOYO Linux end. *****/ |
646 |
|
|
|
647 |
|
|
/* This lock_kernel fixes a subtle race with suid exec */ |
648 |
|
|
lock_kernel(); |
649 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/Config.in |
650 |
|
|
+++ linux-2.4.37.3/fs/Config.in |
651 |
kumaneko |
1603 |
@@ -176,4 +176,7 @@ comment 'Partition Types' |
652 |
|
|
source fs/partitions/Config.in |
653 |
|
|
endmenu |
654 |
|
|
source fs/nls/Config.in |
655 |
|
|
+ |
656 |
|
|
+source fs/Config.ccs.in |
657 |
|
|
+ |
658 |
|
|
endmenu |
659 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/Makefile |
660 |
|
|
+++ linux-2.4.37.3/fs/Makefile |
661 |
kumaneko |
1603 |
@@ -80,5 +80,5 @@ obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o |
662 |
|
|
# persistent filesystems |
663 |
|
|
obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o)) |
664 |
|
|
|
665 |
|
|
- |
666 |
|
|
+include Makefile-2.4.ccs |
667 |
|
|
include $(TOPDIR)/Rules.make |
668 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/attr.c |
669 |
|
|
+++ linux-2.4.37.3/fs/attr.c |
670 |
kumaneko |
1603 |
@@ -12,6 +12,9 @@ |
671 |
|
|
#include <linux/dnotify.h> |
672 |
|
|
#include <linux/fcntl.h> |
673 |
|
|
#include <linux/quotaops.h> |
674 |
|
|
+/***** TOMOYO Linux start. *****/ |
675 |
|
|
+#include <linux/tomoyo.h> |
676 |
|
|
+/***** TOMOYO Linux end. *****/ |
677 |
|
|
|
678 |
|
|
/* Taken over from the old code... */ |
679 |
|
|
|
680 |
|
|
@@ -127,6 +130,13 @@ int notify_change(struct dentry * dentry |
681 |
|
|
attr->ia_atime = now; |
682 |
|
|
if (!(ia_valid & ATTR_MTIME_SET)) |
683 |
|
|
attr->ia_mtime = now; |
684 |
|
|
+ /***** TOMOYO Linux start. *****/ |
685 |
kumaneko |
2282 |
+ if ((ia_valid & ATTR_MODE) && !ccs_capable(CCS_SYS_CHMOD)) |
686 |
kumaneko |
1603 |
+ return -EPERM; |
687 |
|
|
+ if ((ia_valid & (ATTR_UID | ATTR_GID)) && |
688 |
kumaneko |
2282 |
+ !ccs_capable(CCS_SYS_CHOWN)) |
689 |
kumaneko |
1603 |
+ return -EPERM; |
690 |
|
|
+ /***** TOMOYO Linux end. *****/ |
691 |
|
|
|
692 |
|
|
lock_kernel(); |
693 |
|
|
if (inode->i_op && inode->i_op->setattr) |
694 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/exec.c |
695 |
|
|
+++ linux-2.4.37.3/fs/exec.c |
696 |
kumaneko |
1603 |
@@ -48,6 +48,10 @@ |
697 |
|
|
#include <linux/kmod.h> |
698 |
|
|
#endif |
699 |
|
|
|
700 |
|
|
+/***** TOMOYO Linux start. *****/ |
701 |
|
|
+#include <linux/tomoyo.h> |
702 |
|
|
+/***** TOMOYO Linux end. *****/ |
703 |
|
|
+ |
704 |
|
|
int core_uses_pid; |
705 |
|
|
char core_pattern[65] = "core"; |
706 |
|
|
int core_setuid_ok = 0; |
707 |
kumaneko |
2306 |
@@ -125,6 +129,12 @@ asmlinkage long sys_uselib(const char * |
708 |
kumaneko |
1603 |
if (error) |
709 |
|
|
goto exit; |
710 |
|
|
|
711 |
|
|
+ /***** TOMOYO Linux start. *****/ |
712 |
kumaneko |
2306 |
+ error = ccs_check_uselib_permission(nd.dentry, nd.mnt); |
713 |
kumaneko |
1603 |
+ if (error) |
714 |
|
|
+ goto exit; |
715 |
|
|
+ /***** TOMOYO Linux end. *****/ |
716 |
|
|
+ |
717 |
|
|
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); |
718 |
|
|
error = PTR_ERR(file); |
719 |
|
|
if (IS_ERR(file)) |
720 |
kumaneko |
2306 |
@@ -389,6 +399,11 @@ struct file *open_exec(const char *name) |
721 |
kumaneko |
1603 |
int err = permission(inode, MAY_EXEC); |
722 |
|
|
if (!err && !(inode->i_mode & 0111)) |
723 |
|
|
err = -EACCES; |
724 |
|
|
+ /***** TOMOYO Linux start. *****/ |
725 |
kumaneko |
2306 |
+ if (!err) |
726 |
|
|
+ err = ccs_check_open_exec_permission(nd.dentry, |
727 |
|
|
+ nd.mnt); |
728 |
kumaneko |
1603 |
+ /***** TOMOYO Linux end. *****/ |
729 |
|
|
file = ERR_PTR(err); |
730 |
|
|
if (!err) { |
731 |
|
|
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); |
732 |
kumaneko |
2306 |
@@ -986,7 +1001,8 @@ int do_execve(char * filename, char ** a |
733 |
kumaneko |
1603 |
if (retval < 0) |
734 |
|
|
goto out; |
735 |
|
|
|
736 |
|
|
- retval = search_binary_handler(&bprm,regs); |
737 |
kumaneko |
2300 |
+ retval = ccs_search_binary_handler(&bprm, regs); |
738 |
kumaneko |
1603 |
+ |
739 |
|
|
if (retval >= 0) |
740 |
|
|
/* execve success */ |
741 |
|
|
return retval; |
742 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/fcntl.c |
743 |
|
|
+++ linux-2.4.37.3/fs/fcntl.c |
744 |
kumaneko |
1603 |
@@ -16,6 +16,9 @@ |
745 |
|
|
#include <asm/poll.h> |
746 |
|
|
#include <asm/siginfo.h> |
747 |
|
|
#include <asm/uaccess.h> |
748 |
|
|
+/***** TOMOYO Linux start. *****/ |
749 |
|
|
+#include <linux/tomoyo.h> |
750 |
|
|
+/***** TOMOYO Linux end. *****/ |
751 |
|
|
|
752 |
|
|
extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg); |
753 |
|
|
extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); |
754 |
|
|
@@ -214,6 +217,11 @@ static int setfl(int fd, struct file * f |
755 |
|
|
if (!(arg & O_APPEND) && IS_APPEND(inode)) |
756 |
|
|
return -EPERM; |
757 |
|
|
|
758 |
|
|
+ /***** TOMOYO Linux start. *****/ |
759 |
|
|
+ if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp)) |
760 |
|
|
+ return -EPERM; |
761 |
|
|
+ /***** TOMOYO Linux end. *****/ |
762 |
|
|
+ |
763 |
|
|
/* Did FASYNC state change? */ |
764 |
|
|
if ((arg ^ filp->f_flags) & FASYNC) { |
765 |
|
|
if (filp->f_op && filp->f_op->fasync) { |
766 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/ioctl.c |
767 |
|
|
+++ linux-2.4.37.3/fs/ioctl.c |
768 |
kumaneko |
1603 |
@@ -10,6 +10,9 @@ |
769 |
|
|
|
770 |
|
|
#include <asm/uaccess.h> |
771 |
|
|
#include <asm/ioctls.h> |
772 |
|
|
+/***** TOMOYO Linux start. *****/ |
773 |
|
|
+#include <linux/tomoyo.h> |
774 |
|
|
+/***** TOMOYO Linux end. *****/ |
775 |
|
|
|
776 |
|
|
static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg) |
777 |
|
|
{ |
778 |
kumaneko |
2283 |
@@ -55,6 +58,13 @@ asmlinkage long sys_ioctl(unsigned int f |
779 |
kumaneko |
2279 |
filp = fget(fd); |
780 |
|
|
if (!filp) |
781 |
|
|
goto out; |
782 |
|
|
+ /***** TOMOYO Linux start. *****/ |
783 |
|
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
784 |
kumaneko |
2283 |
+ if (error) { |
785 |
|
|
+ fput(filp); |
786 |
kumaneko |
2279 |
+ goto out; |
787 |
kumaneko |
2283 |
+ } |
788 |
kumaneko |
2279 |
+ /***** TOMOYO Linux end. *****/ |
789 |
|
|
error = 0; |
790 |
|
|
lock_kernel(); |
791 |
|
|
switch (cmd) { |
792 |
kumaneko |
2283 |
@@ -112,6 +122,12 @@ asmlinkage long sys_ioctl(unsigned int f |
793 |
kumaneko |
1603 |
error = -ENOTTY; |
794 |
|
|
break; |
795 |
|
|
default: |
796 |
|
|
+ /***** TOMOYO Linux start. *****/ |
797 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
798 |
kumaneko |
1603 |
+ error = -EPERM; |
799 |
|
|
+ break; |
800 |
|
|
+ } |
801 |
|
|
+ /***** TOMOYO Linux end. *****/ |
802 |
|
|
error = -ENOTTY; |
803 |
|
|
if (S_ISREG(filp->f_dentry->d_inode->i_mode)) |
804 |
|
|
error = file_ioctl(filp, cmd, arg); |
805 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/namei.c |
806 |
|
|
+++ linux-2.4.37.3/fs/namei.c |
807 |
kumaneko |
1603 |
@@ -28,6 +28,11 @@ |
808 |
|
|
|
809 |
|
|
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
810 |
|
|
|
811 |
|
|
+/***** TOMOYO Linux start. *****/ |
812 |
|
|
+#include <linux/tomoyo.h> |
813 |
|
|
+#include <linux/module.h> |
814 |
|
|
+/***** TOMOYO Linux end. *****/ |
815 |
|
|
+ |
816 |
|
|
/* [Feb-1997 T. Schoebel-Theuer] |
817 |
|
|
* Fundamental changes in the pathname lookup mechanisms (namei) |
818 |
|
|
* were necessary because of omirr. The reason is that omirr needs |
819 |
kumaneko |
1811 |
@@ -1003,6 +1008,9 @@ exit_lock: |
820 |
kumaneko |
1603 |
return error; |
821 |
|
|
} |
822 |
|
|
|
823 |
|
|
+/***** TOMOYO Linux start. *****/ |
824 |
|
|
+#include <linux/tomoyo_vfs.h> |
825 |
|
|
+/***** TOMOYO Linux end. *****/ |
826 |
|
|
/* |
827 |
|
|
* open_namei() |
828 |
|
|
* |
829 |
kumaneko |
1811 |
@@ -1068,6 +1076,13 @@ do_last: |
830 |
kumaneko |
1603 |
|
831 |
|
|
/* Negative dentry, just create the file */ |
832 |
|
|
if (!dentry->d_inode) { |
833 |
|
|
+ /***** TOMOYO Linux start. *****/ |
834 |
kumaneko |
2290 |
+ error = ccs_check_mknod_permission(dir->d_inode, dentry, |
835 |
|
|
+ nd->mnt, |
836 |
|
|
+ mode & ~current->fs->umask, |
837 |
|
|
+ 0); |
838 |
kumaneko |
1603 |
+ if (!error) |
839 |
|
|
+ /***** TOMOYO Linux end. *****/ |
840 |
|
|
error = vfs_create(dir->d_inode, dentry, |
841 |
|
|
mode & ~current->fs->umask); |
842 |
|
|
up(&dir->d_inode->i_sem); |
843 |
kumaneko |
1811 |
@@ -1154,6 +1169,13 @@ ok: |
844 |
kumaneko |
1603 |
goto exit; |
845 |
|
|
} |
846 |
|
|
|
847 |
|
|
+ /***** TOMOYO Linux start. *****/ |
848 |
|
|
+ /* includes O_APPEND and O_TRUNC checks */ |
849 |
|
|
+ error = ccs_check_open_permission(dentry, nd->mnt, flag); |
850 |
|
|
+ if (error) |
851 |
|
|
+ goto exit; |
852 |
|
|
+ /***** TOMOYO Linux end. *****/ |
853 |
|
|
+ |
854 |
|
|
/* |
855 |
|
|
* Ensure there are no outstanding leases on the file. |
856 |
|
|
*/ |
857 |
kumaneko |
2290 |
@@ -1292,6 +1314,7 @@ asmlinkage long sys_mknod(const char * f |
858 |
kumaneko |
1603 |
|
859 |
|
|
if (S_ISDIR(mode)) |
860 |
|
|
return -EPERM; |
861 |
|
|
+ |
862 |
|
|
tmp = getname(filename); |
863 |
|
|
if (IS_ERR(tmp)) |
864 |
|
|
return PTR_ERR(tmp); |
865 |
kumaneko |
2297 |
@@ -1304,6 +1327,12 @@ asmlinkage long sys_mknod(const char * f |
866 |
kumaneko |
2290 |
|
867 |
|
|
mode &= ~current->fs->umask; |
868 |
kumaneko |
1603 |
if (!IS_ERR(dentry)) { |
869 |
kumaneko |
2290 |
+ /***** TOMOYO Linux start. *****/ |
870 |
|
|
+ error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
871 |
|
|
+ nd.mnt, mode, dev); |
872 |
kumaneko |
2297 |
+ if (error) |
873 |
|
|
+ goto out_dput; |
874 |
kumaneko |
2290 |
+ /***** TOMOYO Linux end. *****/ |
875 |
kumaneko |
1603 |
switch (mode & S_IFMT) { |
876 |
|
|
case 0: case S_IFREG: |
877 |
|
|
error = vfs_create(nd.dentry->d_inode,dentry,mode); |
878 |
kumaneko |
2297 |
@@ -1317,6 +1346,9 @@ asmlinkage long sys_mknod(const char * f |
879 |
|
|
default: |
880 |
|
|
error = -EINVAL; |
881 |
|
|
} |
882 |
|
|
+ /***** TOMOYO Linux start. *****/ |
883 |
|
|
+out_dput: |
884 |
|
|
+ /***** TOMOYO Linux end. *****/ |
885 |
|
|
dput(dentry); |
886 |
|
|
} |
887 |
|
|
up(&nd.dentry->d_inode->i_sem); |
888 |
|
|
@@ -1370,6 +1402,12 @@ asmlinkage long sys_mkdir(const char * p |
889 |
kumaneko |
1603 |
dentry = lookup_create(&nd, 1); |
890 |
|
|
error = PTR_ERR(dentry); |
891 |
|
|
if (!IS_ERR(dentry)) { |
892 |
|
|
+ /***** TOMOYO Linux start. *****/ |
893 |
kumaneko |
2290 |
+ error = ccs_check_mkdir_permission(nd.dentry->d_inode, |
894 |
|
|
+ dentry, nd.mnt, |
895 |
|
|
+ mode); |
896 |
kumaneko |
1603 |
+ if (!error) |
897 |
|
|
+ /***** TOMOYO Linux end. *****/ |
898 |
|
|
error = vfs_mkdir(nd.dentry->d_inode, dentry, |
899 |
|
|
mode & ~current->fs->umask); |
900 |
|
|
dput(dentry); |
901 |
kumaneko |
2297 |
@@ -1479,6 +1517,11 @@ asmlinkage long sys_rmdir(const char * p |
902 |
kumaneko |
1603 |
dentry = lookup_hash(&nd.last, nd.dentry); |
903 |
|
|
error = PTR_ERR(dentry); |
904 |
|
|
if (!IS_ERR(dentry)) { |
905 |
|
|
+ /***** TOMOYO Linux start. *****/ |
906 |
kumaneko |
2290 |
+ error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry, |
907 |
|
|
+ nd.mnt); |
908 |
kumaneko |
1603 |
+ if (!error) |
909 |
|
|
+ /***** TOMOYO Linux end. *****/ |
910 |
|
|
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
911 |
|
|
dput(dentry); |
912 |
|
|
} |
913 |
kumaneko |
2297 |
@@ -1548,6 +1591,12 @@ asmlinkage long sys_unlink(const char * |
914 |
kumaneko |
1603 |
/* Why not before? Because we want correct error value */ |
915 |
|
|
if (nd.last.name[nd.last.len]) |
916 |
|
|
goto slashes; |
917 |
|
|
+ /***** TOMOYO Linux start. *****/ |
918 |
kumaneko |
2290 |
+ error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry, |
919 |
|
|
+ nd.mnt); |
920 |
kumaneko |
2297 |
+ if (error) |
921 |
|
|
+ goto exit2; |
922 |
kumaneko |
1603 |
+ /***** TOMOYO Linux end. *****/ |
923 |
|
|
error = vfs_unlink(nd.dentry->d_inode, dentry); |
924 |
|
|
exit2: |
925 |
|
|
dput(dentry); |
926 |
kumaneko |
2297 |
@@ -1612,6 +1661,12 @@ asmlinkage long sys_symlink(const char * |
927 |
kumaneko |
1603 |
dentry = lookup_create(&nd, 0); |
928 |
|
|
error = PTR_ERR(dentry); |
929 |
|
|
if (!IS_ERR(dentry)) { |
930 |
|
|
+ /***** TOMOYO Linux start. *****/ |
931 |
kumaneko |
2290 |
+ error = ccs_check_symlink_permission(nd.dentry->d_inode, |
932 |
|
|
+ dentry, nd.mnt, |
933 |
|
|
+ from); |
934 |
kumaneko |
1603 |
+ if (!error) |
935 |
|
|
+ /***** TOMOYO Linux end. *****/ |
936 |
|
|
error = vfs_symlink(nd.dentry->d_inode, dentry, from); |
937 |
|
|
dput(dentry); |
938 |
|
|
} |
939 |
kumaneko |
2297 |
@@ -1698,6 +1753,12 @@ asmlinkage long sys_link(const char * ol |
940 |
kumaneko |
1603 |
new_dentry = lookup_create(&nd, 0); |
941 |
|
|
error = PTR_ERR(new_dentry); |
942 |
|
|
if (!IS_ERR(new_dentry)) { |
943 |
|
|
+ /***** TOMOYO Linux start. *****/ |
944 |
kumaneko |
2290 |
+ error = ccs_check_link_permission(old_nd.dentry, |
945 |
|
|
+ nd.dentry->d_inode, |
946 |
|
|
+ new_dentry, nd.mnt); |
947 |
kumaneko |
1603 |
+ if (!error) |
948 |
|
|
+ /***** TOMOYO Linux end. *****/ |
949 |
|
|
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
950 |
|
|
dput(new_dentry); |
951 |
|
|
} |
952 |
kumaneko |
2297 |
@@ -1928,12 +1989,22 @@ static inline int do_rename(const char * |
953 |
kumaneko |
1603 |
error = PTR_ERR(new_dentry); |
954 |
|
|
if (IS_ERR(new_dentry)) |
955 |
|
|
goto exit4; |
956 |
|
|
+ /***** TOMOYO Linux start. *****/ |
957 |
kumaneko |
2290 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
958 |
|
|
+ new_dir->d_inode, new_dentry, |
959 |
|
|
+ newnd.mnt); |
960 |
|
|
+ if (error) |
961 |
|
|
+ goto exit5; |
962 |
kumaneko |
1603 |
+ /***** TOMOYO Linux end. *****/ |
963 |
|
|
|
964 |
|
|
lock_kernel(); |
965 |
|
|
error = vfs_rename(old_dir->d_inode, old_dentry, |
966 |
kumaneko |
2290 |
new_dir->d_inode, new_dentry); |
967 |
|
|
unlock_kernel(); |
968 |
|
|
|
969 |
kumaneko |
1603 |
+ /***** TOMOYO Linux start. *****/ |
970 |
kumaneko |
2290 |
+exit5: |
971 |
kumaneko |
1603 |
+ /***** TOMOYO Linux end. *****/ |
972 |
kumaneko |
2290 |
dput(new_dentry); |
973 |
|
|
exit4: |
974 |
|
|
dput(old_dentry); |
975 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/namespace.c |
976 |
|
|
+++ linux-2.4.37.3/fs/namespace.c |
977 |
kumaneko |
1603 |
@@ -21,6 +21,13 @@ |
978 |
|
|
#include <linux/seq_file.h> |
979 |
|
|
#include <linux/namespace.h> |
980 |
|
|
|
981 |
|
|
+/***** SAKURA Linux start. *****/ |
982 |
|
|
+#include <linux/sakura.h> |
983 |
|
|
+/***** SAKURA Linux end. *****/ |
984 |
|
|
+/***** TOMOYO Linux start. *****/ |
985 |
|
|
+#include <linux/tomoyo.h> |
986 |
|
|
+/***** TOMOYO Linux end. *****/ |
987 |
|
|
+ |
988 |
|
|
struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data); |
989 |
|
|
int do_remount_sb(struct super_block *sb, int flags, void * data); |
990 |
|
|
void kill_super(struct super_block *sb); |
991 |
|
|
@@ -290,6 +297,10 @@ static int do_umount(struct vfsmount *mn |
992 |
|
|
{ |
993 |
|
|
struct super_block * sb = mnt->mnt_sb; |
994 |
|
|
int retval = 0; |
995 |
|
|
+ /***** SAKURA Linux start. *****/ |
996 |
|
|
+ if (ccs_may_umount(mnt)) |
997 |
|
|
+ return -EPERM; |
998 |
|
|
+ /***** SAKURA Linux end. *****/ |
999 |
|
|
|
1000 |
|
|
/* |
1001 |
|
|
* If we may have to abort operations to get out of this |
1002 |
|
|
@@ -365,6 +376,10 @@ asmlinkage long sys_umount(char * name, |
1003 |
|
|
{ |
1004 |
|
|
struct nameidata nd; |
1005 |
|
|
int retval; |
1006 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1007 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
1008 |
kumaneko |
1603 |
+ return -EPERM; |
1009 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1010 |
|
|
|
1011 |
|
|
retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd); |
1012 |
|
|
if (retval) |
1013 |
|
|
@@ -500,6 +515,11 @@ static int do_loopback(struct nameidata |
1014 |
|
|
down_write(¤t->namespace->sem); |
1015 |
|
|
err = -EINVAL; |
1016 |
|
|
if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) { |
1017 |
|
|
+ /***** SAKURA Linux start. *****/ |
1018 |
|
|
+ err = -EPERM; |
1019 |
|
|
+ if (ccs_may_mount(nd)) |
1020 |
|
|
+ goto out; |
1021 |
|
|
+ /***** SAKURA Linux end. *****/ |
1022 |
|
|
err = -ENOMEM; |
1023 |
|
|
if (recurse) |
1024 |
|
|
mnt = copy_tree(old_nd.mnt, old_nd.dentry); |
1025 |
|
|
@@ -516,7 +536,9 @@ static int do_loopback(struct nameidata |
1026 |
|
|
} else |
1027 |
|
|
mntput(mnt); |
1028 |
|
|
} |
1029 |
|
|
- |
1030 |
|
|
+ /***** SAKURA Linux start. *****/ |
1031 |
|
|
+ out: |
1032 |
|
|
+ /***** SAKURA Linux end. *****/ |
1033 |
|
|
up_write(¤t->namespace->sem); |
1034 |
|
|
path_release(&old_nd); |
1035 |
|
|
return err; |
1036 |
|
|
@@ -570,6 +592,12 @@ static int do_move_mount(struct nameidat |
1037 |
|
|
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
1038 |
|
|
goto out; |
1039 |
|
|
|
1040 |
|
|
+ /***** SAKURA Linux start. *****/ |
1041 |
|
|
+ err = -EPERM; |
1042 |
|
|
+ if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd)) |
1043 |
|
|
+ goto out; |
1044 |
|
|
+ /***** SAKURA Linux end. *****/ |
1045 |
|
|
+ |
1046 |
|
|
err = -ENOENT; |
1047 |
|
|
down(&nd->dentry->d_inode->i_zombie); |
1048 |
|
|
if (IS_DEADDIR(nd->dentry->d_inode)) |
1049 |
|
|
@@ -641,6 +669,12 @@ static int do_add_mount(struct nameidata |
1050 |
|
|
if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry) |
1051 |
|
|
goto unlock; |
1052 |
|
|
|
1053 |
|
|
+ /***** SAKURA Linux start. *****/ |
1054 |
|
|
+ err = -EPERM; |
1055 |
|
|
+ if (ccs_may_mount(nd)) |
1056 |
|
|
+ goto unlock; |
1057 |
|
|
+ /***** SAKURA Linux end. *****/ |
1058 |
|
|
+ |
1059 |
|
|
mnt->mnt_flags = mnt_flags; |
1060 |
|
|
err = graft_tree(mnt, nd); |
1061 |
|
|
unlock: |
1062 |
|
|
@@ -718,6 +752,17 @@ long do_mount(char * dev_name, char * di |
1063 |
|
|
if (data_page) |
1064 |
|
|
((char *)data_page)[PAGE_SIZE - 1] = 0; |
1065 |
|
|
|
1066 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1067 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
1068 |
kumaneko |
1603 |
+ return -EPERM; |
1069 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1070 |
|
|
+ /***** SAKURA Linux start. *****/ |
1071 |
|
|
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
1072 |
|
|
+ &flags); |
1073 |
|
|
+ if (retval) |
1074 |
|
|
+ return retval; |
1075 |
|
|
+ /***** SAKURA Linux end. *****/ |
1076 |
|
|
+ |
1077 |
|
|
/* Separate the per-mountpoint flags */ |
1078 |
|
|
if (flags & MS_NOSUID) |
1079 |
|
|
mnt_flags |= MNT_NOSUID; |
1080 |
|
|
@@ -911,6 +956,10 @@ asmlinkage long sys_pivot_root(const cha |
1081 |
|
|
|
1082 |
|
|
if (!capable(CAP_SYS_ADMIN)) |
1083 |
|
|
return -EPERM; |
1084 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1085 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
1086 |
kumaneko |
1603 |
+ return -EPERM; |
1087 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1088 |
|
|
|
1089 |
|
|
lock_kernel(); |
1090 |
|
|
|
1091 |
|
|
@@ -925,6 +974,13 @@ asmlinkage long sys_pivot_root(const cha |
1092 |
|
|
if (error) |
1093 |
|
|
goto out1; |
1094 |
|
|
|
1095 |
|
|
+ /***** SAKURA Linux start. *****/ |
1096 |
|
|
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
1097 |
|
|
+ if (error) { |
1098 |
|
|
+ path_release(&old_nd); |
1099 |
|
|
+ goto out1; |
1100 |
|
|
+ } |
1101 |
|
|
+ /***** SAKURA Linux end. *****/ |
1102 |
|
|
read_lock(¤t->fs->lock); |
1103 |
|
|
user_nd.mnt = mntget(current->fs->rootmnt); |
1104 |
|
|
user_nd.dentry = dget(current->fs->root); |
1105 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/open.c |
1106 |
|
|
+++ linux-2.4.37.3/fs/open.c |
1107 |
kumaneko |
1603 |
@@ -20,6 +20,13 @@ |
1108 |
|
|
|
1109 |
|
|
#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) |
1110 |
|
|
|
1111 |
|
|
+/***** SAKURA Linux start. *****/ |
1112 |
|
|
+#include <linux/sakura.h> |
1113 |
|
|
+/***** SAKURA Linux end. *****/ |
1114 |
|
|
+/***** TOMOYO Linux start. *****/ |
1115 |
|
|
+#include <linux/tomoyo.h> |
1116 |
|
|
+/***** TOMOYO Linux end. *****/ |
1117 |
|
|
+ |
1118 |
|
|
int vfs_statfs(struct super_block *sb, struct statfs *buf) |
1119 |
|
|
{ |
1120 |
|
|
int retval = -ENODEV; |
1121 |
kumaneko |
1811 |
@@ -164,6 +171,11 @@ static inline long do_sys_truncate(const |
1122 |
kumaneko |
1603 |
if (error) |
1123 |
|
|
goto dput_and_out; |
1124 |
|
|
|
1125 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1126 |
kumaneko |
2290 |
+ error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0); |
1127 |
kumaneko |
1603 |
+ if (!error) |
1128 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1129 |
|
|
+ |
1130 |
|
|
error = locks_verify_truncate(inode, NULL, length); |
1131 |
|
|
if (!error) { |
1132 |
|
|
DQUOT_INIT(inode); |
1133 |
kumaneko |
2290 |
@@ -217,6 +229,12 @@ static inline long do_sys_ftruncate(unsi |
1134 |
kumaneko |
1603 |
if (IS_APPEND(inode)) |
1135 |
|
|
goto out_putf; |
1136 |
|
|
|
1137 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1138 |
kumaneko |
2290 |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
1139 |
|
|
+ 0); |
1140 |
kumaneko |
1603 |
+ if (error) |
1141 |
|
|
+ goto out_putf; |
1142 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1143 |
|
|
error = locks_verify_truncate(inode, file, length); |
1144 |
|
|
if (!error) |
1145 |
|
|
error = do_truncate(dentry, length); |
1146 |
kumaneko |
2290 |
@@ -466,6 +484,14 @@ asmlinkage long sys_chroot(const char * |
1147 |
kumaneko |
1603 |
error = -EPERM; |
1148 |
|
|
if (!capable(CAP_SYS_CHROOT)) |
1149 |
|
|
goto dput_and_out; |
1150 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1151 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
1152 |
kumaneko |
1603 |
+ goto dput_and_out; |
1153 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1154 |
|
|
+ /***** SAKURA Linux start. *****/ |
1155 |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
1156 |
|
|
+ goto dput_and_out; |
1157 |
|
|
+ /***** SAKURA Linux end. *****/ |
1158 |
|
|
|
1159 |
|
|
set_fs_root(current->fs, nd.mnt, nd.dentry); |
1160 |
|
|
set_fs_altroot(); |
1161 |
kumaneko |
2290 |
@@ -897,6 +923,10 @@ out_unlock: |
1162 |
kumaneko |
1603 |
*/ |
1163 |
|
|
asmlinkage long sys_vhangup(void) |
1164 |
|
|
{ |
1165 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1166 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
1167 |
kumaneko |
1603 |
+ return -EPERM; |
1168 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1169 |
|
|
if (capable(CAP_SYS_TTY_CONFIG)) { |
1170 |
|
|
tty_vhangup(current->tty); |
1171 |
|
|
return 0; |
1172 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/proc/Makefile |
1173 |
|
|
+++ linux-2.4.37.3/fs/proc/Makefile |
1174 |
kumaneko |
1603 |
@@ -18,4 +18,8 @@ ifeq ($(CONFIG_PROC_DEVICETREE),y) |
1175 |
|
|
obj-y += proc_devtree.o |
1176 |
|
|
endif |
1177 |
|
|
|
1178 |
|
|
+export-objs += ccs_proc.o |
1179 |
|
|
+obj-$(CONFIG_SAKURA) += ccs_proc.o |
1180 |
|
|
+obj-$(CONFIG_TOMOYO) += ccs_proc.o |
1181 |
|
|
+ |
1182 |
|
|
include $(TOPDIR)/Rules.make |
1183 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/fs/proc/proc_misc.c |
1184 |
|
|
+++ linux-2.4.37.3/fs/proc/proc_misc.c |
1185 |
kumaneko |
1603 |
@@ -670,4 +670,9 @@ void __init proc_misc_init(void) |
1186 |
|
|
entry->proc_fops = &ppc_htab_operations; |
1187 |
|
|
} |
1188 |
|
|
#endif |
1189 |
|
|
+ /***** CCS start. *****/ |
1190 |
|
|
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
1191 |
kumaneko |
2781 |
+ printk(KERN_INFO "Hook version: 2.4.37.3 2009/07/20\n"); |
1192 |
kumaneko |
1603 |
+#endif |
1193 |
|
|
+ /***** CCS end. *****/ |
1194 |
|
|
} |
1195 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/include/linux/sched.h |
1196 |
|
|
+++ linux-2.4.37.3/include/linux/sched.h |
1197 |
kumaneko |
2282 |
@@ -29,6 +29,10 @@ extern unsigned long event; |
1198 |
kumaneko |
1603 |
|
1199 |
|
|
struct exec_domain; |
1200 |
|
|
|
1201 |
|
|
+/***** TOMOYO Linux start. *****/ |
1202 |
kumaneko |
2282 |
+struct ccs_domain_info; |
1203 |
kumaneko |
1603 |
+/***** TOMOYO Linux end. *****/ |
1204 |
|
|
+ |
1205 |
|
|
/* |
1206 |
|
|
* cloning flags: |
1207 |
|
|
*/ |
1208 |
kumaneko |
2282 |
@@ -417,6 +421,10 @@ struct task_struct { |
1209 |
kumaneko |
1811 |
void *journal_info; |
1210 |
kumaneko |
1603 |
|
1211 |
kumaneko |
1811 |
struct list_head *scm_work_list; |
1212 |
kumaneko |
1603 |
+ /***** TOMOYO Linux start. *****/ |
1213 |
kumaneko |
2282 |
+ struct ccs_domain_info *ccs_domain_info; |
1214 |
|
|
+ u32 ccs_flags; |
1215 |
kumaneko |
1603 |
+ /***** TOMOYO Linux end. *****/ |
1216 |
|
|
}; |
1217 |
|
|
|
1218 |
|
|
/* |
1219 |
kumaneko |
2282 |
@@ -512,6 +520,10 @@ extern struct exec_domain default_exec_d |
1220 |
kumaneko |
1603 |
blocked: {{0}}, \ |
1221 |
|
|
alloc_lock: SPIN_LOCK_UNLOCKED, \ |
1222 |
|
|
journal_info: NULL, \ |
1223 |
|
|
+ /***** TOMOYO Linux start. *****/ \ |
1224 |
kumaneko |
2282 |
+ ccs_domain_info: NULL, \ |
1225 |
|
|
+ ccs_flags: 0 \ |
1226 |
kumaneko |
1603 |
+ /***** TOMOYO Linux end. *****/ \ |
1227 |
|
|
} |
1228 |
|
|
|
1229 |
|
|
|
1230 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/kernel/kmod.c |
1231 |
|
|
+++ linux-2.4.37.3/kernel/kmod.c |
1232 |
kumaneko |
1603 |
@@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa |
1233 |
|
|
/* Allow execve args to be in kernel space. */ |
1234 |
|
|
set_fs(KERNEL_DS); |
1235 |
|
|
|
1236 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1237 |
kumaneko |
2282 |
+ current->ccs_domain_info = NULL; |
1238 |
|
|
+ current->ccs_flags = 0; |
1239 |
kumaneko |
1603 |
+ /***** TOMOYO Linux end. *****/ |
1240 |
|
|
+ |
1241 |
|
|
/* Go, go, go... */ |
1242 |
|
|
if (execve(program_path, argv, envp) < 0) |
1243 |
|
|
return -errno; |
1244 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/kernel/module.c |
1245 |
|
|
+++ linux-2.4.37.3/kernel/module.c |
1246 |
kumaneko |
1603 |
@@ -10,6 +10,9 @@ |
1247 |
|
|
#include <linux/slab.h> |
1248 |
|
|
#include <linux/kmod.h> |
1249 |
|
|
#include <linux/seq_file.h> |
1250 |
|
|
+/***** TOMOYO Linux start. *****/ |
1251 |
|
|
+#include <linux/tomoyo.h> |
1252 |
|
|
+/***** TOMOYO Linux end. *****/ |
1253 |
|
|
|
1254 |
|
|
/* |
1255 |
|
|
* Originally by Anonymous (as far as I know...) |
1256 |
|
|
@@ -298,6 +301,10 @@ sys_create_module(const char *name_user, |
1257 |
|
|
|
1258 |
|
|
if (!capable(CAP_SYS_MODULE)) |
1259 |
|
|
return -EPERM; |
1260 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1261 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
1262 |
kumaneko |
1603 |
+ return -EPERM; |
1263 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1264 |
|
|
lock_kernel(); |
1265 |
|
|
if ((namelen = get_mod_name(name_user, &name)) < 0) { |
1266 |
|
|
error = namelen; |
1267 |
|
|
@@ -353,6 +360,10 @@ sys_init_module(const char *name_user, s |
1268 |
|
|
|
1269 |
|
|
if (!capable(CAP_SYS_MODULE)) |
1270 |
|
|
return -EPERM; |
1271 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1272 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
1273 |
kumaneko |
1603 |
+ return -EPERM; |
1274 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1275 |
|
|
lock_kernel(); |
1276 |
|
|
if ((namelen = get_mod_name(name_user, &name)) < 0) { |
1277 |
|
|
error = namelen; |
1278 |
|
|
@@ -614,6 +625,10 @@ sys_delete_module(const char *name_user) |
1279 |
|
|
|
1280 |
|
|
if (!capable(CAP_SYS_MODULE)) |
1281 |
|
|
return -EPERM; |
1282 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1283 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
1284 |
kumaneko |
1603 |
+ return -EPERM; |
1285 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1286 |
|
|
|
1287 |
|
|
lock_kernel(); |
1288 |
|
|
if (name_user) { |
1289 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/kernel/sched.c |
1290 |
|
|
+++ linux-2.4.37.3/kernel/sched.c |
1291 |
kumaneko |
1603 |
@@ -32,6 +32,9 @@ |
1292 |
|
|
|
1293 |
|
|
#include <asm/uaccess.h> |
1294 |
|
|
#include <asm/mmu_context.h> |
1295 |
|
|
+/***** TOMOYO Linux start. *****/ |
1296 |
|
|
+#include <linux/tomoyo.h> |
1297 |
|
|
+/***** TOMOYO Linux end. *****/ |
1298 |
|
|
|
1299 |
|
|
extern void timer_bh(void); |
1300 |
|
|
extern void tqueue_bh(void); |
1301 |
|
|
@@ -899,6 +902,10 @@ void set_cpus_allowed(struct task_struct |
1302 |
|
|
asmlinkage long sys_nice(int increment) |
1303 |
|
|
{ |
1304 |
|
|
long newprio; |
1305 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1306 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
1307 |
kumaneko |
1603 |
+ return -EPERM; |
1308 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1309 |
|
|
|
1310 |
|
|
/* |
1311 |
|
|
* Setpriority might change our priority at the same moment. |
1312 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/kernel/signal.c |
1313 |
|
|
+++ linux-2.4.37.3/kernel/signal.c |
1314 |
kumaneko |
1603 |
@@ -15,6 +15,9 @@ |
1315 |
|
|
#include <linux/sched.h> |
1316 |
|
|
|
1317 |
|
|
#include <asm/uaccess.h> |
1318 |
|
|
+/***** TOMOYO Linux start. *****/ |
1319 |
|
|
+#include <linux/tomoyo.h> |
1320 |
|
|
+/***** TOMOYO Linux end. *****/ |
1321 |
|
|
|
1322 |
|
|
/* |
1323 |
|
|
* SLAB caches for signal bits. |
1324 |
|
|
@@ -1025,6 +1028,12 @@ asmlinkage long |
1325 |
|
|
sys_kill(int pid, int sig) |
1326 |
|
|
{ |
1327 |
|
|
struct siginfo info; |
1328 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1329 |
kumaneko |
2282 |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
1330 |
kumaneko |
1603 |
+ return -EPERM; |
1331 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1332 |
|
|
+ return -EPERM; |
1333 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1334 |
|
|
|
1335 |
|
|
info.si_signo = sig; |
1336 |
|
|
info.si_errno = 0; |
1337 |
|
|
@@ -1049,6 +1058,12 @@ sys_tkill(int pid, int sig) |
1338 |
|
|
if (pid <= 0) |
1339 |
|
|
return -EINVAL; |
1340 |
|
|
|
1341 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1342 |
kumaneko |
2282 |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
1343 |
kumaneko |
1603 |
+ return -EPERM; |
1344 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
1345 |
|
|
+ return -EPERM; |
1346 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1347 |
|
|
info.si_signo = sig; |
1348 |
|
|
info.si_errno = 0; |
1349 |
|
|
info.si_code = SI_TKILL; |
1350 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/kernel/sys.c |
1351 |
|
|
+++ linux-2.4.37.3/kernel/sys.c |
1352 |
kumaneko |
1603 |
@@ -17,6 +17,9 @@ |
1353 |
|
|
|
1354 |
|
|
#include <asm/uaccess.h> |
1355 |
|
|
#include <asm/io.h> |
1356 |
|
|
+/***** TOMOYO Linux start. *****/ |
1357 |
|
|
+#include <linux/tomoyo.h> |
1358 |
|
|
+/***** TOMOYO Linux end. *****/ |
1359 |
|
|
|
1360 |
|
|
#ifndef SET_UNALIGN_CTL |
1361 |
|
|
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
1362 |
|
|
@@ -220,6 +223,10 @@ asmlinkage long sys_setpriority(int whic |
1363 |
|
|
|
1364 |
|
|
if (which > 2 || which < 0) |
1365 |
|
|
return -EINVAL; |
1366 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1367 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
1368 |
kumaneko |
1603 |
+ return -EPERM; |
1369 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1370 |
|
|
|
1371 |
|
|
/* normalize: avoid signed division (rounding problems) */ |
1372 |
|
|
error = -ESRCH; |
1373 |
|
|
@@ -299,6 +306,10 @@ asmlinkage long sys_reboot(int magic1, i |
1374 |
|
|
(magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && |
1375 |
|
|
magic2 != LINUX_REBOOT_MAGIC2B)) |
1376 |
|
|
return -EINVAL; |
1377 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1378 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
1379 |
kumaneko |
1603 |
+ return -EPERM; |
1380 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1381 |
|
|
|
1382 |
|
|
lock_kernel(); |
1383 |
|
|
switch (cmd) { |
1384 |
|
|
@@ -1042,6 +1053,10 @@ asmlinkage long sys_sethostname(char *na |
1385 |
|
|
return -EPERM; |
1386 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
1387 |
|
|
return -EINVAL; |
1388 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1389 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
1390 |
kumaneko |
1603 |
+ return -EPERM; |
1391 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1392 |
|
|
down_write(&uts_sem); |
1393 |
|
|
errno = -EFAULT; |
1394 |
|
|
if (!copy_from_user(tmp, name, len)) { |
1395 |
|
|
@@ -1083,6 +1098,10 @@ asmlinkage long sys_setdomainname(char * |
1396 |
|
|
return -EPERM; |
1397 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
1398 |
|
|
return -EINVAL; |
1399 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1400 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
1401 |
kumaneko |
1603 |
+ return -EPERM; |
1402 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1403 |
|
|
|
1404 |
|
|
down_write(&uts_sem); |
1405 |
|
|
errno = -EFAULT; |
1406 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/kernel/sysctl.c |
1407 |
|
|
+++ linux-2.4.37.3/kernel/sysctl.c |
1408 |
kumaneko |
1603 |
@@ -33,6 +33,9 @@ |
1409 |
|
|
#include <linux/swap.h> |
1410 |
|
|
|
1411 |
|
|
#include <asm/uaccess.h> |
1412 |
|
|
+/***** TOMOYO Linux start. *****/ |
1413 |
|
|
+#include <linux/tomoyo.h> |
1414 |
|
|
+/***** TOMOYO Linux end. *****/ |
1415 |
|
|
|
1416 |
|
|
#ifdef CONFIG_ROOT_NFS |
1417 |
|
|
#include <linux/nfs_fs.h> |
1418 |
kumaneko |
2298 |
@@ -439,6 +442,11 @@ int do_sysctl(int *name, int nlen, void |
1419 |
kumaneko |
1603 |
|
1420 |
|
|
spin_unlock(&sysctl_lock); |
1421 |
|
|
|
1422 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1423 |
kumaneko |
2298 |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
1424 |
kumaneko |
1603 |
+ head->ctl_table); |
1425 |
|
|
+ if (!error) |
1426 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1427 |
|
|
error = parse_table(name, nlen, oldval, oldlenp, |
1428 |
|
|
newval, newlen, head->ctl_table, |
1429 |
|
|
&context); |
1430 |
kumaneko |
2298 |
@@ -508,6 +516,15 @@ repeat: |
1431 |
kumaneko |
1603 |
if (ctl_perm(table, 001)) |
1432 |
|
|
return -EPERM; |
1433 |
|
|
if (table->strategy) { |
1434 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1435 |
|
|
+ int op = 0; |
1436 |
|
|
+ if (oldval) |
1437 |
|
|
+ op |= 004; |
1438 |
|
|
+ if (newval) |
1439 |
|
|
+ op |= 002; |
1440 |
|
|
+ if (ctl_perm(table, op)) |
1441 |
|
|
+ return -EPERM; |
1442 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1443 |
|
|
error = table->strategy( |
1444 |
|
|
table, name, nlen, |
1445 |
|
|
oldval, oldlenp, |
1446 |
kumaneko |
2298 |
@@ -1456,7 +1473,7 @@ int sysctl_string(ctl_table *table, int |
1447 |
kumaneko |
1603 |
len--; |
1448 |
|
|
((char *) table->data)[len] = 0; |
1449 |
|
|
} |
1450 |
|
|
- return 0; |
1451 |
|
|
+ return 1; |
1452 |
|
|
} |
1453 |
|
|
|
1454 |
|
|
/* |
1455 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/kernel/time.c |
1456 |
|
|
+++ linux-2.4.37.3/kernel/time.c |
1457 |
kumaneko |
1603 |
@@ -29,6 +29,9 @@ |
1458 |
|
|
#include <linux/smp_lock.h> |
1459 |
|
|
|
1460 |
|
|
#include <asm/uaccess.h> |
1461 |
|
|
+/***** TOMOYO Linux start. *****/ |
1462 |
|
|
+#include <linux/tomoyo.h> |
1463 |
|
|
+/***** TOMOYO Linux end. *****/ |
1464 |
|
|
|
1465 |
|
|
/* |
1466 |
|
|
* The timezone where the local system is located. Used as a default by some |
1467 |
|
|
@@ -77,6 +80,10 @@ asmlinkage long sys_stime(int * tptr) |
1468 |
|
|
|
1469 |
|
|
if (!capable(CAP_SYS_TIME)) |
1470 |
|
|
return -EPERM; |
1471 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1472 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1473 |
kumaneko |
1603 |
+ return -EPERM; |
1474 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1475 |
|
|
if (get_user(value, tptr)) |
1476 |
|
|
return -EFAULT; |
1477 |
|
|
write_lock_irq(&xtime_lock); |
1478 |
|
|
@@ -151,6 +158,10 @@ int do_sys_settimeofday(struct timeval * |
1479 |
|
|
|
1480 |
|
|
if (!capable(CAP_SYS_TIME)) |
1481 |
|
|
return -EPERM; |
1482 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1483 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1484 |
kumaneko |
1603 |
+ return -EPERM; |
1485 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1486 |
|
|
|
1487 |
|
|
if (tz) { |
1488 |
|
|
/* SMP safe, global irq locking makes it work. */ |
1489 |
|
|
@@ -217,6 +228,10 @@ int do_adjtimex(struct timex *txc) |
1490 |
|
|
/* In order to modify anything, you gotta be super-user! */ |
1491 |
|
|
if (txc->modes && !capable(CAP_SYS_TIME)) |
1492 |
|
|
return -EPERM; |
1493 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1494 |
kumaneko |
2282 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
1495 |
kumaneko |
1603 |
+ return -EPERM; |
1496 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1497 |
|
|
|
1498 |
|
|
/* Now we validate the data before disabling interrupts */ |
1499 |
|
|
|
1500 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/ipv4/raw.c |
1501 |
|
|
+++ linux-2.4.37.3/net/ipv4/raw.c |
1502 |
kumaneko |
2459 |
@@ -64,6 +64,9 @@ |
1503 |
|
|
#include <net/raw.h> |
1504 |
|
|
#include <net/inet_common.h> |
1505 |
kumaneko |
1603 |
#include <net/checksum.h> |
1506 |
|
|
+/***** TOMOYO Linux start. *****/ |
1507 |
|
|
+#include <linux/tomoyo_socket.h> |
1508 |
|
|
+/***** TOMOYO Linux end. *****/ |
1509 |
|
|
|
1510 |
kumaneko |
2459 |
struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE]; |
1511 |
|
|
rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED; |
1512 |
|
|
@@ -503,6 +506,11 @@ int raw_recvmsg(struct sock *sk, struct |
1513 |
|
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1514 |
|
|
if (!skb) |
1515 |
|
|
goto out; |
1516 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1517 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1518 |
|
|
+ if (err) |
1519 |
|
|
+ goto out; |
1520 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1521 |
kumaneko |
1603 |
|
1522 |
kumaneko |
2459 |
copied = skb->len; |
1523 |
|
|
if (len < copied) { |
1524 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/ipv4/tcp_ipv4.c |
1525 |
|
|
+++ linux-2.4.37.3/net/ipv4/tcp_ipv4.c |
1526 |
kumaneko |
1603 |
@@ -67,6 +67,9 @@ |
1527 |
|
|
#include <linux/inet.h> |
1528 |
|
|
#include <linux/stddef.h> |
1529 |
|
|
#include <linux/ipsec.h> |
1530 |
|
|
+/***** SAKURA Linux start. *****/ |
1531 |
|
|
+#include <linux/sakura.h> |
1532 |
|
|
+/***** SAKURA Linux end. *****/ |
1533 |
|
|
|
1534 |
|
|
extern int sysctl_ip_dynaddr; |
1535 |
|
|
extern int sysctl_ip_default_ttl; |
1536 |
|
|
@@ -228,6 +231,10 @@ static int tcp_v4_get_port(struct sock * |
1537 |
|
|
rover = low; |
1538 |
|
|
head = &tcp_bhash[tcp_bhashfn(rover)]; |
1539 |
|
|
spin_lock(&head->lock); |
1540 |
|
|
+ /***** SAKURA Linux start. *****/ |
1541 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(rover)) |
1542 |
kumaneko |
1603 |
+ goto next; |
1543 |
|
|
+ /***** SAKURA Linux end. *****/ |
1544 |
|
|
for (tb = head->chain; tb; tb = tb->next) |
1545 |
|
|
if (tb->port == rover) |
1546 |
|
|
goto next; |
1547 |
|
|
@@ -688,6 +695,10 @@ static int tcp_v4_hash_connect(struct so |
1548 |
|
|
rover = low; |
1549 |
|
|
head = &tcp_bhash[tcp_bhashfn(rover)]; |
1550 |
|
|
spin_lock(&head->lock); |
1551 |
|
|
+ /***** SAKURA Linux start. *****/ |
1552 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(rover)) |
1553 |
kumaneko |
1603 |
+ goto next_port; |
1554 |
|
|
+ /***** SAKURA Linux end. *****/ |
1555 |
|
|
|
1556 |
|
|
/* Does not bother with rcv_saddr checks, |
1557 |
|
|
* because the established check is already |
1558 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/ipv4/udp.c |
1559 |
|
|
+++ linux-2.4.37.3/net/ipv4/udp.c |
1560 |
kumaneko |
2459 |
@@ -97,6 +97,12 @@ |
1561 |
kumaneko |
1603 |
#include <net/route.h> |
1562 |
|
|
#include <net/inet_common.h> |
1563 |
|
|
#include <net/checksum.h> |
1564 |
|
|
+/***** SAKURA Linux start. *****/ |
1565 |
|
|
+#include <linux/sakura.h> |
1566 |
|
|
+/***** SAKURA Linux end. *****/ |
1567 |
kumaneko |
2459 |
+/***** TOMOYO Linux start. *****/ |
1568 |
|
|
+#include <linux/tomoyo_socket.h> |
1569 |
|
|
+/***** TOMOYO Linux end. *****/ |
1570 |
kumaneko |
1603 |
|
1571 |
|
|
/* |
1572 |
|
|
* Snmp MIB for the UDP layer |
1573 |
kumaneko |
2459 |
@@ -131,6 +137,10 @@ static int udp_v4_get_port(struct sock * |
1574 |
kumaneko |
1603 |
result = sysctl_local_port_range[0] + |
1575 |
|
|
((result - sysctl_local_port_range[0]) & |
1576 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1577 |
|
|
+ /***** SAKURA Linux start. *****/ |
1578 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(result)) |
1579 |
kumaneko |
1603 |
+ continue; |
1580 |
|
|
+ /***** SAKURA Linux end. *****/ |
1581 |
|
|
goto gotit; |
1582 |
|
|
} |
1583 |
|
|
size = 0; |
1584 |
kumaneko |
2459 |
@@ -148,6 +158,10 @@ static int udp_v4_get_port(struct sock * |
1585 |
kumaneko |
1603 |
result = sysctl_local_port_range[0] |
1586 |
|
|
+ ((result - sysctl_local_port_range[0]) & |
1587 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1588 |
|
|
+ /***** SAKURA Linux start. *****/ |
1589 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(result)) |
1590 |
kumaneko |
1603 |
+ continue; |
1591 |
|
|
+ /***** SAKURA Linux end. *****/ |
1592 |
|
|
if (!udp_lport_inuse(result)) |
1593 |
|
|
break; |
1594 |
|
|
} |
1595 |
kumaneko |
2459 |
@@ -711,6 +725,11 @@ try_again: |
1596 |
|
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1597 |
|
|
if (!skb) |
1598 |
|
|
goto out; |
1599 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1600 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1601 |
|
|
+ if (err) |
1602 |
|
|
+ goto out; |
1603 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1604 |
|
|
|
1605 |
|
|
copied = skb->len - sizeof(struct udphdr); |
1606 |
|
|
if (copied > len) { |
1607 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/ipv6/raw.c |
1608 |
|
|
+++ linux-2.4.37.3/net/ipv6/raw.c |
1609 |
kumaneko |
2459 |
@@ -45,6 +45,9 @@ |
1610 |
|
|
#include <net/inet_common.h> |
1611 |
|
|
|
1612 |
|
|
#include <net/rawv6.h> |
1613 |
|
|
+/***** TOMOYO Linux start. *****/ |
1614 |
|
|
+#include <linux/tomoyo_socket.h> |
1615 |
|
|
+/***** TOMOYO Linux end. *****/ |
1616 |
|
|
|
1617 |
|
|
struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1618 |
|
|
rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED; |
1619 |
|
|
@@ -369,6 +372,11 @@ int rawv6_recvmsg(struct sock *sk, struc |
1620 |
|
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1621 |
|
|
if (!skb) |
1622 |
|
|
goto out; |
1623 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1624 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1625 |
|
|
+ if (err) |
1626 |
|
|
+ goto out; |
1627 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1628 |
|
|
|
1629 |
|
|
copied = skb->len; |
1630 |
|
|
if (copied > len) { |
1631 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/ipv6/tcp_ipv6.c |
1632 |
|
|
+++ linux-2.4.37.3/net/ipv6/tcp_ipv6.c |
1633 |
kumaneko |
1603 |
@@ -52,6 +52,9 @@ |
1634 |
|
|
#include <net/inet_ecn.h> |
1635 |
|
|
|
1636 |
|
|
#include <asm/uaccess.h> |
1637 |
|
|
+/***** SAKURA Linux start. *****/ |
1638 |
|
|
+#include <linux/sakura.h> |
1639 |
|
|
+/***** SAKURA Linux end. *****/ |
1640 |
|
|
|
1641 |
|
|
static void tcp_v6_send_reset(struct sk_buff *skb); |
1642 |
|
|
static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req); |
1643 |
|
|
@@ -110,6 +113,10 @@ static int tcp_v6_get_port(struct sock * |
1644 |
|
|
rover = low; |
1645 |
|
|
head = &tcp_bhash[tcp_bhashfn(rover)]; |
1646 |
|
|
spin_lock(&head->lock); |
1647 |
|
|
+ /***** SAKURA Linux start. *****/ |
1648 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(rover)) |
1649 |
kumaneko |
1603 |
+ goto next; |
1650 |
|
|
+ /***** SAKURA Linux end. *****/ |
1651 |
|
|
for (tb = head->chain; tb; tb = tb->next) |
1652 |
|
|
if (tb->port == rover) |
1653 |
|
|
goto next; |
1654 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/ipv6/udp.c |
1655 |
|
|
+++ linux-2.4.37.3/net/ipv6/udp.c |
1656 |
kumaneko |
2459 |
@@ -50,6 +50,12 @@ |
1657 |
kumaneko |
1603 |
#include <net/inet_common.h> |
1658 |
|
|
|
1659 |
|
|
#include <net/checksum.h> |
1660 |
|
|
+/***** SAKURA Linux start. *****/ |
1661 |
|
|
+#include <linux/sakura.h> |
1662 |
|
|
+/***** SAKURA Linux end. *****/ |
1663 |
kumaneko |
2459 |
+/***** TOMOYO Linux start. *****/ |
1664 |
|
|
+#include <linux/tomoyo_socket.h> |
1665 |
|
|
+/***** TOMOYO Linux end. *****/ |
1666 |
kumaneko |
1603 |
|
1667 |
|
|
struct udp_mib udp_stats_in6[NR_CPUS*2]; |
1668 |
|
|
|
1669 |
kumaneko |
2459 |
@@ -77,6 +83,10 @@ static int udp_v6_get_port(struct sock * |
1670 |
kumaneko |
1603 |
result = sysctl_local_port_range[0] + |
1671 |
|
|
((result - sysctl_local_port_range[0]) & |
1672 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1673 |
|
|
+ /***** SAKURA Linux start. *****/ |
1674 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(result)) |
1675 |
kumaneko |
1603 |
+ continue; |
1676 |
|
|
+ /***** SAKURA Linux end. *****/ |
1677 |
|
|
goto gotit; |
1678 |
|
|
} |
1679 |
|
|
size = 0; |
1680 |
kumaneko |
2459 |
@@ -94,6 +104,10 @@ static int udp_v6_get_port(struct sock * |
1681 |
kumaneko |
1603 |
result = sysctl_local_port_range[0] |
1682 |
|
|
+ ((result - sysctl_local_port_range[0]) & |
1683 |
|
|
(UDP_HTABLE_SIZE - 1)); |
1684 |
|
|
+ /***** SAKURA Linux start. *****/ |
1685 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(result)) |
1686 |
kumaneko |
1603 |
+ continue; |
1687 |
|
|
+ /***** SAKURA Linux end. *****/ |
1688 |
|
|
if (!udp_lport_inuse(result)) |
1689 |
|
|
break; |
1690 |
|
|
} |
1691 |
kumaneko |
2459 |
@@ -406,6 +420,11 @@ try_again: |
1692 |
|
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1693 |
|
|
if (!skb) |
1694 |
|
|
goto out; |
1695 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1696 |
|
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1697 |
|
|
+ if (err) |
1698 |
|
|
+ goto out; |
1699 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1700 |
|
|
|
1701 |
|
|
copied = skb->len - sizeof(struct udphdr); |
1702 |
|
|
if (copied > len) { |
1703 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/socket.c |
1704 |
|
|
+++ linux-2.4.37.3/net/socket.c |
1705 |
kumaneko |
1603 |
@@ -84,6 +84,10 @@ |
1706 |
|
|
#include <net/sock.h> |
1707 |
|
|
#include <net/scm.h> |
1708 |
|
|
#include <linux/netfilter.h> |
1709 |
|
|
+/***** TOMOYO Linux start. *****/ |
1710 |
|
|
+#include <linux/tomoyo.h> |
1711 |
|
|
+#include <linux/tomoyo_socket.h> |
1712 |
|
|
+/***** TOMOYO Linux end. *****/ |
1713 |
|
|
|
1714 |
|
|
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1715 |
|
|
static ssize_t sock_read(struct file *file, char *buf, |
1716 |
|
|
@@ -501,7 +505,12 @@ int sock_sendmsg(struct socket *sock, st |
1717 |
|
|
{ |
1718 |
|
|
int err; |
1719 |
|
|
struct scm_cookie scm; |
1720 |
|
|
- |
1721 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1722 |
|
|
+ err = ccs_socket_sendmsg_permission(sock, |
1723 |
|
|
+ (struct sockaddr *) msg->msg_name, |
1724 |
|
|
+ msg->msg_namelen); |
1725 |
|
|
+ if (!err) |
1726 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1727 |
|
|
err = scm_send(sock, msg, &scm); |
1728 |
|
|
if (err >= 0) { |
1729 |
|
|
err = sock->ops->sendmsg(sock, msg, size, &scm); |
1730 |
|
|
@@ -847,7 +856,11 @@ int sock_create(int family, int type, in |
1731 |
|
|
} |
1732 |
|
|
family = PF_PACKET; |
1733 |
|
|
} |
1734 |
|
|
- |
1735 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1736 |
|
|
+ i = ccs_socket_create_permission(family, type, protocol); |
1737 |
|
|
+ if (i) |
1738 |
|
|
+ return i; |
1739 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1740 |
|
|
#if defined(CONFIG_KMOD) && defined(CONFIG_NET) |
1741 |
|
|
/* Attempt to load a protocol module if the find failed. |
1742 |
|
|
* |
1743 |
|
|
@@ -1003,6 +1016,12 @@ asmlinkage long sys_bind(int fd, struct |
1744 |
|
|
if((sock = sockfd_lookup(fd,&err))!=NULL) |
1745 |
|
|
{ |
1746 |
|
|
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) |
1747 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1748 |
|
|
+ err = ccs_socket_bind_permission(sock, |
1749 |
|
|
+ (struct sockaddr *) |
1750 |
|
|
+ address, addrlen); |
1751 |
|
|
+ if (!err) |
1752 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1753 |
|
|
err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen); |
1754 |
|
|
sockfd_put(sock); |
1755 |
|
|
} |
1756 |
|
|
@@ -1026,6 +1045,10 @@ asmlinkage long sys_listen(int fd, int b |
1757 |
|
|
if ((sock = sockfd_lookup(fd, &err)) != NULL) { |
1758 |
|
|
if ((unsigned) backlog > sysctl_somaxconn) |
1759 |
|
|
backlog = sysctl_somaxconn; |
1760 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1761 |
|
|
+ err = ccs_socket_listen_permission(sock); |
1762 |
|
|
+ if (!err) |
1763 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1764 |
|
|
err=sock->ops->listen(sock, backlog); |
1765 |
|
|
sockfd_put(sock); |
1766 |
|
|
} |
1767 |
|
|
@@ -1066,6 +1089,13 @@ asmlinkage long sys_accept(int fd, struc |
1768 |
|
|
if (err < 0) |
1769 |
|
|
goto out_release; |
1770 |
|
|
|
1771 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1772 |
|
|
+ if (ccs_socket_accept_permission(newsock, |
1773 |
|
|
+ (struct sockaddr *) address)) { |
1774 |
|
|
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1775 |
|
|
+ goto out_release; |
1776 |
|
|
+ } |
1777 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1778 |
|
|
if (upeer_sockaddr) { |
1779 |
|
|
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
1780 |
|
|
err = -ECONNABORTED; |
1781 |
|
|
@@ -1116,6 +1146,12 @@ asmlinkage long sys_connect(int fd, stru |
1782 |
|
|
err = move_addr_to_kernel(uservaddr, addrlen, address); |
1783 |
|
|
if (err < 0) |
1784 |
|
|
goto out_put; |
1785 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1786 |
|
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, |
1787 |
|
|
+ addrlen); |
1788 |
|
|
+ if (err) |
1789 |
|
|
+ goto out_put; |
1790 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1791 |
|
|
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
1792 |
|
|
sock->file->f_flags); |
1793 |
|
|
out_put: |
1794 |
kumaneko |
2781 |
--- linux-2.4.37.3.orig/net/unix/af_unix.c |
1795 |
|
|
+++ linux-2.4.37.3/net/unix/af_unix.c |
1796 |
kumaneko |
1603 |
@@ -111,6 +111,9 @@ |
1797 |
|
|
#include <linux/rtnetlink.h> |
1798 |
|
|
|
1799 |
|
|
#include <asm/checksum.h> |
1800 |
|
|
+/***** TOMOYO Linux start. *****/ |
1801 |
|
|
+#include <linux/tomoyo.h> |
1802 |
|
|
+/***** TOMOYO Linux end. *****/ |
1803 |
|
|
|
1804 |
|
|
int sysctl_unix_max_dgram_qlen = 10; |
1805 |
|
|
|
1806 |
kumaneko |
2457 |
@@ -710,6 +713,11 @@ static int unix_bind(struct socket *sock |
1807 |
kumaneko |
1603 |
* All right, let's create it. |
1808 |
|
|
*/ |
1809 |
|
|
mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask); |
1810 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1811 |
kumaneko |
2290 |
+ err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
1812 |
|
|
+ nd.mnt, mode, 0); |
1813 |
kumaneko |
1603 |
+ if (!err) |
1814 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1815 |
|
|
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1816 |
|
|
if (err) |
1817 |
|
|
goto out_mknod_dput; |