1 |
This is TOMOYO Linux patch for kernel 2.6.21. |
This is TOMOYO Linux patch for kernel 2.6.21.7. |
2 |
|
|
3 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.tar.bz2 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.7.tar.bz2 |
4 |
--- |
--- |
5 |
Makefile | 2 |
arch/alpha/kernel/ptrace.c | 3 +++ |
6 |
arch/alpha/kernel/ptrace.c | 8 +++ |
arch/ia64/ia32/sys_ia32.c | 3 +++ |
7 |
arch/ia64/kernel/ptrace.c | 8 +++ |
arch/ia64/kernel/ptrace.c | 3 +++ |
8 |
arch/m32r/kernel/ptrace.c | 8 +++ |
arch/m32r/kernel/ptrace.c | 3 +++ |
9 |
arch/powerpc/kernel/ptrace32.c | 8 +++ |
arch/mips/kernel/ptrace32.c | 3 +++ |
10 |
arch/s390/kernel/ptrace.c | 8 +++ |
arch/powerpc/kernel/ptrace32.c | 3 +++ |
11 |
arch/sh64/kernel/ptrace.c | 8 +++ |
arch/s390/kernel/ptrace.c | 3 +++ |
12 |
arch/sparc/kernel/ptrace.c | 8 +++ |
arch/sparc/kernel/ptrace.c | 5 +++++ |
13 |
arch/sparc64/kernel/ptrace.c | 8 +++ |
arch/sparc64/kernel/ptrace.c | 5 +++++ |
14 |
arch/x86_64/ia32/ptrace32.c | 8 +++ |
arch/x86_64/ia32/ptrace32.c | 3 +++ |
15 |
fs/Kconfig | 2 |
fs/attr.c | 5 +++++ |
16 |
fs/Makefile | 2 |
fs/compat.c | 9 ++++++++- |
17 |
fs/attr.c | 11 +++++ |
fs/exec.c | 11 ++++++++++- |
18 |
fs/compat.c | 8 +++ |
fs/fcntl.c | 4 ++++ |
19 |
fs/exec.c | 14 ++++++ |
fs/ioctl.c | 5 +++++ |
20 |
fs/fcntl.c | 7 +++ |
fs/namei.c | 31 ++++++++++++++++++++++++++++++- |
21 |
fs/ioctl.c | 6 ++ |
fs/namespace.c | 22 ++++++++++++++++++++++ |
22 |
fs/namei.c | 60 +++++++++++++++++++++++++++++ |
fs/open.c | 28 ++++++++++++++++++++++++++++ |
23 |
fs/namespace.c | 38 ++++++++++++++++++ |
fs/proc/proc_misc.c | 1 + |
24 |
fs/open.c | 21 ++++++++++ |
include/linux/init_task.h | 9 +++++++++ |
25 |
fs/proc/Makefile | 3 + |
include/linux/sched.h | 6 ++++++ |
26 |
fs/proc/proc_misc.c | 9 ++++ |
kernel/compat.c | 3 +++ |
27 |
include/linux/init_task.h | 4 + |
kernel/kexec.c | 3 +++ |
28 |
include/linux/sched.h | 9 ++++ |
kernel/kmod.c | 5 +++++ |
29 |
kernel/compat.c | 6 ++ |
kernel/module.c | 5 +++++ |
30 |
kernel/kexec.c | 6 ++ |
kernel/ptrace.c | 3 +++ |
31 |
kernel/kmod.c | 5 ++ |
kernel/sched.c | 3 +++ |
32 |
kernel/module.c | 9 ++++ |
kernel/signal.c | 9 +++++++++ |
33 |
kernel/ptrace.c | 8 +++ |
kernel/sys.c | 11 +++++++++++ |
34 |
kernel/sched.c | 6 ++ |
kernel/sysctl.c | 5 +++++ |
35 |
kernel/signal.c | 15 +++++++ |
kernel/time.c | 5 +++++ |
36 |
kernel/sys.c | 15 +++++++ |
kernel/time/ntp.c | 3 +++ |
37 |
kernel/sysctl.c | 81 ++++++++++++++++++++++++++++++++++++++++ |
net/ipv4/inet_connection_sock.c | 3 +++ |
38 |
kernel/time.c | 9 ++++ |
net/ipv4/inet_hashtables.c | 3 +++ |
39 |
kernel/time/ntp.c | 6 ++ |
net/ipv4/raw.c | 4 ++++ |
40 |
net/core/datagram.c | 9 ++++ |
net/ipv4/udp.c | 8 ++++++++ |
41 |
net/ipv4/inet_connection_sock.c | 6 ++ |
net/ipv6/inet6_hashtables.c | 3 +++ |
42 |
net/ipv4/inet_hashtables.c | 6 ++ |
net/ipv6/raw.c | 4 ++++ |
43 |
net/ipv4/udp.c | 9 ++++ |
net/ipv6/udp.c | 4 ++++ |
44 |
net/ipv6/inet6_hashtables.c | 6 ++ |
net/socket.c | 23 +++++++++++++++++++++++ |
45 |
net/socket.c | 28 +++++++++++++ |
net/unix/af_unix.c | 4 ++++ |
46 |
net/unix/af_unix.c | 10 ++++ |
security/Kconfig | 2 ++ |
47 |
42 files changed, 505 insertions(+), 3 deletions(-) |
security/Makefile | 3 +++ |
48 |
|
43 files changed, 278 insertions(+), 3 deletions(-) |
49 |
|
|
50 |
--- linux-2.6.21.orig/Makefile |
--- linux-2.6.21.7.orig/arch/alpha/kernel/ptrace.c |
51 |
+++ linux-2.6.21/Makefile |
+++ linux-2.6.21.7/arch/alpha/kernel/ptrace.c |
52 |
@@ -1,7 +1,7 @@ |
@@ -20,6 +20,7 @@ |
|
VERSION = 2 |
|
|
PATCHLEVEL = 6 |
|
|
SUBLEVEL = 21 |
|
|
-EXTRAVERSION = |
|
|
+EXTRAVERSION = -ccs |
|
|
NAME = Nocturnal Monster Puppy |
|
|
|
|
|
# *DOCUMENTATION* |
|
|
--- linux-2.6.21.orig/arch/alpha/kernel/ptrace.c |
|
|
+++ linux-2.6.21/arch/alpha/kernel/ptrace.c |
|
|
@@ -20,6 +20,9 @@ |
|
53 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
54 |
#include <asm/system.h> |
#include <asm/system.h> |
55 |
#include <asm/fpu.h> |
#include <asm/fpu.h> |
56 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
57 |
|
|
58 |
#include "proto.h" |
#include "proto.h" |
59 |
|
|
60 |
@@ -268,6 +271,11 @@ do_sys_ptrace(long request, long pid, lo |
@@ -268,6 +269,8 @@ do_sys_ptrace(long request, long pid, lo |
61 |
unsigned long tmp; |
unsigned long tmp; |
62 |
size_t copied; |
size_t copied; |
63 |
long ret; |
long ret; |
64 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
65 |
+#ifdef TOMOYO_SYS_PTRACE |
+ return -EPERM; |
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
66 |
|
|
67 |
lock_kernel(); |
lock_kernel(); |
68 |
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n", |
69 |
--- linux-2.6.21.orig/arch/ia64/kernel/ptrace.c |
--- linux-2.6.21.7.orig/arch/ia64/ia32/sys_ia32.c |
70 |
+++ linux-2.6.21/arch/ia64/kernel/ptrace.c |
+++ linux-2.6.21.7/arch/ia64/ia32/sys_ia32.c |
71 |
@@ -28,6 +28,9 @@ |
@@ -56,6 +56,7 @@ |
72 |
|
#include <asm/types.h> |
73 |
|
#include <asm/uaccess.h> |
74 |
|
#include <asm/unistd.h> |
75 |
|
+#include <linux/ccsecurity.h> |
76 |
|
|
77 |
|
#include "ia32priv.h" |
78 |
|
|
79 |
|
@@ -1758,6 +1759,8 @@ sys32_ptrace (int request, pid_t pid, un |
80 |
|
struct task_struct *child; |
81 |
|
unsigned int value, tmp; |
82 |
|
long i, ret; |
83 |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
84 |
|
+ return -EPERM; |
85 |
|
|
86 |
|
lock_kernel(); |
87 |
|
if (request == PTRACE_TRACEME) { |
88 |
|
--- linux-2.6.21.7.orig/arch/ia64/kernel/ptrace.c |
89 |
|
+++ linux-2.6.21.7/arch/ia64/kernel/ptrace.c |
90 |
|
@@ -28,6 +28,7 @@ |
91 |
#ifdef CONFIG_PERFMON |
#ifdef CONFIG_PERFMON |
92 |
#include <asm/perfmon.h> |
#include <asm/perfmon.h> |
93 |
#endif |
#endif |
94 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
95 |
|
|
96 |
#include "entry.h" |
#include "entry.h" |
97 |
|
|
98 |
@@ -1418,6 +1421,11 @@ sys_ptrace (long request, pid_t pid, uns |
@@ -1418,6 +1419,8 @@ sys_ptrace (long request, pid_t pid, uns |
99 |
struct task_struct *child; |
struct task_struct *child; |
100 |
struct switch_stack *sw; |
struct switch_stack *sw; |
101 |
long ret; |
long ret; |
102 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
103 |
+#ifdef TOMOYO_SYS_PTRACE |
+ return -EPERM; |
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
104 |
|
|
105 |
lock_kernel(); |
lock_kernel(); |
106 |
ret = -EPERM; |
ret = -EPERM; |
107 |
--- linux-2.6.21.orig/arch/m32r/kernel/ptrace.c |
--- linux-2.6.21.7.orig/arch/m32r/kernel/ptrace.c |
108 |
+++ linux-2.6.21/arch/m32r/kernel/ptrace.c |
+++ linux-2.6.21.7/arch/m32r/kernel/ptrace.c |
109 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
110 |
#include <asm/system.h> |
#include <asm/system.h> |
111 |
#include <asm/processor.h> |
#include <asm/processor.h> |
112 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
113 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
114 |
|
|
115 |
/* |
/* |
116 |
* This routine will get a word off of the process kernel stack. |
* This routine will get a word off of the process kernel stack. |
117 |
@@ -742,6 +745,11 @@ asmlinkage long sys_ptrace(long request, |
@@ -742,6 +743,8 @@ asmlinkage long sys_ptrace(long request, |
118 |
{ |
{ |
119 |
struct task_struct *child; |
struct task_struct *child; |
120 |
int ret; |
int ret; |
121 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
122 |
+#ifdef TOMOYO_SYS_PTRACE |
+ return -EPERM; |
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
123 |
|
|
124 |
lock_kernel(); |
lock_kernel(); |
125 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
126 |
--- linux-2.6.21.orig/arch/s390/kernel/ptrace.c |
--- linux-2.6.21.7.orig/arch/mips/kernel/ptrace32.c |
127 |
+++ linux-2.6.21/arch/s390/kernel/ptrace.c |
+++ linux-2.6.21.7/arch/mips/kernel/ptrace32.c |
128 |
@@ -41,6 +41,9 @@ |
@@ -35,6 +35,7 @@ |
129 |
|
#include <asm/system.h> |
130 |
|
#include <asm/uaccess.h> |
131 |
|
#include <asm/bootinfo.h> |
132 |
|
+#include <linux/ccsecurity.h> |
133 |
|
|
134 |
|
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
135 |
|
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
136 |
|
@@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request, |
137 |
|
{ |
138 |
|
struct task_struct *child; |
139 |
|
int ret; |
140 |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
141 |
|
+ return -EPERM; |
142 |
|
|
143 |
|
#if 0 |
144 |
|
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
145 |
|
--- linux-2.6.21.7.orig/arch/powerpc/kernel/ptrace32.c |
146 |
|
+++ linux-2.6.21.7/arch/powerpc/kernel/ptrace32.c |
147 |
|
@@ -32,6 +32,7 @@ |
148 |
|
#include <asm/page.h> |
149 |
|
#include <asm/pgtable.h> |
150 |
|
#include <asm/system.h> |
151 |
|
+#include <linux/ccsecurity.h> |
152 |
|
|
153 |
|
#include "ptrace-common.h" |
154 |
|
|
155 |
|
@@ -45,6 +46,8 @@ long compat_sys_ptrace(int request, int |
156 |
|
{ |
157 |
|
struct task_struct *child; |
158 |
|
int ret; |
159 |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
160 |
|
+ return -EPERM; |
161 |
|
|
162 |
|
lock_kernel(); |
163 |
|
if (request == PTRACE_TRACEME) { |
164 |
|
--- linux-2.6.21.7.orig/arch/s390/kernel/ptrace.c |
165 |
|
+++ linux-2.6.21.7/arch/s390/kernel/ptrace.c |
166 |
|
@@ -41,6 +41,7 @@ |
167 |
#include <asm/system.h> |
#include <asm/system.h> |
168 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
169 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
170 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
171 |
|
|
172 |
#ifdef CONFIG_COMPAT |
#ifdef CONFIG_COMPAT |
173 |
#include "compat_ptrace.h" |
#include "compat_ptrace.h" |
174 |
@@ -713,6 +716,11 @@ sys_ptrace(long request, long pid, long |
@@ -713,6 +714,8 @@ sys_ptrace(long request, long pid, long |
175 |
struct task_struct *child; |
struct task_struct *child; |
176 |
int ret; |
int ret; |
177 |
|
|
178 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
179 |
+#ifdef TOMOYO_SYS_PTRACE |
+ return -EPERM; |
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
180 |
lock_kernel(); |
lock_kernel(); |
181 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
182 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
183 |
--- linux-2.6.21.orig/arch/sparc/kernel/ptrace.c |
--- linux-2.6.21.7.orig/arch/sparc/kernel/ptrace.c |
184 |
+++ linux-2.6.21/arch/sparc/kernel/ptrace.c |
+++ linux-2.6.21.7/arch/sparc/kernel/ptrace.c |
185 |
@@ -23,6 +23,9 @@ |
@@ -23,6 +23,7 @@ |
186 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
187 |
#include <asm/system.h> |
#include <asm/system.h> |
188 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
189 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
190 |
|
|
191 |
#define MAGIC_CONSTANT 0x80000000 |
#define MAGIC_CONSTANT 0x80000000 |
192 |
|
|
193 |
@@ -267,6 +270,11 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs |
194 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
195 |
struct task_struct *child; |
struct task_struct *child; |
196 |
int ret; |
int ret; |
197 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
198 |
+#ifdef TOMOYO_SYS_PTRACE |
+ pt_error_return(regs, EPERM); |
199 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
+ return; |
200 |
+#endif |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
201 |
|
|
202 |
lock_kernel(); |
lock_kernel(); |
203 |
#ifdef DEBUG_PTRACE |
#ifdef DEBUG_PTRACE |
204 |
--- linux-2.6.21.orig/arch/sparc64/kernel/ptrace.c |
--- linux-2.6.21.7.orig/arch/sparc64/kernel/ptrace.c |
205 |
+++ linux-2.6.21/arch/sparc64/kernel/ptrace.c |
+++ linux-2.6.21.7/arch/sparc64/kernel/ptrace.c |
206 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
207 |
#include <asm/spitfire.h> |
#include <asm/spitfire.h> |
208 |
#include <asm/page.h> |
#include <asm/page.h> |
209 |
#include <asm/cpudata.h> |
#include <asm/cpudata.h> |
210 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
211 |
|
|
212 |
/* Returning from ptrace is a bit tricky because the syscall return |
/* Returning from ptrace is a bit tricky because the syscall return |
213 |
* low level code assumes any value returned which is negative and |
* low level code assumes any value returned which is negative and |
214 |
@@ -176,6 +179,11 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -176,6 +177,10 @@ asmlinkage void do_ptrace(struct pt_regs |
215 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
216 |
struct task_struct *child; |
struct task_struct *child; |
217 |
int ret; |
int ret; |
218 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
219 |
+#ifdef TOMOYO_SYS_PTRACE |
+ pt_error_return(regs, EPERM); |
220 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
+ return; |
221 |
+#endif |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
222 |
|
|
223 |
if (test_thread_flag(TIF_32BIT)) { |
if (test_thread_flag(TIF_32BIT)) { |
224 |
addr &= 0xffffffffUL; |
addr &= 0xffffffffUL; |
225 |
--- linux-2.6.21.orig/fs/Kconfig |
--- linux-2.6.21.7.orig/arch/x86_64/ia32/ptrace32.c |
226 |
+++ linux-2.6.21/fs/Kconfig |
+++ linux-2.6.21.7/arch/x86_64/ia32/ptrace32.c |
227 |
@@ -2055,5 +2055,7 @@ endif |
@@ -26,6 +26,7 @@ |
228 |
source "fs/nls/Kconfig" |
#include <asm/i387.h> |
229 |
source "fs/dlm/Kconfig" |
#include <asm/fpu32.h> |
230 |
|
#include <asm/ia32.h> |
231 |
|
+#include <linux/ccsecurity.h> |
232 |
|
|
233 |
+source "fs/Kconfig.ccs" |
/* |
234 |
+ |
* Determines which flags the user has access to [1 = access, 0 = no access]. |
235 |
endmenu |
@@ -234,6 +235,8 @@ asmlinkage long sys32_ptrace(long reques |
236 |
|
void __user *datap = compat_ptr(data); |
237 |
|
int ret; |
238 |
|
__u32 val; |
239 |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
240 |
|
+ return -EPERM; |
241 |
|
|
242 |
--- linux-2.6.21.orig/fs/Makefile |
switch (request) { |
243 |
+++ linux-2.6.21/fs/Makefile |
case PTRACE_TRACEME: |
244 |
@@ -114,3 +114,5 @@ obj-$(CONFIG_HPPFS) += hppfs/ |
--- linux-2.6.21.7.orig/fs/attr.c |
245 |
obj-$(CONFIG_DEBUG_FS) += debugfs/ |
+++ linux-2.6.21.7/fs/attr.c |
246 |
obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
@@ -15,6 +15,7 @@ |
|
obj-$(CONFIG_GFS2_FS) += gfs2/ |
|
|
+ |
|
|
+include $(srctree)/fs/Makefile-2.6.ccs |
|
|
--- linux-2.6.21.orig/fs/attr.c |
|
|
+++ linux-2.6.21/fs/attr.c |
|
|
@@ -15,6 +15,9 @@ |
|
247 |
#include <linux/fcntl.h> |
#include <linux/fcntl.h> |
248 |
#include <linux/quotaops.h> |
#include <linux/quotaops.h> |
249 |
#include <linux/security.h> |
#include <linux/security.h> |
250 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
251 |
|
|
252 |
/* Taken over from the old code... */ |
/* Taken over from the old code... */ |
253 |
|
|
254 |
@@ -145,12 +148,20 @@ int notify_change(struct dentry * dentry |
@@ -146,11 +147,15 @@ int notify_change(struct dentry * dentry |
|
|
|
255 |
if (inode->i_op && inode->i_op->setattr) { |
if (inode->i_op && inode->i_op->setattr) { |
256 |
error = security_inode_setattr(dentry, attr); |
error = security_inode_setattr(dentry, attr); |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD); |
|
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN); |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
257 |
if (!error) |
if (!error) |
258 |
|
+ error = ccs_setattr_permission(dentry, attr); |
259 |
|
+ if (!error) |
260 |
error = inode->i_op->setattr(dentry, attr); |
error = inode->i_op->setattr(dentry, attr); |
261 |
} else { |
} else { |
262 |
error = inode_change_ok(inode, attr); |
error = inode_change_ok(inode, attr); |
263 |
if (!error) |
if (!error) |
264 |
error = security_inode_setattr(dentry, attr); |
error = security_inode_setattr(dentry, attr); |
265 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!error) |
266 |
+ if (!error && (ia_valid & ATTR_MODE)) error = CheckCapabilityACL(TOMOYO_SYS_CHMOD); |
+ error = ccs_setattr_permission(dentry, attr); |
|
+ if (!error && (ia_valid & (ATTR_UID | ATTR_GID))) error = CheckCapabilityACL(TOMOYO_SYS_CHOWN); |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
267 |
if (!error) { |
if (!error) { |
268 |
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
269 |
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
270 |
--- linux-2.6.21.orig/fs/compat.c |
--- linux-2.6.21.7.orig/fs/compat.c |
271 |
+++ linux-2.6.21/fs/compat.c |
+++ linux-2.6.21.7/fs/compat.c |
272 |
@@ -56,6 +56,9 @@ |
@@ -56,6 +56,7 @@ |
273 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
274 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
275 |
#include "internal.h" |
#include "internal.h" |
276 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
277 |
|
|
278 |
int compat_log = 1; |
int compat_log = 1; |
279 |
|
|
280 |
@@ -422,6 +425,9 @@ asmlinkage long compat_sys_ioctl(unsigne |
@@ -398,6 +399,8 @@ asmlinkage long compat_sys_ioctl(unsigne |
281 |
|
|
282 |
|
/* RED-PEN how should LSM module know it's handling 32bit? */ |
283 |
|
error = security_file_ioctl(filp, cmd, arg); |
284 |
|
+ if (!error) |
285 |
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
286 |
|
if (error) |
287 |
|
goto out_fput; |
288 |
|
|
289 |
|
@@ -422,6 +425,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
290 |
/*FALL THROUGH*/ |
/*FALL THROUGH*/ |
291 |
|
|
292 |
default: |
default: |
293 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
294 |
+ if ((error = CheckCapabilityACL(TOMOYO_SYS_IOCTL)) < 0) goto out_fput; |
+ error = -EPERM; |
295 |
+ /***** TOMOYO Linux end. *****/ |
+ goto out_fput; |
296 |
|
+ } |
297 |
if (filp->f_op && filp->f_op->compat_ioctl) { |
if (filp->f_op && filp->f_op->compat_ioctl) { |
298 |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
299 |
if (error != -ENOIOCTLCMD) |
if (error != -ENOIOCTLCMD) |
300 |
@@ -1552,7 +1558,7 @@ int compat_do_execve(char * filename, |
@@ -1552,7 +1559,7 @@ int compat_do_execve(char * filename, |
301 |
if (retval < 0) |
if (retval < 0) |
302 |
goto out; |
goto out; |
303 |
|
|
304 |
- retval = search_binary_handler(bprm, regs); |
- retval = search_binary_handler(bprm, regs); |
305 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
306 |
if (retval >= 0) { |
if (retval >= 0) { |
307 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
308 |
|
|
309 |
--- linux-2.6.21.orig/fs/exec.c |
--- linux-2.6.21.7.orig/fs/exec.c |
310 |
+++ linux-2.6.21/fs/exec.c |
+++ linux-2.6.21.7/fs/exec.c |
311 |
@@ -58,6 +58,10 @@ |
@@ -58,6 +58,8 @@ |
312 |
#include <linux/kmod.h> |
#include <linux/kmod.h> |
313 |
#endif |
#endif |
314 |
|
|
315 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
316 |
+ |
+ |
317 |
int core_uses_pid; |
int core_uses_pid; |
318 |
char core_pattern[128] = "core"; |
char core_pattern[128] = "core"; |
319 |
int suid_dumpable = 0; |
int suid_dumpable = 0; |
320 |
@@ -140,6 +144,11 @@ asmlinkage long sys_uselib(const char __ |
@@ -140,6 +142,10 @@ asmlinkage long sys_uselib(const char __ |
321 |
if (error) |
if (error) |
322 |
goto exit; |
goto exit; |
323 |
|
|
324 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_uselib_permission(nd.dentry, nd.mnt); |
325 |
+ error = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */ |
+ if (error) |
326 |
+ if (error) goto exit; |
+ goto exit; |
|
+ /***** TOMOYO Linux end. *****/ |
|
327 |
+ |
+ |
328 |
file = nameidata_to_filp(&nd, O_RDONLY); |
file = nameidata_to_filp(&nd, O_RDONLY); |
329 |
error = PTR_ERR(file); |
error = PTR_ERR(file); |
330 |
if (IS_ERR(file)) |
if (IS_ERR(file)) |
331 |
@@ -485,6 +494,9 @@ struct file *open_exec(const char *name) |
@@ -485,6 +491,9 @@ struct file *open_exec(const char *name) |
332 |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
333 |
S_ISREG(inode->i_mode)) { |
S_ISREG(inode->i_mode)) { |
334 |
int err = vfs_permission(&nd, MAY_EXEC); |
int err = vfs_permission(&nd, MAY_EXEC); |
335 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!err) |
336 |
+ if (!err && (current->tomoyo_flags & TOMOYO_CHECK_READ_FOR_OPEN_EXEC)) err = CheckOpenPermission(nd.dentry, nd.mnt, 01); /* 01 means "read". */ |
+ err = ccs_open_exec_permission(nd.dentry, |
337 |
+ /***** TOMOYO Linux end. *****/ |
+ nd.mnt); |
338 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
339 |
if (!err) { |
if (!err) { |
340 |
file = nameidata_to_filp(&nd, O_RDONLY); |
file = nameidata_to_filp(&nd, O_RDONLY); |
341 |
@@ -1183,7 +1195,7 @@ int do_execve(char * filename, |
@@ -1183,7 +1192,7 @@ int do_execve(char * filename, |
342 |
if (retval < 0) |
if (retval < 0) |
343 |
goto out; |
goto out; |
344 |
|
|
345 |
- retval = search_binary_handler(bprm,regs); |
- retval = search_binary_handler(bprm,regs); |
346 |
+ retval = search_binary_handler_with_transition(bprm,regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
347 |
if (retval >= 0) { |
if (retval >= 0) { |
348 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
349 |
|
|
350 |
--- linux-2.6.21.orig/fs/fcntl.c |
--- linux-2.6.21.7.orig/fs/fcntl.c |
351 |
+++ linux-2.6.21/fs/fcntl.c |
+++ linux-2.6.21.7/fs/fcntl.c |
352 |
@@ -22,6 +22,9 @@ |
@@ -22,6 +22,7 @@ |
353 |
#include <asm/poll.h> |
#include <asm/poll.h> |
354 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
355 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
356 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
357 |
|
|
358 |
void fastcall set_close_on_exec(unsigned int fd, int flag) |
void fastcall set_close_on_exec(unsigned int fd, int flag) |
359 |
{ |
{ |
360 |
@@ -213,6 +216,10 @@ static int setfl(int fd, struct file * f |
@@ -213,6 +214,9 @@ static int setfl(int fd, struct file * f |
361 |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
362 |
return -EPERM; |
return -EPERM; |
363 |
|
|
364 |
+ /***** TOMOYO Linux start. *****/ |
+ if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp)) |
365 |
+ if (((arg ^ filp->f_flags) & O_APPEND) && CheckReWritePermission(filp)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
366 |
+ |
+ |
367 |
/* O_NOATIME can only be set by the owner or superuser */ |
/* O_NOATIME can only be set by the owner or superuser */ |
368 |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
369 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
370 |
--- linux-2.6.21.orig/fs/ioctl.c |
--- linux-2.6.21.7.orig/fs/ioctl.c |
371 |
+++ linux-2.6.21/fs/ioctl.c |
+++ linux-2.6.21.7/fs/ioctl.c |
372 |
@@ -15,6 +15,9 @@ |
@@ -15,6 +15,7 @@ |
373 |
|
|
374 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
375 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
376 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
377 |
|
|
378 |
static long do_ioctl(struct file *filp, unsigned int cmd, |
static long do_ioctl(struct file *filp, unsigned int cmd, |
379 |
unsigned long arg) |
unsigned long arg) |
380 |
@@ -23,6 +26,9 @@ static long do_ioctl(struct file *filp, |
@@ -23,6 +24,8 @@ static long do_ioctl(struct file *filp, |
381 |
|
|
382 |
if (!filp->f_op) |
if (!filp->f_op) |
383 |
goto out; |
goto out; |
384 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
385 |
+ if (CheckCapabilityACL(TOMOYO_SYS_IOCTL) < 0) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
386 |
|
|
387 |
if (filp->f_op->unlocked_ioctl) { |
if (filp->f_op->unlocked_ioctl) { |
388 |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
389 |
--- linux-2.6.21.orig/fs/namei.c |
@@ -167,6 +170,8 @@ asmlinkage long sys_ioctl(unsigned int f |
390 |
+++ linux-2.6.21/fs/namei.c |
goto out; |
391 |
@@ -37,6 +37,10 @@ |
|
392 |
|
error = security_file_ioctl(filp, cmd, arg); |
393 |
|
+ if (!error) |
394 |
|
+ error = ccs_ioctl_permission(filp, cmd, arg); |
395 |
|
if (error) |
396 |
|
goto out_fput; |
397 |
|
|
398 |
|
--- linux-2.6.21.7.orig/fs/namei.c |
399 |
|
+++ linux-2.6.21.7/fs/namei.c |
400 |
|
@@ -37,6 +37,8 @@ |
401 |
|
|
402 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
403 |
|
|
404 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
405 |
+ |
+ |
406 |
/* [Feb-1997 T. Schoebel-Theuer] |
/* [Feb-1997 T. Schoebel-Theuer] |
407 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
* Fundamental changes in the pathname lookup mechanisms (namei) |
408 |
* were necessary because of omirr. The reason is that omirr needs |
* were necessary because of omirr. The reason is that omirr needs |
409 |
@@ -1506,6 +1510,9 @@ int vfs_create(struct inode *dir, struct |
@@ -1561,6 +1563,11 @@ int may_open(struct nameidata *nd, int a |
|
error = security_inode_create(dir, dentry, mode); |
|
|
if (error) |
|
|
return error; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (nd && (error = CheckSingleWritePermission(TYPE_CREATE_ACL, dentry, nd->mnt)) < 0) return error; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
DQUOT_INIT(dir); |
|
|
error = dir->i_op->create(dir, dentry, mode, nd); |
|
|
if (!error) |
|
|
@@ -1561,6 +1568,11 @@ int may_open(struct nameidata *nd, int a |
|
410 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
411 |
return -EPERM; |
return -EPERM; |
412 |
|
|
413 |
+ /***** TOMOYO Linux start. *****/ |
+ /* includes O_APPEND and O_TRUNC checks */ |
414 |
+ error = CheckOpenPermission(dentry, nd->mnt, flag); /* includes O_APPEND and O_TRUNC checks */ |
+ error = ccs_open_permission(dentry, nd->mnt, flag); |
415 |
+ if (error) return error; |
+ if (error) |
416 |
+ /***** TOMOYO Linux end. *****/ |
+ return error; |
417 |
+ |
+ |
418 |
/* |
/* |
419 |
* Ensure there are no outstanding leases on the file. |
* Ensure there are no outstanding leases on the file. |
420 |
*/ |
*/ |
421 |
@@ -1610,6 +1622,9 @@ static int open_namei_create(struct name |
@@ -1600,6 +1607,9 @@ static int open_namei_create(struct name |
422 |
|
|
423 |
|
if (!IS_POSIXACL(dir->d_inode)) |
424 |
|
mode &= ~current->fs->umask; |
425 |
|
+ error = ccs_mknod_permission(dir->d_inode, path->dentry, nd->mnt, mode, |
426 |
|
+ 0); |
427 |
|
+ if (!error) |
428 |
|
error = vfs_create(dir->d_inode, path->dentry, mode, nd); |
429 |
|
mutex_unlock(&dir->d_inode->i_mutex); |
430 |
|
dput(nd->dentry); |
431 |
|
@@ -1610,6 +1620,7 @@ static int open_namei_create(struct name |
432 |
return may_open(nd, 0, flag & ~O_TRUNC); |
return may_open(nd, 0, flag & ~O_TRUNC); |
433 |
} |
} |
434 |
|
|
435 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity_vfs.h> |
|
+#include <linux/tomoyo_vfs.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
436 |
/* |
/* |
437 |
* open_namei() |
* open_namei() |
438 |
* |
* |
439 |
@@ -1870,6 +1885,12 @@ asmlinkage long sys_mknodat(int dfd, con |
@@ -1883,6 +1894,9 @@ asmlinkage long sys_mknodat(int dfd, con |
440 |
|
if (!IS_POSIXACL(nd.dentry->d_inode)) |
441 |
if (S_ISDIR(mode)) |
mode &= ~current->fs->umask; |
442 |
return -EPERM; |
if (!IS_ERR(dentry)) { |
443 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_mknod_permission(nd.dentry->d_inode, dentry, |
444 |
+ if (S_ISCHR(mode) && CheckCapabilityACL(TOMOYO_CREATE_CHAR_DEV)) return -EPERM; |
+ nd.mnt, mode, dev); |
445 |
+ if (S_ISBLK(mode) && CheckCapabilityACL(TOMOYO_CREATE_BLOCK_DEV)) return -EPERM; |
+ if (!error) |
446 |
+ if (S_ISFIFO(mode) && CheckCapabilityACL(TOMOYO_CREATE_FIFO)) return -EPERM; |
switch (mode & S_IFMT) { |
447 |
+ if (S_ISSOCK(mode) && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) return -EPERM; |
case 0: case S_IFREG: |
|
+ /***** TOMOYO Linux end. *****/ |
|
|
tmp = getname(filename); |
|
|
if (IS_ERR(tmp)) |
|
|
return PTR_ERR(tmp); |
|
|
@@ -1888,10 +1909,16 @@ asmlinkage long sys_mknodat(int dfd, con |
|
448 |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
449 |
break; |
@@ -1959,6 +1973,8 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
case S_IFCHR: case S_IFBLK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISCHR(mode) ? TYPE_MKCHAR_ACL : TYPE_MKBLOCK_ACL, dentry, nd.mnt)) == 0) |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode, |
|
|
new_decode_dev(dev)); |
|
|
break; |
|
|
case S_IFIFO: case S_IFSOCK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if ((error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (error = CheckSingleWritePermission(S_ISFIFO(mode) ? TYPE_MKFIFO_ACL : TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0) |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0); |
|
|
break; |
|
|
case S_IFDIR: |
|
|
@@ -1959,6 +1986,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
450 |
|
|
451 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
452 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
453 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_mkdir_permission(nd.dentry->d_inode, dentry, nd.mnt, mode); |
454 |
+ if ((error = pre_vfs_mkdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_MKDIR_ACL, dentry, nd.mnt)) == 0) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
455 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
456 |
dput(dentry); |
dput(dentry); |
457 |
out_unlock: |
out_unlock: |
458 |
@@ -2066,6 +2096,9 @@ static long do_rmdir(int dfd, const char |
@@ -2066,6 +2082,8 @@ static long do_rmdir(int dfd, const char |
459 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
460 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
461 |
goto exit2; |
goto exit2; |
462 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, nd.mnt); |
463 |
+ if ((error = pre_vfs_rmdir(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_RMDIR_ACL, dentry, nd.mnt)) == 0) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
464 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
465 |
dput(dentry); |
dput(dentry); |
466 |
exit2: |
exit2: |
467 |
@@ -2125,6 +2158,9 @@ static long do_unlinkat(int dfd, const c |
@@ -2146,6 +2164,9 @@ static long do_unlinkat(int dfd, const c |
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
struct inode *inode = NULL; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (CheckCapabilityACL(TOMOYO_SYS_UNLINK)) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
name = getname(pathname); |
|
|
if(IS_ERR(name)) |
|
|
@@ -2146,6 +2182,9 @@ static long do_unlinkat(int dfd, const c |
|
468 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
469 |
if (inode) |
if (inode) |
470 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
471 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_unlink_permission(nd.dentry->d_inode, dentry, |
472 |
+ if ((error = pre_vfs_unlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_UNLINK_ACL, dentry, nd.mnt)) == 0) |
+ nd.mnt); |
473 |
+ /***** TOMOYO Linux end. *****/ |
+ if (!error) |
474 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
475 |
exit2: |
exit2: |
476 |
dput(dentry); |
dput(dentry); |
477 |
@@ -2210,6 +2249,9 @@ asmlinkage long sys_symlinkat(const char |
@@ -2227,6 +2248,9 @@ asmlinkage long sys_symlinkat(const char |
|
char * to; |
|
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (CheckCapabilityACL(TOMOYO_SYS_SYMLINK)) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
|
@@ -2227,6 +2269,9 @@ asmlinkage long sys_symlinkat(const char |
|
478 |
if (IS_ERR(dentry)) |
if (IS_ERR(dentry)) |
479 |
goto out_unlock; |
goto out_unlock; |
480 |
|
|
481 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_symlink_permission(nd.dentry->d_inode, dentry, nd.mnt, |
482 |
+ if ((error = pre_vfs_symlink(nd.dentry->d_inode, dentry)) == 0 && (error = CheckSingleWritePermission(TYPE_SYMLINK_ACL, dentry, nd.mnt)) == 0) |
+ from); |
483 |
+ /***** TOMOYO Linux end. *****/ |
+ if (!error) |
484 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
485 |
dput(dentry); |
dput(dentry); |
486 |
out_unlock: |
out_unlock: |
487 |
@@ -2299,6 +2344,9 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2322,6 +2346,9 @@ asmlinkage long sys_linkat(int olddfd, c |
|
struct nameidata nd, old_nd; |
|
|
int error; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (CheckCapabilityACL(TOMOYO_SYS_LINK)) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
if ((flags & ~AT_SYMLINK_FOLLOW) != 0) |
|
|
return -EINVAL; |
|
|
@@ -2322,6 +2370,9 @@ asmlinkage long sys_linkat(int olddfd, c |
|
488 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
489 |
if (IS_ERR(new_dentry)) |
if (IS_ERR(new_dentry)) |
490 |
goto out_unlock; |
goto out_unlock; |
491 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode, |
492 |
+ if ((error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry)) == 0 && (error = CheckDoubleWritePermission(TYPE_LINK_ACL, old_nd.dentry, old_nd.mnt, new_dentry, nd.mnt)) == 0) |
+ new_dentry, nd.mnt); |
493 |
+ /***** TOMOYO Linux end. *****/ |
+ if (!error) |
494 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
495 |
dput(new_dentry); |
dput(new_dentry); |
496 |
out_unlock: |
out_unlock: |
497 |
@@ -2547,6 +2598,12 @@ static int do_rename(int olddfd, const c |
@@ -2547,7 +2574,9 @@ static int do_rename(int olddfd, const c |
498 |
error = -ENOTEMPTY; |
error = -ENOTEMPTY; |
499 |
if (new_dentry == trap) |
if (new_dentry == trap) |
500 |
goto exit5; |
goto exit5; |
501 |
+ /***** TOMOYO Linux start. *****/ |
- |
502 |
+ if ((error = pre_vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry)) < 0 || |
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
503 |
+ (error = CheckDoubleWritePermission(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, new_dentry, newnd.mnt)) < 0) { |
+ new_dir->d_inode, new_dentry, newnd.mnt); |
504 |
+ goto exit5; |
+ if (!error) |
|
+ } |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
505 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
error = vfs_rename(old_dir->d_inode, old_dentry, |
506 |
new_dir->d_inode, new_dentry); |
new_dir->d_inode, new_dentry); |
507 |
@@ -2570,6 +2627,9 @@ asmlinkage long sys_renameat(int olddfd, |
exit5: |
508 |
int error; |
--- linux-2.6.21.7.orig/fs/namespace.c |
509 |
char * from; |
+++ linux-2.6.21.7/fs/namespace.c |
510 |
char * to; |
@@ -28,6 +28,7 @@ |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (CheckCapabilityACL(TOMOYO_SYS_RENAME)) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
|
--- linux-2.6.21.orig/fs/namespace.c |
|
|
+++ linux-2.6.21/fs/namespace.c |
|
|
@@ -28,6 +28,12 @@ |
|
511 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
512 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
513 |
#include "pnode.h" |
#include "pnode.h" |
514 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
515 |
|
|
516 |
/* spinlock for vfsmount related operations, inplace of dcache_lock */ |
/* spinlock for vfsmount related operations, inplace of dcache_lock */ |
517 |
__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); |
__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); |
518 |
@@ -545,6 +551,10 @@ static int do_umount(struct vfsmount *mn |
@@ -542,6 +543,8 @@ static int do_umount(struct vfsmount *mn |
519 |
|
LIST_HEAD(umount_list); |
520 |
|
|
521 |
|
retval = security_sb_umount(mnt, flags); |
522 |
|
+ if (!retval) |
523 |
|
+ retval = ccs_umount_permission(mnt, flags); |
524 |
if (retval) |
if (retval) |
525 |
return retval; |
return retval; |
526 |
|
|
527 |
+ /***** SAKURA Linux start. *****/ |
@@ -633,6 +636,8 @@ asmlinkage long sys_umount(char __user * |
|
+ if (SAKURA_MayUmount(mnt) < 0) return -EPERM; |
|
|
+ /***** SAKURA Linux end. *****/ |
|
|
+ |
|
|
/* |
|
|
* Allow userspace to request a mountpoint be expired rather than |
|
|
* unmounting unconditionally. Unmount only happens if: |
|
|
@@ -633,6 +643,9 @@ asmlinkage long sys_umount(char __user * |
|
528 |
{ |
{ |
529 |
struct nameidata nd; |
struct nameidata nd; |
530 |
int retval; |
int retval; |
531 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
532 |
+ if (CheckCapabilityACL(TOMOYO_SYS_UMOUNT)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
533 |
|
|
534 |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
535 |
if (retval) |
if (retval) |
536 |
@@ -917,6 +930,10 @@ static int do_loopback(struct nameidata |
@@ -917,6 +922,9 @@ static int do_loopback(struct nameidata |
537 |
|
|
538 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
539 |
goto out; |
goto out; |
|
+ /***** SAKURA Linux start. *****/ |
|
540 |
+ err = -EPERM; |
+ err = -EPERM; |
541 |
+ if (SAKURA_MayMount(nd) < 0) goto out; |
+ if (ccs_may_mount(nd)) |
542 |
+ /***** SAKURA Linux end. *****/ |
+ goto out; |
543 |
|
|
544 |
err = -ENOMEM; |
err = -ENOMEM; |
545 |
if (recurse) |
if (recurse) |
546 |
@@ -1002,6 +1019,10 @@ static int do_move_mount(struct nameidat |
@@ -1002,6 +1010,9 @@ static int do_move_mount(struct nameidat |
547 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
548 |
goto out; |
goto out; |
549 |
|
|
|
+ /***** SAKURA Linux start. *****/ |
|
550 |
+ err = -EPERM; |
+ err = -EPERM; |
551 |
+ if (SAKURA_MayUmount(old_nd.mnt) < 0 || SAKURA_MayMount(nd) < 0) goto out; |
+ if (ccs_may_mount(nd)) |
552 |
+ /***** SAKURA Linux end. *****/ |
+ goto out; |
553 |
err = -ENOENT; |
err = -ENOENT; |
554 |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
555 |
if (IS_DEADDIR(nd->dentry->d_inode)) |
if (IS_DEADDIR(nd->dentry->d_inode)) |
556 |
@@ -1103,6 +1124,10 @@ int do_add_mount(struct vfsmount *newmnt |
@@ -1103,6 +1114,9 @@ int do_add_mount(struct vfsmount *newmnt |
557 |
err = -EINVAL; |
err = -EINVAL; |
558 |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
559 |
goto unlock; |
goto unlock; |
|
+ /***** SAKURA Linux start. *****/ |
|
560 |
+ err = -EPERM; |
+ err = -EPERM; |
561 |
+ if (SAKURA_MayMount(nd) < 0) goto unlock; |
+ if (ccs_may_mount(nd)) |
562 |
+ /***** SAKURA Linux end. *****/ |
+ goto unlock; |
563 |
|
|
564 |
newmnt->mnt_flags = mnt_flags; |
newmnt->mnt_flags = mnt_flags; |
565 |
if ((err = graft_tree(newmnt, nd))) |
if ((err = graft_tree(newmnt, nd))) |
566 |
@@ -1394,6 +1419,13 @@ long do_mount(char *dev_name, char *dir_ |
@@ -1376,6 +1390,7 @@ int copy_mount_options(const void __user |
567 |
if (data_page) |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
568 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
unsigned long flags, void *data_page) |
569 |
|
{ |
570 |
+ /***** TOMOYO Linux start. *****/ |
+ const unsigned long original_flags = flags; |
571 |
+ if (CheckCapabilityACL(TOMOYO_SYS_MOUNT)) return -EPERM; |
struct nameidata nd; |
572 |
+ /***** TOMOYO Linux end. *****/ |
int retval = 0; |
573 |
+ /***** SAKURA Linux start. *****/ |
int mnt_flags = 0; |
574 |
+ if ((retval = CheckMountPermission(dev_name, dir_name, type_page, &flags)) < 0) return retval; |
@@ -1417,6 +1432,9 @@ long do_mount(char *dev_name, char *dir_ |
575 |
+ /***** SAKURA Linux end. *****/ |
return retval; |
576 |
+ |
|
577 |
/* Separate the per-mountpoint flags */ |
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
578 |
if (flags & MS_NOSUID) |
+ if (!retval) |
579 |
mnt_flags |= MNT_NOSUID; |
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
580 |
@@ -1686,6 +1718,9 @@ asmlinkage long sys_pivot_root(const cha |
+ original_flags, data_page); |
581 |
|
if (retval) |
582 |
|
goto dput_out; |
583 |
|
|
584 |
|
@@ -1686,6 +1704,8 @@ asmlinkage long sys_pivot_root(const cha |
585 |
|
|
586 |
if (!capable(CAP_SYS_ADMIN)) |
if (!capable(CAP_SYS_ADMIN)) |
587 |
return -EPERM; |
return -EPERM; |
588 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
589 |
+ if (CheckCapabilityACL(TOMOYO_SYS_PIVOT_ROOT)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
590 |
|
|
591 |
lock_kernel(); |
lock_kernel(); |
592 |
|
|
593 |
@@ -1702,6 +1737,9 @@ asmlinkage long sys_pivot_root(const cha |
@@ -1702,6 +1722,8 @@ asmlinkage long sys_pivot_root(const cha |
594 |
goto out1; |
goto out1; |
595 |
|
|
596 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
error = security_sb_pivotroot(&old_nd, &new_nd); |
597 |
+ /***** SAKURA Linux start. *****/ |
+ if (!error) |
598 |
+ if (!error) error = CheckPivotRootPermission(&old_nd, &new_nd); |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
|
+ /***** SAKURA Linux end. *****/ |
|
599 |
if (error) { |
if (error) { |
600 |
path_release(&old_nd); |
path_release(&old_nd); |
601 |
goto out1; |
goto out1; |
602 |
--- linux-2.6.21.orig/fs/open.c |
--- linux-2.6.21.7.orig/fs/open.c |
603 |
+++ linux-2.6.21/fs/open.c |
+++ linux-2.6.21.7/fs/open.c |
604 |
@@ -27,6 +27,12 @@ |
@@ -27,6 +27,7 @@ |
605 |
#include <linux/syscalls.h> |
#include <linux/syscalls.h> |
606 |
#include <linux/rcupdate.h> |
#include <linux/rcupdate.h> |
607 |
#include <linux/audit.h> |
#include <linux/audit.h> |
608 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
609 |
|
|
610 |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
611 |
{ |
{ |
612 |
@@ -264,6 +270,9 @@ static long do_sys_truncate(const char _ |
@@ -264,6 +265,8 @@ static long do_sys_truncate(const char _ |
613 |
if (error) |
if (error) |
614 |
goto dput_and_out; |
goto dput_and_out; |
615 |
|
|
616 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0); |
617 |
+ if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt)) == 0) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
618 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
619 |
if (!error) { |
if (!error) { |
620 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
621 |
@@ -317,6 +326,9 @@ static long do_sys_ftruncate(unsigned in |
@@ -317,6 +320,9 @@ static long do_sys_ftruncate(unsigned in |
622 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
623 |
goto out_putf; |
goto out_putf; |
624 |
|
|
625 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0); |
626 |
+ if ((error = CheckSingleWritePermission(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt)) == 0) |
+ if (error) |
627 |
+ /***** TOMOYO Linux end. *****/ |
+ goto out_putf; |
628 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
629 |
if (!error) |
if (!error) |
630 |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
631 |
@@ -481,6 +493,12 @@ asmlinkage long sys_chroot(const char __ |
@@ -481,6 +487,10 @@ asmlinkage long sys_chroot(const char __ |
632 |
error = -EPERM; |
error = -EPERM; |
633 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
634 |
goto dput_and_out; |
goto dput_and_out; |
635 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
636 |
+ if (CheckCapabilityACL(TOMOYO_SYS_CHROOT)) goto dput_and_out; |
+ goto dput_and_out; |
637 |
+ /***** TOMOYO Linux end. *****/ |
+ if (ccs_chroot_permission(&nd)) |
638 |
+ /***** SAKURA Linux start. *****/ |
+ goto dput_and_out; |
|
+ if (CheckChRootPermission(&nd)) goto dput_and_out; |
|
|
+ /***** SAKURA Linux end. *****/ |
|
639 |
|
|
640 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
641 |
set_fs_altroot(); |
set_fs_altroot(); |
642 |
@@ -1085,6 +1103,9 @@ EXPORT_SYMBOL(sys_close); |
@@ -514,6 +524,9 @@ asmlinkage long sys_fchmod(unsigned int |
643 |
|
err = -EPERM; |
644 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
645 |
|
goto out_putf; |
646 |
|
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
647 |
|
+ if (err) |
648 |
|
+ goto out_putf; |
649 |
|
mutex_lock(&inode->i_mutex); |
650 |
|
if (mode == (mode_t) -1) |
651 |
|
mode = inode->i_mode; |
652 |
|
@@ -548,6 +561,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
653 |
|
error = -EPERM; |
654 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
655 |
|
goto dput_and_out; |
656 |
|
+ error = ccs_chmod_permission(nd.dentry, nd.mnt, mode); |
657 |
|
+ if (error) |
658 |
|
+ goto dput_and_out; |
659 |
|
|
660 |
|
mutex_lock(&inode->i_mutex); |
661 |
|
if (mode == (mode_t) -1) |
662 |
|
@@ -611,6 +627,8 @@ asmlinkage long sys_chown(const char __u |
663 |
|
error = user_path_walk(filename, &nd); |
664 |
|
if (error) |
665 |
|
goto out; |
666 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
667 |
|
+ if (!error) |
668 |
|
error = chown_common(nd.dentry, user, group); |
669 |
|
path_release(&nd); |
670 |
|
out: |
671 |
|
@@ -631,6 +649,8 @@ asmlinkage long sys_fchownat(int dfd, co |
672 |
|
error = __user_walk_fd(dfd, filename, follow, &nd); |
673 |
|
if (error) |
674 |
|
goto out; |
675 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
676 |
|
+ if (!error) |
677 |
|
error = chown_common(nd.dentry, user, group); |
678 |
|
path_release(&nd); |
679 |
|
out: |
680 |
|
@@ -645,6 +665,8 @@ asmlinkage long sys_lchown(const char __ |
681 |
|
error = user_path_walk_link(filename, &nd); |
682 |
|
if (error) |
683 |
|
goto out; |
684 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
685 |
|
+ if (!error) |
686 |
|
error = chown_common(nd.dentry, user, group); |
687 |
|
path_release(&nd); |
688 |
|
out: |
689 |
|
@@ -664,6 +686,8 @@ asmlinkage long sys_fchown(unsigned int |
690 |
|
|
691 |
|
dentry = file->f_path.dentry; |
692 |
|
audit_inode(NULL, dentry->d_inode); |
693 |
|
+ error = ccs_chown_permission(dentry, file->f_vfsmnt, user, group); |
694 |
|
+ if (!error) |
695 |
|
error = chown_common(dentry, user, group); |
696 |
|
fput(file); |
697 |
|
out: |
698 |
|
@@ -756,7 +780,9 @@ static struct file *do_filp_open(int dfd |
699 |
|
if ((namei_flags+1) & O_ACCMODE) |
700 |
|
namei_flags++; |
701 |
|
|
702 |
|
+ ccs_save_open_mode(flags); |
703 |
|
error = open_namei(dfd, filename, namei_flags, mode, &nd); |
704 |
|
+ ccs_clear_open_mode(); |
705 |
|
if (!error) |
706 |
|
return nameidata_to_filp(&nd, flags); |
707 |
|
|
708 |
|
@@ -1085,6 +1111,8 @@ EXPORT_SYMBOL(sys_close); |
709 |
*/ |
*/ |
710 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
711 |
{ |
{ |
712 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
713 |
+ if (CheckCapabilityACL(TOMOYO_SYS_VHANGUP) == 0) |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
714 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
715 |
/* XXX: this needs locking */ |
/* XXX: this needs locking */ |
716 |
tty_vhangup(current->signal->tty); |
tty_vhangup(current->signal->tty); |
717 |
--- linux-2.6.21.orig/fs/proc/Makefile |
--- linux-2.6.21.7.orig/fs/proc/proc_misc.c |
718 |
+++ linux-2.6.21/fs/proc/Makefile |
+++ linux-2.6.21.7/fs/proc/proc_misc.c |
719 |
@@ -15,3 +15,6 @@ proc-$(CONFIG_PROC_KCORE) += kcore.o |
@@ -747,4 +747,5 @@ void __init proc_misc_init(void) |
|
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
|
|
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
|
|
proc-$(CONFIG_PRINTK) += kmsg.o |
|
|
+ |
|
|
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
|
|
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
|
|
--- linux-2.6.21.orig/fs/proc/proc_misc.c |
|
|
+++ linux-2.6.21/fs/proc/proc_misc.c |
|
|
@@ -747,4 +747,13 @@ void __init proc_misc_init(void) |
|
720 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
entry->proc_fops = &proc_sysrq_trigger_operations; |
721 |
} |
} |
722 |
#endif |
#endif |
723 |
+ /***** CCS start. *****/ |
+ printk(KERN_INFO "Hook version: 2.6.21.7 2009/09/10\n"); |
|
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
|
|
+ { |
|
|
+ extern void __init CCSProc_Init(void); |
|
|
+ CCSProc_Init(); |
|
|
+ printk("Hook version: 2.6.21 2008/01/05\n"); |
|
|
+ } |
|
|
+#endif |
|
|
+ /***** CCS end. *****/ |
|
724 |
} |
} |
725 |
--- linux-2.6.21.orig/include/linux/init_task.h |
--- linux-2.6.21.7.orig/include/linux/init_task.h |
726 |
+++ linux-2.6.21/include/linux/init_task.h |
+++ linux-2.6.21.7/include/linux/init_task.h |
727 |
@@ -141,6 +141,10 @@ extern struct group_info init_groups; |
@@ -88,6 +88,14 @@ extern struct nsproxy init_nsproxy; |
728 |
|
|
729 |
|
extern struct group_info init_groups; |
730 |
|
|
731 |
|
+#ifdef CONFIG_CCSECURITY |
732 |
|
+#define INIT_CCSECURITY \ |
733 |
|
+ .ccs_domain_info = NULL, \ |
734 |
|
+ .ccs_flags = 0, |
735 |
|
+#else |
736 |
|
+#define INIT_CCSECURITY |
737 |
|
+#endif |
738 |
|
+ |
739 |
|
/* |
740 |
|
* INIT_TASK is used to set up the first task table, touch at |
741 |
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
742 |
|
@@ -141,6 +149,7 @@ extern struct group_info init_groups; |
743 |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
744 |
INIT_TRACE_IRQFLAGS \ |
INIT_TRACE_IRQFLAGS \ |
745 |
INIT_LOCKDEP \ |
INIT_LOCKDEP \ |
746 |
+ /***** TOMOYO Linux start. *****/ \ |
+ INIT_CCSECURITY \ |
|
+ .domain_info = &KERNEL_DOMAIN, \ |
|
|
+ .tomoyo_flags = 0, \ |
|
|
+ /***** TOMOYO Linux end. *****/ \ |
|
747 |
} |
} |
748 |
|
|
749 |
|
|
750 |
--- linux-2.6.21.orig/include/linux/sched.h |
--- linux-2.6.21.7.orig/include/linux/sched.h |
751 |
+++ linux-2.6.21/include/linux/sched.h |
+++ linux-2.6.21.7/include/linux/sched.h |
752 |
@@ -27,6 +27,11 @@ |
@@ -27,6 +27,8 @@ |
753 |
#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ |
#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ |
754 |
#define CLONE_NEWIPC 0x08000000 /* New ipcs */ |
#define CLONE_NEWIPC 0x08000000 /* New ipcs */ |
755 |
|
|
756 |
+/***** TOMOYO Linux start. *****/ |
+struct ccs_domain_info; |
|
+struct domain_info; |
|
|
+extern struct domain_info KERNEL_DOMAIN; |
|
|
+/***** TOMOYO Linux end. *****/ |
|
757 |
+ |
+ |
758 |
/* |
/* |
759 |
* Scheduling policies |
* Scheduling policies |
760 |
*/ |
*/ |
761 |
@@ -1052,6 +1057,10 @@ struct task_struct { |
@@ -1052,6 +1054,10 @@ struct task_struct { |
762 |
#ifdef CONFIG_FAULT_INJECTION |
#ifdef CONFIG_FAULT_INJECTION |
763 |
int make_it_fail; |
int make_it_fail; |
764 |
#endif |
#endif |
765 |
+ /***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
766 |
+ struct domain_info *domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
767 |
+ u32 tomoyo_flags; |
+ u32 ccs_flags; |
768 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
769 |
}; |
}; |
770 |
|
|
771 |
static inline pid_t process_group(struct task_struct *tsk) |
static inline pid_t process_group(struct task_struct *tsk) |
772 |
--- linux-2.6.21.orig/kernel/compat.c |
--- linux-2.6.21.7.orig/kernel/compat.c |
773 |
+++ linux-2.6.21/kernel/compat.c |
+++ linux-2.6.21.7/kernel/compat.c |
774 |
@@ -25,6 +25,9 @@ |
@@ -25,6 +25,7 @@ |
775 |
#include <linux/posix-timers.h> |
#include <linux/posix-timers.h> |
776 |
|
|
777 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
778 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
779 |
|
|
780 |
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) |
781 |
{ |
{ |
782 |
@@ -869,6 +872,9 @@ asmlinkage long compat_sys_stime(compat_ |
@@ -869,6 +870,8 @@ asmlinkage long compat_sys_stime(compat_ |
783 |
err = security_settime(&tv, NULL); |
err = security_settime(&tv, NULL); |
784 |
if (err) |
if (err) |
785 |
return err; |
return err; |
786 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
787 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
788 |
|
|
789 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
790 |
return 0; |
return 0; |
791 |
--- linux-2.6.21.orig/kernel/kexec.c |
--- linux-2.6.21.7.orig/kernel/kexec.c |
792 |
+++ linux-2.6.21/kernel/kexec.c |
+++ linux-2.6.21.7/kernel/kexec.c |
793 |
@@ -28,6 +28,9 @@ |
@@ -28,6 +28,7 @@ |
794 |
#include <asm/io.h> |
#include <asm/io.h> |
795 |
#include <asm/system.h> |
#include <asm/system.h> |
796 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
797 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
798 |
|
|
799 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
/* Per cpu memory for storing cpu states in case of system crash. */ |
800 |
note_buf_t* crash_notes; |
note_buf_t* crash_notes; |
801 |
@@ -924,6 +927,9 @@ asmlinkage long sys_kexec_load(unsigned |
@@ -924,6 +925,8 @@ asmlinkage long sys_kexec_load(unsigned |
802 |
/* We only trust the superuser with rebooting the system. */ |
/* We only trust the superuser with rebooting the system. */ |
803 |
if (!capable(CAP_SYS_BOOT)) |
if (!capable(CAP_SYS_BOOT)) |
804 |
return -EPERM; |
return -EPERM; |
805 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
806 |
+ if (CheckCapabilityACL(TOMOYO_SYS_KEXEC_LOAD)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
807 |
|
|
808 |
/* |
/* |
809 |
* Verify we have a legal set of flags |
* Verify we have a legal set of flags |
810 |
--- linux-2.6.21.orig/kernel/kmod.c |
--- linux-2.6.21.7.orig/kernel/kmod.c |
811 |
+++ linux-2.6.21/kernel/kmod.c |
+++ linux-2.6.21.7/kernel/kmod.c |
812 |
@@ -166,6 +166,11 @@ static int ____call_usermodehelper(void |
@@ -166,6 +166,11 @@ static int ____call_usermodehelper(void |
813 |
/* We can run anywhere, unlike our parent keventd(). */ |
/* We can run anywhere, unlike our parent keventd(). */ |
814 |
set_cpus_allowed(current, CPU_MASK_ALL); |
set_cpus_allowed(current, CPU_MASK_ALL); |
815 |
|
|
816 |
+ /***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
817 |
+ current->domain_info = &KERNEL_DOMAIN; |
+ current->ccs_domain_info = NULL; |
818 |
+ current->tomoyo_flags = 0; |
+ current->ccs_flags = 0; |
819 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
820 |
+ |
+ |
821 |
retval = -EPERM; |
retval = -EPERM; |
822 |
if (current->fs->root) |
if (current->fs->root) |
823 |
retval = kernel_execve(sub_info->path, |
retval = kernel_execve(sub_info->path, |
824 |
--- linux-2.6.21.orig/kernel/module.c |
--- linux-2.6.21.7.orig/kernel/module.c |
825 |
+++ linux-2.6.21/kernel/module.c |
+++ linux-2.6.21.7/kernel/module.c |
826 |
@@ -44,6 +44,9 @@ |
@@ -44,6 +44,7 @@ |
827 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
828 |
#include <asm/cacheflush.h> |
#include <asm/cacheflush.h> |
829 |
#include <linux/license.h> |
#include <linux/license.h> |
830 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
831 |
|
|
832 |
#if 0 |
#if 0 |
833 |
#define DEBUGP printk |
#define DEBUGP printk |
834 |
@@ -662,6 +665,9 @@ sys_delete_module(const char __user *nam |
@@ -662,6 +663,8 @@ sys_delete_module(const char __user *nam |
835 |
|
|
836 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
837 |
return -EPERM; |
return -EPERM; |
838 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
839 |
+ if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
840 |
|
|
841 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
842 |
return -EFAULT; |
return -EFAULT; |
843 |
@@ -1983,6 +1989,9 @@ sys_init_module(void __user *umod, |
@@ -1983,6 +1986,8 @@ sys_init_module(void __user *umod, |
844 |
/* Must have permission */ |
/* Must have permission */ |
845 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
846 |
return -EPERM; |
return -EPERM; |
847 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
848 |
+ if (CheckCapabilityACL(TOMOYO_USE_KERNEL_MODULE)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
849 |
|
|
850 |
/* Only one module load at a time, please */ |
/* Only one module load at a time, please */ |
851 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
if (mutex_lock_interruptible(&module_mutex) != 0) |
852 |
--- linux-2.6.21.orig/kernel/ptrace.c |
--- linux-2.6.21.7.orig/kernel/ptrace.c |
853 |
+++ linux-2.6.21/kernel/ptrace.c |
+++ linux-2.6.21.7/kernel/ptrace.c |
854 |
@@ -21,6 +21,9 @@ |
@@ -21,6 +21,7 @@ |
855 |
|
|
856 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
857 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
858 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
859 |
|
|
860 |
/* |
/* |
861 |
* ptrace a task: make the debugger its new parent and |
* ptrace a task: make the debugger its new parent and |
862 |
@@ -456,6 +459,11 @@ asmlinkage long sys_ptrace(long request, |
@@ -456,6 +457,8 @@ asmlinkage long sys_ptrace(long request, |
863 |
/* |
/* |
864 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
865 |
*/ |
*/ |
866 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
867 |
+#ifdef TOMOYO_SYS_PTRACE |
+ return -EPERM; |
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
868 |
lock_kernel(); |
lock_kernel(); |
869 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
870 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
871 |
--- linux-2.6.21.orig/kernel/sched.c |
--- linux-2.6.21.7.orig/kernel/sched.c |
872 |
+++ linux-2.6.21/kernel/sched.c |
+++ linux-2.6.21.7/kernel/sched.c |
873 |
@@ -55,6 +55,9 @@ |
@@ -55,6 +55,7 @@ |
874 |
#include <asm/tlb.h> |
#include <asm/tlb.h> |
875 |
|
|
876 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
877 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
878 |
|
|
879 |
/* |
/* |
880 |
* Scheduler clock - returns current time in nanosec units. |
* Scheduler clock - returns current time in nanosec units. |
881 |
@@ -3960,6 +3963,9 @@ int can_nice(const struct task_struct *p |
@@ -3964,6 +3965,8 @@ int can_nice(const struct task_struct *p |
882 |
asmlinkage long sys_nice(int increment) |
asmlinkage long sys_nice(int increment) |
883 |
{ |
{ |
884 |
long nice, retval; |
long nice, retval; |
885 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_NICE)) |
886 |
+ if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
887 |
|
|
888 |
/* |
/* |
889 |
* Setpriority might change our priority at the same moment. |
* Setpriority might change our priority at the same moment. |
890 |
--- linux-2.6.21.orig/kernel/signal.c |
--- linux-2.6.21.7.orig/kernel/signal.c |
891 |
+++ linux-2.6.21/kernel/signal.c |
+++ linux-2.6.21.7/kernel/signal.c |
892 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
893 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
894 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
895 |
#include "audit.h" /* audit_signal_info() */ |
#include "audit.h" /* audit_signal_info() */ |
896 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
897 |
|
|
898 |
/* |
/* |
899 |
* SLAB caches for signal bits. |
* SLAB caches for signal bits. |
900 |
@@ -2235,6 +2238,10 @@ asmlinkage long |
@@ -2235,6 +2236,8 @@ asmlinkage long |
901 |
sys_kill(int pid, int sig) |
sys_kill(int pid, int sig) |
902 |
{ |
{ |
903 |
struct siginfo info; |
struct siginfo info; |
904 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_kill_permission(pid, sig)) |
905 |
+ if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM; |
+ return -EPERM; |
|
+ if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
906 |
|
|
907 |
info.si_signo = sig; |
info.si_signo = sig; |
908 |
info.si_errno = 0; |
info.si_errno = 0; |
909 |
@@ -2293,6 +2300,10 @@ asmlinkage long sys_tgkill(int tgid, int |
@@ -2293,6 +2296,8 @@ asmlinkage long sys_tgkill(int tgid, int |
910 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
911 |
if (pid <= 0 || tgid <= 0) |
if (pid <= 0 || tgid <= 0) |
912 |
return -EINVAL; |
return -EINVAL; |
913 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
914 |
+ if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM; |
+ return -EPERM; |
|
+ if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
915 |
|
|
916 |
return do_tkill(tgid, pid, sig); |
return do_tkill(tgid, pid, sig); |
917 |
} |
} |
918 |
@@ -2306,6 +2317,10 @@ sys_tkill(int pid, int sig) |
@@ -2306,6 +2311,8 @@ sys_tkill(int pid, int sig) |
919 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
920 |
if (pid <= 0) |
if (pid <= 0) |
921 |
return -EINVAL; |
return -EINVAL; |
922 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_tkill_permission(pid, sig)) |
923 |
+ if (sig && CheckCapabilityACL(TOMOYO_SYS_KILL) < 0) return -EPERM; |
+ return -EPERM; |
|
+ if (sig && CheckSignalACL(sig, pid) < 0) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
924 |
|
|
925 |
return do_tkill(0, pid, sig); |
return do_tkill(0, pid, sig); |
926 |
} |
} |
927 |
--- linux-2.6.21.orig/kernel/sys.c |
@@ -2323,6 +2330,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
928 |
+++ linux-2.6.21/kernel/sys.c |
if (info.si_code >= 0) |
929 |
@@ -37,6 +37,9 @@ |
return -EPERM; |
930 |
|
info.si_signo = sig; |
931 |
|
+ if (ccs_sigqueue_permission(pid, sig)) |
932 |
|
+ return -EPERM; |
933 |
|
|
934 |
|
/* POSIX.1b doesn't mention process groups. */ |
935 |
|
return kill_proc_info(sig, &info, pid); |
936 |
|
--- linux-2.6.21.7.orig/kernel/sys.c |
937 |
|
+++ linux-2.6.21.7/kernel/sys.c |
938 |
|
@@ -37,6 +37,7 @@ |
939 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
940 |
#include <asm/io.h> |
#include <asm/io.h> |
941 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
942 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
943 |
|
|
944 |
#ifndef SET_UNALIGN_CTL |
#ifndef SET_UNALIGN_CTL |
945 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
946 |
@@ -600,6 +603,9 @@ asmlinkage long sys_setpriority(int whic |
@@ -600,6 +601,10 @@ asmlinkage long sys_setpriority(int whic |
947 |
|
|
948 |
if (which > 2 || which < 0) |
if (which > 2 || which < 0) |
949 |
goto out; |
goto out; |
950 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
951 |
+ if (CheckCapabilityACL(TOMOYO_SYS_NICE)) return -EPERM; |
+ error = -EPERM; |
952 |
+ /***** TOMOYO Linux end. *****/ |
+ goto out; |
953 |
|
+ } |
954 |
|
|
955 |
/* normalize: avoid signed division (rounding problems) */ |
/* normalize: avoid signed division (rounding problems) */ |
956 |
error = -ESRCH; |
error = -ESRCH; |
957 |
@@ -830,6 +836,9 @@ asmlinkage long sys_reboot(int magic1, i |
@@ -830,6 +835,8 @@ asmlinkage long sys_reboot(int magic1, i |
958 |
magic2 != LINUX_REBOOT_MAGIC2B && |
magic2 != LINUX_REBOOT_MAGIC2B && |
959 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
magic2 != LINUX_REBOOT_MAGIC2C)) |
960 |
return -EINVAL; |
return -EINVAL; |
961 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
962 |
+ if (CheckCapabilityACL(TOMOYO_SYS_REBOOT)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
963 |
|
|
964 |
/* Instead of trying to make the power_off code look like |
/* Instead of trying to make the power_off code look like |
965 |
* halt when pm_power_off is not set do it the easy way. |
* halt when pm_power_off is not set do it the easy way. |
966 |
@@ -1806,6 +1815,9 @@ asmlinkage long sys_sethostname(char __u |
@@ -1806,6 +1813,8 @@ asmlinkage long sys_sethostname(char __u |
967 |
return -EPERM; |
return -EPERM; |
968 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
969 |
return -EINVAL; |
return -EINVAL; |
970 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
971 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
972 |
down_write(&uts_sem); |
down_write(&uts_sem); |
973 |
errno = -EFAULT; |
errno = -EFAULT; |
974 |
if (!copy_from_user(tmp, name, len)) { |
if (!copy_from_user(tmp, name, len)) { |
975 |
@@ -1851,6 +1863,9 @@ asmlinkage long sys_setdomainname(char _ |
@@ -1851,6 +1860,8 @@ asmlinkage long sys_setdomainname(char _ |
976 |
return -EPERM; |
return -EPERM; |
977 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
978 |
return -EINVAL; |
return -EINVAL; |
979 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
980 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETHOSTNAME)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
981 |
|
|
982 |
down_write(&uts_sem); |
down_write(&uts_sem); |
983 |
errno = -EFAULT; |
errno = -EFAULT; |
984 |
--- linux-2.6.21.orig/kernel/sysctl.c |
--- linux-2.6.21.7.orig/kernel/sysctl.c |
985 |
+++ linux-2.6.21/kernel/sysctl.c |
+++ linux-2.6.21.7/kernel/sysctl.c |
986 |
@@ -48,6 +48,9 @@ |
@@ -48,6 +48,7 @@ |
987 |
|
|
988 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
989 |
#include <asm/processor.h> |
#include <asm/processor.h> |
990 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
991 |
|
|
992 |
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
extern int proc_nr_files(ctl_table *table, int write, struct file *filp, |
993 |
void __user *buffer, size_t *lenp, loff_t *ppos); |
void __user *buffer, size_t *lenp, loff_t *ppos); |
994 |
@@ -1088,6 +1091,81 @@ struct ctl_table_header *sysctl_head_nex |
@@ -1088,6 +1089,7 @@ struct ctl_table_header *sysctl_head_nex |
995 |
} |
} |
996 |
|
|
997 |
#ifdef CONFIG_SYSCTL_SYSCALL |
#ifdef CONFIG_SYSCTL_SYSCALL |
998 |
+ |
+ |
|
+/***** 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) == NULL) goto out; |
|
|
+ } |
|
|
+ if (table->child) { |
|
|
+ name++; |
|
|
+ nlen--; |
|
|
+ table = table->child; |
|
|
+ goto repeat; |
|
|
+ } |
|
|
+ /* printk("sysctl='%s'\n", buffer); */ |
|
|
+ error = CheckFilePerm(buffer, op, "sysctl"); |
|
|
+ goto out; |
|
|
+ } |
|
|
+ } |
|
|
+ error = -ENOTDIR; |
|
|
+ out: |
|
|
+ kfree(buffer); |
|
|
+ return error; |
|
|
+} |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
+ |
|
999 |
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, |
1000 |
void __user *newval, size_t newlen) |
void __user *newval, size_t newlen) |
1001 |
{ |
{ |
1002 |
@@ -1104,6 +1182,9 @@ int do_sysctl(int __user *name, int nlen |
@@ -1104,6 +1106,9 @@ int do_sysctl(int __user *name, int nlen |
1003 |
|
|
1004 |
for (head = sysctl_head_next(NULL); head; |
for (head = sysctl_head_next(NULL); head; |
1005 |
head = sysctl_head_next(head)) { |
head = sysctl_head_next(head)) { |
1006 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
1007 |
+ if ((error = try_parse_table(name, nlen, oldval, newval, head->ctl_table)) == 0) |
+ head->ctl_table); |
1008 |
+ /***** TOMOYO Linux end. *****/ |
+ if (!error) |
1009 |
error = parse_table(name, nlen, oldval, oldlenp, |
error = parse_table(name, nlen, oldval, oldlenp, |
1010 |
newval, newlen, head->ctl_table); |
newval, newlen, head->ctl_table); |
1011 |
if (error != -ENOTDIR) { |
if (error != -ENOTDIR) { |
1012 |
--- linux-2.6.21.orig/kernel/time.c |
--- linux-2.6.21.7.orig/kernel/time.c |
1013 |
+++ linux-2.6.21/kernel/time.c |
+++ linux-2.6.21.7/kernel/time.c |
1014 |
@@ -39,6 +39,9 @@ |
@@ -39,6 +39,7 @@ |
1015 |
|
|
1016 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1017 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
1018 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1019 |
|
|
1020 |
/* |
/* |
1021 |
* The timezone where the local system is located. Used as a default by some |
* The timezone where the local system is located. Used as a default by some |
1022 |
@@ -91,6 +94,9 @@ asmlinkage long sys_stime(time_t __user |
@@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user |
1023 |
err = security_settime(&tv, NULL); |
err = security_settime(&tv, NULL); |
1024 |
if (err) |
if (err) |
1025 |
return err; |
return err; |
1026 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1027 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1028 |
|
|
1029 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
1030 |
return 0; |
return 0; |
1031 |
@@ -161,6 +167,9 @@ int do_sys_settimeofday(struct timespec |
@@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec |
1032 |
error = security_settime(tv, tz); |
error = security_settime(tv, tz); |
1033 |
if (error) |
if (error) |
1034 |
return error; |
return error; |
1035 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1036 |
+ if (CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1037 |
|
|
1038 |
if (tz) { |
if (tz) { |
1039 |
/* SMP safe, global irq locking makes it work. */ |
/* SMP safe, global irq locking makes it work. */ |
1040 |
--- linux-2.6.21.orig/kernel/time/ntp.c |
--- linux-2.6.21.7.orig/kernel/time/ntp.c |
1041 |
+++ linux-2.6.21/kernel/time/ntp.c |
+++ linux-2.6.21.7/kernel/time/ntp.c |
1042 |
@@ -14,6 +14,9 @@ |
@@ -14,6 +14,7 @@ |
1043 |
|
|
1044 |
#include <asm/div64.h> |
#include <asm/div64.h> |
1045 |
#include <asm/timex.h> |
#include <asm/timex.h> |
1046 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1047 |
|
|
1048 |
/* |
/* |
1049 |
* Timekeeping variables |
* Timekeeping variables |
1050 |
@@ -203,6 +206,9 @@ int do_adjtimex(struct timex *txc) |
@@ -201,6 +202,8 @@ int do_adjtimex(struct timex *txc) |
1051 |
/* In order to modify anything, you gotta be super-user! */ |
/* In order to modify anything, you gotta be super-user! */ |
1052 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
if (txc->modes && !capable(CAP_SYS_TIME)) |
1053 |
return -EPERM; |
return -EPERM; |
1054 |
+ /***** TOMOYO Linux start. *****/ |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
1055 |
+ if (txc->modes && CheckCapabilityACL(TOMOYO_SYS_SETTIME)) return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1056 |
|
|
1057 |
/* Now we validate the data before disabling interrupts */ |
/* Now we validate the data before disabling interrupts */ |
1058 |
|
|
1059 |
--- linux-2.6.21.orig/net/core/datagram.c |
--- linux-2.6.21.7.orig/net/ipv4/inet_connection_sock.c |
1060 |
+++ linux-2.6.21/net/core/datagram.c |
+++ linux-2.6.21.7/net/ipv4/inet_connection_sock.c |
1061 |
@@ -56,6 +56,11 @@ |
@@ -23,6 +23,7 @@ |
|
#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' ? |
|
|
*/ |
|
|
@@ -178,6 +183,10 @@ struct sk_buff *skb_recv_datagram(struct |
|
|
} else |
|
|
skb = skb_dequeue(&sk->sk_receive_queue); |
|
|
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if ((error = CheckSocketRecvDatagramPermission(sk, skb, flags)) < 0) goto no_packet; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ |
|
|
if (skb) |
|
|
return skb; |
|
|
|
|
|
--- linux-2.6.21.orig/net/ipv4/inet_connection_sock.c |
|
|
+++ linux-2.6.21/net/ipv4/inet_connection_sock.c |
|
|
@@ -23,6 +23,9 @@ |
|
1062 |
#include <net/route.h> |
#include <net/route.h> |
1063 |
#include <net/tcp_states.h> |
#include <net/tcp_states.h> |
1064 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1065 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1066 |
|
|
1067 |
#ifdef INET_CSK_DEBUG |
#ifdef INET_CSK_DEBUG |
1068 |
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"; |
1069 |
@@ -87,6 +90,9 @@ int inet_csk_get_port(struct inet_hashin |
@@ -85,6 +86,8 @@ int inet_csk_get_port(struct inet_hashin |
1070 |
do { |
do { |
1071 |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
1072 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1073 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(rover)) |
1074 |
+ if (SAKURA_MayAutobind(rover) < 0) goto next; |
+ goto next; |
|
+ /***** SAKURA Linux end. *****/ |
|
1075 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
inet_bind_bucket_for_each(tb, node, &head->chain) |
1076 |
if (tb->port == rover) |
if (tb->port == rover) |
1077 |
goto next; |
goto next; |
1078 |
--- linux-2.6.21.orig/net/ipv4/inet_hashtables.c |
--- linux-2.6.21.7.orig/net/ipv4/inet_hashtables.c |
1079 |
+++ linux-2.6.21/net/ipv4/inet_hashtables.c |
+++ linux-2.6.21.7/net/ipv4/inet_hashtables.c |
1080 |
@@ -22,6 +22,9 @@ |
@@ -22,6 +22,7 @@ |
1081 |
#include <net/inet_connection_sock.h> |
#include <net/inet_connection_sock.h> |
1082 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1083 |
#include <net/ip.h> |
#include <net/ip.h> |
1084 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1085 |
|
|
1086 |
/* |
/* |
1087 |
* Allocate and initialize a new local port bind bucket. |
* Allocate and initialize a new local port bind bucket. |
1088 |
@@ -292,6 +295,9 @@ int inet_hash_connect(struct inet_timewa |
@@ -292,6 +293,8 @@ int inet_hash_connect(struct inet_timewa |
1089 |
local_bh_disable(); |
local_bh_disable(); |
1090 |
for (i = 1; i <= range; i++) { |
for (i = 1; i <= range; i++) { |
1091 |
port = low + (i + offset) % range; |
port = low + (i + offset) % range; |
1092 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(port)) |
1093 |
+ if (SAKURA_MayAutobind(port) < 0) continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1094 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1095 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1096 |
|
|
1097 |
--- linux-2.6.21.orig/net/ipv4/udp.c |
--- linux-2.6.21.7.orig/net/ipv4/raw.c |
1098 |
+++ linux-2.6.21/net/ipv4/udp.c |
+++ linux-2.6.21.7/net/ipv4/raw.c |
1099 |
@@ -102,6 +102,9 @@ |
@@ -78,6 +78,7 @@ |
1100 |
|
#include <linux/seq_file.h> |
1101 |
|
#include <linux/netfilter.h> |
1102 |
|
#include <linux/netfilter_ipv4.h> |
1103 |
|
+#include <linux/ccsecurity.h> |
1104 |
|
|
1105 |
|
struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; |
1106 |
|
DEFINE_RWLOCK(raw_v4_lock); |
1107 |
|
@@ -597,6 +598,9 @@ static int raw_recvmsg(struct kiocb *ioc |
1108 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1109 |
|
if (!skb) |
1110 |
|
goto out; |
1111 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1112 |
|
+ if (err) |
1113 |
|
+ goto out; |
1114 |
|
|
1115 |
|
copied = skb->len; |
1116 |
|
if (len < copied) { |
1117 |
|
--- linux-2.6.21.7.orig/net/ipv4/udp.c |
1118 |
|
+++ linux-2.6.21.7/net/ipv4/udp.c |
1119 |
|
@@ -102,6 +102,7 @@ |
1120 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1121 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1122 |
#include "udp_impl.h" |
#include "udp_impl.h" |
1123 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1124 |
|
|
1125 |
/* |
/* |
1126 |
* Snmp MIB for the UDP layer |
* Snmp MIB for the UDP layer |
1127 |
@@ -162,6 +165,9 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -162,6 +163,8 @@ int __udp_lib_get_port(struct sock *sk, |
1128 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1129 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1130 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1131 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
1132 |
+ if (SAKURA_MayAutobind(result) < 0) continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1133 |
goto gotit; |
goto gotit; |
1134 |
} |
} |
1135 |
size = 0; |
size = 0; |
1136 |
@@ -180,6 +186,9 @@ int __udp_lib_get_port(struct sock *sk, |
@@ -180,6 +183,8 @@ int __udp_lib_get_port(struct sock *sk, |
1137 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1138 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1139 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1140 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
1141 |
+ if (SAKURA_MayAutobind(result) < 0) continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1142 |
if (! __udp_lib_lport_inuse(result, udptable)) |
if (! __udp_lib_lport_inuse(result, udptable)) |
1143 |
break; |
break; |
1144 |
} |
} |
1145 |
--- linux-2.6.21.orig/net/ipv6/inet6_hashtables.c |
@@ -825,6 +830,9 @@ try_again: |
1146 |
+++ linux-2.6.21/net/ipv6/inet6_hashtables.c |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1147 |
@@ -21,6 +21,9 @@ |
if (!skb) |
1148 |
|
goto out; |
1149 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1150 |
|
+ if (err) |
1151 |
|
+ goto out; |
1152 |
|
|
1153 |
|
copied = skb->len - sizeof(struct udphdr); |
1154 |
|
if (copied > len) { |
1155 |
|
--- linux-2.6.21.7.orig/net/ipv6/inet6_hashtables.c |
1156 |
|
+++ linux-2.6.21.7/net/ipv6/inet6_hashtables.c |
1157 |
|
@@ -21,6 +21,7 @@ |
1158 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1159 |
#include <net/inet6_hashtables.h> |
#include <net/inet6_hashtables.h> |
1160 |
#include <net/ip.h> |
#include <net/ip.h> |
1161 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1162 |
|
|
1163 |
void __inet6_hash(struct inet_hashinfo *hashinfo, |
void __inet6_hash(struct inet_hashinfo *hashinfo, |
1164 |
struct sock *sk) |
struct sock *sk) |
1165 |
@@ -266,6 +269,9 @@ int inet6_hash_connect(struct inet_timew |
@@ -266,6 +267,8 @@ int inet6_hash_connect(struct inet_timew |
1166 |
local_bh_disable(); |
local_bh_disable(); |
1167 |
for (i = 1; i <= range; i++) { |
for (i = 1; i <= range; i++) { |
1168 |
port = low + (i + offset) % range; |
port = low + (i + offset) % range; |
1169 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(port)) |
1170 |
+ if (SAKURA_MayAutobind(port) < 0) continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1171 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1172 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1173 |
|
|
1174 |
--- linux-2.6.21.orig/net/socket.c |
--- linux-2.6.21.7.orig/net/ipv6/raw.c |
1175 |
+++ linux-2.6.21/net/socket.c |
+++ linux-2.6.21.7/net/ipv6/raw.c |
1176 |
@@ -93,6 +93,11 @@ |
@@ -58,6 +58,7 @@ |
1177 |
|
|
1178 |
|
#include <linux/proc_fs.h> |
1179 |
|
#include <linux/seq_file.h> |
1180 |
|
+#include <linux/ccsecurity.h> |
1181 |
|
|
1182 |
|
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1183 |
|
DEFINE_RWLOCK(raw_v6_lock); |
1184 |
|
@@ -413,6 +414,9 @@ static int rawv6_recvmsg(struct kiocb *i |
1185 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1186 |
|
if (!skb) |
1187 |
|
goto out; |
1188 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1189 |
|
+ if (err) |
1190 |
|
+ goto out; |
1191 |
|
|
1192 |
|
copied = skb->len; |
1193 |
|
if (copied > len) { |
1194 |
|
--- linux-2.6.21.7.orig/net/ipv6/udp.c |
1195 |
|
+++ linux-2.6.21.7/net/ipv6/udp.c |
1196 |
|
@@ -49,6 +49,7 @@ |
1197 |
|
#include <linux/proc_fs.h> |
1198 |
|
#include <linux/seq_file.h> |
1199 |
|
#include "udp_impl.h" |
1200 |
|
+#include <linux/ccsecurity.h> |
1201 |
|
|
1202 |
|
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
1203 |
|
|
1204 |
|
@@ -133,6 +134,9 @@ try_again: |
1205 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1206 |
|
if (!skb) |
1207 |
|
goto out; |
1208 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1209 |
|
+ if (err) |
1210 |
|
+ goto out; |
1211 |
|
|
1212 |
|
copied = skb->len - sizeof(struct udphdr); |
1213 |
|
if (copied > len) { |
1214 |
|
--- linux-2.6.21.7.orig/net/socket.c |
1215 |
|
+++ linux-2.6.21.7/net/socket.c |
1216 |
|
@@ -93,6 +93,8 @@ |
1217 |
#include <net/sock.h> |
#include <net/sock.h> |
1218 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1219 |
|
|
1220 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+#include <linux/tomoyo_socket.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1221 |
+ |
+ |
1222 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1223 |
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, |
1224 |
unsigned long nr_segs, loff_t pos); |
unsigned long nr_segs, loff_t pos); |
1225 |
@@ -549,6 +554,9 @@ static inline int __sock_sendmsg(struct |
@@ -547,6 +549,10 @@ static inline int __sock_sendmsg(struct |
1226 |
|
si->size = size; |
1227 |
|
|
1228 |
err = security_socket_sendmsg(sock, msg, size); |
err = security_socket_sendmsg(sock, msg, size); |
1229 |
|
+ if (!err) |
1230 |
|
+ err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *) |
1231 |
|
+ msg->msg_name, |
1232 |
|
+ msg->msg_namelen); |
1233 |
if (err) |
if (err) |
1234 |
return err; |
return err; |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (CheckSocketSendMsgPermission(sock, (struct sockaddr *) msg->msg_name, msg->msg_namelen)) return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1235 |
|
|
1236 |
return sock->ops->sendmsg(iocb, sock, msg, size); |
@@ -1071,6 +1077,8 @@ static int __sock_create(int family, int |
|
} |
|
|
@@ -1070,6 +1078,10 @@ static int __sock_create(int family, int |
|
|
family = PF_PACKET; |
|
1237 |
} |
} |
1238 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if ((err = CheckSocketCreatePermission(family, type, protocol)) < 0) return err; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ |
|
1239 |
err = security_socket_create(family, type, protocol, kern); |
err = security_socket_create(family, type, protocol, kern); |
1240 |
|
+ if (!err) |
1241 |
|
+ err = ccs_socket_create_permission(family, type, protocol); |
1242 |
if (err) |
if (err) |
1243 |
return err; |
return err; |
1244 |
@@ -1298,6 +1310,9 @@ asmlinkage long sys_bind(int fd, struct |
|
1245 |
err = security_socket_bind(sock, |
@@ -1299,6 +1307,11 @@ asmlinkage long sys_bind(int fd, struct |
1246 |
(struct sockaddr *)address, |
(struct sockaddr *)address, |
1247 |
addrlen); |
addrlen); |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!err) err = CheckSocketBindPermission(sock, (struct sockaddr *) address, addrlen); |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1248 |
if (!err) |
if (!err) |
1249 |
|
+ err = ccs_socket_bind_permission(sock, |
1250 |
|
+ (struct sockaddr *) |
1251 |
|
+ address, |
1252 |
|
+ addrlen); |
1253 |
|
+ if (!err) |
1254 |
err = sock->ops->bind(sock, |
err = sock->ops->bind(sock, |
1255 |
(struct sockaddr *) |
(struct sockaddr *) |
1256 |
@@ -1327,6 +1342,9 @@ asmlinkage long sys_listen(int fd, int b |
address, addrlen); |
1257 |
backlog = sysctl_somaxconn; |
@@ -1328,6 +1341,8 @@ asmlinkage long sys_listen(int fd, int b |
1258 |
|
|
1259 |
err = security_socket_listen(sock, backlog); |
err = security_socket_listen(sock, backlog); |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!err) err = CheckSocketListenPermission(sock); |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1260 |
if (!err) |
if (!err) |
1261 |
|
+ err = ccs_socket_listen_permission(sock); |
1262 |
|
+ if (!err) |
1263 |
err = sock->ops->listen(sock, backlog); |
err = sock->ops->listen(sock, backlog); |
1264 |
|
|
1265 |
@@ -1391,6 +1409,12 @@ asmlinkage long sys_accept(int fd, struc |
fput_light(sock->file, fput_needed); |
1266 |
|
@@ -1391,6 +1406,11 @@ asmlinkage long sys_accept(int fd, struc |
1267 |
if (err < 0) |
if (err < 0) |
1268 |
goto out_fd; |
goto out_fd; |
1269 |
|
|
1270 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_socket_accept_permission(newsock, |
1271 |
+ if (CheckSocketAcceptPermission(newsock, (struct sockaddr *) address)) { |
+ (struct sockaddr *) address)) { |
1272 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1273 |
+ goto out_fd; |
+ goto out_fd; |
1274 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
1275 |
if (upeer_sockaddr) { |
if (upeer_sockaddr) { |
1276 |
if (newsock->ops->getname(newsock, (struct sockaddr *)address, |
if (newsock->ops->getname(newsock, (struct sockaddr *)address, |
1277 |
&len, 2) < 0) { |
&len, 2) < 0) { |
1278 |
@@ -1455,6 +1479,10 @@ asmlinkage long sys_connect(int fd, stru |
@@ -1453,6 +1473,9 @@ asmlinkage long sys_connect(int fd, stru |
1279 |
|
|
1280 |
|
err = |
1281 |
security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1282 |
|
+ if (!err) |
1283 |
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) |
1284 |
|
+ address, addrlen); |
1285 |
if (err) |
if (err) |
1286 |
goto out_put; |
goto out_put; |
1287 |
+ /***** TOMOYO Linux start. *****/ |
|
1288 |
+ err = CheckSocketConnectPermission(sock, (struct sockaddr *) address, addrlen); |
--- linux-2.6.21.7.orig/net/unix/af_unix.c |
1289 |
+ if (err) goto out_put; |
+++ linux-2.6.21.7/net/unix/af_unix.c |
1290 |
+ /***** TOMOYO Linux end. *****/ |
@@ -116,6 +116,7 @@ |
|
|
|
|
err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen, |
|
|
sock->file->f_flags); |
|
|
--- linux-2.6.21.orig/net/unix/af_unix.c |
|
|
+++ linux-2.6.21/net/unix/af_unix.c |
|
|
@@ -116,6 +116,9 @@ |
|
1291 |
#include <linux/mount.h> |
#include <linux/mount.h> |
1292 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1293 |
#include <linux/security.h> |
#include <linux/security.h> |
1294 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1295 |
|
|
1296 |
int sysctl_unix_max_dgram_qlen __read_mostly = 10; |
int sysctl_unix_max_dgram_qlen __read_mostly = 10; |
1297 |
|
|
1298 |
@@ -765,6 +768,10 @@ static int unix_bind(struct socket *sock |
@@ -808,6 +809,9 @@ static int unix_bind(struct socket *sock |
|
err = unix_autobind(sock); |
|
|
goto out; |
|
|
} |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = -EPERM; |
|
|
+ if (sunaddr->sun_path[0] && CheckCapabilityACL(TOMOYO_CREATE_UNIX_SOCKET)) goto out; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
err = unix_mkname(sunaddr, addr_len, &hash); |
|
|
if (err < 0) |
|
|
@@ -808,6 +815,9 @@ static int unix_bind(struct socket *sock |
|
1299 |
*/ |
*/ |
1300 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1301 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1302 |
+ /***** TOMOYO Linux start. *****/ |
+ err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt, |
1303 |
+ if ((err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode)) == 0 && (err = CheckSingleWritePermission(TYPE_MKSOCK_ACL, dentry, nd.mnt)) == 0) |
+ mode, 0); |
1304 |
+ /***** TOMOYO Linux end. *****/ |
+ if (!err) |
1305 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1306 |
if (err) |
if (err) |
1307 |
goto out_mknod_dput; |
goto out_mknod_dput; |
1308 |
--- linux-2.6.21.orig/arch/powerpc/kernel/ptrace32.c |
--- linux-2.6.21.7.orig/security/Kconfig |
1309 |
+++ linux-2.6.21/arch/powerpc/kernel/ptrace32.c |
+++ linux-2.6.21.7/security/Kconfig |
1310 |
@@ -32,6 +32,9 @@ |
@@ -95,5 +95,7 @@ config SECURITY_ROOTPLUG |
|
#include <asm/page.h> |
|
|
#include <asm/pgtable.h> |
|
|
#include <asm/system.h> |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
|
|
|
#include "ptrace-common.h" |
|
|
|
|
|
@@ -45,6 +48,11 @@ long compat_sys_ptrace(int request, int |
|
|
{ |
|
|
struct task_struct *child; |
|
|
int ret; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+#ifdef TOMOYO_SYS_PTRACE |
|
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
lock_kernel(); |
|
|
if (request == PTRACE_TRACEME) { |
|
|
--- linux-2.6.21.orig/arch/sh64/kernel/ptrace.c |
|
|
+++ linux-2.6.21/arch/sh64/kernel/ptrace.c |
|
|
@@ -35,6 +35,9 @@ |
|
|
#include <asm/system.h> |
|
|
#include <asm/processor.h> |
|
|
#include <asm/mmu_context.h> |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
|
|
|
/* This mask defines the bits of the SR which the user is not allowed to |
|
|
change, which are everything except S, Q, M, PR, SZ, FR. */ |
|
|
@@ -271,6 +274,11 @@ asmlinkage int sh64_ptrace(long request, |
|
|
extern void poke_real_address_q(unsigned long long addr, unsigned long long data); |
|
|
#define WPC_DBRMODE 0x0d104008 |
|
|
static int first_call = 1; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+#ifdef TOMOYO_SYS_PTRACE |
|
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1311 |
|
|
1312 |
lock_kernel(); |
source security/selinux/Kconfig |
|
if (first_call) { |
|
|
--- linux-2.6.21.orig/arch/x86_64/ia32/ptrace32.c |
|
|
+++ linux-2.6.21/arch/x86_64/ia32/ptrace32.c |
|
|
@@ -26,6 +26,9 @@ |
|
|
#include <asm/i387.h> |
|
|
#include <asm/fpu32.h> |
|
|
#include <asm/ia32.h> |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1313 |
|
|
1314 |
/* |
+source security/ccsecurity/Kconfig |
1315 |
* Determines which flags the user has access to [1 = access, 0 = no access]. |
+ |
1316 |
@@ -234,6 +237,11 @@ asmlinkage long sys32_ptrace(long reques |
endmenu |
|
void __user *datap = compat_ptr(data); |
|
|
int ret; |
|
|
__u32 val; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+#ifdef TOMOYO_SYS_PTRACE |
|
|
+ if (CheckCapabilityACL(TOMOYO_SYS_PTRACE)) return -EPERM; |
|
|
+#endif |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1317 |
|
|
1318 |
switch (request) { |
--- linux-2.6.21.7.orig/security/Makefile |
1319 |
case PTRACE_TRACEME: |
+++ linux-2.6.21.7/security/Makefile |
1320 |
|
@@ -16,3 +16,6 @@ obj-$(CONFIG_SECURITY) += security.o d |
1321 |
|
obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o |
1322 |
|
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |
1323 |
|
obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o |
1324 |
|
+ |
1325 |
|
+subdir-$(CONFIG_CCSECURITY)+= ccsecurity |
1326 |
|
+obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o |