1 |
kumaneko |
1498 |
This is TOMOYO Linux patch for openSUSE 11.0. |
2 |
|
|
|
3 |
kumaneko |
2073 |
Source code for this patch is http://download.opensuse.org/update/11.0/rpm/i586/kernel-source-2.6.25.20-0.1.i586.rpm |
4 |
kumaneko |
1498 |
--- |
5 |
kumaneko |
2298 |
arch/ia64/ia32/sys_ia32.c | 7 ++++ |
6 |
|
|
arch/mips/kernel/ptrace32.c | 7 ++++ |
7 |
|
|
arch/s390/kernel/ptrace.c | 7 ++++ |
8 |
|
|
arch/x86/kernel/ptrace.c | 7 ++++ |
9 |
|
|
fs/Kconfig | 2 + |
10 |
|
|
fs/Makefile | 2 + |
11 |
|
|
fs/attr.c | 19 +++++++++++++ |
12 |
|
|
fs/compat.c | 5 ++- |
13 |
|
|
fs/compat_ioctl.c | 13 +++++++++ |
14 |
kumaneko |
2306 |
fs/exec.c | 18 +++++++++++- |
15 |
kumaneko |
2298 |
fs/fcntl.c | 9 ++++++ |
16 |
|
|
fs/ioctl.c | 11 +++++++ |
17 |
|
|
fs/namei.c | 57 ++++++++++++++++++++++++++++++++++++++++ |
18 |
|
|
fs/namespace.c | 49 ++++++++++++++++++++++++++++++++++ |
19 |
|
|
fs/open.c | 30 +++++++++++++++++++++ |
20 |
|
|
fs/proc/Makefile | 3 ++ |
21 |
|
|
fs/proc/proc_misc.c | 5 +++ |
22 |
|
|
include/linux/init_task.h | 4 ++ |
23 |
|
|
include/linux/sched.h | 8 +++++ |
24 |
|
|
kernel/compat.c | 7 ++++ |
25 |
|
|
kernel/kexec.c | 7 ++++ |
26 |
|
|
kernel/kmod.c | 5 +++ |
27 |
|
|
kernel/module.c | 11 +++++++ |
28 |
|
|
kernel/ptrace.c | 11 +++++++ |
29 |
|
|
kernel/sched.c | 7 ++++ |
30 |
|
|
kernel/signal.c | 21 ++++++++++++++ |
31 |
|
|
kernel/sys.c | 21 ++++++++++++++ |
32 |
|
|
kernel/sysctl.c | 9 ++++++ |
33 |
|
|
kernel/time.c | 11 +++++++ |
34 |
|
|
kernel/time/ntp.c | 7 ++++ |
35 |
|
|
net/core/datagram.c | 11 +++++++ |
36 |
|
|
net/ipv4/inet_connection_sock.c | 7 ++++ |
37 |
|
|
net/ipv4/inet_hashtables.c | 7 ++++ |
38 |
|
|
net/ipv4/udp.c | 10 +++++++ |
39 |
|
|
net/socket.c | 41 ++++++++++++++++++++++++++++ |
40 |
|
|
net/unix/af_unix.c | 8 +++++ |
41 |
kumaneko |
2306 |
36 files changed, 462 insertions(+), 2 deletions(-) |
42 |
kumaneko |
1498 |
|
43 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/arch/ia64/ia32/sys_ia32.c |
44 |
|
|
+++ linux-2.6.25.20-0.1/arch/ia64/ia32/sys_ia32.c |
45 |
kumaneko |
1498 |
@@ -50,6 +50,9 @@ |
46 |
|
|
#include <asm/types.h> |
47 |
|
|
#include <asm/uaccess.h> |
48 |
|
|
#include <asm/unistd.h> |
49 |
|
|
+/***** TOMOYO Linux start. *****/ |
50 |
|
|
+#include <linux/tomoyo.h> |
51 |
|
|
+/***** TOMOYO Linux end. *****/ |
52 |
|
|
|
53 |
|
|
#include "ia32priv.h" |
54 |
|
|
|
55 |
kumaneko |
2278 |
@@ -1753,6 +1756,10 @@ sys32_ptrace (int request, pid_t pid, un |
56 |
kumaneko |
1498 |
struct task_struct *child; |
57 |
|
|
unsigned int value, tmp; |
58 |
|
|
long i, ret; |
59 |
|
|
+ /***** TOMOYO Linux start. *****/ |
60 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
61 |
kumaneko |
1498 |
+ return -EPERM; |
62 |
|
|
+ /***** TOMOYO Linux end. *****/ |
63 |
|
|
|
64 |
|
|
lock_kernel(); |
65 |
|
|
if (request == PTRACE_TRACEME) { |
66 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/arch/mips/kernel/ptrace32.c |
67 |
|
|
+++ linux-2.6.25.20-0.1/arch/mips/kernel/ptrace32.c |
68 |
kumaneko |
1498 |
@@ -35,6 +35,9 @@ |
69 |
|
|
#include <asm/system.h> |
70 |
|
|
#include <asm/uaccess.h> |
71 |
|
|
#include <asm/bootinfo.h> |
72 |
|
|
+/***** TOMOYO Linux start. *****/ |
73 |
|
|
+#include <linux/tomoyo.h> |
74 |
|
|
+/***** TOMOYO Linux end. *****/ |
75 |
|
|
|
76 |
|
|
int ptrace_getregs(struct task_struct *child, __s64 __user *data); |
77 |
|
|
int ptrace_setregs(struct task_struct *child, __s64 __user *data); |
78 |
kumaneko |
2278 |
@@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request, |
79 |
kumaneko |
1498 |
{ |
80 |
|
|
struct task_struct *child; |
81 |
|
|
int ret; |
82 |
|
|
+ /***** TOMOYO Linux start. *****/ |
83 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
84 |
kumaneko |
1498 |
+ return -EPERM; |
85 |
|
|
+ /***** TOMOYO Linux end. *****/ |
86 |
|
|
|
87 |
|
|
#if 0 |
88 |
|
|
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
89 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/arch/s390/kernel/ptrace.c |
90 |
|
|
+++ linux-2.6.25.20-0.1/arch/s390/kernel/ptrace.c |
91 |
kumaneko |
1498 |
@@ -41,6 +41,9 @@ |
92 |
|
|
#include <asm/system.h> |
93 |
|
|
#include <asm/uaccess.h> |
94 |
|
|
#include <asm/unistd.h> |
95 |
|
|
+/***** TOMOYO Linux start. *****/ |
96 |
|
|
+#include <linux/tomoyo.h> |
97 |
|
|
+/***** TOMOYO Linux end. *****/ |
98 |
|
|
|
99 |
|
|
#ifdef CONFIG_COMPAT |
100 |
|
|
#include "compat_ptrace.h" |
101 |
kumaneko |
2278 |
@@ -698,6 +701,10 @@ sys_ptrace(long request, long pid, long |
102 |
kumaneko |
1498 |
struct task_struct *child; |
103 |
|
|
int ret; |
104 |
|
|
|
105 |
|
|
+ /***** TOMOYO Linux start. *****/ |
106 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
107 |
kumaneko |
1498 |
+ return -EPERM; |
108 |
|
|
+ /***** TOMOYO Linux end. *****/ |
109 |
|
|
lock_kernel(); |
110 |
|
|
if (request == PTRACE_TRACEME) { |
111 |
|
|
ret = ptrace_traceme(); |
112 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/arch/x86/kernel/ptrace.c |
113 |
|
|
+++ linux-2.6.25.20-0.1/arch/x86/kernel/ptrace.c |
114 |
kumaneko |
1498 |
@@ -32,6 +32,9 @@ |
115 |
|
|
#include <asm/prctl.h> |
116 |
|
|
#include <asm/proto.h> |
117 |
|
|
#include <asm/ds.h> |
118 |
|
|
+/***** TOMOYO Linux start. *****/ |
119 |
|
|
+#include <linux/tomoyo.h> |
120 |
|
|
+/***** TOMOYO Linux end. *****/ |
121 |
|
|
|
122 |
|
|
#include "tls.h" |
123 |
|
|
|
124 |
kumaneko |
2278 |
@@ -1240,6 +1243,10 @@ asmlinkage long sys32_ptrace(long reques |
125 |
kumaneko |
1498 |
void __user *datap = compat_ptr(data); |
126 |
|
|
int ret; |
127 |
|
|
__u32 val; |
128 |
|
|
+ /***** TOMOYO Linux start. *****/ |
129 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
130 |
kumaneko |
1498 |
+ return -EPERM; |
131 |
|
|
+ /***** TOMOYO Linux end. *****/ |
132 |
|
|
|
133 |
|
|
switch (request) { |
134 |
|
|
case PTRACE_TRACEME: |
135 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/Kconfig |
136 |
|
|
+++ linux-2.6.25.20-0.1/fs/Kconfig |
137 |
kumaneko |
1498 |
@@ -2187,4 +2187,6 @@ endif |
138 |
|
|
source "fs/nls/Kconfig" |
139 |
|
|
source "fs/dlm/Kconfig" |
140 |
|
|
|
141 |
|
|
+source "fs/Kconfig.ccs" |
142 |
|
|
+ |
143 |
|
|
endmenu |
144 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/Makefile |
145 |
|
|
+++ linux-2.6.25.20-0.1/fs/Makefile |
146 |
kumaneko |
1498 |
@@ -125,3 +125,5 @@ obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
147 |
|
|
obj-$(CONFIG_GFS2_FS) += gfs2/ |
148 |
|
|
obj-$(CONFIG_NOVFS) += novfs/ |
149 |
|
|
obj-$(CONFIG_SQUASHFS) += squashfs/ |
150 |
|
|
+ |
151 |
|
|
+include $(srctree)/fs/Makefile-2.6.ccs |
152 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/attr.c |
153 |
|
|
+++ linux-2.6.25.20-0.1/fs/attr.c |
154 |
kumaneko |
1498 |
@@ -14,6 +14,9 @@ |
155 |
|
|
#include <linux/fcntl.h> |
156 |
|
|
#include <linux/quotaops.h> |
157 |
|
|
#include <linux/security.h> |
158 |
|
|
+/***** TOMOYO Linux start. *****/ |
159 |
|
|
+#include <linux/tomoyo.h> |
160 |
|
|
+/***** TOMOYO Linux end. *****/ |
161 |
|
|
|
162 |
|
|
/* Taken over from the old code... */ |
163 |
|
|
|
164 |
|
|
@@ -160,6 +163,14 @@ int fnotify_change(struct dentry *dentry |
165 |
|
|
|
166 |
|
|
if (inode->i_op && inode->i_op->setattr) { |
167 |
|
|
error = security_inode_setattr(dentry, mnt, attr); |
168 |
|
|
+ /***** TOMOYO Linux start. *****/ |
169 |
|
|
+ if (!error && (ia_valid & ATTR_MODE) && |
170 |
kumaneko |
2282 |
+ !ccs_capable(CCS_SYS_CHMOD)) |
171 |
kumaneko |
1498 |
+ error = -EPERM; |
172 |
|
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && |
173 |
kumaneko |
2282 |
+ !ccs_capable(CCS_SYS_CHOWN)) |
174 |
kumaneko |
1498 |
+ error = -EPERM; |
175 |
|
|
+ /***** TOMOYO Linux end. *****/ |
176 |
|
|
if (!error) { |
177 |
|
|
if (file && file->f_op && file->f_op->fsetattr) |
178 |
|
|
error = file->f_op->fsetattr(file, attr); |
179 |
|
|
@@ -181,6 +192,14 @@ int fnotify_change(struct dentry *dentry |
180 |
|
|
error = inode_change_ok(inode, attr); |
181 |
|
|
if (!error) |
182 |
|
|
error = security_inode_setattr(dentry, mnt, attr); |
183 |
|
|
+ /***** TOMOYO Linux start. *****/ |
184 |
|
|
+ if (!error && (ia_valid & ATTR_MODE) && |
185 |
kumaneko |
2282 |
+ !ccs_capable(CCS_SYS_CHMOD)) |
186 |
kumaneko |
1498 |
+ error = -EPERM; |
187 |
|
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && |
188 |
kumaneko |
2282 |
+ !ccs_capable(CCS_SYS_CHOWN)) |
189 |
kumaneko |
1498 |
+ error = -EPERM; |
190 |
|
|
+ /***** TOMOYO Linux end. *****/ |
191 |
|
|
if (!error) { |
192 |
|
|
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
193 |
|
|
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
194 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/compat.c |
195 |
|
|
+++ linux-2.6.25.20-0.1/fs/compat.c |
196 |
kumaneko |
1498 |
@@ -55,6 +55,9 @@ |
197 |
|
|
#include <asm/mmu_context.h> |
198 |
|
|
#include <asm/ioctls.h> |
199 |
|
|
#include "internal.h" |
200 |
|
|
+/***** TOMOYO Linux start. *****/ |
201 |
|
|
+#include <linux/tomoyo.h> |
202 |
|
|
+/***** TOMOYO Linux end. *****/ |
203 |
|
|
|
204 |
|
|
int compat_log = 1; |
205 |
|
|
|
206 |
|
|
@@ -1399,7 +1402,7 @@ int compat_do_execve(char * filename, |
207 |
|
|
if (retval < 0) |
208 |
|
|
goto out; |
209 |
|
|
|
210 |
|
|
- retval = search_binary_handler(bprm, regs); |
211 |
kumaneko |
2300 |
+ retval = ccs_search_binary_handler(bprm, regs); |
212 |
kumaneko |
1498 |
if (retval >= 0) { |
213 |
|
|
/* execve success */ |
214 |
|
|
security_bprm_free(bprm); |
215 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/compat_ioctl.c |
216 |
|
|
+++ linux-2.6.25.20-0.1/fs/compat_ioctl.c |
217 |
kumaneko |
1498 |
@@ -120,6 +120,9 @@ |
218 |
|
|
#include <xen/public/privcmd.h> |
219 |
|
|
#include <xen/compat_ioctl.h> |
220 |
|
|
#endif |
221 |
|
|
+/***** TOMOYO Linux start. *****/ |
222 |
|
|
+#include <linux/tomoyo.h> |
223 |
|
|
+/***** TOMOYO Linux end. *****/ |
224 |
|
|
|
225 |
|
|
static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
226 |
|
|
unsigned long arg, struct file *f) |
227 |
kumaneko |
2279 |
@@ -2906,6 +2909,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
228 |
|
|
|
229 |
|
|
/* RED-PEN how should LSM module know it's handling 32bit? */ |
230 |
|
|
error = security_file_ioctl(filp, cmd, arg); |
231 |
|
|
+ /***** TOMOYO Linux start. *****/ |
232 |
|
|
+ if (!error) |
233 |
|
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
234 |
|
|
+ /***** TOMOYO Linux end. *****/ |
235 |
|
|
if (error) |
236 |
|
|
goto out_fput; |
237 |
|
|
|
238 |
|
|
@@ -2930,6 +2937,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
239 |
kumaneko |
1498 |
/*FALL THROUGH*/ |
240 |
|
|
|
241 |
|
|
default: |
242 |
|
|
+ /***** TOMOYO Linux start. *****/ |
243 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
244 |
kumaneko |
1498 |
+ error = -EPERM; |
245 |
|
|
+ goto out_fput; |
246 |
|
|
+ } |
247 |
|
|
+ /***** TOMOYO Linux end. *****/ |
248 |
|
|
if (filp->f_op && filp->f_op->compat_ioctl) { |
249 |
|
|
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
250 |
|
|
if (error != -ENOIOCTLCMD) |
251 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/exec.c |
252 |
|
|
+++ linux-2.6.25.20-0.1/fs/exec.c |
253 |
kumaneko |
1498 |
@@ -60,6 +60,10 @@ |
254 |
|
|
#include <linux/kmod.h> |
255 |
|
|
#endif |
256 |
|
|
|
257 |
|
|
+/***** TOMOYO Linux start. *****/ |
258 |
|
|
+#include <linux/tomoyo.h> |
259 |
|
|
+/***** TOMOYO Linux end. *****/ |
260 |
|
|
+ |
261 |
|
|
int core_uses_pid; |
262 |
|
|
char core_pattern[CORENAME_MAX_SIZE] = "core"; |
263 |
|
|
int suid_dumpable = 0; |
264 |
kumaneko |
2306 |
@@ -118,6 +122,11 @@ asmlinkage long sys_uselib(const char __ |
265 |
kumaneko |
1498 |
error = vfs_permission(&nd, MAY_READ | MAY_EXEC); |
266 |
|
|
if (error) |
267 |
|
|
goto exit; |
268 |
|
|
+ /***** TOMOYO Linux start. *****/ |
269 |
kumaneko |
2306 |
+ error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt); |
270 |
kumaneko |
1498 |
+ if (error) |
271 |
|
|
+ goto exit; |
272 |
|
|
+ /***** TOMOYO Linux end. *****/ |
273 |
|
|
|
274 |
|
|
file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
275 |
|
|
error = PTR_ERR(file); |
276 |
kumaneko |
2306 |
@@ -664,6 +673,13 @@ struct file *open_exec(const char *name) |
277 |
kumaneko |
1498 |
file = ERR_PTR(-EACCES); |
278 |
|
|
if (S_ISREG(inode->i_mode)) { |
279 |
|
|
int err = vfs_permission(&nd, MAY_EXEC); |
280 |
|
|
+ /***** TOMOYO Linux start. *****/ |
281 |
kumaneko |
2306 |
+ if (!err) |
282 |
|
|
+ err = ccs_check_open_exec_permission(nd.path. |
283 |
|
|
+ dentry, |
284 |
|
|
+ nd.path. |
285 |
|
|
+ mnt); |
286 |
kumaneko |
1498 |
+ /***** TOMOYO Linux end. *****/ |
287 |
|
|
file = ERR_PTR(err); |
288 |
|
|
if (!err) { |
289 |
|
|
file = nameidata_to_filp(&nd, |
290 |
kumaneko |
2306 |
@@ -1336,7 +1352,7 @@ int do_execve(char * filename, |
291 |
kumaneko |
1498 |
goto out; |
292 |
|
|
bprm->argv_len = env_p - bprm->p; |
293 |
|
|
|
294 |
|
|
- retval = search_binary_handler(bprm,regs); |
295 |
kumaneko |
2300 |
+ retval = ccs_search_binary_handler(bprm, regs); |
296 |
kumaneko |
1498 |
if (retval >= 0) { |
297 |
|
|
/* execve success */ |
298 |
|
|
free_arg_pages(bprm); |
299 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/fcntl.c |
300 |
|
|
+++ linux-2.6.25.20-0.1/fs/fcntl.c |
301 |
kumaneko |
1498 |
@@ -23,6 +23,9 @@ |
302 |
|
|
#include <asm/poll.h> |
303 |
|
|
#include <asm/siginfo.h> |
304 |
|
|
#include <asm/uaccess.h> |
305 |
|
|
+/***** TOMOYO Linux start. *****/ |
306 |
|
|
+#include <linux/tomoyo.h> |
307 |
|
|
+/***** TOMOYO Linux end. *****/ |
308 |
|
|
|
309 |
|
|
void set_close_on_exec(unsigned int fd, int flag) |
310 |
|
|
{ |
311 |
|
|
@@ -217,6 +220,12 @@ static int setfl(int fd, struct file * f |
312 |
|
|
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
313 |
|
|
return -EPERM; |
314 |
|
|
|
315 |
|
|
+ /***** TOMOYO Linux start. *****/ |
316 |
|
|
+ if (((arg ^ filp->f_flags) & O_APPEND) && |
317 |
|
|
+ ccs_check_rewrite_permission(filp)) |
318 |
|
|
+ return -EPERM; |
319 |
|
|
+ /***** TOMOYO Linux end. *****/ |
320 |
|
|
+ |
321 |
|
|
/* O_NOATIME can only be set by the owner or superuser */ |
322 |
|
|
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
323 |
|
|
if (!is_owner_or_cap(inode)) |
324 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/ioctl.c |
325 |
|
|
+++ linux-2.6.25.20-0.1/fs/ioctl.c |
326 |
kumaneko |
1498 |
@@ -15,6 +15,9 @@ |
327 |
|
|
#include <linux/uaccess.h> |
328 |
|
|
|
329 |
|
|
#include <asm/ioctls.h> |
330 |
|
|
+/***** TOMOYO Linux start. *****/ |
331 |
|
|
+#include <linux/tomoyo.h> |
332 |
|
|
+/***** TOMOYO Linux end. *****/ |
333 |
|
|
|
334 |
|
|
/** |
335 |
|
|
* vfs_ioctl - call filesystem specific ioctl methods |
336 |
|
|
@@ -35,6 +38,10 @@ long vfs_ioctl(struct file *filp, unsign |
337 |
|
|
|
338 |
|
|
if (!filp->f_op) |
339 |
|
|
goto out; |
340 |
|
|
+ /***** TOMOYO Linux start. *****/ |
341 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
342 |
kumaneko |
1498 |
+ return -EPERM; |
343 |
|
|
+ /***** TOMOYO Linux end. *****/ |
344 |
|
|
|
345 |
|
|
if (filp->f_op->unlocked_ioctl) { |
346 |
|
|
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
347 |
kumaneko |
2279 |
@@ -202,6 +209,10 @@ asmlinkage long sys_ioctl(unsigned int f |
348 |
|
|
goto out; |
349 |
|
|
|
350 |
|
|
error = security_file_ioctl(filp, cmd, arg); |
351 |
|
|
+ /***** TOMOYO Linux start. *****/ |
352 |
|
|
+ if (!error) |
353 |
|
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
354 |
|
|
+ /***** TOMOYO Linux end. *****/ |
355 |
|
|
if (error) |
356 |
|
|
goto out_fput; |
357 |
|
|
|
358 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/namei.c |
359 |
|
|
+++ linux-2.6.25.20-0.1/fs/namei.c |
360 |
kumaneko |
1498 |
@@ -35,6 +35,10 @@ |
361 |
|
|
|
362 |
|
|
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
363 |
|
|
|
364 |
|
|
+/***** TOMOYO Linux start. *****/ |
365 |
|
|
+#include <linux/tomoyo.h> |
366 |
|
|
+/***** TOMOYO Linux end. *****/ |
367 |
|
|
+ |
368 |
|
|
/* [Feb-1997 T. Schoebel-Theuer] |
369 |
|
|
* Fundamental changes in the pathname lookup mechanisms (namei) |
370 |
|
|
* were necessary because of omirr. The reason is that omirr needs |
371 |
kumaneko |
2297 |
@@ -1690,6 +1694,13 @@ int may_open(struct nameidata *nd, int a |
372 |
kumaneko |
1498 |
if (!is_owner_or_cap(inode)) |
373 |
|
|
return -EPERM; |
374 |
|
|
|
375 |
|
|
+ /***** TOMOYO Linux start. *****/ |
376 |
|
|
+ /* includes O_APPEND and O_TRUNC checks */ |
377 |
|
|
+ error = ccs_check_open_permission(dentry, nd->path.mnt, flag); |
378 |
|
|
+ if (error) |
379 |
|
|
+ return error; |
380 |
|
|
+ /***** TOMOYO Linux end. *****/ |
381 |
|
|
+ |
382 |
|
|
/* |
383 |
|
|
* Ensure there are no outstanding leases on the file. |
384 |
|
|
*/ |
385 |
kumaneko |
2297 |
@@ -1731,6 +1742,11 @@ static int open_namei_create(struct name |
386 |
|
|
|
387 |
|
|
if (!IS_POSIXACL(dir->d_inode)) |
388 |
|
|
mode &= ~current->fs->umask; |
389 |
|
|
+ /***** TOMOYO Linux start. *****/ |
390 |
|
|
+ error = ccs_check_mknod_permission(dir->d_inode, path->dentry, |
391 |
|
|
+ nd->path.mnt, mode, 0); |
392 |
|
|
+ if (!error) |
393 |
|
|
+ /***** TOMOYO Linux end. *****/ |
394 |
|
|
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
395 |
|
|
mutex_unlock(&dir->d_inode->i_mutex); |
396 |
|
|
dput(nd->path.dentry); |
397 |
|
|
@@ -1741,6 +1757,9 @@ static int open_namei_create(struct name |
398 |
kumaneko |
1498 |
return may_open(nd, 0, flag & ~O_TRUNC); |
399 |
|
|
} |
400 |
|
|
|
401 |
|
|
+/***** TOMOYO Linux start. *****/ |
402 |
|
|
+#include <linux/tomoyo_vfs.h> |
403 |
|
|
+/***** TOMOYO Linux end. *****/ |
404 |
|
|
/* |
405 |
|
|
* open_namei() |
406 |
|
|
* |
407 |
kumaneko |
2297 |
@@ -2019,6 +2038,12 @@ asmlinkage long sys_mknodat(int dfd, con |
408 |
|
|
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
409 |
|
|
mode &= ~current->fs->umask; |
410 |
|
|
if (!IS_ERR(dentry)) { |
411 |
|
|
+ /***** TOMOYO Linux start. *****/ |
412 |
|
|
+ error = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
413 |
|
|
+ dentry, nd.path.mnt, mode, |
414 |
|
|
+ new_decode_dev(dev)); |
415 |
|
|
+ if (!error) |
416 |
|
|
+ /***** TOMOYO Linux end. *****/ |
417 |
|
|
switch (mode & S_IFMT) { |
418 |
|
|
case 0: case S_IFREG: |
419 |
kumaneko |
1498 |
error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); |
420 |
kumaneko |
2297 |
@@ -2097,6 +2122,11 @@ asmlinkage long sys_mkdirat(int dfd, con |
421 |
kumaneko |
1498 |
|
422 |
|
|
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
423 |
|
|
mode &= ~current->fs->umask; |
424 |
|
|
+ /***** TOMOYO Linux start. *****/ |
425 |
kumaneko |
2297 |
+ error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry, |
426 |
|
|
+ nd.path.mnt, mode); |
427 |
kumaneko |
1498 |
+ if (!error) |
428 |
|
|
+ /***** TOMOYO Linux end. *****/ |
429 |
|
|
error = vfs_mkdir(nd.path.dentry->d_inode, dentry, nd.path.mnt, mode); |
430 |
|
|
dput(dentry); |
431 |
|
|
out_unlock: |
432 |
kumaneko |
2297 |
@@ -2205,6 +2235,11 @@ static long do_rmdir(int dfd, const char |
433 |
kumaneko |
1498 |
error = PTR_ERR(dentry); |
434 |
|
|
if (IS_ERR(dentry)) |
435 |
|
|
goto exit2; |
436 |
|
|
+ /***** TOMOYO Linux start. *****/ |
437 |
kumaneko |
2297 |
+ error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry, |
438 |
|
|
+ nd.path.mnt); |
439 |
kumaneko |
1498 |
+ if (!error) |
440 |
|
|
+ /***** TOMOYO Linux end. *****/ |
441 |
|
|
error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
442 |
|
|
dput(dentry); |
443 |
|
|
exit2: |
444 |
kumaneko |
2297 |
@@ -2286,6 +2321,11 @@ static long do_unlinkat(int dfd, const c |
445 |
kumaneko |
1498 |
inode = dentry->d_inode; |
446 |
|
|
if (inode) |
447 |
|
|
atomic_inc(&inode->i_count); |
448 |
|
|
+ /***** TOMOYO Linux start. *****/ |
449 |
kumaneko |
2297 |
+ error = ccs_check_unlink_permission(nd.path.dentry->d_inode, |
450 |
|
|
+ dentry, nd.path.mnt); |
451 |
|
|
+ if (!error) |
452 |
kumaneko |
1498 |
+ /***** TOMOYO Linux end. *****/ |
453 |
|
|
error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
454 |
|
|
exit2: |
455 |
|
|
dput(dentry); |
456 |
kumaneko |
2297 |
@@ -2368,6 +2408,11 @@ asmlinkage long sys_symlinkat(const char |
457 |
kumaneko |
1498 |
if (IS_ERR(dentry)) |
458 |
|
|
goto out_unlock; |
459 |
|
|
|
460 |
|
|
+ /***** TOMOYO Linux start. *****/ |
461 |
kumaneko |
2297 |
+ error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry, |
462 |
|
|
+ nd.path.mnt, from); |
463 |
kumaneko |
1498 |
+ if (!error) |
464 |
|
|
+ /***** TOMOYO Linux end. *****/ |
465 |
|
|
error = vfs_symlink(nd.path.dentry->d_inode, dentry, nd.path.mnt, from, |
466 |
|
|
S_IALLUGO); |
467 |
|
|
dput(dentry); |
468 |
kumaneko |
2297 |
@@ -2465,6 +2510,12 @@ asmlinkage long sys_linkat(int olddfd, c |
469 |
kumaneko |
1498 |
error = PTR_ERR(new_dentry); |
470 |
|
|
if (IS_ERR(new_dentry)) |
471 |
|
|
goto out_unlock; |
472 |
|
|
+ /***** TOMOYO Linux start. *****/ |
473 |
kumaneko |
2297 |
+ error = ccs_check_link_permission(old_nd.path.dentry, |
474 |
|
|
+ nd.path.dentry->d_inode, new_dentry, |
475 |
|
|
+ nd.path.mnt); |
476 |
kumaneko |
1498 |
+ if (!error) |
477 |
|
|
+ /***** TOMOYO Linux end. *****/ |
478 |
|
|
error = vfs_link(old_nd.path.dentry, old_nd.path.mnt, nd.path.dentry->d_inode, |
479 |
|
|
new_dentry, nd.path.mnt); |
480 |
|
|
dput(new_dentry); |
481 |
kumaneko |
2297 |
@@ -2698,6 +2749,12 @@ static int do_rename(int olddfd, const c |
482 |
kumaneko |
1498 |
error = -ENOTEMPTY; |
483 |
|
|
if (new_dentry == trap) |
484 |
|
|
goto exit5; |
485 |
|
|
+ /***** TOMOYO Linux start. *****/ |
486 |
kumaneko |
2297 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
487 |
|
|
+ new_dir->d_inode, new_dentry, |
488 |
|
|
+ newnd.path.mnt); |
489 |
|
|
+ if (!error) |
490 |
kumaneko |
1498 |
+ /***** TOMOYO Linux end. *****/ |
491 |
|
|
|
492 |
|
|
error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt, |
493 |
|
|
new_dir->d_inode, new_dentry, newnd.path.mnt); |
494 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/namespace.c |
495 |
|
|
+++ linux-2.6.25.20-0.1/fs/namespace.c |
496 |
kumaneko |
1498 |
@@ -30,6 +30,12 @@ |
497 |
|
|
#include <asm/unistd.h> |
498 |
|
|
#include "pnode.h" |
499 |
|
|
#include "internal.h" |
500 |
|
|
+/***** SAKURA Linux start. *****/ |
501 |
|
|
+#include <linux/sakura.h> |
502 |
|
|
+/***** SAKURA Linux end. *****/ |
503 |
|
|
+/***** TOMOYO Linux start. *****/ |
504 |
|
|
+#include <linux/tomoyo.h> |
505 |
|
|
+/***** TOMOYO Linux end. *****/ |
506 |
|
|
|
507 |
|
|
#define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head)) |
508 |
|
|
#define HASH_SIZE (1UL << HASH_SHIFT) |
509 |
|
|
@@ -591,6 +597,11 @@ static int do_umount(struct vfsmount *mn |
510 |
|
|
if (retval) |
511 |
|
|
return retval; |
512 |
|
|
|
513 |
|
|
+ /***** SAKURA Linux start. *****/ |
514 |
|
|
+ if (ccs_may_umount(mnt)) |
515 |
|
|
+ return -EPERM; |
516 |
|
|
+ /***** SAKURA Linux end. *****/ |
517 |
|
|
+ |
518 |
|
|
/* |
519 |
|
|
* Allow userspace to request a mountpoint be expired rather than |
520 |
|
|
* unmounting unconditionally. Unmount only happens if: |
521 |
|
|
@@ -682,6 +693,10 @@ asmlinkage long sys_umount(char __user * |
522 |
|
|
{ |
523 |
|
|
struct nameidata nd; |
524 |
|
|
int retval; |
525 |
|
|
+ /***** TOMOYO Linux start. *****/ |
526 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
527 |
kumaneko |
1498 |
+ return -EPERM; |
528 |
|
|
+ /***** TOMOYO Linux end. *****/ |
529 |
|
|
|
530 |
|
|
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
531 |
|
|
if (retval) |
532 |
|
|
@@ -991,6 +1006,11 @@ static noinline int do_loopback(struct n |
533 |
|
|
err = -EINVAL; |
534 |
|
|
if (IS_MNT_UNBINDABLE(old_nd.path.mnt)) |
535 |
|
|
goto out; |
536 |
|
|
+ /***** SAKURA Linux start. *****/ |
537 |
|
|
+ err = -EPERM; |
538 |
|
|
+ if (ccs_may_mount(nd)) |
539 |
|
|
+ goto out; |
540 |
|
|
+ /***** SAKURA Linux end. *****/ |
541 |
|
|
|
542 |
|
|
if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt)) |
543 |
|
|
goto out; |
544 |
|
|
@@ -1085,6 +1105,11 @@ static noinline int do_move_mount(struct |
545 |
|
|
if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt)) |
546 |
|
|
goto out; |
547 |
|
|
|
548 |
|
|
+ /***** SAKURA Linux start. *****/ |
549 |
|
|
+ err = -EPERM; |
550 |
|
|
+ if (ccs_may_umount(old_nd.path.mnt) || ccs_may_mount(nd)) |
551 |
|
|
+ goto out; |
552 |
|
|
+ /***** SAKURA Linux end. *****/ |
553 |
|
|
err = -ENOENT; |
554 |
|
|
mutex_lock(&nd->path.dentry->d_inode->i_mutex); |
555 |
|
|
if (IS_DEADDIR(nd->path.dentry->d_inode)) |
556 |
|
|
@@ -1189,6 +1214,11 @@ int do_add_mount(struct vfsmount *newmnt |
557 |
|
|
err = -EINVAL; |
558 |
|
|
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
559 |
|
|
goto unlock; |
560 |
|
|
+ /***** SAKURA Linux start. *****/ |
561 |
|
|
+ err = -EPERM; |
562 |
|
|
+ if (ccs_may_mount(nd)) |
563 |
|
|
+ goto unlock; |
564 |
|
|
+ /***** SAKURA Linux end. *****/ |
565 |
|
|
|
566 |
|
|
newmnt->mnt_flags = mnt_flags; |
567 |
|
|
if ((err = graft_tree(newmnt, nd))) |
568 |
|
|
@@ -1412,6 +1442,17 @@ long do_mount(char *dev_name, char *dir_ |
569 |
|
|
if (data_page) |
570 |
|
|
((char *)data_page)[PAGE_SIZE - 1] = 0; |
571 |
|
|
|
572 |
|
|
+ /***** TOMOYO Linux start. *****/ |
573 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
574 |
kumaneko |
1498 |
+ return -EPERM; |
575 |
|
|
+ /***** TOMOYO Linux end. *****/ |
576 |
|
|
+ /***** SAKURA Linux start. *****/ |
577 |
|
|
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
578 |
|
|
+ &flags); |
579 |
|
|
+ if (retval) |
580 |
|
|
+ return retval; |
581 |
|
|
+ /***** SAKURA Linux end. *****/ |
582 |
|
|
+ |
583 |
|
|
/* Separate the per-mountpoint flags */ |
584 |
|
|
if (flags & MS_NOSUID) |
585 |
|
|
mnt_flags |= MNT_NOSUID; |
586 |
|
|
@@ -1680,6 +1721,10 @@ asmlinkage long sys_pivot_root(const cha |
587 |
|
|
|
588 |
|
|
if (!capable(CAP_SYS_ADMIN)) |
589 |
|
|
return -EPERM; |
590 |
|
|
+ /***** TOMOYO Linux start. *****/ |
591 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
592 |
kumaneko |
1498 |
+ return -EPERM; |
593 |
|
|
+ /***** TOMOYO Linux end. *****/ |
594 |
|
|
|
595 |
|
|
lock_kernel(); |
596 |
|
|
|
597 |
|
|
@@ -1696,6 +1741,10 @@ asmlinkage long sys_pivot_root(const cha |
598 |
|
|
goto out1; |
599 |
|
|
|
600 |
|
|
error = security_sb_pivotroot(&old_nd, &new_nd); |
601 |
|
|
+ /***** SAKURA Linux start. *****/ |
602 |
|
|
+ if (!error) |
603 |
|
|
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
604 |
|
|
+ /***** SAKURA Linux end. *****/ |
605 |
|
|
if (error) { |
606 |
|
|
path_put(&old_nd.path); |
607 |
|
|
goto out1; |
608 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/open.c |
609 |
|
|
+++ linux-2.6.25.20-0.1/fs/open.c |
610 |
kumaneko |
1498 |
@@ -27,6 +27,12 @@ |
611 |
|
|
#include <linux/rcupdate.h> |
612 |
|
|
#include <linux/audit.h> |
613 |
|
|
#include <linux/falloc.h> |
614 |
|
|
+/***** SAKURA Linux start. *****/ |
615 |
|
|
+#include <linux/sakura.h> |
616 |
|
|
+/***** SAKURA Linux end. *****/ |
617 |
|
|
+/***** TOMOYO Linux start. *****/ |
618 |
|
|
+#include <linux/tomoyo.h> |
619 |
|
|
+/***** TOMOYO Linux end. *****/ |
620 |
|
|
|
621 |
|
|
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
622 |
|
|
{ |
623 |
|
|
@@ -267,6 +273,12 @@ static long do_sys_truncate(const char _ |
624 |
|
|
if (error) |
625 |
|
|
goto put_write_and_out; |
626 |
|
|
|
627 |
|
|
+ /***** TOMOYO Linux start. *****/ |
628 |
kumaneko |
2297 |
+ error = ccs_check_truncate_permission(nd.path.dentry, nd.path.mnt, |
629 |
|
|
+ length, 0); |
630 |
kumaneko |
1498 |
+ if (error) |
631 |
|
|
+ goto put_write_and_out; |
632 |
|
|
+ /***** TOMOYO Linux end. *****/ |
633 |
|
|
error = locks_verify_truncate(inode, NULL, length); |
634 |
|
|
if (!error) { |
635 |
|
|
DQUOT_INIT(inode); |
636 |
kumaneko |
2297 |
@@ -321,6 +333,12 @@ static long do_sys_ftruncate(unsigned in |
637 |
kumaneko |
1498 |
if (IS_APPEND(inode)) |
638 |
|
|
goto out_putf; |
639 |
|
|
|
640 |
|
|
+ /***** TOMOYO Linux start. *****/ |
641 |
kumaneko |
2297 |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
642 |
|
|
+ 0); |
643 |
kumaneko |
1498 |
+ if (error) |
644 |
|
|
+ goto out_putf; |
645 |
|
|
+ /***** TOMOYO Linux end. *****/ |
646 |
|
|
error = locks_verify_truncate(inode, file, length); |
647 |
|
|
if (!error) |
648 |
|
|
error = do_truncate(dentry, file->f_path.mnt, length, |
649 |
kumaneko |
2297 |
@@ -539,6 +557,14 @@ asmlinkage long sys_chroot(const char __ |
650 |
kumaneko |
1498 |
error = -EPERM; |
651 |
|
|
if (!capable(CAP_SYS_CHROOT)) |
652 |
|
|
goto dput_and_out; |
653 |
|
|
+ /***** TOMOYO Linux start. *****/ |
654 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
655 |
kumaneko |
1498 |
+ goto dput_and_out; |
656 |
|
|
+ /***** TOMOYO Linux end. *****/ |
657 |
|
|
+ /***** SAKURA Linux start. *****/ |
658 |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
659 |
|
|
+ goto dput_and_out; |
660 |
|
|
+ /***** SAKURA Linux end. *****/ |
661 |
|
|
|
662 |
|
|
set_fs_root(current->fs, &nd.path); |
663 |
|
|
set_fs_altroot(); |
664 |
kumaneko |
2297 |
@@ -1172,6 +1198,10 @@ EXPORT_SYMBOL(sys_close); |
665 |
kumaneko |
1498 |
*/ |
666 |
|
|
asmlinkage long sys_vhangup(void) |
667 |
|
|
{ |
668 |
|
|
+ /***** TOMOYO Linux start. *****/ |
669 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
670 |
kumaneko |
1498 |
+ return -EPERM; |
671 |
|
|
+ /***** TOMOYO Linux end. *****/ |
672 |
|
|
if (capable(CAP_SYS_TTY_CONFIG)) { |
673 |
|
|
/* XXX: this needs locking */ |
674 |
|
|
tty_vhangup(current->signal->tty); |
675 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/proc/Makefile |
676 |
|
|
+++ linux-2.6.25.20-0.1/fs/proc/Makefile |
677 |
kumaneko |
1498 |
@@ -16,3 +16,6 @@ proc-$(CONFIG_PROC_KCORE) += kcore.o |
678 |
|
|
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
679 |
|
|
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
680 |
|
|
proc-$(CONFIG_PRINTK) += kmsg.o |
681 |
|
|
+ |
682 |
|
|
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
683 |
|
|
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
684 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/fs/proc/proc_misc.c |
685 |
|
|
+++ linux-2.6.25.20-0.1/fs/proc/proc_misc.c |
686 |
kumaneko |
1498 |
@@ -1021,4 +1021,9 @@ void __init proc_misc_init(void) |
687 |
|
|
entry->proc_fops = &proc_sysrq_trigger_operations; |
688 |
|
|
} |
689 |
|
|
#endif |
690 |
|
|
+ /***** CCS start. *****/ |
691 |
|
|
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
692 |
kumaneko |
2306 |
+ printk(KERN_INFO "Hook version: 2.6.25.20-0.1 2009/03/24\n"); |
693 |
kumaneko |
1498 |
+#endif |
694 |
|
|
+ /***** CCS end. *****/ |
695 |
|
|
} |
696 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/include/linux/init_task.h |
697 |
|
|
+++ linux-2.6.25.20-0.1/include/linux/init_task.h |
698 |
kumaneko |
1498 |
@@ -196,6 +196,10 @@ extern struct group_info init_groups; |
699 |
|
|
INIT_IDS \ |
700 |
|
|
INIT_TRACE_IRQFLAGS \ |
701 |
|
|
INIT_LOCKDEP \ |
702 |
|
|
+ /***** TOMOYO Linux start. *****/ \ |
703 |
kumaneko |
2282 |
+ .ccs_domain_info = NULL, \ |
704 |
|
|
+ .ccs_flags = 0, \ |
705 |
kumaneko |
1498 |
+ /***** TOMOYO Linux end. *****/ \ |
706 |
|
|
} |
707 |
|
|
|
708 |
|
|
|
709 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/include/linux/sched.h |
710 |
|
|
+++ linux-2.6.25.20-0.1/include/linux/sched.h |
711 |
kumaneko |
2282 |
@@ -29,6 +29,10 @@ |
712 |
kumaneko |
1498 |
#define CLONE_NEWNET 0x40000000 /* New network namespace */ |
713 |
|
|
#define CLONE_IO 0x80000000 /* Clone io context */ |
714 |
|
|
|
715 |
|
|
+/***** TOMOYO Linux start. *****/ |
716 |
kumaneko |
2282 |
+struct ccs_domain_info; |
717 |
kumaneko |
1498 |
+/***** TOMOYO Linux end. *****/ |
718 |
|
|
+ |
719 |
|
|
/* |
720 |
|
|
* Scheduling policies |
721 |
|
|
*/ |
722 |
kumaneko |
2282 |
@@ -1274,6 +1278,10 @@ struct task_struct { |
723 |
kumaneko |
2073 |
#ifndef __GENKSYMS__ |
724 |
|
|
struct list_head *scm_work_list; |
725 |
kumaneko |
1498 |
#endif |
726 |
|
|
+ /***** TOMOYO Linux start. *****/ |
727 |
kumaneko |
2282 |
+ struct ccs_domain_info *ccs_domain_info; |
728 |
|
|
+ u32 ccs_flags; |
729 |
kumaneko |
1498 |
+ /***** TOMOYO Linux end. *****/ |
730 |
|
|
}; |
731 |
|
|
|
732 |
|
|
/* |
733 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/compat.c |
734 |
|
|
+++ linux-2.6.25.20-0.1/kernel/compat.c |
735 |
kumaneko |
1498 |
@@ -25,6 +25,9 @@ |
736 |
|
|
#include <linux/posix-timers.h> |
737 |
|
|
|
738 |
|
|
#include <asm/uaccess.h> |
739 |
|
|
+/***** TOMOYO Linux start. *****/ |
740 |
|
|
+#include <linux/tomoyo.h> |
741 |
|
|
+/***** TOMOYO Linux end. *****/ |
742 |
|
|
|
743 |
|
|
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
744 |
|
|
{ |
745 |
|
|
@@ -869,6 +872,10 @@ asmlinkage long compat_sys_stime(compat_ |
746 |
|
|
err = security_settime(&tv, NULL); |
747 |
|
|
if (err) |
748 |
|
|
return err; |
749 |
|
|
+ /***** TOMOYO Linux start. *****/ |
750 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
751 |
kumaneko |
1498 |
+ return -EPERM; |
752 |
|
|
+ /***** TOMOYO Linux end. *****/ |
753 |
|
|
|
754 |
|
|
do_settimeofday(&tv); |
755 |
|
|
return 0; |
756 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/kexec.c |
757 |
|
|
+++ linux-2.6.25.20-0.1/kernel/kexec.c |
758 |
kumaneko |
1498 |
@@ -31,6 +31,9 @@ |
759 |
|
|
#include <asm/system.h> |
760 |
|
|
#include <asm/semaphore.h> |
761 |
|
|
#include <asm/sections.h> |
762 |
|
|
+/***** TOMOYO Linux start. *****/ |
763 |
|
|
+#include <linux/tomoyo.h> |
764 |
|
|
+/***** TOMOYO Linux end. *****/ |
765 |
|
|
|
766 |
|
|
/* Per cpu memory for storing cpu states in case of system crash. */ |
767 |
|
|
note_buf_t* crash_notes; |
768 |
|
|
@@ -969,6 +972,10 @@ asmlinkage long sys_kexec_load(unsigned |
769 |
|
|
/* We only trust the superuser with rebooting the system. */ |
770 |
|
|
if (!capable(CAP_SYS_BOOT)) |
771 |
|
|
return -EPERM; |
772 |
|
|
+ /***** TOMOYO Linux start. *****/ |
773 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
774 |
kumaneko |
1498 |
+ return -EPERM; |
775 |
|
|
+ /***** TOMOYO Linux end. *****/ |
776 |
|
|
|
777 |
|
|
/* |
778 |
|
|
* Verify we have a legal set of flags |
779 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/kmod.c |
780 |
|
|
+++ linux-2.6.25.20-0.1/kernel/kmod.c |
781 |
kumaneko |
1498 |
@@ -173,6 +173,11 @@ static int ____call_usermodehelper(void |
782 |
|
|
*/ |
783 |
|
|
set_user_nice(current, 0); |
784 |
|
|
|
785 |
|
|
+ /***** TOMOYO Linux start. *****/ |
786 |
kumaneko |
2282 |
+ current->ccs_domain_info = NULL; |
787 |
|
|
+ current->ccs_flags = 0; |
788 |
kumaneko |
1498 |
+ /***** TOMOYO Linux end. *****/ |
789 |
|
|
+ |
790 |
|
|
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
791 |
|
|
|
792 |
|
|
/* Exec failed? */ |
793 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/module.c |
794 |
|
|
+++ linux-2.6.25.20-0.1/kernel/module.c |
795 |
kumaneko |
1498 |
@@ -47,6 +47,9 @@ |
796 |
|
|
#include <asm/cacheflush.h> |
797 |
|
|
#include <linux/license.h> |
798 |
|
|
#include <asm/sections.h> |
799 |
|
|
+/***** TOMOYO Linux start. *****/ |
800 |
|
|
+#include <linux/tomoyo.h> |
801 |
|
|
+/***** TOMOYO Linux end. *****/ |
802 |
|
|
|
803 |
|
|
#if 0 |
804 |
|
|
#define DEBUGP printk |
805 |
|
|
@@ -700,6 +703,10 @@ sys_delete_module(const char __user *nam |
806 |
|
|
|
807 |
|
|
if (!capable(CAP_SYS_MODULE)) |
808 |
|
|
return -EPERM; |
809 |
|
|
+ /***** TOMOYO Linux start. *****/ |
810 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
811 |
kumaneko |
1498 |
+ return -EPERM; |
812 |
|
|
+ /***** TOMOYO Linux end. *****/ |
813 |
|
|
|
814 |
|
|
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
815 |
|
|
return -EFAULT; |
816 |
|
|
@@ -2181,6 +2188,10 @@ sys_init_module(void __user *umod, |
817 |
|
|
/* Must have permission */ |
818 |
|
|
if (!capable(CAP_SYS_MODULE)) |
819 |
|
|
return -EPERM; |
820 |
|
|
+ /***** TOMOYO Linux start. *****/ |
821 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
822 |
kumaneko |
1498 |
+ return -EPERM; |
823 |
|
|
+ /***** TOMOYO Linux end. *****/ |
824 |
|
|
|
825 |
|
|
/* Only one module load at a time, please */ |
826 |
|
|
if (mutex_lock_interruptible(&module_mutex) != 0) |
827 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/ptrace.c |
828 |
|
|
+++ linux-2.6.25.20-0.1/kernel/ptrace.c |
829 |
kumaneko |
1498 |
@@ -24,6 +24,9 @@ |
830 |
|
|
|
831 |
|
|
#include <asm/pgtable.h> |
832 |
|
|
#include <asm/uaccess.h> |
833 |
|
|
+/***** TOMOYO Linux start. *****/ |
834 |
|
|
+#include <linux/tomoyo.h> |
835 |
|
|
+/***** TOMOYO Linux end. *****/ |
836 |
|
|
|
837 |
|
|
/* |
838 |
|
|
* ptrace a task: make the debugger its new parent and |
839 |
kumaneko |
2278 |
@@ -548,6 +551,10 @@ asmlinkage long sys_ptrace(long request, |
840 |
kumaneko |
1498 |
/* |
841 |
|
|
* This lock_kernel fixes a subtle race with suid exec |
842 |
|
|
*/ |
843 |
|
|
+ /***** TOMOYO Linux start. *****/ |
844 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
845 |
kumaneko |
1498 |
+ return -EPERM; |
846 |
|
|
+ /***** TOMOYO Linux end. *****/ |
847 |
|
|
lock_kernel(); |
848 |
|
|
if (request == PTRACE_TRACEME) { |
849 |
|
|
ret = ptrace_traceme(); |
850 |
kumaneko |
2278 |
@@ -655,6 +662,10 @@ asmlinkage long compat_sys_ptrace(compat |
851 |
kumaneko |
1498 |
/* |
852 |
|
|
* This lock_kernel fixes a subtle race with suid exec |
853 |
|
|
*/ |
854 |
|
|
+ /***** TOMOYO Linux start. *****/ |
855 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
856 |
kumaneko |
1498 |
+ return -EPERM; |
857 |
|
|
+ /***** TOMOYO Linux end. *****/ |
858 |
|
|
lock_kernel(); |
859 |
|
|
if (request == PTRACE_TRACEME) { |
860 |
|
|
ret = ptrace_traceme(); |
861 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/sched.c |
862 |
|
|
+++ linux-2.6.25.20-0.1/kernel/sched.c |
863 |
kumaneko |
1498 |
@@ -69,6 +69,9 @@ |
864 |
|
|
|
865 |
|
|
#include <asm/tlb.h> |
866 |
|
|
#include <asm/irq_regs.h> |
867 |
|
|
+/***** TOMOYO Linux start. *****/ |
868 |
|
|
+#include <linux/tomoyo.h> |
869 |
|
|
+/***** TOMOYO Linux end. *****/ |
870 |
|
|
|
871 |
|
|
/* |
872 |
|
|
* Scheduler clock - returns current time in nanosec units. |
873 |
|
|
@@ -4510,6 +4513,10 @@ int can_nice(const struct task_struct *p |
874 |
|
|
asmlinkage long sys_nice(int increment) |
875 |
|
|
{ |
876 |
|
|
long nice, retval; |
877 |
|
|
+ /***** TOMOYO Linux start. *****/ |
878 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
879 |
kumaneko |
1498 |
+ return -EPERM; |
880 |
|
|
+ /***** TOMOYO Linux end. *****/ |
881 |
|
|
|
882 |
|
|
/* |
883 |
|
|
* Setpriority might change our priority at the same moment. |
884 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/signal.c |
885 |
|
|
+++ linux-2.6.25.20-0.1/kernel/signal.c |
886 |
kumaneko |
1498 |
@@ -32,6 +32,9 @@ |
887 |
|
|
#include <asm/unistd.h> |
888 |
|
|
#include <asm/siginfo.h> |
889 |
|
|
#include "audit.h" /* audit_signal_info() */ |
890 |
|
|
+/***** TOMOYO Linux start. *****/ |
891 |
|
|
+#include <linux/tomoyo.h> |
892 |
|
|
+/***** TOMOYO Linux end. *****/ |
893 |
|
|
|
894 |
|
|
/* |
895 |
|
|
* SLAB caches for signal bits. |
896 |
kumaneko |
1758 |
@@ -2232,6 +2235,12 @@ asmlinkage long |
897 |
kumaneko |
1498 |
sys_kill(int pid, int sig) |
898 |
|
|
{ |
899 |
|
|
struct siginfo info; |
900 |
|
|
+ /***** TOMOYO Linux start. *****/ |
901 |
kumaneko |
2282 |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
902 |
kumaneko |
1498 |
+ return -EPERM; |
903 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
904 |
|
|
+ return -EPERM; |
905 |
|
|
+ /***** TOMOYO Linux end. *****/ |
906 |
|
|
|
907 |
|
|
info.si_signo = sig; |
908 |
|
|
info.si_errno = 0; |
909 |
kumaneko |
1758 |
@@ -2290,6 +2299,12 @@ asmlinkage long sys_tgkill(int tgid, int |
910 |
kumaneko |
1498 |
/* This is only valid for single tasks */ |
911 |
|
|
if (pid <= 0 || tgid <= 0) |
912 |
|
|
return -EINVAL; |
913 |
|
|
+ /***** TOMOYO Linux start. *****/ |
914 |
kumaneko |
2282 |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
915 |
kumaneko |
1498 |
+ return -EPERM; |
916 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
917 |
|
|
+ return -EPERM; |
918 |
|
|
+ /***** TOMOYO Linux end. *****/ |
919 |
|
|
|
920 |
|
|
return do_tkill(tgid, pid, sig); |
921 |
|
|
} |
922 |
kumaneko |
1758 |
@@ -2303,6 +2318,12 @@ sys_tkill(int pid, int sig) |
923 |
kumaneko |
1498 |
/* This is only valid for single tasks */ |
924 |
|
|
if (pid <= 0) |
925 |
|
|
return -EINVAL; |
926 |
|
|
+ /***** TOMOYO Linux start. *****/ |
927 |
kumaneko |
2282 |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
928 |
kumaneko |
1498 |
+ return -EPERM; |
929 |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
930 |
|
|
+ return -EPERM; |
931 |
|
|
+ /***** TOMOYO Linux end. *****/ |
932 |
|
|
|
933 |
|
|
return do_tkill(0, pid, sig); |
934 |
|
|
} |
935 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/sys.c |
936 |
|
|
+++ linux-2.6.25.20-0.1/kernel/sys.c |
937 |
kumaneko |
1498 |
@@ -42,6 +42,9 @@ |
938 |
|
|
#include <asm/uaccess.h> |
939 |
|
|
#include <asm/io.h> |
940 |
|
|
#include <asm/unistd.h> |
941 |
|
|
+/***** TOMOYO Linux start. *****/ |
942 |
|
|
+#include <linux/tomoyo.h> |
943 |
|
|
+/***** TOMOYO Linux end. *****/ |
944 |
|
|
|
945 |
|
|
#ifndef SET_UNALIGN_CTL |
946 |
|
|
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
947 |
|
|
@@ -140,6 +143,12 @@ asmlinkage long sys_setpriority(int whic |
948 |
|
|
|
949 |
|
|
if (which > PRIO_USER || which < PRIO_PROCESS) |
950 |
|
|
goto out; |
951 |
|
|
+ /***** TOMOYO Linux start. *****/ |
952 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
953 |
kumaneko |
1498 |
+ error = -EPERM; |
954 |
|
|
+ goto out; |
955 |
|
|
+ } |
956 |
|
|
+ /***** TOMOYO Linux end. *****/ |
957 |
|
|
|
958 |
|
|
/* normalize: avoid signed division (rounding problems) */ |
959 |
|
|
error = -ESRCH; |
960 |
|
|
@@ -376,6 +385,10 @@ asmlinkage long sys_reboot(int magic1, i |
961 |
|
|
magic2 != LINUX_REBOOT_MAGIC2B && |
962 |
|
|
magic2 != LINUX_REBOOT_MAGIC2C)) |
963 |
|
|
return -EINVAL; |
964 |
|
|
+ /***** TOMOYO Linux start. *****/ |
965 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
966 |
kumaneko |
1498 |
+ return -EPERM; |
967 |
|
|
+ /***** TOMOYO Linux end. *****/ |
968 |
|
|
|
969 |
|
|
/* Instead of trying to make the power_off code look like |
970 |
|
|
* halt when pm_power_off is not set do it the easy way. |
971 |
|
|
@@ -1347,6 +1360,10 @@ asmlinkage long sys_sethostname(char __u |
972 |
|
|
return -EPERM; |
973 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
974 |
|
|
return -EINVAL; |
975 |
|
|
+ /***** TOMOYO Linux start. *****/ |
976 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
977 |
kumaneko |
1498 |
+ return -EPERM; |
978 |
|
|
+ /***** TOMOYO Linux end. *****/ |
979 |
|
|
down_write(&uts_sem); |
980 |
|
|
errno = -EFAULT; |
981 |
|
|
if (!copy_from_user(tmp, name, len)) { |
982 |
|
|
@@ -1392,6 +1409,10 @@ asmlinkage long sys_setdomainname(char _ |
983 |
|
|
return -EPERM; |
984 |
|
|
if (len < 0 || len > __NEW_UTS_LEN) |
985 |
|
|
return -EINVAL; |
986 |
|
|
+ /***** TOMOYO Linux start. *****/ |
987 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
988 |
kumaneko |
1498 |
+ return -EPERM; |
989 |
|
|
+ /***** TOMOYO Linux end. *****/ |
990 |
|
|
|
991 |
|
|
down_write(&uts_sem); |
992 |
|
|
errno = -EFAULT; |
993 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/sysctl.c |
994 |
|
|
+++ linux-2.6.25.20-0.1/kernel/sysctl.c |
995 |
kumaneko |
1498 |
@@ -48,6 +48,9 @@ |
996 |
|
|
|
997 |
|
|
#include <asm/uaccess.h> |
998 |
|
|
#include <asm/processor.h> |
999 |
|
|
+/***** TOMOYO Linux start. *****/ |
1000 |
|
|
+#include <linux/tomoyo.h> |
1001 |
|
|
+/***** TOMOYO Linux end. *****/ |
1002 |
|
|
|
1003 |
|
|
#ifdef CONFIG_X86 |
1004 |
|
|
#include <asm/nmi.h> |
1005 |
kumaneko |
2298 |
@@ -1500,6 +1503,7 @@ char *sysctl_pathname(struct ctl_table * |
1006 |
kumaneko |
1498 |
EXPORT_SYMBOL_GPL(sysctl_pathname); |
1007 |
|
|
|
1008 |
|
|
#ifdef CONFIG_SYSCTL_SYSCALL |
1009 |
|
|
+ |
1010 |
|
|
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
1011 |
|
|
void __user *newval, size_t newlen) |
1012 |
|
|
{ |
1013 |
kumaneko |
2298 |
@@ -1516,6 +1520,11 @@ int do_sysctl(int __user *name, int nlen |
1014 |
kumaneko |
1498 |
|
1015 |
|
|
for (head = sysctl_head_next(NULL); head; |
1016 |
|
|
head = sysctl_head_next(head)) { |
1017 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1018 |
kumaneko |
2298 |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
1019 |
kumaneko |
1498 |
+ head->ctl_table); |
1020 |
|
|
+ if (!error) |
1021 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1022 |
|
|
error = parse_table(name, nlen, oldval, oldlenp, |
1023 |
|
|
newval, newlen, head->ctl_table); |
1024 |
|
|
if (error != -ENOTDIR) { |
1025 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/time.c |
1026 |
|
|
+++ linux-2.6.25.20-0.1/kernel/time.c |
1027 |
kumaneko |
1498 |
@@ -38,6 +38,9 @@ |
1028 |
|
|
|
1029 |
|
|
#include <asm/uaccess.h> |
1030 |
|
|
#include <asm/unistd.h> |
1031 |
|
|
+/***** TOMOYO Linux start. *****/ |
1032 |
|
|
+#include <linux/tomoyo.h> |
1033 |
|
|
+/***** TOMOYO Linux end. *****/ |
1034 |
|
|
|
1035 |
|
|
#include "timeconst.h" |
1036 |
|
|
|
1037 |
|
|
@@ -88,6 +91,10 @@ asmlinkage long sys_stime(time_t __user |
1038 |
|
|
err = security_settime(&tv, NULL); |
1039 |
|
|
if (err) |
1040 |
|
|
return err; |
1041 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1042 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1043 |
kumaneko |
1498 |
+ return -EPERM; |
1044 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1045 |
|
|
|
1046 |
|
|
do_settimeofday(&tv); |
1047 |
|
|
return 0; |
1048 |
|
|
@@ -159,6 +166,10 @@ int do_sys_settimeofday(struct timespec |
1049 |
|
|
error = security_settime(tv, tz); |
1050 |
|
|
if (error) |
1051 |
|
|
return error; |
1052 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1053 |
kumaneko |
2282 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1054 |
kumaneko |
1498 |
+ return -EPERM; |
1055 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1056 |
|
|
|
1057 |
|
|
if (tz) { |
1058 |
|
|
/* SMP safe, global irq locking makes it work. */ |
1059 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/kernel/time/ntp.c |
1060 |
|
|
+++ linux-2.6.25.20-0.1/kernel/time/ntp.c |
1061 |
kumaneko |
1498 |
@@ -17,6 +17,9 @@ |
1062 |
|
|
#include <linux/capability.h> |
1063 |
|
|
#include <asm/div64.h> |
1064 |
|
|
#include <asm/timex.h> |
1065 |
|
|
+/***** TOMOYO Linux start. *****/ |
1066 |
|
|
+#include <linux/tomoyo.h> |
1067 |
|
|
+/***** TOMOYO Linux end. *****/ |
1068 |
|
|
|
1069 |
|
|
/* |
1070 |
|
|
* Timekeeping variables |
1071 |
|
|
@@ -243,6 +246,10 @@ int do_adjtimex(struct timex *txc) |
1072 |
|
|
/* In order to modify anything, you gotta be super-user! */ |
1073 |
|
|
if (txc->modes && !capable(CAP_SYS_TIME)) |
1074 |
|
|
return -EPERM; |
1075 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1076 |
kumaneko |
2282 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
1077 |
kumaneko |
1498 |
+ return -EPERM; |
1078 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1079 |
|
|
|
1080 |
|
|
/* Now we validate the data before disabling interrupts */ |
1081 |
|
|
|
1082 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/net/core/datagram.c |
1083 |
|
|
+++ linux-2.6.25.20-0.1/net/core/datagram.c |
1084 |
kumaneko |
1498 |
@@ -56,6 +56,11 @@ |
1085 |
|
|
#include <net/sock.h> |
1086 |
|
|
#include <net/tcp_states.h> |
1087 |
|
|
|
1088 |
|
|
+/***** TOMOYO Linux start. *****/ |
1089 |
|
|
+#include <linux/tomoyo.h> |
1090 |
|
|
+#include <linux/tomoyo_socket.h> |
1091 |
|
|
+/***** TOMOYO Linux end. *****/ |
1092 |
|
|
+ |
1093 |
|
|
/* |
1094 |
|
|
* Is a socket 'connection oriented' ? |
1095 |
|
|
*/ |
1096 |
|
|
@@ -179,6 +184,12 @@ struct sk_buff *__skb_recv_datagram(stru |
1097 |
|
|
} |
1098 |
|
|
spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); |
1099 |
|
|
|
1100 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1101 |
|
|
+ error = ccs_socket_recv_datagram_permission(sk, skb, flags); |
1102 |
|
|
+ if (error) |
1103 |
|
|
+ goto no_packet; |
1104 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1105 |
|
|
+ |
1106 |
|
|
if (skb) |
1107 |
|
|
return skb; |
1108 |
|
|
|
1109 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/net/ipv4/inet_connection_sock.c |
1110 |
|
|
+++ linux-2.6.25.20-0.1/net/ipv4/inet_connection_sock.c |
1111 |
kumaneko |
1498 |
@@ -23,6 +23,9 @@ |
1112 |
|
|
#include <net/route.h> |
1113 |
|
|
#include <net/tcp_states.h> |
1114 |
|
|
#include <net/xfrm.h> |
1115 |
|
|
+/***** SAKURA Linux start. *****/ |
1116 |
|
|
+#include <linux/sakura.h> |
1117 |
|
|
+/***** SAKURA Linux end. *****/ |
1118 |
|
|
|
1119 |
|
|
#ifdef INET_CSK_DEBUG |
1120 |
|
|
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
1121 |
|
|
@@ -98,6 +101,10 @@ int inet_csk_get_port(struct sock *sk, u |
1122 |
|
|
do { |
1123 |
|
|
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
1124 |
|
|
spin_lock(&head->lock); |
1125 |
|
|
+ /***** SAKURA Linux start. *****/ |
1126 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(rover)) |
1127 |
kumaneko |
1498 |
+ goto next; |
1128 |
|
|
+ /***** SAKURA Linux end. *****/ |
1129 |
|
|
inet_bind_bucket_for_each(tb, node, &head->chain) |
1130 |
|
|
if (tb->ib_net == net && tb->port == rover) |
1131 |
|
|
goto next; |
1132 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/net/ipv4/inet_hashtables.c |
1133 |
|
|
+++ linux-2.6.25.20-0.1/net/ipv4/inet_hashtables.c |
1134 |
kumaneko |
1498 |
@@ -22,6 +22,9 @@ |
1135 |
|
|
#include <net/inet_connection_sock.h> |
1136 |
|
|
#include <net/inet_hashtables.h> |
1137 |
|
|
#include <net/ip.h> |
1138 |
|
|
+/***** SAKURA Linux start. *****/ |
1139 |
|
|
+#include <linux/sakura.h> |
1140 |
|
|
+/***** SAKURA Linux end. *****/ |
1141 |
|
|
|
1142 |
|
|
/* |
1143 |
|
|
* Allocate and initialize a new local port bind bucket. |
1144 |
|
|
@@ -421,6 +424,10 @@ int __inet_hash_connect(struct inet_time |
1145 |
|
|
local_bh_disable(); |
1146 |
|
|
for (i = 1; i <= remaining; i++) { |
1147 |
|
|
port = low + (i + offset) % remaining; |
1148 |
|
|
+ /***** SAKURA Linux start. *****/ |
1149 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(port)) |
1150 |
kumaneko |
1498 |
+ continue; |
1151 |
|
|
+ /***** SAKURA Linux end. *****/ |
1152 |
|
|
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1153 |
|
|
spin_lock(&head->lock); |
1154 |
|
|
|
1155 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/net/ipv4/udp.c |
1156 |
|
|
+++ linux-2.6.25.20-0.1/net/ipv4/udp.c |
1157 |
kumaneko |
1498 |
@@ -105,6 +105,9 @@ |
1158 |
|
|
#include <net/checksum.h> |
1159 |
|
|
#include <net/xfrm.h> |
1160 |
|
|
#include "udp_impl.h" |
1161 |
|
|
+/***** SAKURA Linux start. *****/ |
1162 |
|
|
+#include <linux/sakura.h> |
1163 |
|
|
+/***** SAKURA Linux end. *****/ |
1164 |
|
|
|
1165 |
|
|
/* |
1166 |
|
|
* Snmp MIB for the UDP layer |
1167 |
|
|
@@ -176,6 +179,10 @@ int __udp_lib_get_port(struct sock *sk, |
1168 |
|
|
/* 1st pass: look for empty (or shortest) hash chain */ |
1169 |
|
|
for (i = 0; i < UDP_HTABLE_SIZE; i++) { |
1170 |
|
|
int size = 0; |
1171 |
|
|
+ /***** SAKURA Linux start. *****/ |
1172 |
kumaneko |
2299 |
+ if (ccs_lport_reserved(rover)) |
1173 |
kumaneko |
1498 |
+ goto next; |
1174 |
|
|
+ /***** SAKURA Linux end. *****/ |
1175 |
|
|
|
1176 |
|
|
head = &udptable[rover & (UDP_HTABLE_SIZE - 1)]; |
1177 |
|
|
if (hlist_empty(head)) |
1178 |
|
|
@@ -199,6 +206,9 @@ int __udp_lib_get_port(struct sock *sk, |
1179 |
|
|
/* 2nd pass: find hole in shortest hash chain */ |
1180 |
|
|
rover = best; |
1181 |
|
|
for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) { |
1182 |
|
|
+ /***** SAKURA Linux start. *****/ |
1183 |
kumaneko |
2299 |
+ if (!ccs_lport_reserved(rover)) |
1184 |
kumaneko |
1498 |
+ /***** SAKURA Linux end. *****/ |
1185 |
|
|
if (! __udp_lib_lport_inuse(net, rover, udptable)) |
1186 |
|
|
goto gotit; |
1187 |
|
|
rover += UDP_HTABLE_SIZE; |
1188 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/net/socket.c |
1189 |
|
|
+++ linux-2.6.25.20-0.1/net/socket.c |
1190 |
kumaneko |
1498 |
@@ -94,6 +94,11 @@ |
1191 |
|
|
#include <net/sock.h> |
1192 |
|
|
#include <linux/netfilter.h> |
1193 |
|
|
|
1194 |
|
|
+/***** TOMOYO Linux start. *****/ |
1195 |
|
|
+#include <linux/tomoyo.h> |
1196 |
|
|
+#include <linux/tomoyo_socket.h> |
1197 |
|
|
+/***** TOMOYO Linux end. *****/ |
1198 |
|
|
+ |
1199 |
|
|
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1200 |
|
|
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, |
1201 |
|
|
unsigned long nr_segs, loff_t pos); |
1202 |
|
|
@@ -557,6 +562,12 @@ static inline int __sock_sendmsg(struct |
1203 |
|
|
err = security_socket_sendmsg(sock, msg, size); |
1204 |
|
|
if (err) |
1205 |
|
|
return err; |
1206 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1207 |
|
|
+ if (ccs_socket_sendmsg_permission(sock, |
1208 |
|
|
+ (struct sockaddr *) msg->msg_name, |
1209 |
|
|
+ msg->msg_namelen)) |
1210 |
|
|
+ return -EPERM; |
1211 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1212 |
|
|
|
1213 |
|
|
return sock->ops->sendmsg(iocb, sock, msg, size); |
1214 |
|
|
} |
1215 |
|
|
@@ -1120,6 +1131,12 @@ static int __sock_create(struct net *net |
1216 |
|
|
family = PF_PACKET; |
1217 |
|
|
} |
1218 |
|
|
|
1219 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1220 |
|
|
+ err = ccs_socket_create_permission(family, type, protocol); |
1221 |
|
|
+ if (err) |
1222 |
|
|
+ return err; |
1223 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1224 |
|
|
+ |
1225 |
|
|
err = security_socket_create(family, type, protocol, kern); |
1226 |
|
|
if (err) |
1227 |
|
|
return err; |
1228 |
|
|
@@ -1351,6 +1368,13 @@ asmlinkage long sys_bind(int fd, struct |
1229 |
|
|
err = security_socket_bind(sock, |
1230 |
|
|
(struct sockaddr *)address, |
1231 |
|
|
addrlen); |
1232 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1233 |
|
|
+ if (!err) |
1234 |
|
|
+ err = ccs_socket_bind_permission(sock, |
1235 |
|
|
+ (struct sockaddr *) |
1236 |
|
|
+ address, |
1237 |
|
|
+ addrlen); |
1238 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1239 |
|
|
if (!err) |
1240 |
|
|
err = sock->ops->bind(sock, |
1241 |
|
|
(struct sockaddr *) |
1242 |
|
|
@@ -1380,6 +1404,10 @@ asmlinkage long sys_listen(int fd, int b |
1243 |
|
|
backlog = somaxconn; |
1244 |
|
|
|
1245 |
|
|
err = security_socket_listen(sock, backlog); |
1246 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1247 |
|
|
+ if (!err) |
1248 |
|
|
+ err = ccs_socket_listen_permission(sock); |
1249 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1250 |
|
|
if (!err) |
1251 |
|
|
err = sock->ops->listen(sock, backlog); |
1252 |
|
|
|
1253 |
|
|
@@ -1444,6 +1472,13 @@ asmlinkage long sys_accept(int fd, struc |
1254 |
|
|
if (err < 0) |
1255 |
|
|
goto out_fd; |
1256 |
|
|
|
1257 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1258 |
|
|
+ if (ccs_socket_accept_permission(newsock, |
1259 |
|
|
+ (struct sockaddr *) address)) { |
1260 |
|
|
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1261 |
|
|
+ goto out_fd; |
1262 |
|
|
+ } |
1263 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1264 |
|
|
if (upeer_sockaddr) { |
1265 |
|
|
if (newsock->ops->getname(newsock, (struct sockaddr *)address, |
1266 |
|
|
&len, 2) < 0) { |
1267 |
|
|
@@ -1508,6 +1543,12 @@ asmlinkage long sys_connect(int fd, stru |
1268 |
|
|
security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1269 |
|
|
if (err) |
1270 |
|
|
goto out_put; |
1271 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1272 |
|
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, |
1273 |
|
|
+ addrlen); |
1274 |
|
|
+ if (err) |
1275 |
|
|
+ goto out_put; |
1276 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1277 |
|
|
|
1278 |
|
|
err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen, |
1279 |
|
|
sock->file->f_flags); |
1280 |
kumaneko |
2073 |
--- linux-2.6.25.20-0.1.orig/net/unix/af_unix.c |
1281 |
|
|
+++ linux-2.6.25.20-0.1/net/unix/af_unix.c |
1282 |
kumaneko |
1498 |
@@ -116,6 +116,9 @@ |
1283 |
|
|
#include <linux/mount.h> |
1284 |
|
|
#include <net/checksum.h> |
1285 |
|
|
#include <linux/security.h> |
1286 |
|
|
+/***** TOMOYO Linux start. *****/ |
1287 |
|
|
+#include <linux/tomoyo.h> |
1288 |
|
|
+/***** TOMOYO Linux end. *****/ |
1289 |
|
|
|
1290 |
|
|
static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; |
1291 |
|
|
static DEFINE_SPINLOCK(unix_table_lock); |
1292 |
kumaneko |
2297 |
@@ -819,6 +822,11 @@ static int unix_bind(struct socket *sock |
1293 |
kumaneko |
1498 |
*/ |
1294 |
|
|
mode = S_IFSOCK | |
1295 |
|
|
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1296 |
|
|
+ /***** TOMOYO Linux start. *****/ |
1297 |
kumaneko |
2297 |
+ err = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
1298 |
|
|
+ dentry, nd.path.mnt, mode, 0); |
1299 |
kumaneko |
1498 |
+ if (!err) |
1300 |
|
|
+ /***** TOMOYO Linux end. *****/ |
1301 |
|
|
err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt, |
1302 |
|
|
mode, 0); |
1303 |
|
|
if (err) |