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

Subversion リポジトリの参照

Annotation of /trunk/1.8.x/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3054 - (hide annotations) (download) (as text)
Fri Sep 18 04:30:43 2009 UTC (14 years, 8 months ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/patches/ccs-patch-2.6.16-vine-linux-4.2.diff
File MIME type: text/x-diff
File size: 40400 byte(s)


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

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