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

Subversion リポジトリの参照

Annotation of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.21.diff

Parent Directory Parent Directory | Revision Log Revision Log


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

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