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

Subversion リポジトリの参照

Annotation of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3075 - (hide annotations) (download) (as text)
Thu Oct 1 03:33:21 2009 UTC (14 years, 7 months ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.18-debian-etch.diff
File MIME type: text/x-diff
File size: 39608 byte(s)
Update sendmsg() hook.
1 kumaneko 1498 This is TOMOYO Linux patch for Debian Etch.
2    
3     Source code for this patch is "apt-get install linux-source-2.6.18"
4     ---
5 kumaneko 2796 arch/alpha/kernel/ptrace.c | 3 +++
6     arch/ia64/ia32/sys_ia32.c | 3 +++
7     arch/ia64/kernel/ptrace.c | 3 +++
8     arch/m32r/kernel/ptrace.c | 3 +++
9     arch/mips/kernel/ptrace32.c | 3 +++
10     arch/powerpc/kernel/ptrace32.c | 3 +++
11     arch/s390/kernel/ptrace.c | 3 +++
12     arch/sparc/kernel/ptrace.c | 5 +++++
13     arch/sparc64/kernel/ptrace.c | 5 +++++
14     arch/x86_64/ia32/ptrace32.c | 3 +++
15     fs/compat.c | 9 ++++++++-
16     fs/exec.c | 12 +++++++++++-
17 kumaneko 2922 fs/fcntl.c | 4 ++++
18 kumaneko 2796 fs/ioctl.c | 5 +++++
19 kumaneko 2922 fs/namei.c | 32 ++++++++++++++++++++++++++++++++
20 kumaneko 3052 fs/namespace.c | 23 ++++++++++++++++++++++-
21 kumaneko 2950 fs/open.c | 29 +++++++++++++++++++++++++++++
22 kumaneko 2796 fs/proc/proc_misc.c | 1 +
23 kumaneko 2926 include/linux/init_task.h | 9 +++++++++
24     include/linux/sched.h | 6 ++++++
25 kumaneko 2796 kernel/compat.c | 3 +++
26     kernel/kexec.c | 3 +++
27 kumaneko 2926 kernel/kmod.c | 5 +++++
28 kumaneko 2796 kernel/module.c | 7 +++++--
29     kernel/ptrace.c | 3 +++
30     kernel/sched.c | 3 +++
31 kumaneko 2869 kernel/signal.c | 9 +++++++++
32 kumaneko 2796 kernel/sys.c | 11 +++++++++++
33     kernel/sysctl.c | 11 +++++++++++
34     kernel/time.c | 7 +++++++
35     net/ipv4/inet_connection_sock.c | 3 +++
36     net/ipv4/inet_hashtables.c | 3 +++
37     net/ipv4/raw.c | 4 ++++
38 kumaneko 2859 net/ipv4/udp.c | 10 +++++++++-
39 kumaneko 2796 net/ipv6/inet6_hashtables.c | 5 ++++-
40     net/ipv6/raw.c | 4 ++++
41 kumaneko 2859 net/ipv6/udp.c | 8 ++++++++
42 kumaneko 3075 net/socket.c | 23 +++++++++++++++++++++--
43 kumaneko 2796 net/unix/af_unix.c | 4 ++++
44 kumaneko 2858 security/Kconfig | 2 ++
45     security/Makefile | 3 +++
46 kumaneko 3075 41 files changed, 286 insertions(+), 9 deletions(-)
47 kumaneko 1498
48 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/alpha/kernel/ptrace.c
49     +++ linux-2.6.18-24etch4/arch/alpha/kernel/ptrace.c
50 kumaneko 2796 @@ -20,6 +20,7 @@
51 kumaneko 1498 #include <asm/pgtable.h>
52     #include <asm/system.h>
53     #include <asm/fpu.h>
54 kumaneko 2859 +#include <linux/ccsecurity.h>
55 kumaneko 1498
56     #include "proto.h"
57    
58 kumaneko 2796 @@ -268,6 +269,8 @@ do_sys_ptrace(long request, long pid, lo
59 kumaneko 1498 unsigned long tmp;
60     size_t copied;
61     long ret;
62 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
63 kumaneko 1498 + return -EPERM;
64    
65     lock_kernel();
66     DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
67 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/ia64/ia32/sys_ia32.c
68     +++ linux-2.6.18-24etch4/arch/ia64/ia32/sys_ia32.c
69 kumaneko 2796 @@ -56,6 +56,7 @@
70 kumaneko 1498 #include <asm/types.h>
71     #include <asm/uaccess.h>
72     #include <asm/unistd.h>
73 kumaneko 2859 +#include <linux/ccsecurity.h>
74 kumaneko 1498
75     #include "ia32priv.h"
76    
77 kumaneko 2796 @@ -1741,6 +1742,8 @@ sys32_ptrace (int request, pid_t pid, un
78 kumaneko 1498 struct task_struct *child;
79     unsigned int value, tmp;
80     long i, ret;
81 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
82 kumaneko 1498 + return -EPERM;
83    
84     lock_kernel();
85     if (request == PTRACE_TRACEME) {
86 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/ia64/kernel/ptrace.c
87     +++ linux-2.6.18-24etch4/arch/ia64/kernel/ptrace.c
88 kumaneko 2796 @@ -28,6 +28,7 @@
89 kumaneko 1498 #ifdef CONFIG_PERFMON
90     #include <asm/perfmon.h>
91     #endif
92 kumaneko 2859 +#include <linux/ccsecurity.h>
93 kumaneko 1498
94     #include "entry.h"
95    
96 kumaneko 2796 @@ -1417,6 +1418,8 @@ sys_ptrace (long request, pid_t pid, uns
97 kumaneko 1498 struct task_struct *child;
98     struct switch_stack *sw;
99     long ret;
100 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
101 kumaneko 1498 + return -EPERM;
102    
103     lock_kernel();
104     ret = -EPERM;
105 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/m32r/kernel/ptrace.c
106     +++ linux-2.6.18-24etch4/arch/m32r/kernel/ptrace.c
107 kumaneko 2796 @@ -32,6 +32,7 @@
108 kumaneko 1498 #include <asm/system.h>
109     #include <asm/processor.h>
110     #include <asm/mmu_context.h>
111 kumaneko 2859 +#include <linux/ccsecurity.h>
112 kumaneko 1498
113     /*
114     * This routine will get a word off of the process kernel stack.
115 kumaneko 2796 @@ -742,6 +743,8 @@ asmlinkage long sys_ptrace(long request,
116 kumaneko 1498 {
117     struct task_struct *child;
118     int ret;
119 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
120 kumaneko 1498 + return -EPERM;
121    
122     lock_kernel();
123     if (request == PTRACE_TRACEME) {
124 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/mips/kernel/ptrace32.c
125     +++ linux-2.6.18-24etch4/arch/mips/kernel/ptrace32.c
126 kumaneko 2796 @@ -35,6 +35,7 @@
127 kumaneko 1498 #include <asm/system.h>
128     #include <asm/uaccess.h>
129     #include <asm/bootinfo.h>
130 kumaneko 2859 +#include <linux/ccsecurity.h>
131 kumaneko 1498
132     int ptrace_getregs (struct task_struct *child, __s64 __user *data);
133     int ptrace_setregs (struct task_struct *child, __s64 __user *data);
134 kumaneko 2796 @@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request,
135 kumaneko 1498 {
136     struct task_struct *child;
137     int ret;
138 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
139 kumaneko 1498 + return -EPERM;
140    
141     #if 0
142     printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
143 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/powerpc/kernel/ptrace32.c
144     +++ linux-2.6.18-24etch4/arch/powerpc/kernel/ptrace32.c
145 kumaneko 2796 @@ -32,6 +32,7 @@
146 kumaneko 1498 #include <asm/page.h>
147     #include <asm/pgtable.h>
148     #include <asm/system.h>
149 kumaneko 2859 +#include <linux/ccsecurity.h>
150 kumaneko 1498
151     #include "ptrace-common.h"
152    
153 kumaneko 2796 @@ -45,6 +46,8 @@ long compat_sys_ptrace(int request, int
154 kumaneko 1498 {
155     struct task_struct *child;
156     int ret;
157 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
158 kumaneko 1498 + return -EPERM;
159    
160     lock_kernel();
161     if (request == PTRACE_TRACEME) {
162 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/s390/kernel/ptrace.c
163     +++ linux-2.6.18-24etch4/arch/s390/kernel/ptrace.c
164 kumaneko 2796 @@ -41,6 +41,7 @@
165 kumaneko 1498 #include <asm/system.h>
166     #include <asm/uaccess.h>
167     #include <asm/unistd.h>
168 kumaneko 2859 +#include <linux/ccsecurity.h>
169 kumaneko 1498
170     #ifdef CONFIG_COMPAT
171     #include "compat_ptrace.h"
172 kumaneko 2796 @@ -711,6 +712,8 @@ sys_ptrace(long request, long pid, long
173 kumaneko 1498 struct task_struct *child;
174     int ret;
175    
176 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
177 kumaneko 1498 + return -EPERM;
178     lock_kernel();
179     if (request == PTRACE_TRACEME) {
180     ret = ptrace_traceme();
181 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/sparc/kernel/ptrace.c
182     +++ linux-2.6.18-24etch4/arch/sparc/kernel/ptrace.c
183 kumaneko 2796 @@ -23,6 +23,7 @@
184 kumaneko 1498 #include <asm/pgtable.h>
185     #include <asm/system.h>
186     #include <asm/uaccess.h>
187 kumaneko 2859 +#include <linux/ccsecurity.h>
188 kumaneko 1498
189     #define MAGIC_CONSTANT 0x80000000
190    
191 kumaneko 2796 @@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs
192 kumaneko 1498 unsigned long addr2 = regs->u_regs[UREG_I4];
193     struct task_struct *child;
194     int ret;
195 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE)) {
196 kumaneko 1498 + pt_error_return(regs, EPERM);
197     + return;
198     + }
199    
200     lock_kernel();
201     #ifdef DEBUG_PTRACE
202 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/sparc64/kernel/ptrace.c
203     +++ linux-2.6.18-24etch4/arch/sparc64/kernel/ptrace.c
204 kumaneko 2796 @@ -32,6 +32,7 @@
205 kumaneko 1498 #include <asm/spitfire.h>
206     #include <asm/page.h>
207     #include <asm/cpudata.h>
208 kumaneko 2859 +#include <linux/ccsecurity.h>
209 kumaneko 1498
210     /* Returning from ptrace is a bit tricky because the syscall return
211     * low level code assumes any value returned which is negative and
212 kumaneko 2796 @@ -176,6 +177,10 @@ asmlinkage void do_ptrace(struct pt_regs
213 kumaneko 1498 unsigned long addr2 = regs->u_regs[UREG_I4];
214     struct task_struct *child;
215     int ret;
216 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE)) {
217 kumaneko 1498 + pt_error_return(regs, EPERM);
218     + return;
219     + }
220    
221     if (test_thread_flag(TIF_32BIT)) {
222     addr &= 0xffffffffUL;
223 kumaneko 2949 --- linux-2.6.18-24etch4.orig/arch/x86_64/ia32/ptrace32.c
224     +++ linux-2.6.18-24etch4/arch/x86_64/ia32/ptrace32.c
225 kumaneko 2796 @@ -26,6 +26,7 @@
226 kumaneko 1498 #include <asm/i387.h>
227     #include <asm/fpu32.h>
228     #include <asm/ia32.h>
229 kumaneko 2859 +#include <linux/ccsecurity.h>
230 kumaneko 1498
231     /*
232     * Determines which flags the user has access to [1 = access, 0 = no access].
233 kumaneko 2796 @@ -230,6 +231,8 @@ asmlinkage long sys32_ptrace(long reques
234 kumaneko 1498 void __user *datap = compat_ptr(data);
235     int ret;
236     __u32 val;
237 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
238 kumaneko 1498 + return -EPERM;
239    
240     switch (request) {
241     case PTRACE_TRACEME:
242 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/compat.c
243     +++ linux-2.6.18-24etch4/fs/compat.c
244 kumaneko 2796 @@ -52,6 +52,7 @@
245 kumaneko 1498 #include <asm/uaccess.h>
246     #include <asm/mmu_context.h>
247     #include <asm/ioctls.h>
248 kumaneko 2859 +#include <linux/ccsecurity.h>
249 kumaneko 1498
250     extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
251    
252 kumaneko 2796 @@ -397,6 +398,8 @@ asmlinkage long compat_sys_ioctl(unsigne
253 kumaneko 2279
254     /* RED-PEN how should LSM module know it's handling 32bit? */
255     error = security_file_ioctl(filp, cmd, arg);
256     + if (!error)
257     + error = ccs_check_ioctl_permission(filp, cmd, arg);
258     if (error)
259     goto out_fput;
260    
261 kumaneko 2796 @@ -421,6 +424,10 @@ asmlinkage long compat_sys_ioctl(unsigne
262 kumaneko 1498 /*FALL THROUGH*/
263    
264     default:
265 kumaneko 2282 + if (!ccs_capable(CCS_SYS_IOCTL)) {
266 kumaneko 1498 + error = -EPERM;
267     + goto out_fput;
268     + }
269     if (filp->f_op && filp->f_op->compat_ioctl) {
270     error = filp->f_op->compat_ioctl(filp, cmd, arg);
271     if (error != -ENOIOCTLCMD)
272 kumaneko 2796 @@ -1567,7 +1574,7 @@ int compat_do_execve(char * filename,
273 kumaneko 1498 if (retval < 0)
274     goto out;
275    
276     - retval = search_binary_handler(bprm, regs);
277 kumaneko 2300 + retval = ccs_search_binary_handler(bprm, regs);
278 kumaneko 1498 if (retval >= 0) {
279     free_arg_pages(bprm);
280    
281 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/exec.c
282     +++ linux-2.6.18-24etch4/fs/exec.c
283 kumaneko 2796 @@ -57,6 +57,8 @@
284 kumaneko 1498 #include <linux/kmod.h>
285     #endif
286    
287 kumaneko 2859 +#include <linux/ccsecurity.h>
288 kumaneko 1498 +
289     int core_uses_pid;
290     char core_pattern[65] = "core";
291     int suid_dumpable = 0;
292 kumaneko 2796 @@ -139,6 +141,10 @@ asmlinkage long sys_uselib(const char __
293 kumaneko 1498 if (error)
294     goto exit;
295    
296 kumaneko 2922 + error = ccs_uselib_permission(nd.dentry, nd.mnt);
297 kumaneko 1498 + if (error)
298     + goto exit;
299     +
300     file = nameidata_to_filp(&nd, O_RDONLY);
301     error = PTR_ERR(file);
302     if (IS_ERR(file))
303 kumaneko 2796 @@ -486,6 +492,9 @@ struct file *open_exec(const char *name)
304 kumaneko 1498 if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
305     S_ISREG(inode->i_mode)) {
306     int err = vfs_permission(&nd, MAY_EXEC);
307 kumaneko 2306 + if (!err)
308 kumaneko 2922 + err = ccs_open_exec_permission(nd.dentry,
309 kumaneko 2306 + nd.mnt);
310 kumaneko 1498 file = ERR_PTR(err);
311     if (!err) {
312     file = nameidata_to_filp(&nd, O_RDONLY);
313 kumaneko 2796 @@ -1188,7 +1197,8 @@ int do_execve(char * filename,
314 kumaneko 1498 if (retval < 0)
315     goto out;
316    
317     - retval = search_binary_handler(bprm,regs);
318 kumaneko 2300 + retval = ccs_search_binary_handler(bprm, regs);
319 kumaneko 1498 +
320     if (retval >= 0) {
321     free_arg_pages(bprm);
322    
323 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/fcntl.c
324     +++ linux-2.6.18-24etch4/fs/fcntl.c
325 kumaneko 2796 @@ -22,6 +22,7 @@
326 kumaneko 1498 #include <asm/poll.h>
327     #include <asm/siginfo.h>
328     #include <asm/uaccess.h>
329 kumaneko 2859 +#include <linux/ccsecurity.h>
330 kumaneko 1498
331     void fastcall set_close_on_exec(unsigned int fd, int flag)
332     {
333 kumaneko 2922 @@ -214,6 +215,9 @@ static int setfl(int fd, struct file * f
334 kumaneko 1498 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
335     return -EPERM;
336    
337 kumaneko 2922 + if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp))
338 kumaneko 1498 + return -EPERM;
339     +
340     /* O_NOATIME can only be set by the owner or superuser */
341     if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
342     if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
343 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/ioctl.c
344     +++ linux-2.6.18-24etch4/fs/ioctl.c
345 kumaneko 2796 @@ -15,6 +15,7 @@
346 kumaneko 1498
347     #include <asm/uaccess.h>
348     #include <asm/ioctls.h>
349 kumaneko 2859 +#include <linux/ccsecurity.h>
350 kumaneko 1498
351     static long do_ioctl(struct file *filp, unsigned int cmd,
352     unsigned long arg)
353 kumaneko 2796 @@ -23,6 +24,8 @@ static long do_ioctl(struct file *filp,
354 kumaneko 1498
355     if (!filp->f_op)
356     goto out;
357 kumaneko 2282 + if (!ccs_capable(CCS_SYS_IOCTL))
358 kumaneko 1498 + return -EPERM;
359    
360     if (filp->f_op->unlocked_ioctl) {
361     error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
362 kumaneko 2796 @@ -167,6 +170,8 @@ asmlinkage long sys_ioctl(unsigned int f
363 kumaneko 2279 goto out;
364    
365     error = security_file_ioctl(filp, cmd, arg);
366     + if (!error)
367 kumaneko 2922 + error = ccs_ioctl_permission(filp, cmd, arg);
368 kumaneko 2279 if (error)
369     goto out_fput;
370    
371 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/namei.c
372     +++ linux-2.6.18-24etch4/fs/namei.c
373 kumaneko 2796 @@ -37,6 +37,8 @@
374 kumaneko 1498
375     #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
376    
377 kumaneko 2859 +#include <linux/ccsecurity.h>
378 kumaneko 1498 +
379     /* [Feb-1997 T. Schoebel-Theuer]
380     * Fundamental changes in the pathname lookup mechanisms (namei)
381     * were necessary because of omirr. The reason is that omirr needs
382 kumaneko 2796 @@ -1536,6 +1538,11 @@ int may_open(struct nameidata *nd, int a
383 kumaneko 1498 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
384     return -EPERM;
385    
386     + /* includes O_APPEND and O_TRUNC checks */
387 kumaneko 2922 + error = ccs_open_permission(dentry, nd->mnt, flag);
388 kumaneko 1498 + if (error)
389     + return error;
390     +
391     /*
392     * Ensure there are no outstanding leases on the file.
393     */
394 kumaneko 2796 @@ -1567,6 +1574,7 @@ int may_open(struct nameidata *nd, int a
395 kumaneko 1498 return 0;
396     }
397    
398 kumaneko 2859 +#include <linux/ccsecurity_vfs.h>
399 kumaneko 1498 /*
400     * open_namei()
401     *
402 kumaneko 2796 @@ -1650,6 +1658,9 @@ do_last:
403 kumaneko 2297 if (!path.dentry->d_inode) {
404     if (!IS_POSIXACL(dir->d_inode))
405     mode &= ~current->fs->umask;
406 kumaneko 2922 + error = ccs_mknod_permission(dir->d_inode, path.dentry,
407     + nd->mnt, mode, 0);
408 kumaneko 2297 + if (!error)
409     error = vfs_create(dir->d_inode, path.dentry, mode, nd);
410     mutex_unlock(&dir->d_inode->i_mutex);
411     dput(nd->dentry);
412 kumaneko 2922 @@ -1848,6 +1859,9 @@ asmlinkage long sys_mknodat(int dfd, con
413 kumaneko 2297 if (!IS_POSIXACL(nd.dentry->d_inode))
414     mode &= ~current->fs->umask;
415     if (!IS_ERR(dentry)) {
416 kumaneko 2922 + error = ccs_mknod_permission(nd.dentry->d_inode, dentry,
417     + nd.mnt, mode, dev);
418 kumaneko 2297 + if (!error)
419     switch (mode & S_IFMT) {
420     case 0: case S_IFREG:
421 kumaneko 1498 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
422 kumaneko 2922 @@ -1921,6 +1935,9 @@ asmlinkage long sys_mkdirat(int dfd, con
423 kumaneko 1498 if (!IS_ERR(dentry)) {
424     if (!IS_POSIXACL(nd.dentry->d_inode))
425     mode &= ~current->fs->umask;
426 kumaneko 2922 + error = ccs_mkdir_permission(nd.dentry->d_inode,
427     + dentry, nd.mnt, mode);
428 kumaneko 1498 + if (!error)
429     error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
430     dput(dentry);
431     }
432 kumaneko 2922 @@ -2029,6 +2046,9 @@ static long do_rmdir(int dfd, const char
433 kumaneko 1498 dentry = lookup_hash(&nd);
434     error = PTR_ERR(dentry);
435     if (!IS_ERR(dentry)) {
436 kumaneko 2922 + error = ccs_rmdir_permission(nd.dentry->d_inode, dentry,
437     + nd.mnt);
438 kumaneko 1498 + if (!error)
439     error = vfs_rmdir(nd.dentry->d_inode, dentry);
440     dput(dentry);
441     }
442 kumaneko 2922 @@ -2109,6 +2129,9 @@ static long do_unlinkat(int dfd, const c
443 kumaneko 1498 inode = dentry->d_inode;
444     if (inode)
445     atomic_inc(&inode->i_count);
446 kumaneko 2922 + error = ccs_unlink_permission(nd.dentry->d_inode, dentry,
447     + nd.mnt);
448 kumaneko 2297 + if (!error)
449 kumaneko 1498 error = vfs_unlink(nd.dentry->d_inode, dentry);
450     exit2:
451     dput(dentry);
452 kumaneko 2922 @@ -2187,6 +2210,9 @@ asmlinkage long sys_symlinkat(const char
453 kumaneko 1498 dentry = lookup_create(&nd, 0);
454     error = PTR_ERR(dentry);
455     if (!IS_ERR(dentry)) {
456 kumaneko 2922 + error = ccs_symlink_permission(nd.dentry->d_inode,
457     + dentry, nd.mnt, from);
458 kumaneko 1498 + if (!error)
459     error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
460     dput(dentry);
461     }
462 kumaneko 2922 @@ -2281,6 +2307,9 @@ asmlinkage long sys_linkat(int olddfd, c
463 kumaneko 1498 new_dentry = lookup_create(&nd, 0);
464     error = PTR_ERR(new_dentry);
465     if (!IS_ERR(new_dentry)) {
466 kumaneko 2922 + error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode,
467     + new_dentry, nd.mnt);
468 kumaneko 1498 + if (!error)
469     error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
470     dput(new_dentry);
471     }
472 kumaneko 2922 @@ -2507,6 +2536,9 @@ static int do_rename(int olddfd, const c
473 kumaneko 1498 if (new_dentry == trap)
474     goto exit5;
475    
476 kumaneko 2922 + error = ccs_rename_permission(old_dir->d_inode, old_dentry,
477     + new_dir->d_inode, new_dentry, newnd.mnt);
478 kumaneko 2297 + if (!error)
479 kumaneko 1498 error = vfs_rename(old_dir->d_inode, old_dentry,
480     new_dir->d_inode, new_dentry);
481     exit5:
482 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/namespace.c
483     +++ linux-2.6.18-24etch4/fs/namespace.c
484 kumaneko 2859 @@ -25,6 +25,7 @@
485 kumaneko 1498 #include <asm/uaccess.h>
486     #include <asm/unistd.h>
487     #include "pnode.h"
488 kumaneko 2859 +#include <linux/ccsecurity.h>
489 kumaneko 1498
490     extern int __init init_rootfs(void);
491    
492 kumaneko 3052 @@ -550,6 +551,8 @@ static int do_umount(struct vfsmount *mn
493     LIST_HEAD(umount_list);
494    
495     retval = security_sb_umount(mnt, flags);
496     + if (!retval)
497     + retval = ccs_umount_permission(mnt, flags);
498 kumaneko 1498 if (retval)
499     return retval;
500    
501 kumaneko 3052 @@ -641,6 +644,8 @@ asmlinkage long sys_umount(char __user *
502 kumaneko 1498 {
503     struct nameidata nd;
504     int retval;
505 kumaneko 2282 + if (!ccs_capable(CCS_SYS_UMOUNT))
506 kumaneko 1498 + return -EPERM;
507    
508     retval = __user_walk(name, LOOKUP_FOLLOW, &nd);
509     if (retval)
510 kumaneko 3052 @@ -925,6 +930,9 @@ static int do_loopback(struct nameidata
511 kumaneko 1498
512     if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
513     goto out;
514     + err = -EPERM;
515     + if (ccs_may_mount(nd))
516     + goto out;
517    
518     err = -ENOMEM;
519     if (recurse)
520 kumaneko 3052 @@ -1009,7 +1017,9 @@ static int do_move_mount(struct nameidat
521 kumaneko 1498 err = -EINVAL;
522     if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
523     goto out;
524     -
525     + err = -EPERM;
526 kumaneko 3009 + if (ccs_may_mount(nd))
527 kumaneko 1498 + goto out;
528     err = -ENOENT;
529     mutex_lock(&nd->dentry->d_inode->i_mutex);
530     if (IS_DEADDIR(nd->dentry->d_inode))
531 kumaneko 3052 @@ -1111,6 +1121,9 @@ int do_add_mount(struct vfsmount *newmnt
532 kumaneko 1498 err = -EINVAL;
533     if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode))
534     goto unlock;
535     + err = -EPERM;
536     + if (ccs_may_mount(nd))
537     + goto unlock;
538    
539     newmnt->mnt_flags = mnt_flags;
540     if ((err = graft_tree(newmnt, nd)))
541 kumaneko 3052 @@ -1384,6 +1397,7 @@ int copy_mount_options(const void __user
542     long do_mount(char *dev_name, char *dir_name, char *type_page,
543     unsigned long flags, void *data_page)
544     {
545     + const unsigned long original_flags = flags;
546     struct nameidata nd;
547     int retval = 0;
548     int mnt_flags = 0;
549     @@ -1423,6 +1437,9 @@ long do_mount(char *dev_name, char *dir_
550     return retval;
551 kumaneko 1498
552 kumaneko 3052 retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
553     + if (!retval)
554     + retval = ccs_mount_permission(dev_name, &nd, type_page,
555     + original_flags, data_page);
556     if (retval)
557     goto dput_out;
558 kumaneko 1498
559 kumaneko 3052 @@ -1691,6 +1708,8 @@ asmlinkage long sys_pivot_root(const cha
560    
561 kumaneko 1498 if (!capable(CAP_SYS_ADMIN))
562     return -EPERM;
563 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PIVOT_ROOT))
564 kumaneko 1498 + return -EPERM;
565    
566     lock_kernel();
567    
568 kumaneko 3052 @@ -1707,6 +1726,8 @@ asmlinkage long sys_pivot_root(const cha
569 kumaneko 1498 goto out1;
570    
571     error = security_sb_pivotroot(&old_nd, &new_nd);
572     + if (!error)
573 kumaneko 2922 + error = ccs_pivot_root_permission(&old_nd, &new_nd);
574 kumaneko 1498 if (error) {
575     path_release(&old_nd);
576     goto out1;
577 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/open.c
578     +++ linux-2.6.18-24etch4/fs/open.c
579 kumaneko 2859 @@ -30,6 +30,7 @@
580 kumaneko 1498 #include <linux/audit.h>
581    
582     #include <asm/unistd.h>
583 kumaneko 2859 +#include <linux/ccsecurity.h>
584 kumaneko 1498
585     int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
586     {
587 kumaneko 2859 @@ -267,6 +268,8 @@ static long do_sys_truncate(const char _
588 kumaneko 1498 if (error)
589     goto dput_and_out;
590    
591 kumaneko 2922 + error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0);
592 kumaneko 1498 + if (!error)
593     error = locks_verify_truncate(inode, NULL, length);
594     if (!error) {
595     DQUOT_INIT(inode);
596 kumaneko 2922 @@ -320,6 +323,9 @@ static long do_sys_ftruncate(unsigned in
597 kumaneko 1498 if (IS_APPEND(inode))
598     goto out_putf;
599    
600 kumaneko 2922 + error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0);
601 kumaneko 1498 + if (error)
602     + goto out_putf;
603     error = locks_verify_truncate(inode, file, length);
604     if (!error)
605     error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
606 kumaneko 2922 @@ -608,6 +614,10 @@ asmlinkage long sys_chroot(const char __
607 kumaneko 1498 error = -EPERM;
608     if (!capable(CAP_SYS_CHROOT))
609     goto dput_and_out;
610 kumaneko 2282 + if (!ccs_capable(CCS_SYS_CHROOT))
611 kumaneko 1498 + goto dput_and_out;
612 kumaneko 2922 + if (ccs_chroot_permission(&nd))
613 kumaneko 1498 + goto dput_and_out;
614    
615     set_fs_root(current->fs, nd.mnt, nd.dentry);
616     set_fs_altroot();
617 kumaneko 2922 @@ -641,6 +651,9 @@ asmlinkage long sys_fchmod(unsigned int
618 kumaneko 2869 err = -EPERM;
619     if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
620     goto out_putf;
621     + err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
622     + if (err)
623     + goto out_putf;
624     mutex_lock(&inode->i_mutex);
625     if (mode == (mode_t) -1)
626     mode = inode->i_mode;
627 kumaneko 2922 @@ -675,6 +688,9 @@ asmlinkage long sys_fchmodat(int dfd, co
628 kumaneko 2869 error = -EPERM;
629     if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
630     goto dput_and_out;
631     + error = ccs_chmod_permission(nd.dentry, nd.mnt, mode);
632     + if (error)
633     + goto dput_and_out;
634    
635     mutex_lock(&inode->i_mutex);
636     if (mode == (mode_t) -1)
637 kumaneko 2922 @@ -737,6 +753,8 @@ asmlinkage long sys_chown(const char __u
638 kumaneko 2869
639     error = user_path_walk(filename, &nd);
640     if (!error) {
641     + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
642     + if (!error)
643     error = chown_common(nd.dentry, user, group);
644     path_release(&nd);
645     }
646 kumaneko 2922 @@ -756,6 +774,8 @@ asmlinkage long sys_fchownat(int dfd, co
647 kumaneko 2869 follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
648     error = __user_walk_fd(dfd, filename, follow, &nd);
649     if (!error) {
650     + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
651     + if (!error)
652     error = chown_common(nd.dentry, user, group);
653     path_release(&nd);
654     }
655 kumaneko 2922 @@ -770,6 +790,8 @@ asmlinkage long sys_lchown(const char __
656 kumaneko 2869
657     error = user_path_walk_link(filename, &nd);
658     if (!error) {
659     + error = ccs_chown_permission(nd.dentry, nd.mnt, user, group);
660     + if (!error)
661     error = chown_common(nd.dentry, user, group);
662     path_release(&nd);
663     }
664 kumaneko 2922 @@ -787,6 +809,9 @@ asmlinkage long sys_fchown(unsigned int
665 kumaneko 2869 struct dentry * dentry;
666     dentry = file->f_dentry;
667     audit_inode(NULL, dentry->d_inode);
668     + error = ccs_chown_permission(dentry, file->f_vfsmnt, user,
669     + group);
670     + if (!error)
671     error = chown_common(dentry, user, group);
672     fput(file);
673     }
674 kumaneko 2950 @@ -879,7 +904,9 @@ static struct file *do_filp_open(int dfd
675     if ((namei_flags+1) & O_ACCMODE)
676     namei_flags++;
677    
678     + ccs_save_open_mode(flags);
679     error = open_namei(dfd, filename, namei_flags, mode, &nd);
680     + ccs_clear_open_mode();
681     if (!error)
682     return nameidata_to_filp(&nd, flags);
683    
684     @@ -1199,6 +1226,8 @@ EXPORT_SYMBOL(sys_close);
685 kumaneko 1498 */
686     asmlinkage long sys_vhangup(void)
687     {
688 kumaneko 2282 + if (!ccs_capable(CCS_SYS_VHANGUP))
689 kumaneko 1498 + return -EPERM;
690     if (capable(CAP_SYS_TTY_CONFIG)) {
691     tty_vhangup(current->signal->tty);
692     return 0;
693 kumaneko 2949 --- linux-2.6.18-24etch4.orig/fs/proc/proc_misc.c
694     +++ linux-2.6.18-24etch4/fs/proc/proc_misc.c
695 kumaneko 2796 @@ -723,4 +723,5 @@ void __init proc_misc_init(void)
696 kumaneko 1498 if (entry)
697     entry->proc_fops = &proc_sysrq_trigger_operations;
698     #endif
699 kumaneko 3075 + printk(KERN_INFO "Hook version: 2.6.18-24etch4 2009/10/01\n");
700 kumaneko 1498 }
701 kumaneko 2949 --- linux-2.6.18-24etch4.orig/include/linux/init_task.h
702     +++ linux-2.6.18-24etch4/include/linux/init_task.h
703 kumaneko 2926 @@ -76,6 +76,14 @@
704    
705     extern struct group_info init_groups;
706    
707     +#ifdef CONFIG_CCSECURITY
708     +#define INIT_CCSECURITY \
709     + .ccs_domain_info = NULL, \
710     + .ccs_flags = 0,
711     +#else
712     +#define INIT_CCSECURITY
713     +#endif
714     +
715     /*
716     * INIT_TASK is used to set up the first task table, touch at
717     * your own risk!. Base=0, limit=0x1fffff (=2MB)
718     @@ -128,6 +136,7 @@ extern struct group_info init_groups;
719 kumaneko 1498 .pi_lock = SPIN_LOCK_UNLOCKED, \
720     INIT_TRACE_IRQFLAGS \
721     INIT_LOCKDEP \
722 kumaneko 2926 + INIT_CCSECURITY \
723 kumaneko 1498 }
724    
725    
726 kumaneko 2949 --- linux-2.6.18-24etch4.orig/include/linux/sched.h
727     +++ linux-2.6.18-24etch4/include/linux/sched.h
728 kumaneko 2796 @@ -25,6 +25,8 @@
729 kumaneko 1498 #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
730     #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
731    
732 kumaneko 2282 +struct ccs_domain_info;
733 kumaneko 1498 +
734     /*
735     * Scheduling policies
736     */
737 kumaneko 2926 @@ -996,6 +998,10 @@ struct task_struct {
738 kumaneko 1498 #ifdef CONFIG_TASK_DELAY_ACCT
739     struct task_delay_info *delays;
740     #endif
741 kumaneko 2926 +#ifdef CONFIG_CCSECURITY
742 kumaneko 2282 + struct ccs_domain_info *ccs_domain_info;
743     + u32 ccs_flags;
744 kumaneko 2926 +#endif
745 kumaneko 1498 };
746    
747     static inline pid_t process_group(struct task_struct *tsk)
748 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/compat.c
749     +++ linux-2.6.18-24etch4/kernel/compat.c
750 kumaneko 2796 @@ -24,6 +24,7 @@
751 kumaneko 1498 #include <linux/migrate.h>
752    
753     #include <asm/uaccess.h>
754 kumaneko 2859 +#include <linux/ccsecurity.h>
755 kumaneko 1498
756     int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
757     {
758 kumaneko 2796 @@ -836,6 +837,8 @@ asmlinkage long compat_sys_stime(compat_
759 kumaneko 1498 err = security_settime(&tv, NULL);
760     if (err)
761     return err;
762 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
763 kumaneko 1498 + return -EPERM;
764    
765     do_settimeofday(&tv);
766     return 0;
767 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/kexec.c
768     +++ linux-2.6.18-24etch4/kernel/kexec.c
769 kumaneko 2796 @@ -26,6 +26,7 @@
770 kumaneko 1498 #include <asm/io.h>
771     #include <asm/system.h>
772     #include <asm/semaphore.h>
773 kumaneko 2859 +#include <linux/ccsecurity.h>
774 kumaneko 1498
775     /* Per cpu memory for storing cpu states in case of system crash. */
776     note_buf_t* crash_notes;
777 kumaneko 2796 @@ -922,6 +923,8 @@ asmlinkage long sys_kexec_load(unsigned
778 kumaneko 1498 /* We only trust the superuser with rebooting the system. */
779     if (!capable(CAP_SYS_BOOT))
780     return -EPERM;
781 kumaneko 2282 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
782 kumaneko 1498 + return -EPERM;
783    
784     /*
785     * Verify we have a legal set of flags
786 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/kmod.c
787     +++ linux-2.6.18-24etch4/kernel/kmod.c
788 kumaneko 2926 @@ -148,6 +148,11 @@ static int ____call_usermodehelper(void
789 kumaneko 1498 /* We can run anywhere, unlike our parent keventd(). */
790     set_cpus_allowed(current, CPU_MASK_ALL);
791    
792 kumaneko 2926 +#ifdef CONFIG_CCSECURITY
793 kumaneko 2282 + current->ccs_domain_info = NULL;
794     + current->ccs_flags = 0;
795 kumaneko 2926 +#endif
796 kumaneko 1498 +
797     retval = -EPERM;
798     if (current->fs->root)
799     retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
800 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/module.c
801     +++ linux-2.6.18-24etch4/kernel/module.c
802 kumaneko 2796 @@ -44,6 +44,7 @@
803 kumaneko 1498 #include <asm/semaphore.h>
804     #include <asm/cacheflush.h>
805     #include <linux/license.h>
806 kumaneko 2859 +#include <linux/ccsecurity.h>
807 kumaneko 1498
808     #if 0
809     #define DEBUGP printk
810 kumaneko 2796 @@ -652,7 +653,8 @@ sys_delete_module(const char __user *nam
811 kumaneko 1498
812     if (!capable(CAP_SYS_MODULE))
813     return -EPERM;
814     -
815 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
816 kumaneko 1498 + return -EPERM;
817     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
818     return -EFAULT;
819     name[MODULE_NAME_LEN-1] = '\0';
820 kumaneko 2796 @@ -1884,7 +1886,8 @@ sys_init_module(void __user *umod,
821 kumaneko 1498 /* Must have permission */
822     if (!capable(CAP_SYS_MODULE))
823     return -EPERM;
824     -
825 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
826 kumaneko 1498 + return -EPERM;
827     /* Only one module load at a time, please */
828     if (mutex_lock_interruptible(&module_mutex) != 0)
829     return -EINTR;
830 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/ptrace.c
831     +++ linux-2.6.18-24etch4/kernel/ptrace.c
832 kumaneko 2796 @@ -21,6 +21,7 @@
833 kumaneko 1498
834     #include <asm/pgtable.h>
835     #include <asm/uaccess.h>
836 kumaneko 2859 +#include <linux/ccsecurity.h>
837 kumaneko 1498
838     /*
839     * ptrace a task: make the debugger its new parent and
840 kumaneko 2796 @@ -509,6 +510,8 @@ asmlinkage long sys_ptrace(long request,
841 kumaneko 1498 /*
842     * This lock_kernel fixes a subtle race with suid exec
843     */
844 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
845 kumaneko 1498 + return -EPERM;
846     lock_kernel();
847     if (request == PTRACE_TRACEME) {
848     ret = ptrace_traceme();
849 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/sched.c
850     +++ linux-2.6.18-24etch4/kernel/sched.c
851 kumaneko 2796 @@ -55,6 +55,7 @@
852 kumaneko 1498 #include <asm/tlb.h>
853    
854     #include <asm/unistd.h>
855 kumaneko 2859 +#include <linux/ccsecurity.h>
856 kumaneko 1498
857     /*
858     * Convert user-nice values [ -20 ... 0 ... 19 ]
859 kumaneko 2796 @@ -3939,6 +3940,8 @@ int can_nice(const struct task_struct *p
860 kumaneko 1498 asmlinkage long sys_nice(int increment)
861     {
862     long nice, retval;
863 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE))
864 kumaneko 1498 + return -EPERM;
865    
866     /*
867     * Setpriority might change our priority at the same moment.
868 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/signal.c
869     +++ linux-2.6.18-24etch4/kernel/signal.c
870 kumaneko 2796 @@ -28,6 +28,7 @@
871 kumaneko 1498 #include <asm/unistd.h>
872     #include <asm/siginfo.h>
873     #include "audit.h" /* audit_signal_info() */
874 kumaneko 2859 +#include <linux/ccsecurity.h>
875 kumaneko 1498
876     /*
877     * SLAB caches for signal bits.
878 kumaneko 2851 @@ -2183,6 +2184,8 @@ asmlinkage long
879 kumaneko 1498 sys_kill(int pid, int sig)
880     {
881     struct siginfo info;
882 kumaneko 2851 + if (ccs_kill_permission(pid, sig))
883 kumaneko 1498 + return -EPERM;
884    
885     info.si_signo = sig;
886     info.si_errno = 0;
887 kumaneko 2851 @@ -2241,6 +2244,8 @@ asmlinkage long sys_tgkill(int tgid, int
888 kumaneko 1498 /* This is only valid for single tasks */
889     if (pid <= 0 || tgid <= 0)
890     return -EINVAL;
891 kumaneko 2851 + if (ccs_tgkill_permission(tgid, pid, sig))
892 kumaneko 1498 + return -EPERM;
893    
894     return do_tkill(tgid, pid, sig);
895     }
896 kumaneko 2851 @@ -2254,6 +2259,8 @@ sys_tkill(int pid, int sig)
897 kumaneko 1498 /* This is only valid for single tasks */
898     if (pid <= 0)
899     return -EINVAL;
900 kumaneko 2851 + if (ccs_tkill_permission(pid, sig))
901 kumaneko 1498 + return -EPERM;
902    
903     return do_tkill(0, pid, sig);
904     }
905 kumaneko 2869 @@ -2271,6 +2278,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
906     if (info.si_code >= 0)
907     return -EPERM;
908     info.si_signo = sig;
909     + if (ccs_sigqueue_permission(pid, sig))
910     + return -EPERM;
911    
912     /* POSIX.1b doesn't mention process groups. */
913     return kill_proc_info(sig, &info, pid);
914 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/sys.c
915     +++ linux-2.6.18-24etch4/kernel/sys.c
916 kumaneko 2796 @@ -36,6 +36,7 @@
917 kumaneko 1498 #include <asm/uaccess.h>
918     #include <asm/io.h>
919     #include <asm/unistd.h>
920 kumaneko 2859 +#include <linux/ccsecurity.h>
921 kumaneko 1498
922     #ifndef SET_UNALIGN_CTL
923     # define SET_UNALIGN_CTL(a,b) (-EINVAL)
924 kumaneko 2796 @@ -467,6 +468,10 @@ asmlinkage long sys_setpriority(int whic
925 kumaneko 1498
926     if (which > 2 || which < 0)
927     goto out;
928 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE)) {
929 kumaneko 1498 + error = -EPERM;
930     + goto out;
931     + }
932    
933     /* normalize: avoid signed division (rounding problems) */
934     error = -ESRCH;
935 kumaneko 2796 @@ -693,6 +698,8 @@ asmlinkage long sys_reboot(int magic1, i
936 kumaneko 1498 magic2 != LINUX_REBOOT_MAGIC2B &&
937     magic2 != LINUX_REBOOT_MAGIC2C))
938     return -EINVAL;
939 kumaneko 2282 + if (!ccs_capable(CCS_SYS_REBOOT))
940 kumaneko 1498 + return -EPERM;
941    
942     /* Instead of trying to make the power_off code look like
943     * halt when pm_power_off is not set do it the easy way.
944 kumaneko 2796 @@ -1690,6 +1697,8 @@ asmlinkage long sys_sethostname(char __u
945 kumaneko 1498 return -EPERM;
946     if (len < 0 || len > __NEW_UTS_LEN)
947     return -EINVAL;
948 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
949 kumaneko 1498 + return -EPERM;
950     down_write(&uts_sem);
951     errno = -EFAULT;
952     if (!copy_from_user(tmp, name, len)) {
953 kumaneko 2796 @@ -1735,6 +1744,8 @@ asmlinkage long sys_setdomainname(char _
954 kumaneko 1498 return -EPERM;
955     if (len < 0 || len > __NEW_UTS_LEN)
956     return -EINVAL;
957 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
958 kumaneko 1498 + return -EPERM;
959    
960     down_write(&uts_sem);
961     errno = -EFAULT;
962 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/sysctl.c
963     +++ linux-2.6.18-24etch4/kernel/sysctl.c
964 kumaneko 2796 @@ -48,6 +48,7 @@
965 kumaneko 1498
966     #include <asm/uaccess.h>
967     #include <asm/processor.h>
968 kumaneko 2859 +#include <linux/ccsecurity.h>
969 kumaneko 1498
970     extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
971     void __user *buffer, size_t *lenp, loff_t *ppos);
972 kumaneko 2796 @@ -1169,6 +1170,9 @@ int do_sysctl(int __user *name, int nlen
973 kumaneko 1498
974     spin_unlock(&sysctl_lock);
975    
976 kumaneko 2298 + error = ccs_parse_table(name, nlen, oldval, newval,
977 kumaneko 1498 + head->ctl_table);
978     + if (!error)
979     error = parse_table(name, nlen, oldval, oldlenp,
980     newval, newlen, head->ctl_table,
981     &context);
982 kumaneko 2796 @@ -1241,6 +1245,13 @@ repeat:
983 kumaneko 1498 if (ctl_perm(table, 001))
984     return -EPERM;
985     if (table->strategy) {
986     + int op = 0;
987     + if (oldval)
988     + op |= 004;
989     + if (newval)
990     + op |= 002;
991     + if (ctl_perm(table, op))
992     + return -EPERM;
993     error = table->strategy(
994     table, name, nlen,
995     oldval, oldlenp,
996 kumaneko 2949 --- linux-2.6.18-24etch4.orig/kernel/time.c
997     +++ linux-2.6.18-24etch4/kernel/time.c
998 kumaneko 2796 @@ -39,6 +39,7 @@
999 kumaneko 1498
1000     #include <asm/uaccess.h>
1001     #include <asm/unistd.h>
1002 kumaneko 2859 +#include <linux/ccsecurity.h>
1003 kumaneko 1498
1004     /*
1005     * The timezone where the local system is located. Used as a default by some
1006 kumaneko 2796 @@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user
1007 kumaneko 1498 err = security_settime(&tv, NULL);
1008     if (err)
1009     return err;
1010 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1011 kumaneko 1498 + return -EPERM;
1012    
1013     do_settimeofday(&tv);
1014     return 0;
1015 kumaneko 2796 @@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec
1016 kumaneko 1498 error = security_settime(tv, tz);
1017     if (error)
1018     return error;
1019 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1020 kumaneko 1498 + return -EPERM;
1021    
1022     if (tz) {
1023     /* SMP safe, global irq locking makes it work. */
1024 kumaneko 2796 @@ -221,6 +226,8 @@ int do_adjtimex(struct timex *txc)
1025 kumaneko 1498 /* In order to modify anything, you gotta be super-user! */
1026     if (txc->modes && !capable(CAP_SYS_TIME))
1027     return -EPERM;
1028 kumaneko 2282 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1029 kumaneko 1498 + return -EPERM;
1030    
1031     /* Now we validate the data before disabling interrupts */
1032    
1033 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/ipv4/inet_connection_sock.c
1034     +++ linux-2.6.18-24etch4/net/ipv4/inet_connection_sock.c
1035 kumaneko 2796 @@ -23,6 +23,7 @@
1036 kumaneko 1498 #include <net/route.h>
1037     #include <net/tcp_states.h>
1038     #include <net/xfrm.h>
1039 kumaneko 2859 +#include <linux/ccsecurity.h>
1040 kumaneko 1498
1041     #ifdef INET_CSK_DEBUG
1042     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1043 kumaneko 2796 @@ -87,6 +88,8 @@ int inet_csk_get_port(struct inet_hashin
1044 kumaneko 1498 do {
1045     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1046     spin_lock(&head->lock);
1047 kumaneko 2299 + if (ccs_lport_reserved(rover))
1048 kumaneko 1498 + goto next;
1049     inet_bind_bucket_for_each(tb, node, &head->chain)
1050     if (tb->port == rover)
1051     goto next;
1052 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/ipv4/inet_hashtables.c
1053     +++ linux-2.6.18-24etch4/net/ipv4/inet_hashtables.c
1054 kumaneko 2796 @@ -22,6 +22,7 @@
1055 kumaneko 1498 #include <net/inet_connection_sock.h>
1056     #include <net/inet_hashtables.h>
1057     #include <net/ip.h>
1058 kumaneko 2859 +#include <linux/ccsecurity.h>
1059 kumaneko 1498
1060     /*
1061     * Allocate and initialize a new local port bind bucket.
1062 kumaneko 2796 @@ -263,6 +264,8 @@ int inet_hash_connect(struct inet_timewa
1063 kumaneko 1498 local_bh_disable();
1064     for (i = 1; i <= range; i++) {
1065     port = low + (i + offset) % range;
1066 kumaneko 2299 + if (ccs_lport_reserved(port))
1067 kumaneko 1498 + continue;
1068     head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1069     spin_lock(&head->lock);
1070    
1071 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/ipv4/raw.c
1072     +++ linux-2.6.18-24etch4/net/ipv4/raw.c
1073 kumaneko 2796 @@ -79,6 +79,7 @@
1074 kumaneko 2459 #include <linux/seq_file.h>
1075     #include <linux/netfilter.h>
1076     #include <linux/netfilter_ipv4.h>
1077 kumaneko 2859 +#include <linux/ccsecurity.h>
1078 kumaneko 2459
1079     struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1080     DEFINE_RWLOCK(raw_v4_lock);
1081 kumaneko 2796 @@ -592,6 +593,9 @@ static int raw_recvmsg(struct kiocb *ioc
1082 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1083     if (!skb)
1084     goto out;
1085     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1086     + if (err)
1087     + goto out;
1088    
1089     copied = skb->len;
1090     if (len < copied) {
1091 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/ipv4/udp.c
1092     +++ linux-2.6.18-24etch4/net/ipv4/udp.c
1093 kumaneko 2859 @@ -108,6 +108,7 @@
1094 kumaneko 1498 #include <net/inet_common.h>
1095     #include <net/checksum.h>
1096     #include <net/xfrm.h>
1097 kumaneko 2859 +#include <linux/ccsecurity.h>
1098 kumaneko 1498
1099     /*
1100     * Snmp MIB for the UDP layer
1101 kumaneko 2859 @@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock *
1102 kumaneko 1498 result = sysctl_local_port_range[0] +
1103     ((result - sysctl_local_port_range[0]) &
1104     (UDP_HTABLE_SIZE - 1));
1105 kumaneko 2299 + if (ccs_lport_reserved(result))
1106 kumaneko 1498 + continue;
1107     goto gotit;
1108     }
1109     size = 0;
1110 kumaneko 2859 @@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock *
1111 kumaneko 1498 result = sysctl_local_port_range[0]
1112     + ((result - sysctl_local_port_range[0]) &
1113     (UDP_HTABLE_SIZE - 1));
1114 kumaneko 2299 + if (ccs_lport_reserved(result))
1115 kumaneko 1498 + continue;
1116     if (!udp_lport_inuse(result))
1117     break;
1118     }
1119 kumaneko 2859 @@ -796,7 +801,10 @@ try_again:
1120 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1121     if (!skb)
1122     goto out;
1123     -
1124     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1125     + if (err)
1126     + goto out;
1127     +
1128     copied = skb->len - sizeof(struct udphdr);
1129     if (copied > len) {
1130     copied = len;
1131 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/ipv6/inet6_hashtables.c
1132     +++ linux-2.6.18-24etch4/net/ipv6/inet6_hashtables.c
1133 kumaneko 2796 @@ -21,6 +21,7 @@
1134 kumaneko 1498 #include <net/inet_hashtables.h>
1135     #include <net/inet6_hashtables.h>
1136     #include <net/ip.h>
1137 kumaneko 2859 +#include <linux/ccsecurity.h>
1138 kumaneko 1498
1139     void __inet6_hash(struct inet_hashinfo *hashinfo,
1140     struct sock *sk)
1141 kumaneko 2796 @@ -172,7 +173,7 @@ static int __inet6_check_established(str
1142 kumaneko 1498 const struct in6_addr *saddr = &np->daddr;
1143     const int dif = sk->sk_bound_dev_if;
1144     const u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
1145     - const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr,
1146     + const unsigned int hash = inet6_ehashfn(daddr, lport, saddr,
1147     inet->dport);
1148     struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
1149     struct sock *sk2;
1150 kumaneko 2796 @@ -266,6 +267,8 @@ int inet6_hash_connect(struct inet_timew
1151 kumaneko 1498 local_bh_disable();
1152     for (i = 1; i <= range; i++) {
1153     port = low + (i + offset) % range;
1154 kumaneko 2299 + if (ccs_lport_reserved(port))
1155 kumaneko 1498 + continue;
1156     head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1157     spin_lock(&head->lock);
1158    
1159 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/ipv6/raw.c
1160     +++ linux-2.6.18-24etch4/net/ipv6/raw.c
1161 kumaneko 2796 @@ -56,6 +56,7 @@
1162 kumaneko 2459
1163     #include <linux/proc_fs.h>
1164     #include <linux/seq_file.h>
1165 kumaneko 2859 +#include <linux/ccsecurity.h>
1166 kumaneko 2459
1167     struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1168     DEFINE_RWLOCK(raw_v6_lock);
1169 kumaneko 2796 @@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i
1170 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1171     if (!skb)
1172     goto out;
1173     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1174     + if (err)
1175     + goto out;
1176    
1177     copied = skb->len;
1178     if (copied > len) {
1179 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/ipv6/udp.c
1180     +++ linux-2.6.18-24etch4/net/ipv6/udp.c
1181 kumaneko 2859 @@ -58,6 +58,7 @@
1182 kumaneko 1498
1183     #include <linux/proc_fs.h>
1184     #include <linux/seq_file.h>
1185 kumaneko 2859 +#include <linux/ccsecurity.h>
1186 kumaneko 1498
1187     DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1188    
1189 kumaneko 2859 @@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock *
1190 kumaneko 1498 result = sysctl_local_port_range[0] +
1191     ((result - sysctl_local_port_range[0]) &
1192     (UDP_HTABLE_SIZE - 1));
1193 kumaneko 2299 + if (ccs_lport_reserved(result))
1194 kumaneko 1498 + continue;
1195     goto gotit;
1196     }
1197     size = 0;
1198 kumaneko 2859 @@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock *
1199 kumaneko 1498 result = sysctl_local_port_range[0]
1200     + ((result - sysctl_local_port_range[0]) &
1201     (UDP_HTABLE_SIZE - 1));
1202 kumaneko 2299 + if (ccs_lport_reserved(result))
1203 kumaneko 1498 + continue;
1204     if (!udp_lport_inuse(result))
1205     break;
1206     }
1207 kumaneko 2859 @@ -237,6 +242,9 @@ try_again:
1208 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1209     if (!skb)
1210     goto out;
1211     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1212     + if (err)
1213     + goto out;
1214    
1215     copied = skb->len - sizeof(struct udphdr);
1216     if (copied > len) {
1217 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/socket.c
1218     +++ linux-2.6.18-24etch4/net/socket.c
1219 kumaneko 2859 @@ -94,6 +94,8 @@
1220 kumaneko 1498 #include <net/sock.h>
1221     #include <linux/netfilter.h>
1222    
1223 kumaneko 2859 +#include <linux/ccsecurity.h>
1224 kumaneko 1498 +
1225     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1226     static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
1227     size_t size, loff_t pos);
1228 kumaneko 3075 @@ -590,9 +592,10 @@ static inline int __sock_sendmsg(struct
1229 kumaneko 2805 si->size = size;
1230    
1231 kumaneko 1498 err = security_socket_sendmsg(sock, msg, size);
1232 kumaneko 2805 + if (!err)
1233 kumaneko 3075 + err = ccs_socket_sendmsg_permission(sock, msg, size);
1234 kumaneko 1498 if (err)
1235     return err;
1236     -
1237     return sock->ops->sendmsg(iocb, sock, msg, size);
1238     }
1239    
1240 kumaneko 3075 @@ -1149,6 +1152,8 @@ static int __sock_create(int family, int
1241 kumaneko 1498 }
1242    
1243     err = security_socket_create(family, type, protocol, kern);
1244 kumaneko 2805 + if (!err)
1245     + err = ccs_socket_create_permission(family, type, protocol);
1246 kumaneko 1498 if (err)
1247     return err;
1248 kumaneko 2805
1249 kumaneko 3075 @@ -1343,6 +1348,11 @@ asmlinkage long sys_bind(int fd, struct
1250 kumaneko 1498 if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
1251     err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);
1252 kumaneko 2796 if (!err)
1253 kumaneko 1498 + err = ccs_socket_bind_permission(sock,
1254     + (struct sockaddr *)
1255     + address,
1256     + addrlen);
1257 kumaneko 2796 + if (!err)
1258 kumaneko 1498 err = sock->ops->bind(sock,
1259     (struct sockaddr *)address, addrlen);
1260 kumaneko 2796 }
1261 kumaneko 3075 @@ -1371,6 +1381,8 @@ asmlinkage long sys_listen(int fd, int b
1262 kumaneko 1498
1263     err = security_socket_listen(sock, backlog);
1264 kumaneko 2796 if (!err)
1265     + err = ccs_socket_listen_permission(sock);
1266 kumaneko 1498 + if (!err)
1267     err = sock->ops->listen(sock, backlog);
1268    
1269 kumaneko 2796 fput_light(sock->file, fput_needed);
1270 kumaneko 3075 @@ -1434,6 +1446,11 @@ asmlinkage long sys_accept(int fd, struc
1271 kumaneko 1498 if (err < 0)
1272     goto out_fd;
1273    
1274     + if (ccs_socket_accept_permission(newsock,
1275     + (struct sockaddr *) address)) {
1276     + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1277     + goto out_fd;
1278     + }
1279     if (upeer_sockaddr) {
1280     if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
1281     err = -ECONNABORTED;
1282 kumaneko 3075 @@ -1488,9 +1505,11 @@ asmlinkage long sys_connect(int fd, stru
1283 kumaneko 2805 goto out_put;
1284    
1285 kumaneko 1498 err = security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1286 kumaneko 2805 + if (!err)
1287     + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1288     + address, addrlen);
1289 kumaneko 1498 if (err)
1290     goto out_put;
1291     -
1292     err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen,
1293     sock->file->f_flags);
1294     out_put:
1295 kumaneko 2949 --- linux-2.6.18-24etch4.orig/net/unix/af_unix.c
1296     +++ linux-2.6.18-24etch4/net/unix/af_unix.c
1297 kumaneko 2796 @@ -116,6 +116,7 @@
1298 kumaneko 1498 #include <linux/mount.h>
1299     #include <net/checksum.h>
1300     #include <linux/security.h>
1301 kumaneko 2859 +#include <linux/ccsecurity.h>
1302 kumaneko 1498
1303     int sysctl_unix_max_dgram_qlen = 10;
1304    
1305 kumaneko 2796 @@ -807,6 +808,9 @@ static int unix_bind(struct socket *sock
1306 kumaneko 1498 */
1307     mode = S_IFSOCK |
1308     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1309 kumaneko 2922 + err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1310     + mode, 0);
1311 kumaneko 1498 + if (!err)
1312     err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1313     if (err)
1314     goto out_mknod_dput;
1315 kumaneko 2949 --- linux-2.6.18-24etch4.orig/security/Kconfig
1316     +++ linux-2.6.18-24etch4/security/Kconfig
1317 kumaneko 2858 @@ -107,5 +107,7 @@ config SECURITY_SECLVL
1318    
1319     source security/selinux/Kconfig
1320    
1321     +source security/ccsecurity/Kconfig
1322     +
1323     endmenu
1324    
1325 kumaneko 2949 --- linux-2.6.18-24etch4.orig/security/Makefile
1326     +++ linux-2.6.18-24etch4/security/Makefile
1327 kumaneko 2858 @@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin
1328     obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o
1329     obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o
1330     obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o
1331     +
1332     +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1333     +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

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