1 |
This is TOMOYO Linux patch for Hardened Gentoo. |
2 |
|
3 |
Source code for this patch is "emerge hardened-sources" |
4 |
--- |
5 |
fs/attr.c | 3 +++ |
6 |
fs/compat.c | 3 ++- |
7 |
fs/compat_ioctl.c | 7 +++++++ |
8 |
fs/exec.c | 10 +++++++++- |
9 |
fs/fcntl.c | 5 +++++ |
10 |
fs/ioctl.c | 5 +++++ |
11 |
fs/namei.c | 35 +++++++++++++++++++++++++++++++++++ |
12 |
fs/namespace.c | 24 ++++++++++++++++++++++++ |
13 |
fs/open.c | 14 ++++++++++++++ |
14 |
fs/proc/version.c | 7 +++++++ |
15 |
include/linux/init_task.h | 2 ++ |
16 |
include/linux/sched.h | 4 ++++ |
17 |
kernel/compat.c | 3 +++ |
18 |
kernel/kexec.c | 3 +++ |
19 |
kernel/kmod.c | 3 +++ |
20 |
kernel/module.c | 5 +++++ |
21 |
kernel/ptrace.c | 5 +++++ |
22 |
kernel/sched.c | 3 +++ |
23 |
kernel/signal.c | 7 +++++++ |
24 |
kernel/sys.c | 11 +++++++++++ |
25 |
kernel/sysctl.c | 4 ++++ |
26 |
kernel/time.c | 5 +++++ |
27 |
kernel/time/ntp.c | 6 ++++++ |
28 |
net/ipv4/inet_connection_sock.c | 3 +++ |
29 |
net/ipv4/inet_hashtables.c | 3 +++ |
30 |
net/ipv4/raw.c | 4 ++++ |
31 |
net/ipv4/udp.c | 8 +++++++- |
32 |
net/ipv6/raw.c | 4 ++++ |
33 |
net/ipv6/udp.c | 4 ++++ |
34 |
net/socket.c | 23 +++++++++++++++++++++++ |
35 |
net/unix/af_unix.c | 4 ++++ |
36 |
security/Kconfig | 2 ++ |
37 |
security/Makefile | 3 +++ |
38 |
33 files changed, 229 insertions(+), 3 deletions(-) |
39 |
|
40 |
--- linux-2.6.28-hardened-r7.orig/fs/attr.c |
41 |
+++ linux-2.6.28-hardened-r7/fs/attr.c |
42 |
@@ -14,6 +14,7 @@ |
43 |
#include <linux/fcntl.h> |
44 |
#include <linux/quotaops.h> |
45 |
#include <linux/security.h> |
46 |
+#include <linux/ccsecurity.h> |
47 |
|
48 |
/* Taken over from the old code... */ |
49 |
|
50 |
@@ -160,6 +161,8 @@ int notify_change(struct dentry * dentry |
51 |
return 0; |
52 |
|
53 |
error = security_inode_setattr(dentry, attr); |
54 |
+ if (!error) |
55 |
+ error = ccs_check_setattr_permission(dentry, attr); |
56 |
if (error) |
57 |
return error; |
58 |
|
59 |
--- linux-2.6.28-hardened-r7.orig/fs/compat.c |
60 |
+++ linux-2.6.28-hardened-r7/fs/compat.c |
61 |
@@ -56,6 +56,7 @@ |
62 |
#include <asm/mmu_context.h> |
63 |
#include <asm/ioctls.h> |
64 |
#include "internal.h" |
65 |
+#include <linux/ccsecurity.h> |
66 |
|
67 |
int compat_log = 1; |
68 |
|
69 |
@@ -1472,7 +1473,7 @@ int compat_do_execve(char * filename, |
70 |
|
71 |
gr_set_proc_label(file->f_dentry, file->f_vfsmnt); |
72 |
|
73 |
- retval = search_binary_handler(bprm, regs); |
74 |
+ retval = ccs_search_binary_handler(bprm, regs); |
75 |
if (retval >= 0) { |
76 |
#ifdef CONFIG_GRKERNSEC |
77 |
if (old_exec_file) |
78 |
--- linux-2.6.28-hardened-r7.orig/fs/compat_ioctl.c |
79 |
+++ linux-2.6.28-hardened-r7/fs/compat_ioctl.c |
80 |
@@ -113,6 +113,7 @@ |
81 |
#ifdef CONFIG_SPARC |
82 |
#include <asm/fbio.h> |
83 |
#endif |
84 |
+#include <linux/ccsecurity.h> |
85 |
|
86 |
static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
87 |
unsigned long arg, struct file *f) |
88 |
@@ -2788,6 +2789,8 @@ asmlinkage long compat_sys_ioctl(unsigne |
89 |
|
90 |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
91 |
error = security_file_ioctl(filp, cmd, arg); |
92 |
+ if (!error) |
93 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
94 |
if (error) |
95 |
goto out_fput; |
96 |
|
97 |
@@ -2812,6 +2815,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
98 |
/*FALL THROUGH*/ |
99 |
|
100 |
default: |
101 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
102 |
+ error = -EPERM; |
103 |
+ goto out_fput; |
104 |
+ } |
105 |
if (filp->f_op && filp->f_op->compat_ioctl) { |
106 |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
107 |
if (error != -ENOIOCTLCMD) |
108 |
--- linux-2.6.28-hardened-r7.orig/fs/exec.c |
109 |
+++ linux-2.6.28-hardened-r7/fs/exec.c |
110 |
@@ -72,6 +72,8 @@ void (*pax_set_initial_flags_func)(struc |
111 |
EXPORT_SYMBOL(pax_set_initial_flags_func); |
112 |
#endif |
113 |
|
114 |
+#include <linux/ccsecurity.h> |
115 |
+ |
116 |
int core_uses_pid; |
117 |
char core_pattern[CORENAME_MAX_SIZE] = "core"; |
118 |
int suid_dumpable = 0; |
119 |
@@ -140,6 +142,9 @@ SYSCALL_DEFINE1(uselib, const char __use |
120 |
error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN); |
121 |
if (error) |
122 |
goto exit; |
123 |
+ error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt); |
124 |
+ if (error) |
125 |
+ goto exit; |
126 |
|
127 |
file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
128 |
error = PTR_ERR(file); |
129 |
@@ -710,6 +715,9 @@ struct file *open_exec(const char *name) |
130 |
err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN); |
131 |
if (err) |
132 |
goto out_path_put; |
133 |
+ err = ccs_check_open_exec_permission(nd.path.dentry, nd.path.mnt); |
134 |
+ if (err) |
135 |
+ goto out_path_put; |
136 |
|
137 |
file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
138 |
if (IS_ERR(file)) |
139 |
@@ -1413,7 +1421,7 @@ int do_execve(char * filename, |
140 |
goto out_fail; |
141 |
|
142 |
current->flags &= ~PF_KTHREAD; |
143 |
- retval = search_binary_handler(bprm,regs); |
144 |
+ retval = ccs_search_binary_handler(bprm, regs); |
145 |
if (retval >= 0) { |
146 |
#ifdef CONFIG_GRKERNSEC |
147 |
if (old_exec_file) |
148 |
--- linux-2.6.28-hardened-r7.orig/fs/fcntl.c |
149 |
+++ linux-2.6.28-hardened-r7/fs/fcntl.c |
150 |
@@ -24,6 +24,7 @@ |
151 |
#include <asm/poll.h> |
152 |
#include <asm/siginfo.h> |
153 |
#include <asm/uaccess.h> |
154 |
+#include <linux/ccsecurity.h> |
155 |
|
156 |
void set_close_on_exec(unsigned int fd, int flag) |
157 |
{ |
158 |
@@ -155,6 +156,10 @@ static int setfl(int fd, struct file * f |
159 |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
160 |
return -EPERM; |
161 |
|
162 |
+ if (((arg ^ filp->f_flags) & O_APPEND) && |
163 |
+ ccs_check_rewrite_permission(filp)) |
164 |
+ return -EPERM; |
165 |
+ |
166 |
/* O_NOATIME can only be set by the owner or superuser */ |
167 |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
168 |
if (!is_owner_or_cap(inode)) |
169 |
--- linux-2.6.28-hardened-r7.orig/fs/ioctl.c |
170 |
+++ linux-2.6.28-hardened-r7/fs/ioctl.c |
171 |
@@ -17,6 +17,7 @@ |
172 |
#include <linux/buffer_head.h> |
173 |
|
174 |
#include <asm/ioctls.h> |
175 |
+#include <linux/ccsecurity.h> |
176 |
|
177 |
/* So that the fiemap access checks can't overflow on 32 bit machines. */ |
178 |
#define FIEMAP_MAX_EXTENTS (UINT_MAX / sizeof(struct fiemap_extent)) |
179 |
@@ -40,6 +41,8 @@ static long vfs_ioctl(struct file *filp, |
180 |
|
181 |
if (!filp->f_op) |
182 |
goto out; |
183 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
184 |
+ return -EPERM; |
185 |
|
186 |
if (filp->f_op->unlocked_ioctl) { |
187 |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
188 |
@@ -483,6 +486,8 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd, |
189 |
goto out; |
190 |
|
191 |
error = security_file_ioctl(filp, cmd, arg); |
192 |
+ if (!error) |
193 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
194 |
if (error) |
195 |
goto out_fput; |
196 |
|
197 |
--- linux-2.6.28-hardened-r7.orig/fs/namei.c |
198 |
+++ linux-2.6.28-hardened-r7/fs/namei.c |
199 |
@@ -35,6 +35,8 @@ |
200 |
|
201 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
202 |
|
203 |
+#include <linux/ccsecurity.h> |
204 |
+ |
205 |
/* [Feb-1997 T. Schoebel-Theuer] |
206 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
207 |
* were necessary because of omirr. The reason is that omirr needs |
208 |
@@ -1552,6 +1554,11 @@ int may_open(struct nameidata *nd, int a |
209 |
if (!is_owner_or_cap(inode)) |
210 |
return -EPERM; |
211 |
|
212 |
+ /* includes O_APPEND and O_TRUNC checks */ |
213 |
+ error = ccs_check_open_permission(dentry, nd->path.mnt, flag); |
214 |
+ if (error) |
215 |
+ return error; |
216 |
+ |
217 |
/* |
218 |
* Ensure there are no outstanding leases on the file. |
219 |
*/ |
220 |
@@ -1603,6 +1610,9 @@ static int __open_namei_create(struct na |
221 |
|
222 |
if (!IS_POSIXACL(dir->d_inode)) |
223 |
mode &= ~current->fs->umask; |
224 |
+ error = ccs_check_mknod_permission(dir->d_inode, path->dentry, |
225 |
+ nd->path.mnt, mode, 0); |
226 |
+ if (!error) |
227 |
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
228 |
if (!error) |
229 |
gr_handle_create(path->dentry, nd->path.mnt); |
230 |
@@ -1616,6 +1626,7 @@ out_unlock_dput: |
231 |
return may_open(nd, 0, flag & ~O_TRUNC); |
232 |
} |
233 |
|
234 |
+#include <linux/ccsecurity_vfs.h> |
235 |
/* |
236 |
* Note that while the flag value (low two bits) for sys_open means: |
237 |
* 00 - read-only |
238 |
@@ -2062,6 +2073,10 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const |
239 |
error = mnt_want_write(nd.path.mnt); |
240 |
if (error) |
241 |
goto out_dput; |
242 |
+ error = ccs_check_mknod_permission(nd.path.dentry->d_inode, dentry, |
243 |
+ nd.path.mnt, mode, |
244 |
+ new_decode_dev(dev)); |
245 |
+ if (!error) |
246 |
switch (mode & S_IFMT) { |
247 |
case 0: case S_IFREG: |
248 |
error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); |
249 |
@@ -2141,6 +2156,9 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const |
250 |
error = mnt_want_write(nd.path.mnt); |
251 |
if (error) |
252 |
goto out_dput; |
253 |
+ error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry, |
254 |
+ nd.path.mnt, mode); |
255 |
+ if (!error) |
256 |
error = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode); |
257 |
mnt_drop_write(nd.path.mnt); |
258 |
|
259 |
@@ -2270,6 +2288,9 @@ static long do_rmdir(int dfd, const char |
260 |
error = mnt_want_write(nd.path.mnt); |
261 |
if (error) |
262 |
goto exit3; |
263 |
+ error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry, |
264 |
+ nd.path.mnt); |
265 |
+ if (!error) |
266 |
error = vfs_rmdir(nd.path.dentry->d_inode, dentry); |
267 |
mnt_drop_write(nd.path.mnt); |
268 |
if (!error && (saved_dev || saved_ino)) |
269 |
@@ -2370,6 +2391,9 @@ static long do_unlinkat(int dfd, const c |
270 |
error = mnt_want_write(nd.path.mnt); |
271 |
if (error) |
272 |
goto exit2; |
273 |
+ error = ccs_check_unlink_permission(nd.path.dentry->d_inode, |
274 |
+ dentry, nd.path.mnt); |
275 |
+ if (!error) |
276 |
error = vfs_unlink(nd.path.dentry->d_inode, dentry); |
277 |
if (!error && (saved_ino || saved_dev)) |
278 |
gr_handle_delete(saved_ino, saved_dev); |
279 |
@@ -2458,6 +2482,9 @@ SYSCALL_DEFINE3(symlinkat, const char __ |
280 |
error = mnt_want_write(nd.path.mnt); |
281 |
if (error) |
282 |
goto out_dput; |
283 |
+ error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry, |
284 |
+ nd.path.mnt, from); |
285 |
+ if (!error) |
286 |
error = vfs_symlink(nd.path.dentry->d_inode, dentry, from); |
287 |
if (!error) |
288 |
gr_handle_create(dentry, nd.path.mnt); |
289 |
@@ -2570,6 +2597,10 @@ SYSCALL_DEFINE5(linkat, int, olddfd, con |
290 |
error = mnt_want_write(nd.path.mnt); |
291 |
if (error) |
292 |
goto out_dput; |
293 |
+ error = ccs_check_link_permission(old_path.dentry, |
294 |
+ nd.path.dentry->d_inode, new_dentry, |
295 |
+ nd.path.mnt); |
296 |
+ if (!error) |
297 |
error = vfs_link(old_path.dentry, nd.path.dentry->d_inode, new_dentry); |
298 |
if (!error) |
299 |
gr_handle_create(new_dentry, nd.path.mnt); |
300 |
@@ -2814,6 +2845,10 @@ SYSCALL_DEFINE4(renameat, int, olddfd, c |
301 |
error = mnt_want_write(oldnd.path.mnt); |
302 |
if (error) |
303 |
goto exit5; |
304 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
305 |
+ new_dir->d_inode, new_dentry, |
306 |
+ newnd.path.mnt); |
307 |
+ if (!error) |
308 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
309 |
new_dir->d_inode, new_dentry); |
310 |
if (!error) |
311 |
--- linux-2.6.28-hardened-r7.orig/fs/namespace.c |
312 |
+++ linux-2.6.28-hardened-r7/fs/namespace.c |
313 |
@@ -31,6 +31,7 @@ |
314 |
#include <asm/unistd.h> |
315 |
#include "pnode.h" |
316 |
#include "internal.h" |
317 |
+#include <linux/ccsecurity.h> |
318 |
|
319 |
#define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head)) |
320 |
#define HASH_SIZE (1UL << HASH_SHIFT) |
321 |
@@ -1041,6 +1042,9 @@ static int do_umount(struct vfsmount *mn |
322 |
if (retval) |
323 |
return retval; |
324 |
|
325 |
+ if (ccs_may_umount(mnt)) |
326 |
+ return -EPERM; |
327 |
+ |
328 |
/* |
329 |
* Allow userspace to request a mountpoint be expired rather than |
330 |
* unmounting unconditionally. Unmount only happens if: |
331 |
@@ -1137,6 +1141,8 @@ SYSCALL_DEFINE2(umount, char __user *, n |
332 |
{ |
333 |
struct path path; |
334 |
int retval; |
335 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
336 |
+ return -EPERM; |
337 |
|
338 |
retval = user_path(name, &path); |
339 |
if (retval) |
340 |
@@ -1485,6 +1491,9 @@ static int do_loopback(struct path *path |
341 |
|
342 |
if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
343 |
goto out; |
344 |
+ err = -EPERM; |
345 |
+ if (ccs_may_mount(path)) |
346 |
+ goto out; |
347 |
|
348 |
err = -ENOMEM; |
349 |
if (recurse) |
350 |
@@ -1596,6 +1605,9 @@ static int do_move_mount(struct path *pa |
351 |
if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
352 |
goto out; |
353 |
|
354 |
+ err = -EPERM; |
355 |
+ if (ccs_may_umount(old_path.mnt) || ccs_may_mount(path)) |
356 |
+ goto out; |
357 |
err = -ENOENT; |
358 |
mutex_lock(&path->dentry->d_inode->i_mutex); |
359 |
if (IS_DEADDIR(path->dentry->d_inode)) |
360 |
@@ -1699,6 +1711,9 @@ int do_add_mount(struct vfsmount *newmnt |
361 |
err = -EINVAL; |
362 |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
363 |
goto unlock; |
364 |
+ err = -EPERM; |
365 |
+ if (ccs_may_mount(path)) |
366 |
+ goto unlock; |
367 |
|
368 |
newmnt->mnt_flags = mnt_flags; |
369 |
if ((err = graft_tree(newmnt, path))) |
370 |
@@ -1922,6 +1937,11 @@ long do_mount(char *dev_name, char *dir_ |
371 |
if (data_page) |
372 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
373 |
|
374 |
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
375 |
+ &flags); |
376 |
+ if (retval) |
377 |
+ return retval; |
378 |
+ |
379 |
/* Separate the per-mountpoint flags */ |
380 |
if (flags & MS_NOSUID) |
381 |
mnt_flags |= MNT_NOSUID; |
382 |
@@ -2196,6 +2216,8 @@ SYSCALL_DEFINE2(pivot_root, const char _ |
383 |
|
384 |
if (!capable(CAP_SYS_ADMIN)) |
385 |
return -EPERM; |
386 |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
387 |
+ return -EPERM; |
388 |
|
389 |
error = user_path_dir(new_root, &new); |
390 |
if (error) |
391 |
@@ -2209,6 +2231,8 @@ SYSCALL_DEFINE2(pivot_root, const char _ |
392 |
goto out1; |
393 |
|
394 |
error = security_sb_pivotroot(&old, &new); |
395 |
+ if (!error) |
396 |
+ error = ccs_check_pivot_root_permission(&old, &new); |
397 |
if (error) { |
398 |
path_put(&old); |
399 |
goto out1; |
400 |
--- linux-2.6.28-hardened-r7.orig/fs/open.c |
401 |
+++ linux-2.6.28-hardened-r7/fs/open.c |
402 |
@@ -29,6 +29,7 @@ |
403 |
#include <linux/rcupdate.h> |
404 |
#include <linux/audit.h> |
405 |
#include <linux/falloc.h> |
406 |
+#include <linux/ccsecurity.h> |
407 |
|
408 |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
409 |
{ |
410 |
@@ -272,6 +273,9 @@ static long do_sys_truncate(const char _ |
411 |
if (error) |
412 |
goto put_write_and_out; |
413 |
|
414 |
+ error = ccs_check_truncate_permission(path.dentry, path.mnt, length, 0); |
415 |
+ if (error) |
416 |
+ goto put_write_and_out; |
417 |
error = locks_verify_truncate(inode, NULL, length); |
418 |
if (!error) { |
419 |
DQUOT_INIT(inode); |
420 |
@@ -328,6 +332,10 @@ static long do_sys_ftruncate(unsigned in |
421 |
if (IS_APPEND(inode)) |
422 |
goto out_putf; |
423 |
|
424 |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
425 |
+ 0); |
426 |
+ if (error) |
427 |
+ goto out_putf; |
428 |
error = locks_verify_truncate(inode, file, length); |
429 |
if (!error) |
430 |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
431 |
@@ -605,6 +613,10 @@ SYSCALL_DEFINE1(chroot, const char __use |
432 |
error = -EPERM; |
433 |
if (!capable(CAP_SYS_CHROOT)) |
434 |
goto dput_and_out; |
435 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
436 |
+ goto dput_and_out; |
437 |
+ if (ccs_check_chroot_permission(&path)) |
438 |
+ goto dput_and_out; |
439 |
|
440 |
if (gr_handle_chroot_chroot(path.dentry, path.mnt)) |
441 |
goto dput_and_out; |
442 |
@@ -1211,6 +1223,8 @@ EXPORT_SYMBOL(sys_close); |
443 |
*/ |
444 |
SYSCALL_DEFINE0(vhangup) |
445 |
{ |
446 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
447 |
+ return -EPERM; |
448 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
449 |
tty_vhangup_self(); |
450 |
return 0; |
451 |
--- linux-2.6.28-hardened-r7.orig/fs/proc/version.c |
452 |
+++ linux-2.6.28-hardened-r7/fs/proc/version.c |
453 |
@@ -32,3 +32,10 @@ static int __init proc_version_init(void |
454 |
return 0; |
455 |
} |
456 |
module_init(proc_version_init); |
457 |
+ |
458 |
+static int __init ccs_show_version(void) |
459 |
+{ |
460 |
+ printk(KERN_INFO "Hook version: 2.6.28-hardened-r7 2009/08/05\n"); |
461 |
+ return 0; |
462 |
+} |
463 |
+module_init(ccs_show_version); |
464 |
--- linux-2.6.28-hardened-r7.orig/include/linux/init_task.h |
465 |
+++ linux-2.6.28-hardened-r7/include/linux/init_task.h |
466 |
@@ -180,6 +180,8 @@ extern struct group_info init_groups; |
467 |
INIT_IDS \ |
468 |
INIT_TRACE_IRQFLAGS \ |
469 |
INIT_LOCKDEP \ |
470 |
+ .ccs_domain_info = NULL, \ |
471 |
+ .ccs_flags = 0, \ |
472 |
} |
473 |
|
474 |
|
475 |
--- linux-2.6.28-hardened-r7.orig/include/linux/sched.h |
476 |
+++ linux-2.6.28-hardened-r7/include/linux/sched.h |
477 |
@@ -29,6 +29,8 @@ |
478 |
#define CLONE_NEWNET 0x40000000 /* New network namespace */ |
479 |
#define CLONE_IO 0x80000000 /* Clone io context */ |
480 |
|
481 |
+struct ccs_domain_info; |
482 |
+ |
483 |
/* |
484 |
* Scheduling policies |
485 |
*/ |
486 |
@@ -1375,6 +1377,8 @@ struct task_struct { |
487 |
u8 is_writable; |
488 |
u8 brute; |
489 |
#endif |
490 |
+ struct ccs_domain_info *ccs_domain_info; |
491 |
+ u32 ccs_flags; |
492 |
|
493 |
}; |
494 |
|
495 |
--- linux-2.6.28-hardened-r7.orig/kernel/compat.c |
496 |
+++ linux-2.6.28-hardened-r7/kernel/compat.c |
497 |
@@ -26,6 +26,7 @@ |
498 |
#include <linux/times.h> |
499 |
|
500 |
#include <asm/uaccess.h> |
501 |
+#include <linux/ccsecurity.h> |
502 |
|
503 |
/* |
504 |
* Note that the native side is already converted to a timespec, because |
505 |
@@ -901,6 +902,8 @@ asmlinkage long compat_sys_stime(compat_ |
506 |
err = security_settime(&tv, NULL); |
507 |
if (err) |
508 |
return err; |
509 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
510 |
+ return -EPERM; |
511 |
|
512 |
do_settimeofday(&tv); |
513 |
return 0; |
514 |
--- linux-2.6.28-hardened-r7.orig/kernel/kexec.c |
515 |
+++ linux-2.6.28-hardened-r7/kernel/kexec.c |
516 |
@@ -37,6 +37,7 @@ |
517 |
#include <asm/io.h> |
518 |
#include <asm/system.h> |
519 |
#include <asm/sections.h> |
520 |
+#include <linux/ccsecurity.h> |
521 |
|
522 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
523 |
note_buf_t* crash_notes; |
524 |
@@ -943,6 +944,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon |
525 |
/* We only trust the superuser with rebooting the system. */ |
526 |
if (!capable(CAP_SYS_BOOT)) |
527 |
return -EPERM; |
528 |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
529 |
+ return -EPERM; |
530 |
|
531 |
/* |
532 |
* Verify we have a legal set of flags |
533 |
--- linux-2.6.28-hardened-r7.orig/kernel/kmod.c |
534 |
+++ linux-2.6.28-hardened-r7/kernel/kmod.c |
535 |
@@ -174,6 +174,9 @@ static int ____call_usermodehelper(void |
536 |
*/ |
537 |
set_user_nice(current, 0); |
538 |
|
539 |
+ current->ccs_domain_info = NULL; |
540 |
+ current->ccs_flags = 0; |
541 |
+ |
542 |
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
543 |
|
544 |
/* Exec failed? */ |
545 |
--- linux-2.6.28-hardened-r7.orig/kernel/module.c |
546 |
+++ linux-2.6.28-hardened-r7/kernel/module.c |
547 |
@@ -56,6 +56,7 @@ |
548 |
#include <asm/sections.h> |
549 |
#include <linux/tracepoint.h> |
550 |
#include <linux/ftrace.h> |
551 |
+#include <linux/ccsecurity.h> |
552 |
|
553 |
#if 0 |
554 |
#define DEBUGP printk |
555 |
@@ -769,6 +770,8 @@ SYSCALL_DEFINE2(delete_module, const cha |
556 |
|
557 |
if (!capable(CAP_SYS_MODULE)) |
558 |
return -EPERM; |
559 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
560 |
+ return -EPERM; |
561 |
|
562 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
563 |
return -EFAULT; |
564 |
@@ -2449,6 +2452,8 @@ SYSCALL_DEFINE3(init_module, void __user |
565 |
/* Must have permission */ |
566 |
if (!capable(CAP_SYS_MODULE)) |
567 |
return -EPERM; |
568 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
569 |
+ return -EPERM; |
570 |
|
571 |
/* Only one module load at a time, please */ |
572 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
573 |
--- linux-2.6.28-hardened-r7.orig/kernel/ptrace.c |
574 |
+++ linux-2.6.28-hardened-r7/kernel/ptrace.c |
575 |
@@ -24,6 +24,7 @@ |
576 |
|
577 |
#include <asm/pgtable.h> |
578 |
#include <asm/uaccess.h> |
579 |
+#include <linux/ccsecurity.h> |
580 |
|
581 |
/* |
582 |
* ptrace a task: make the debugger its new parent and |
583 |
@@ -549,6 +550,8 @@ SYSCALL_DEFINE4(ptrace, long, request, l |
584 |
{ |
585 |
struct task_struct *child; |
586 |
long ret; |
587 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
588 |
+ return -EPERM; |
589 |
|
590 |
/* |
591 |
* This lock_kernel fixes a subtle race with suid exec |
592 |
@@ -677,6 +680,8 @@ asmlinkage long compat_sys_ptrace(compat |
593 |
{ |
594 |
struct task_struct *child; |
595 |
long ret; |
596 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
597 |
+ return -EPERM; |
598 |
|
599 |
/* |
600 |
* This lock_kernel fixes a subtle race with suid exec |
601 |
--- linux-2.6.28-hardened-r7.orig/kernel/sched.c |
602 |
+++ linux-2.6.28-hardened-r7/kernel/sched.c |
603 |
@@ -76,6 +76,7 @@ |
604 |
|
605 |
#include <asm/tlb.h> |
606 |
#include <asm/irq_regs.h> |
607 |
+#include <linux/ccsecurity.h> |
608 |
|
609 |
#include "sched_cpupri.h" |
610 |
|
611 |
@@ -5028,6 +5029,8 @@ int can_nice(const struct task_struct *p |
612 |
SYSCALL_DEFINE1(nice, int, increment) |
613 |
{ |
614 |
long nice, retval; |
615 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
616 |
+ return -EPERM; |
617 |
|
618 |
/* |
619 |
* Setpriority might change our priority at the same moment. |
620 |
--- linux-2.6.28-hardened-r7.orig/kernel/signal.c |
621 |
+++ linux-2.6.28-hardened-r7/kernel/signal.c |
622 |
@@ -34,6 +34,7 @@ |
623 |
#include <asm/unistd.h> |
624 |
#include <asm/siginfo.h> |
625 |
#include "audit.h" /* audit_signal_info() */ |
626 |
+#include <linux/ccsecurity.h> |
627 |
|
628 |
/* |
629 |
* SLAB caches for signal bits. |
630 |
@@ -2210,6 +2211,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s |
631 |
SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) |
632 |
{ |
633 |
struct siginfo info; |
634 |
+ if (ccs_kill_permission(pid, sig)) |
635 |
+ return -EPERM; |
636 |
|
637 |
info.si_signo = sig; |
638 |
info.si_errno = 0; |
639 |
@@ -2271,6 +2274,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid |
640 |
/* This is only valid for single tasks */ |
641 |
if (pid <= 0 || tgid <= 0) |
642 |
return -EINVAL; |
643 |
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
644 |
+ return -EPERM; |
645 |
|
646 |
return do_tkill(tgid, pid, sig); |
647 |
} |
648 |
@@ -2283,6 +2288,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int, |
649 |
/* This is only valid for single tasks */ |
650 |
if (pid <= 0) |
651 |
return -EINVAL; |
652 |
+ if (ccs_tkill_permission(pid, sig)) |
653 |
+ return -EPERM; |
654 |
|
655 |
return do_tkill(0, pid, sig); |
656 |
} |
657 |
--- linux-2.6.28-hardened-r7.orig/kernel/sys.c |
658 |
+++ linux-2.6.28-hardened-r7/kernel/sys.c |
659 |
@@ -42,6 +42,7 @@ |
660 |
#include <asm/uaccess.h> |
661 |
#include <asm/io.h> |
662 |
#include <asm/unistd.h> |
663 |
+#include <linux/ccsecurity.h> |
664 |
|
665 |
#ifndef SET_UNALIGN_CTL |
666 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
667 |
@@ -152,6 +153,10 @@ SYSCALL_DEFINE3(setpriority, int, which, |
668 |
|
669 |
if (which > PRIO_USER || which < PRIO_PROCESS) |
670 |
goto out; |
671 |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
672 |
+ error = -EPERM; |
673 |
+ goto out; |
674 |
+ } |
675 |
|
676 |
/* normalize: avoid signed division (rounding problems) */ |
677 |
error = -ESRCH; |
678 |
@@ -369,6 +374,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int |
679 |
magic2 != LINUX_REBOOT_MAGIC2B && |
680 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
681 |
return -EINVAL; |
682 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
683 |
+ return -EPERM; |
684 |
|
685 |
/* Instead of trying to make the power_off code look like |
686 |
* halt when pm_power_off is not set do it the easy way. |
687 |
@@ -1387,6 +1394,8 @@ SYSCALL_DEFINE2(sethostname, char __user |
688 |
return -EPERM; |
689 |
if (len < 0 || len > __NEW_UTS_LEN) |
690 |
return -EINVAL; |
691 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
692 |
+ return -EPERM; |
693 |
down_write(&uts_sem); |
694 |
errno = -EFAULT; |
695 |
if (!copy_from_user(tmp, name, len)) { |
696 |
@@ -1436,6 +1445,8 @@ SYSCALL_DEFINE2(setdomainname, char __us |
697 |
return -EPERM; |
698 |
if (len < 0 || len > __NEW_UTS_LEN) |
699 |
return -EINVAL; |
700 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
701 |
+ return -EPERM; |
702 |
|
703 |
down_write(&uts_sem); |
704 |
errno = -EFAULT; |
705 |
--- linux-2.6.28-hardened-r7.orig/kernel/sysctl.c |
706 |
+++ linux-2.6.28-hardened-r7/kernel/sysctl.c |
707 |
@@ -51,6 +51,7 @@ |
708 |
|
709 |
#include <asm/uaccess.h> |
710 |
#include <asm/processor.h> |
711 |
+#include <linux/ccsecurity.h> |
712 |
|
713 |
#ifdef CONFIG_X86 |
714 |
#include <asm/nmi.h> |
715 |
@@ -1667,6 +1668,9 @@ int do_sysctl(int __user *name, int nlen |
716 |
|
717 |
for (head = sysctl_head_next(NULL); head; |
718 |
head = sysctl_head_next(head)) { |
719 |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
720 |
+ head->ctl_table); |
721 |
+ if (!error) |
722 |
error = parse_table(name, nlen, oldval, oldlenp, |
723 |
newval, newlen, |
724 |
head->root, head->ctl_table); |
725 |
--- linux-2.6.28-hardened-r7.orig/kernel/time.c |
726 |
+++ linux-2.6.28-hardened-r7/kernel/time.c |
727 |
@@ -40,6 +40,7 @@ |
728 |
|
729 |
#include <asm/uaccess.h> |
730 |
#include <asm/unistd.h> |
731 |
+#include <linux/ccsecurity.h> |
732 |
|
733 |
#include "timeconst.h" |
734 |
|
735 |
@@ -90,6 +91,8 @@ SYSCALL_DEFINE1(stime, time_t __user *, |
736 |
err = security_settime(&tv, NULL); |
737 |
if (err) |
738 |
return err; |
739 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
740 |
+ return -EPERM; |
741 |
|
742 |
do_settimeofday(&tv); |
743 |
|
744 |
@@ -164,6 +167,8 @@ int do_sys_settimeofday(struct timespec |
745 |
error = security_settime(tv, tz); |
746 |
if (error) |
747 |
return error; |
748 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
749 |
+ return -EPERM; |
750 |
|
751 |
if (tz) { |
752 |
/* SMP safe, global irq locking makes it work. */ |
753 |
--- linux-2.6.28-hardened-r7.orig/kernel/time/ntp.c |
754 |
+++ linux-2.6.28-hardened-r7/kernel/time/ntp.c |
755 |
@@ -18,6 +18,7 @@ |
756 |
#include <linux/clocksource.h> |
757 |
#include <linux/workqueue.h> |
758 |
#include <asm/timex.h> |
759 |
+#include <linux/ccsecurity.h> |
760 |
|
761 |
/* |
762 |
* Timekeeping variables |
763 |
@@ -286,10 +287,15 @@ int do_adjtimex(struct timex *txc) |
764 |
if (!(txc->modes & ADJ_OFFSET_READONLY) && |
765 |
!capable(CAP_SYS_TIME)) |
766 |
return -EPERM; |
767 |
+ if (!(txc->modes & ADJ_OFFSET_READONLY) && |
768 |
+ !ccs_capable(CCS_SYS_SETTIME)) |
769 |
+ return -EPERM; |
770 |
} else { |
771 |
/* In order to modify anything, you gotta be super-user! */ |
772 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
773 |
return -EPERM; |
774 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
775 |
+ return -EPERM; |
776 |
|
777 |
/* if the quartz is off by more than 10% something is VERY wrong! */ |
778 |
if (txc->modes & ADJ_TICK && |
779 |
--- linux-2.6.28-hardened-r7.orig/net/ipv4/inet_connection_sock.c |
780 |
+++ linux-2.6.28-hardened-r7/net/ipv4/inet_connection_sock.c |
781 |
@@ -24,6 +24,7 @@ |
782 |
#include <net/route.h> |
783 |
#include <net/tcp_states.h> |
784 |
#include <net/xfrm.h> |
785 |
+#include <linux/ccsecurity.h> |
786 |
|
787 |
#ifdef INET_CSK_DEBUG |
788 |
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
789 |
@@ -109,6 +110,8 @@ int inet_csk_get_port(struct sock *sk, u |
790 |
head = &hashinfo->bhash[inet_bhashfn(net, rover, |
791 |
hashinfo->bhash_size)]; |
792 |
spin_lock(&head->lock); |
793 |
+ if (ccs_lport_reserved(rover)) |
794 |
+ goto next; |
795 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
796 |
if (tb->ib_net == net && tb->port == rover) |
797 |
goto next; |
798 |
--- linux-2.6.28-hardened-r7.orig/net/ipv4/inet_hashtables.c |
799 |
+++ linux-2.6.28-hardened-r7/net/ipv4/inet_hashtables.c |
800 |
@@ -23,6 +23,7 @@ |
801 |
#include <net/inet_connection_sock.h> |
802 |
#include <net/inet_hashtables.h> |
803 |
#include <net/ip.h> |
804 |
+#include <linux/ccsecurity.h> |
805 |
|
806 |
extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet); |
807 |
|
808 |
@@ -443,6 +444,8 @@ int __inet_hash_connect(struct inet_time |
809 |
local_bh_disable(); |
810 |
for (i = 1; i <= remaining; i++) { |
811 |
port = low + (i + offset) % remaining; |
812 |
+ if (ccs_lport_reserved(port)) |
813 |
+ continue; |
814 |
head = &hinfo->bhash[inet_bhashfn(net, port, |
815 |
hinfo->bhash_size)]; |
816 |
spin_lock(&head->lock); |
817 |
--- linux-2.6.28-hardened-r7.orig/net/ipv4/raw.c |
818 |
+++ linux-2.6.28-hardened-r7/net/ipv4/raw.c |
819 |
@@ -77,6 +77,7 @@ |
820 |
#include <linux/seq_file.h> |
821 |
#include <linux/netfilter.h> |
822 |
#include <linux/netfilter_ipv4.h> |
823 |
+#include <linux/ccsecurity.h> |
824 |
|
825 |
static struct raw_hashinfo raw_v4_hashinfo = { |
826 |
.lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock), |
827 |
@@ -665,6 +666,9 @@ static int raw_recvmsg(struct kiocb *ioc |
828 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
829 |
if (!skb) |
830 |
goto out; |
831 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
832 |
+ if (err) |
833 |
+ goto out; |
834 |
|
835 |
copied = skb->len; |
836 |
if (len < copied) { |
837 |
--- linux-2.6.28-hardened-r7.orig/net/ipv4/udp.c |
838 |
+++ linux-2.6.28-hardened-r7/net/ipv4/udp.c |
839 |
@@ -104,6 +104,7 @@ |
840 |
#include <net/checksum.h> |
841 |
#include <net/xfrm.h> |
842 |
#include "udp_impl.h" |
843 |
+#include <linux/ccsecurity.h> |
844 |
|
845 |
extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb); |
846 |
extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr); |
847 |
@@ -176,7 +177,9 @@ int udp_lib_get_port(struct sock *sk, un |
848 |
snum = first = rand % remaining + low; |
849 |
rand |= 1; |
850 |
while (udp_lib_lport_inuse(net, snum, udptable, sk, |
851 |
- saddr_comp)) { |
852 |
+ saddr_comp) |
853 |
+ || ccs_lport_reserved(snum) |
854 |
+ ) { |
855 |
do { |
856 |
snum = snum + rand; |
857 |
} while (snum < low || snum > high); |
858 |
@@ -861,6 +864,9 @@ try_again: |
859 |
&peeked, &err); |
860 |
if (!skb) |
861 |
goto out; |
862 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
863 |
+ if (err) |
864 |
+ goto out; |
865 |
|
866 |
err = gr_search_udp_recvmsg(sk, skb); |
867 |
if (err) |
868 |
--- linux-2.6.28-hardened-r7.orig/net/ipv6/raw.c |
869 |
+++ linux-2.6.28-hardened-r7/net/ipv6/raw.c |
870 |
@@ -59,6 +59,7 @@ |
871 |
|
872 |
#include <linux/proc_fs.h> |
873 |
#include <linux/seq_file.h> |
874 |
+#include <linux/ccsecurity.h> |
875 |
|
876 |
static struct raw_hashinfo raw_v6_hashinfo = { |
877 |
.lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock), |
878 |
@@ -465,6 +466,9 @@ static int rawv6_recvmsg(struct kiocb *i |
879 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
880 |
if (!skb) |
881 |
goto out; |
882 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
883 |
+ if (err) |
884 |
+ goto out; |
885 |
|
886 |
copied = skb->len; |
887 |
if (copied > len) { |
888 |
--- linux-2.6.28-hardened-r7.orig/net/ipv6/udp.c |
889 |
+++ linux-2.6.28-hardened-r7/net/ipv6/udp.c |
890 |
@@ -48,6 +48,7 @@ |
891 |
#include <linux/proc_fs.h> |
892 |
#include <linux/seq_file.h> |
893 |
#include "udp_impl.h" |
894 |
+#include <linux/ccsecurity.h> |
895 |
|
896 |
int udp_v6_get_port(struct sock *sk, unsigned short snum) |
897 |
{ |
898 |
@@ -151,6 +152,9 @@ try_again: |
899 |
&peeked, &err); |
900 |
if (!skb) |
901 |
goto out; |
902 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
903 |
+ if (err) |
904 |
+ goto out; |
905 |
|
906 |
ulen = skb->len - sizeof(struct udphdr); |
907 |
copied = len; |
908 |
--- linux-2.6.28-hardened-r7.orig/net/socket.c |
909 |
+++ linux-2.6.28-hardened-r7/net/socket.c |
910 |
@@ -113,6 +113,8 @@ extern int gr_search_accept(struct socke |
911 |
extern int gr_search_socket(const int domain, const int type, |
912 |
const int protocol); |
913 |
|
914 |
+#include <linux/ccsecurity.h> |
915 |
+ |
916 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
917 |
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, |
918 |
unsigned long nr_segs, loff_t pos); |
919 |
@@ -574,6 +576,10 @@ static inline int __sock_sendmsg(struct |
920 |
si->size = size; |
921 |
|
922 |
err = security_socket_sendmsg(sock, msg, size); |
923 |
+ if (!err) |
924 |
+ err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *) |
925 |
+ msg->msg_name, |
926 |
+ msg->msg_namelen); |
927 |
if (err) |
928 |
return err; |
929 |
|
930 |
@@ -1139,6 +1145,8 @@ static int __sock_create(struct net *net |
931 |
} |
932 |
|
933 |
err = security_socket_create(family, type, protocol, kern); |
934 |
+ if (!err) |
935 |
+ err = ccs_socket_create_permission(family, type, protocol); |
936 |
if (err) |
937 |
return err; |
938 |
|
939 |
@@ -1412,6 +1420,11 @@ SYSCALL_DEFINE3(bind, int, fd, struct so |
940 |
(struct sockaddr *)&address, |
941 |
addrlen); |
942 |
if (!err) |
943 |
+ err = ccs_socket_bind_permission(sock, |
944 |
+ (struct sockaddr *) |
945 |
+ &address, |
946 |
+ addrlen); |
947 |
+ if (!err) |
948 |
err = sock->ops->bind(sock, |
949 |
(struct sockaddr *) |
950 |
&address, addrlen); |
951 |
@@ -1451,6 +1464,8 @@ SYSCALL_DEFINE2(listen, int, fd, int, ba |
952 |
|
953 |
err = security_socket_listen(sock, backlog); |
954 |
if (!err) |
955 |
+ err = ccs_socket_listen_permission(sock); |
956 |
+ if (!err) |
957 |
err = sock->ops->listen(sock, backlog); |
958 |
|
959 |
error: |
960 |
@@ -1533,6 +1548,11 @@ SYSCALL_DEFINE4(accept4, int, fd, struct |
961 |
if (err < 0) |
962 |
goto out_fd; |
963 |
|
964 |
+ if (ccs_socket_accept_permission(newsock, |
965 |
+ (struct sockaddr *) &address)) { |
966 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
967 |
+ goto out_fd; |
968 |
+ } |
969 |
if (upeer_sockaddr) { |
970 |
if (newsock->ops->getname(newsock, (struct sockaddr *)&address, |
971 |
&len, 2) < 0) { |
972 |
@@ -1614,6 +1634,9 @@ SYSCALL_DEFINE3(connect, int, fd, struct |
973 |
|
974 |
err = |
975 |
security_socket_connect(sock, (struct sockaddr *)&address, addrlen); |
976 |
+ if (!err) |
977 |
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) |
978 |
+ &address, addrlen); |
979 |
if (err) |
980 |
goto out_put; |
981 |
|
982 |
--- linux-2.6.28-hardened-r7.orig/net/unix/af_unix.c |
983 |
+++ linux-2.6.28-hardened-r7/net/unix/af_unix.c |
984 |
@@ -114,6 +114,7 @@ |
985 |
#include <linux/mount.h> |
986 |
#include <net/checksum.h> |
987 |
#include <linux/security.h> |
988 |
+#include <linux/ccsecurity.h> |
989 |
|
990 |
static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; |
991 |
static DEFINE_SPINLOCK(unix_table_lock); |
992 |
@@ -849,6 +850,9 @@ static int unix_bind(struct socket *sock |
993 |
goto out_mknod_dput; |
994 |
} |
995 |
|
996 |
+ err = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
997 |
+ dentry, nd.path.mnt, mode, 0); |
998 |
+ if (!err) |
999 |
err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0); |
1000 |
mnt_drop_write(nd.path.mnt); |
1001 |
if (err) |
1002 |
--- linux-2.6.28-hardened-r7.orig/security/Kconfig |
1003 |
+++ linux-2.6.28-hardened-r7/security/Kconfig |
1004 |
@@ -567,5 +567,7 @@ config SECURITY_DEFAULT_MMAP_MIN_ADDR |
1005 |
source security/selinux/Kconfig |
1006 |
source security/smack/Kconfig |
1007 |
|
1008 |
+source security/ccsecurity/Kconfig |
1009 |
+ |
1010 |
endmenu |
1011 |
|
1012 |
--- linux-2.6.28-hardened-r7.orig/security/Makefile |
1013 |
+++ linux-2.6.28-hardened-r7/security/Makefile |
1014 |
@@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin |
1015 |
obj-$(CONFIG_SECURITY_SMACK) += smack/built-in.o |
1016 |
obj-$(CONFIG_SECURITY_ROOTPLUG) += root_plug.o |
1017 |
obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o |
1018 |
+ |
1019 |
+subdir-$(CONFIG_CCSECURITY)+= ccsecurity |
1020 |
+obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o |