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