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