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

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 3009 - (hide annotations) (download) (as text)
Thu Sep 10 05:40:52 2009 UTC (14 years, 8 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: 38701 byte(s)


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 kumaneko 2950 fs/open.c | 28 ++++++++++++++++++++++++++++
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 2950 43 files changed, 279 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 3009 + if (ccs_may_mount(nd))
553 kumaneko 1128 + 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 2950 @@ -756,7 +780,9 @@ static struct file *do_filp_open(int dfd
693     if ((namei_flags+1) & O_ACCMODE)
694     namei_flags++;
695    
696     + ccs_save_open_mode(flags);
697     error = open_namei(dfd, filename, namei_flags, mode, &nd);
698     + ccs_clear_open_mode();
699     if (!error)
700     return nameidata_to_filp(&nd, flags);
701    
702     @@ -1085,6 +1111,8 @@ EXPORT_SYMBOL(sys_close);
703 kumaneko 193 */
704     asmlinkage long sys_vhangup(void)
705     {
706 kumaneko 2282 + if (!ccs_capable(CCS_SYS_VHANGUP))
707 kumaneko 1128 + return -EPERM;
708 kumaneko 193 if (capable(CAP_SYS_TTY_CONFIG)) {
709     /* XXX: this needs locking */
710     tty_vhangup(current->signal->tty);
711 kumaneko 1498 --- linux-2.6.21.7.orig/fs/proc/proc_misc.c
712     +++ linux-2.6.21.7/fs/proc/proc_misc.c
713 kumaneko 2796 @@ -747,4 +747,5 @@ void __init proc_misc_init(void)
714 kumaneko 193 entry->proc_fops = &proc_sysrq_trigger_operations;
715     }
716     #endif
717 kumaneko 3009 + printk(KERN_INFO "Hook version: 2.6.21.7 2009/09/10\n");
718 kumaneko 193 }
719 kumaneko 1498 --- linux-2.6.21.7.orig/include/linux/init_task.h
720     +++ linux-2.6.21.7/include/linux/init_task.h
721 kumaneko 2926 @@ -88,6 +88,14 @@ extern struct nsproxy init_nsproxy;
722    
723     extern struct group_info init_groups;
724    
725     +#ifdef CONFIG_CCSECURITY
726     +#define INIT_CCSECURITY \
727     + .ccs_domain_info = NULL, \
728     + .ccs_flags = 0,
729     +#else
730     +#define INIT_CCSECURITY
731     +#endif
732     +
733     /*
734     * INIT_TASK is used to set up the first task table, touch at
735     * your own risk!. Base=0, limit=0x1fffff (=2MB)
736     @@ -141,6 +149,7 @@ extern struct group_info init_groups;
737 kumaneko 193 .pi_lock = SPIN_LOCK_UNLOCKED, \
738     INIT_TRACE_IRQFLAGS \
739     INIT_LOCKDEP \
740 kumaneko 2926 + INIT_CCSECURITY \
741 kumaneko 193 }
742    
743    
744 kumaneko 1498 --- linux-2.6.21.7.orig/include/linux/sched.h
745     +++ linux-2.6.21.7/include/linux/sched.h
746 kumaneko 2796 @@ -27,6 +27,8 @@
747 kumaneko 193 #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
748     #define CLONE_NEWIPC 0x08000000 /* New ipcs */
749    
750 kumaneko 2282 +struct ccs_domain_info;
751 kumaneko 193 +
752     /*
753     * Scheduling policies
754     */
755 kumaneko 2926 @@ -1052,6 +1054,10 @@ struct task_struct {
756 kumaneko 193 #ifdef CONFIG_FAULT_INJECTION
757     int make_it_fail;
758     #endif
759 kumaneko 2926 +#ifdef CONFIG_CCSECURITY
760 kumaneko 2282 + struct ccs_domain_info *ccs_domain_info;
761     + u32 ccs_flags;
762 kumaneko 2926 +#endif
763 kumaneko 193 };
764    
765     static inline pid_t process_group(struct task_struct *tsk)
766 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/compat.c
767     +++ linux-2.6.21.7/kernel/compat.c
768 kumaneko 2796 @@ -25,6 +25,7 @@
769 kumaneko 290 #include <linux/posix-timers.h>
770    
771     #include <asm/uaccess.h>
772 kumaneko 2859 +#include <linux/ccsecurity.h>
773 kumaneko 290
774     int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
775     {
776 kumaneko 2796 @@ -869,6 +870,8 @@ asmlinkage long compat_sys_stime(compat_
777 kumaneko 290 err = security_settime(&tv, NULL);
778     if (err)
779     return err;
780 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
781 kumaneko 1128 + return -EPERM;
782 kumaneko 290
783     do_settimeofday(&tv);
784     return 0;
785 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/kexec.c
786     +++ linux-2.6.21.7/kernel/kexec.c
787 kumaneko 2796 @@ -28,6 +28,7 @@
788 kumaneko 193 #include <asm/io.h>
789     #include <asm/system.h>
790     #include <asm/semaphore.h>
791 kumaneko 2859 +#include <linux/ccsecurity.h>
792 kumaneko 193
793     /* Per cpu memory for storing cpu states in case of system crash. */
794     note_buf_t* crash_notes;
795 kumaneko 2796 @@ -924,6 +925,8 @@ asmlinkage long sys_kexec_load(unsigned
796 kumaneko 193 /* We only trust the superuser with rebooting the system. */
797     if (!capable(CAP_SYS_BOOT))
798     return -EPERM;
799 kumaneko 2282 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
800 kumaneko 1128 + return -EPERM;
801 kumaneko 193
802     /*
803     * Verify we have a legal set of flags
804 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/kmod.c
805     +++ linux-2.6.21.7/kernel/kmod.c
806 kumaneko 2926 @@ -166,6 +166,11 @@ static int ____call_usermodehelper(void
807 kumaneko 193 /* We can run anywhere, unlike our parent keventd(). */
808     set_cpus_allowed(current, CPU_MASK_ALL);
809    
810 kumaneko 2926 +#ifdef CONFIG_CCSECURITY
811 kumaneko 2282 + current->ccs_domain_info = NULL;
812     + current->ccs_flags = 0;
813 kumaneko 2926 +#endif
814 kumaneko 193 +
815     retval = -EPERM;
816     if (current->fs->root)
817     retval = kernel_execve(sub_info->path,
818 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/module.c
819     +++ linux-2.6.21.7/kernel/module.c
820 kumaneko 2796 @@ -44,6 +44,7 @@
821 kumaneko 193 #include <asm/semaphore.h>
822     #include <asm/cacheflush.h>
823     #include <linux/license.h>
824 kumaneko 2859 +#include <linux/ccsecurity.h>
825 kumaneko 193
826     #if 0
827     #define DEBUGP printk
828 kumaneko 2796 @@ -662,6 +663,8 @@ sys_delete_module(const char __user *nam
829 kumaneko 193
830     if (!capable(CAP_SYS_MODULE))
831     return -EPERM;
832 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
833 kumaneko 1128 + return -EPERM;
834 kumaneko 193
835     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
836     return -EFAULT;
837 kumaneko 2796 @@ -1983,6 +1986,8 @@ sys_init_module(void __user *umod,
838 kumaneko 193 /* Must have permission */
839     if (!capable(CAP_SYS_MODULE))
840     return -EPERM;
841 kumaneko 2282 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
842 kumaneko 1128 + return -EPERM;
843 kumaneko 193
844     /* Only one module load at a time, please */
845     if (mutex_lock_interruptible(&module_mutex) != 0)
846 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/ptrace.c
847     +++ linux-2.6.21.7/kernel/ptrace.c
848 kumaneko 2796 @@ -21,6 +21,7 @@
849 kumaneko 863
850     #include <asm/pgtable.h>
851     #include <asm/uaccess.h>
852 kumaneko 2859 +#include <linux/ccsecurity.h>
853 kumaneko 863
854     /*
855     * ptrace a task: make the debugger its new parent and
856 kumaneko 2796 @@ -456,6 +457,8 @@ asmlinkage long sys_ptrace(long request,
857 kumaneko 863 /*
858     * This lock_kernel fixes a subtle race with suid exec
859     */
860 kumaneko 2282 + if (!ccs_capable(CCS_SYS_PTRACE))
861 kumaneko 1128 + return -EPERM;
862 kumaneko 863 lock_kernel();
863     if (request == PTRACE_TRACEME) {
864     ret = ptrace_traceme();
865 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/sched.c
866     +++ linux-2.6.21.7/kernel/sched.c
867 kumaneko 2796 @@ -55,6 +55,7 @@
868 kumaneko 193 #include <asm/tlb.h>
869    
870     #include <asm/unistd.h>
871 kumaneko 2859 +#include <linux/ccsecurity.h>
872 kumaneko 193
873     /*
874     * Scheduler clock - returns current time in nanosec units.
875 kumaneko 2796 @@ -3964,6 +3965,8 @@ int can_nice(const struct task_struct *p
876 kumaneko 193 asmlinkage long sys_nice(int increment)
877     {
878     long nice, retval;
879 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE))
880 kumaneko 1128 + return -EPERM;
881 kumaneko 193
882     /*
883     * Setpriority might change our priority at the same moment.
884 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/signal.c
885     +++ linux-2.6.21.7/kernel/signal.c
886 kumaneko 2796 @@ -32,6 +32,7 @@
887 kumaneko 193 #include <asm/unistd.h>
888     #include <asm/siginfo.h>
889     #include "audit.h" /* audit_signal_info() */
890 kumaneko 2859 +#include <linux/ccsecurity.h>
891 kumaneko 193
892     /*
893     * SLAB caches for signal bits.
894 kumaneko 2851 @@ -2235,6 +2236,8 @@ asmlinkage long
895 kumaneko 193 sys_kill(int pid, int sig)
896     {
897     struct siginfo info;
898 kumaneko 2851 + if (ccs_kill_permission(pid, sig))
899 kumaneko 1128 + return -EPERM;
900 kumaneko 193
901     info.si_signo = sig;
902     info.si_errno = 0;
903 kumaneko 2851 @@ -2293,6 +2296,8 @@ asmlinkage long sys_tgkill(int tgid, int
904 kumaneko 193 /* This is only valid for single tasks */
905     if (pid <= 0 || tgid <= 0)
906     return -EINVAL;
907 kumaneko 2851 + if (ccs_tgkill_permission(tgid, pid, sig))
908 kumaneko 1128 + return -EPERM;
909 kumaneko 193
910     return do_tkill(tgid, pid, sig);
911     }
912 kumaneko 2851 @@ -2306,6 +2311,8 @@ sys_tkill(int pid, int sig)
913 kumaneko 193 /* This is only valid for single tasks */
914     if (pid <= 0)
915     return -EINVAL;
916 kumaneko 2851 + if (ccs_tkill_permission(pid, sig))
917 kumaneko 1128 + return -EPERM;
918 kumaneko 193
919     return do_tkill(0, pid, sig);
920     }
921 kumaneko 2869 @@ -2323,6 +2330,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si
922     if (info.si_code >= 0)
923     return -EPERM;
924     info.si_signo = sig;
925     + if (ccs_sigqueue_permission(pid, sig))
926     + return -EPERM;
927    
928     /* POSIX.1b doesn't mention process groups. */
929     return kill_proc_info(sig, &info, pid);
930 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/sys.c
931     +++ linux-2.6.21.7/kernel/sys.c
932 kumaneko 2796 @@ -37,6 +37,7 @@
933 kumaneko 193 #include <asm/uaccess.h>
934     #include <asm/io.h>
935     #include <asm/unistd.h>
936 kumaneko 2859 +#include <linux/ccsecurity.h>
937 kumaneko 193
938     #ifndef SET_UNALIGN_CTL
939     # define SET_UNALIGN_CTL(a,b) (-EINVAL)
940 kumaneko 2796 @@ -600,6 +601,10 @@ asmlinkage long sys_setpriority(int whic
941 kumaneko 193
942     if (which > 2 || which < 0)
943     goto out;
944 kumaneko 2282 + if (!ccs_capable(CCS_SYS_NICE)) {
945 kumaneko 1151 + error = -EPERM;
946     + goto out;
947     + }
948 kumaneko 193
949     /* normalize: avoid signed division (rounding problems) */
950     error = -ESRCH;
951 kumaneko 2796 @@ -830,6 +835,8 @@ asmlinkage long sys_reboot(int magic1, i
952 kumaneko 193 magic2 != LINUX_REBOOT_MAGIC2B &&
953     magic2 != LINUX_REBOOT_MAGIC2C))
954     return -EINVAL;
955 kumaneko 2282 + if (!ccs_capable(CCS_SYS_REBOOT))
956 kumaneko 1128 + return -EPERM;
957 kumaneko 193
958     /* Instead of trying to make the power_off code look like
959     * halt when pm_power_off is not set do it the easy way.
960 kumaneko 2796 @@ -1806,6 +1813,8 @@ asmlinkage long sys_sethostname(char __u
961 kumaneko 193 return -EPERM;
962     if (len < 0 || len > __NEW_UTS_LEN)
963     return -EINVAL;
964 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
965 kumaneko 1128 + return -EPERM;
966 kumaneko 193 down_write(&uts_sem);
967     errno = -EFAULT;
968     if (!copy_from_user(tmp, name, len)) {
969 kumaneko 2796 @@ -1851,6 +1860,8 @@ asmlinkage long sys_setdomainname(char _
970 kumaneko 193 return -EPERM;
971     if (len < 0 || len > __NEW_UTS_LEN)
972     return -EINVAL;
973 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
974 kumaneko 1128 + return -EPERM;
975 kumaneko 193
976     down_write(&uts_sem);
977     errno = -EFAULT;
978 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/sysctl.c
979     +++ linux-2.6.21.7/kernel/sysctl.c
980 kumaneko 2796 @@ -48,6 +48,7 @@
981 kumaneko 193
982     #include <asm/uaccess.h>
983     #include <asm/processor.h>
984 kumaneko 2859 +#include <linux/ccsecurity.h>
985 kumaneko 193
986     extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
987     void __user *buffer, size_t *lenp, loff_t *ppos);
988 kumaneko 2796 @@ -1088,6 +1089,7 @@ struct ctl_table_header *sysctl_head_nex
989 kumaneko 193 }
990    
991     #ifdef CONFIG_SYSCTL_SYSCALL
992     +
993     int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
994     void __user *newval, size_t newlen)
995     {
996 kumaneko 2796 @@ -1104,6 +1106,9 @@ int do_sysctl(int __user *name, int nlen
997 kumaneko 193
998     for (head = sysctl_head_next(NULL); head;
999     head = sysctl_head_next(head)) {
1000 kumaneko 2298 + error = ccs_parse_table(name, nlen, oldval, newval,
1001 kumaneko 1128 + head->ctl_table);
1002     + if (!error)
1003 kumaneko 193 error = parse_table(name, nlen, oldval, oldlenp,
1004     newval, newlen, head->ctl_table);
1005     if (error != -ENOTDIR) {
1006 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/time.c
1007     +++ linux-2.6.21.7/kernel/time.c
1008 kumaneko 2796 @@ -39,6 +39,7 @@
1009 kumaneko 193
1010     #include <asm/uaccess.h>
1011     #include <asm/unistd.h>
1012 kumaneko 2859 +#include <linux/ccsecurity.h>
1013 kumaneko 193
1014     /*
1015     * The timezone where the local system is located. Used as a default by some
1016 kumaneko 2796 @@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user
1017 kumaneko 193 err = security_settime(&tv, NULL);
1018     if (err)
1019     return err;
1020 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1021 kumaneko 1128 + return -EPERM;
1022 kumaneko 193
1023     do_settimeofday(&tv);
1024     return 0;
1025 kumaneko 2796 @@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec
1026 kumaneko 193 error = security_settime(tv, tz);
1027     if (error)
1028     return error;
1029 kumaneko 2282 + if (!ccs_capable(CCS_SYS_SETTIME))
1030 kumaneko 1128 + return -EPERM;
1031 kumaneko 193
1032     if (tz) {
1033     /* SMP safe, global irq locking makes it work. */
1034 kumaneko 1498 --- linux-2.6.21.7.orig/kernel/time/ntp.c
1035     +++ linux-2.6.21.7/kernel/time/ntp.c
1036 kumaneko 2796 @@ -14,6 +14,7 @@
1037 kumaneko 862
1038     #include <asm/div64.h>
1039     #include <asm/timex.h>
1040 kumaneko 2859 +#include <linux/ccsecurity.h>
1041 kumaneko 862
1042     /*
1043     * Timekeeping variables
1044 kumaneko 2796 @@ -201,6 +202,8 @@ int do_adjtimex(struct timex *txc)
1045 kumaneko 862 /* In order to modify anything, you gotta be super-user! */
1046     if (txc->modes && !capable(CAP_SYS_TIME))
1047     return -EPERM;
1048 kumaneko 2282 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
1049 kumaneko 1128 + return -EPERM;
1050 kumaneko 862
1051     /* Now we validate the data before disabling interrupts */
1052    
1053 kumaneko 1498 --- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c
1054     +++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c
1055 kumaneko 2796 @@ -23,6 +23,7 @@
1056 kumaneko 193 #include <net/route.h>
1057     #include <net/tcp_states.h>
1058     #include <net/xfrm.h>
1059 kumaneko 2859 +#include <linux/ccsecurity.h>
1060 kumaneko 193
1061     #ifdef INET_CSK_DEBUG
1062     const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
1063 kumaneko 2796 @@ -85,6 +86,8 @@ int inet_csk_get_port(struct inet_hashin
1064 kumaneko 193 do {
1065     head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];
1066     spin_lock(&head->lock);
1067 kumaneko 2299 + if (ccs_lport_reserved(rover))
1068 kumaneko 1128 + goto next;
1069 kumaneko 193 inet_bind_bucket_for_each(tb, node, &head->chain)
1070     if (tb->port == rover)
1071     goto next;
1072 kumaneko 1498 --- linux-2.6.21.7.orig/net/ipv4/inet_hashtables.c
1073     +++ linux-2.6.21.7/net/ipv4/inet_hashtables.c
1074 kumaneko 2796 @@ -22,6 +22,7 @@
1075 kumaneko 193 #include <net/inet_connection_sock.h>
1076     #include <net/inet_hashtables.h>
1077     #include <net/ip.h>
1078 kumaneko 2859 +#include <linux/ccsecurity.h>
1079 kumaneko 193
1080     /*
1081     * Allocate and initialize a new local port bind bucket.
1082 kumaneko 2796 @@ -292,6 +293,8 @@ int inet_hash_connect(struct inet_timewa
1083 kumaneko 193 local_bh_disable();
1084     for (i = 1; i <= range; i++) {
1085     port = low + (i + offset) % range;
1086 kumaneko 2299 + if (ccs_lport_reserved(port))
1087 kumaneko 1128 + continue;
1088 kumaneko 193 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1089     spin_lock(&head->lock);
1090    
1091 kumaneko 2459 --- linux-2.6.21.7.orig/net/ipv4/raw.c
1092     +++ linux-2.6.21.7/net/ipv4/raw.c
1093 kumaneko 2796 @@ -78,6 +78,7 @@
1094 kumaneko 2459 #include <linux/seq_file.h>
1095     #include <linux/netfilter.h>
1096     #include <linux/netfilter_ipv4.h>
1097 kumaneko 2859 +#include <linux/ccsecurity.h>
1098 kumaneko 2459
1099     struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
1100     DEFINE_RWLOCK(raw_v4_lock);
1101 kumaneko 2796 @@ -597,6 +598,9 @@ static int raw_recvmsg(struct kiocb *ioc
1102 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1103     if (!skb)
1104     goto out;
1105     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1106     + if (err)
1107     + goto out;
1108    
1109     copied = skb->len;
1110     if (len < copied) {
1111 kumaneko 1498 --- linux-2.6.21.7.orig/net/ipv4/udp.c
1112     +++ linux-2.6.21.7/net/ipv4/udp.c
1113 kumaneko 2859 @@ -102,6 +102,7 @@
1114 kumaneko 193 #include <net/checksum.h>
1115     #include <net/xfrm.h>
1116     #include "udp_impl.h"
1117 kumaneko 2859 +#include <linux/ccsecurity.h>
1118 kumaneko 193
1119     /*
1120     * Snmp MIB for the UDP layer
1121 kumaneko 2859 @@ -162,6 +163,8 @@ int __udp_lib_get_port(struct sock *sk,
1122 kumaneko 237 result = sysctl_local_port_range[0] +
1123     ((result - sysctl_local_port_range[0]) &
1124     (UDP_HTABLE_SIZE - 1));
1125 kumaneko 2299 + if (ccs_lport_reserved(result))
1126 kumaneko 1128 + continue;
1127 kumaneko 237 goto gotit;
1128     }
1129     size = 0;
1130 kumaneko 2859 @@ -180,6 +183,8 @@ int __udp_lib_get_port(struct sock *sk,
1131 kumaneko 193 result = sysctl_local_port_range[0]
1132     + ((result - sysctl_local_port_range[0]) &
1133     (UDP_HTABLE_SIZE - 1));
1134 kumaneko 2299 + if (ccs_lport_reserved(result))
1135 kumaneko 1128 + continue;
1136 kumaneko 193 if (! __udp_lib_lport_inuse(result, udptable))
1137     break;
1138     }
1139 kumaneko 2859 @@ -825,6 +830,9 @@ try_again:
1140 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1141     if (!skb)
1142     goto out;
1143     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1144     + if (err)
1145     + goto out;
1146    
1147     copied = skb->len - sizeof(struct udphdr);
1148     if (copied > len) {
1149 kumaneko 1498 --- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c
1150     +++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c
1151 kumaneko 2796 @@ -21,6 +21,7 @@
1152 kumaneko 193 #include <net/inet_hashtables.h>
1153     #include <net/inet6_hashtables.h>
1154     #include <net/ip.h>
1155 kumaneko 2859 +#include <linux/ccsecurity.h>
1156 kumaneko 193
1157     void __inet6_hash(struct inet_hashinfo *hashinfo,
1158     struct sock *sk)
1159 kumaneko 2796 @@ -266,6 +267,8 @@ int inet6_hash_connect(struct inet_timew
1160 kumaneko 193 local_bh_disable();
1161     for (i = 1; i <= range; i++) {
1162     port = low + (i + offset) % range;
1163 kumaneko 2299 + if (ccs_lport_reserved(port))
1164 kumaneko 1128 + continue;
1165 kumaneko 193 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
1166     spin_lock(&head->lock);
1167    
1168 kumaneko 2459 --- linux-2.6.21.7.orig/net/ipv6/raw.c
1169     +++ linux-2.6.21.7/net/ipv6/raw.c
1170 kumaneko 2796 @@ -58,6 +58,7 @@
1171 kumaneko 2459
1172     #include <linux/proc_fs.h>
1173     #include <linux/seq_file.h>
1174 kumaneko 2859 +#include <linux/ccsecurity.h>
1175 kumaneko 2459
1176     struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
1177     DEFINE_RWLOCK(raw_v6_lock);
1178 kumaneko 2796 @@ -413,6 +414,9 @@ static int rawv6_recvmsg(struct kiocb *i
1179 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1180     if (!skb)
1181     goto out;
1182     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1183     + if (err)
1184     + goto out;
1185    
1186     copied = skb->len;
1187     if (copied > len) {
1188     --- linux-2.6.21.7.orig/net/ipv6/udp.c
1189     +++ linux-2.6.21.7/net/ipv6/udp.c
1190 kumaneko 2796 @@ -49,6 +49,7 @@
1191 kumaneko 2459 #include <linux/proc_fs.h>
1192     #include <linux/seq_file.h>
1193     #include "udp_impl.h"
1194 kumaneko 2859 +#include <linux/ccsecurity.h>
1195 kumaneko 2459
1196     DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
1197    
1198 kumaneko 2796 @@ -133,6 +134,9 @@ try_again:
1199 kumaneko 2459 skb = skb_recv_datagram(sk, flags, noblock, &err);
1200     if (!skb)
1201     goto out;
1202     + err = ccs_socket_recvmsg_permission(sk, skb, flags);
1203     + if (err)
1204     + goto out;
1205    
1206     copied = skb->len - sizeof(struct udphdr);
1207     if (copied > len) {
1208 kumaneko 1498 --- linux-2.6.21.7.orig/net/socket.c
1209     +++ linux-2.6.21.7/net/socket.c
1210 kumaneko 2859 @@ -93,6 +93,8 @@
1211 kumaneko 193 #include <net/sock.h>
1212     #include <linux/netfilter.h>
1213    
1214 kumaneko 2859 +#include <linux/ccsecurity.h>
1215 kumaneko 193 +
1216     static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
1217     static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
1218     unsigned long nr_segs, loff_t pos);
1219 kumaneko 2859 @@ -547,6 +549,10 @@ static inline int __sock_sendmsg(struct
1220 kumaneko 2805 si->size = size;
1221    
1222 kumaneko 193 err = security_socket_sendmsg(sock, msg, size);
1223 kumaneko 2805 + if (!err)
1224     + err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *)
1225     + msg->msg_name,
1226     + msg->msg_namelen);
1227 kumaneko 193 if (err)
1228     return err;
1229    
1230 kumaneko 2859 @@ -1071,6 +1077,8 @@ static int __sock_create(int family, int
1231 kumaneko 193 }
1232    
1233     err = security_socket_create(family, type, protocol, kern);
1234 kumaneko 2805 + if (!err)
1235     + err = ccs_socket_create_permission(family, type, protocol);
1236 kumaneko 193 if (err)
1237     return err;
1238 kumaneko 2805
1239 kumaneko 2859 @@ -1299,6 +1307,11 @@ asmlinkage long sys_bind(int fd, struct
1240 kumaneko 193 (struct sockaddr *)address,
1241     addrlen);
1242 kumaneko 2796 if (!err)
1243 kumaneko 1128 + err = ccs_socket_bind_permission(sock,
1244     + (struct sockaddr *)
1245     + address,
1246     + addrlen);
1247 kumaneko 2796 + if (!err)
1248 kumaneko 193 err = sock->ops->bind(sock,
1249     (struct sockaddr *)
1250 kumaneko 2796 address, addrlen);
1251 kumaneko 2859 @@ -1328,6 +1341,8 @@ asmlinkage long sys_listen(int fd, int b
1252 kumaneko 193
1253     err = security_socket_listen(sock, backlog);
1254 kumaneko 2796 if (!err)
1255     + err = ccs_socket_listen_permission(sock);
1256 kumaneko 1128 + if (!err)
1257 kumaneko 193 err = sock->ops->listen(sock, backlog);
1258    
1259 kumaneko 2796 fput_light(sock->file, fput_needed);
1260 kumaneko 2859 @@ -1391,6 +1406,11 @@ asmlinkage long sys_accept(int fd, struc
1261 kumaneko 193 if (err < 0)
1262     goto out_fd;
1263    
1264 kumaneko 1128 + if (ccs_socket_accept_permission(newsock,
1265     + (struct sockaddr *) address)) {
1266 kumaneko 193 + err = -ECONNABORTED; /* Hope less harmful than -EPERM. */
1267     + goto out_fd;
1268     + }
1269     if (upeer_sockaddr) {
1270     if (newsock->ops->getname(newsock, (struct sockaddr *)address,
1271     &len, 2) < 0) {
1272 kumaneko 2859 @@ -1453,6 +1473,9 @@ asmlinkage long sys_connect(int fd, stru
1273 kumaneko 2805
1274     err =
1275 kumaneko 193 security_socket_connect(sock, (struct sockaddr *)address, addrlen);
1276 kumaneko 2805 + if (!err)
1277     + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
1278     + address, addrlen);
1279 kumaneko 193 if (err)
1280     goto out_put;
1281    
1282 kumaneko 1498 --- linux-2.6.21.7.orig/net/unix/af_unix.c
1283     +++ linux-2.6.21.7/net/unix/af_unix.c
1284 kumaneko 2796 @@ -116,6 +116,7 @@
1285 kumaneko 193 #include <linux/mount.h>
1286     #include <net/checksum.h>
1287     #include <linux/security.h>
1288 kumaneko 2859 +#include <linux/ccsecurity.h>
1289 kumaneko 193
1290     int sysctl_unix_max_dgram_qlen __read_mostly = 10;
1291    
1292 kumaneko 2796 @@ -808,6 +809,9 @@ static int unix_bind(struct socket *sock
1293 kumaneko 193 */
1294     mode = S_IFSOCK |
1295     (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
1296 kumaneko 2922 + err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt,
1297     + mode, 0);
1298 kumaneko 1128 + if (!err)
1299 kumaneko 193 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
1300     if (err)
1301     goto out_mknod_dput;
1302 kumaneko 2858 --- linux-2.6.21.7.orig/security/Kconfig
1303     +++ linux-2.6.21.7/security/Kconfig
1304     @@ -95,5 +95,7 @@ config SECURITY_ROOTPLUG
1305    
1306     source security/selinux/Kconfig
1307    
1308     +source security/ccsecurity/Kconfig
1309     +
1310     endmenu
1311    
1312     --- linux-2.6.21.7.orig/security/Makefile
1313     +++ linux-2.6.21.7/security/Makefile
1314     @@ -16,3 +16,6 @@ obj-$(CONFIG_SECURITY) += security.o d
1315     obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o
1316     obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o
1317     obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o
1318     +
1319     +subdir-$(CONFIG_CCSECURITY)+= ccsecurity
1320     +obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o

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