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