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

Subversion リポジトリの参照

Annotation 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 2298 - (hide annotations) (download) (as text)
Mon Mar 23 01:27:04 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: 40423 byte(s)
Move sysctl()'s permission check to fs/tomoyo_file.c .
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     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 | 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     36 files changed, 464 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     + retval = search_binary_handler_with_transition(bprm, regs);
212     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     @@ -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 kumaneko 2282 + if (!err && (current->ccs_flags &
283     + CCS_CHECK_READ_FOR_OPEN_EXEC))
284 kumaneko 1498 + /* 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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/fs/fcntl.c
302     +++ linux-2.6.25.20-0.1/fs/fcntl.c
303 kumaneko 1498 @@ -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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/fs/ioctl.c
327     +++ linux-2.6.25.20-0.1/fs/ioctl.c
328 kumaneko 1498 @@ -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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_IOCTL))
344 kumaneko 1498 + 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 kumaneko 2279 @@ -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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/fs/namei.c
361     +++ linux-2.6.25.20-0.1/fs/namei.c
362 kumaneko 1498 @@ -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 kumaneko 2297 @@ -1690,6 +1694,13 @@ int may_open(struct nameidata *nd, int a
374 kumaneko 1498 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 kumaneko 2297 @@ -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 kumaneko 1498 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 kumaneko 2297 @@ -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 kumaneko 1498 error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd);
422 kumaneko 2297 @@ -2097,6 +2122,11 @@ asmlinkage long sys_mkdirat(int dfd, con
423 kumaneko 1498
424     if (!IS_POSIXACL(nd.path.dentry->d_inode))
425     mode &= ~current->fs->umask;
426     + /***** TOMOYO Linux start. *****/
427 kumaneko 2297 + error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry,
428     + nd.path.mnt, mode);
429 kumaneko 1498 + 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 kumaneko 2297 @@ -2205,6 +2235,11 @@ static long do_rmdir(int dfd, const char
435 kumaneko 1498 error = PTR_ERR(dentry);
436     if (IS_ERR(dentry))
437     goto exit2;
438     + /***** TOMOYO Linux start. *****/
439 kumaneko 2297 + error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry,
440     + nd.path.mnt);
441 kumaneko 1498 + 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 kumaneko 2297 @@ -2286,6 +2321,11 @@ static long do_unlinkat(int dfd, const c
447 kumaneko 1498 inode = dentry->d_inode;
448     if (inode)
449     atomic_inc(&inode->i_count);
450     + /***** TOMOYO Linux start. *****/
451 kumaneko 2297 + error = ccs_check_unlink_permission(nd.path.dentry->d_inode,
452     + dentry, nd.path.mnt);
453     + if (!error)
454 kumaneko 1498 + /***** TOMOYO Linux end. *****/
455     error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt);
456     exit2:
457     dput(dentry);
458 kumaneko 2297 @@ -2368,6 +2408,11 @@ asmlinkage long sys_symlinkat(const char
459 kumaneko 1498 if (IS_ERR(dentry))
460     goto out_unlock;
461    
462     + /***** TOMOYO Linux start. *****/
463 kumaneko 2297 + error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry,
464     + nd.path.mnt, from);
465 kumaneko 1498 + 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 kumaneko 2297 @@ -2465,6 +2510,12 @@ asmlinkage long sys_linkat(int olddfd, c
471 kumaneko 1498 error = PTR_ERR(new_dentry);
472     if (IS_ERR(new_dentry))
473     goto out_unlock;
474     + /***** TOMOYO Linux start. *****/
475 kumaneko 2297 + error = ccs_check_link_permission(old_nd.path.dentry,
476     + nd.path.dentry->d_inode, new_dentry,
477     + nd.path.mnt);
478 kumaneko 1498 + 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 kumaneko 2297 @@ -2698,6 +2749,12 @@ static int do_rename(int olddfd, const c
484 kumaneko 1498 error = -ENOTEMPTY;
485     if (new_dentry == trap)
486     goto exit5;
487     + /***** TOMOYO Linux start. *****/
488 kumaneko 2297 + 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 kumaneko 1498 + /***** 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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/fs/namespace.c
497     +++ linux-2.6.25.20-0.1/fs/namespace.c
498 kumaneko 1498 @@ -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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_UMOUNT))
529 kumaneko 1498 + 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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_MOUNT))
576 kumaneko 1498 + 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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
594 kumaneko 1498 + 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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/fs/open.c
611     +++ linux-2.6.25.20-0.1/fs/open.c
612 kumaneko 1498 @@ -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 kumaneko 2297 + error = ccs_check_truncate_permission(nd.path.dentry, nd.path.mnt,
631     + length, 0);
632 kumaneko 1498 + 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 kumaneko 2297 @@ -321,6 +333,12 @@ static long do_sys_ftruncate(unsigned in
639 kumaneko 1498 if (IS_APPEND(inode))
640     goto out_putf;
641    
642     + /***** TOMOYO Linux start. *****/
643 kumaneko 2297 + error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length,
644     + 0);
645 kumaneko 1498 + 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 kumaneko 2297 @@ -539,6 +557,14 @@ asmlinkage long sys_chroot(const char __
652 kumaneko 1498 error = -EPERM;
653     if (!capable(CAP_SYS_CHROOT))
654     goto dput_and_out;
655     + /***** TOMOYO Linux start. *****/
656 kumaneko 2282 + if (!ccs_capable(CCS_SYS_CHROOT))
657 kumaneko 1498 + 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 kumaneko 2297 @@ -1172,6 +1198,10 @@ EXPORT_SYMBOL(sys_close);
667 kumaneko 1498 */
668     asmlinkage long sys_vhangup(void)
669     {
670     + /***** TOMOYO Linux start. *****/
671 kumaneko 2282 + if (!ccs_capable(CCS_SYS_VHANGUP))
672 kumaneko 1498 + 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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/fs/proc/Makefile
678     +++ linux-2.6.25.20-0.1/fs/proc/Makefile
679 kumaneko 1498 @@ -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 kumaneko 2073 --- 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 kumaneko 1498 @@ -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 kumaneko 2279 + printk(KERN_INFO "Hook version: 2.6.25.20-0.1 2009/03/18\n");
695 kumaneko 1498 +#endif
696     + /***** CCS end. *****/
697     }
698 kumaneko 2073 --- 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 kumaneko 1498 @@ -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 kumaneko 2282 + .ccs_domain_info = NULL, \
706     + .ccs_flags = 0, \
707 kumaneko 1498 + /***** TOMOYO Linux end. *****/ \
708     }
709    
710    
711 kumaneko 2073 --- 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 kumaneko 2282 @@ -29,6 +29,10 @@
714 kumaneko 1498 #define CLONE_NEWNET 0x40000000 /* New network namespace */
715     #define CLONE_IO 0x80000000 /* Clone io context */
716    
717     +/***** TOMOYO Linux start. *****/
718 kumaneko 2282 +struct ccs_domain_info;
719 kumaneko 1498 +/***** TOMOYO Linux end. *****/
720     +
721     /*
722     * Scheduling policies
723     */
724 kumaneko 2282 @@ -1274,6 +1278,10 @@ struct task_struct {
725 kumaneko 2073 #ifndef __GENKSYMS__
726     struct list_head *scm_work_list;
727 kumaneko 1498 #endif
728     + /***** TOMOYO Linux start. *****/
729 kumaneko 2282 + struct ccs_domain_info *ccs_domain_info;
730     + u32 ccs_flags;
731 kumaneko 1498 + /***** TOMOYO Linux end. *****/
732     };
733    
734     /*
735 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/compat.c
736     +++ linux-2.6.25.20-0.1/kernel/compat.c
737 kumaneko 1498 @@ -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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
753 kumaneko 1498 + return -EPERM;
754     + /***** TOMOYO Linux end. *****/
755    
756     do_settimeofday(&tv);
757     return 0;
758 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/kexec.c
759     +++ linux-2.6.25.20-0.1/kernel/kexec.c
760 kumaneko 1498 @@ -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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
776 kumaneko 1498 + return -EPERM;
777     + /***** TOMOYO Linux end. *****/
778    
779     /*
780     * Verify we have a legal set of flags
781 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/kmod.c
782     +++ linux-2.6.25.20-0.1/kernel/kmod.c
783 kumaneko 1498 @@ -173,6 +173,11 @@ static int ____call_usermodehelper(void
784     */
785     set_user_nice(current, 0);
786    
787     + /***** TOMOYO Linux start. *****/
788 kumaneko 2282 + current->ccs_domain_info = NULL;
789     + current->ccs_flags = 0;
790 kumaneko 1498 + /***** TOMOYO Linux end. *****/
791     +
792     retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp);
793    
794     /* Exec failed? */
795 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/module.c
796     +++ linux-2.6.25.20-0.1/kernel/module.c
797 kumaneko 1498 @@ -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 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
813 kumaneko 1498 + 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 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
824 kumaneko 1498 + 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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/ptrace.c
830     +++ linux-2.6.25.20-0.1/kernel/ptrace.c
831 kumaneko 1498 @@ -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 kumaneko 2278 @@ -548,6 +551,10 @@ asmlinkage long sys_ptrace(long request,
842 kumaneko 1498 /*
843     * This lock_kernel fixes a subtle race with suid exec
844     */
845     + /***** TOMOYO Linux start. *****/
846 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
847 kumaneko 1498 + return -EPERM;
848     + /***** TOMOYO Linux end. *****/
849     lock_kernel();
850     if (request == PTRACE_TRACEME) {
851     ret = ptrace_traceme();
852 kumaneko 2278 @@ -655,6 +662,10 @@ asmlinkage long compat_sys_ptrace(compat
853 kumaneko 1498 /*
854     * This lock_kernel fixes a subtle race with suid exec
855     */
856     + /***** TOMOYO Linux start. *****/
857 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
858 kumaneko 1498 + return -EPERM;
859     + /***** TOMOYO Linux end. *****/
860     lock_kernel();
861     if (request == PTRACE_TRACEME) {
862     ret = ptrace_traceme();
863 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/sched.c
864     +++ linux-2.6.25.20-0.1/kernel/sched.c
865 kumaneko 1498 @@ -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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE))
881 kumaneko 1498 + return -EPERM;
882     + /***** TOMOYO Linux end. *****/
883    
884     /*
885     * Setpriority might change our priority at the same moment.
886 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/signal.c
887     +++ linux-2.6.25.20-0.1/kernel/signal.c
888 kumaneko 1498 @@ -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 kumaneko 1758 @@ -2232,6 +2235,12 @@ asmlinkage long
899 kumaneko 1498 sys_kill(int pid, int sig)
900     {
901     struct siginfo info;
902     + /***** TOMOYO Linux start. *****/
903 kumaneko 2282 + if (sig && !ccs_capable(CCS_SYS_KILL))
904 kumaneko 1498 + 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 kumaneko 1758 @@ -2290,6 +2299,12 @@ asmlinkage long sys_tgkill(int tgid, int
912 kumaneko 1498 /* This is only valid for single tasks */
913     if (pid <= 0 || tgid <= 0)
914     return -EINVAL;
915     + /***** TOMOYO Linux start. *****/
916 kumaneko 2282 + if (sig && !ccs_capable(CCS_SYS_KILL))
917 kumaneko 1498 + 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 kumaneko 1758 @@ -2303,6 +2318,12 @@ sys_tkill(int pid, int sig)
925 kumaneko 1498 /* This is only valid for single tasks */
926     if (pid <= 0)
927     return -EINVAL;
928     + /***** TOMOYO Linux start. *****/
929 kumaneko 2282 + if (sig && !ccs_capable(CCS_SYS_KILL))
930 kumaneko 1498 + 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 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/sys.c
938     +++ linux-2.6.25.20-0.1/kernel/sys.c
939 kumaneko 1498 @@ -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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE)) {
955 kumaneko 1498 + 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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_REBOOT))
968 kumaneko 1498 + 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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
979 kumaneko 1498 + 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 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
990 kumaneko 1498 + return -EPERM;
991     + /***** TOMOYO Linux end. *****/
992    
993     down_write(&uts_sem);
994     errno = -EFAULT;
995 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/sysctl.c
996     +++ linux-2.6.25.20-0.1/kernel/sysctl.c
997 kumaneko 1498 @@ -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 kumaneko 2298 @@ -1500,6 +1503,7 @@ char *sysctl_pathname(struct ctl_table *
1008 kumaneko 1498 EXPORT_SYMBOL_GPL(sysctl_pathname);
1009    
1010     #ifdef CONFIG_SYSCTL_SYSCALL
1011     +
1012     int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1013     void __user *newval, size_t newlen)
1014     {
1015 kumaneko 2298 @@ -1516,6 +1520,11 @@ int do_sysctl(int __user *name, int nlen
1016 kumaneko 1498
1017     for (head = sysctl_head_next(NULL); head;
1018     head = sysctl_head_next(head)) {
1019     + /***** TOMOYO Linux start. *****/
1020 kumaneko 2298 + error = ccs_parse_table(name, nlen, oldval, newval,
1021 kumaneko 1498 + head->ctl_table);
1022     + if (!error)
1023     + /***** TOMOYO Linux end. *****/
1024     error = parse_table(name, nlen, oldval, oldlenp,
1025     newval, newlen, head->ctl_table);
1026     if (error != -ENOTDIR) {
1027 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/time.c
1028     +++ linux-2.6.25.20-0.1/kernel/time.c
1029 kumaneko 1498 @@ -38,6 +38,9 @@
1030    
1031     #include <asm/uaccess.h>
1032     #include <asm/unistd.h>
1033     +/***** TOMOYO Linux start. *****/
1034     +#include <linux/tomoyo.h>
1035     +/***** TOMOYO Linux end. *****/
1036    
1037     #include "timeconst.h"
1038    
1039     @@ -88,6 +91,10 @@ asmlinkage long sys_stime(time_t __user
1040     err = security_settime(&tv, NULL);
1041     if (err)
1042     return err;
1043     + /***** TOMOYO Linux start. *****/
1044 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1045 kumaneko 1498 + return -EPERM;
1046     + /***** TOMOYO Linux end. *****/
1047    
1048     do_settimeofday(&tv);
1049     return 0;
1050     @@ -159,6 +166,10 @@ int do_sys_settimeofday(struct timespec
1051     error = security_settime(tv, tz);
1052     if (error)
1053     return error;
1054     + /***** TOMOYO Linux start. *****/
1055 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1056 kumaneko 1498 + return -EPERM;
1057     + /***** TOMOYO Linux end. *****/
1058    
1059     if (tz) {
1060     /* SMP safe, global irq locking makes it work. */
1061 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/kernel/time/ntp.c
1062     +++ linux-2.6.25.20-0.1/kernel/time/ntp.c
1063 kumaneko 1498 @@ -17,6 +17,9 @@
1064     #include <linux/capability.h>
1065     #include <asm/div64.h>
1066     #include <asm/timex.h>
1067     +/***** TOMOYO Linux start. *****/
1068     +#include <linux/tomoyo.h>
1069     +/***** TOMOYO Linux end. *****/
1070    
1071     /*
1072     * Timekeeping variables
1073     @@ -243,6 +246,10 @@ int do_adjtimex(struct timex *txc)
1074     /* In order to modify anything, you gotta be super-user! */
1075     if (txc->modes && !capable(CAP_SYS_TIME))
1076     return -EPERM;
1077     + /***** TOMOYO Linux start. *****/
1078 kumaneko 2282 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1079 kumaneko 1498 + return -EPERM;
1080     + /***** TOMOYO Linux end. *****/
1081    
1082     /* Now we validate the data before disabling interrupts */
1083    
1084 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/net/core/datagram.c
1085     +++ linux-2.6.25.20-0.1/net/core/datagram.c
1086 kumaneko 1498 @@ -56,6 +56,11 @@
1087     #include <net/sock.h>
1088     #include <net/tcp_states.h>
1089    
1090     +/***** TOMOYO Linux start. *****/
1091     +#include <linux/tomoyo.h>
1092     +#include <linux/tomoyo_socket.h>
1093     +/***** TOMOYO Linux end. *****/
1094     +
1095     /*
1096     * Is a socket 'connection oriented' ?
1097     */
1098     @@ -179,6 +184,12 @@ struct sk_buff *__skb_recv_datagram(stru
1099     }
1100     spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
1101    
1102     + /***** TOMOYO Linux start. *****/
1103     + error = ccs_socket_recv_datagram_permission(sk, skb, flags);
1104     + if (error)
1105     + goto no_packet;
1106     + /***** TOMOYO Linux end. *****/
1107     +
1108     if (skb)
1109     return skb;
1110    
1111 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/net/ipv4/inet_connection_sock.c
1112     +++ linux-2.6.25.20-0.1/net/ipv4/inet_connection_sock.c
1113 kumaneko 1498 @@ -23,6 +23,9 @@
1114     #include <net/route.h>
1115     #include <net/tcp_states.h>
1116     #include <net/xfrm.h>
1117     +/***** SAKURA Linux start. *****/
1118     +#include <linux/sakura.h>
1119     +/***** SAKURA Linux end. *****/
1120    
1121     #ifdef INET_CSK_DEBUG
1122     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1123     @@ -98,6 +101,10 @@ int inet_csk_get_port(struct sock *sk, u
1124     do {
1125     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1126     spin_lock(&head->lock);
1127     + /***** SAKURA Linux start. *****/
1128     + if (ccs_may_autobind(rover))
1129     + goto next;
1130     + /***** SAKURA Linux end. *****/
1131     inet_bind_bucket_for_each(tb, node, &head->chain)
1132     if (tb->ib_net == net && tb->port == rover)
1133     goto next;
1134 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/net/ipv4/inet_hashtables.c
1135     +++ linux-2.6.25.20-0.1/net/ipv4/inet_hashtables.c
1136 kumaneko 1498 @@ -22,6 +22,9 @@
1137     #include <net/inet_connection_sock.h>
1138     #include <net/inet_hashtables.h>
1139     #include <net/ip.h>
1140     +/***** SAKURA Linux start. *****/
1141     +#include <linux/sakura.h>
1142     +/***** SAKURA Linux end. *****/
1143    
1144     /*
1145     * Allocate and initialize a new local port bind bucket.
1146     @@ -421,6 +424,10 @@ int __inet_hash_connect(struct inet_time
1147     local_bh_disable();
1148     for (i = 1; i <= remaining; i++) {
1149     port = low + (i + offset) % remaining;
1150     + /***** SAKURA Linux start. *****/
1151     + if (ccs_may_autobind(port))
1152     + continue;
1153     + /***** SAKURA Linux end. *****/
1154     head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1155     spin_lock(&head->lock);
1156    
1157 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/net/ipv4/udp.c
1158     +++ linux-2.6.25.20-0.1/net/ipv4/udp.c
1159 kumaneko 1498 @@ -105,6 +105,9 @@
1160     #include <net/checksum.h>
1161     #include <net/xfrm.h>
1162     #include "udp_impl.h"
1163     +/***** SAKURA Linux start. *****/
1164     +#include <linux/sakura.h>
1165     +/***** SAKURA Linux end. *****/
1166    
1167     /*
1168     * Snmp MIB for the UDP layer
1169     @@ -176,6 +179,10 @@ int __udp_lib_get_port(struct sock *sk,
1170     /* 1st pass: look for empty (or shortest) hash chain */
1171     for (i = 0; i < UDP_HTABLE_SIZE; i++) {
1172     int size = 0;
1173     + /***** SAKURA Linux start. *****/
1174     + if (ccs_may_autobind(rover))
1175     + goto next;
1176     + /***** SAKURA Linux end. *****/
1177    
1178     head = &udptable[rover & (UDP_HTABLE_SIZE - 1)];
1179     if (hlist_empty(head))
1180     @@ -199,6 +206,9 @@ int __udp_lib_get_port(struct sock *sk,
1181     /* 2nd pass: find hole in shortest hash chain */
1182     rover = best;
1183     for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) {
1184     + /***** SAKURA Linux start. *****/
1185     + if (!ccs_may_autobind(rover))
1186     + /***** SAKURA Linux end. *****/
1187     if (! __udp_lib_lport_inuse(net, rover, udptable))
1188     goto gotit;
1189     rover += UDP_HTABLE_SIZE;
1190 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/net/socket.c
1191     +++ linux-2.6.25.20-0.1/net/socket.c
1192 kumaneko 1498 @@ -94,6 +94,11 @@
1193     #include <net/sock.h>
1194     #include <linux/netfilter.h>
1195    
1196     +/***** TOMOYO Linux start. *****/
1197     +#include <linux/tomoyo.h>
1198     +#include <linux/tomoyo_socket.h>
1199     +/***** TOMOYO Linux end. *****/
1200     +
1201     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1202     static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
1203     unsigned long nr_segs, loff_t pos);
1204     @@ -557,6 +562,12 @@ static inline int __sock_sendmsg(struct
1205     err = security_socket_sendmsg(sock, msg, size);
1206     if (err)
1207     return err;
1208     + /***** TOMOYO Linux start. *****/
1209     + if (ccs_socket_sendmsg_permission(sock,
1210     + (struct sockaddr *) msg->msg_name,
1211     + msg->msg_namelen))
1212     + return -EPERM;
1213     + /***** TOMOYO Linux end. *****/
1214    
1215     return sock->ops->sendmsg(iocb, sock, msg, size);
1216     }
1217     @@ -1120,6 +1131,12 @@ static int __sock_create(struct net *net
1218     family = PF_PACKET;
1219     }
1220    
1221     + /***** TOMOYO Linux start. *****/
1222     + err = ccs_socket_create_permission(family, type, protocol);
1223     + if (err)
1224     + return err;
1225     + /***** TOMOYO Linux end. *****/
1226     +
1227     err = security_socket_create(family, type, protocol, kern);
1228     if (err)
1229     return err;
1230     @@ -1351,6 +1368,13 @@ asmlinkage long sys_bind(int fd, struct
1231     err = security_socket_bind(sock,
1232     (struct sockaddr *)address,
1233     addrlen);
1234     + /***** TOMOYO Linux start. *****/
1235     + if (!err)
1236     + err = ccs_socket_bind_permission(sock,
1237     + (struct sockaddr *)
1238     + address,
1239     + addrlen);
1240     + /***** TOMOYO Linux end. *****/
1241     if (!err)
1242     err = sock->ops->bind(sock,
1243     (struct sockaddr *)
1244     @@ -1380,6 +1404,10 @@ asmlinkage long sys_listen(int fd, int b
1245     backlog = somaxconn;
1246    
1247     err = security_socket_listen(sock, backlog);
1248     + /***** TOMOYO Linux start. *****/
1249     + if (!err)
1250     + err = ccs_socket_listen_permission(sock);
1251     + /***** TOMOYO Linux end. *****/
1252     if (!err)
1253     err = sock->ops->listen(sock, backlog);
1254    
1255     @@ -1444,6 +1472,13 @@ asmlinkage long sys_accept(int fd, struc
1256     if (err < 0)
1257     goto out_fd;
1258    
1259     + /***** TOMOYO Linux start. *****/
1260     + if (ccs_socket_accept_permission(newsock,
1261     + (struct sockaddr *) address)) {
1262     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1263     + goto out_fd;
1264     + }
1265     + /***** TOMOYO Linux end. *****/
1266     if (upeer_sockaddr) {
1267     if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1268     &len, 2) < 0) {
1269     @@ -1508,6 +1543,12 @@ asmlinkage long sys_connect(int fd, stru
1270     security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1271     if (err)
1272     goto out_put;
1273     + /***** TOMOYO Linux start. *****/
1274     + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1275     + addrlen);
1276     + if (err)
1277     + goto out_put;
1278     + /***** TOMOYO Linux end. *****/
1279    
1280     err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
1281     sock->file->f_flags);
1282 kumaneko 2073 --- linux-2.6.25.20-0.1.orig/net/unix/af_unix.c
1283     +++ linux-2.6.25.20-0.1/net/unix/af_unix.c
1284 kumaneko 1498 @@ -116,6 +116,9 @@
1285     #include <linux/mount.h>
1286     #include <net/checksum.h>
1287     #include <linux/security.h>
1288     +/***** TOMOYO Linux start. *****/
1289     +#include <linux/tomoyo.h>
1290     +/***** TOMOYO Linux end. *****/
1291    
1292     static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
1293     static DEFINE_SPINLOCK(unix_table_lock);
1294 kumaneko 2297 @@ -819,6 +822,11 @@ static int unix_bind(struct socket *sock
1295 kumaneko 1498 */
1296     mode = S_IFSOCK |
1297     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1298     + /***** TOMOYO Linux start. *****/
1299 kumaneko 2297 + err = ccs_check_mknod_permission(nd.path.dentry->d_inode,
1300     + dentry, nd.path.mnt, mode, 0);
1301 kumaneko 1498 + if (!err)
1302     + /***** TOMOYO Linux end. *****/
1303     err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt,
1304     mode, 0);
1305     if (err)

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