オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.25-suse-11.0.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2297 - (show annotations) (download) (as text)
Mon Mar 23 00:46:34 2009 UTC (15 years, 2 months ago) by kumaneko
Original Path: trunk/1.6.x/ccs-patch/patches/ccs-patch-2.6.25-suse-11.0.diff
File MIME type: text/x-diff
File size: 42344 byte(s)


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

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26