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

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 2647 - (hide annotations) (download) (as text)
Tue Jun 9 01:10:00 2009 UTC (14 years, 11 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: 42159 byte(s)


1 kumaneko 1498 This is TOMOYO Linux patch for openSUSE 11.0.
2    
3 kumaneko 2647 Source code for this patch is http://download.opensuse.org/update/11.0/rpm/i586/kernel-source-2.6.25.20-0.4.i586.rpm
4 kumaneko 1498 ---
5 kumaneko 2298 arch/ia64/ia32/sys_ia32.c | 7 ++++
6     arch/mips/kernel/ptrace32.c | 7 ++++
7     arch/s390/kernel/ptrace.c | 7 ++++
8     arch/x86/kernel/ptrace.c | 7 ++++
9     fs/Kconfig | 2 +
10     fs/Makefile | 2 +
11     fs/attr.c | 19 +++++++++++++
12     fs/compat.c | 5 ++-
13     fs/compat_ioctl.c | 13 +++++++++
14 kumaneko 2306 fs/exec.c | 18 +++++++++++-
15 kumaneko 2298 fs/fcntl.c | 9 ++++++
16     fs/ioctl.c | 11 +++++++
17     fs/namei.c | 57 ++++++++++++++++++++++++++++++++++++++++
18     fs/namespace.c | 49 ++++++++++++++++++++++++++++++++++
19     fs/open.c | 30 +++++++++++++++++++++
20     fs/proc/Makefile | 3 ++
21     fs/proc/proc_misc.c | 5 +++
22     include/linux/init_task.h | 4 ++
23     include/linux/sched.h | 8 +++++
24     kernel/compat.c | 7 ++++
25     kernel/kexec.c | 7 ++++
26     kernel/kmod.c | 5 +++
27     kernel/module.c | 11 +++++++
28     kernel/ptrace.c | 11 +++++++
29     kernel/sched.c | 7 ++++
30     kernel/signal.c | 21 ++++++++++++++
31     kernel/sys.c | 21 ++++++++++++++
32     kernel/sysctl.c | 9 ++++++
33     kernel/time.c | 11 +++++++
34     kernel/time/ntp.c | 7 ++++
35     net/ipv4/inet_connection_sock.c | 7 ++++
36     net/ipv4/inet_hashtables.c | 7 ++++
37 kumaneko 2459 net/ipv4/raw.c | 8 +++++
38     net/ipv4/udp.c | 18 ++++++++++++
39     net/ipv6/raw.c | 8 +++++
40     net/ipv6/udp.c | 8 +++++
41 kumaneko 2298 net/socket.c | 41 ++++++++++++++++++++++++++++
42     net/unix/af_unix.c | 8 +++++
43 kumaneko 2459 38 files changed, 483 insertions(+), 2 deletions(-)
44 kumaneko 1498
45 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/arch/ia64/ia32/sys_ia32.c
46     +++ linux-2.6.25.20-0.4/arch/ia64/ia32/sys_ia32.c
47 kumaneko 1498 @@ -50,6 +50,9 @@
48     #include <asm/types.h>
49     #include <asm/uaccess.h>
50     #include <asm/unistd.h>
51     +/***** TOMOYO Linux start. *****/
52     +#include <linux/tomoyo.h>
53     +/***** TOMOYO Linux end. *****/
54    
55     #include "ia32priv.h"
56    
57 kumaneko 2278 @@ -1753,6 +1756,10 @@ sys32_ptrace (int request, pid_t pid, un
58 kumaneko 1498 struct task_struct *child;
59     unsigned int value, tmp;
60     long i, ret;
61     + /***** TOMOYO Linux start. *****/
62 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
63 kumaneko 1498 + return -EPERM;
64     + /***** TOMOYO Linux end. *****/
65    
66     lock_kernel();
67     if (request == PTRACE_TRACEME) {
68 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/arch/mips/kernel/ptrace32.c
69     +++ linux-2.6.25.20-0.4/arch/mips/kernel/ptrace32.c
70 kumaneko 1498 @@ -35,6 +35,9 @@
71     #include <asm/system.h>
72     #include <asm/uaccess.h>
73     #include <asm/bootinfo.h>
74     +/***** TOMOYO Linux start. *****/
75     +#include <linux/tomoyo.h>
76     +/***** TOMOYO Linux end. *****/
77    
78     int ptrace_getregs(struct task_struct *child, __s64 __user *data);
79     int ptrace_setregs(struct task_struct *child, __s64 __user *data);
80 kumaneko 2278 @@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request,
81 kumaneko 1498 {
82     struct task_struct *child;
83     int ret;
84     + /***** TOMOYO Linux start. *****/
85 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
86 kumaneko 1498 + return -EPERM;
87     + /***** TOMOYO Linux end. *****/
88    
89     #if 0
90     printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
91 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/arch/s390/kernel/ptrace.c
92     +++ linux-2.6.25.20-0.4/arch/s390/kernel/ptrace.c
93 kumaneko 1498 @@ -41,6 +41,9 @@
94     #include <asm/system.h>
95     #include <asm/uaccess.h>
96     #include <asm/unistd.h>
97     +/***** TOMOYO Linux start. *****/
98     +#include <linux/tomoyo.h>
99     +/***** TOMOYO Linux end. *****/
100    
101     #ifdef CONFIG_COMPAT
102     #include "compat_ptrace.h"
103 kumaneko 2278 @@ -698,6 +701,10 @@ sys_ptrace(long request, long pid, long
104 kumaneko 1498 struct task_struct *child;
105     int ret;
106    
107     + /***** TOMOYO Linux start. *****/
108 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
109 kumaneko 1498 + return -EPERM;
110     + /***** TOMOYO Linux end. *****/
111     lock_kernel();
112     if (request == PTRACE_TRACEME) {
113     ret = ptrace_traceme();
114 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/arch/x86/kernel/ptrace.c
115     +++ linux-2.6.25.20-0.4/arch/x86/kernel/ptrace.c
116 kumaneko 1498 @@ -32,6 +32,9 @@
117     #include <asm/prctl.h>
118     #include <asm/proto.h>
119     #include <asm/ds.h>
120     +/***** TOMOYO Linux start. *****/
121     +#include <linux/tomoyo.h>
122     +/***** TOMOYO Linux end. *****/
123    
124     #include "tls.h"
125    
126 kumaneko 2278 @@ -1240,6 +1243,10 @@ asmlinkage long sys32_ptrace(long reques
127 kumaneko 1498 void __user *datap = compat_ptr(data);
128     int ret;
129     __u32 val;
130     + /***** TOMOYO Linux start. *****/
131 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
132 kumaneko 1498 + return -EPERM;
133     + /***** TOMOYO Linux end. *****/
134    
135     switch (request) {
136     case PTRACE_TRACEME:
137 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/fs/Kconfig
138     +++ linux-2.6.25.20-0.4/fs/Kconfig
139 kumaneko 1498 @@ -2187,4 +2187,6 @@ endif
140     source "fs/nls/Kconfig"
141     source "fs/dlm/Kconfig"
142    
143     +source "fs/Kconfig.ccs"
144     +
145     endmenu
146 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/fs/Makefile
147     +++ linux-2.6.25.20-0.4/fs/Makefile
148 kumaneko 1498 @@ -125,3 +125,5 @@ obj-$(CONFIG_OCFS2_FS) += ocfs2/
149     obj-$(CONFIG_GFS2_FS) += gfs2/
150     obj-$(CONFIG_NOVFS) += novfs/
151     obj-$(CONFIG_SQUASHFS) += squashfs/
152     +
153     +include $(srctree)/fs/Makefile-2.6.ccs
154 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/fs/attr.c
155     +++ linux-2.6.25.20-0.4/fs/attr.c
156 kumaneko 1498 @@ -14,6 +14,9 @@
157     #include <linux/fcntl.h>
158     #include <linux/quotaops.h>
159     #include <linux/security.h>
160     +/***** TOMOYO Linux start. *****/
161     +#include <linux/tomoyo.h>
162     +/***** TOMOYO Linux end. *****/
163    
164     /* Taken over from the old code... */
165    
166     @@ -160,6 +163,14 @@ int fnotify_change(struct dentry *dentry
167    
168     if (inode->i_op && inode->i_op->setattr) {
169     error = security_inode_setattr(dentry, mnt, attr);
170     + /***** TOMOYO Linux start. *****/
171     + if (!error && (ia_valid & ATTR_MODE) &&
172 kumaneko 2282 + !ccs_capable(CCS_SYS_CHMOD))
173 kumaneko 1498 + error = -EPERM;
174     + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
175 kumaneko 2282 + !ccs_capable(CCS_SYS_CHOWN))
176 kumaneko 1498 + error = -EPERM;
177     + /***** TOMOYO Linux end. *****/
178     if (!error) {
179     if (file && file->f_op && file->f_op->fsetattr)
180     error = file->f_op->fsetattr(file, attr);
181     @@ -181,6 +192,14 @@ int fnotify_change(struct dentry *dentry
182     error = inode_change_ok(inode, attr);
183     if (!error)
184     error = security_inode_setattr(dentry, mnt, attr);
185     + /***** TOMOYO Linux start. *****/
186     + if (!error && (ia_valid & ATTR_MODE) &&
187 kumaneko 2282 + !ccs_capable(CCS_SYS_CHMOD))
188 kumaneko 1498 + error = -EPERM;
189     + if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) &&
190 kumaneko 2282 + !ccs_capable(CCS_SYS_CHOWN))
191 kumaneko 1498 + error = -EPERM;
192     + /***** TOMOYO Linux end. *****/
193     if (!error) {
194     if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
195     (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
196 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/fs/compat.c
197     +++ linux-2.6.25.20-0.4/fs/compat.c
198 kumaneko 1498 @@ -55,6 +55,9 @@
199     #include <asm/mmu_context.h>
200     #include <asm/ioctls.h>
201     #include "internal.h"
202     +/***** TOMOYO Linux start. *****/
203     +#include <linux/tomoyo.h>
204     +/***** TOMOYO Linux end. *****/
205    
206     int compat_log = 1;
207    
208     @@ -1399,7 +1402,7 @@ int compat_do_execve(char * filename,
209     if (retval < 0)
210     goto out;
211    
212     - retval = search_binary_handler(bprm, regs);
213 kumaneko 2300 + retval = ccs_search_binary_handler(bprm, regs);
214 kumaneko 1498 if (retval >= 0) {
215     /* execve success */
216     security_bprm_free(bprm);
217 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/fs/compat_ioctl.c
218     +++ linux-2.6.25.20-0.4/fs/compat_ioctl.c
219 kumaneko 1498 @@ -120,6 +120,9 @@
220     #include <xen/public/privcmd.h>
221     #include <xen/compat_ioctl.h>
222     #endif
223     +/***** TOMOYO Linux start. *****/
224     +#include <linux/tomoyo.h>
225     +/***** TOMOYO Linux end. *****/
226    
227     static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
228     unsigned long arg, struct file *f)
229 kumaneko 2279 @@ -2906,6 +2909,10 @@ asmlinkage long compat_sys_ioctl(unsigne
230    
231     /* RED-PEN how should LSM module know it's handling 32bit? */
232     error = security_file_ioctl(filp, cmd, arg);
233     + /***** TOMOYO Linux start. *****/
234     + if (!error)
235     + error = ccs_check_ioctl_permission(filp, cmd, arg);
236     + /***** TOMOYO Linux end. *****/
237     if (error)
238     goto out_fput;
239    
240     @@ -2930,6 +2937,12 @@ asmlinkage long compat_sys_ioctl(unsigne
241 kumaneko 1498 /*FALL THROUGH*/
242    
243     default:
244     + /***** TOMOYO Linux start. *****/
245 kumaneko 2282 + if (!ccs_capable(CCS_SYS_IOCTL)) {
246 kumaneko 1498 + error = -EPERM;
247     + goto out_fput;
248     + }
249     + /***** TOMOYO Linux end. *****/
250     if (filp->f_op && filp->f_op->compat_ioctl) {
251     error = filp->f_op->compat_ioctl(filp, cmd, arg);
252     if (error != -ENOIOCTLCMD)
253 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/fs/exec.c
254     +++ linux-2.6.25.20-0.4/fs/exec.c
255 kumaneko 1498 @@ -60,6 +60,10 @@
256     #include <linux/kmod.h>
257     #endif
258    
259     +/***** TOMOYO Linux start. *****/
260     +#include <linux/tomoyo.h>
261     +/***** TOMOYO Linux end. *****/
262     +
263     int core_uses_pid;
264     char core_pattern[CORENAME_MAX_SIZE] = "core";
265     int suid_dumpable = 0;
266 kumaneko 2306 @@ -118,6 +122,11 @@ asmlinkage long sys_uselib(const char __
267 kumaneko 1498 error = vfs_permission(&nd, MAY_READ | MAY_EXEC);
268     if (error)
269     goto exit;
270     + /***** TOMOYO Linux start. *****/
271 kumaneko 2306 + error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt);
272 kumaneko 1498 + if (error)
273     + goto exit;
274     + /***** TOMOYO Linux end. *****/
275    
276     file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
277     error = PTR_ERR(file);
278 kumaneko 2306 @@ -664,6 +673,13 @@ struct file *open_exec(const char *name)
279 kumaneko 1498 file = ERR_PTR(-EACCES);
280     if (S_ISREG(inode->i_mode)) {
281     int err = vfs_permission(&nd, MAY_EXEC);
282     + /***** TOMOYO Linux start. *****/
283 kumaneko 2306 + if (!err)
284     + err = ccs_check_open_exec_permission(nd.path.
285     + dentry,
286     + nd.path.
287     + mnt);
288 kumaneko 1498 + /***** TOMOYO Linux end. *****/
289     file = ERR_PTR(err);
290     if (!err) {
291     file = nameidata_to_filp(&nd,
292 kumaneko 2306 @@ -1336,7 +1352,7 @@ int do_execve(char * filename,
293 kumaneko 1498 goto out;
294     bprm->argv_len = env_p - bprm->p;
295    
296     - retval = search_binary_handler(bprm,regs);
297 kumaneko 2300 + retval = ccs_search_binary_handler(bprm, regs);
298 kumaneko 1498 if (retval >= 0) {
299     /* execve success */
300     free_arg_pages(bprm);
301 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/fs/fcntl.c
302     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/fs/ioctl.c
327     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/fs/namei.c
361     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/fs/namespace.c
497     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/fs/open.c
611     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/fs/proc/Makefile
678     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/fs/proc/proc_misc.c
687     +++ linux-2.6.25.20-0.4/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 2647 + printk(KERN_INFO "Hook version: 2.6.25.20-0.4 2009/06/09\n");
695 kumaneko 1498 +#endif
696     + /***** CCS end. *****/
697     }
698 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/include/linux/init_task.h
699     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/include/linux/sched.h
712     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/compat.c
736     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/kexec.c
759     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/kmod.c
782     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/module.c
796     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/ptrace.c
830     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/sched.c
864     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/signal.c
887     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/sys.c
938     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/sysctl.c
996     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/time.c
1028     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/kernel/time/ntp.c
1062     +++ linux-2.6.25.20-0.4/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 2647 --- linux-2.6.25.20-0.4.orig/net/ipv4/inet_connection_sock.c
1085     +++ linux-2.6.25.20-0.4/net/ipv4/inet_connection_sock.c
1086 kumaneko 1498 @@ -23,6 +23,9 @@
1087     #include <net/route.h>
1088     #include <net/tcp_states.h>
1089     #include <net/xfrm.h>
1090     +/***** SAKURA Linux start. *****/
1091     +#include <linux/sakura.h>
1092     +/***** SAKURA Linux end. *****/
1093    
1094     #ifdef INET_CSK_DEBUG
1095     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1096     @@ -98,6 +101,10 @@ int inet_csk_get_port(struct sock *sk, u
1097     do {
1098     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1099     spin_lock(&head->lock);
1100     + /***** SAKURA Linux start. *****/
1101 kumaneko 2299 + if (ccs_lport_reserved(rover))
1102 kumaneko 1498 + goto next;
1103     + /***** SAKURA Linux end. *****/
1104     inet_bind_bucket_for_each(tb, node, &head->chain)
1105     if (tb->ib_net == net && tb->port == rover)
1106     goto next;
1107 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/net/ipv4/inet_hashtables.c
1108     +++ linux-2.6.25.20-0.4/net/ipv4/inet_hashtables.c
1109 kumaneko 1498 @@ -22,6 +22,9 @@
1110     #include <net/inet_connection_sock.h>
1111     #include <net/inet_hashtables.h>
1112     #include <net/ip.h>
1113     +/***** SAKURA Linux start. *****/
1114     +#include <linux/sakura.h>
1115     +/***** SAKURA Linux end. *****/
1116    
1117     /*
1118     * Allocate and initialize a new local port bind bucket.
1119     @@ -421,6 +424,10 @@ int __inet_hash_connect(struct inet_time
1120     local_bh_disable();
1121     for (i = 1; i <= remaining; i++) {
1122     port = low + (i + offset) % remaining;
1123     + /***** SAKURA Linux start. *****/
1124 kumaneko 2299 + if (ccs_lport_reserved(port))
1125 kumaneko 1498 + continue;
1126     + /***** SAKURA Linux end. *****/
1127     head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1128     spin_lock(&head->lock);
1129    
1130 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/net/ipv4/raw.c
1131     +++ linux-2.6.25.20-0.4/net/ipv4/raw.c
1132 kumaneko 2459 @@ -79,6 +79,9 @@
1133     #include <linux/seq_file.h>
1134     #include <linux/netfilter.h>
1135     #include <linux/netfilter_ipv4.h>
1136     +/***** TOMOYO Linux start. *****/
1137     +#include <linux/tomoyo_socket.h>
1138     +/***** TOMOYO Linux end. *****/
1139    
1140     static struct raw_hashinfo raw_v4_hashinfo = {
1141     .lock = __RW_LOCK_UNLOCKED(),
1142     @@ -668,6 +671,11 @@ static int raw_recvmsg(struct kiocb *ioc
1143     skb = skb_recv_datagram(sk, flags, noblock, &err);
1144     if (!skb)
1145     goto out;
1146     + /***** TOMOYO Linux start. *****/
1147     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1148     + if (err)
1149     + goto out;
1150     + /***** TOMOYO Linux end. *****/
1151    
1152     copied = skb->len;
1153     if (len < copied) {
1154 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/net/ipv4/udp.c
1155     +++ linux-2.6.25.20-0.4/net/ipv4/udp.c
1156 kumaneko 2459 @@ -105,6 +105,12 @@
1157 kumaneko 1498 #include <net/checksum.h>
1158     #include <net/xfrm.h>
1159     #include "udp_impl.h"
1160     +/***** SAKURA Linux start. *****/
1161     +#include <linux/sakura.h>
1162     +/***** SAKURA Linux end. *****/
1163 kumaneko 2459 +/***** TOMOYO Linux start. *****/
1164     +#include <linux/tomoyo_socket.h>
1165     +/***** TOMOYO Linux end. *****/
1166 kumaneko 1498
1167     /*
1168     * Snmp MIB for the UDP layer
1169 kumaneko 2459 @@ -176,6 +182,10 @@ int __udp_lib_get_port(struct sock *sk,
1170 kumaneko 1498 /* 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 kumaneko 2299 + if (ccs_lport_reserved(rover))
1175 kumaneko 1498 + goto next;
1176     + /***** SAKURA Linux end. *****/
1177    
1178     head = &udptable[rover & (UDP_HTABLE_SIZE - 1)];
1179     if (hlist_empty(head))
1180 kumaneko 2459 @@ -199,6 +209,9 @@ int __udp_lib_get_port(struct sock *sk,
1181 kumaneko 1498 /* 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 kumaneko 2299 + if (!ccs_lport_reserved(rover))
1186 kumaneko 1498 + /***** SAKURA Linux end. *****/
1187     if (! __udp_lib_lport_inuse(net, rover, udptable))
1188     goto gotit;
1189     rover += UDP_HTABLE_SIZE;
1190 kumaneko 2459 @@ -863,6 +876,11 @@ try_again:
1191     &peeked, &err);
1192     if (!skb)
1193     goto out;
1194     + /***** TOMOYO Linux start. *****/
1195     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1196     + if (err)
1197     + goto out;
1198     + /***** TOMOYO Linux end. *****/
1199    
1200     ulen = skb->len - sizeof(struct udphdr);
1201     copied = len;
1202 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/net/ipv6/raw.c
1203     +++ linux-2.6.25.20-0.4/net/ipv6/raw.c
1204 kumaneko 2459 @@ -60,6 +60,9 @@
1205    
1206     #include <linux/proc_fs.h>
1207     #include <linux/seq_file.h>
1208     +/***** TOMOYO Linux start. *****/
1209     +#include <linux/tomoyo_socket.h>
1210     +/***** TOMOYO Linux end. *****/
1211    
1212     static struct raw_hashinfo raw_v6_hashinfo = {
1213     .lock = __RW_LOCK_UNLOCKED(),
1214     @@ -482,6 +485,11 @@ static int rawv6_recvmsg(struct kiocb *i
1215     skb = skb_recv_datagram(sk, flags, noblock, &err);
1216     if (!skb)
1217     goto out;
1218     + /***** TOMOYO Linux start. *****/
1219     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1220     + if (err)
1221     + goto out;
1222     + /***** TOMOYO Linux end. *****/
1223    
1224     copied = skb->len;
1225     if (copied > len) {
1226 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/net/ipv6/udp.c
1227     +++ linux-2.6.25.20-0.4/net/ipv6/udp.c
1228 kumaneko 2459 @@ -50,6 +50,9 @@
1229     #include <linux/proc_fs.h>
1230     #include <linux/seq_file.h>
1231     #include "udp_impl.h"
1232     +/***** TOMOYO Linux start. *****/
1233     +#include <linux/tomoyo_socket.h>
1234     +/***** TOMOYO Linux end. *****/
1235    
1236     static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
1237     {
1238     @@ -137,6 +140,11 @@ try_again:
1239     &peeked, &err);
1240     if (!skb)
1241     goto out;
1242     + /***** TOMOYO Linux start. *****/
1243     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1244     + if (err)
1245     + goto out;
1246     + /***** TOMOYO Linux end. *****/
1247    
1248     ulen = skb->len - sizeof(struct udphdr);
1249     copied = len;
1250 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/net/socket.c
1251     +++ linux-2.6.25.20-0.4/net/socket.c
1252 kumaneko 1498 @@ -94,6 +94,11 @@
1253     #include <net/sock.h>
1254     #include <linux/netfilter.h>
1255    
1256     +/***** TOMOYO Linux start. *****/
1257     +#include <linux/tomoyo.h>
1258     +#include <linux/tomoyo_socket.h>
1259     +/***** TOMOYO Linux end. *****/
1260     +
1261     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1262     static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
1263     unsigned long nr_segs, loff_t pos);
1264     @@ -557,6 +562,12 @@ static inline int __sock_sendmsg(struct
1265     err = security_socket_sendmsg(sock, msg, size);
1266     if (err)
1267     return err;
1268     + /***** TOMOYO Linux start. *****/
1269     + if (ccs_socket_sendmsg_permission(sock,
1270     + (struct sockaddr *) msg->msg_name,
1271     + msg->msg_namelen))
1272     + return -EPERM;
1273     + /***** TOMOYO Linux end. *****/
1274    
1275     return sock->ops->sendmsg(iocb, sock, msg, size);
1276     }
1277     @@ -1120,6 +1131,12 @@ static int __sock_create(struct net *net
1278     family = PF_PACKET;
1279     }
1280    
1281     + /***** TOMOYO Linux start. *****/
1282     + err = ccs_socket_create_permission(family, type, protocol);
1283     + if (err)
1284     + return err;
1285     + /***** TOMOYO Linux end. *****/
1286     +
1287     err = security_socket_create(family, type, protocol, kern);
1288     if (err)
1289     return err;
1290     @@ -1351,6 +1368,13 @@ asmlinkage long sys_bind(int fd, struct
1291     err = security_socket_bind(sock,
1292     (struct sockaddr *)address,
1293     addrlen);
1294     + /***** TOMOYO Linux start. *****/
1295     + if (!err)
1296     + err = ccs_socket_bind_permission(sock,
1297     + (struct sockaddr *)
1298     + address,
1299     + addrlen);
1300     + /***** TOMOYO Linux end. *****/
1301     if (!err)
1302     err = sock->ops->bind(sock,
1303     (struct sockaddr *)
1304     @@ -1380,6 +1404,10 @@ asmlinkage long sys_listen(int fd, int b
1305     backlog = somaxconn;
1306    
1307     err = security_socket_listen(sock, backlog);
1308     + /***** TOMOYO Linux start. *****/
1309     + if (!err)
1310     + err = ccs_socket_listen_permission(sock);
1311     + /***** TOMOYO Linux end. *****/
1312     if (!err)
1313     err = sock->ops->listen(sock, backlog);
1314    
1315     @@ -1444,6 +1472,13 @@ asmlinkage long sys_accept(int fd, struc
1316     if (err < 0)
1317     goto out_fd;
1318    
1319     + /***** TOMOYO Linux start. *****/
1320     + if (ccs_socket_accept_permission(newsock,
1321     + (struct sockaddr *) address)) {
1322     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1323     + goto out_fd;
1324     + }
1325     + /***** TOMOYO Linux end. *****/
1326     if (upeer_sockaddr) {
1327     if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1328     &len, 2) < 0) {
1329     @@ -1508,6 +1543,12 @@ asmlinkage long sys_connect(int fd, stru
1330     security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1331     if (err)
1332     goto out_put;
1333     + /***** TOMOYO Linux start. *****/
1334     + err = ccs_socket_connect_permission(sock, (struct sockaddr *) address,
1335     + addrlen);
1336     + if (err)
1337     + goto out_put;
1338     + /***** TOMOYO Linux end. *****/
1339    
1340     err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen,
1341     sock->file->f_flags);
1342 kumaneko 2647 --- linux-2.6.25.20-0.4.orig/net/unix/af_unix.c
1343     +++ linux-2.6.25.20-0.4/net/unix/af_unix.c
1344 kumaneko 1498 @@ -116,6 +116,9 @@
1345     #include <linux/mount.h>
1346     #include <net/checksum.h>
1347     #include <linux/security.h>
1348     +/***** TOMOYO Linux start. *****/
1349     +#include <linux/tomoyo.h>
1350     +/***** TOMOYO Linux end. *****/
1351    
1352     static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
1353     static DEFINE_SPINLOCK(unix_table_lock);
1354 kumaneko 2297 @@ -819,6 +822,11 @@ static int unix_bind(struct socket *sock
1355 kumaneko 1498 */
1356     mode = S_IFSOCK |
1357     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1358     + /***** TOMOYO Linux start. *****/
1359 kumaneko 2297 + err = ccs_check_mknod_permission(nd.path.dentry->d_inode,
1360     + dentry, nd.path.mnt, mode, 0);
1361 kumaneko 1498 + if (!err)
1362     + /***** TOMOYO Linux end. *****/
1363     err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt,
1364     mode, 0);
1365     if (err)

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