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

Subversion リポジトリの参照

Annotation of /trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.25-suse-11.0.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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