1 |
This is TOMOYO Linux patch for openSUSE 11.0. |
This is TOMOYO Linux patch for openSUSE 11.0. |
2 |
|
|
3 |
Source code for this patch is http://download.opensuse.org/update/11.0/rpm/i586/kernel-source-2.6.25.20-0.4.i586.rpm |
Source code for this patch is http://download.opensuse.org/update/11.0/rpm/i586/kernel-source-2.6.25.20-0.7.i586.rpm |
4 |
--- |
--- |
5 |
arch/ia64/ia32/sys_ia32.c | 3 +++ |
arch/ia64/ia32/sys_ia32.c | 3 +++ |
6 |
arch/mips/kernel/ptrace32.c | 3 +++ |
arch/mips/kernel/ptrace32.c | 3 +++ |
7 |
arch/s390/kernel/ptrace.c | 3 +++ |
arch/s390/kernel/ptrace.c | 3 +++ |
8 |
arch/x86/kernel/ptrace.c | 3 +++ |
arch/x86/kernel/ptrace.c | 3 +++ |
|
fs/attr.c | 5 +++++ |
|
9 |
fs/compat.c | 3 ++- |
fs/compat.c | 3 ++- |
10 |
fs/compat_ioctl.c | 7 +++++++ |
fs/compat_ioctl.c | 3 +++ |
11 |
fs/exec.c | 12 +++++++++++- |
fs/exec.c | 12 +++++++++++- |
12 |
fs/fcntl.c | 5 +++++ |
fs/fcntl.c | 4 ++++ |
13 |
fs/ioctl.c | 5 +++++ |
fs/ioctl.c | 3 +++ |
14 |
fs/namei.c | 35 +++++++++++++++++++++++++++++++++++ |
fs/namei.c | 34 +++++++++++++++++++++++++++++++++- |
15 |
fs/namespace.c | 27 +++++++++++++++++++++++++++ |
fs/namespace.c | 9 +++++++++ |
16 |
fs/open.c | 16 ++++++++++++++++ |
fs/open.c | 27 +++++++++++++++++++++++++++ |
17 |
fs/proc/proc_misc.c | 1 + |
fs/proc/proc_misc.c | 1 + |
18 |
include/linux/init_task.h | 2 ++ |
include/linux/init_task.h | 9 +++++++++ |
19 |
include/linux/sched.h | 4 ++++ |
include/linux/sched.h | 6 ++++++ |
20 |
kernel/compat.c | 3 +++ |
kernel/compat.c | 3 +++ |
21 |
kernel/kexec.c | 3 +++ |
kernel/kexec.c | 3 +++ |
22 |
kernel/kmod.c | 3 +++ |
kernel/kmod.c | 5 +++++ |
23 |
kernel/module.c | 5 +++++ |
kernel/module.c | 5 +++++ |
24 |
kernel/ptrace.c | 5 +++++ |
kernel/ptrace.c | 5 +++++ |
25 |
kernel/sched.c | 3 +++ |
kernel/sched.c | 3 +++ |
26 |
kernel/signal.c | 7 +++++++ |
kernel/signal.c | 9 +++++++++ |
27 |
kernel/sys.c | 11 +++++++++++ |
kernel/sys.c | 11 +++++++++++ |
28 |
kernel/sysctl.c | 5 +++++ |
kernel/sysctl.c | 5 +++++ |
29 |
kernel/time.c | 5 +++++ |
kernel/time.c | 5 +++++ |
30 |
kernel/time/ntp.c | 3 +++ |
kernel/time/ntp.c | 3 +++ |
31 |
net/ipv4/inet_connection_sock.c | 3 +++ |
net/ipv4/inet_connection_sock.c | 3 +++ |
32 |
net/ipv4/inet_hashtables.c | 3 +++ |
net/ipv4/inet_hashtables.c | 3 +++ |
33 |
net/ipv4/raw.c | 4 ++++ |
net/ipv4/raw.c | 12 +++++++++--- |
34 |
net/ipv4/udp.c | 8 ++++++++ |
net/ipv4/udp.c | 12 +++++++++++- |
35 |
net/ipv6/raw.c | 4 ++++ |
net/ipv6/raw.c | 12 +++++++++--- |
36 |
net/ipv6/udp.c | 4 ++++ |
net/ipv6/udp.c | 9 ++++++++- |
37 |
net/socket.c | 24 ++++++++++++++++++++++++ |
net/socket.c | 22 ++++++++++++++++++++++ |
38 |
net/unix/af_unix.c | 4 ++++ |
net/unix/af_unix.c | 4 ++++ |
39 |
security/Kconfig | 2 ++ |
security/Kconfig | 2 ++ |
40 |
security/Makefile | 3 +++ |
security/Makefile | 3 +++ |
41 |
37 files changed, 244 insertions(+), 2 deletions(-) |
36 files changed, 251 insertions(+), 11 deletions(-) |
42 |
|
|
43 |
--- linux-2.6.25.20-0.4.orig/arch/ia64/ia32/sys_ia32.c |
--- linux-2.6.25.20-0.7.orig/arch/ia64/ia32/sys_ia32.c |
44 |
+++ linux-2.6.25.20-0.4/arch/ia64/ia32/sys_ia32.c |
+++ linux-2.6.25.20-0.7/arch/ia64/ia32/sys_ia32.c |
45 |
@@ -50,6 +50,7 @@ |
@@ -50,6 +50,7 @@ |
46 |
#include <asm/types.h> |
#include <asm/types.h> |
47 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
48 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
49 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
50 |
|
|
51 |
#include "ia32priv.h" |
#include "ia32priv.h" |
52 |
|
|
54 |
struct task_struct *child; |
struct task_struct *child; |
55 |
unsigned int value, tmp; |
unsigned int value, tmp; |
56 |
long i, ret; |
long i, ret; |
57 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
58 |
+ return -EPERM; |
+ return -EPERM; |
59 |
|
|
60 |
lock_kernel(); |
lock_kernel(); |
61 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
62 |
--- linux-2.6.25.20-0.4.orig/arch/mips/kernel/ptrace32.c |
--- linux-2.6.25.20-0.7.orig/arch/mips/kernel/ptrace32.c |
63 |
+++ linux-2.6.25.20-0.4/arch/mips/kernel/ptrace32.c |
+++ linux-2.6.25.20-0.7/arch/mips/kernel/ptrace32.c |
64 |
@@ -35,6 +35,7 @@ |
@@ -35,6 +35,7 @@ |
65 |
#include <asm/system.h> |
#include <asm/system.h> |
66 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
67 |
#include <asm/bootinfo.h> |
#include <asm/bootinfo.h> |
68 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
69 |
|
|
70 |
int ptrace_getregs(struct task_struct *child, __s64 __user *data); |
int ptrace_getregs(struct task_struct *child, __s64 __user *data); |
71 |
int ptrace_setregs(struct task_struct *child, __s64 __user *data); |
int ptrace_setregs(struct task_struct *child, __s64 __user *data); |
73 |
{ |
{ |
74 |
struct task_struct *child; |
struct task_struct *child; |
75 |
int ret; |
int ret; |
76 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
77 |
+ return -EPERM; |
+ return -EPERM; |
78 |
|
|
79 |
#if 0 |
#if 0 |
80 |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
81 |
--- linux-2.6.25.20-0.4.orig/arch/s390/kernel/ptrace.c |
--- linux-2.6.25.20-0.7.orig/arch/s390/kernel/ptrace.c |
82 |
+++ linux-2.6.25.20-0.4/arch/s390/kernel/ptrace.c |
+++ linux-2.6.25.20-0.7/arch/s390/kernel/ptrace.c |
83 |
@@ -41,6 +41,7 @@ |
@@ -41,6 +41,7 @@ |
84 |
#include <asm/system.h> |
#include <asm/system.h> |
85 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
86 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
87 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
88 |
|
|
89 |
#ifdef CONFIG_COMPAT |
#ifdef CONFIG_COMPAT |
90 |
#include "compat_ptrace.h" |
#include "compat_ptrace.h" |
92 |
struct task_struct *child; |
struct task_struct *child; |
93 |
int ret; |
int ret; |
94 |
|
|
95 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
96 |
+ return -EPERM; |
+ return -EPERM; |
97 |
lock_kernel(); |
lock_kernel(); |
98 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
99 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
100 |
--- linux-2.6.25.20-0.4.orig/arch/x86/kernel/ptrace.c |
--- linux-2.6.25.20-0.7.orig/arch/x86/kernel/ptrace.c |
101 |
+++ linux-2.6.25.20-0.4/arch/x86/kernel/ptrace.c |
+++ linux-2.6.25.20-0.7/arch/x86/kernel/ptrace.c |
102 |
@@ -32,6 +32,7 @@ |
@@ -32,6 +32,7 @@ |
103 |
#include <asm/prctl.h> |
#include <asm/prctl.h> |
104 |
#include <asm/proto.h> |
#include <asm/proto.h> |
105 |
#include <asm/ds.h> |
#include <asm/ds.h> |
106 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
107 |
|
|
108 |
#include "tls.h" |
#include "tls.h" |
109 |
|
|
111 |
void __user *datap = compat_ptr(data); |
void __user *datap = compat_ptr(data); |
112 |
int ret; |
int ret; |
113 |
__u32 val; |
__u32 val; |
114 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
115 |
+ return -EPERM; |
+ return -EPERM; |
116 |
|
|
117 |
switch (request) { |
switch (request) { |
118 |
case PTRACE_TRACEME: |
case PTRACE_TRACEME: |
119 |
--- linux-2.6.25.20-0.4.orig/fs/attr.c |
--- linux-2.6.25.20-0.7.orig/fs/compat.c |
120 |
+++ linux-2.6.25.20-0.4/fs/attr.c |
+++ linux-2.6.25.20-0.7/fs/compat.c |
|
@@ -14,6 +14,7 @@ |
|
|
#include <linux/fcntl.h> |
|
|
#include <linux/quotaops.h> |
|
|
#include <linux/security.h> |
|
|
+#include <linux/tomoyo.h> |
|
|
|
|
|
/* Taken over from the old code... */ |
|
|
|
|
|
@@ -160,6 +161,8 @@ int fnotify_change(struct dentry *dentry |
|
|
|
|
|
if (inode->i_op && inode->i_op->setattr) { |
|
|
error = security_inode_setattr(dentry, mnt, attr); |
|
|
+ if (!error) |
|
|
+ error = ccs_check_setattr_permission(dentry, attr); |
|
|
if (!error) { |
|
|
if (file && file->f_op && file->f_op->fsetattr) |
|
|
error = file->f_op->fsetattr(file, attr); |
|
|
@@ -181,6 +184,8 @@ int fnotify_change(struct dentry *dentry |
|
|
error = inode_change_ok(inode, attr); |
|
|
if (!error) |
|
|
error = security_inode_setattr(dentry, mnt, attr); |
|
|
+ if (!error) |
|
|
+ error = ccs_check_setattr_permission(dentry, attr); |
|
|
if (!error) { |
|
|
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
|
|
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
|
|
--- linux-2.6.25.20-0.4.orig/fs/compat.c |
|
|
+++ linux-2.6.25.20-0.4/fs/compat.c |
|
121 |
@@ -55,6 +55,7 @@ |
@@ -55,6 +55,7 @@ |
122 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
123 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
124 |
#include "internal.h" |
#include "internal.h" |
125 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
126 |
|
|
127 |
int compat_log = 1; |
int compat_log = 1; |
128 |
|
|
135 |
if (retval >= 0) { |
if (retval >= 0) { |
136 |
/* execve success */ |
/* execve success */ |
137 |
security_bprm_free(bprm); |
security_bprm_free(bprm); |
138 |
--- linux-2.6.25.20-0.4.orig/fs/compat_ioctl.c |
--- linux-2.6.25.20-0.7.orig/fs/compat_ioctl.c |
139 |
+++ linux-2.6.25.20-0.4/fs/compat_ioctl.c |
+++ linux-2.6.25.20-0.7/fs/compat_ioctl.c |
140 |
@@ -120,6 +120,7 @@ |
@@ -120,6 +120,7 @@ |
141 |
#include <xen/public/privcmd.h> |
#include <xen/public/privcmd.h> |
142 |
#include <xen/compat_ioctl.h> |
#include <xen/compat_ioctl.h> |
143 |
#endif |
#endif |
144 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
145 |
|
|
146 |
static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
147 |
unsigned long arg, struct file *f) |
unsigned long arg, struct file *f) |
150 |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
151 |
error = security_file_ioctl(filp, cmd, arg); |
error = security_file_ioctl(filp, cmd, arg); |
152 |
+ if (!error) |
+ if (!error) |
153 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
154 |
if (error) |
if (error) |
155 |
goto out_fput; |
goto out_fput; |
156 |
|
|
157 |
@@ -2930,6 +2933,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
--- linux-2.6.25.20-0.7.orig/fs/exec.c |
158 |
/*FALL THROUGH*/ |
+++ linux-2.6.25.20-0.7/fs/exec.c |
|
|
|
|
default: |
|
|
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
|
|
+ error = -EPERM; |
|
|
+ goto out_fput; |
|
|
+ } |
|
|
if (filp->f_op && filp->f_op->compat_ioctl) { |
|
|
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
|
|
if (error != -ENOIOCTLCMD) |
|
|
--- linux-2.6.25.20-0.4.orig/fs/exec.c |
|
|
+++ linux-2.6.25.20-0.4/fs/exec.c |
|
159 |
@@ -60,6 +60,8 @@ |
@@ -60,6 +60,8 @@ |
160 |
#include <linux/kmod.h> |
#include <linux/kmod.h> |
161 |
#endif |
#endif |
162 |
|
|
163 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
164 |
+ |
+ |
165 |
int core_uses_pid; |
int core_uses_pid; |
166 |
char core_pattern[CORENAME_MAX_SIZE] = "core"; |
char core_pattern[CORENAME_MAX_SIZE] = "core"; |
169 |
error = vfs_permission(&nd, MAY_READ | MAY_EXEC); |
error = vfs_permission(&nd, MAY_READ | MAY_EXEC); |
170 |
if (error) |
if (error) |
171 |
goto exit; |
goto exit; |
172 |
+ error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt); |
+ error = ccs_uselib_permission(nd.path.dentry, nd.path.mnt); |
173 |
+ if (error) |
+ if (error) |
174 |
+ goto exit; |
+ goto exit; |
175 |
|
|
180 |
if (S_ISREG(inode->i_mode)) { |
if (S_ISREG(inode->i_mode)) { |
181 |
int err = vfs_permission(&nd, MAY_EXEC); |
int err = vfs_permission(&nd, MAY_EXEC); |
182 |
+ if (!err) |
+ if (!err) |
183 |
+ err = ccs_check_open_exec_permission(nd.path. |
+ err = ccs_open_exec_permission(nd.path. |
184 |
+ dentry, |
+ dentry, |
185 |
+ nd.path. |
+ nd.path. |
186 |
+ mnt); |
+ mnt); |
187 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
188 |
if (!err) { |
if (!err) { |
189 |
file = nameidata_to_filp(&nd, |
file = nameidata_to_filp(&nd, |
190 |
@@ -1336,7 +1346,7 @@ int do_execve(char * filename, |
@@ -1340,7 +1350,7 @@ int do_execve(char * filename, |
191 |
goto out; |
goto out; |
192 |
bprm->argv_len = env_p - bprm->p; |
bprm->argv_len = env_p - bprm->p; |
193 |
|
|
196 |
if (retval >= 0) { |
if (retval >= 0) { |
197 |
/* execve success */ |
/* execve success */ |
198 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
199 |
--- linux-2.6.25.20-0.4.orig/fs/fcntl.c |
--- linux-2.6.25.20-0.7.orig/fs/fcntl.c |
200 |
+++ linux-2.6.25.20-0.4/fs/fcntl.c |
+++ linux-2.6.25.20-0.7/fs/fcntl.c |
201 |
@@ -23,6 +23,7 @@ |
@@ -23,6 +23,7 @@ |
202 |
#include <asm/poll.h> |
#include <asm/poll.h> |
203 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
204 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
205 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
206 |
|
|
207 |
void set_close_on_exec(unsigned int fd, int flag) |
void set_close_on_exec(unsigned int fd, int flag) |
208 |
{ |
{ |
209 |
@@ -217,6 +218,10 @@ static int setfl(int fd, struct file * f |
@@ -217,6 +218,9 @@ static int setfl(int fd, struct file * f |
210 |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
211 |
return -EPERM; |
return -EPERM; |
212 |
|
|
213 |
+ if (((arg ^ filp->f_flags) & O_APPEND) && |
+ if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp)) |
|
+ ccs_check_rewrite_permission(filp)) |
|
214 |
+ return -EPERM; |
+ return -EPERM; |
215 |
+ |
+ |
216 |
/* O_NOATIME can only be set by the owner or superuser */ |
/* O_NOATIME can only be set by the owner or superuser */ |
217 |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
218 |
if (!is_owner_or_cap(inode)) |
if (!is_owner_or_cap(inode)) |
219 |
--- linux-2.6.25.20-0.4.orig/fs/ioctl.c |
--- linux-2.6.25.20-0.7.orig/fs/ioctl.c |
220 |
+++ linux-2.6.25.20-0.4/fs/ioctl.c |
+++ linux-2.6.25.20-0.7/fs/ioctl.c |
221 |
@@ -15,6 +15,7 @@ |
@@ -15,6 +15,7 @@ |
222 |
#include <linux/uaccess.h> |
#include <linux/uaccess.h> |
223 |
|
|
224 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
225 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
226 |
|
|
227 |
/** |
/** |
228 |
* vfs_ioctl - call filesystem specific ioctl methods |
* vfs_ioctl - call filesystem specific ioctl methods |
229 |
@@ -35,6 +36,8 @@ long vfs_ioctl(struct file *filp, unsign |
@@ -202,6 +203,8 @@ asmlinkage long sys_ioctl(unsigned int f |
|
|
|
|
if (!filp->f_op) |
|
|
goto out; |
|
|
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
|
|
+ return -EPERM; |
|
|
|
|
|
if (filp->f_op->unlocked_ioctl) { |
|
|
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
|
|
@@ -202,6 +205,8 @@ asmlinkage long sys_ioctl(unsigned int f |
|
230 |
goto out; |
goto out; |
231 |
|
|
232 |
error = security_file_ioctl(filp, cmd, arg); |
error = security_file_ioctl(filp, cmd, arg); |
233 |
+ if (!error) |
+ if (!error) |
234 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
235 |
if (error) |
if (error) |
236 |
goto out_fput; |
goto out_fput; |
237 |
|
|
238 |
--- linux-2.6.25.20-0.4.orig/fs/namei.c |
--- linux-2.6.25.20-0.7.orig/fs/namei.c |
239 |
+++ linux-2.6.25.20-0.4/fs/namei.c |
+++ linux-2.6.25.20-0.7/fs/namei.c |
240 |
@@ -35,6 +35,8 @@ |
@@ -35,6 +35,8 @@ |
241 |
|
|
242 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
243 |
|
|
244 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
245 |
+ |
+ |
246 |
/* [Feb-1997 T. Schoebel-Theuer] |
/* [Feb-1997 T. Schoebel-Theuer] |
247 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
* Fundamental changes in the pathname lookup mechanisms (namei) |
251 |
return -EPERM; |
return -EPERM; |
252 |
|
|
253 |
+ /* includes O_APPEND and O_TRUNC checks */ |
+ /* includes O_APPEND and O_TRUNC checks */ |
254 |
+ error = ccs_check_open_permission(dentry, nd->path.mnt, flag); |
+ error = ccs_open_permission(dentry, nd->path.mnt, flag); |
255 |
+ if (error) |
+ if (error) |
256 |
+ return error; |
+ return error; |
257 |
+ |
+ |
262 |
|
|
263 |
if (!IS_POSIXACL(dir->d_inode)) |
if (!IS_POSIXACL(dir->d_inode)) |
264 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
265 |
+ error = ccs_check_mknod_permission(dir->d_inode, path->dentry, |
+ error = ccs_mknod_permission(dir->d_inode, path->dentry, nd->path.mnt, |
266 |
+ nd->path.mnt, mode, 0); |
+ mode, 0); |
267 |
+ if (!error) |
+ if (!error) |
268 |
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
269 |
mutex_unlock(&dir->d_inode->i_mutex); |
mutex_unlock(&dir->d_inode->i_mutex); |
270 |
dput(nd->path.dentry); |
dput(nd->path.dentry); |
271 |
@@ -1741,6 +1751,7 @@ static int open_namei_create(struct name |
@@ -2019,6 +2029,9 @@ asmlinkage long sys_mknodat(int dfd, con |
|
return may_open(nd, 0, flag & ~O_TRUNC); |
|
|
} |
|
|
|
|
|
+#include <linux/tomoyo_vfs.h> |
|
|
/* |
|
|
* open_namei() |
|
|
* |
|
|
@@ -2019,6 +2030,10 @@ asmlinkage long sys_mknodat(int dfd, con |
|
272 |
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
273 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
274 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
275 |
+ error = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
+ error = ccs_mknod_permission(nd.path.dentry->d_inode, dentry, |
276 |
+ dentry, nd.path.mnt, mode, |
+ nd.path.mnt, mode, dev); |
|
+ new_decode_dev(dev)); |
|
277 |
+ if (!error) |
+ if (!error) |
278 |
switch (mode & S_IFMT) { |
switch (mode & S_IFMT) { |
279 |
case 0: case S_IFREG: |
case 0: case S_IFREG: |
280 |
error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); |
error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); |
281 |
@@ -2097,6 +2112,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
@@ -2097,6 +2110,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
282 |
|
|
283 |
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
284 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
285 |
+ error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry, |
+ error = ccs_mkdir_permission(nd.path.dentry->d_inode, dentry, |
286 |
+ nd.path.mnt, mode); |
+ nd.path.mnt, mode); |
287 |
+ if (!error) |
+ if (!error) |
288 |
error = vfs_mkdir(nd.path.dentry->d_inode, dentry, nd.path.mnt, mode); |
error = vfs_mkdir(nd.path.dentry->d_inode, dentry, nd.path.mnt, mode); |
289 |
dput(dentry); |
dput(dentry); |
290 |
out_unlock: |
out_unlock: |
291 |
@@ -2205,6 +2223,9 @@ static long do_rmdir(int dfd, const char |
@@ -2205,6 +2221,9 @@ static long do_rmdir(int dfd, const char |
292 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
293 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
294 |
goto exit2; |
goto exit2; |
295 |
+ error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry, |
+ error = ccs_rmdir_permission(nd.path.dentry->d_inode, dentry, |
296 |
+ nd.path.mnt); |
+ nd.path.mnt); |
297 |
+ if (!error) |
+ if (!error) |
298 |
error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
299 |
dput(dentry); |
dput(dentry); |
300 |
exit2: |
exit2: |
301 |
@@ -2286,6 +2307,9 @@ static long do_unlinkat(int dfd, const c |
@@ -2286,6 +2305,9 @@ static long do_unlinkat(int dfd, const c |
302 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
303 |
if (inode) |
if (inode) |
304 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
305 |
+ error = ccs_check_unlink_permission(nd.path.dentry->d_inode, |
+ error = ccs_unlink_permission(nd.path.dentry->d_inode, dentry, |
306 |
+ dentry, nd.path.mnt); |
+ nd.path.mnt); |
307 |
+ if (!error) |
+ if (!error) |
308 |
error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
309 |
exit2: |
exit2: |
310 |
dput(dentry); |
dput(dentry); |
311 |
@@ -2368,6 +2392,9 @@ asmlinkage long sys_symlinkat(const char |
@@ -2368,6 +2390,9 @@ asmlinkage long sys_symlinkat(const char |
312 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
313 |
goto out_unlock; |
goto out_unlock; |
314 |
|
|
315 |
+ error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry, |
+ error = ccs_symlink_permission(nd.path.dentry->d_inode, dentry, |
316 |
+ nd.path.mnt, from); |
+ nd.path.mnt, from); |
317 |
+ if (!error) |
+ if (!error) |
318 |
error = vfs_symlink(nd.path.dentry->d_inode, dentry, nd.path.mnt, from, |
error = vfs_symlink(nd.path.dentry->d_inode, dentry, nd.path.mnt, from, |
319 |
S_IALLUGO); |
S_IALLUGO); |
320 |
dput(dentry); |
dput(dentry); |
321 |
@@ -2465,6 +2492,10 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2465,6 +2490,10 @@ asmlinkage long sys_linkat(int olddfd, c |
322 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
323 |
if (IS_ERR(new_dentry)) |
if (IS_ERR(new_dentry)) |
324 |
goto out_unlock; |
goto out_unlock; |
325 |
+ error = ccs_check_link_permission(old_nd.path.dentry, |
+ error = ccs_link_permission(old_nd.path.dentry, |
326 |
+ nd.path.dentry->d_inode, new_dentry, |
+ nd.path.dentry->d_inode, new_dentry, |
327 |
+ nd.path.mnt); |
+ nd.path.mnt); |
328 |
+ if (!error) |
+ if (!error) |
329 |
error = vfs_link(old_nd.path.dentry, old_nd.path.mnt, nd.path.dentry->d_inode, |
error = vfs_link(old_nd.path.dentry, old_nd.path.mnt, nd.path.dentry->d_inode, |
330 |
new_dentry, nd.path.mnt); |
new_dentry, nd.path.mnt); |
331 |
dput(new_dentry); |
dput(new_dentry); |
332 |
@@ -2698,6 +2729,10 @@ static int do_rename(int olddfd, const c |
@@ -2698,7 +2727,10 @@ static int do_rename(int olddfd, const c |
333 |
error = -ENOTEMPTY; |
error = -ENOTEMPTY; |
334 |
if (new_dentry == trap) |
if (new_dentry == trap) |
335 |
goto exit5; |
goto exit5; |
336 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
- |
337 |
+ new_dir->d_inode, new_dentry, |
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
338 |
+ newnd.path.mnt); |
+ new_dir->d_inode, new_dentry, |
339 |
|
+ newnd.path.mnt); |
340 |
+ if (!error) |
+ if (!error) |
|
|
|
341 |
error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt, |
error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt, |
342 |
new_dir->d_inode, new_dentry, newnd.path.mnt); |
new_dir->d_inode, new_dentry, newnd.path.mnt); |
343 |
--- linux-2.6.25.20-0.4.orig/fs/namespace.c |
exit5: |
344 |
+++ linux-2.6.25.20-0.4/fs/namespace.c |
--- linux-2.6.25.20-0.7.orig/fs/namespace.c |
345 |
@@ -30,6 +30,8 @@ |
+++ linux-2.6.25.20-0.7/fs/namespace.c |
346 |
|
@@ -30,6 +30,7 @@ |
347 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
348 |
#include "pnode.h" |
#include "pnode.h" |
349 |
#include "internal.h" |
#include "internal.h" |
350 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
351 |
|
|
352 |
#define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head)) |
#define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head)) |
353 |
#define HASH_SIZE (1UL << HASH_SHIFT) |
#define HASH_SIZE (1UL << HASH_SHIFT) |
354 |
@@ -591,6 +593,9 @@ static int do_umount(struct vfsmount *mn |
@@ -588,6 +589,8 @@ static int do_umount(struct vfsmount *mn |
355 |
|
LIST_HEAD(umount_list); |
356 |
|
|
357 |
|
retval = security_sb_umount(mnt, flags); |
358 |
|
+ if (!retval) |
359 |
|
+ retval = ccs_umount_permission(mnt, flags); |
360 |
if (retval) |
if (retval) |
361 |
return retval; |
return retval; |
362 |
|
|
363 |
+ if (ccs_may_umount(mnt)) |
@@ -1394,6 +1397,7 @@ int copy_mount_options(const void __user |
364 |
+ return -EPERM; |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
365 |
+ |
unsigned long flags, void *data_page) |
|
/* |
|
|
* Allow userspace to request a mountpoint be expired rather than |
|
|
* unmounting unconditionally. Unmount only happens if: |
|
|
@@ -682,6 +687,8 @@ asmlinkage long sys_umount(char __user * |
|
366 |
{ |
{ |
367 |
|
+ const unsigned long original_flags = flags; |
368 |
struct nameidata nd; |
struct nameidata nd; |
369 |
int retval; |
int retval = 0; |
370 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
int mnt_flags = 0; |
371 |
+ return -EPERM; |
@@ -1435,6 +1439,9 @@ long do_mount(char *dev_name, char *dir_ |
372 |
|
return retval; |
373 |
|
|
374 |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
375 |
|
+ if (!retval) |
376 |
|
+ retval = ccs_mount_permission(dev_name, &nd.path, type_page, |
377 |
|
+ original_flags, data_page); |
378 |
if (retval) |
if (retval) |
379 |
@@ -991,6 +998,9 @@ static noinline int do_loopback(struct n |
goto dput_out; |
|
err = -EINVAL; |
|
|
if (IS_MNT_UNBINDABLE(old_nd.path.mnt)) |
|
|
goto out; |
|
|
+ err = -EPERM; |
|
|
+ if (ccs_may_mount(nd)) |
|
|
+ goto out; |
|
380 |
|
|
381 |
if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt)) |
@@ -1696,6 +1703,8 @@ asmlinkage long sys_pivot_root(const cha |
|
goto out; |
|
|
@@ -1085,6 +1095,9 @@ static noinline int do_move_mount(struct |
|
|
if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt)) |
|
|
goto out; |
|
|
|
|
|
+ err = -EPERM; |
|
|
+ if (ccs_may_umount(old_nd.path.mnt) || ccs_may_mount(nd)) |
|
|
+ goto out; |
|
|
err = -ENOENT; |
|
|
mutex_lock(&nd->path.dentry->d_inode->i_mutex); |
|
|
if (IS_DEADDIR(nd->path.dentry->d_inode)) |
|
|
@@ -1189,6 +1202,9 @@ int do_add_mount(struct vfsmount *newmnt |
|
|
err = -EINVAL; |
|
|
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
|
|
goto unlock; |
|
|
+ err = -EPERM; |
|
|
+ if (ccs_may_mount(nd)) |
|
|
+ goto unlock; |
|
|
|
|
|
newmnt->mnt_flags = mnt_flags; |
|
|
if ((err = graft_tree(newmnt, nd))) |
|
|
@@ -1412,6 +1428,13 @@ long do_mount(char *dev_name, char *dir_ |
|
|
if (data_page) |
|
|
((char *)data_page)[PAGE_SIZE - 1] = 0; |
|
|
|
|
|
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
|
|
+ return -EPERM; |
|
|
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
|
|
+ &flags); |
|
|
+ if (retval) |
|
|
+ return retval; |
|
|
+ |
|
|
/* Separate the per-mountpoint flags */ |
|
|
if (flags & MS_NOSUID) |
|
|
mnt_flags |= MNT_NOSUID; |
|
|
@@ -1680,6 +1703,8 @@ asmlinkage long sys_pivot_root(const cha |
|
|
|
|
|
if (!capable(CAP_SYS_ADMIN)) |
|
|
return -EPERM; |
|
|
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
|
|
+ return -EPERM; |
|
|
|
|
|
lock_kernel(); |
|
|
|
|
|
@@ -1696,6 +1721,8 @@ asmlinkage long sys_pivot_root(const cha |
|
382 |
goto out1; |
goto out1; |
383 |
|
|
384 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
error = security_sb_pivotroot(&old_nd, &new_nd); |
385 |
+ if (!error) |
+ if (!error) |
386 |
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
+ error = ccs_pivot_root_permission(&old_nd.path, &new_nd.path); |
387 |
if (error) { |
if (error) { |
388 |
path_put(&old_nd.path); |
path_put(&old_nd.path); |
389 |
goto out1; |
goto out1; |
390 |
--- linux-2.6.25.20-0.4.orig/fs/open.c |
--- linux-2.6.25.20-0.7.orig/fs/open.c |
391 |
+++ linux-2.6.25.20-0.4/fs/open.c |
+++ linux-2.6.25.20-0.7/fs/open.c |
392 |
@@ -27,6 +27,8 @@ |
@@ -27,6 +27,7 @@ |
393 |
#include <linux/rcupdate.h> |
#include <linux/rcupdate.h> |
394 |
#include <linux/audit.h> |
#include <linux/audit.h> |
395 |
#include <linux/falloc.h> |
#include <linux/falloc.h> |
396 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
397 |
|
|
398 |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
399 |
{ |
{ |
400 |
@@ -267,6 +269,10 @@ static long do_sys_truncate(const char _ |
@@ -267,6 +268,9 @@ static long do_sys_truncate(const char _ |
401 |
if (error) |
if (error) |
402 |
goto put_write_and_out; |
goto put_write_and_out; |
403 |
|
|
404 |
+ error = ccs_check_truncate_permission(nd.path.dentry, nd.path.mnt, |
+ error = ccs_truncate_permission(nd.path.dentry, nd.path.mnt); |
|
+ length, 0); |
|
405 |
+ if (error) |
+ if (error) |
406 |
+ goto put_write_and_out; |
+ goto put_write_and_out; |
407 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
408 |
if (!error) { |
if (!error) { |
409 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
410 |
@@ -321,6 +327,10 @@ static long do_sys_ftruncate(unsigned in |
@@ -321,6 +325,9 @@ static long do_sys_ftruncate(unsigned in |
411 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
412 |
goto out_putf; |
goto out_putf; |
413 |
|
|
414 |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt); |
|
+ 0); |
|
415 |
+ if (error) |
+ if (error) |
416 |
+ goto out_putf; |
+ goto out_putf; |
417 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
418 |
if (!error) |
if (!error) |
419 |
error = do_truncate(dentry, file->f_path.mnt, length, |
error = do_truncate(dentry, file->f_path.mnt, length, |
420 |
@@ -539,6 +549,10 @@ asmlinkage long sys_chroot(const char __ |
@@ -539,6 +546,8 @@ asmlinkage long sys_chroot(const char __ |
421 |
error = -EPERM; |
error = -EPERM; |
422 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
423 |
goto dput_and_out; |
goto dput_and_out; |
424 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
+ if (ccs_chroot_permission(&nd.path)) |
|
+ goto dput_and_out; |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
|
425 |
+ goto dput_and_out; |
+ goto dput_and_out; |
426 |
|
|
427 |
set_fs_root(current->fs, &nd.path); |
set_fs_root(current->fs, &nd.path); |
428 |
set_fs_altroot(); |
set_fs_altroot(); |
429 |
@@ -1172,6 +1186,8 @@ EXPORT_SYMBOL(sys_close); |
@@ -572,6 +581,9 @@ asmlinkage long sys_fchmod(unsigned int |
430 |
|
err = -EPERM; |
431 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
432 |
|
goto out_putf; |
433 |
|
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
434 |
|
+ if (err) |
435 |
|
+ goto out_putf; |
436 |
|
mutex_lock(&inode->i_mutex); |
437 |
|
if (mode == (mode_t) -1) |
438 |
|
mode = inode->i_mode; |
439 |
|
@@ -606,6 +618,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
440 |
|
error = -EPERM; |
441 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
442 |
|
goto dput_and_out; |
443 |
|
+ error = ccs_chmod_permission(nd.path.dentry, nd.path.mnt, mode); |
444 |
|
+ if (error) |
445 |
|
+ goto dput_and_out; |
446 |
|
|
447 |
|
mutex_lock(&inode->i_mutex); |
448 |
|
if (mode == (mode_t) -1) |
449 |
|
@@ -674,6 +689,8 @@ asmlinkage long sys_chown(const char __u |
450 |
|
error = user_path_walk(filename, &nd); |
451 |
|
if (error) |
452 |
|
goto out; |
453 |
|
+ error = ccs_chown_permission(nd.path.dentry, nd.path.mnt, user, group); |
454 |
|
+ if (!error) |
455 |
|
error = chown_common(nd.path.dentry, nd.path.mnt, user, group, NULL); |
456 |
|
path_put(&nd.path); |
457 |
|
out: |
458 |
|
@@ -694,6 +711,8 @@ asmlinkage long sys_fchownat(int dfd, co |
459 |
|
error = __user_walk_fd(dfd, filename, follow, &nd); |
460 |
|
if (error) |
461 |
|
goto out; |
462 |
|
+ error = ccs_chown_permission(nd.path.dentry, nd.path.mnt, user, group); |
463 |
|
+ if (!error) |
464 |
|
error = chown_common(nd.path.dentry, nd.path.mnt, user, group, NULL); |
465 |
|
path_put(&nd.path); |
466 |
|
out: |
467 |
|
@@ -708,6 +727,8 @@ asmlinkage long sys_lchown(const char __ |
468 |
|
error = user_path_walk_link(filename, &nd); |
469 |
|
if (error) |
470 |
|
goto out; |
471 |
|
+ error = ccs_chown_permission(nd.path.dentry, nd.path.mnt, user, group); |
472 |
|
+ if (!error) |
473 |
|
error = chown_common(nd.path.dentry, nd.path.mnt, user, group, NULL); |
474 |
|
path_put(&nd.path); |
475 |
|
out: |
476 |
|
@@ -727,6 +748,8 @@ asmlinkage long sys_fchown(unsigned int |
477 |
|
|
478 |
|
dentry = file->f_path.dentry; |
479 |
|
audit_inode(NULL, dentry); |
480 |
|
+ error = ccs_chown_permission(dentry, file->f_vfsmnt, user, group); |
481 |
|
+ if (!error) |
482 |
|
error = chown_common(dentry, file->f_path.mnt, user, group, file); |
483 |
|
fput(file); |
484 |
|
out: |
485 |
|
@@ -823,7 +846,9 @@ static struct file *do_filp_open(int dfd |
486 |
|
if ((namei_flags+1) & O_ACCMODE) |
487 |
|
namei_flags++; |
488 |
|
|
489 |
|
+ ccs_save_open_mode(flags); |
490 |
|
error = open_namei(dfd, filename, namei_flags, mode, &nd); |
491 |
|
+ ccs_clear_open_mode(); |
492 |
|
if (!error) |
493 |
|
return nameidata_to_filp(&nd, flags); |
494 |
|
|
495 |
|
@@ -1172,6 +1197,8 @@ EXPORT_SYMBOL(sys_close); |
496 |
*/ |
*/ |
497 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
498 |
{ |
{ |
501 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
502 |
/* XXX: this needs locking */ |
/* XXX: this needs locking */ |
503 |
tty_vhangup(current->signal->tty); |
tty_vhangup(current->signal->tty); |
504 |
--- linux-2.6.25.20-0.4.orig/fs/proc/proc_misc.c |
--- linux-2.6.25.20-0.7.orig/fs/proc/proc_misc.c |
505 |
+++ linux-2.6.25.20-0.4/fs/proc/proc_misc.c |
+++ linux-2.6.25.20-0.7/fs/proc/proc_misc.c |
506 |
@@ -1021,4 +1021,5 @@ void __init proc_misc_init(void) |
@@ -1021,4 +1021,5 @@ void __init proc_misc_init(void) |
507 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
entry->proc_fops = &proc_sysrq_trigger_operations; |
508 |
} |
} |
509 |
#endif |
#endif |
510 |
+ printk(KERN_INFO "Hook version: 2.6.25.20-0.4 2009/08/05\n"); |
+ printk(KERN_INFO "Hook version: 2.6.25.20-0.7 2010/07/26\n"); |
511 |
} |
} |
512 |
--- linux-2.6.25.20-0.4.orig/include/linux/init_task.h |
--- linux-2.6.25.20-0.7.orig/include/linux/init_task.h |
513 |
+++ linux-2.6.25.20-0.4/include/linux/init_task.h |
+++ linux-2.6.25.20-0.7/include/linux/init_task.h |
514 |
@@ -196,6 +196,8 @@ extern struct group_info init_groups; |
@@ -133,6 +133,14 @@ extern struct group_info init_groups; |
515 |
|
# define CAP_INIT_BSET CAP_INIT_EFF_SET |
516 |
|
#endif |
517 |
|
|
518 |
|
+#ifdef CONFIG_CCSECURITY |
519 |
|
+#define INIT_CCSECURITY \ |
520 |
|
+ .ccs_domain_info = NULL, \ |
521 |
|
+ .ccs_flags = 0, |
522 |
|
+#else |
523 |
|
+#define INIT_CCSECURITY |
524 |
|
+#endif |
525 |
|
+ |
526 |
|
/* |
527 |
|
* INIT_TASK is used to set up the first task table, touch at |
528 |
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
529 |
|
@@ -196,6 +204,7 @@ extern struct group_info init_groups; |
530 |
INIT_IDS \ |
INIT_IDS \ |
531 |
INIT_TRACE_IRQFLAGS \ |
INIT_TRACE_IRQFLAGS \ |
532 |
INIT_LOCKDEP \ |
INIT_LOCKDEP \ |
533 |
+ .ccs_domain_info = NULL, \ |
+ INIT_CCSECURITY \ |
|
+ .ccs_flags = 0, \ |
|
534 |
} |
} |
535 |
|
|
536 |
|
|
537 |
--- linux-2.6.25.20-0.4.orig/include/linux/sched.h |
--- linux-2.6.25.20-0.7.orig/include/linux/sched.h |
538 |
+++ linux-2.6.25.20-0.4/include/linux/sched.h |
+++ linux-2.6.25.20-0.7/include/linux/sched.h |
539 |
@@ -29,6 +29,8 @@ |
@@ -41,6 +41,8 @@ |
540 |
#define CLONE_NEWNET 0x40000000 /* New network namespace */ |
|
541 |
#define CLONE_IO 0x80000000 /* Clone io context */ |
#ifdef __KERNEL__ |
542 |
|
|
543 |
+struct ccs_domain_info; |
+struct ccs_domain_info; |
544 |
+ |
+ |
545 |
/* |
struct sched_param { |
546 |
* Scheduling policies |
int sched_priority; |
547 |
*/ |
}; |
548 |
@@ -1274,6 +1276,8 @@ struct task_struct { |
@@ -1274,6 +1276,10 @@ struct task_struct { |
549 |
#ifndef __GENKSYMS__ |
#ifndef __GENKSYMS__ |
550 |
struct list_head *scm_work_list; |
struct list_head *scm_work_list; |
551 |
#endif |
#endif |
552 |
|
+#ifdef CONFIG_CCSECURITY |
553 |
+ struct ccs_domain_info *ccs_domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
554 |
+ u32 ccs_flags; |
+ u32 ccs_flags; |
555 |
|
+#endif |
556 |
}; |
}; |
557 |
|
|
558 |
/* |
/* |
559 |
--- linux-2.6.25.20-0.4.orig/kernel/compat.c |
--- linux-2.6.25.20-0.7.orig/kernel/compat.c |
560 |
+++ linux-2.6.25.20-0.4/kernel/compat.c |
+++ linux-2.6.25.20-0.7/kernel/compat.c |
561 |
@@ -25,6 +25,7 @@ |
@@ -25,6 +25,7 @@ |
562 |
#include <linux/posix-timers.h> |
#include <linux/posix-timers.h> |
563 |
|
|
564 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
565 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
566 |
|
|
567 |
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) |
568 |
{ |
{ |
575 |
|
|
576 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
577 |
return 0; |
return 0; |
578 |
--- linux-2.6.25.20-0.4.orig/kernel/kexec.c |
--- linux-2.6.25.20-0.7.orig/kernel/kexec.c |
579 |
+++ linux-2.6.25.20-0.4/kernel/kexec.c |
+++ linux-2.6.25.20-0.7/kernel/kexec.c |
580 |
@@ -31,6 +31,7 @@ |
@@ -31,6 +31,7 @@ |
581 |
#include <asm/system.h> |
#include <asm/system.h> |
582 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
583 |
#include <asm/sections.h> |
#include <asm/sections.h> |
584 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
585 |
|
|
586 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
/* Per cpu memory for storing cpu states in case of system crash. */ |
587 |
note_buf_t* crash_notes; |
note_buf_t* crash_notes; |
594 |
|
|
595 |
/* |
/* |
596 |
* Verify we have a legal set of flags |
* Verify we have a legal set of flags |
597 |
--- linux-2.6.25.20-0.4.orig/kernel/kmod.c |
--- linux-2.6.25.20-0.7.orig/kernel/kmod.c |
598 |
+++ linux-2.6.25.20-0.4/kernel/kmod.c |
+++ linux-2.6.25.20-0.7/kernel/kmod.c |
599 |
@@ -173,6 +173,9 @@ static int ____call_usermodehelper(void |
@@ -173,6 +173,11 @@ static int ____call_usermodehelper(void |
600 |
*/ |
*/ |
601 |
set_user_nice(current, 0); |
set_user_nice(current, 0); |
602 |
|
|
603 |
|
+#ifdef CONFIG_CCSECURITY |
604 |
+ current->ccs_domain_info = NULL; |
+ current->ccs_domain_info = NULL; |
605 |
+ current->ccs_flags = 0; |
+ current->ccs_flags = 0; |
606 |
|
+#endif |
607 |
+ |
+ |
608 |
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
609 |
|
|
610 |
/* Exec failed? */ |
/* Exec failed? */ |
611 |
--- linux-2.6.25.20-0.4.orig/kernel/module.c |
--- linux-2.6.25.20-0.7.orig/kernel/module.c |
612 |
+++ linux-2.6.25.20-0.4/kernel/module.c |
+++ linux-2.6.25.20-0.7/kernel/module.c |
613 |
@@ -47,6 +47,7 @@ |
@@ -47,6 +47,7 @@ |
614 |
#include <asm/cacheflush.h> |
#include <asm/cacheflush.h> |
615 |
#include <linux/license.h> |
#include <linux/license.h> |
616 |
#include <asm/sections.h> |
#include <asm/sections.h> |
617 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
618 |
|
|
619 |
#if 0 |
#if 0 |
620 |
#define DEBUGP printk |
#define DEBUGP printk |
636 |
|
|
637 |
/* Only one module load at a time, please */ |
/* Only one module load at a time, please */ |
638 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
if (mutex_lock_interruptible(&module_mutex) != 0) |
639 |
--- linux-2.6.25.20-0.4.orig/kernel/ptrace.c |
--- linux-2.6.25.20-0.7.orig/kernel/ptrace.c |
640 |
+++ linux-2.6.25.20-0.4/kernel/ptrace.c |
+++ linux-2.6.25.20-0.7/kernel/ptrace.c |
641 |
@@ -24,6 +24,7 @@ |
@@ -24,6 +24,7 @@ |
642 |
|
|
643 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
644 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
645 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
646 |
|
|
647 |
/* |
/* |
648 |
* ptrace a task: make the debugger its new parent and |
* ptrace a task: make the debugger its new parent and |
650 |
/* |
/* |
651 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
652 |
*/ |
*/ |
653 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
654 |
+ return -EPERM; |
+ return -EPERM; |
655 |
lock_kernel(); |
lock_kernel(); |
656 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
659 |
/* |
/* |
660 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
661 |
*/ |
*/ |
662 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (ccs_ptrace_permission(request, pid)) |
663 |
+ return -EPERM; |
+ return -EPERM; |
664 |
lock_kernel(); |
lock_kernel(); |
665 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
666 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
667 |
--- linux-2.6.25.20-0.4.orig/kernel/sched.c |
--- linux-2.6.25.20-0.7.orig/kernel/sched.c |
668 |
+++ linux-2.6.25.20-0.4/kernel/sched.c |
+++ linux-2.6.25.20-0.7/kernel/sched.c |
669 |
@@ -69,6 +69,7 @@ |
@@ -69,6 +69,7 @@ |
670 |
|
|
671 |
#include <asm/tlb.h> |
#include <asm/tlb.h> |
672 |
#include <asm/irq_regs.h> |
#include <asm/irq_regs.h> |
673 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
674 |
|
|
675 |
/* |
/* |
676 |
* Scheduler clock - returns current time in nanosec units. |
* Scheduler clock - returns current time in nanosec units. |
683 |
|
|
684 |
/* |
/* |
685 |
* Setpriority might change our priority at the same moment. |
* Setpriority might change our priority at the same moment. |
686 |
--- linux-2.6.25.20-0.4.orig/kernel/signal.c |
--- linux-2.6.25.20-0.7.orig/kernel/signal.c |
687 |
+++ linux-2.6.25.20-0.4/kernel/signal.c |
+++ linux-2.6.25.20-0.7/kernel/signal.c |
688 |
@@ -32,6 +32,7 @@ |
@@ -32,6 +32,7 @@ |
689 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
690 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
691 |
#include "audit.h" /* audit_signal_info() */ |
#include "audit.h" /* audit_signal_info() */ |
692 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
693 |
|
|
694 |
/* |
/* |
695 |
* SLAB caches for signal bits. |
* SLAB caches for signal bits. |
696 |
@@ -2232,6 +2233,8 @@ asmlinkage long |
@@ -2233,6 +2234,8 @@ asmlinkage long |
697 |
sys_kill(int pid, int sig) |
sys_kill(int pid, int sig) |
698 |
{ |
{ |
699 |
struct siginfo info; |
struct siginfo info; |
702 |
|
|
703 |
info.si_signo = sig; |
info.si_signo = sig; |
704 |
info.si_errno = 0; |
info.si_errno = 0; |
705 |
@@ -2290,6 +2293,8 @@ asmlinkage long sys_tgkill(int tgid, int |
@@ -2291,6 +2294,8 @@ asmlinkage long sys_tgkill(int tgid, int |
706 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
707 |
if (pid <= 0 || tgid <= 0) |
if (pid <= 0 || tgid <= 0) |
708 |
return -EINVAL; |
return -EINVAL; |
711 |
|
|
712 |
return do_tkill(tgid, pid, sig); |
return do_tkill(tgid, pid, sig); |
713 |
} |
} |
714 |
@@ -2303,6 +2308,8 @@ sys_tkill(int pid, int sig) |
@@ -2304,6 +2309,8 @@ sys_tkill(int pid, int sig) |
715 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
716 |
if (pid <= 0) |
if (pid <= 0) |
717 |
return -EINVAL; |
return -EINVAL; |
720 |
|
|
721 |
return do_tkill(0, pid, sig); |
return do_tkill(0, pid, sig); |
722 |
} |
} |
723 |
--- linux-2.6.25.20-0.4.orig/kernel/sys.c |
@@ -2321,6 +2328,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
724 |
+++ linux-2.6.25.20-0.4/kernel/sys.c |
if (info.si_code >= 0) |
725 |
|
return -EPERM; |
726 |
|
info.si_signo = sig; |
727 |
|
+ if (ccs_sigqueue_permission(pid, sig)) |
728 |
|
+ return -EPERM; |
729 |
|
|
730 |
|
/* POSIX.1b doesn't mention process groups. */ |
731 |
|
return kill_proc_info(sig, &info, pid); |
732 |
|
--- linux-2.6.25.20-0.7.orig/kernel/sys.c |
733 |
|
+++ linux-2.6.25.20-0.7/kernel/sys.c |
734 |
@@ -42,6 +42,7 @@ |
@@ -42,6 +42,7 @@ |
735 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
736 |
#include <asm/io.h> |
#include <asm/io.h> |
737 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
738 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
739 |
|
|
740 |
#ifndef SET_UNALIGN_CTL |
#ifndef SET_UNALIGN_CTL |
741 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
777 |
|
|
778 |
down_write(&uts_sem); |
down_write(&uts_sem); |
779 |
errno = -EFAULT; |
errno = -EFAULT; |
780 |
--- linux-2.6.25.20-0.4.orig/kernel/sysctl.c |
--- linux-2.6.25.20-0.7.orig/kernel/sysctl.c |
781 |
+++ linux-2.6.25.20-0.4/kernel/sysctl.c |
+++ linux-2.6.25.20-0.7/kernel/sysctl.c |
782 |
@@ -48,6 +48,7 @@ |
@@ -48,6 +48,7 @@ |
783 |
|
|
784 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
785 |
#include <asm/processor.h> |
#include <asm/processor.h> |
786 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
787 |
|
|
788 |
#ifdef CONFIG_X86 |
#ifdef CONFIG_X86 |
789 |
#include <asm/nmi.h> |
#include <asm/nmi.h> |
805 |
error = parse_table(name, nlen, oldval, oldlenp, |
error = parse_table(name, nlen, oldval, oldlenp, |
806 |
newval, newlen, head->ctl_table); |
newval, newlen, head->ctl_table); |
807 |
if (error != -ENOTDIR) { |
if (error != -ENOTDIR) { |
808 |
--- linux-2.6.25.20-0.4.orig/kernel/time.c |
--- linux-2.6.25.20-0.7.orig/kernel/time.c |
809 |
+++ linux-2.6.25.20-0.4/kernel/time.c |
+++ linux-2.6.25.20-0.7/kernel/time.c |
810 |
@@ -38,6 +38,7 @@ |
@@ -38,6 +38,7 @@ |
811 |
|
|
812 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
813 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
814 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
815 |
|
|
816 |
#include "timeconst.h" |
#include "timeconst.h" |
817 |
|
|
833 |
|
|
834 |
if (tz) { |
if (tz) { |
835 |
/* SMP safe, global irq locking makes it work. */ |
/* SMP safe, global irq locking makes it work. */ |
836 |
--- linux-2.6.25.20-0.4.orig/kernel/time/ntp.c |
--- linux-2.6.25.20-0.7.orig/kernel/time/ntp.c |
837 |
+++ linux-2.6.25.20-0.4/kernel/time/ntp.c |
+++ linux-2.6.25.20-0.7/kernel/time/ntp.c |
838 |
@@ -17,6 +17,7 @@ |
@@ -17,6 +17,7 @@ |
839 |
#include <linux/capability.h> |
#include <linux/capability.h> |
840 |
#include <asm/div64.h> |
#include <asm/div64.h> |
841 |
#include <asm/timex.h> |
#include <asm/timex.h> |
842 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
843 |
|
|
844 |
/* |
/* |
845 |
* Timekeeping variables |
* Timekeeping variables |
852 |
|
|
853 |
/* Now we validate the data before disabling interrupts */ |
/* Now we validate the data before disabling interrupts */ |
854 |
|
|
855 |
--- linux-2.6.25.20-0.4.orig/net/ipv4/inet_connection_sock.c |
--- linux-2.6.25.20-0.7.orig/net/ipv4/inet_connection_sock.c |
856 |
+++ linux-2.6.25.20-0.4/net/ipv4/inet_connection_sock.c |
+++ linux-2.6.25.20-0.7/net/ipv4/inet_connection_sock.c |
857 |
@@ -23,6 +23,7 @@ |
@@ -23,6 +23,7 @@ |
858 |
#include <net/route.h> |
#include <net/route.h> |
859 |
#include <net/tcp_states.h> |
#include <net/tcp_states.h> |
860 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
861 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
862 |
|
|
863 |
#ifdef INET_CSK_DEBUG |
#ifdef INET_CSK_DEBUG |
864 |
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; |
871 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
inet_bind_bucket_for_each(tb, node, &head->chain) |
872 |
if (tb->ib_net == net && tb->port == rover) |
if (tb->ib_net == net && tb->port == rover) |
873 |
goto next; |
goto next; |
874 |
--- linux-2.6.25.20-0.4.orig/net/ipv4/inet_hashtables.c |
--- linux-2.6.25.20-0.7.orig/net/ipv4/inet_hashtables.c |
875 |
+++ linux-2.6.25.20-0.4/net/ipv4/inet_hashtables.c |
+++ linux-2.6.25.20-0.7/net/ipv4/inet_hashtables.c |
876 |
@@ -22,6 +22,7 @@ |
@@ -22,6 +22,7 @@ |
877 |
#include <net/inet_connection_sock.h> |
#include <net/inet_connection_sock.h> |
878 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
879 |
#include <net/ip.h> |
#include <net/ip.h> |
880 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
881 |
|
|
882 |
/* |
/* |
883 |
* Allocate and initialize a new local port bind bucket. |
* Allocate and initialize a new local port bind bucket. |
890 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
891 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
892 |
|
|
893 |
--- linux-2.6.25.20-0.4.orig/net/ipv4/raw.c |
--- linux-2.6.25.20-0.7.orig/net/ipv4/raw.c |
894 |
+++ linux-2.6.25.20-0.4/net/ipv4/raw.c |
+++ linux-2.6.25.20-0.7/net/ipv4/raw.c |
895 |
@@ -79,6 +79,7 @@ |
@@ -79,6 +79,7 @@ |
896 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
897 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
898 |
#include <linux/netfilter_ipv4.h> |
#include <linux/netfilter_ipv4.h> |
899 |
+#include <linux/tomoyo_socket.h> |
+#include <linux/ccsecurity.h> |
900 |
|
|
901 |
static struct raw_hashinfo raw_v4_hashinfo = { |
static struct raw_hashinfo raw_v4_hashinfo = { |
902 |
.lock = __RW_LOCK_UNLOCKED(), |
.lock = __RW_LOCK_UNLOCKED(), |
903 |
@@ -668,6 +669,9 @@ static int raw_recvmsg(struct kiocb *ioc |
@@ -665,9 +666,14 @@ static int raw_recvmsg(struct kiocb *ioc |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
|
|
if (!skb) |
|
904 |
goto out; |
goto out; |
905 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
} |
906 |
+ if (err) |
|
907 |
+ goto out; |
- skb = skb_recv_datagram(sk, flags, noblock, &err); |
908 |
|
- if (!skb) |
909 |
|
- goto out; |
910 |
|
+ for (;;) { |
911 |
|
+ skb = skb_recv_datagram(sk, flags, noblock, &err); |
912 |
|
+ if (!skb) |
913 |
|
+ goto out; |
914 |
|
+ if (!ccs_socket_post_recvmsg_permission(sk, skb)) |
915 |
|
+ break; |
916 |
|
+ skb_kill_datagram(sk, skb, flags); |
917 |
|
+ } |
918 |
|
|
919 |
copied = skb->len; |
copied = skb->len; |
920 |
if (len < copied) { |
if (len < copied) { |
921 |
--- linux-2.6.25.20-0.4.orig/net/ipv4/udp.c |
--- linux-2.6.25.20-0.7.orig/net/ipv4/udp.c |
922 |
+++ linux-2.6.25.20-0.4/net/ipv4/udp.c |
+++ linux-2.6.25.20-0.7/net/ipv4/udp.c |
923 |
@@ -105,6 +105,8 @@ |
@@ -105,6 +105,7 @@ |
924 |
#include <net/checksum.h> |
#include <net/checksum.h> |
925 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
926 |
#include "udp_impl.h" |
#include "udp_impl.h" |
927 |
+#include <linux/sakura.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo_socket.h> |
|
928 |
|
|
929 |
/* |
/* |
930 |
* Snmp MIB for the UDP layer |
* Snmp MIB for the UDP layer |
931 |
@@ -176,6 +178,8 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -176,6 +177,8 @@ int __udp_lib_get_port(struct sock *sk, |
932 |
/* 1st pass: look for empty (or shortest) hash chain */ |
/* 1st pass: look for empty (or shortest) hash chain */ |
933 |
for (i = 0; i < UDP_HTABLE_SIZE; i++) { |
for (i = 0; i < UDP_HTABLE_SIZE; i++) { |
934 |
int size = 0; |
int size = 0; |
937 |
|
|
938 |
head = &udptable[rover & (UDP_HTABLE_SIZE - 1)]; |
head = &udptable[rover & (UDP_HTABLE_SIZE - 1)]; |
939 |
if (hlist_empty(head)) |
if (hlist_empty(head)) |
940 |
@@ -199,6 +203,7 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -199,6 +202,7 @@ int __udp_lib_get_port(struct sock *sk, |
941 |
/* 2nd pass: find hole in shortest hash chain */ |
/* 2nd pass: find hole in shortest hash chain */ |
942 |
rover = best; |
rover = best; |
943 |
for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) { |
for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) { |
945 |
if (! __udp_lib_lport_inuse(net, rover, udptable)) |
if (! __udp_lib_lport_inuse(net, rover, udptable)) |
946 |
goto gotit; |
goto gotit; |
947 |
rover += UDP_HTABLE_SIZE; |
rover += UDP_HTABLE_SIZE; |
948 |
@@ -863,6 +868,9 @@ try_again: |
@@ -848,6 +852,7 @@ int udp_recvmsg(struct kiocb *iocb, stru |
949 |
|
int peeked; |
950 |
|
int err; |
951 |
|
int is_udplite = IS_UDPLITE(sk); |
952 |
|
+ _Bool update_stat; |
953 |
|
|
954 |
|
/* |
955 |
|
* Check any passed addresses |
956 |
|
@@ -863,6 +868,11 @@ try_again: |
957 |
&peeked, &err); |
&peeked, &err); |
958 |
if (!skb) |
if (!skb) |
959 |
goto out; |
goto out; |
960 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
961 |
+ if (err) |
+ update_stat = 0; |
962 |
+ goto out; |
+ goto csum_copy_err; |
963 |
|
+ } |
964 |
|
+ update_stat = 1; |
965 |
|
|
966 |
ulen = skb->len - sizeof(struct udphdr); |
ulen = skb->len - sizeof(struct udphdr); |
967 |
copied = len; |
copied = len; |
968 |
--- linux-2.6.25.20-0.4.orig/net/ipv6/raw.c |
@@ -924,7 +934,7 @@ out: |
969 |
+++ linux-2.6.25.20-0.4/net/ipv6/raw.c |
|
970 |
|
csum_copy_err: |
971 |
|
lock_sock(sk); |
972 |
|
- if (!skb_kill_datagram(sk, skb, flags)) |
973 |
|
+ if (!skb_kill_datagram(sk, skb, flags) && update_stat) |
974 |
|
UDP_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite); |
975 |
|
release_sock(sk); |
976 |
|
|
977 |
|
--- linux-2.6.25.20-0.7.orig/net/ipv6/raw.c |
978 |
|
+++ linux-2.6.25.20-0.7/net/ipv6/raw.c |
979 |
@@ -60,6 +60,7 @@ |
@@ -60,6 +60,7 @@ |
980 |
|
|
981 |
#include <linux/proc_fs.h> |
#include <linux/proc_fs.h> |
982 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
983 |
+#include <linux/tomoyo_socket.h> |
+#include <linux/ccsecurity.h> |
984 |
|
|
985 |
static struct raw_hashinfo raw_v6_hashinfo = { |
static struct raw_hashinfo raw_v6_hashinfo = { |
986 |
.lock = __RW_LOCK_UNLOCKED(), |
.lock = __RW_LOCK_UNLOCKED(), |
987 |
@@ -482,6 +483,9 @@ static int rawv6_recvmsg(struct kiocb *i |
@@ -479,9 +480,14 @@ static int rawv6_recvmsg(struct kiocb *i |
988 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
if (flags & MSG_ERRQUEUE) |
989 |
if (!skb) |
return ipv6_recv_error(sk, msg, len); |
990 |
goto out; |
|
991 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
- skb = skb_recv_datagram(sk, flags, noblock, &err); |
992 |
+ if (err) |
- if (!skb) |
993 |
+ goto out; |
- goto out; |
994 |
|
+ for (;;) { |
995 |
|
+ skb = skb_recv_datagram(sk, flags, noblock, &err); |
996 |
|
+ if (!skb) |
997 |
|
+ goto out; |
998 |
|
+ if (!ccs_socket_post_recvmsg_permission(sk, skb)) |
999 |
|
+ break; |
1000 |
|
+ skb_kill_datagram(sk, skb, flags); |
1001 |
|
+ } |
1002 |
|
|
1003 |
copied = skb->len; |
copied = skb->len; |
1004 |
if (copied > len) { |
if (copied > len) { |
1005 |
--- linux-2.6.25.20-0.4.orig/net/ipv6/udp.c |
--- linux-2.6.25.20-0.7.orig/net/ipv6/udp.c |
1006 |
+++ linux-2.6.25.20-0.4/net/ipv6/udp.c |
+++ linux-2.6.25.20-0.7/net/ipv6/udp.c |
1007 |
@@ -50,6 +50,7 @@ |
@@ -50,6 +50,7 @@ |
1008 |
#include <linux/proc_fs.h> |
#include <linux/proc_fs.h> |
1009 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
1010 |
#include "udp_impl.h" |
#include "udp_impl.h" |
1011 |
+#include <linux/tomoyo_socket.h> |
+#include <linux/ccsecurity.h> |
1012 |
|
|
1013 |
static inline int udp_v6_get_port(struct sock *sk, unsigned short snum) |
static inline int udp_v6_get_port(struct sock *sk, unsigned short snum) |
1014 |
{ |
{ |
1015 |
@@ -137,6 +138,9 @@ try_again: |
@@ -125,6 +126,7 @@ int udpv6_recvmsg(struct kiocb *iocb, st |
1016 |
|
int peeked; |
1017 |
|
int err; |
1018 |
|
int is_udplite = IS_UDPLITE(sk); |
1019 |
|
+ _Bool update_stat; |
1020 |
|
|
1021 |
|
if (addr_len) |
1022 |
|
*addr_len=sizeof(struct sockaddr_in6); |
1023 |
|
@@ -137,6 +139,11 @@ try_again: |
1024 |
&peeked, &err); |
&peeked, &err); |
1025 |
if (!skb) |
if (!skb) |
1026 |
goto out; |
goto out; |
1027 |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1028 |
+ if (err) |
+ update_stat = 0; |
1029 |
+ goto out; |
+ goto csum_copy_err; |
1030 |
|
+ } |
1031 |
|
+ update_stat = 1; |
1032 |
|
|
1033 |
ulen = skb->len - sizeof(struct udphdr); |
ulen = skb->len - sizeof(struct udphdr); |
1034 |
copied = len; |
copied = len; |
1035 |
--- linux-2.6.25.20-0.4.orig/net/socket.c |
@@ -214,7 +221,7 @@ out: |
1036 |
+++ linux-2.6.25.20-0.4/net/socket.c |
|
1037 |
@@ -94,6 +94,9 @@ |
csum_copy_err: |
1038 |
|
lock_sock(sk); |
1039 |
|
- if (!skb_kill_datagram(sk, skb, flags)) |
1040 |
|
+ if (!skb_kill_datagram(sk, skb, flags) && update_stat) |
1041 |
|
UDP6_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite); |
1042 |
|
release_sock(sk); |
1043 |
|
|
1044 |
|
--- linux-2.6.25.20-0.7.orig/net/socket.c |
1045 |
|
+++ linux-2.6.25.20-0.7/net/socket.c |
1046 |
|
@@ -94,6 +94,8 @@ |
1047 |
#include <net/sock.h> |
#include <net/sock.h> |
1048 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1049 |
|
|
1050 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo_socket.h> |
|
1051 |
+ |
+ |
1052 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1053 |
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, |
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, |
1054 |
unsigned long nr_segs, loff_t pos); |
unsigned long nr_segs, loff_t pos); |
1055 |
@@ -555,6 +558,10 @@ static inline int __sock_sendmsg(struct |
@@ -555,6 +557,8 @@ static inline int __sock_sendmsg(struct |
1056 |
si->size = size; |
si->size = size; |
1057 |
|
|
1058 |
err = security_socket_sendmsg(sock, msg, size); |
err = security_socket_sendmsg(sock, msg, size); |
1059 |
+ if (!err) |
+ if (!err) |
1060 |
+ err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *) |
+ err = ccs_socket_sendmsg_permission(sock, msg, size); |
|
+ msg->msg_name, |
|
|
+ msg->msg_namelen); |
|
1061 |
if (err) |
if (err) |
1062 |
return err; |
return err; |
1063 |
|
|
1064 |
@@ -1121,6 +1128,8 @@ static int __sock_create(struct net *net |
@@ -1121,6 +1125,8 @@ static int __sock_create(struct net *net |
1065 |
} |
} |
1066 |
|
|
1067 |
err = security_socket_create(family, type, protocol, kern); |
err = security_socket_create(family, type, protocol, kern); |
1070 |
if (err) |
if (err) |
1071 |
return err; |
return err; |
1072 |
|
|
1073 |
@@ -1352,6 +1361,11 @@ asmlinkage long sys_bind(int fd, struct |
@@ -1352,6 +1358,11 @@ asmlinkage long sys_bind(int fd, struct |
1074 |
(struct sockaddr *)address, |
(struct sockaddr *)address, |
1075 |
addrlen); |
addrlen); |
1076 |
if (!err) |
if (!err) |
1082 |
err = sock->ops->bind(sock, |
err = sock->ops->bind(sock, |
1083 |
(struct sockaddr *) |
(struct sockaddr *) |
1084 |
address, addrlen); |
address, addrlen); |
1085 |
@@ -1381,6 +1395,8 @@ asmlinkage long sys_listen(int fd, int b |
@@ -1381,6 +1392,8 @@ asmlinkage long sys_listen(int fd, int b |
1086 |
|
|
1087 |
err = security_socket_listen(sock, backlog); |
err = security_socket_listen(sock, backlog); |
1088 |
if (!err) |
if (!err) |
1091 |
err = sock->ops->listen(sock, backlog); |
err = sock->ops->listen(sock, backlog); |
1092 |
|
|
1093 |
fput_light(sock->file, fput_needed); |
fput_light(sock->file, fput_needed); |
1094 |
@@ -1444,6 +1460,11 @@ asmlinkage long sys_accept(int fd, struc |
@@ -1412,6 +1425,7 @@ asmlinkage long sys_accept(int fd, struc |
1095 |
|
if (!sock) |
1096 |
|
goto out; |
1097 |
|
|
1098 |
|
+retry: |
1099 |
|
err = -ENFILE; |
1100 |
|
if (!(newsock = sock_alloc())) |
1101 |
|
goto out_put; |
1102 |
|
@@ -1444,6 +1458,11 @@ asmlinkage long sys_accept(int fd, struc |
1103 |
if (err < 0) |
if (err < 0) |
1104 |
goto out_fd; |
goto out_fd; |
1105 |
|
|
1106 |
+ if (ccs_socket_accept_permission(newsock, |
+ if (ccs_socket_post_accept_permission(sock, newsock)) { |
1107 |
+ (struct sockaddr *) address)) { |
+ fput(newfile); |
1108 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
+ put_unused_fd(newfd); |
1109 |
+ goto out_fd; |
+ goto retry; |
1110 |
+ } |
+ } |
1111 |
if (upeer_sockaddr) { |
if (upeer_sockaddr) { |
1112 |
if (newsock->ops->getname(newsock, (struct sockaddr *)address, |
if (newsock->ops->getname(newsock, (struct sockaddr *)address, |
1113 |
&len, 2) < 0) { |
&len, 2) < 0) { |
1114 |
@@ -1506,6 +1527,9 @@ asmlinkage long sys_connect(int fd, stru |
@@ -1506,6 +1525,9 @@ asmlinkage long sys_connect(int fd, stru |
1115 |
|
|
1116 |
err = |
err = |
1117 |
security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1121 |
if (err) |
if (err) |
1122 |
goto out_put; |
goto out_put; |
1123 |
|
|
1124 |
--- linux-2.6.25.20-0.4.orig/net/unix/af_unix.c |
--- linux-2.6.25.20-0.7.orig/net/unix/af_unix.c |
1125 |
+++ linux-2.6.25.20-0.4/net/unix/af_unix.c |
+++ linux-2.6.25.20-0.7/net/unix/af_unix.c |
1126 |
@@ -116,6 +116,7 @@ |
@@ -116,6 +116,7 @@ |
1127 |
#include <linux/mount.h> |
#include <linux/mount.h> |
1128 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1129 |
#include <linux/security.h> |
#include <linux/security.h> |
1130 |
+#include <linux/tomoyo.h> |
+#include <linux/ccsecurity.h> |
1131 |
|
|
1132 |
static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; |
static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; |
1133 |
static DEFINE_SPINLOCK(unix_table_lock); |
static DEFINE_SPINLOCK(unix_table_lock); |
1135 |
*/ |
*/ |
1136 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1137 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1138 |
+ err = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
+ err = ccs_mknod_permission(nd.path.dentry->d_inode, dentry, |
1139 |
+ dentry, nd.path.mnt, mode, 0); |
+ nd.path.mnt, mode, 0); |
1140 |
+ if (!err) |
+ if (!err) |
1141 |
err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt, |
err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt, |
1142 |
mode, 0); |
mode, 0); |
1143 |
if (err) |
if (err) |
1144 |
--- linux-2.6.25.20-0.4.orig/security/Kconfig |
--- linux-2.6.25.20-0.7.orig/security/Kconfig |
1145 |
+++ linux-2.6.25.20-0.4/security/Kconfig |
+++ linux-2.6.25.20-0.7/security/Kconfig |
1146 |
@@ -126,5 +126,7 @@ source security/selinux/Kconfig |
@@ -126,5 +126,7 @@ source security/selinux/Kconfig |
1147 |
source security/smack/Kconfig |
source security/smack/Kconfig |
1148 |
source security/apparmor/Kconfig |
source security/apparmor/Kconfig |
1151 |
+ |
+ |
1152 |
endmenu |
endmenu |
1153 |
|
|
1154 |
--- linux-2.6.25.20-0.4.orig/security/Makefile |
--- linux-2.6.25.20-0.7.orig/security/Makefile |
1155 |
+++ linux-2.6.25.20-0.4/security/Makefile |
+++ linux-2.6.25.20-0.7/security/Makefile |
1156 |
@@ -19,3 +19,6 @@ obj-$(CONFIG_SECURITY_SMACK) += commonc |
@@ -19,3 +19,6 @@ obj-$(CONFIG_SECURITY_SMACK) += commonc |
1157 |
obj-$(CONFIG_SECURITY_APPARMOR) += commoncap.o apparmor/ |
obj-$(CONFIG_SECURITY_APPARMOR) += commoncap.o apparmor/ |
1158 |
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |