12 |
arch/sparc/kernel/ptrace.c | 5 +++++ |
arch/sparc/kernel/ptrace.c | 5 +++++ |
13 |
arch/sparc64/kernel/ptrace.c | 5 +++++ |
arch/sparc64/kernel/ptrace.c | 5 +++++ |
14 |
arch/x86_64/ia32/ptrace32.c | 3 +++ |
arch/x86_64/ia32/ptrace32.c | 3 +++ |
|
fs/Kconfig | 2 ++ |
|
|
fs/Makefile | 2 ++ |
|
|
fs/attr.c | 5 +++++ |
|
15 |
fs/compat.c | 9 ++++++++- |
fs/compat.c | 9 ++++++++- |
16 |
fs/exec.c | 12 +++++++++++- |
fs/exec.c | 12 +++++++++++- |
17 |
fs/fcntl.c | 5 +++++ |
fs/fcntl.c | 4 ++++ |
18 |
fs/ioctl.c | 5 +++++ |
fs/ioctl.c | 5 +++++ |
19 |
fs/namei.c | 38 ++++++++++++++++++++++++++++++++++++++ |
fs/namei.c | 32 ++++++++++++++++++++++++++++++++ |
20 |
fs/namespace.c | 28 +++++++++++++++++++++++++++- |
fs/namespace.c | 21 ++++++++++++++++++++- |
21 |
fs/open.c | 14 ++++++++++++++ |
fs/open.c | 27 +++++++++++++++++++++++++++ |
|
fs/proc/Makefile | 3 +++ |
|
22 |
fs/proc/proc_misc.c | 1 + |
fs/proc/proc_misc.c | 1 + |
23 |
include/linux/init_task.h | 2 ++ |
include/linux/init_task.h | 9 +++++++++ |
24 |
include/linux/sched.h | 4 ++++ |
include/linux/sched.h | 6 ++++++ |
25 |
kernel/compat.c | 3 +++ |
kernel/compat.c | 3 +++ |
26 |
kernel/kexec.c | 3 +++ |
kernel/kexec.c | 3 +++ |
27 |
kernel/kmod.c | 3 +++ |
kernel/kmod.c | 5 +++++ |
28 |
kernel/module.c | 7 +++++-- |
kernel/module.c | 7 +++++-- |
29 |
kernel/ptrace.c | 3 +++ |
kernel/ptrace.c | 3 +++ |
30 |
kernel/sched.c | 3 +++ |
kernel/sched.c | 3 +++ |
31 |
kernel/signal.c | 7 +++++++ |
kernel/signal.c | 9 +++++++++ |
32 |
kernel/sys.c | 11 +++++++++++ |
kernel/sys.c | 11 +++++++++++ |
33 |
kernel/sysctl.c | 11 +++++++++++ |
kernel/sysctl.c | 11 +++++++++++ |
34 |
kernel/time.c | 7 +++++++ |
kernel/time.c | 7 +++++++ |
35 |
net/ipv4/inet_connection_sock.c | 3 +++ |
net/ipv4/inet_connection_sock.c | 3 +++ |
36 |
net/ipv4/inet_hashtables.c | 3 +++ |
net/ipv4/inet_hashtables.c | 3 +++ |
37 |
net/ipv4/raw.c | 4 ++++ |
net/ipv4/raw.c | 12 +++++++++--- |
38 |
net/ipv4/udp.c | 11 ++++++++++- |
net/ipv4/udp.c | 16 ++++++++++++++-- |
39 |
net/ipv6/inet6_hashtables.c | 5 ++++- |
net/ipv6/inet6_hashtables.c | 5 ++++- |
40 |
net/ipv6/raw.c | 4 ++++ |
net/ipv6/raw.c | 12 +++++++++--- |
41 |
net/ipv6/udp.c | 9 +++++++++ |
net/ipv6/udp.c | 14 +++++++++++++- |
42 |
net/socket.c | 26 ++++++++++++++++++++++++-- |
net/socket.c | 24 ++++++++++++++++++++++-- |
43 |
net/unix/af_unix.c | 4 ++++ |
net/unix/af_unix.c | 4 ++++ |
44 |
43 files changed, 282 insertions(+), 9 deletions(-) |
security/Kconfig | 2 ++ |
45 |
|
security/Makefile | 3 +++ |
46 |
|
41 files changed, 303 insertions(+), 17 deletions(-) |
47 |
|
|
48 |
--- linux-2.6.18-24etch2.orig/arch/alpha/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/alpha/kernel/ptrace.c |
49 |
+++ linux-2.6.18-24etch2/arch/alpha/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/alpha/kernel/ptrace.c |
50 |
@@ -20,6 +20,7 @@ |
@@ -20,6 +20,7 @@ |
51 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
52 |
#include <asm/system.h> |
#include <asm/system.h> |
53 |
#include <asm/fpu.h> |
#include <asm/fpu.h> |
54 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
55 |
|
|
56 |
#include "proto.h" |
#include "proto.h" |
57 |
|
|
59 |
unsigned long tmp; |
unsigned long tmp; |
60 |
size_t copied; |
size_t copied; |
61 |
long ret; |
long ret; |
62 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
63 |
+ return -EPERM; |
+ return -EPERM; |
64 |
|
|
65 |
lock_kernel(); |
lock_kernel(); |
66 |
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
67 |
--- linux-2.6.18-24etch2.orig/arch/ia64/ia32/sys_ia32.c |
--- linux-2.6.18-26etch2.orig/arch/ia64/ia32/sys_ia32.c |
68 |
+++ linux-2.6.18-24etch2/arch/ia64/ia32/sys_ia32.c |
+++ linux-2.6.18-26etch2/arch/ia64/ia32/sys_ia32.c |
69 |
@@ -56,6 +56,7 @@ |
@@ -56,6 +56,7 @@ |
70 |
#include <asm/types.h> |
#include <asm/types.h> |
71 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
72 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
73 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
74 |
|
|
75 |
#include "ia32priv.h" |
#include "ia32priv.h" |
76 |
|
|
78 |
struct task_struct *child; |
struct task_struct *child; |
79 |
unsigned int value, tmp; |
unsigned int value, tmp; |
80 |
long i, ret; |
long i, ret; |
81 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
82 |
+ return -EPERM; |
+ return -EPERM; |
83 |
|
|
84 |
lock_kernel(); |
lock_kernel(); |
85 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
86 |
--- linux-2.6.18-24etch2.orig/arch/ia64/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/ia64/kernel/ptrace.c |
87 |
+++ linux-2.6.18-24etch2/arch/ia64/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/ia64/kernel/ptrace.c |
88 |
@@ -28,6 +28,7 @@ |
@@ -28,6 +28,7 @@ |
89 |
#ifdef CONFIG_PERFMON |
#ifdef CONFIG_PERFMON |
90 |
#include <asm/perfmon.h> |
#include <asm/perfmon.h> |
91 |
#endif |
#endif |
92 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
93 |
|
|
94 |
#include "entry.h" |
#include "entry.h" |
95 |
|
|
97 |
struct task_struct *child; |
struct task_struct *child; |
98 |
struct switch_stack *sw; |
struct switch_stack *sw; |
99 |
long ret; |
long ret; |
100 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
101 |
+ return -EPERM; |
+ return -EPERM; |
102 |
|
|
103 |
lock_kernel(); |
lock_kernel(); |
104 |
ret = -EPERM; |
ret = -EPERM; |
105 |
--- linux-2.6.18-24etch2.orig/arch/m32r/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/m32r/kernel/ptrace.c |
106 |
+++ linux-2.6.18-24etch2/arch/m32r/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/m32r/kernel/ptrace.c |
107 |
@@ -32,6 +32,7 @@ |
@@ -32,6 +32,7 @@ |
108 |
#include <asm/system.h> |
#include <asm/system.h> |
109 |
#include <asm/processor.h> |
#include <asm/processor.h> |
110 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
111 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
112 |
|
|
113 |
/* |
/* |
114 |
* This routine will get a word off of the process kernel stack. |
* This routine will get a word off of the process kernel stack. |
116 |
{ |
{ |
117 |
struct task_struct *child; |
struct task_struct *child; |
118 |
int ret; |
int ret; |
119 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
120 |
+ return -EPERM; |
+ return -EPERM; |
121 |
|
|
122 |
lock_kernel(); |
lock_kernel(); |
123 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
124 |
--- linux-2.6.18-24etch2.orig/arch/mips/kernel/ptrace32.c |
--- linux-2.6.18-26etch2.orig/arch/mips/kernel/ptrace32.c |
125 |
+++ linux-2.6.18-24etch2/arch/mips/kernel/ptrace32.c |
+++ linux-2.6.18-26etch2/arch/mips/kernel/ptrace32.c |
126 |
@@ -35,6 +35,7 @@ |
@@ -35,6 +35,7 @@ |
127 |
#include <asm/system.h> |
#include <asm/system.h> |
128 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
129 |
#include <asm/bootinfo.h> |
#include <asm/bootinfo.h> |
130 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
131 |
|
|
132 |
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
133 |
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
135 |
{ |
{ |
136 |
struct task_struct *child; |
struct task_struct *child; |
137 |
int ret; |
int ret; |
138 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
139 |
+ return -EPERM; |
+ return -EPERM; |
140 |
|
|
141 |
#if 0 |
#if 0 |
142 |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
143 |
--- linux-2.6.18-24etch2.orig/arch/powerpc/kernel/ptrace32.c |
--- linux-2.6.18-26etch2.orig/arch/powerpc/kernel/ptrace32.c |
144 |
+++ linux-2.6.18-24etch2/arch/powerpc/kernel/ptrace32.c |
+++ linux-2.6.18-26etch2/arch/powerpc/kernel/ptrace32.c |
145 |
@@ -32,6 +32,7 @@ |
@@ -32,6 +32,7 @@ |
146 |
#include <asm/page.h> |
#include <asm/page.h> |
147 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
148 |
#include <asm/system.h> |
#include <asm/system.h> |
149 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
150 |
|
|
151 |
#include "ptrace-common.h" |
#include "ptrace-common.h" |
152 |
|
|
154 |
{ |
{ |
155 |
struct task_struct *child; |
struct task_struct *child; |
156 |
int ret; |
int ret; |
157 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
158 |
+ return -EPERM; |
+ return -EPERM; |
159 |
|
|
160 |
lock_kernel(); |
lock_kernel(); |
161 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
162 |
--- linux-2.6.18-24etch2.orig/arch/s390/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/s390/kernel/ptrace.c |
163 |
+++ linux-2.6.18-24etch2/arch/s390/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/s390/kernel/ptrace.c |
164 |
@@ -41,6 +41,7 @@ |
@@ -41,6 +41,7 @@ |
165 |
#include <asm/system.h> |
#include <asm/system.h> |
166 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
167 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
168 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
169 |
|
|
170 |
#ifdef CONFIG_COMPAT |
#ifdef CONFIG_COMPAT |
171 |
#include "compat_ptrace.h" |
#include "compat_ptrace.h" |
173 |
struct task_struct *child; |
struct task_struct *child; |
174 |
int ret; |
int ret; |
175 |
|
|
176 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
177 |
+ return -EPERM; |
+ return -EPERM; |
178 |
lock_kernel(); |
lock_kernel(); |
179 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
180 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
181 |
--- linux-2.6.18-24etch2.orig/arch/sparc/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/sparc/kernel/ptrace.c |
182 |
+++ linux-2.6.18-24etch2/arch/sparc/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/sparc/kernel/ptrace.c |
183 |
@@ -23,6 +23,7 @@ |
@@ -23,6 +23,7 @@ |
184 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
185 |
#include <asm/system.h> |
#include <asm/system.h> |
186 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
187 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
188 |
|
|
189 |
#define MAGIC_CONSTANT 0x80000000 |
#define MAGIC_CONSTANT 0x80000000 |
190 |
|
|
192 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
193 |
struct task_struct *child; |
struct task_struct *child; |
194 |
int ret; |
int ret; |
195 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
+ if (ccs_ptrace_permission(request, pid)) { |
196 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
197 |
+ return; |
+ return; |
198 |
+ } |
+ } |
199 |
|
|
200 |
lock_kernel(); |
lock_kernel(); |
201 |
#ifdef DEBUG_PTRACE |
#ifdef DEBUG_PTRACE |
202 |
--- linux-2.6.18-24etch2.orig/arch/sparc64/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/sparc64/kernel/ptrace.c |
203 |
+++ linux-2.6.18-24etch2/arch/sparc64/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/sparc64/kernel/ptrace.c |
204 |
@@ -32,6 +32,7 @@ |
@@ -32,6 +32,7 @@ |
205 |
#include <asm/spitfire.h> |
#include <asm/spitfire.h> |
206 |
#include <asm/page.h> |
#include <asm/page.h> |
207 |
#include <asm/cpudata.h> |
#include <asm/cpudata.h> |
208 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
209 |
|
|
210 |
/* Returning from ptrace is a bit tricky because the syscall return |
/* Returning from ptrace is a bit tricky because the syscall return |
211 |
* low level code assumes any value returned which is negative and |
* low level code assumes any value returned which is negative and |
213 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
214 |
struct task_struct *child; |
struct task_struct *child; |
215 |
int ret; |
int ret; |
216 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
+ if (ccs_ptrace_permission(request, pid)) { |
217 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
218 |
+ return; |
+ return; |
219 |
+ } |
+ } |
220 |
|
|
221 |
if (test_thread_flag(TIF_32BIT)) { |
if (test_thread_flag(TIF_32BIT)) { |
222 |
addr &= 0xffffffffUL; |
addr &= 0xffffffffUL; |
223 |
--- linux-2.6.18-24etch2.orig/arch/x86_64/ia32/ptrace32.c |
--- linux-2.6.18-26etch2.orig/arch/x86_64/ia32/ptrace32.c |
224 |
+++ linux-2.6.18-24etch2/arch/x86_64/ia32/ptrace32.c |
+++ linux-2.6.18-26etch2/arch/x86_64/ia32/ptrace32.c |
225 |
@@ -26,6 +26,7 @@ |
@@ -26,6 +26,7 @@ |
226 |
#include <asm/i387.h> |
#include <asm/i387.h> |
227 |
#include <asm/fpu32.h> |
#include <asm/fpu32.h> |
228 |
#include <asm/ia32.h> |
#include <asm/ia32.h> |
229 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
230 |
|
|
231 |
/* |
/* |
232 |
* Determines which flags the user has access to [1 = access, 0 = no access]. |
* Determines which flags the user has access to [1 = access, 0 = no access]. |
234 |
void __user *datap = compat_ptr(data); |
void __user *datap = compat_ptr(data); |
235 |
int ret; |
int ret; |
236 |
__u32 val; |
__u32 val; |
237 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
238 |
+ return -EPERM; |
+ return -EPERM; |
239 |
|
|
240 |
switch (request) { |
switch (request) { |
241 |
case PTRACE_TRACEME: |
case PTRACE_TRACEME: |
242 |
--- linux-2.6.18-24etch2.orig/fs/Kconfig |
--- linux-2.6.18-26etch2.orig/fs/compat.c |
243 |
+++ linux-2.6.18-24etch2/fs/Kconfig |
+++ linux-2.6.18-26etch2/fs/compat.c |
|
@@ -1931,5 +1931,7 @@ endmenu |
|
|
|
|
|
source "fs/nls/Kconfig" |
|
|
|
|
|
+source "fs/Kconfig.ccs" |
|
|
+ |
|
|
endmenu |
|
|
|
|
|
--- linux-2.6.18-24etch2.orig/fs/Makefile |
|
|
+++ linux-2.6.18-24etch2/fs/Makefile |
|
|
@@ -102,3 +102,5 @@ obj-$(CONFIG_HOSTFS) += hostfs/ |
|
|
obj-$(CONFIG_HPPFS) += hppfs/ |
|
|
obj-$(CONFIG_DEBUG_FS) += debugfs/ |
|
|
obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
|
|
+ |
|
|
+include $(srctree)/fs/Makefile-2.6.ccs |
|
|
--- linux-2.6.18-24etch2.orig/fs/attr.c |
|
|
+++ linux-2.6.18-24etch2/fs/attr.c |
|
|
@@ -15,6 +15,7 @@ |
|
|
#include <linux/fcntl.h> |
|
|
#include <linux/quotaops.h> |
|
|
#include <linux/security.h> |
|
|
+#include <linux/tomoyo.h> |
|
|
|
|
|
/* Taken over from the old code... */ |
|
|
|
|
|
@@ -146,11 +147,15 @@ int notify_change(struct dentry * dentry |
|
|
if (inode->i_op && inode->i_op->setattr) { |
|
|
error = security_inode_setattr(dentry, attr); |
|
|
if (!error) |
|
|
+ error = ccs_check_setattr_permission(dentry, attr); |
|
|
+ if (!error) |
|
|
error = inode->i_op->setattr(dentry, attr); |
|
|
} else { |
|
|
error = inode_change_ok(inode, attr); |
|
|
if (!error) |
|
|
error = security_inode_setattr(dentry, attr); |
|
|
+ if (!error) |
|
|
+ error = ccs_check_setattr_permission(dentry, attr); |
|
|
if (!error) { |
|
|
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
|
|
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
|
|
--- linux-2.6.18-24etch2.orig/fs/compat.c |
|
|
+++ linux-2.6.18-24etch2/fs/compat.c |
|
244 |
@@ -52,6 +52,7 @@ |
@@ -52,6 +52,7 @@ |
245 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
246 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
247 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
248 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
249 |
|
|
250 |
extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
251 |
|
|
254 |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
255 |
error = security_file_ioctl(filp, cmd, arg); |
error = security_file_ioctl(filp, cmd, arg); |
256 |
+ if (!error) |
+ if (!error) |
257 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
258 |
if (error) |
if (error) |
259 |
goto out_fput; |
goto out_fput; |
260 |
|
|
278 |
if (retval >= 0) { |
if (retval >= 0) { |
279 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
280 |
|
|
281 |
--- linux-2.6.18-24etch2.orig/fs/exec.c |
--- linux-2.6.18-26etch2.orig/fs/exec.c |
282 |
+++ linux-2.6.18-24etch2/fs/exec.c |
+++ linux-2.6.18-26etch2/fs/exec.c |
283 |
@@ -57,6 +57,8 @@ |
@@ -57,6 +57,8 @@ |
284 |
#include <linux/kmod.h> |
#include <linux/kmod.h> |
285 |
#endif |
#endif |
286 |
|
|
287 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
288 |
+ |
+ |
289 |
int core_uses_pid; |
int core_uses_pid; |
290 |
char core_pattern[65] = "core"; |
char core_pattern[65] = "core"; |
293 |
if (error) |
if (error) |
294 |
goto exit; |
goto exit; |
295 |
|
|
296 |
+ error = ccs_check_uselib_permission(nd.dentry, nd.mnt); |
+ error = ccs_uselib_permission(nd.dentry, nd.mnt); |
297 |
+ if (error) |
+ if (error) |
298 |
+ goto exit; |
+ goto exit; |
299 |
+ |
+ |
305 |
S_ISREG(inode->i_mode)) { |
S_ISREG(inode->i_mode)) { |
306 |
int err = vfs_permission(&nd, MAY_EXEC); |
int err = vfs_permission(&nd, MAY_EXEC); |
307 |
+ if (!err) |
+ if (!err) |
308 |
+ err = ccs_check_open_exec_permission(nd.dentry, |
+ err = ccs_open_exec_permission(nd.dentry, |
309 |
+ nd.mnt); |
+ nd.mnt); |
310 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
311 |
if (!err) { |
if (!err) { |
320 |
if (retval >= 0) { |
if (retval >= 0) { |
321 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
322 |
|
|
323 |
--- linux-2.6.18-24etch2.orig/fs/fcntl.c |
--- linux-2.6.18-26etch2.orig/fs/fcntl.c |
324 |
+++ linux-2.6.18-24etch2/fs/fcntl.c |
+++ linux-2.6.18-26etch2/fs/fcntl.c |
325 |
@@ -22,6 +22,7 @@ |
@@ -22,6 +22,7 @@ |
326 |
#include <asm/poll.h> |
#include <asm/poll.h> |
327 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
328 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
329 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
330 |
|
|
331 |
void fastcall set_close_on_exec(unsigned int fd, int flag) |
void fastcall set_close_on_exec(unsigned int fd, int flag) |
332 |
{ |
{ |
333 |
@@ -214,6 +215,10 @@ static int setfl(int fd, struct file * f |
@@ -214,6 +215,9 @@ static int setfl(int fd, struct file * f |
334 |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
335 |
return -EPERM; |
return -EPERM; |
336 |
|
|
337 |
+ if (((arg ^ filp->f_flags) & O_APPEND) && |
+ if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp)) |
|
+ ccs_check_rewrite_permission(filp)) |
|
338 |
+ return -EPERM; |
+ return -EPERM; |
339 |
+ |
+ |
340 |
/* O_NOATIME can only be set by the owner or superuser */ |
/* O_NOATIME can only be set by the owner or superuser */ |
341 |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
342 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
343 |
--- linux-2.6.18-24etch2.orig/fs/ioctl.c |
--- linux-2.6.18-26etch2.orig/fs/ioctl.c |
344 |
+++ linux-2.6.18-24etch2/fs/ioctl.c |
+++ linux-2.6.18-26etch2/fs/ioctl.c |
345 |
@@ -15,6 +15,7 @@ |
@@ -15,6 +15,7 @@ |
346 |
|
|
347 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
348 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
349 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
350 |
|
|
351 |
static long do_ioctl(struct file *filp, unsigned int cmd, |
static long do_ioctl(struct file *filp, unsigned int cmd, |
352 |
unsigned long arg) |
unsigned long arg) |
364 |
|
|
365 |
error = security_file_ioctl(filp, cmd, arg); |
error = security_file_ioctl(filp, cmd, arg); |
366 |
+ if (!error) |
+ if (!error) |
367 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
368 |
if (error) |
if (error) |
369 |
goto out_fput; |
goto out_fput; |
370 |
|
|
371 |
--- linux-2.6.18-24etch2.orig/fs/namei.c |
--- linux-2.6.18-26etch2.orig/fs/namei.c |
372 |
+++ linux-2.6.18-24etch2/fs/namei.c |
+++ linux-2.6.18-26etch2/fs/namei.c |
373 |
@@ -37,6 +37,8 @@ |
@@ -37,6 +37,8 @@ |
374 |
|
|
375 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
376 |
|
|
377 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
378 |
+ |
+ |
379 |
/* [Feb-1997 T. Schoebel-Theuer] |
/* [Feb-1997 T. Schoebel-Theuer] |
380 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
* Fundamental changes in the pathname lookup mechanisms (namei) |
384 |
return -EPERM; |
return -EPERM; |
385 |
|
|
386 |
+ /* includes O_APPEND and O_TRUNC checks */ |
+ /* includes O_APPEND and O_TRUNC checks */ |
387 |
+ error = ccs_check_open_permission(dentry, nd->mnt, flag); |
+ error = ccs_open_permission(dentry, nd->mnt, flag); |
388 |
+ if (error) |
+ if (error) |
389 |
+ return error; |
+ return error; |
390 |
+ |
+ |
395 |
return 0; |
return 0; |
396 |
} |
} |
397 |
|
|
398 |
+#include <linux/tomoyo_vfs.h> |
+#include <linux/ccsecurity_vfs.h> |
399 |
/* |
/* |
400 |
* open_namei() |
* open_namei() |
401 |
* |
* |
403 |
if (!path.dentry->d_inode) { |
if (!path.dentry->d_inode) { |
404 |
if (!IS_POSIXACL(dir->d_inode)) |
if (!IS_POSIXACL(dir->d_inode)) |
405 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
406 |
+ error = ccs_check_mknod_permission(dir->d_inode, path.dentry, |
+ error = ccs_mknod_permission(dir->d_inode, path.dentry, |
407 |
+ nd->mnt, mode, 0); |
+ nd->mnt, mode, 0); |
408 |
+ if (!error) |
+ if (!error) |
409 |
error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
410 |
mutex_unlock(&dir->d_inode->i_mutex); |
mutex_unlock(&dir->d_inode->i_mutex); |
411 |
dput(nd->dentry); |
dput(nd->dentry); |
412 |
@@ -1848,6 +1859,10 @@ asmlinkage long sys_mknodat(int dfd, con |
@@ -1848,6 +1859,9 @@ asmlinkage long sys_mknodat(int dfd, con |
413 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
414 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
415 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
416 |
+ error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
+ error = ccs_mknod_permission(nd.dentry->d_inode, dentry, |
417 |
+ nd.mnt, mode, |
+ nd.mnt, mode, dev); |
|
+ new_decode_dev(dev)); |
|
418 |
+ if (!error) |
+ if (!error) |
419 |
switch (mode & S_IFMT) { |
switch (mode & S_IFMT) { |
420 |
case 0: case S_IFREG: |
case 0: case S_IFREG: |
421 |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
422 |
@@ -1921,6 +1936,10 @@ asmlinkage long sys_mkdirat(int dfd, con |
@@ -1921,6 +1935,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
423 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
424 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
425 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
426 |
+ error = ccs_check_mkdir_permission(nd.dentry->d_inode, |
+ error = ccs_mkdir_permission(nd.dentry->d_inode, |
427 |
+ dentry, nd.mnt, |
+ dentry, nd.mnt, mode); |
|
+ mode); |
|
428 |
+ if (!error) |
+ if (!error) |
429 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
430 |
dput(dentry); |
dput(dentry); |
431 |
} |
} |
432 |
@@ -2029,6 +2048,9 @@ static long do_rmdir(int dfd, const char |
@@ -2029,6 +2046,9 @@ static long do_rmdir(int dfd, const char |
433 |
dentry = lookup_hash(&nd); |
dentry = lookup_hash(&nd); |
434 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
435 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
436 |
+ error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry, |
+ error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, |
437 |
+ nd.mnt); |
+ nd.mnt); |
438 |
+ if (!error) |
+ if (!error) |
439 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
440 |
dput(dentry); |
dput(dentry); |
441 |
} |
} |
442 |
@@ -2109,6 +2131,9 @@ static long do_unlinkat(int dfd, const c |
@@ -2109,6 +2129,9 @@ static long do_unlinkat(int dfd, const c |
443 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
444 |
if (inode) |
if (inode) |
445 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
446 |
+ error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry, |
+ error = ccs_unlink_permission(nd.dentry->d_inode, dentry, |
447 |
+ nd.mnt); |
+ nd.mnt); |
448 |
+ if (!error) |
+ if (!error) |
449 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
450 |
exit2: |
exit2: |
451 |
dput(dentry); |
dput(dentry); |
452 |
@@ -2187,6 +2212,10 @@ asmlinkage long sys_symlinkat(const char |
@@ -2187,6 +2210,9 @@ asmlinkage long sys_symlinkat(const char |
453 |
dentry = lookup_create(&nd, 0); |
dentry = lookup_create(&nd, 0); |
454 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
455 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
456 |
+ error = ccs_check_symlink_permission(nd.dentry->d_inode, |
+ error = ccs_symlink_permission(nd.dentry->d_inode, |
457 |
+ dentry, nd.mnt, |
+ dentry, nd.mnt, from); |
|
+ from); |
|
458 |
+ if (!error) |
+ if (!error) |
459 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
460 |
dput(dentry); |
dput(dentry); |
461 |
} |
} |
462 |
@@ -2281,6 +2310,10 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2281,6 +2307,9 @@ asmlinkage long sys_linkat(int olddfd, c |
463 |
new_dentry = lookup_create(&nd, 0); |
new_dentry = lookup_create(&nd, 0); |
464 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
465 |
if (!IS_ERR(new_dentry)) { |
if (!IS_ERR(new_dentry)) { |
466 |
+ error = ccs_check_link_permission(old_nd.dentry, |
+ error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode, |
467 |
+ nd.dentry->d_inode, |
+ new_dentry, nd.mnt); |
|
+ new_dentry, nd.mnt); |
|
468 |
+ if (!error) |
+ if (!error) |
469 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
470 |
dput(new_dentry); |
dput(new_dentry); |
471 |
} |
} |
472 |
@@ -2507,6 +2540,11 @@ static int do_rename(int olddfd, const c |
@@ -2507,6 +2536,9 @@ static int do_rename(int olddfd, const c |
473 |
if (new_dentry == trap) |
if (new_dentry == trap) |
474 |
goto exit5; |
goto exit5; |
475 |
|
|
476 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
477 |
+ new_dir->d_inode, new_dentry, |
+ new_dir->d_inode, new_dentry, newnd.mnt); |
|
+ newnd.mnt); |
|
478 |
+ if (!error) |
+ if (!error) |
|
+ |
|
479 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
error = vfs_rename(old_dir->d_inode, old_dentry, |
480 |
new_dir->d_inode, new_dentry); |
new_dir->d_inode, new_dentry); |
481 |
exit5: |
exit5: |
482 |
--- linux-2.6.18-24etch2.orig/fs/namespace.c |
--- linux-2.6.18-26etch2.orig/fs/namespace.c |
483 |
+++ linux-2.6.18-24etch2/fs/namespace.c |
+++ linux-2.6.18-26etch2/fs/namespace.c |
484 |
@@ -25,6 +25,8 @@ |
@@ -25,6 +25,7 @@ |
485 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
486 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
487 |
#include "pnode.h" |
#include "pnode.h" |
488 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
489 |
|
|
490 |
extern int __init init_rootfs(void); |
extern int __init init_rootfs(void); |
491 |
|
|
492 |
@@ -553,6 +555,9 @@ static int do_umount(struct vfsmount *mn |
@@ -550,6 +551,8 @@ static int do_umount(struct vfsmount *mn |
493 |
|
LIST_HEAD(umount_list); |
494 |
|
|
495 |
|
retval = security_sb_umount(mnt, flags); |
496 |
|
+ if (!retval) |
497 |
|
+ retval = ccs_umount_permission(mnt, flags); |
498 |
if (retval) |
if (retval) |
499 |
return retval; |
return retval; |
500 |
|
|
501 |
+ if (ccs_may_umount(mnt)) |
@@ -641,6 +644,8 @@ asmlinkage long sys_umount(char __user * |
|
+ return -EPERM; |
|
|
+ |
|
|
/* |
|
|
* Allow userspace to request a mountpoint be expired rather than |
|
|
* unmounting unconditionally. Unmount only happens if: |
|
|
@@ -641,6 +646,8 @@ asmlinkage long sys_umount(char __user * |
|
502 |
{ |
{ |
503 |
struct nameidata nd; |
struct nameidata nd; |
504 |
int retval; |
int retval; |
507 |
|
|
508 |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
509 |
if (retval) |
if (retval) |
510 |
@@ -925,6 +932,9 @@ static int do_loopback(struct nameidata |
@@ -925,6 +930,9 @@ static int do_loopback(struct nameidata |
511 |
|
|
512 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
513 |
goto out; |
goto out; |
517 |
|
|
518 |
err = -ENOMEM; |
err = -ENOMEM; |
519 |
if (recurse) |
if (recurse) |
520 |
@@ -1009,7 +1019,9 @@ static int do_move_mount(struct nameidat |
@@ -1009,7 +1017,9 @@ static int do_move_mount(struct nameidat |
521 |
err = -EINVAL; |
err = -EINVAL; |
522 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
523 |
goto out; |
goto out; |
524 |
- |
- |
525 |
+ err = -EPERM; |
+ err = -EPERM; |
526 |
+ if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
527 |
+ goto out; |
+ goto out; |
528 |
err = -ENOENT; |
err = -ENOENT; |
529 |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
530 |
if (IS_DEADDIR(nd->dentry->d_inode)) |
if (IS_DEADDIR(nd->dentry->d_inode)) |
531 |
@@ -1111,6 +1123,9 @@ int do_add_mount(struct vfsmount *newmnt |
@@ -1111,6 +1121,9 @@ int do_add_mount(struct vfsmount *newmnt |
532 |
err = -EINVAL; |
err = -EINVAL; |
533 |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
534 |
goto unlock; |
goto unlock; |
538 |
|
|
539 |
newmnt->mnt_flags = mnt_flags; |
newmnt->mnt_flags = mnt_flags; |
540 |
if ((err = graft_tree(newmnt, nd))) |
if ((err = graft_tree(newmnt, nd))) |
541 |
@@ -1402,6 +1417,13 @@ long do_mount(char *dev_name, char *dir_ |
@@ -1384,6 +1397,7 @@ int copy_mount_options(const void __user |
542 |
if (data_page) |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
543 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
unsigned long flags, void *data_page) |
544 |
|
{ |
545 |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
+ const unsigned long original_flags = flags; |
546 |
+ return -EPERM; |
struct nameidata nd; |
547 |
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
int retval = 0; |
548 |
+ &flags); |
int mnt_flags = 0; |
549 |
+ if (retval) |
@@ -1423,6 +1437,9 @@ long do_mount(char *dev_name, char *dir_ |
550 |
+ return retval; |
return retval; |
|
+ |
|
|
/* Separate the per-mountpoint flags */ |
|
|
if (flags & MS_NOSUID) |
|
|
mnt_flags |= MNT_NOSUID; |
|
|
@@ -1691,6 +1713,8 @@ asmlinkage long sys_pivot_root(const cha |
|
|
|
|
|
if (!capable(CAP_SYS_ADMIN)) |
|
|
return -EPERM; |
|
|
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
|
|
+ return -EPERM; |
|
551 |
|
|
552 |
lock_kernel(); |
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
553 |
|
+ if (!retval) |
554 |
|
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
555 |
|
+ original_flags, data_page); |
556 |
|
if (retval) |
557 |
|
goto dput_out; |
558 |
|
|
559 |
@@ -1707,6 +1731,8 @@ asmlinkage long sys_pivot_root(const cha |
@@ -1707,6 +1724,8 @@ asmlinkage long sys_pivot_root(const cha |
560 |
goto out1; |
goto out1; |
561 |
|
|
562 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
error = security_sb_pivotroot(&old_nd, &new_nd); |
563 |
+ if (!error) |
+ if (!error) |
564 |
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
565 |
if (error) { |
if (error) { |
566 |
path_release(&old_nd); |
path_release(&old_nd); |
567 |
goto out1; |
goto out1; |
568 |
--- linux-2.6.18-24etch2.orig/fs/open.c |
--- linux-2.6.18-26etch2.orig/fs/open.c |
569 |
+++ linux-2.6.18-24etch2/fs/open.c |
+++ linux-2.6.18-26etch2/fs/open.c |
570 |
@@ -30,6 +30,8 @@ |
@@ -30,6 +30,7 @@ |
571 |
#include <linux/audit.h> |
#include <linux/audit.h> |
572 |
|
|
573 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
574 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
575 |
|
|
576 |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
577 |
{ |
{ |
578 |
@@ -267,6 +269,8 @@ static long do_sys_truncate(const char _ |
@@ -267,6 +268,8 @@ static long do_sys_truncate(const char _ |
579 |
if (error) |
if (error) |
580 |
goto dput_and_out; |
goto dput_and_out; |
581 |
|
|
582 |
+ error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0); |
+ error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0); |
583 |
+ if (!error) |
+ if (!error) |
584 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
585 |
if (!error) { |
if (!error) { |
586 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
587 |
@@ -320,6 +324,10 @@ static long do_sys_ftruncate(unsigned in |
@@ -320,6 +323,9 @@ static long do_sys_ftruncate(unsigned in |
588 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
589 |
goto out_putf; |
goto out_putf; |
590 |
|
|
591 |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0); |
|
+ 0); |
|
592 |
+ if (error) |
+ if (error) |
593 |
+ goto out_putf; |
+ goto out_putf; |
594 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
595 |
if (!error) |
if (!error) |
596 |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
597 |
@@ -608,6 +616,10 @@ asmlinkage long sys_chroot(const char __ |
@@ -608,6 +614,8 @@ asmlinkage long sys_chroot(const char __ |
598 |
error = -EPERM; |
error = -EPERM; |
599 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
600 |
goto dput_and_out; |
goto dput_and_out; |
601 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
+ if (ccs_chroot_permission(&nd)) |
|
+ goto dput_and_out; |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
|
602 |
+ goto dput_and_out; |
+ goto dput_and_out; |
603 |
|
|
604 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
605 |
set_fs_altroot(); |
set_fs_altroot(); |
606 |
@@ -1199,6 +1211,8 @@ EXPORT_SYMBOL(sys_close); |
@@ -641,6 +649,9 @@ asmlinkage long sys_fchmod(unsigned int |
607 |
|
err = -EPERM; |
608 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
609 |
|
goto out_putf; |
610 |
|
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
611 |
|
+ if (err) |
612 |
|
+ goto out_putf; |
613 |
|
mutex_lock(&inode->i_mutex); |
614 |
|
if (mode == (mode_t) -1) |
615 |
|
mode = inode->i_mode; |
616 |
|
@@ -675,6 +686,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
617 |
|
error = -EPERM; |
618 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
619 |
|
goto dput_and_out; |
620 |
|
+ error = ccs_chmod_permission(nd.dentry, nd.mnt, mode); |
621 |
|
+ if (error) |
622 |
|
+ goto dput_and_out; |
623 |
|
|
624 |
|
mutex_lock(&inode->i_mutex); |
625 |
|
if (mode == (mode_t) -1) |
626 |
|
@@ -737,6 +751,8 @@ asmlinkage long sys_chown(const char __u |
627 |
|
|
628 |
|
error = user_path_walk(filename, &nd); |
629 |
|
if (!error) { |
630 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
631 |
|
+ if (!error) |
632 |
|
error = chown_common(nd.dentry, user, group); |
633 |
|
path_release(&nd); |
634 |
|
} |
635 |
|
@@ -756,6 +772,8 @@ asmlinkage long sys_fchownat(int dfd, co |
636 |
|
follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
637 |
|
error = __user_walk_fd(dfd, filename, follow, &nd); |
638 |
|
if (!error) { |
639 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
640 |
|
+ if (!error) |
641 |
|
error = chown_common(nd.dentry, user, group); |
642 |
|
path_release(&nd); |
643 |
|
} |
644 |
|
@@ -770,6 +788,8 @@ asmlinkage long sys_lchown(const char __ |
645 |
|
|
646 |
|
error = user_path_walk_link(filename, &nd); |
647 |
|
if (!error) { |
648 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
649 |
|
+ if (!error) |
650 |
|
error = chown_common(nd.dentry, user, group); |
651 |
|
path_release(&nd); |
652 |
|
} |
653 |
|
@@ -787,6 +807,9 @@ asmlinkage long sys_fchown(unsigned int |
654 |
|
struct dentry * dentry; |
655 |
|
dentry = file->f_dentry; |
656 |
|
audit_inode(NULL, dentry->d_inode); |
657 |
|
+ error = ccs_chown_permission(dentry, file->f_vfsmnt, user, |
658 |
|
+ group); |
659 |
|
+ if (!error) |
660 |
|
error = chown_common(dentry, user, group); |
661 |
|
fput(file); |
662 |
|
} |
663 |
|
@@ -879,7 +902,9 @@ static struct file *do_filp_open(int dfd |
664 |
|
if ((namei_flags+1) & O_ACCMODE) |
665 |
|
namei_flags++; |
666 |
|
|
667 |
|
+ ccs_save_open_mode(flags); |
668 |
|
error = open_namei(dfd, filename, namei_flags, mode, &nd); |
669 |
|
+ ccs_clear_open_mode(); |
670 |
|
if (!error) |
671 |
|
return nameidata_to_filp(&nd, flags); |
672 |
|
|
673 |
|
@@ -1199,6 +1224,8 @@ EXPORT_SYMBOL(sys_close); |
674 |
*/ |
*/ |
675 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
676 |
{ |
{ |
679 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
680 |
tty_vhangup(current->signal->tty); |
tty_vhangup(current->signal->tty); |
681 |
return 0; |
return 0; |
682 |
--- linux-2.6.18-24etch2.orig/fs/proc/Makefile |
--- linux-2.6.18-26etch2.orig/fs/proc/proc_misc.c |
683 |
+++ linux-2.6.18-24etch2/fs/proc/Makefile |
+++ linux-2.6.18-26etch2/fs/proc/proc_misc.c |
|
@@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge |
|
|
proc-$(CONFIG_PROC_KCORE) += kcore.o |
|
|
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
|
|
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
|
|
+ |
|
|
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
|
|
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
|
|
--- linux-2.6.18-24etch2.orig/fs/proc/proc_misc.c |
|
|
+++ linux-2.6.18-24etch2/fs/proc/proc_misc.c |
|
684 |
@@ -723,4 +723,5 @@ void __init proc_misc_init(void) |
@@ -723,4 +723,5 @@ void __init proc_misc_init(void) |
685 |
if (entry) |
if (entry) |
686 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
entry->proc_fops = &proc_sysrq_trigger_operations; |
687 |
#endif |
#endif |
688 |
+ printk(KERN_INFO "Hook version: 2.6.18-24etch2 2009/08/05\n"); |
+ printk(KERN_INFO "Hook version: 2.6.18-26etch2 2010/07/21\n"); |
689 |
} |
} |
690 |
--- linux-2.6.18-24etch2.orig/include/linux/init_task.h |
--- linux-2.6.18-26etch2.orig/include/linux/init_task.h |
691 |
+++ linux-2.6.18-24etch2/include/linux/init_task.h |
+++ linux-2.6.18-26etch2/include/linux/init_task.h |
692 |
@@ -128,6 +128,8 @@ extern struct group_info init_groups; |
@@ -76,6 +76,14 @@ |
693 |
|
|
694 |
|
extern struct group_info init_groups; |
695 |
|
|
696 |
|
+#ifdef CONFIG_CCSECURITY |
697 |
|
+#define INIT_CCSECURITY \ |
698 |
|
+ .ccs_domain_info = NULL, \ |
699 |
|
+ .ccs_flags = 0, |
700 |
|
+#else |
701 |
|
+#define INIT_CCSECURITY |
702 |
|
+#endif |
703 |
|
+ |
704 |
|
/* |
705 |
|
* INIT_TASK is used to set up the first task table, touch at |
706 |
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
707 |
|
@@ -128,6 +136,7 @@ extern struct group_info init_groups; |
708 |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
709 |
INIT_TRACE_IRQFLAGS \ |
INIT_TRACE_IRQFLAGS \ |
710 |
INIT_LOCKDEP \ |
INIT_LOCKDEP \ |
711 |
+ .ccs_domain_info = NULL, \ |
+ INIT_CCSECURITY \ |
|
+ .ccs_flags = 0, \ |
|
712 |
} |
} |
713 |
|
|
714 |
|
|
715 |
--- linux-2.6.18-24etch2.orig/include/linux/sched.h |
--- linux-2.6.18-26etch2.orig/include/linux/sched.h |
716 |
+++ linux-2.6.18-24etch2/include/linux/sched.h |
+++ linux-2.6.18-26etch2/include/linux/sched.h |
717 |
@@ -25,6 +25,8 @@ |
@@ -35,6 +35,8 @@ |
718 |
#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ |
|
719 |
#define CLONE_STOPPED 0x02000000 /* Start in stopped state */ |
#ifdef __KERNEL__ |
720 |
|
|
721 |
+struct ccs_domain_info; |
+struct ccs_domain_info; |
722 |
+ |
+ |
723 |
/* |
struct sched_param { |
724 |
* Scheduling policies |
int sched_priority; |
725 |
*/ |
}; |
726 |
@@ -996,6 +998,8 @@ struct task_struct { |
@@ -996,6 +998,10 @@ struct task_struct { |
727 |
#ifdef CONFIG_TASK_DELAY_ACCT |
#ifdef CONFIG_TASK_DELAY_ACCT |
728 |
struct task_delay_info *delays; |
struct task_delay_info *delays; |
729 |
#endif |
#endif |
730 |
|
+#ifdef CONFIG_CCSECURITY |
731 |
+ struct ccs_domain_info *ccs_domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
732 |
+ u32 ccs_flags; |
+ u32 ccs_flags; |
733 |
|
+#endif |
734 |
}; |
}; |
735 |
|
|
736 |
static inline pid_t process_group(struct task_struct *tsk) |
static inline pid_t process_group(struct task_struct *tsk) |
737 |
--- linux-2.6.18-24etch2.orig/kernel/compat.c |
--- linux-2.6.18-26etch2.orig/kernel/compat.c |
738 |
+++ linux-2.6.18-24etch2/kernel/compat.c |
+++ linux-2.6.18-26etch2/kernel/compat.c |
739 |
@@ -24,6 +24,7 @@ |
@@ -24,6 +24,7 @@ |
740 |
#include <linux/migrate.h> |
#include <linux/migrate.h> |
741 |
|
|
742 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
743 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
744 |
|
|
745 |
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
746 |
{ |
{ |
753 |
|
|
754 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
755 |
return 0; |
return 0; |
756 |
--- linux-2.6.18-24etch2.orig/kernel/kexec.c |
--- linux-2.6.18-26etch2.orig/kernel/kexec.c |
757 |
+++ linux-2.6.18-24etch2/kernel/kexec.c |
+++ linux-2.6.18-26etch2/kernel/kexec.c |
758 |
@@ -26,6 +26,7 @@ |
@@ -26,6 +26,7 @@ |
759 |
#include <asm/io.h> |
#include <asm/io.h> |
760 |
#include <asm/system.h> |
#include <asm/system.h> |
761 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
762 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
763 |
|
|
764 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
/* Per cpu memory for storing cpu states in case of system crash. */ |
765 |
note_buf_t* crash_notes; |
note_buf_t* crash_notes; |
772 |
|
|
773 |
/* |
/* |
774 |
* Verify we have a legal set of flags |
* Verify we have a legal set of flags |
775 |
--- linux-2.6.18-24etch2.orig/kernel/kmod.c |
--- linux-2.6.18-26etch2.orig/kernel/kmod.c |
776 |
+++ linux-2.6.18-24etch2/kernel/kmod.c |
+++ linux-2.6.18-26etch2/kernel/kmod.c |
777 |
@@ -148,6 +148,9 @@ static int ____call_usermodehelper(void |
@@ -148,6 +148,11 @@ static int ____call_usermodehelper(void |
778 |
/* We can run anywhere, unlike our parent keventd(). */ |
/* We can run anywhere, unlike our parent keventd(). */ |
779 |
set_cpus_allowed(current, CPU_MASK_ALL); |
set_cpus_allowed(current, CPU_MASK_ALL); |
780 |
|
|
781 |
|
+#ifdef CONFIG_CCSECURITY |
782 |
+ current->ccs_domain_info = NULL; |
+ current->ccs_domain_info = NULL; |
783 |
+ current->ccs_flags = 0; |
+ current->ccs_flags = 0; |
784 |
|
+#endif |
785 |
+ |
+ |
786 |
retval = -EPERM; |
retval = -EPERM; |
787 |
if (current->fs->root) |
if (current->fs->root) |
788 |
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
789 |
--- linux-2.6.18-24etch2.orig/kernel/module.c |
--- linux-2.6.18-26etch2.orig/kernel/module.c |
790 |
+++ linux-2.6.18-24etch2/kernel/module.c |
+++ linux-2.6.18-26etch2/kernel/module.c |
791 |
@@ -44,6 +44,7 @@ |
@@ -44,6 +44,7 @@ |
792 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
793 |
#include <asm/cacheflush.h> |
#include <asm/cacheflush.h> |
794 |
#include <linux/license.h> |
#include <linux/license.h> |
795 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
796 |
|
|
797 |
#if 0 |
#if 0 |
798 |
#define DEBUGP printk |
#define DEBUGP printk |
816 |
/* Only one module load at a time, please */ |
/* Only one module load at a time, please */ |
817 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
if (mutex_lock_interruptible(&module_mutex) != 0) |
818 |
return -EINTR; |
return -EINTR; |
819 |
--- linux-2.6.18-24etch2.orig/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/kernel/ptrace.c |
820 |
+++ linux-2.6.18-24etch2/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/kernel/ptrace.c |
821 |
@@ -21,6 +21,7 @@ |
@@ -21,6 +21,7 @@ |
822 |
|
|
823 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
824 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
825 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
826 |
|
|
827 |
/* |
/* |
828 |
* ptrace a task: make the debugger its new parent and |
* ptrace a task: make the debugger its new parent and |
830 |
/* |
/* |
831 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
832 |
*/ |
*/ |
833 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
834 |
+ return -EPERM; |
+ return -EPERM; |
835 |
lock_kernel(); |
lock_kernel(); |
836 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
837 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
838 |
--- linux-2.6.18-24etch2.orig/kernel/sched.c |
--- linux-2.6.18-26etch2.orig/kernel/sched.c |
839 |
+++ linux-2.6.18-24etch2/kernel/sched.c |
+++ linux-2.6.18-26etch2/kernel/sched.c |
840 |
@@ -55,6 +55,7 @@ |
@@ -55,6 +55,7 @@ |
841 |
#include <asm/tlb.h> |
#include <asm/tlb.h> |
842 |
|
|
843 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
844 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
845 |
|
|
846 |
/* |
/* |
847 |
* Convert user-nice values [ -20 ... 0 ... 19 ] |
* Convert user-nice values [ -20 ... 0 ... 19 ] |
854 |
|
|
855 |
/* |
/* |
856 |
* Setpriority might change our priority at the same moment. |
* Setpriority might change our priority at the same moment. |
857 |
--- linux-2.6.18-24etch2.orig/kernel/signal.c |
--- linux-2.6.18-26etch2.orig/kernel/signal.c |
858 |
+++ linux-2.6.18-24etch2/kernel/signal.c |
+++ linux-2.6.18-26etch2/kernel/signal.c |
859 |
@@ -28,6 +28,7 @@ |
@@ -28,6 +28,7 @@ |
860 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
861 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
862 |
#include "audit.h" /* audit_signal_info() */ |
#include "audit.h" /* audit_signal_info() */ |
863 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
864 |
|
|
865 |
/* |
/* |
866 |
* SLAB caches for signal bits. |
* SLAB caches for signal bits. |
891 |
|
|
892 |
return do_tkill(0, pid, sig); |
return do_tkill(0, pid, sig); |
893 |
} |
} |
894 |
--- linux-2.6.18-24etch2.orig/kernel/sys.c |
@@ -2271,6 +2278,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
895 |
+++ linux-2.6.18-24etch2/kernel/sys.c |
if (info.si_code >= 0) |
896 |
|
return -EPERM; |
897 |
|
info.si_signo = sig; |
898 |
|
+ if (ccs_sigqueue_permission(pid, sig)) |
899 |
|
+ return -EPERM; |
900 |
|
|
901 |
|
/* POSIX.1b doesn't mention process groups. */ |
902 |
|
return kill_proc_info(sig, &info, pid); |
903 |
|
--- linux-2.6.18-26etch2.orig/kernel/sys.c |
904 |
|
+++ linux-2.6.18-26etch2/kernel/sys.c |
905 |
@@ -36,6 +36,7 @@ |
@@ -36,6 +36,7 @@ |
906 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
907 |
#include <asm/io.h> |
#include <asm/io.h> |
908 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
909 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
910 |
|
|
911 |
#ifndef SET_UNALIGN_CTL |
#ifndef SET_UNALIGN_CTL |
912 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
948 |
|
|
949 |
down_write(&uts_sem); |
down_write(&uts_sem); |
950 |
errno = -EFAULT; |
errno = -EFAULT; |
951 |
--- linux-2.6.18-24etch2.orig/kernel/sysctl.c |
--- linux-2.6.18-26etch2.orig/kernel/sysctl.c |
952 |
+++ linux-2.6.18-24etch2/kernel/sysctl.c |
+++ linux-2.6.18-26etch2/kernel/sysctl.c |
953 |
@@ -48,6 +48,7 @@ |
@@ -48,6 +48,7 @@ |
954 |
|
|
955 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
956 |
#include <asm/processor.h> |
#include <asm/processor.h> |
957 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
958 |
|
|
959 |
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
960 |
void __user *buffer, size_t *lenp, loff_t *ppos); |
void __user *buffer, size_t *lenp, loff_t *ppos); |
982 |
error = table->strategy( |
error = table->strategy( |
983 |
table, name, nlen, |
table, name, nlen, |
984 |
oldval, oldlenp, |
oldval, oldlenp, |
985 |
--- linux-2.6.18-24etch2.orig/kernel/time.c |
--- linux-2.6.18-26etch2.orig/kernel/time.c |
986 |
+++ linux-2.6.18-24etch2/kernel/time.c |
+++ linux-2.6.18-26etch2/kernel/time.c |
987 |
@@ -39,6 +39,7 @@ |
@@ -39,6 +39,7 @@ |
988 |
|
|
989 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
990 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
991 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
992 |
|
|
993 |
/* |
/* |
994 |
* The timezone where the local system is located. Used as a default by some |
* The timezone where the local system is located. Used as a default by some |
1019 |
|
|
1020 |
/* Now we validate the data before disabling interrupts */ |
/* Now we validate the data before disabling interrupts */ |
1021 |
|
|
1022 |
--- linux-2.6.18-24etch2.orig/net/ipv4/inet_connection_sock.c |
--- linux-2.6.18-26etch2.orig/net/ipv4/inet_connection_sock.c |
1023 |
+++ linux-2.6.18-24etch2/net/ipv4/inet_connection_sock.c |
+++ linux-2.6.18-26etch2/net/ipv4/inet_connection_sock.c |
1024 |
@@ -23,6 +23,7 @@ |
@@ -23,6 +23,7 @@ |
1025 |
#include <net/route.h> |
#include <net/route.h> |
1026 |
#include <net/tcp_states.h> |
#include <net/tcp_states.h> |
1027 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1028 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
1029 |
|
|
1030 |
#ifdef INET_CSK_DEBUG |
#ifdef INET_CSK_DEBUG |
1031 |
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
1038 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
inet_bind_bucket_for_each(tb, node, &head->chain) |
1039 |
if (tb->port == rover) |
if (tb->port == rover) |
1040 |
goto next; |
goto next; |
1041 |
--- linux-2.6.18-24etch2.orig/net/ipv4/inet_hashtables.c |
--- linux-2.6.18-26etch2.orig/net/ipv4/inet_hashtables.c |
1042 |
+++ linux-2.6.18-24etch2/net/ipv4/inet_hashtables.c |
+++ linux-2.6.18-26etch2/net/ipv4/inet_hashtables.c |
1043 |
@@ -22,6 +22,7 @@ |
@@ -22,6 +22,7 @@ |
1044 |
#include <net/inet_connection_sock.h> |
#include <net/inet_connection_sock.h> |
1045 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1046 |
#include <net/ip.h> |
#include <net/ip.h> |
1047 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
1048 |
|
|
1049 |
/* |
/* |
1050 |
* Allocate and initialize a new local port bind bucket. |
* Allocate and initialize a new local port bind bucket. |
1057 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1058 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1059 |
|
|
1060 |
--- linux-2.6.18-24etch2.orig/net/ipv4/raw.c |
--- linux-2.6.18-26etch2.orig/net/ipv4/raw.c |
1061 |
+++ linux-2.6.18-24etch2/net/ipv4/raw.c |
+++ linux-2.6.18-26etch2/net/ipv4/raw.c |
1062 |
@@ -79,6 +79,7 @@ |
@@ -79,6 +79,7 @@ |
1063 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
1064 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1065 |
#include <linux/netfilter_ipv4.h> |
#include <linux/netfilter_ipv4.h> |
1066 |
+#include <linux/tomoyo_socket.h> |
+#include <linux/ccsecurity.h> |
1067 |
|
|
1068 |
struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; |
struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; |
1069 |
DEFINE_RWLOCK(raw_v4_lock); |
DEFINE_RWLOCK(raw_v4_lock); |
1070 |
@@ -592,6 +593,9 @@ static int raw_recvmsg(struct kiocb *ioc |
@@ -589,9 +590,14 @@ static int raw_recvmsg(struct kiocb *ioc |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
|
|
if (!skb) |
|
1071 |
goto out; |
goto out; |
1072 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
} |
1073 |
+ if (err) |
|
1074 |
+ goto out; |
- skb = skb_recv_datagram(sk, flags, noblock, &err); |
1075 |
|
- if (!skb) |
1076 |
|
- goto out; |
1077 |
|
+ for (;;) { |
1078 |
|
+ skb = skb_recv_datagram(sk, flags, noblock, &err); |
1079 |
|
+ if (!skb) |
1080 |
|
+ goto out; |
1081 |
|
+ if (!ccs_socket_post_recvmsg_permission(sk, skb)) |
1082 |
|
+ break; |
1083 |
|
+ skb_kill_datagram(sk, skb, flags); |
1084 |
|
+ } |
1085 |
|
|
1086 |
copied = skb->len; |
copied = skb->len; |
1087 |
if (len < copied) { |
if (len < copied) { |
1088 |
--- linux-2.6.18-24etch2.orig/net/ipv4/udp.c |
--- linux-2.6.18-26etch2.orig/net/ipv4/udp.c |
1089 |
+++ linux-2.6.18-24etch2/net/ipv4/udp.c |
+++ linux-2.6.18-26etch2/net/ipv4/udp.c |
1090 |
@@ -108,6 +108,8 @@ |
@@ -108,6 +108,7 @@ |
1091 |
#include <net/inet_common.h> |
#include <net/inet_common.h> |
1092 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1093 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1094 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo_socket.h> |
|
1095 |
|
|
1096 |
/* |
/* |
1097 |
* Snmp MIB for the UDP layer |
* Snmp MIB for the UDP layer |
1098 |
@@ -146,6 +148,8 @@ static int udp_v4_get_port(struct sock * |
@@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock * |
1099 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1100 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1101 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1104 |
goto gotit; |
goto gotit; |
1105 |
} |
} |
1106 |
size = 0; |
size = 0; |
1107 |
@@ -162,6 +166,8 @@ static int udp_v4_get_port(struct sock * |
@@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock * |
1108 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1109 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1110 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1113 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1114 |
break; |
break; |
1115 |
} |
} |
1116 |
@@ -796,7 +802,10 @@ try_again: |
@@ -782,6 +787,7 @@ static int udp_recvmsg(struct kiocb *ioc |
1117 |
|
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; |
1118 |
|
struct sk_buff *skb; |
1119 |
|
int copied, err; |
1120 |
|
+ _Bool update_stat; |
1121 |
|
|
1122 |
|
/* |
1123 |
|
* Check any passed addresses |
1124 |
|
@@ -796,7 +802,12 @@ try_again: |
1125 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1126 |
if (!skb) |
if (!skb) |
1127 |
goto out; |
goto out; |
1128 |
- |
- |
1129 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1130 |
+ if (err) |
+ update_stat = 0; |
1131 |
+ goto out; |
+ goto csum_copy_err; |
1132 |
|
+ } |
1133 |
|
+ update_stat = 1; |
1134 |
+ |
+ |
1135 |
copied = skb->len - sizeof(struct udphdr); |
copied = skb->len - sizeof(struct udphdr); |
1136 |
if (copied > len) { |
if (copied > len) { |
1137 |
copied = len; |
copied = len; |
1138 |
--- linux-2.6.18-24etch2.orig/net/ipv6/inet6_hashtables.c |
@@ -844,7 +855,8 @@ out: |
1139 |
+++ linux-2.6.18-24etch2/net/ipv6/inet6_hashtables.c |
return err; |
1140 |
|
|
1141 |
|
csum_copy_err: |
1142 |
|
- UDP_INC_STATS_BH(UDP_MIB_INERRORS); |
1143 |
|
+ if (update_stat) |
1144 |
|
+ UDP_INC_STATS_BH(UDP_MIB_INERRORS); |
1145 |
|
|
1146 |
|
skb_kill_datagram(sk, skb, flags); |
1147 |
|
|
1148 |
|
--- linux-2.6.18-26etch2.orig/net/ipv6/inet6_hashtables.c |
1149 |
|
+++ linux-2.6.18-26etch2/net/ipv6/inet6_hashtables.c |
1150 |
@@ -21,6 +21,7 @@ |
@@ -21,6 +21,7 @@ |
1151 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1152 |
#include <net/inet6_hashtables.h> |
#include <net/inet6_hashtables.h> |
1153 |
#include <net/ip.h> |
#include <net/ip.h> |
1154 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
1155 |
|
|
1156 |
void __inet6_hash(struct inet_hashinfo *hashinfo, |
void __inet6_hash(struct inet_hashinfo *hashinfo, |
1157 |
struct sock *sk) |
struct sock *sk) |
1173 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1174 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1175 |
|
|
1176 |
--- linux-2.6.18-24etch2.orig/net/ipv6/raw.c |
--- linux-2.6.18-26etch2.orig/net/ipv6/raw.c |
1177 |
+++ linux-2.6.18-24etch2/net/ipv6/raw.c |
+++ linux-2.6.18-26etch2/net/ipv6/raw.c |
1178 |
@@ -56,6 +56,7 @@ |
@@ -56,6 +56,7 @@ |
1179 |
|
|
1180 |
#include <linux/proc_fs.h> |
#include <linux/proc_fs.h> |
1181 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
1182 |
+#include <linux/tomoyo_socket.h> |
+#include <linux/ccsecurity.h> |
1183 |
|
|
1184 |
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1185 |
DEFINE_RWLOCK(raw_v6_lock); |
DEFINE_RWLOCK(raw_v6_lock); |
1186 |
@@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i |
@@ -384,9 +385,14 @@ static int rawv6_recvmsg(struct kiocb *i |
1187 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
if (flags & MSG_ERRQUEUE) |
1188 |
if (!skb) |
return ipv6_recv_error(sk, msg, len); |
1189 |
goto out; |
|
1190 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
- skb = skb_recv_datagram(sk, flags, noblock, &err); |
1191 |
+ if (err) |
- if (!skb) |
1192 |
+ goto out; |
- goto out; |
1193 |
|
+ for (;;) { |
1194 |
|
+ skb = skb_recv_datagram(sk, flags, noblock, &err); |
1195 |
|
+ if (!skb) |
1196 |
|
+ goto out; |
1197 |
|
+ if (!ccs_socket_post_recvmsg_permission(sk, skb)) |
1198 |
|
+ break; |
1199 |
|
+ skb_kill_datagram(sk, skb, flags); |
1200 |
|
+ } |
1201 |
|
|
1202 |
copied = skb->len; |
copied = skb->len; |
1203 |
if (copied > len) { |
if (copied > len) { |
1204 |
--- linux-2.6.18-24etch2.orig/net/ipv6/udp.c |
--- linux-2.6.18-26etch2.orig/net/ipv6/udp.c |
1205 |
+++ linux-2.6.18-24etch2/net/ipv6/udp.c |
+++ linux-2.6.18-26etch2/net/ipv6/udp.c |
1206 |
@@ -58,6 +58,8 @@ |
@@ -58,6 +58,7 @@ |
1207 |
|
|
1208 |
#include <linux/proc_fs.h> |
#include <linux/proc_fs.h> |
1209 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
1210 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo_socket.h> |
|
1211 |
|
|
1212 |
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
1213 |
|
|
1214 |
@@ -88,6 +90,8 @@ static int udp_v6_get_port(struct sock * |
@@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock * |
1215 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1216 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1217 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1220 |
goto gotit; |
goto gotit; |
1221 |
} |
} |
1222 |
size = 0; |
size = 0; |
1223 |
@@ -104,6 +108,8 @@ static int udp_v6_get_port(struct sock * |
@@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock * |
1224 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1225 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1226 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1229 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1230 |
break; |
break; |
1231 |
} |
} |
1232 |
@@ -237,6 +243,9 @@ try_again: |
@@ -226,6 +231,7 @@ static int udpv6_recvmsg(struct kiocb *i |
1233 |
|
struct sk_buff *skb; |
1234 |
|
size_t copied; |
1235 |
|
int err; |
1236 |
|
+ _Bool update_stat; |
1237 |
|
|
1238 |
|
if (addr_len) |
1239 |
|
*addr_len=sizeof(struct sockaddr_in6); |
1240 |
|
@@ -237,6 +243,11 @@ try_again: |
1241 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1242 |
if (!skb) |
if (!skb) |
1243 |
goto out; |
goto out; |
1244 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1245 |
+ if (err) |
+ update_stat = 0; |
1246 |
+ goto out; |
+ goto csum_copy_err; |
1247 |
|
+ } |
1248 |
|
+ update_stat = 1; |
1249 |
|
|
1250 |
copied = skb->len - sizeof(struct udphdr); |
copied = skb->len - sizeof(struct udphdr); |
1251 |
if (copied > len) { |
if (copied > len) { |
1252 |
--- linux-2.6.18-24etch2.orig/net/socket.c |
@@ -303,7 +314,8 @@ csum_copy_err: |
1253 |
+++ linux-2.6.18-24etch2/net/socket.c |
skb_kill_datagram(sk, skb, flags); |
1254 |
@@ -94,6 +94,9 @@ |
|
1255 |
|
if (flags & MSG_DONTWAIT) { |
1256 |
|
- UDP6_INC_STATS_USER(UDP_MIB_INERRORS); |
1257 |
|
+ if (update_stat) |
1258 |
|
+ UDP6_INC_STATS_USER(UDP_MIB_INERRORS); |
1259 |
|
return -EAGAIN; |
1260 |
|
} |
1261 |
|
goto try_again; |
1262 |
|
--- linux-2.6.18-26etch2.orig/net/socket.c |
1263 |
|
+++ linux-2.6.18-26etch2/net/socket.c |
1264 |
|
@@ -94,6 +94,8 @@ |
1265 |
#include <net/sock.h> |
#include <net/sock.h> |
1266 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1267 |
|
|
1268 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo_socket.h> |
|
1269 |
+ |
+ |
1270 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1271 |
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
1272 |
size_t size, loff_t pos); |
size_t size, loff_t pos); |
1273 |
@@ -590,9 +593,12 @@ static inline int __sock_sendmsg(struct |
@@ -590,9 +592,10 @@ static inline int __sock_sendmsg(struct |
1274 |
si->size = size; |
si->size = size; |
1275 |
|
|
1276 |
err = security_socket_sendmsg(sock, msg, size); |
err = security_socket_sendmsg(sock, msg, size); |
1277 |
+ if (!err) |
+ if (!err) |
1278 |
+ err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *) |
+ err = ccs_socket_sendmsg_permission(sock, msg, size); |
|
+ msg->msg_name, |
|
|
+ msg->msg_namelen); |
|
1279 |
if (err) |
if (err) |
1280 |
return err; |
return err; |
1281 |
- |
- |
1282 |
return sock->ops->sendmsg(iocb, sock, msg, size); |
return sock->ops->sendmsg(iocb, sock, msg, size); |
1283 |
} |
} |
1284 |
|
|
1285 |
@@ -1149,6 +1155,8 @@ static int __sock_create(int family, int |
@@ -1149,6 +1152,8 @@ static int __sock_create(int family, int |
1286 |
} |
} |
1287 |
|
|
1288 |
err = security_socket_create(family, type, protocol, kern); |
err = security_socket_create(family, type, protocol, kern); |
1291 |
if (err) |
if (err) |
1292 |
return err; |
return err; |
1293 |
|
|
1294 |
@@ -1343,6 +1351,11 @@ asmlinkage long sys_bind(int fd, struct |
@@ -1343,6 +1348,11 @@ asmlinkage long sys_bind(int fd, struct |
1295 |
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) { |
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) { |
1296 |
err = security_socket_bind(sock, (struct sockaddr *)address, addrlen); |
err = security_socket_bind(sock, (struct sockaddr *)address, addrlen); |
1297 |
if (!err) |
if (!err) |
1303 |
err = sock->ops->bind(sock, |
err = sock->ops->bind(sock, |
1304 |
(struct sockaddr *)address, addrlen); |
(struct sockaddr *)address, addrlen); |
1305 |
} |
} |
1306 |
@@ -1371,6 +1384,8 @@ asmlinkage long sys_listen(int fd, int b |
@@ -1371,6 +1381,8 @@ asmlinkage long sys_listen(int fd, int b |
1307 |
|
|
1308 |
err = security_socket_listen(sock, backlog); |
err = security_socket_listen(sock, backlog); |
1309 |
if (!err) |
if (!err) |
1312 |
err = sock->ops->listen(sock, backlog); |
err = sock->ops->listen(sock, backlog); |
1313 |
|
|
1314 |
fput_light(sock->file, fput_needed); |
fput_light(sock->file, fput_needed); |
1315 |
@@ -1434,6 +1449,11 @@ asmlinkage long sys_accept(int fd, struc |
@@ -1402,6 +1414,7 @@ asmlinkage long sys_accept(int fd, struc |
1316 |
|
if (!sock) |
1317 |
|
goto out; |
1318 |
|
|
1319 |
|
+retry: |
1320 |
|
err = -ENFILE; |
1321 |
|
if (!(newsock = sock_alloc())) |
1322 |
|
goto out_put; |
1323 |
|
@@ -1434,6 +1447,11 @@ asmlinkage long sys_accept(int fd, struc |
1324 |
if (err < 0) |
if (err < 0) |
1325 |
goto out_fd; |
goto out_fd; |
1326 |
|
|
1327 |
+ if (ccs_socket_accept_permission(newsock, |
+ if (ccs_socket_post_accept_permission(sock, newsock)) { |
1328 |
+ (struct sockaddr *) address)) { |
+ fput(newfile); |
1329 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
+ put_unused_fd(newfd); |
1330 |
+ goto out_fd; |
+ goto retry; |
1331 |
+ } |
+ } |
1332 |
if (upeer_sockaddr) { |
if (upeer_sockaddr) { |
1333 |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
1334 |
err = -ECONNABORTED; |
err = -ECONNABORTED; |
1335 |
@@ -1488,9 +1508,11 @@ asmlinkage long sys_connect(int fd, stru |
@@ -1488,9 +1506,11 @@ asmlinkage long sys_connect(int fd, stru |
1336 |
goto out_put; |
goto out_put; |
1337 |
|
|
1338 |
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1345 |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
1346 |
sock->file->f_flags); |
sock->file->f_flags); |
1347 |
out_put: |
out_put: |
1348 |
--- linux-2.6.18-24etch2.orig/net/unix/af_unix.c |
--- linux-2.6.18-26etch2.orig/net/unix/af_unix.c |
1349 |
+++ linux-2.6.18-24etch2/net/unix/af_unix.c |
+++ linux-2.6.18-26etch2/net/unix/af_unix.c |
1350 |
@@ -116,6 +116,7 @@ |
@@ -116,6 +116,7 @@ |
1351 |
#include <linux/mount.h> |
#include <linux/mount.h> |
1352 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1353 |
#include <linux/security.h> |
#include <linux/security.h> |
1354 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
1355 |
|
|
1356 |
int sysctl_unix_max_dgram_qlen = 10; |
int sysctl_unix_max_dgram_qlen = 10; |
1357 |
|
|
1359 |
*/ |
*/ |
1360 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1361 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1362 |
+ err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
+ err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt, |
1363 |
+ nd.mnt, mode, 0); |
+ mode, 0); |
1364 |
+ if (!err) |
+ if (!err) |
1365 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1366 |
if (err) |
if (err) |
1367 |
goto out_mknod_dput; |
goto out_mknod_dput; |
1368 |
|
--- linux-2.6.18-26etch2.orig/security/Kconfig |
1369 |
|
+++ linux-2.6.18-26etch2/security/Kconfig |
1370 |
|
@@ -107,5 +107,7 @@ config SECURITY_SECLVL |
1371 |
|
|
1372 |
|
source security/selinux/Kconfig |
1373 |
|
|
1374 |
|
+source security/ccsecurity/Kconfig |
1375 |
|
+ |
1376 |
|
endmenu |
1377 |
|
|
1378 |
|
--- linux-2.6.18-26etch2.orig/security/Makefile |
1379 |
|
+++ linux-2.6.18-26etch2/security/Makefile |
1380 |
|
@@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin |
1381 |
|
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |
1382 |
|
obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o |
1383 |
|
obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o |
1384 |
|
+ |
1385 |
|
+subdir-$(CONFIG_CCSECURITY)+= ccsecurity |
1386 |
|
+obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o |