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.1.i586.rpm |
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 |
4 |
--- |
--- |
5 |
arch/ia64/ia32/sys_ia32.c | 7 ++ |
arch/ia64/ia32/sys_ia32.c | 7 ++++ |
6 |
arch/mips/kernel/ptrace32.c | 7 ++ |
arch/mips/kernel/ptrace32.c | 7 ++++ |
7 |
arch/s390/kernel/ptrace.c | 7 ++ |
arch/s390/kernel/ptrace.c | 7 ++++ |
8 |
arch/x86/kernel/ptrace.c | 7 ++ |
arch/x86/kernel/ptrace.c | 7 ++++ |
9 |
fs/Kconfig | 2 |
fs/Kconfig | 2 + |
10 |
fs/Makefile | 2 |
fs/Makefile | 2 + |
11 |
fs/attr.c | 19 ++++++ |
fs/attr.c | 11 +++++++ |
12 |
fs/compat.c | 5 + |
fs/compat.c | 5 ++- |
13 |
fs/compat_ioctl.c | 9 ++ |
fs/compat_ioctl.c | 13 +++++++++ |
14 |
fs/exec.c | 20 ++++++ |
fs/exec.c | 18 +++++++++++- |
15 |
fs/fcntl.c | 9 ++ |
fs/fcntl.c | 9 ++++++ |
16 |
fs/ioctl.c | 7 ++ |
fs/ioctl.c | 11 +++++++ |
17 |
fs/namei.c | 122 ++++++++++++++++++++++++++++++++++++++++ |
fs/namei.c | 57 ++++++++++++++++++++++++++++++++++++++++ |
18 |
fs/namespace.c | 49 ++++++++++++++++ |
fs/namespace.c | 49 ++++++++++++++++++++++++++++++++++ |
19 |
fs/open.c | 29 +++++++++ |
fs/open.c | 30 +++++++++++++++++++++ |
20 |
fs/proc/Makefile | 3 |
fs/proc/Makefile | 3 ++ |
21 |
fs/proc/proc_misc.c | 5 + |
fs/proc/proc_misc.c | 5 +++ |
22 |
include/linux/init_task.h | 4 + |
include/linux/init_task.h | 4 ++ |
23 |
include/linux/sched.h | 9 ++ |
include/linux/sched.h | 8 +++++ |
24 |
kernel/compat.c | 7 ++ |
kernel/compat.c | 7 ++++ |
25 |
kernel/kexec.c | 7 ++ |
kernel/kexec.c | 7 ++++ |
26 |
kernel/kmod.c | 5 + |
kernel/kmod.c | 5 +++ |
27 |
kernel/module.c | 11 +++ |
kernel/module.c | 11 +++++++ |
28 |
kernel/ptrace.c | 11 +++ |
kernel/ptrace.c | 11 +++++++ |
29 |
kernel/sched.c | 7 ++ |
kernel/sched.c | 7 ++++ |
30 |
kernel/signal.c | 21 ++++++ |
kernel/signal.c | 21 ++++++++++++++ |
31 |
kernel/sys.c | 21 ++++++ |
kernel/sys.c | 21 ++++++++++++++ |
32 |
kernel/sysctl.c | 95 +++++++++++++++++++++++++++++++ |
kernel/sysctl.c | 9 ++++++ |
33 |
kernel/time.c | 11 +++ |
kernel/time.c | 11 +++++++ |
34 |
kernel/time/ntp.c | 7 ++ |
kernel/time/ntp.c | 7 ++++ |
35 |
net/core/datagram.c | 11 +++ |
net/ipv4/inet_connection_sock.c | 7 ++++ |
36 |
net/ipv4/inet_connection_sock.c | 7 ++ |
net/ipv4/inet_hashtables.c | 7 ++++ |
37 |
net/ipv4/inet_hashtables.c | 7 ++ |
net/ipv4/raw.c | 8 +++++ |
38 |
net/ipv4/udp.c | 10 +++ |
net/ipv4/udp.c | 18 ++++++++++++ |
39 |
net/socket.c | 41 +++++++++++++ |
net/ipv6/raw.c | 8 +++++ |
40 |
net/unix/af_unix.c | 15 ++++ |
net/ipv6/udp.c | 8 +++++ |
41 |
36 files changed, 614 insertions(+), 2 deletions(-) |
net/socket.c | 41 ++++++++++++++++++++++++++++ |
42 |
|
net/unix/af_unix.c | 8 +++++ |
43 |
|
38 files changed, 475 insertions(+), 2 deletions(-) |
44 |
|
|
45 |
--- linux-2.6.25.20-0.1.orig/arch/ia64/ia32/sys_ia32.c |
--- linux-2.6.25.20-0.4.orig/arch/ia64/ia32/sys_ia32.c |
46 |
+++ linux-2.6.25.20-0.1/arch/ia64/ia32/sys_ia32.c |
+++ linux-2.6.25.20-0.4/arch/ia64/ia32/sys_ia32.c |
47 |
@@ -50,6 +50,9 @@ |
@@ -50,6 +50,9 @@ |
48 |
#include <asm/types.h> |
#include <asm/types.h> |
49 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
59 |
unsigned int value, tmp; |
unsigned int value, tmp; |
60 |
long i, ret; |
long i, ret; |
61 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
62 |
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
63 |
+ return -EPERM; |
+ return -EPERM; |
64 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
65 |
|
|
66 |
lock_kernel(); |
lock_kernel(); |
67 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
68 |
--- linux-2.6.25.20-0.1.orig/arch/mips/kernel/ptrace32.c |
--- linux-2.6.25.20-0.4.orig/arch/mips/kernel/ptrace32.c |
69 |
+++ linux-2.6.25.20-0.1/arch/mips/kernel/ptrace32.c |
+++ linux-2.6.25.20-0.4/arch/mips/kernel/ptrace32.c |
70 |
@@ -35,6 +35,9 @@ |
@@ -35,6 +35,9 @@ |
71 |
#include <asm/system.h> |
#include <asm/system.h> |
72 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
82 |
struct task_struct *child; |
struct task_struct *child; |
83 |
int ret; |
int ret; |
84 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
85 |
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
86 |
+ return -EPERM; |
+ return -EPERM; |
87 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
88 |
|
|
89 |
#if 0 |
#if 0 |
90 |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
91 |
--- linux-2.6.25.20-0.1.orig/arch/s390/kernel/ptrace.c |
--- linux-2.6.25.20-0.4.orig/arch/s390/kernel/ptrace.c |
92 |
+++ linux-2.6.25.20-0.1/arch/s390/kernel/ptrace.c |
+++ linux-2.6.25.20-0.4/arch/s390/kernel/ptrace.c |
93 |
@@ -41,6 +41,9 @@ |
@@ -41,6 +41,9 @@ |
94 |
#include <asm/system.h> |
#include <asm/system.h> |
95 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
105 |
int ret; |
int ret; |
106 |
|
|
107 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
108 |
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
109 |
+ return -EPERM; |
+ return -EPERM; |
110 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
111 |
lock_kernel(); |
lock_kernel(); |
112 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
113 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
114 |
--- linux-2.6.25.20-0.1.orig/arch/x86/kernel/ptrace.c |
--- linux-2.6.25.20-0.4.orig/arch/x86/kernel/ptrace.c |
115 |
+++ linux-2.6.25.20-0.1/arch/x86/kernel/ptrace.c |
+++ linux-2.6.25.20-0.4/arch/x86/kernel/ptrace.c |
116 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,9 @@ |
117 |
#include <asm/prctl.h> |
#include <asm/prctl.h> |
118 |
#include <asm/proto.h> |
#include <asm/proto.h> |
128 |
int ret; |
int ret; |
129 |
__u32 val; |
__u32 val; |
130 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
131 |
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
132 |
+ return -EPERM; |
+ return -EPERM; |
133 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
134 |
|
|
135 |
switch (request) { |
switch (request) { |
136 |
case PTRACE_TRACEME: |
case PTRACE_TRACEME: |
137 |
--- linux-2.6.25.20-0.1.orig/fs/Kconfig |
--- linux-2.6.25.20-0.4.orig/fs/Kconfig |
138 |
+++ linux-2.6.25.20-0.1/fs/Kconfig |
+++ linux-2.6.25.20-0.4/fs/Kconfig |
139 |
@@ -2187,4 +2187,6 @@ endif |
@@ -2187,4 +2187,6 @@ endif |
140 |
source "fs/nls/Kconfig" |
source "fs/nls/Kconfig" |
141 |
source "fs/dlm/Kconfig" |
source "fs/dlm/Kconfig" |
143 |
+source "fs/Kconfig.ccs" |
+source "fs/Kconfig.ccs" |
144 |
+ |
+ |
145 |
endmenu |
endmenu |
146 |
--- linux-2.6.25.20-0.1.orig/fs/Makefile |
--- linux-2.6.25.20-0.4.orig/fs/Makefile |
147 |
+++ linux-2.6.25.20-0.1/fs/Makefile |
+++ linux-2.6.25.20-0.4/fs/Makefile |
148 |
@@ -125,3 +125,5 @@ obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
@@ -125,3 +125,5 @@ obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
149 |
obj-$(CONFIG_GFS2_FS) += gfs2/ |
obj-$(CONFIG_GFS2_FS) += gfs2/ |
150 |
obj-$(CONFIG_NOVFS) += novfs/ |
obj-$(CONFIG_NOVFS) += novfs/ |
151 |
obj-$(CONFIG_SQUASHFS) += squashfs/ |
obj-$(CONFIG_SQUASHFS) += squashfs/ |
152 |
+ |
+ |
153 |
+include $(srctree)/fs/Makefile-2.6.ccs |
+include $(srctree)/fs/Makefile-2.6.ccs |
154 |
--- linux-2.6.25.20-0.1.orig/fs/attr.c |
--- linux-2.6.25.20-0.4.orig/fs/attr.c |
155 |
+++ linux-2.6.25.20-0.1/fs/attr.c |
+++ linux-2.6.25.20-0.4/fs/attr.c |
156 |
@@ -14,6 +14,9 @@ |
@@ -14,6 +14,9 @@ |
157 |
#include <linux/fcntl.h> |
#include <linux/fcntl.h> |
158 |
#include <linux/quotaops.h> |
#include <linux/quotaops.h> |
163 |
|
|
164 |
/* Taken over from the old code... */ |
/* Taken over from the old code... */ |
165 |
|
|
166 |
@@ -160,6 +163,14 @@ int fnotify_change(struct dentry *dentry |
@@ -160,6 +163,10 @@ int fnotify_change(struct dentry *dentry |
167 |
|
|
168 |
if (inode->i_op && inode->i_op->setattr) { |
if (inode->i_op && inode->i_op->setattr) { |
169 |
error = security_inode_setattr(dentry, mnt, attr); |
error = security_inode_setattr(dentry, mnt, attr); |
170 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
171 |
+ if (!error && (ia_valid & ATTR_MODE) && |
+ if (!error) |
172 |
+ !ccs_capable(TOMOYO_SYS_CHMOD)) |
+ error = ccs_check_setattr_permission(dentry, attr); |
|
+ error = -EPERM; |
|
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && |
|
|
+ !ccs_capable(TOMOYO_SYS_CHOWN)) |
|
|
+ error = -EPERM; |
|
173 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
174 |
if (!error) { |
if (!error) { |
175 |
if (file && file->f_op && file->f_op->fsetattr) |
if (file && file->f_op && file->f_op->fsetattr) |
176 |
error = file->f_op->fsetattr(file, attr); |
error = file->f_op->fsetattr(file, attr); |
177 |
@@ -181,6 +192,14 @@ int fnotify_change(struct dentry *dentry |
@@ -181,6 +188,10 @@ int fnotify_change(struct dentry *dentry |
178 |
error = inode_change_ok(inode, attr); |
error = inode_change_ok(inode, attr); |
179 |
if (!error) |
if (!error) |
180 |
error = security_inode_setattr(dentry, mnt, attr); |
error = security_inode_setattr(dentry, mnt, attr); |
181 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
182 |
+ if (!error && (ia_valid & ATTR_MODE) && |
+ if (!error) |
183 |
+ !ccs_capable(TOMOYO_SYS_CHMOD)) |
+ error = ccs_check_setattr_permission(dentry, attr); |
|
+ error = -EPERM; |
|
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID)) && |
|
|
+ !ccs_capable(TOMOYO_SYS_CHOWN)) |
|
|
+ error = -EPERM; |
|
184 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
185 |
if (!error) { |
if (!error) { |
186 |
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
187 |
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
188 |
--- linux-2.6.25.20-0.1.orig/fs/compat.c |
--- linux-2.6.25.20-0.4.orig/fs/compat.c |
189 |
+++ linux-2.6.25.20-0.1/fs/compat.c |
+++ linux-2.6.25.20-0.4/fs/compat.c |
190 |
@@ -55,6 +55,9 @@ |
@@ -55,6 +55,9 @@ |
191 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
192 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
202 |
goto out; |
goto out; |
203 |
|
|
204 |
- retval = search_binary_handler(bprm, regs); |
- retval = search_binary_handler(bprm, regs); |
205 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
206 |
if (retval >= 0) { |
if (retval >= 0) { |
207 |
/* execve success */ |
/* execve success */ |
208 |
security_bprm_free(bprm); |
security_bprm_free(bprm); |
209 |
--- linux-2.6.25.20-0.1.orig/fs/compat_ioctl.c |
--- linux-2.6.25.20-0.4.orig/fs/compat_ioctl.c |
210 |
+++ linux-2.6.25.20-0.1/fs/compat_ioctl.c |
+++ linux-2.6.25.20-0.4/fs/compat_ioctl.c |
211 |
@@ -120,6 +120,9 @@ |
@@ -120,6 +120,9 @@ |
212 |
#include <xen/public/privcmd.h> |
#include <xen/public/privcmd.h> |
213 |
#include <xen/compat_ioctl.h> |
#include <xen/compat_ioctl.h> |
218 |
|
|
219 |
static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
220 |
unsigned long arg, struct file *f) |
unsigned long arg, struct file *f) |
221 |
@@ -2930,6 +2933,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
@@ -2906,6 +2909,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
222 |
|
|
223 |
|
/* RED-PEN how should LSM module know it's handling 32bit? */ |
224 |
|
error = security_file_ioctl(filp, cmd, arg); |
225 |
|
+ /***** TOMOYO Linux start. *****/ |
226 |
|
+ if (!error) |
227 |
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
228 |
|
+ /***** TOMOYO Linux end. *****/ |
229 |
|
if (error) |
230 |
|
goto out_fput; |
231 |
|
|
232 |
|
@@ -2930,6 +2937,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
233 |
/*FALL THROUGH*/ |
/*FALL THROUGH*/ |
234 |
|
|
235 |
default: |
default: |
236 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
237 |
+ if (!ccs_capable(TOMOYO_SYS_IOCTL)) { |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
238 |
+ error = -EPERM; |
+ error = -EPERM; |
239 |
+ goto out_fput; |
+ goto out_fput; |
240 |
+ } |
+ } |
242 |
if (filp->f_op && filp->f_op->compat_ioctl) { |
if (filp->f_op && filp->f_op->compat_ioctl) { |
243 |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
244 |
if (error != -ENOIOCTLCMD) |
if (error != -ENOIOCTLCMD) |
245 |
--- linux-2.6.25.20-0.1.orig/fs/exec.c |
--- linux-2.6.25.20-0.4.orig/fs/exec.c |
246 |
+++ linux-2.6.25.20-0.1/fs/exec.c |
+++ linux-2.6.25.20-0.4/fs/exec.c |
247 |
@@ -60,6 +60,10 @@ |
@@ -60,6 +60,10 @@ |
248 |
#include <linux/kmod.h> |
#include <linux/kmod.h> |
249 |
#endif |
#endif |
255 |
int core_uses_pid; |
int core_uses_pid; |
256 |
char core_pattern[CORENAME_MAX_SIZE] = "core"; |
char core_pattern[CORENAME_MAX_SIZE] = "core"; |
257 |
int suid_dumpable = 0; |
int suid_dumpable = 0; |
258 |
@@ -118,6 +122,12 @@ asmlinkage long sys_uselib(const char __ |
@@ -118,6 +122,11 @@ asmlinkage long sys_uselib(const char __ |
259 |
error = vfs_permission(&nd, MAY_READ | MAY_EXEC); |
error = vfs_permission(&nd, MAY_READ | MAY_EXEC); |
260 |
if (error) |
if (error) |
261 |
goto exit; |
goto exit; |
262 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
263 |
+ /* 01 means "read". */ |
+ error = ccs_check_uselib_permission(nd.path.dentry, nd.path.mnt); |
|
+ error = ccs_check_open_permission(nd.path.dentry, nd.path.mnt, 01); |
|
264 |
+ if (error) |
+ if (error) |
265 |
+ goto exit; |
+ goto exit; |
266 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
267 |
|
|
268 |
file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
269 |
error = PTR_ERR(file); |
error = PTR_ERR(file); |
270 |
@@ -664,6 +674,14 @@ struct file *open_exec(const char *name) |
@@ -664,6 +673,13 @@ struct file *open_exec(const char *name) |
271 |
file = ERR_PTR(-EACCES); |
file = ERR_PTR(-EACCES); |
272 |
if (S_ISREG(inode->i_mode)) { |
if (S_ISREG(inode->i_mode)) { |
273 |
int err = vfs_permission(&nd, MAY_EXEC); |
int err = vfs_permission(&nd, MAY_EXEC); |
274 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
275 |
+ if (!err && (current->tomoyo_flags & |
+ if (!err) |
276 |
+ TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) |
+ err = ccs_check_open_exec_permission(nd.path. |
277 |
+ /* 01 means "read". */ |
+ dentry, |
278 |
+ err = ccs_check_open_permission(nd.path.dentry, |
+ nd.path. |
279 |
+ nd.path.mnt, |
+ mnt); |
|
+ 01); |
|
280 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
281 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
282 |
if (!err) { |
if (!err) { |
283 |
file = nameidata_to_filp(&nd, |
file = nameidata_to_filp(&nd, |
284 |
@@ -1336,7 +1354,7 @@ int do_execve(char * filename, |
@@ -1336,7 +1352,7 @@ int do_execve(char * filename, |
285 |
goto out; |
goto out; |
286 |
bprm->argv_len = env_p - bprm->p; |
bprm->argv_len = env_p - bprm->p; |
287 |
|
|
288 |
- retval = search_binary_handler(bprm,regs); |
- retval = search_binary_handler(bprm,regs); |
289 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
290 |
if (retval >= 0) { |
if (retval >= 0) { |
291 |
/* execve success */ |
/* execve success */ |
292 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
293 |
--- linux-2.6.25.20-0.1.orig/fs/fcntl.c |
--- linux-2.6.25.20-0.4.orig/fs/fcntl.c |
294 |
+++ linux-2.6.25.20-0.1/fs/fcntl.c |
+++ linux-2.6.25.20-0.4/fs/fcntl.c |
295 |
@@ -23,6 +23,9 @@ |
@@ -23,6 +23,9 @@ |
296 |
#include <asm/poll.h> |
#include <asm/poll.h> |
297 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
315 |
/* O_NOATIME can only be set by the owner or superuser */ |
/* O_NOATIME can only be set by the owner or superuser */ |
316 |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
317 |
if (!is_owner_or_cap(inode)) |
if (!is_owner_or_cap(inode)) |
318 |
--- linux-2.6.25.20-0.1.orig/fs/ioctl.c |
--- linux-2.6.25.20-0.4.orig/fs/ioctl.c |
319 |
+++ linux-2.6.25.20-0.1/fs/ioctl.c |
+++ linux-2.6.25.20-0.4/fs/ioctl.c |
320 |
@@ -15,6 +15,9 @@ |
@@ -15,6 +15,9 @@ |
321 |
#include <linux/uaccess.h> |
#include <linux/uaccess.h> |
322 |
|
|
332 |
if (!filp->f_op) |
if (!filp->f_op) |
333 |
goto out; |
goto out; |
334 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
335 |
+ if (!ccs_capable(TOMOYO_SYS_IOCTL)) |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
336 |
+ return -EPERM; |
+ return -EPERM; |
337 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
338 |
|
|
339 |
if (filp->f_op->unlocked_ioctl) { |
if (filp->f_op->unlocked_ioctl) { |
340 |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
341 |
--- linux-2.6.25.20-0.1.orig/fs/namei.c |
@@ -202,6 +209,10 @@ asmlinkage long sys_ioctl(unsigned int f |
342 |
+++ linux-2.6.25.20-0.1/fs/namei.c |
goto out; |
343 |
|
|
344 |
|
error = security_file_ioctl(filp, cmd, arg); |
345 |
|
+ /***** TOMOYO Linux start. *****/ |
346 |
|
+ if (!error) |
347 |
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
348 |
|
+ /***** TOMOYO Linux end. *****/ |
349 |
|
if (error) |
350 |
|
goto out_fput; |
351 |
|
|
352 |
|
--- linux-2.6.25.20-0.4.orig/fs/namei.c |
353 |
|
+++ linux-2.6.25.20-0.4/fs/namei.c |
354 |
@@ -35,6 +35,10 @@ |
@@ -35,6 +35,10 @@ |
355 |
|
|
356 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
362 |
/* [Feb-1997 T. Schoebel-Theuer] |
/* [Feb-1997 T. Schoebel-Theuer] |
363 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
* Fundamental changes in the pathname lookup mechanisms (namei) |
364 |
* were necessary because of omirr. The reason is that omirr needs |
* were necessary because of omirr. The reason is that omirr needs |
365 |
@@ -1635,6 +1639,14 @@ int vfs_create(struct inode *dir, struct |
@@ -1690,6 +1694,13 @@ int may_open(struct nameidata *nd, int a |
|
error = security_inode_create(dir, dentry, nd ? nd->path.mnt : NULL, mode); |
|
|
if (error) |
|
|
return error; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (nd) { |
|
|
+ error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, |
|
|
+ nd->path.mnt); |
|
|
+ if (error) |
|
|
+ return error; |
|
|
+ } |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
DQUOT_INIT(dir); |
|
|
error = dir->i_op->create(dir, dentry, mode, nd); |
|
|
if (!error) |
|
|
@@ -1690,6 +1702,13 @@ int may_open(struct nameidata *nd, int a |
|
366 |
if (!is_owner_or_cap(inode)) |
if (!is_owner_or_cap(inode)) |
367 |
return -EPERM; |
return -EPERM; |
368 |
|
|
376 |
/* |
/* |
377 |
* Ensure there are no outstanding leases on the file. |
* Ensure there are no outstanding leases on the file. |
378 |
*/ |
*/ |
379 |
@@ -1741,6 +1760,9 @@ static int open_namei_create(struct name |
@@ -1731,6 +1742,11 @@ static int open_namei_create(struct name |
380 |
|
|
381 |
|
if (!IS_POSIXACL(dir->d_inode)) |
382 |
|
mode &= ~current->fs->umask; |
383 |
|
+ /***** TOMOYO Linux start. *****/ |
384 |
|
+ error = ccs_check_mknod_permission(dir->d_inode, path->dentry, |
385 |
|
+ nd->path.mnt, mode, 0); |
386 |
|
+ if (!error) |
387 |
|
+ /***** TOMOYO Linux end. *****/ |
388 |
|
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
389 |
|
mutex_unlock(&dir->d_inode->i_mutex); |
390 |
|
dput(nd->path.dentry); |
391 |
|
@@ -1741,6 +1757,9 @@ static int open_namei_create(struct name |
392 |
return may_open(nd, 0, flag & ~O_TRUNC); |
return may_open(nd, 0, flag & ~O_TRUNC); |
393 |
} |
} |
394 |
|
|
398 |
/* |
/* |
399 |
* open_namei() |
* open_namei() |
400 |
* |
* |
401 |
@@ -2006,6 +2028,16 @@ asmlinkage long sys_mknodat(int dfd, con |
@@ -2019,6 +2038,12 @@ asmlinkage long sys_mknodat(int dfd, con |
402 |
|
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
403 |
if (S_ISDIR(mode)) |
mode &= ~current->fs->umask; |
404 |
return -EPERM; |
if (!IS_ERR(dentry)) { |
405 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
406 |
+ if (S_ISCHR(mode) && !ccs_capable(TOMOYO_CREATE_CHAR_DEV)) |
+ error = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
407 |
+ return -EPERM; |
+ dentry, nd.path.mnt, mode, |
408 |
+ if (S_ISBLK(mode) && !ccs_capable(TOMOYO_CREATE_BLOCK_DEV)) |
+ new_decode_dev(dev)); |
409 |
+ return -EPERM; |
+ if (!error) |
410 |
+ if (S_ISFIFO(mode) && !ccs_capable(TOMOYO_CREATE_FIFO)) |
+ /***** TOMOYO Linux end. *****/ |
411 |
+ return -EPERM; |
switch (mode & S_IFMT) { |
412 |
+ if (S_ISSOCK(mode) && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) |
case 0: case S_IFREG: |
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
tmp = getname(filename); |
|
|
if (IS_ERR(tmp)) |
|
|
return PTR_ERR(tmp); |
|
|
@@ -2024,10 +2056,34 @@ asmlinkage long sys_mknodat(int dfd, con |
|
413 |
error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); |
error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); |
414 |
break; |
@@ -2097,6 +2122,11 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
case S_IFCHR: case S_IFBLK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = pre_vfs_mknod(nd.path.dentry->d_inode, dentry, |
|
|
+ mode); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ error = ccs_check_1path_perm(S_ISCHR(mode) ? |
|
|
+ TYPE_MKCHAR_ACL : |
|
|
+ TYPE_MKBLOCK_ACL, |
|
|
+ dentry, nd.path.mnt); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.path.dentry->d_inode, dentry, |
|
|
nd.path.mnt, mode, new_decode_dev(dev)); |
|
|
break; |
|
|
case S_IFIFO: case S_IFSOCK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = pre_vfs_mknod(nd.path.dentry->d_inode, dentry, |
|
|
+ mode); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ error = ccs_check_1path_perm(S_ISFIFO(mode) ? |
|
|
+ TYPE_MKFIFO_ACL : |
|
|
+ TYPE_MKSOCK_ACL, |
|
|
+ dentry, nd.path.mnt); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.path.dentry->d_inode, dentry, |
|
|
nd.path.mnt, mode, 0); |
|
|
break; |
|
|
@@ -2097,6 +2153,13 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
415 |
|
|
416 |
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
if (!IS_POSIXACL(nd.path.dentry->d_inode)) |
417 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
418 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
419 |
+ error = pre_vfs_mkdir(nd.path.dentry->d_inode, dentry); |
+ error = ccs_check_mkdir_permission(nd.path.dentry->d_inode, dentry, |
420 |
+ if (!error) |
+ nd.path.mnt, mode); |
|
+ error = ccs_check_1path_perm(TYPE_MKDIR_ACL, dentry, |
|
|
+ nd.path.mnt); |
|
421 |
+ if (!error) |
+ if (!error) |
422 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
423 |
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); |
424 |
dput(dentry); |
dput(dentry); |
425 |
out_unlock: |
out_unlock: |
426 |
@@ -2205,6 +2268,13 @@ static long do_rmdir(int dfd, const char |
@@ -2205,6 +2235,11 @@ static long do_rmdir(int dfd, const char |
427 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
428 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
429 |
goto exit2; |
goto exit2; |
430 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
431 |
+ error = pre_vfs_rmdir(nd.path.dentry->d_inode, dentry); |
+ error = ccs_check_rmdir_permission(nd.path.dentry->d_inode, dentry, |
432 |
+ if (!error) |
+ nd.path.mnt); |
|
+ error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, |
|
|
+ nd.path.mnt); |
|
433 |
+ if (!error) |
+ if (!error) |
434 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
435 |
error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
error = vfs_rmdir(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
436 |
dput(dentry); |
dput(dentry); |
437 |
exit2: |
exit2: |
438 |
@@ -2265,6 +2335,10 @@ static long do_unlinkat(int dfd, const c |
@@ -2286,6 +2321,11 @@ static long do_unlinkat(int dfd, const c |
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
struct inode *inode = NULL; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_UNLINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
name = getname(pathname); |
|
|
if(IS_ERR(name)) |
|
|
@@ -2286,6 +2360,15 @@ static long do_unlinkat(int dfd, const c |
|
439 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
440 |
if (inode) |
if (inode) |
441 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
442 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
443 |
+ error = pre_vfs_unlink(nd.path.dentry->d_inode, dentry); |
+ error = ccs_check_unlink_permission(nd.path.dentry->d_inode, |
444 |
+ if (error) |
+ dentry, nd.path.mnt); |
445 |
+ goto exit2; |
+ if (!error) |
|
+ error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, |
|
|
+ nd.path.mnt); |
|
|
+ if (error) |
|
|
+ goto exit2; |
|
446 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
447 |
error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt); |
448 |
exit2: |
exit2: |
449 |
dput(dentry); |
dput(dentry); |
450 |
@@ -2351,6 +2434,10 @@ asmlinkage long sys_symlinkat(const char |
@@ -2368,6 +2408,11 @@ asmlinkage long sys_symlinkat(const char |
|
char * to; |
|
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_SYMLINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
|
@@ -2368,6 +2455,13 @@ asmlinkage long sys_symlinkat(const char |
|
451 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
452 |
goto out_unlock; |
goto out_unlock; |
453 |
|
|
454 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
455 |
+ error = pre_vfs_symlink(nd.path.dentry->d_inode, dentry); |
+ error = ccs_check_symlink_permission(nd.path.dentry->d_inode, dentry, |
456 |
+ if (!error) |
+ nd.path.mnt, from); |
|
+ error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, dentry, |
|
|
+ nd.path.mnt); |
|
457 |
+ if (!error) |
+ if (!error) |
458 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
459 |
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, |
460 |
S_IALLUGO); |
S_IALLUGO); |
461 |
dput(dentry); |
dput(dentry); |
462 |
@@ -2442,6 +2536,10 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2465,6 +2510,12 @@ asmlinkage long sys_linkat(int olddfd, c |
|
struct nameidata nd, old_nd; |
|
|
int error; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_LINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
if ((flags & ~AT_SYMLINK_FOLLOW) != 0) |
|
|
return -EINVAL; |
|
|
@@ -2465,6 +2563,15 @@ asmlinkage long sys_linkat(int olddfd, c |
|
463 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
464 |
if (IS_ERR(new_dentry)) |
if (IS_ERR(new_dentry)) |
465 |
goto out_unlock; |
goto out_unlock; |
466 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
467 |
+ error = pre_vfs_link(old_nd.path.dentry, nd.path.dentry->d_inode, |
+ error = ccs_check_link_permission(old_nd.path.dentry, |
468 |
+ new_dentry); |
+ nd.path.dentry->d_inode, new_dentry, |
469 |
+ if (!error) |
+ nd.path.mnt); |
|
+ error = ccs_check_2path_perm(TYPE_LINK_ACL, old_nd.path.dentry, |
|
|
+ old_nd.path.mnt, new_dentry, |
|
|
+ nd.path.mnt); |
|
470 |
+ if (!error) |
+ if (!error) |
471 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
472 |
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, |
473 |
new_dentry, nd.path.mnt); |
new_dentry, nd.path.mnt); |
474 |
dput(new_dentry); |
dput(new_dentry); |
475 |
@@ -2698,6 +2805,17 @@ static int do_rename(int olddfd, const c |
@@ -2698,6 +2749,12 @@ static int do_rename(int olddfd, const c |
476 |
error = -ENOTEMPTY; |
error = -ENOTEMPTY; |
477 |
if (new_dentry == trap) |
if (new_dentry == trap) |
478 |
goto exit5; |
goto exit5; |
479 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
480 |
+ error = pre_vfs_rename(old_dir->d_inode, old_dentry, |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
481 |
+ new_dir->d_inode, new_dentry); |
+ new_dir->d_inode, new_dentry, |
482 |
+ if (error) |
+ newnd.path.mnt); |
483 |
+ goto exit5; |
+ if (!error) |
|
+ error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, |
|
|
+ oldnd.path.mnt, new_dentry, |
|
|
+ newnd.path.mnt); |
|
|
+ if (error) |
|
|
+ goto exit5; |
|
484 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
485 |
|
|
486 |
error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt, |
error = vfs_rename(old_dir->d_inode, old_dentry, oldnd.path.mnt, |
487 |
new_dir->d_inode, new_dentry, newnd.path.mnt); |
new_dir->d_inode, new_dentry, newnd.path.mnt); |
488 |
@@ -2721,6 +2839,10 @@ asmlinkage long sys_renameat(int olddfd, |
--- linux-2.6.25.20-0.4.orig/fs/namespace.c |
489 |
int error; |
+++ linux-2.6.25.20-0.4/fs/namespace.c |
|
char * from; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(TOMOYO_SYS_RENAME)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
|
--- linux-2.6.25.20-0.1.orig/fs/namespace.c |
|
|
+++ linux-2.6.25.20-0.1/fs/namespace.c |
|
490 |
@@ -30,6 +30,12 @@ |
@@ -30,6 +30,12 @@ |
491 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
492 |
#include "pnode.h" |
#include "pnode.h" |
517 |
struct nameidata nd; |
struct nameidata nd; |
518 |
int retval; |
int retval; |
519 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
520 |
+ if (!ccs_capable(TOMOYO_SYS_UMOUNT)) |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
521 |
+ return -EPERM; |
+ return -EPERM; |
522 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
523 |
|
|
564 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
565 |
|
|
566 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
567 |
+ if (!ccs_capable(TOMOYO_SYS_MOUNT)) |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
568 |
+ return -EPERM; |
+ return -EPERM; |
569 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
570 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
582 |
if (!capable(CAP_SYS_ADMIN)) |
if (!capable(CAP_SYS_ADMIN)) |
583 |
return -EPERM; |
return -EPERM; |
584 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
585 |
+ if (!ccs_capable(TOMOYO_SYS_PIVOT_ROOT)) |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
586 |
+ return -EPERM; |
+ return -EPERM; |
587 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
588 |
|
|
599 |
if (error) { |
if (error) { |
600 |
path_put(&old_nd.path); |
path_put(&old_nd.path); |
601 |
goto out1; |
goto out1; |
602 |
--- linux-2.6.25.20-0.1.orig/fs/open.c |
--- linux-2.6.25.20-0.4.orig/fs/open.c |
603 |
+++ linux-2.6.25.20-0.1/fs/open.c |
+++ linux-2.6.25.20-0.4/fs/open.c |
604 |
@@ -27,6 +27,12 @@ |
@@ -27,6 +27,12 @@ |
605 |
#include <linux/rcupdate.h> |
#include <linux/rcupdate.h> |
606 |
#include <linux/audit.h> |
#include <linux/audit.h> |
619 |
goto put_write_and_out; |
goto put_write_and_out; |
620 |
|
|
621 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
622 |
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.path.dentry, |
+ error = ccs_check_truncate_permission(nd.path.dentry, nd.path.mnt, |
623 |
+ nd.path.mnt); |
+ length, 0); |
624 |
+ if (error) |
+ if (error) |
625 |
+ goto put_write_and_out; |
+ goto put_write_and_out; |
626 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
627 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
628 |
if (!error) { |
if (!error) { |
629 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
630 |
@@ -321,6 +333,11 @@ static long do_sys_ftruncate(unsigned in |
@@ -321,6 +333,12 @@ static long do_sys_ftruncate(unsigned in |
631 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
632 |
goto out_putf; |
goto out_putf; |
633 |
|
|
634 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
635 |
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt); |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
636 |
|
+ 0); |
637 |
+ if (error) |
+ if (error) |
638 |
+ goto out_putf; |
+ goto out_putf; |
639 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
640 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
641 |
if (!error) |
if (!error) |
642 |
error = do_truncate(dentry, file->f_path.mnt, length, |
error = do_truncate(dentry, file->f_path.mnt, length, |
643 |
@@ -539,6 +556,14 @@ asmlinkage long sys_chroot(const char __ |
@@ -539,6 +557,14 @@ asmlinkage long sys_chroot(const char __ |
644 |
error = -EPERM; |
error = -EPERM; |
645 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
646 |
goto dput_and_out; |
goto dput_and_out; |
647 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
648 |
+ if (!ccs_capable(TOMOYO_SYS_CHROOT)) |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
649 |
+ goto dput_and_out; |
+ goto dput_and_out; |
650 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
651 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
655 |
|
|
656 |
set_fs_root(current->fs, &nd.path); |
set_fs_root(current->fs, &nd.path); |
657 |
set_fs_altroot(); |
set_fs_altroot(); |
658 |
@@ -1172,6 +1197,10 @@ EXPORT_SYMBOL(sys_close); |
@@ -1172,6 +1198,10 @@ EXPORT_SYMBOL(sys_close); |
659 |
*/ |
*/ |
660 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
661 |
{ |
{ |
662 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
663 |
+ if (!ccs_capable(TOMOYO_SYS_VHANGUP)) |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
664 |
+ return -EPERM; |
+ return -EPERM; |
665 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
666 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
667 |
/* XXX: this needs locking */ |
/* XXX: this needs locking */ |
668 |
tty_vhangup(current->signal->tty); |
tty_vhangup(current->signal->tty); |
669 |
--- linux-2.6.25.20-0.1.orig/fs/proc/Makefile |
--- linux-2.6.25.20-0.4.orig/fs/proc/Makefile |
670 |
+++ linux-2.6.25.20-0.1/fs/proc/Makefile |
+++ linux-2.6.25.20-0.4/fs/proc/Makefile |
671 |
@@ -16,3 +16,6 @@ proc-$(CONFIG_PROC_KCORE) += kcore.o |
@@ -16,3 +16,6 @@ proc-$(CONFIG_PROC_KCORE) += kcore.o |
672 |
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
673 |
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
675 |
+ |
+ |
676 |
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
677 |
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
678 |
--- linux-2.6.25.20-0.1.orig/fs/proc/proc_misc.c |
--- linux-2.6.25.20-0.4.orig/fs/proc/proc_misc.c |
679 |
+++ linux-2.6.25.20-0.1/fs/proc/proc_misc.c |
+++ linux-2.6.25.20-0.4/fs/proc/proc_misc.c |
680 |
@@ -1021,4 +1021,9 @@ void __init proc_misc_init(void) |
@@ -1021,4 +1021,9 @@ void __init proc_misc_init(void) |
681 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
entry->proc_fops = &proc_sysrq_trigger_operations; |
682 |
} |
} |
683 |
#endif |
#endif |
684 |
+ /***** CCS start. *****/ |
+ /***** CCS start. *****/ |
685 |
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
686 |
+ printk(KERN_INFO "Hook version: 2.6.25.20-0.1 2009/01/25\n"); |
+ printk(KERN_INFO "Hook version: 2.6.25.20-0.4 2009/06/09\n"); |
687 |
+#endif |
+#endif |
688 |
+ /***** CCS end. *****/ |
+ /***** CCS end. *****/ |
689 |
} |
} |
690 |
--- linux-2.6.25.20-0.1.orig/include/linux/init_task.h |
--- linux-2.6.25.20-0.4.orig/include/linux/init_task.h |
691 |
+++ linux-2.6.25.20-0.1/include/linux/init_task.h |
+++ linux-2.6.25.20-0.4/include/linux/init_task.h |
692 |
@@ -196,6 +196,10 @@ extern struct group_info init_groups; |
@@ -196,6 +196,10 @@ extern struct group_info init_groups; |
693 |
INIT_IDS \ |
INIT_IDS \ |
694 |
INIT_TRACE_IRQFLAGS \ |
INIT_TRACE_IRQFLAGS \ |
695 |
INIT_LOCKDEP \ |
INIT_LOCKDEP \ |
696 |
+ /***** TOMOYO Linux start. *****/ \ |
+ /***** TOMOYO Linux start. *****/ \ |
697 |
+ .domain_info = &KERNEL_DOMAIN, \ |
+ .ccs_domain_info = NULL, \ |
698 |
+ .tomoyo_flags = 0, \ |
+ .ccs_flags = 0, \ |
699 |
+ /***** TOMOYO Linux end. *****/ \ |
+ /***** TOMOYO Linux end. *****/ \ |
700 |
} |
} |
701 |
|
|
702 |
|
|
703 |
--- linux-2.6.25.20-0.1.orig/include/linux/sched.h |
--- linux-2.6.25.20-0.4.orig/include/linux/sched.h |
704 |
+++ linux-2.6.25.20-0.1/include/linux/sched.h |
+++ linux-2.6.25.20-0.4/include/linux/sched.h |
705 |
@@ -29,6 +29,11 @@ |
@@ -29,6 +29,10 @@ |
706 |
#define CLONE_NEWNET 0x40000000 /* New network namespace */ |
#define CLONE_NEWNET 0x40000000 /* New network namespace */ |
707 |
#define CLONE_IO 0x80000000 /* Clone io context */ |
#define CLONE_IO 0x80000000 /* Clone io context */ |
708 |
|
|
709 |
+/***** TOMOYO Linux start. *****/ |
+/***** TOMOYO Linux start. *****/ |
710 |
+struct domain_info; |
+struct ccs_domain_info; |
|
+extern struct domain_info KERNEL_DOMAIN; |
|
711 |
+/***** TOMOYO Linux end. *****/ |
+/***** TOMOYO Linux end. *****/ |
712 |
+ |
+ |
713 |
/* |
/* |
714 |
* Scheduling policies |
* Scheduling policies |
715 |
*/ |
*/ |
716 |
@@ -1274,6 +1279,10 @@ struct task_struct { |
@@ -1274,6 +1278,10 @@ struct task_struct { |
717 |
#ifndef __GENKSYMS__ |
#ifndef __GENKSYMS__ |
718 |
struct list_head *scm_work_list; |
struct list_head *scm_work_list; |
719 |
#endif |
#endif |
720 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
721 |
+ struct domain_info *domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
722 |
+ u32 tomoyo_flags; |
+ u32 ccs_flags; |
723 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
724 |
}; |
}; |
725 |
|
|
726 |
/* |
/* |
727 |
--- linux-2.6.25.20-0.1.orig/kernel/compat.c |
--- linux-2.6.25.20-0.4.orig/kernel/compat.c |
728 |
+++ linux-2.6.25.20-0.1/kernel/compat.c |
+++ linux-2.6.25.20-0.4/kernel/compat.c |
729 |
@@ -25,6 +25,9 @@ |
@@ -25,6 +25,9 @@ |
730 |
#include <linux/posix-timers.h> |
#include <linux/posix-timers.h> |
731 |
|
|
741 |
if (err) |
if (err) |
742 |
return err; |
return err; |
743 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
744 |
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
745 |
+ return -EPERM; |
+ return -EPERM; |
746 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
747 |
|
|
748 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
749 |
return 0; |
return 0; |
750 |
--- linux-2.6.25.20-0.1.orig/kernel/kexec.c |
--- linux-2.6.25.20-0.4.orig/kernel/kexec.c |
751 |
+++ linux-2.6.25.20-0.1/kernel/kexec.c |
+++ linux-2.6.25.20-0.4/kernel/kexec.c |
752 |
@@ -31,6 +31,9 @@ |
@@ -31,6 +31,9 @@ |
753 |
#include <asm/system.h> |
#include <asm/system.h> |
754 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
764 |
if (!capable(CAP_SYS_BOOT)) |
if (!capable(CAP_SYS_BOOT)) |
765 |
return -EPERM; |
return -EPERM; |
766 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
767 |
+ if (!ccs_capable(TOMOYO_SYS_KEXEC_LOAD)) |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
768 |
+ return -EPERM; |
+ return -EPERM; |
769 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
770 |
|
|
771 |
/* |
/* |
772 |
* Verify we have a legal set of flags |
* Verify we have a legal set of flags |
773 |
--- linux-2.6.25.20-0.1.orig/kernel/kmod.c |
--- linux-2.6.25.20-0.4.orig/kernel/kmod.c |
774 |
+++ linux-2.6.25.20-0.1/kernel/kmod.c |
+++ linux-2.6.25.20-0.4/kernel/kmod.c |
775 |
@@ -173,6 +173,11 @@ static int ____call_usermodehelper(void |
@@ -173,6 +173,11 @@ static int ____call_usermodehelper(void |
776 |
*/ |
*/ |
777 |
set_user_nice(current, 0); |
set_user_nice(current, 0); |
778 |
|
|
779 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
780 |
+ current->domain_info = &KERNEL_DOMAIN; |
+ current->ccs_domain_info = NULL; |
781 |
+ current->tomoyo_flags = 0; |
+ current->ccs_flags = 0; |
782 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
783 |
+ |
+ |
784 |
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); |
785 |
|
|
786 |
/* Exec failed? */ |
/* Exec failed? */ |
787 |
--- linux-2.6.25.20-0.1.orig/kernel/module.c |
--- linux-2.6.25.20-0.4.orig/kernel/module.c |
788 |
+++ linux-2.6.25.20-0.1/kernel/module.c |
+++ linux-2.6.25.20-0.4/kernel/module.c |
789 |
@@ -47,6 +47,9 @@ |
@@ -47,6 +47,9 @@ |
790 |
#include <asm/cacheflush.h> |
#include <asm/cacheflush.h> |
791 |
#include <linux/license.h> |
#include <linux/license.h> |
801 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
802 |
return -EPERM; |
return -EPERM; |
803 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
804 |
+ if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
805 |
+ return -EPERM; |
+ return -EPERM; |
806 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
807 |
|
|
812 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
813 |
return -EPERM; |
return -EPERM; |
814 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
815 |
+ if (!ccs_capable(TOMOYO_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
816 |
+ return -EPERM; |
+ return -EPERM; |
817 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
818 |
|
|
819 |
/* Only one module load at a time, please */ |
/* Only one module load at a time, please */ |
820 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
if (mutex_lock_interruptible(&module_mutex) != 0) |
821 |
--- linux-2.6.25.20-0.1.orig/kernel/ptrace.c |
--- linux-2.6.25.20-0.4.orig/kernel/ptrace.c |
822 |
+++ linux-2.6.25.20-0.1/kernel/ptrace.c |
+++ linux-2.6.25.20-0.4/kernel/ptrace.c |
823 |
@@ -24,6 +24,9 @@ |
@@ -24,6 +24,9 @@ |
824 |
|
|
825 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
835 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
836 |
*/ |
*/ |
837 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
838 |
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
839 |
+ return -EPERM; |
+ return -EPERM; |
840 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
841 |
lock_kernel(); |
lock_kernel(); |
846 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
847 |
*/ |
*/ |
848 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
849 |
+ if (!ccs_capable(TOMOYO_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
850 |
+ return -EPERM; |
+ return -EPERM; |
851 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
852 |
lock_kernel(); |
lock_kernel(); |
853 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
854 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
855 |
--- linux-2.6.25.20-0.1.orig/kernel/sched.c |
--- linux-2.6.25.20-0.4.orig/kernel/sched.c |
856 |
+++ linux-2.6.25.20-0.1/kernel/sched.c |
+++ linux-2.6.25.20-0.4/kernel/sched.c |
857 |
@@ -69,6 +69,9 @@ |
@@ -69,6 +69,9 @@ |
858 |
|
|
859 |
#include <asm/tlb.h> |
#include <asm/tlb.h> |
869 |
{ |
{ |
870 |
long nice, retval; |
long nice, retval; |
871 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
872 |
+ if (!ccs_capable(TOMOYO_SYS_NICE)) |
+ if (!ccs_capable(CCS_SYS_NICE)) |
873 |
+ return -EPERM; |
+ return -EPERM; |
874 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
875 |
|
|
876 |
/* |
/* |
877 |
* Setpriority might change our priority at the same moment. |
* Setpriority might change our priority at the same moment. |
878 |
--- linux-2.6.25.20-0.1.orig/kernel/signal.c |
--- linux-2.6.25.20-0.4.orig/kernel/signal.c |
879 |
+++ linux-2.6.25.20-0.1/kernel/signal.c |
+++ linux-2.6.25.20-0.4/kernel/signal.c |
880 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,9 @@ |
881 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
882 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
892 |
{ |
{ |
893 |
struct siginfo info; |
struct siginfo info; |
894 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
895 |
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
896 |
+ return -EPERM; |
+ return -EPERM; |
897 |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
898 |
+ return -EPERM; |
+ return -EPERM; |
905 |
if (pid <= 0 || tgid <= 0) |
if (pid <= 0 || tgid <= 0) |
906 |
return -EINVAL; |
return -EINVAL; |
907 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
908 |
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
909 |
+ return -EPERM; |
+ return -EPERM; |
910 |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
911 |
+ return -EPERM; |
+ return -EPERM; |
918 |
if (pid <= 0) |
if (pid <= 0) |
919 |
return -EINVAL; |
return -EINVAL; |
920 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
921 |
+ if (sig && !ccs_capable(TOMOYO_SYS_KILL)) |
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
922 |
+ return -EPERM; |
+ return -EPERM; |
923 |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
+ if (sig && ccs_check_signal_acl(sig, pid)) |
924 |
+ return -EPERM; |
+ return -EPERM; |
926 |
|
|
927 |
return do_tkill(0, pid, sig); |
return do_tkill(0, pid, sig); |
928 |
} |
} |
929 |
--- linux-2.6.25.20-0.1.orig/kernel/sys.c |
--- linux-2.6.25.20-0.4.orig/kernel/sys.c |
930 |
+++ linux-2.6.25.20-0.1/kernel/sys.c |
+++ linux-2.6.25.20-0.4/kernel/sys.c |
931 |
@@ -42,6 +42,9 @@ |
@@ -42,6 +42,9 @@ |
932 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
933 |
#include <asm/io.h> |
#include <asm/io.h> |
943 |
if (which > PRIO_USER || which < PRIO_PROCESS) |
if (which > PRIO_USER || which < PRIO_PROCESS) |
944 |
goto out; |
goto out; |
945 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
946 |
+ if (!ccs_capable(TOMOYO_SYS_NICE)) { |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
947 |
+ error = -EPERM; |
+ error = -EPERM; |
948 |
+ goto out; |
+ goto out; |
949 |
+ } |
+ } |
956 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
magic2 != LINUX_REBOOT_MAGIC2C)) |
957 |
return -EINVAL; |
return -EINVAL; |
958 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
959 |
+ if (!ccs_capable(TOMOYO_SYS_REBOOT)) |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
960 |
+ return -EPERM; |
+ return -EPERM; |
961 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
962 |
|
|
967 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
968 |
return -EINVAL; |
return -EINVAL; |
969 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
970 |
+ if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
971 |
+ return -EPERM; |
+ return -EPERM; |
972 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
973 |
down_write(&uts_sem); |
down_write(&uts_sem); |
978 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
979 |
return -EINVAL; |
return -EINVAL; |
980 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
981 |
+ if (!ccs_capable(TOMOYO_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
982 |
+ return -EPERM; |
+ return -EPERM; |
983 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
984 |
|
|
985 |
down_write(&uts_sem); |
down_write(&uts_sem); |
986 |
errno = -EFAULT; |
errno = -EFAULT; |
987 |
--- linux-2.6.25.20-0.1.orig/kernel/sysctl.c |
--- linux-2.6.25.20-0.4.orig/kernel/sysctl.c |
988 |
+++ linux-2.6.25.20-0.1/kernel/sysctl.c |
+++ linux-2.6.25.20-0.4/kernel/sysctl.c |
989 |
@@ -48,6 +48,9 @@ |
@@ -48,6 +48,9 @@ |
990 |
|
|
991 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
996 |
|
|
997 |
#ifdef CONFIG_X86 |
#ifdef CONFIG_X86 |
998 |
#include <asm/nmi.h> |
#include <asm/nmi.h> |
999 |
@@ -1500,6 +1503,93 @@ char *sysctl_pathname(struct ctl_table * |
@@ -1500,6 +1503,7 @@ char *sysctl_pathname(struct ctl_table * |
1000 |
EXPORT_SYMBOL_GPL(sysctl_pathname); |
EXPORT_SYMBOL_GPL(sysctl_pathname); |
1001 |
|
|
1002 |
#ifdef CONFIG_SYSCTL_SYSCALL |
#ifdef CONFIG_SYSCTL_SYSCALL |
1003 |
+ |
+ |
|
+/***** TOMOYO Linux start. *****/ |
|
|
+static int try_parse_table(int __user *name, int nlen, void __user *oldval, |
|
|
+ void __user *newval, ctl_table *table) |
|
|
+{ |
|
|
+ int n; |
|
|
+ int error = -ENOMEM; |
|
|
+ int op = 0; |
|
|
+ char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); |
|
|
+ if (oldval) |
|
|
+ op |= 004; |
|
|
+ if (newval) |
|
|
+ op |= 002; |
|
|
+ if (!op) { /* Neither read nor write */ |
|
|
+ error = 0; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (!buffer) |
|
|
+ goto out; |
|
|
+ memset(buffer, 0, PAGE_SIZE); |
|
|
+ snprintf(buffer, PAGE_SIZE - 1, "/proc/sys"); |
|
|
+ repeat: |
|
|
+ if (!nlen) { |
|
|
+ error = -ENOTDIR; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (get_user(n, name)) { |
|
|
+ error = -EFAULT; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ for ( ; table->ctl_name || table->procname; table++) { |
|
|
+ if (n == table->ctl_name && n) { |
|
|
+ int pos = strlen(buffer); |
|
|
+ const char *cp = table->procname; |
|
|
+ error = -ENOMEM; |
|
|
+ if (cp) { |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '/'; |
|
|
+ while (*cp) { |
|
|
+ const unsigned char c |
|
|
+ = *(const unsigned char *) cp; |
|
|
+ if (c == '\\') { |
|
|
+ if (pos + 2 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ } else if (c > ' ' && c < 127) { |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = c; |
|
|
+ } else { |
|
|
+ if (pos + 4 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ buffer[pos++] = (c >> 6) + '0'; |
|
|
+ buffer[pos++] = ((c >> 3) & 7) |
|
|
+ + '0'; |
|
|
+ buffer[pos++] = (c & 7) + '0'; |
|
|
+ } |
|
|
+ cp++; |
|
|
+ } |
|
|
+ } else { |
|
|
+ /* Assume nobody assigns "=\$=" for procname. */ |
|
|
+ snprintf(buffer + pos, PAGE_SIZE - pos - 1, |
|
|
+ "/=%d=", n); |
|
|
+ if (!memchr(buffer, '\0', PAGE_SIZE - 2)) |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (table->child) { |
|
|
+ name++; |
|
|
+ nlen--; |
|
|
+ table = table->child; |
|
|
+ goto repeat; |
|
|
+ } |
|
|
+ /* printk("sysctl='%s'\n", buffer); */ |
|
|
+ error = ccs_check_file_perm(buffer, op, "sysctl"); |
|
|
+ goto out; |
|
|
+ } |
|
|
+ } |
|
|
+ error = -ENOTDIR; |
|
|
+ out: |
|
|
+ kfree(buffer); |
|
|
+ return error; |
|
|
+} |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
+ |
|
1004 |
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
1005 |
void __user *newval, size_t newlen) |
void __user *newval, size_t newlen) |
1006 |
{ |
{ |
1007 |
@@ -1516,6 +1606,11 @@ int do_sysctl(int __user *name, int nlen |
@@ -1516,6 +1520,11 @@ int do_sysctl(int __user *name, int nlen |
1008 |
|
|
1009 |
for (head = sysctl_head_next(NULL); head; |
for (head = sysctl_head_next(NULL); head; |
1010 |
head = sysctl_head_next(head)) { |
head = sysctl_head_next(head)) { |
1011 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1012 |
+ error = try_parse_table(name, nlen, oldval, newval, |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
1013 |
+ head->ctl_table); |
+ head->ctl_table); |
1014 |
+ if (!error) |
+ if (!error) |
1015 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1016 |
error = parse_table(name, nlen, oldval, oldlenp, |
error = parse_table(name, nlen, oldval, oldlenp, |
1017 |
newval, newlen, head->ctl_table); |
newval, newlen, head->ctl_table); |
1018 |
if (error != -ENOTDIR) { |
if (error != -ENOTDIR) { |
1019 |
--- linux-2.6.25.20-0.1.orig/kernel/time.c |
--- linux-2.6.25.20-0.4.orig/kernel/time.c |
1020 |
+++ linux-2.6.25.20-0.1/kernel/time.c |
+++ linux-2.6.25.20-0.4/kernel/time.c |
1021 |
@@ -38,6 +38,9 @@ |
@@ -38,6 +38,9 @@ |
1022 |
|
|
1023 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1033 |
if (err) |
if (err) |
1034 |
return err; |
return err; |
1035 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1036 |
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1037 |
+ return -EPERM; |
+ return -EPERM; |
1038 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1039 |
|
|
1044 |
if (error) |
if (error) |
1045 |
return error; |
return error; |
1046 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1047 |
+ if (!ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1048 |
+ return -EPERM; |
+ return -EPERM; |
1049 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1050 |
|
|
1051 |
if (tz) { |
if (tz) { |
1052 |
/* SMP safe, global irq locking makes it work. */ |
/* SMP safe, global irq locking makes it work. */ |
1053 |
--- linux-2.6.25.20-0.1.orig/kernel/time/ntp.c |
--- linux-2.6.25.20-0.4.orig/kernel/time/ntp.c |
1054 |
+++ linux-2.6.25.20-0.1/kernel/time/ntp.c |
+++ linux-2.6.25.20-0.4/kernel/time/ntp.c |
1055 |
@@ -17,6 +17,9 @@ |
@@ -17,6 +17,9 @@ |
1056 |
#include <linux/capability.h> |
#include <linux/capability.h> |
1057 |
#include <asm/div64.h> |
#include <asm/div64.h> |
1067 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
if (txc->modes && !capable(CAP_SYS_TIME)) |
1068 |
return -EPERM; |
return -EPERM; |
1069 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1070 |
+ if (txc->modes && !ccs_capable(TOMOYO_SYS_SETTIME)) |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
1071 |
+ return -EPERM; |
+ return -EPERM; |
1072 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1073 |
|
|
1074 |
/* Now we validate the data before disabling interrupts */ |
/* Now we validate the data before disabling interrupts */ |
1075 |
|
|
1076 |
--- linux-2.6.25.20-0.1.orig/net/core/datagram.c |
--- linux-2.6.25.20-0.4.orig/net/ipv4/inet_connection_sock.c |
1077 |
+++ linux-2.6.25.20-0.1/net/core/datagram.c |
+++ linux-2.6.25.20-0.4/net/ipv4/inet_connection_sock.c |
|
@@ -56,6 +56,11 @@ |
|
|
#include <net/sock.h> |
|
|
#include <net/tcp_states.h> |
|
|
|
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+#include <linux/tomoyo_socket.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
+ |
|
|
/* |
|
|
* Is a socket 'connection oriented' ? |
|
|
*/ |
|
|
@@ -179,6 +184,12 @@ struct sk_buff *__skb_recv_datagram(stru |
|
|
} |
|
|
spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); |
|
|
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = ccs_socket_recv_datagram_permission(sk, skb, flags); |
|
|
+ if (error) |
|
|
+ goto no_packet; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ |
|
|
if (skb) |
|
|
return skb; |
|
|
|
|
|
--- linux-2.6.25.20-0.1.orig/net/ipv4/inet_connection_sock.c |
|
|
+++ linux-2.6.25.20-0.1/net/ipv4/inet_connection_sock.c |
|
1078 |
@@ -23,6 +23,9 @@ |
@@ -23,6 +23,9 @@ |
1079 |
#include <net/route.h> |
#include <net/route.h> |
1080 |
#include <net/tcp_states.h> |
#include <net/tcp_states.h> |
1090 |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
1091 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1092 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1093 |
+ if (ccs_may_autobind(rover)) |
+ if (ccs_lport_reserved(rover)) |
1094 |
+ goto next; |
+ goto next; |
1095 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1096 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
inet_bind_bucket_for_each(tb, node, &head->chain) |
1097 |
if (tb->ib_net == net && tb->port == rover) |
if (tb->ib_net == net && tb->port == rover) |
1098 |
goto next; |
goto next; |
1099 |
--- linux-2.6.25.20-0.1.orig/net/ipv4/inet_hashtables.c |
--- linux-2.6.25.20-0.4.orig/net/ipv4/inet_hashtables.c |
1100 |
+++ linux-2.6.25.20-0.1/net/ipv4/inet_hashtables.c |
+++ linux-2.6.25.20-0.4/net/ipv4/inet_hashtables.c |
1101 |
@@ -22,6 +22,9 @@ |
@@ -22,6 +22,9 @@ |
1102 |
#include <net/inet_connection_sock.h> |
#include <net/inet_connection_sock.h> |
1103 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1113 |
for (i = 1; i <= remaining; i++) { |
for (i = 1; i <= remaining; i++) { |
1114 |
port = low + (i + offset) % remaining; |
port = low + (i + offset) % remaining; |
1115 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1116 |
+ if (ccs_may_autobind(port)) |
+ if (ccs_lport_reserved(port)) |
1117 |
+ continue; |
+ continue; |
1118 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1119 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1120 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1121 |
|
|
1122 |
--- linux-2.6.25.20-0.1.orig/net/ipv4/udp.c |
--- linux-2.6.25.20-0.4.orig/net/ipv4/raw.c |
1123 |
+++ linux-2.6.25.20-0.1/net/ipv4/udp.c |
+++ linux-2.6.25.20-0.4/net/ipv4/raw.c |
1124 |
@@ -105,6 +105,9 @@ |
@@ -79,6 +79,9 @@ |
1125 |
|
#include <linux/seq_file.h> |
1126 |
|
#include <linux/netfilter.h> |
1127 |
|
#include <linux/netfilter_ipv4.h> |
1128 |
|
+/***** TOMOYO Linux start. *****/ |
1129 |
|
+#include <linux/tomoyo_socket.h> |
1130 |
|
+/***** TOMOYO Linux end. *****/ |
1131 |
|
|
1132 |
|
static struct raw_hashinfo raw_v4_hashinfo = { |
1133 |
|
.lock = __RW_LOCK_UNLOCKED(), |
1134 |
|
@@ -668,6 +671,11 @@ static int raw_recvmsg(struct kiocb *ioc |
1135 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1136 |
|
if (!skb) |
1137 |
|
goto out; |
1138 |
|
+ /***** TOMOYO Linux start. *****/ |
1139 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1140 |
|
+ if (err) |
1141 |
|
+ goto out; |
1142 |
|
+ /***** TOMOYO Linux end. *****/ |
1143 |
|
|
1144 |
|
copied = skb->len; |
1145 |
|
if (len < copied) { |
1146 |
|
--- linux-2.6.25.20-0.4.orig/net/ipv4/udp.c |
1147 |
|
+++ linux-2.6.25.20-0.4/net/ipv4/udp.c |
1148 |
|
@@ -105,6 +105,12 @@ |
1149 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1150 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1151 |
#include "udp_impl.h" |
#include "udp_impl.h" |
1152 |
+/***** SAKURA Linux start. *****/ |
+/***** SAKURA Linux start. *****/ |
1153 |
+#include <linux/sakura.h> |
+#include <linux/sakura.h> |
1154 |
+/***** SAKURA Linux end. *****/ |
+/***** SAKURA Linux end. *****/ |
1155 |
|
+/***** TOMOYO Linux start. *****/ |
1156 |
|
+#include <linux/tomoyo_socket.h> |
1157 |
|
+/***** TOMOYO Linux end. *****/ |
1158 |
|
|
1159 |
/* |
/* |
1160 |
* Snmp MIB for the UDP layer |
* Snmp MIB for the UDP layer |
1161 |
@@ -176,6 +179,10 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -176,6 +182,10 @@ int __udp_lib_get_port(struct sock *sk, |
1162 |
/* 1st pass: look for empty (or shortest) hash chain */ |
/* 1st pass: look for empty (or shortest) hash chain */ |
1163 |
for (i = 0; i < UDP_HTABLE_SIZE; i++) { |
for (i = 0; i < UDP_HTABLE_SIZE; i++) { |
1164 |
int size = 0; |
int size = 0; |
1165 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1166 |
+ if (ccs_may_autobind(rover)) |
+ if (ccs_lport_reserved(rover)) |
1167 |
+ goto next; |
+ goto next; |
1168 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1169 |
|
|
1170 |
head = &udptable[rover & (UDP_HTABLE_SIZE - 1)]; |
head = &udptable[rover & (UDP_HTABLE_SIZE - 1)]; |
1171 |
if (hlist_empty(head)) |
if (hlist_empty(head)) |
1172 |
@@ -199,6 +206,9 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -199,6 +209,9 @@ int __udp_lib_get_port(struct sock *sk, |
1173 |
/* 2nd pass: find hole in shortest hash chain */ |
/* 2nd pass: find hole in shortest hash chain */ |
1174 |
rover = best; |
rover = best; |
1175 |
for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) { |
for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) { |
1176 |
+ /***** SAKURA Linux start. *****/ |
+ /***** SAKURA Linux start. *****/ |
1177 |
+ if (!ccs_may_autobind(rover)) |
+ if (!ccs_lport_reserved(rover)) |
1178 |
+ /***** SAKURA Linux end. *****/ |
+ /***** SAKURA Linux end. *****/ |
1179 |
if (! __udp_lib_lport_inuse(net, rover, udptable)) |
if (! __udp_lib_lport_inuse(net, rover, udptable)) |
1180 |
goto gotit; |
goto gotit; |
1181 |
rover += UDP_HTABLE_SIZE; |
rover += UDP_HTABLE_SIZE; |
1182 |
--- linux-2.6.25.20-0.1.orig/net/socket.c |
@@ -863,6 +876,11 @@ try_again: |
1183 |
+++ linux-2.6.25.20-0.1/net/socket.c |
&peeked, &err); |
1184 |
|
if (!skb) |
1185 |
|
goto out; |
1186 |
|
+ /***** TOMOYO Linux start. *****/ |
1187 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1188 |
|
+ if (err) |
1189 |
|
+ goto out; |
1190 |
|
+ /***** TOMOYO Linux end. *****/ |
1191 |
|
|
1192 |
|
ulen = skb->len - sizeof(struct udphdr); |
1193 |
|
copied = len; |
1194 |
|
--- linux-2.6.25.20-0.4.orig/net/ipv6/raw.c |
1195 |
|
+++ linux-2.6.25.20-0.4/net/ipv6/raw.c |
1196 |
|
@@ -60,6 +60,9 @@ |
1197 |
|
|
1198 |
|
#include <linux/proc_fs.h> |
1199 |
|
#include <linux/seq_file.h> |
1200 |
|
+/***** TOMOYO Linux start. *****/ |
1201 |
|
+#include <linux/tomoyo_socket.h> |
1202 |
|
+/***** TOMOYO Linux end. *****/ |
1203 |
|
|
1204 |
|
static struct raw_hashinfo raw_v6_hashinfo = { |
1205 |
|
.lock = __RW_LOCK_UNLOCKED(), |
1206 |
|
@@ -482,6 +485,11 @@ static int rawv6_recvmsg(struct kiocb *i |
1207 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1208 |
|
if (!skb) |
1209 |
|
goto out; |
1210 |
|
+ /***** TOMOYO Linux start. *****/ |
1211 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1212 |
|
+ if (err) |
1213 |
|
+ goto out; |
1214 |
|
+ /***** TOMOYO Linux end. *****/ |
1215 |
|
|
1216 |
|
copied = skb->len; |
1217 |
|
if (copied > len) { |
1218 |
|
--- linux-2.6.25.20-0.4.orig/net/ipv6/udp.c |
1219 |
|
+++ linux-2.6.25.20-0.4/net/ipv6/udp.c |
1220 |
|
@@ -50,6 +50,9 @@ |
1221 |
|
#include <linux/proc_fs.h> |
1222 |
|
#include <linux/seq_file.h> |
1223 |
|
#include "udp_impl.h" |
1224 |
|
+/***** TOMOYO Linux start. *****/ |
1225 |
|
+#include <linux/tomoyo_socket.h> |
1226 |
|
+/***** TOMOYO Linux end. *****/ |
1227 |
|
|
1228 |
|
static inline int udp_v6_get_port(struct sock *sk, unsigned short snum) |
1229 |
|
{ |
1230 |
|
@@ -137,6 +140,11 @@ try_again: |
1231 |
|
&peeked, &err); |
1232 |
|
if (!skb) |
1233 |
|
goto out; |
1234 |
|
+ /***** TOMOYO Linux start. *****/ |
1235 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1236 |
|
+ if (err) |
1237 |
|
+ goto out; |
1238 |
|
+ /***** TOMOYO Linux end. *****/ |
1239 |
|
|
1240 |
|
ulen = skb->len - sizeof(struct udphdr); |
1241 |
|
copied = len; |
1242 |
|
--- linux-2.6.25.20-0.4.orig/net/socket.c |
1243 |
|
+++ linux-2.6.25.20-0.4/net/socket.c |
1244 |
@@ -94,6 +94,11 @@ |
@@ -94,6 +94,11 @@ |
1245 |
#include <net/sock.h> |
#include <net/sock.h> |
1246 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1331 |
|
|
1332 |
err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen, |
err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen, |
1333 |
sock->file->f_flags); |
sock->file->f_flags); |
1334 |
--- linux-2.6.25.20-0.1.orig/net/unix/af_unix.c |
--- linux-2.6.25.20-0.4.orig/net/unix/af_unix.c |
1335 |
+++ linux-2.6.25.20-0.1/net/unix/af_unix.c |
+++ linux-2.6.25.20-0.4/net/unix/af_unix.c |
1336 |
@@ -116,6 +116,9 @@ |
@@ -116,6 +116,9 @@ |
1337 |
#include <linux/mount.h> |
#include <linux/mount.h> |
1338 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1343 |
|
|
1344 |
static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; |
static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; |
1345 |
static DEFINE_SPINLOCK(unix_table_lock); |
static DEFINE_SPINLOCK(unix_table_lock); |
1346 |
@@ -776,6 +779,11 @@ static int unix_bind(struct socket *sock |
@@ -819,6 +822,11 @@ static int unix_bind(struct socket *sock |
|
err = unix_autobind(sock); |
|
|
goto out; |
|
|
} |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = -EPERM; |
|
|
+ if (sunaddr->sun_path[0] && !ccs_capable(TOMOYO_CREATE_UNIX_SOCKET)) |
|
|
+ goto out; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
err = unix_mkname(sunaddr, addr_len, &hash); |
|
|
if (err < 0) |
|
|
@@ -819,6 +827,13 @@ static int unix_bind(struct socket *sock |
|
1347 |
*/ |
*/ |
1348 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1349 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1350 |
+ /***** TOMOYO Linux start. *****/ |
+ /***** TOMOYO Linux start. *****/ |
1351 |
+ err = pre_vfs_mknod(nd.path.dentry->d_inode, dentry, mode); |
+ err = ccs_check_mknod_permission(nd.path.dentry->d_inode, |
1352 |
+ if (!err) |
+ dentry, nd.path.mnt, mode, 0); |
|
+ err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry, |
|
|
+ nd.path.mnt); |
|
1353 |
+ if (!err) |
+ if (!err) |
1354 |
+ /***** TOMOYO Linux end. *****/ |
+ /***** TOMOYO Linux end. *****/ |
1355 |
err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt, |
err = vfs_mknod(nd.path.dentry->d_inode, dentry, nd.path.mnt, |