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