2 |
|
|
3 |
Source code for this patch is "apt-get install linux-source-2.6.18" |
Source code for this patch is "apt-get install linux-source-2.6.18" |
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 | 12 +++++++++++- |
17 |
fs/attr.c | 19 ++++++++++++ |
fs/fcntl.c | 4 ++++ |
18 |
fs/compat.c | 15 +++++++++- |
fs/ioctl.c | 3 +++ |
19 |
fs/exec.c | 21 +++++++++++++- |
fs/namei.c | 31 +++++++++++++++++++++++++++++++ |
20 |
fs/fcntl.c | 9 ++++++ |
fs/namespace.c | 9 +++++++++ |
21 |
fs/ioctl.c | 11 +++++++ |
fs/open.c | 27 +++++++++++++++++++++++++++ |
22 |
fs/namei.c | 60 ++++++++++++++++++++++++++++++++++++++++ |
fs/proc/proc_misc.c | 1 + |
23 |
fs/namespace.c | 50 ++++++++++++++++++++++++++++++++- |
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 | 7 +++++-- |
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 | 13 +++++++- |
kernel/sys.c | 11 +++++++++++ |
33 |
kernel/ptrace.c | 7 ++++ |
kernel/sysctl.c | 11 +++++++++++ |
34 |
kernel/sched.c | 7 ++++ |
kernel/time.c | 7 +++++++ |
35 |
kernel/signal.c | 21 ++++++++++++++ |
net/ipv4/inet_connection_sock.c | 3 +++ |
36 |
kernel/sys.c | 21 ++++++++++++++ |
net/ipv4/inet_hashtables.c | 3 +++ |
37 |
kernel/sysctl.c | 17 +++++++++++ |
net/ipv4/raw.c | 12 +++++++++--- |
38 |
kernel/time.c | 15 ++++++++++ |
net/ipv4/udp.c | 16 ++++++++++++++-- |
39 |
net/core/datagram.c | 11 +++++++ |
net/ipv6/inet6_hashtables.c | 5 ++++- |
40 |
net/ipv4/inet_connection_sock.c | 7 ++++ |
net/ipv6/raw.c | 12 +++++++++--- |
41 |
net/ipv4/inet_hashtables.c | 7 ++++ |
net/ipv6/udp.c | 14 +++++++++++++- |
42 |
net/ipv4/udp.c | 11 +++++++ |
net/socket.c | 24 ++++++++++++++++++++++-- |
43 |
net/ipv6/inet6_hashtables.c | 9 +++++- |
net/unix/af_unix.c | 9 +++++++++ |
44 |
net/ipv6/udp.c | 11 +++++++ |
security/Kconfig | 2 ++ |
45 |
net/socket.c | 43 +++++++++++++++++++++++++++- |
security/Makefile | 3 +++ |
46 |
net/unix/af_unix.c | 8 +++++ |
41 files changed, 294 insertions(+), 16 deletions(-) |
|
42 files changed, 530 insertions(+), 8 deletions(-) |
|
47 |
|
|
48 |
--- linux-2.6.18-24.orig/arch/alpha/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/alpha/kernel/ptrace.c |
49 |
+++ linux-2.6.18-24/arch/alpha/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/alpha/kernel/ptrace.c |
50 |
@@ -20,6 +20,9 @@ |
@@ -20,6 +20,7 @@ |
51 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
52 |
#include <asm/system.h> |
#include <asm/system.h> |
53 |
#include <asm/fpu.h> |
#include <asm/fpu.h> |
54 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
55 |
|
|
56 |
#include "proto.h" |
#include "proto.h" |
57 |
|
|
58 |
@@ -268,6 +271,10 @@ do_sys_ptrace(long request, long pid, lo |
@@ -268,6 +269,8 @@ do_sys_ptrace(long request, long pid, lo |
59 |
unsigned long tmp; |
unsigned long tmp; |
60 |
size_t copied; |
size_t copied; |
61 |
long ret; |
long ret; |
62 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
63 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
64 |
|
|
65 |
lock_kernel(); |
lock_kernel(); |
66 |
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", |
67 |
--- linux-2.6.18-24.orig/arch/ia64/ia32/sys_ia32.c |
--- linux-2.6.18-26etch2.orig/arch/ia64/ia32/sys_ia32.c |
68 |
+++ linux-2.6.18-24/arch/ia64/ia32/sys_ia32.c |
+++ linux-2.6.18-26etch2/arch/ia64/ia32/sys_ia32.c |
69 |
@@ -56,6 +56,9 @@ |
@@ -56,6 +56,7 @@ |
70 |
#include <asm/types.h> |
#include <asm/types.h> |
71 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
72 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
73 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
74 |
|
|
75 |
#include "ia32priv.h" |
#include "ia32priv.h" |
76 |
|
|
77 |
@@ -1741,6 +1744,10 @@ sys32_ptrace (int request, pid_t pid, un |
@@ -1741,6 +1742,8 @@ sys32_ptrace (int request, pid_t pid, un |
78 |
struct task_struct *child; |
struct task_struct *child; |
79 |
unsigned int value, tmp; |
unsigned int value, tmp; |
80 |
long i, ret; |
long i, ret; |
81 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
82 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
83 |
|
|
84 |
lock_kernel(); |
lock_kernel(); |
85 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
86 |
--- linux-2.6.18-24.orig/arch/ia64/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/ia64/kernel/ptrace.c |
87 |
+++ linux-2.6.18-24/arch/ia64/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/ia64/kernel/ptrace.c |
88 |
@@ -28,6 +28,9 @@ |
@@ -28,6 +28,7 @@ |
89 |
#ifdef CONFIG_PERFMON |
#ifdef CONFIG_PERFMON |
90 |
#include <asm/perfmon.h> |
#include <asm/perfmon.h> |
91 |
#endif |
#endif |
92 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
93 |
|
|
94 |
#include "entry.h" |
#include "entry.h" |
95 |
|
|
96 |
@@ -1417,6 +1420,10 @@ sys_ptrace (long request, pid_t pid, uns |
@@ -1417,6 +1418,8 @@ sys_ptrace (long request, pid_t pid, uns |
97 |
struct task_struct *child; |
struct task_struct *child; |
98 |
struct switch_stack *sw; |
struct switch_stack *sw; |
99 |
long ret; |
long ret; |
100 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
101 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
102 |
|
|
103 |
lock_kernel(); |
lock_kernel(); |
104 |
ret = -EPERM; |
ret = -EPERM; |
105 |
--- linux-2.6.18-24.orig/arch/m32r/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/m32r/kernel/ptrace.c |
106 |
+++ linux-2.6.18-24/arch/m32r/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/m32r/kernel/ptrace.c |
107 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
108 |
#include <asm/system.h> |
#include <asm/system.h> |
109 |
#include <asm/processor.h> |
#include <asm/processor.h> |
110 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
111 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
112 |
|
|
113 |
/* |
/* |
114 |
* This routine will get a word off of the process kernel stack. |
* This routine will get a word off of the process kernel stack. |
115 |
@@ -742,6 +745,10 @@ asmlinkage long sys_ptrace(long request, |
@@ -742,6 +743,8 @@ asmlinkage long sys_ptrace(long request, |
116 |
{ |
{ |
117 |
struct task_struct *child; |
struct task_struct *child; |
118 |
int ret; |
int ret; |
119 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
120 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
121 |
|
|
122 |
lock_kernel(); |
lock_kernel(); |
123 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
124 |
--- linux-2.6.18-24.orig/arch/mips/kernel/ptrace32.c |
--- linux-2.6.18-26etch2.orig/arch/mips/kernel/ptrace32.c |
125 |
+++ linux-2.6.18-24/arch/mips/kernel/ptrace32.c |
+++ linux-2.6.18-26etch2/arch/mips/kernel/ptrace32.c |
126 |
@@ -35,6 +35,9 @@ |
@@ -35,6 +35,7 @@ |
127 |
#include <asm/system.h> |
#include <asm/system.h> |
128 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
129 |
#include <asm/bootinfo.h> |
#include <asm/bootinfo.h> |
130 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
131 |
|
|
132 |
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
int ptrace_getregs (struct task_struct *child, __s64 __user *data); |
133 |
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
int ptrace_setregs (struct task_struct *child, __s64 __user *data); |
134 |
@@ -50,6 +53,10 @@ asmlinkage int sys32_ptrace(int request, |
@@ -50,6 +51,8 @@ asmlinkage int sys32_ptrace(int request, |
135 |
{ |
{ |
136 |
struct task_struct *child; |
struct task_struct *child; |
137 |
int ret; |
int ret; |
138 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
139 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
140 |
|
|
141 |
#if 0 |
#if 0 |
142 |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", |
143 |
--- linux-2.6.18-24.orig/arch/powerpc/kernel/ptrace32.c |
--- linux-2.6.18-26etch2.orig/arch/powerpc/kernel/ptrace32.c |
144 |
+++ linux-2.6.18-24/arch/powerpc/kernel/ptrace32.c |
+++ linux-2.6.18-26etch2/arch/powerpc/kernel/ptrace32.c |
145 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
146 |
#include <asm/page.h> |
#include <asm/page.h> |
147 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
148 |
#include <asm/system.h> |
#include <asm/system.h> |
149 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
150 |
|
|
151 |
#include "ptrace-common.h" |
#include "ptrace-common.h" |
152 |
|
|
153 |
@@ -45,6 +48,10 @@ long compat_sys_ptrace(int request, int |
@@ -45,6 +46,8 @@ long compat_sys_ptrace(int request, int |
154 |
{ |
{ |
155 |
struct task_struct *child; |
struct task_struct *child; |
156 |
int ret; |
int ret; |
157 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
158 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
159 |
|
|
160 |
lock_kernel(); |
lock_kernel(); |
161 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
162 |
--- linux-2.6.18-24.orig/arch/s390/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/s390/kernel/ptrace.c |
163 |
+++ linux-2.6.18-24/arch/s390/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/s390/kernel/ptrace.c |
164 |
@@ -41,6 +41,9 @@ |
@@ -41,6 +41,7 @@ |
165 |
#include <asm/system.h> |
#include <asm/system.h> |
166 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
167 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
168 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
169 |
|
|
170 |
#ifdef CONFIG_COMPAT |
#ifdef CONFIG_COMPAT |
171 |
#include "compat_ptrace.h" |
#include "compat_ptrace.h" |
172 |
@@ -711,6 +714,10 @@ sys_ptrace(long request, long pid, long |
@@ -711,6 +712,8 @@ sys_ptrace(long request, long pid, long |
173 |
struct task_struct *child; |
struct task_struct *child; |
174 |
int ret; |
int ret; |
175 |
|
|
176 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
177 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
178 |
lock_kernel(); |
lock_kernel(); |
179 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
180 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
181 |
--- linux-2.6.18-24.orig/arch/sparc/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/sparc/kernel/ptrace.c |
182 |
+++ linux-2.6.18-24/arch/sparc/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/sparc/kernel/ptrace.c |
183 |
@@ -23,6 +23,9 @@ |
@@ -23,6 +23,7 @@ |
184 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
185 |
#include <asm/system.h> |
#include <asm/system.h> |
186 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
187 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
188 |
|
|
189 |
#define MAGIC_CONSTANT 0x80000000 |
#define MAGIC_CONSTANT 0x80000000 |
190 |
|
|
191 |
@@ -267,6 +270,12 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -267,6 +268,10 @@ asmlinkage void do_ptrace(struct pt_regs |
192 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
193 |
struct task_struct *child; |
struct task_struct *child; |
194 |
int ret; |
int ret; |
195 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) { |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
|
196 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
197 |
+ return; |
+ return; |
198 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
199 |
|
|
200 |
lock_kernel(); |
lock_kernel(); |
201 |
#ifdef DEBUG_PTRACE |
#ifdef DEBUG_PTRACE |
202 |
--- linux-2.6.18-24.orig/arch/sparc64/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/arch/sparc64/kernel/ptrace.c |
203 |
+++ linux-2.6.18-24/arch/sparc64/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/arch/sparc64/kernel/ptrace.c |
204 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
205 |
#include <asm/spitfire.h> |
#include <asm/spitfire.h> |
206 |
#include <asm/page.h> |
#include <asm/page.h> |
207 |
#include <asm/cpudata.h> |
#include <asm/cpudata.h> |
208 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
209 |
|
|
210 |
/* Returning from ptrace is a bit tricky because the syscall return |
/* Returning from ptrace is a bit tricky because the syscall return |
211 |
* low level code assumes any value returned which is negative and |
* low level code assumes any value returned which is negative and |
212 |
@@ -176,6 +179,12 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -176,6 +177,10 @@ asmlinkage void do_ptrace(struct pt_regs |
213 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
214 |
struct task_struct *child; |
struct task_struct *child; |
215 |
int ret; |
int ret; |
216 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) { |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
|
217 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
218 |
+ return; |
+ return; |
219 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
220 |
|
|
221 |
if (test_thread_flag(TIF_32BIT)) { |
if (test_thread_flag(TIF_32BIT)) { |
222 |
addr &= 0xffffffffUL; |
addr &= 0xffffffffUL; |
223 |
--- linux-2.6.18-24.orig/arch/x86_64/ia32/ptrace32.c |
--- linux-2.6.18-26etch2.orig/arch/x86_64/ia32/ptrace32.c |
224 |
+++ linux-2.6.18-24/arch/x86_64/ia32/ptrace32.c |
+++ linux-2.6.18-26etch2/arch/x86_64/ia32/ptrace32.c |
225 |
@@ -26,6 +26,9 @@ |
@@ -26,6 +26,7 @@ |
226 |
#include <asm/i387.h> |
#include <asm/i387.h> |
227 |
#include <asm/fpu32.h> |
#include <asm/fpu32.h> |
228 |
#include <asm/ia32.h> |
#include <asm/ia32.h> |
229 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
230 |
|
|
231 |
/* |
/* |
232 |
* 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]. |
233 |
@@ -230,6 +233,10 @@ asmlinkage long sys32_ptrace(long reques |
@@ -230,6 +231,8 @@ asmlinkage long sys32_ptrace(long reques |
234 |
void __user *datap = compat_ptr(data); |
void __user *datap = compat_ptr(data); |
235 |
int ret; |
int ret; |
236 |
__u32 val; |
__u32 val; |
237 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
238 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
239 |
|
|
240 |
switch (request) { |
switch (request) { |
241 |
case PTRACE_TRACEME: |
case PTRACE_TRACEME: |
242 |
--- linux-2.6.18-24.orig/fs/Kconfig |
--- linux-2.6.18-26etch2.orig/fs/compat.c |
243 |
+++ linux-2.6.18-24/fs/Kconfig |
+++ linux-2.6.18-26etch2/fs/compat.c |
244 |
@@ -1931,5 +1931,7 @@ endmenu |
@@ -52,6 +52,7 @@ |
|
|
|
|
source "fs/nls/Kconfig" |
|
|
|
|
|
+source "fs/Kconfig.ccs" |
|
|
+ |
|
|
endmenu |
|
|
|
|
|
--- linux-2.6.18-24.orig/fs/Makefile |
|
|
+++ linux-2.6.18-24/fs/Makefile |
|
|
@@ -102,3 +102,5 @@ obj-$(CONFIG_HOSTFS) += hostfs/ |
|
|
obj-$(CONFIG_HPPFS) += hppfs/ |
|
|
obj-$(CONFIG_DEBUG_FS) += debugfs/ |
|
|
obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
|
|
+ |
|
|
+include $(srctree)/fs/Makefile-2.6.ccs |
|
|
--- linux-2.6.18-24.orig/fs/attr.c |
|
|
+++ linux-2.6.18-24/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)) |
|
|
--- linux-2.6.18-24.orig/fs/compat.c |
|
|
+++ linux-2.6.18-24/fs/compat.c |
|
|
@@ -52,6 +52,9 @@ |
|
245 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
246 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
247 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
248 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
249 |
|
|
250 |
extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
251 |
|
|
252 |
@@ -397,6 +400,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
@@ -397,6 +398,8 @@ asmlinkage long compat_sys_ioctl(unsigne |
253 |
|
|
254 |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
/* RED-PEN how should LSM module know it's handling 32bit? */ |
255 |
error = security_file_ioctl(filp, cmd, arg); |
error = security_file_ioctl(filp, cmd, arg); |
|
+ /***** TOMOYO Linux start. *****/ |
|
256 |
+ if (!error) |
+ if (!error) |
257 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
|
+ /***** TOMOYO Linux end. *****/ |
|
258 |
if (error) |
if (error) |
259 |
goto out_fput; |
goto out_fput; |
260 |
|
|
261 |
@@ -421,6 +428,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
@@ -421,6 +424,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
262 |
/*FALL THROUGH*/ |
/*FALL THROUGH*/ |
263 |
|
|
264 |
default: |
default: |
|
+ /***** TOMOYO Linux start. *****/ |
|
265 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
266 |
+ error = -EPERM; |
+ error = -EPERM; |
267 |
+ goto out_fput; |
+ goto out_fput; |
268 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
269 |
if (filp->f_op && filp->f_op->compat_ioctl) { |
if (filp->f_op && filp->f_op->compat_ioctl) { |
270 |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
error = filp->f_op->compat_ioctl(filp, cmd, arg); |
271 |
if (error != -ENOIOCTLCMD) |
if (error != -ENOIOCTLCMD) |
272 |
@@ -1567,7 +1580,7 @@ int compat_do_execve(char * filename, |
@@ -1567,7 +1574,7 @@ int compat_do_execve(char * filename, |
273 |
if (retval < 0) |
if (retval < 0) |
274 |
goto out; |
goto out; |
275 |
|
|
276 |
- retval = search_binary_handler(bprm, regs); |
- retval = search_binary_handler(bprm, regs); |
277 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
278 |
if (retval >= 0) { |
if (retval >= 0) { |
279 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
280 |
|
|
281 |
--- linux-2.6.18-24.orig/fs/exec.c |
--- linux-2.6.18-26etch2.orig/fs/exec.c |
282 |
+++ linux-2.6.18-24/fs/exec.c |
+++ linux-2.6.18-26etch2/fs/exec.c |
283 |
@@ -57,6 +57,10 @@ |
@@ -57,6 +57,8 @@ |
284 |
#include <linux/kmod.h> |
#include <linux/kmod.h> |
285 |
#endif |
#endif |
286 |
|
|
287 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
288 |
+ |
+ |
289 |
int core_uses_pid; |
int core_uses_pid; |
290 |
char core_pattern[65] = "core"; |
char core_pattern[65] = "core"; |
291 |
int suid_dumpable = 0; |
int suid_dumpable = 0; |
292 |
@@ -139,6 +143,13 @@ asmlinkage long sys_uselib(const char __ |
@@ -139,6 +141,10 @@ asmlinkage long sys_uselib(const char __ |
293 |
if (error) |
if (error) |
294 |
goto exit; |
goto exit; |
295 |
|
|
296 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_uselib_permission(nd.dentry, nd.mnt); |
|
+ /* 01 means "read". */ |
|
|
+ error = ccs_check_open_permission(nd.dentry, nd.mnt, 01); |
|
297 |
+ if (error) |
+ if (error) |
298 |
+ goto exit; |
+ goto exit; |
|
+ /***** TOMOYO Linux end. *****/ |
|
299 |
+ |
+ |
300 |
file = nameidata_to_filp(&nd, O_RDONLY); |
file = nameidata_to_filp(&nd, O_RDONLY); |
301 |
error = PTR_ERR(file); |
error = PTR_ERR(file); |
302 |
if (IS_ERR(file)) |
if (IS_ERR(file)) |
303 |
@@ -486,6 +497,13 @@ struct file *open_exec(const char *name) |
@@ -486,6 +492,9 @@ struct file *open_exec(const char *name) |
304 |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
305 |
S_ISREG(inode->i_mode)) { |
S_ISREG(inode->i_mode)) { |
306 |
int err = vfs_permission(&nd, MAY_EXEC); |
int err = vfs_permission(&nd, MAY_EXEC); |
307 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!err) |
308 |
+ if (!err && (current->ccs_flags & |
+ err = ccs_open_exec_permission(nd.dentry, |
309 |
+ CCS_CHECK_READ_FOR_OPEN_EXEC)) |
+ nd.mnt); |
|
+ /* 01 means "read". */ |
|
|
+ err = ccs_check_open_permission(nd.dentry, |
|
|
+ nd.mnt, 01); |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
310 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
311 |
if (!err) { |
if (!err) { |
312 |
file = nameidata_to_filp(&nd, O_RDONLY); |
file = nameidata_to_filp(&nd, O_RDONLY); |
313 |
@@ -1188,7 +1206,8 @@ int do_execve(char * filename, |
@@ -1188,7 +1197,8 @@ int do_execve(char * filename, |
314 |
if (retval < 0) |
if (retval < 0) |
315 |
goto out; |
goto out; |
316 |
|
|
317 |
- retval = search_binary_handler(bprm,regs); |
- retval = search_binary_handler(bprm,regs); |
318 |
+ retval = search_binary_handler_with_transition(bprm, regs); |
+ retval = ccs_search_binary_handler(bprm, regs); |
319 |
+ |
+ |
320 |
if (retval >= 0) { |
if (retval >= 0) { |
321 |
free_arg_pages(bprm); |
free_arg_pages(bprm); |
322 |
|
|
323 |
--- linux-2.6.18-24.orig/fs/fcntl.c |
--- linux-2.6.18-26etch2.orig/fs/fcntl.c |
324 |
+++ linux-2.6.18-24/fs/fcntl.c |
+++ linux-2.6.18-26etch2/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 |
@@ -214,6 +217,12 @@ static int setfl(int fd, struct file * f |
@@ -214,6 +215,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.18-24.orig/fs/ioctl.c |
--- linux-2.6.18-26etch2.orig/fs/ioctl.c |
344 |
+++ linux-2.6.18-24/fs/ioctl.c |
+++ linux-2.6.18-26etch2/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.18-24.orig/fs/namei.c |
--- linux-2.6.18-26etch2.orig/fs/namei.c |
363 |
+++ linux-2.6.18-24/fs/namei.c |
+++ linux-2.6.18-26etch2/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 |
@@ -1536,6 +1540,13 @@ int may_open(struct nameidata *nd, int a |
@@ -1536,6 +1538,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 |
@@ -1567,6 +1578,9 @@ int may_open(struct nameidata *nd, int a |
@@ -1650,6 +1657,9 @@ do_last: |
|
return 0; |
|
|
} |
|
|
|
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo_vfs.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
/* |
|
|
* open_namei() |
|
|
* |
|
|
@@ -1650,6 +1664,11 @@ do_last: |
|
386 |
if (!path.dentry->d_inode) { |
if (!path.dentry->d_inode) { |
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, |
390 |
+ error = ccs_check_mknod_permission(dir->d_inode, path.dentry, |
+ nd->mnt, mode, 0); |
|
+ nd->path.mnt, 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 |
@@ -1848,6 +1867,12 @@ asmlinkage long sys_mknodat(int dfd, con |
@@ -1848,6 +1858,9 @@ 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.path.dentry->d_inode, |
+ nd.mnt, mode, dev); |
|
+ dentry, nd.path.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 |
@@ -1921,6 +1946,12 @@ asmlinkage long sys_mkdirat(int dfd, con |
@@ -1921,6 +1934,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
406 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
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, |
410 |
+ error = ccs_check_mkdir_permission(nd.dentry->d_inode, |
+ dentry, nd.mnt, mode); |
|
+ dentry, nd.mnt, |
|
|
+ mode); |
|
411 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
412 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
413 |
dput(dentry); |
dput(dentry); |
414 |
} |
} |
415 |
@@ -2029,6 +2060,11 @@ static long do_rmdir(int dfd, const char |
@@ -2029,6 +2045,9 @@ static long do_rmdir(int dfd, const char |
416 |
dentry = lookup_hash(&nd); |
dentry = lookup_hash(&nd); |
417 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
418 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
419 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, |
420 |
+ error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry, |
+ nd.mnt); |
|
+ nd.mnt); |
|
421 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
422 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
423 |
dput(dentry); |
dput(dentry); |
424 |
} |
} |
425 |
@@ -2109,6 +2145,11 @@ static long do_unlinkat(int dfd, const c |
@@ -2109,6 +2128,9 @@ static long do_unlinkat(int dfd, const c |
426 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
427 |
if (inode) |
if (inode) |
428 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
429 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_unlink_permission(nd.dentry->d_inode, dentry, |
430 |
+ error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry, |
+ nd.mnt); |
|
+ nd.mnt); |
|
431 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
432 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
433 |
exit2: |
exit2: |
434 |
dput(dentry); |
dput(dentry); |
435 |
@@ -2187,6 +2228,12 @@ asmlinkage long sys_symlinkat(const char |
@@ -2187,6 +2209,9 @@ asmlinkage long sys_symlinkat(const char |
436 |
dentry = lookup_create(&nd, 0); |
dentry = lookup_create(&nd, 0); |
437 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
438 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
439 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_symlink_permission(nd.dentry->d_inode, |
440 |
+ error = ccs_check_symlink_permission(nd.dentry->d_inode, |
+ dentry, nd.mnt, from); |
|
+ dentry, nd.mnt, |
|
|
+ from); |
|
441 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
442 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
443 |
dput(dentry); |
dput(dentry); |
444 |
} |
} |
445 |
@@ -2281,6 +2328,12 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2281,6 +2306,9 @@ asmlinkage long sys_linkat(int olddfd, c |
446 |
new_dentry = lookup_create(&nd, 0); |
new_dentry = lookup_create(&nd, 0); |
447 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
448 |
if (!IS_ERR(new_dentry)) { |
if (!IS_ERR(new_dentry)) { |
449 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode, |
450 |
+ error = ccs_check_link_permission(old_nd.dentry, |
+ new_dentry, nd.mnt); |
|
+ nd.dentry->d_inode, |
|
|
+ new_dentry, nd.mnt); |
|
451 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
452 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
453 |
dput(new_dentry); |
dput(new_dentry); |
454 |
} |
} |
455 |
@@ -2507,6 +2560,13 @@ static int do_rename(int olddfd, const c |
@@ -2507,6 +2535,9 @@ static int do_rename(int olddfd, const c |
456 |
if (new_dentry == trap) |
if (new_dentry == trap) |
457 |
goto exit5; |
goto exit5; |
458 |
|
|
459 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
460 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
+ new_dir->d_inode, new_dentry, newnd.mnt); |
|
+ new_dir->d_inode, new_dentry, |
|
|
+ newnd.mnt); |
|
461 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ |
|
462 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
error = vfs_rename(old_dir->d_inode, old_dentry, |
463 |
new_dir->d_inode, new_dentry); |
new_dir->d_inode, new_dentry); |
464 |
exit5: |
exit5: |
465 |
--- linux-2.6.18-24.orig/fs/namespace.c |
--- linux-2.6.18-26etch2.orig/fs/namespace.c |
466 |
+++ linux-2.6.18-24/fs/namespace.c |
+++ linux-2.6.18-26etch2/fs/namespace.c |
467 |
@@ -25,6 +25,12 @@ |
@@ -25,6 +25,7 @@ |
468 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
469 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
470 |
#include "pnode.h" |
#include "pnode.h" |
471 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
472 |
|
|
473 |
extern int __init init_rootfs(void); |
extern int __init init_rootfs(void); |
474 |
|
|
475 |
@@ -553,6 +559,11 @@ static int do_umount(struct vfsmount *mn |
@@ -550,6 +551,8 @@ static int do_umount(struct vfsmount *mn |
476 |
|
LIST_HEAD(umount_list); |
477 |
|
|
478 |
|
retval = security_sb_umount(mnt, flags); |
479 |
|
+ if (!retval) |
480 |
|
+ retval = ccs_umount_permission(mnt, flags); |
481 |
if (retval) |
if (retval) |
482 |
return retval; |
return retval; |
483 |
|
|
484 |
+ /***** SAKURA Linux start. *****/ |
@@ -1384,6 +1387,7 @@ int copy_mount_options(const void __user |
485 |
+ if (ccs_may_umount(mnt)) |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
486 |
+ 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: |
|
|
@@ -641,6 +652,10 @@ asmlinkage long sys_umount(char __user * |
|
487 |
{ |
{ |
488 |
|
+ const unsigned long original_flags = flags; |
489 |
struct nameidata nd; |
struct nameidata nd; |
490 |
int retval; |
int retval = 0; |
491 |
+ /***** TOMOYO Linux start. *****/ |
int mnt_flags = 0; |
492 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
@@ -1423,6 +1427,9 @@ long do_mount(char *dev_name, char *dir_ |
493 |
+ return -EPERM; |
return retval; |
|
+ /***** TOMOYO Linux end. *****/ |
|
494 |
|
|
495 |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
496 |
|
+ if (!retval) |
497 |
|
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
498 |
|
+ original_flags, data_page); |
499 |
if (retval) |
if (retval) |
500 |
@@ -925,6 +940,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) |
|
|
@@ -1009,7 +1029,11 @@ static int do_move_mount(struct nameidat |
|
|
err = -EINVAL; |
|
|
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)) |
|
|
@@ -1111,6 +1135,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))) |
|
|
@@ -1402,6 +1431,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; |
|
|
@@ -1691,6 +1731,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. *****/ |
|
|
|
|
|
lock_kernel(); |
|
501 |
|
|
502 |
@@ -1707,6 +1751,10 @@ asmlinkage long sys_pivot_root(const cha |
@@ -1707,6 +1714,8 @@ asmlinkage long sys_pivot_root(const cha |
503 |
goto out1; |
goto out1; |
504 |
|
|
505 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
error = security_sb_pivotroot(&old_nd, &new_nd); |
|
+ /***** SAKURA Linux start. *****/ |
|
506 |
+ if (!error) |
+ if (!error) |
507 |
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
|
+ /***** SAKURA Linux end. *****/ |
|
508 |
if (error) { |
if (error) { |
509 |
path_release(&old_nd); |
path_release(&old_nd); |
510 |
goto out1; |
goto out1; |
511 |
--- linux-2.6.18-24.orig/fs/open.c |
--- linux-2.6.18-26etch2.orig/fs/open.c |
512 |
+++ linux-2.6.18-24/fs/open.c |
+++ linux-2.6.18-26etch2/fs/open.c |
513 |
@@ -30,6 +30,12 @@ |
@@ -30,6 +30,7 @@ |
514 |
#include <linux/audit.h> |
#include <linux/audit.h> |
515 |
|
|
516 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
517 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
518 |
|
|
519 |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
520 |
{ |
{ |
521 |
@@ -267,6 +273,10 @@ static long do_sys_truncate(const char _ |
@@ -267,6 +268,8 @@ static long do_sys_truncate(const char _ |
522 |
if (error) |
if (error) |
523 |
goto dput_and_out; |
goto dput_and_out; |
524 |
|
|
525 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_truncate_permission(nd.dentry, nd.mnt); |
|
+ error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0); |
|
526 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
527 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
528 |
if (!error) { |
if (!error) { |
529 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
530 |
@@ -320,6 +330,12 @@ static long do_sys_ftruncate(unsigned in |
@@ -320,6 +323,9 @@ static long do_sys_ftruncate(unsigned in |
531 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
532 |
goto out_putf; |
goto out_putf; |
533 |
|
|
534 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt); |
|
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
|
|
+ 0); |
|
535 |
+ if (error) |
+ if (error) |
536 |
+ goto out_putf; |
+ goto out_putf; |
|
+ /***** TOMOYO Linux end. *****/ |
|
537 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
538 |
if (!error) |
if (!error) |
539 |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
540 |
@@ -608,6 +624,14 @@ asmlinkage long sys_chroot(const char __ |
@@ -608,6 +614,8 @@ asmlinkage long sys_chroot(const char __ |
541 |
error = -EPERM; |
error = -EPERM; |
542 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
543 |
goto dput_and_out; |
goto dput_and_out; |
544 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_chroot_permission(&nd)) |
|
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
|
545 |
+ goto dput_and_out; |
+ goto dput_and_out; |
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ /***** SAKURA Linux start. *****/ |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
|
|
+ goto dput_and_out; |
|
|
+ /***** SAKURA Linux end. *****/ |
|
546 |
|
|
547 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
548 |
set_fs_altroot(); |
set_fs_altroot(); |
549 |
@@ -1199,6 +1223,10 @@ EXPORT_SYMBOL(sys_close); |
@@ -641,6 +649,9 @@ asmlinkage long sys_fchmod(unsigned int |
550 |
|
err = -EPERM; |
551 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
552 |
|
goto out_putf; |
553 |
|
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
554 |
|
+ if (err) |
555 |
|
+ goto out_putf; |
556 |
|
mutex_lock(&inode->i_mutex); |
557 |
|
if (mode == (mode_t) -1) |
558 |
|
mode = inode->i_mode; |
559 |
|
@@ -675,6 +686,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
560 |
|
error = -EPERM; |
561 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
562 |
|
goto dput_and_out; |
563 |
|
+ error = ccs_chmod_permission(nd.dentry, nd.mnt, mode); |
564 |
|
+ if (error) |
565 |
|
+ goto dput_and_out; |
566 |
|
|
567 |
|
mutex_lock(&inode->i_mutex); |
568 |
|
if (mode == (mode_t) -1) |
569 |
|
@@ -737,6 +751,8 @@ asmlinkage long sys_chown(const char __u |
570 |
|
|
571 |
|
error = user_path_walk(filename, &nd); |
572 |
|
if (!error) { |
573 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
574 |
|
+ if (!error) |
575 |
|
error = chown_common(nd.dentry, user, group); |
576 |
|
path_release(&nd); |
577 |
|
} |
578 |
|
@@ -756,6 +772,8 @@ asmlinkage long sys_fchownat(int dfd, co |
579 |
|
follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
580 |
|
error = __user_walk_fd(dfd, filename, follow, &nd); |
581 |
|
if (!error) { |
582 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
583 |
|
+ if (!error) |
584 |
|
error = chown_common(nd.dentry, user, group); |
585 |
|
path_release(&nd); |
586 |
|
} |
587 |
|
@@ -770,6 +788,8 @@ asmlinkage long sys_lchown(const char __ |
588 |
|
|
589 |
|
error = user_path_walk_link(filename, &nd); |
590 |
|
if (!error) { |
591 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
592 |
|
+ if (!error) |
593 |
|
error = chown_common(nd.dentry, user, group); |
594 |
|
path_release(&nd); |
595 |
|
} |
596 |
|
@@ -787,6 +807,9 @@ asmlinkage long sys_fchown(unsigned int |
597 |
|
struct dentry * dentry; |
598 |
|
dentry = file->f_dentry; |
599 |
|
audit_inode(NULL, dentry->d_inode); |
600 |
|
+ error = ccs_chown_permission(dentry, file->f_vfsmnt, user, |
601 |
|
+ group); |
602 |
|
+ if (!error) |
603 |
|
error = chown_common(dentry, user, group); |
604 |
|
fput(file); |
605 |
|
} |
606 |
|
@@ -879,7 +902,9 @@ static struct file *do_filp_open(int dfd |
607 |
|
if ((namei_flags+1) & O_ACCMODE) |
608 |
|
namei_flags++; |
609 |
|
|
610 |
|
+ ccs_save_open_mode(flags); |
611 |
|
error = open_namei(dfd, filename, namei_flags, mode, &nd); |
612 |
|
+ ccs_clear_open_mode(); |
613 |
|
if (!error) |
614 |
|
return nameidata_to_filp(&nd, flags); |
615 |
|
|
616 |
|
@@ -1199,6 +1224,8 @@ EXPORT_SYMBOL(sys_close); |
617 |
*/ |
*/ |
618 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
619 |
{ |
{ |
|
+ /***** TOMOYO Linux start. *****/ |
|
620 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
621 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
622 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
623 |
tty_vhangup(current->signal->tty); |
tty_vhangup(current->signal->tty); |
624 |
return 0; |
return 0; |
625 |
--- linux-2.6.18-24.orig/fs/proc/Makefile |
--- linux-2.6.18-26etch2.orig/fs/proc/proc_misc.c |
626 |
+++ linux-2.6.18-24/fs/proc/Makefile |
+++ linux-2.6.18-26etch2/fs/proc/proc_misc.c |
627 |
@@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge |
@@ -723,4 +723,5 @@ void __init proc_misc_init(void) |
|
proc-$(CONFIG_PROC_KCORE) += kcore.o |
|
|
proc-$(CONFIG_PROC_VMCORE) += vmcore.o |
|
|
proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o |
|
|
+ |
|
|
+proc-$(CONFIG_SAKURA) += ccs_proc.o |
|
|
+proc-$(CONFIG_TOMOYO) += ccs_proc.o |
|
|
--- linux-2.6.18-24.orig/fs/proc/proc_misc.c |
|
|
+++ linux-2.6.18-24/fs/proc/proc_misc.c |
|
|
@@ -723,4 +723,9 @@ void __init proc_misc_init(void) |
|
628 |
if (entry) |
if (entry) |
629 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
entry->proc_fops = &proc_sysrq_trigger_operations; |
630 |
#endif |
#endif |
631 |
+ /***** CCS start. *****/ |
+ printk(KERN_INFO "Hook version: 2.6.18-26etch2 2010/08/23\n"); |
|
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
|
|
+ printk(KERN_INFO "Hook version: 2.6.18-23etch1 2009/03/18\n"); |
|
|
+#endif |
|
|
+ /***** CCS end. *****/ |
|
632 |
} |
} |
633 |
--- linux-2.6.18-24.orig/include/linux/init_task.h |
--- linux-2.6.18-26etch2.orig/include/linux/init_task.h |
634 |
+++ linux-2.6.18-24/include/linux/init_task.h |
+++ linux-2.6.18-26etch2/include/linux/init_task.h |
635 |
@@ -128,6 +128,10 @@ extern struct group_info init_groups; |
@@ -76,6 +76,14 @@ |
636 |
|
|
637 |
|
extern struct group_info init_groups; |
638 |
|
|
639 |
|
+#ifdef CONFIG_CCSECURITY |
640 |
|
+#define INIT_CCSECURITY \ |
641 |
|
+ .ccs_domain_info = NULL, \ |
642 |
|
+ .ccs_flags = 0, |
643 |
|
+#else |
644 |
|
+#define INIT_CCSECURITY |
645 |
|
+#endif |
646 |
|
+ |
647 |
|
/* |
648 |
|
* INIT_TASK is used to set up the first task table, touch at |
649 |
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
650 |
|
@@ -128,6 +136,7 @@ extern struct group_info init_groups; |
651 |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
.pi_lock = SPIN_LOCK_UNLOCKED, \ |
652 |
INIT_TRACE_IRQFLAGS \ |
INIT_TRACE_IRQFLAGS \ |
653 |
INIT_LOCKDEP \ |
INIT_LOCKDEP \ |
654 |
+ /***** TOMOYO Linux start. *****/ \ |
+ INIT_CCSECURITY \ |
|
+ .ccs_domain_info = NULL, \ |
|
|
+ .ccs_flags = 0, \ |
|
|
+ /***** TOMOYO Linux end. *****/ \ |
|
655 |
} |
} |
656 |
|
|
657 |
|
|
658 |
--- linux-2.6.18-24.orig/include/linux/sched.h |
--- linux-2.6.18-26etch2.orig/include/linux/sched.h |
659 |
+++ linux-2.6.18-24/include/linux/sched.h |
+++ linux-2.6.18-26etch2/include/linux/sched.h |
660 |
@@ -25,6 +25,10 @@ |
@@ -35,6 +35,8 @@ |
661 |
#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ |
|
662 |
#define CLONE_STOPPED 0x02000000 /* Start in stopped state */ |
#ifdef __KERNEL__ |
663 |
|
|
|
+/***** TOMOYO Linux start. *****/ |
|
664 |
+struct ccs_domain_info; |
+struct ccs_domain_info; |
|
+/***** TOMOYO Linux end. *****/ |
|
665 |
+ |
+ |
666 |
/* |
struct sched_param { |
667 |
* Scheduling policies |
int sched_priority; |
668 |
*/ |
}; |
669 |
@@ -996,6 +1000,10 @@ struct task_struct { |
@@ -996,6 +998,10 @@ struct task_struct { |
670 |
#ifdef CONFIG_TASK_DELAY_ACCT |
#ifdef CONFIG_TASK_DELAY_ACCT |
671 |
struct task_delay_info *delays; |
struct task_delay_info *delays; |
672 |
#endif |
#endif |
673 |
+ /***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
674 |
+ struct ccs_domain_info *ccs_domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
675 |
+ u32 ccs_flags; |
+ u32 ccs_flags; |
676 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
677 |
}; |
}; |
678 |
|
|
679 |
static inline pid_t process_group(struct task_struct *tsk) |
static inline pid_t process_group(struct task_struct *tsk) |
680 |
--- linux-2.6.18-24.orig/kernel/compat.c |
--- linux-2.6.18-26etch2.orig/kernel/compat.c |
681 |
+++ linux-2.6.18-24/kernel/compat.c |
+++ linux-2.6.18-26etch2/kernel/compat.c |
682 |
@@ -24,6 +24,9 @@ |
@@ -24,6 +24,7 @@ |
683 |
#include <linux/migrate.h> |
#include <linux/migrate.h> |
684 |
|
|
685 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
686 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
687 |
|
|
688 |
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) |
689 |
{ |
{ |
690 |
@@ -836,6 +839,10 @@ asmlinkage long compat_sys_stime(compat_ |
@@ -836,6 +837,8 @@ asmlinkage long compat_sys_stime(compat_ |
691 |
err = security_settime(&tv, NULL); |
err = security_settime(&tv, NULL); |
692 |
if (err) |
if (err) |
693 |
return err; |
return err; |
|
+ /***** TOMOYO Linux start. *****/ |
|
694 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
695 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
696 |
|
|
697 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
698 |
return 0; |
return 0; |
699 |
--- linux-2.6.18-24.orig/kernel/kexec.c |
--- linux-2.6.18-26etch2.orig/kernel/kexec.c |
700 |
+++ linux-2.6.18-24/kernel/kexec.c |
+++ linux-2.6.18-26etch2/kernel/kexec.c |
701 |
@@ -26,6 +26,9 @@ |
@@ -26,6 +26,7 @@ |
702 |
#include <asm/io.h> |
#include <asm/io.h> |
703 |
#include <asm/system.h> |
#include <asm/system.h> |
704 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
705 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
706 |
|
|
707 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
/* Per cpu memory for storing cpu states in case of system crash. */ |
708 |
note_buf_t* crash_notes; |
note_buf_t* crash_notes; |
709 |
@@ -922,6 +925,10 @@ asmlinkage long sys_kexec_load(unsigned |
@@ -922,6 +923,8 @@ asmlinkage long sys_kexec_load(unsigned |
710 |
/* We only trust the superuser with rebooting the system. */ |
/* We only trust the superuser with rebooting the system. */ |
711 |
if (!capable(CAP_SYS_BOOT)) |
if (!capable(CAP_SYS_BOOT)) |
712 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
713 |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
714 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
715 |
|
|
716 |
/* |
/* |
717 |
* Verify we have a legal set of flags |
* Verify we have a legal set of flags |
718 |
--- linux-2.6.18-24.orig/kernel/kmod.c |
--- linux-2.6.18-26etch2.orig/kernel/kmod.c |
719 |
+++ linux-2.6.18-24/kernel/kmod.c |
+++ linux-2.6.18-26etch2/kernel/kmod.c |
720 |
@@ -148,6 +148,11 @@ static int ____call_usermodehelper(void |
@@ -148,6 +148,11 @@ static int ____call_usermodehelper(void |
721 |
/* We can run anywhere, unlike our parent keventd(). */ |
/* We can run anywhere, unlike our parent keventd(). */ |
722 |
set_cpus_allowed(current, CPU_MASK_ALL); |
set_cpus_allowed(current, CPU_MASK_ALL); |
723 |
|
|
724 |
+ /***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
725 |
+ current->ccs_domain_info = NULL; |
+ current->ccs_domain_info = NULL; |
726 |
+ current->ccs_flags = 0; |
+ current->ccs_flags = 0; |
727 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
728 |
+ |
+ |
729 |
retval = -EPERM; |
retval = -EPERM; |
730 |
if (current->fs->root) |
if (current->fs->root) |
731 |
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
732 |
--- linux-2.6.18-24.orig/kernel/module.c |
--- linux-2.6.18-26etch2.orig/kernel/module.c |
733 |
+++ linux-2.6.18-24/kernel/module.c |
+++ linux-2.6.18-26etch2/kernel/module.c |
734 |
@@ -44,6 +44,9 @@ |
@@ -44,6 +44,7 @@ |
735 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
736 |
#include <asm/cacheflush.h> |
#include <asm/cacheflush.h> |
737 |
#include <linux/license.h> |
#include <linux/license.h> |
738 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
739 |
|
|
740 |
#if 0 |
#if 0 |
741 |
#define DEBUGP printk |
#define DEBUGP printk |
742 |
@@ -652,7 +655,10 @@ sys_delete_module(const char __user *nam |
@@ -652,7 +653,8 @@ sys_delete_module(const char __user *nam |
743 |
|
|
744 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
745 |
return -EPERM; |
return -EPERM; |
746 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
747 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
748 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
749 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
750 |
return -EFAULT; |
return -EFAULT; |
751 |
name[MODULE_NAME_LEN-1] = '\0'; |
name[MODULE_NAME_LEN-1] = '\0'; |
752 |
@@ -1884,7 +1890,10 @@ sys_init_module(void __user *umod, |
@@ -1884,7 +1886,8 @@ sys_init_module(void __user *umod, |
753 |
/* Must have permission */ |
/* Must have permission */ |
754 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
755 |
return -EPERM; |
return -EPERM; |
756 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
757 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
758 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
759 |
/* Only one module load at a time, please */ |
/* Only one module load at a time, please */ |
760 |
if (mutex_lock_interruptible(&module_mutex) != 0) |
if (mutex_lock_interruptible(&module_mutex) != 0) |
761 |
return -EINTR; |
return -EINTR; |
762 |
--- linux-2.6.18-24.orig/kernel/ptrace.c |
--- linux-2.6.18-26etch2.orig/kernel/ptrace.c |
763 |
+++ linux-2.6.18-24/kernel/ptrace.c |
+++ linux-2.6.18-26etch2/kernel/ptrace.c |
764 |
@@ -21,6 +21,9 @@ |
@@ -21,6 +21,7 @@ |
765 |
|
|
766 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
767 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
768 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
769 |
|
|
770 |
/* |
/* |
771 |
* ptrace a task: make the debugger its new parent and |
* ptrace a task: make the debugger its new parent and |
772 |
@@ -509,6 +512,10 @@ asmlinkage long sys_ptrace(long request, |
@@ -509,6 +510,8 @@ asmlinkage long sys_ptrace(long request, |
773 |
/* |
/* |
774 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
775 |
*/ |
*/ |
776 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_ptrace_permission(request, pid)) |
|
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
|
777 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
778 |
lock_kernel(); |
lock_kernel(); |
779 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
780 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
781 |
--- linux-2.6.18-24.orig/kernel/sched.c |
--- linux-2.6.18-26etch2.orig/kernel/sched.c |
782 |
+++ linux-2.6.18-24/kernel/sched.c |
+++ linux-2.6.18-26etch2/kernel/sched.c |
783 |
@@ -55,6 +55,9 @@ |
@@ -55,6 +55,7 @@ |
784 |
#include <asm/tlb.h> |
#include <asm/tlb.h> |
785 |
|
|
786 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
787 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
788 |
|
|
789 |
/* |
/* |
790 |
* Convert user-nice values [ -20 ... 0 ... 19 ] |
* Convert user-nice values [ -20 ... 0 ... 19 ] |
791 |
@@ -3939,6 +3942,10 @@ int can_nice(const struct task_struct *p |
@@ -3939,6 +3940,8 @@ int can_nice(const struct task_struct *p |
792 |
asmlinkage long sys_nice(int increment) |
asmlinkage long sys_nice(int increment) |
793 |
{ |
{ |
794 |
long nice, retval; |
long nice, retval; |
|
+ /***** TOMOYO Linux start. *****/ |
|
795 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
+ if (!ccs_capable(CCS_SYS_NICE)) |
796 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
797 |
|
|
798 |
/* |
/* |
799 |
* Setpriority might change our priority at the same moment. |
* Setpriority might change our priority at the same moment. |
800 |
--- linux-2.6.18-24.orig/kernel/signal.c |
--- linux-2.6.18-26etch2.orig/kernel/signal.c |
801 |
+++ linux-2.6.18-24/kernel/signal.c |
+++ linux-2.6.18-26etch2/kernel/signal.c |
802 |
@@ -28,6 +28,9 @@ |
@@ -28,6 +28,7 @@ |
803 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
804 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
805 |
#include "audit.h" /* audit_signal_info() */ |
#include "audit.h" /* audit_signal_info() */ |
806 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
807 |
|
|
808 |
/* |
/* |
809 |
* SLAB caches for signal bits. |
* SLAB caches for signal bits. |
810 |
@@ -2183,6 +2186,12 @@ asmlinkage long |
@@ -2183,6 +2184,8 @@ asmlinkage long |
811 |
sys_kill(int pid, int sig) |
sys_kill(int pid, int sig) |
812 |
{ |
{ |
813 |
struct siginfo info; |
struct siginfo info; |
814 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_kill_permission(pid, sig)) |
|
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
|
|
+ return -EPERM; |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
|
815 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
816 |
|
|
817 |
info.si_signo = sig; |
info.si_signo = sig; |
818 |
info.si_errno = 0; |
info.si_errno = 0; |
819 |
@@ -2241,6 +2250,12 @@ asmlinkage long sys_tgkill(int tgid, int |
@@ -2241,6 +2244,8 @@ asmlinkage long sys_tgkill(int tgid, int |
820 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
821 |
if (pid <= 0 || tgid <= 0) |
if (pid <= 0 || tgid <= 0) |
822 |
return -EINVAL; |
return -EINVAL; |
823 |
+ /***** 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)) |
|
824 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
825 |
|
|
826 |
return do_tkill(tgid, pid, sig); |
return do_tkill(tgid, pid, sig); |
827 |
} |
} |
828 |
@@ -2254,6 +2269,12 @@ sys_tkill(int pid, int sig) |
@@ -2254,6 +2259,8 @@ sys_tkill(int pid, int sig) |
829 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
830 |
if (pid <= 0) |
if (pid <= 0) |
831 |
return -EINVAL; |
return -EINVAL; |
832 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_tkill_permission(pid, sig)) |
|
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
|
833 |
+ return -EPERM; |
+ return -EPERM; |
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
834 |
|
|
835 |
return do_tkill(0, pid, sig); |
return do_tkill(0, pid, sig); |
836 |
} |
} |
837 |
--- linux-2.6.18-24.orig/kernel/sys.c |
@@ -2271,6 +2278,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
838 |
+++ linux-2.6.18-24/kernel/sys.c |
if (info.si_code >= 0) |
839 |
@@ -36,6 +36,9 @@ |
return -EPERM; |
840 |
|
info.si_signo = sig; |
841 |
|
+ if (ccs_sigqueue_permission(pid, sig)) |
842 |
|
+ return -EPERM; |
843 |
|
|
844 |
|
/* POSIX.1b doesn't mention process groups. */ |
845 |
|
return kill_proc_info(sig, &info, pid); |
846 |
|
--- linux-2.6.18-26etch2.orig/kernel/sys.c |
847 |
|
+++ linux-2.6.18-26etch2/kernel/sys.c |
848 |
|
@@ -36,6 +36,7 @@ |
849 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
850 |
#include <asm/io.h> |
#include <asm/io.h> |
851 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
852 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
853 |
|
|
854 |
#ifndef SET_UNALIGN_CTL |
#ifndef SET_UNALIGN_CTL |
855 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
856 |
@@ -467,6 +470,12 @@ asmlinkage long sys_setpriority(int whic |
@@ -467,6 +468,10 @@ asmlinkage long sys_setpriority(int whic |
857 |
|
|
858 |
if (which > 2 || which < 0) |
if (which > 2 || which < 0) |
859 |
goto out; |
goto out; |
|
+ /***** TOMOYO Linux start. *****/ |
|
860 |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
861 |
+ error = -EPERM; |
+ error = -EPERM; |
862 |
+ goto out; |
+ goto out; |
863 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
864 |
|
|
865 |
/* normalize: avoid signed division (rounding problems) */ |
/* normalize: avoid signed division (rounding problems) */ |
866 |
error = -ESRCH; |
error = -ESRCH; |
867 |
@@ -693,6 +702,10 @@ asmlinkage long sys_reboot(int magic1, i |
@@ -693,6 +698,8 @@ asmlinkage long sys_reboot(int magic1, i |
868 |
magic2 != LINUX_REBOOT_MAGIC2B && |
magic2 != LINUX_REBOOT_MAGIC2B && |
869 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
magic2 != LINUX_REBOOT_MAGIC2C)) |
870 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
871 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
872 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
873 |
|
|
874 |
/* Instead of trying to make the power_off code look like |
/* Instead of trying to make the power_off code look like |
875 |
* 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. |
876 |
@@ -1690,6 +1703,10 @@ asmlinkage long sys_sethostname(char __u |
@@ -1690,6 +1697,8 @@ asmlinkage long sys_sethostname(char __u |
877 |
return -EPERM; |
return -EPERM; |
878 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
879 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
880 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
881 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
882 |
down_write(&uts_sem); |
down_write(&uts_sem); |
883 |
errno = -EFAULT; |
errno = -EFAULT; |
884 |
if (!copy_from_user(tmp, name, len)) { |
if (!copy_from_user(tmp, name, len)) { |
885 |
@@ -1735,6 +1752,10 @@ asmlinkage long sys_setdomainname(char _ |
@@ -1735,6 +1744,8 @@ asmlinkage long sys_setdomainname(char _ |
886 |
return -EPERM; |
return -EPERM; |
887 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
888 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
889 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
890 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
891 |
|
|
892 |
down_write(&uts_sem); |
down_write(&uts_sem); |
893 |
errno = -EFAULT; |
errno = -EFAULT; |
894 |
--- linux-2.6.18-24.orig/kernel/sysctl.c |
--- linux-2.6.18-26etch2.orig/kernel/sysctl.c |
895 |
+++ linux-2.6.18-24/kernel/sysctl.c |
+++ linux-2.6.18-26etch2/kernel/sysctl.c |
896 |
@@ -48,6 +48,9 @@ |
@@ -48,6 +48,7 @@ |
897 |
|
|
898 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
899 |
#include <asm/processor.h> |
#include <asm/processor.h> |
900 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
901 |
|
|
902 |
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, |
903 |
void __user *buffer, size_t *lenp, loff_t *ppos); |
void __user *buffer, size_t *lenp, loff_t *ppos); |
904 |
@@ -1169,6 +1172,11 @@ int do_sysctl(int __user *name, int nlen |
@@ -1169,6 +1170,9 @@ int do_sysctl(int __user *name, int nlen |
905 |
|
|
906 |
spin_unlock(&sysctl_lock); |
spin_unlock(&sysctl_lock); |
907 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
908 |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
909 |
+ head->ctl_table); |
+ head->ctl_table); |
910 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
911 |
error = parse_table(name, nlen, oldval, oldlenp, |
error = parse_table(name, nlen, oldval, oldlenp, |
912 |
newval, newlen, head->ctl_table, |
newval, newlen, head->ctl_table, |
913 |
&context); |
&context); |
914 |
@@ -1241,6 +1249,15 @@ repeat: |
@@ -1241,6 +1245,13 @@ repeat: |
915 |
if (ctl_perm(table, 001)) |
if (ctl_perm(table, 001)) |
916 |
return -EPERM; |
return -EPERM; |
917 |
if (table->strategy) { |
if (table->strategy) { |
|
+ /***** TOMOYO Linux start. *****/ |
|
918 |
+ int op = 0; |
+ int op = 0; |
919 |
+ if (oldval) |
+ if (oldval) |
920 |
+ op |= 004; |
+ op |= 004; |
922 |
+ op |= 002; |
+ op |= 002; |
923 |
+ if (ctl_perm(table, op)) |
+ if (ctl_perm(table, op)) |
924 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
925 |
error = table->strategy( |
error = table->strategy( |
926 |
table, name, nlen, |
table, name, nlen, |
927 |
oldval, oldlenp, |
oldval, oldlenp, |
928 |
--- linux-2.6.18-24.orig/kernel/time.c |
--- linux-2.6.18-26etch2.orig/kernel/time.c |
929 |
+++ linux-2.6.18-24/kernel/time.c |
+++ linux-2.6.18-26etch2/kernel/time.c |
930 |
@@ -39,6 +39,9 @@ |
@@ -39,6 +39,7 @@ |
931 |
|
|
932 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
933 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
934 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
935 |
|
|
936 |
/* |
/* |
937 |
* 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 |
938 |
@@ -91,6 +94,10 @@ asmlinkage long sys_stime(time_t __user |
@@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user |
939 |
err = security_settime(&tv, NULL); |
err = security_settime(&tv, NULL); |
940 |
if (err) |
if (err) |
941 |
return err; |
return err; |
|
+ /***** TOMOYO Linux start. *****/ |
|
942 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
943 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
944 |
|
|
945 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
946 |
return 0; |
return 0; |
947 |
@@ -161,6 +168,10 @@ int do_sys_settimeofday(struct timespec |
@@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec |
948 |
error = security_settime(tv, tz); |
error = security_settime(tv, tz); |
949 |
if (error) |
if (error) |
950 |
return error; |
return error; |
|
+ /***** TOMOYO Linux start. *****/ |
|
951 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
952 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
953 |
|
|
954 |
if (tz) { |
if (tz) { |
955 |
/* SMP safe, global irq locking makes it work. */ |
/* SMP safe, global irq locking makes it work. */ |
956 |
@@ -221,6 +232,10 @@ int do_adjtimex(struct timex *txc) |
@@ -221,6 +226,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 |
|
|
965 |
--- linux-2.6.18-24.orig/net/core/datagram.c |
--- linux-2.6.18-26etch2.orig/net/ipv4/inet_connection_sock.c |
966 |
+++ linux-2.6.18-24/net/core/datagram.c |
+++ linux-2.6.18-26etch2/net/ipv4/inet_connection_sock.c |
967 |
@@ -56,6 +56,11 @@ |
@@ -23,6 +23,7 @@ |
|
#include <net/sock.h> |
|
|
#include <net/tcp_states.h> |
|
|
|
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+#include <linux/tomoyo_socket.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
+ |
|
|
/* |
|
|
* Is a socket 'connection oriented' ? |
|
|
*/ |
|
|
@@ -178,6 +183,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; |
|
|
|
|
|
--- linux-2.6.18-24.orig/net/ipv4/inet_connection_sock.c |
|
|
+++ linux-2.6.18-24/net/ipv4/inet_connection_sock.c |
|
|
@@ -23,6 +23,9 @@ |
|
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 |
@@ -87,6 +90,10 @@ int inet_csk_get_port(struct inet_hashin |
@@ -87,6 +88,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); |
979 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(rover)) |
|
+ if (ccs_may_autobind(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.18-24.orig/net/ipv4/inet_hashtables.c |
--- linux-2.6.18-26etch2.orig/net/ipv4/inet_hashtables.c |
985 |
+++ linux-2.6.18-24/net/ipv4/inet_hashtables.c |
+++ linux-2.6.18-26etch2/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 |
@@ -263,6 +266,10 @@ int inet_hash_connect(struct inet_timewa |
@@ -263,6 +264,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; |
998 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(port)) |
|
+ if (ccs_may_autobind(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.18-24.orig/net/ipv4/udp.c |
--- linux-2.6.18-26etch2.orig/net/ipv4/raw.c |
1004 |
+++ linux-2.6.18-24/net/ipv4/udp.c |
+++ linux-2.6.18-26etch2/net/ipv4/raw.c |
1005 |
@@ -108,6 +108,9 @@ |
@@ -79,6 +79,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 |
|
@@ -589,9 +590,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.18-26etch2.orig/net/ipv4/udp.c |
1032 |
|
+++ linux-2.6.18-26etch2/net/ipv4/udp.c |
1033 |
|
@@ -108,6 +108,7 @@ |
1034 |
#include <net/inet_common.h> |
#include <net/inet_common.h> |
1035 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1036 |
#include <net/xfrm.h> |
#include <net/xfrm.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 |
@@ -146,6 +149,10 @@ static int udp_v4_get_port(struct sock * |
@@ -146,6 +147,8 @@ static int udp_v4_get_port(struct sock * |
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)); |
1045 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1046 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1047 |
goto gotit; |
goto gotit; |
1048 |
} |
} |
1049 |
size = 0; |
size = 0; |
1050 |
@@ -162,6 +169,10 @@ static int udp_v4_get_port(struct sock * |
@@ -162,6 +165,8 @@ static int udp_v4_get_port(struct sock * |
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)); |
1054 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1055 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1056 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1057 |
break; |
break; |
1058 |
} |
} |
1059 |
--- linux-2.6.18-24.orig/net/ipv6/inet6_hashtables.c |
@@ -782,6 +787,7 @@ static int udp_recvmsg(struct kiocb *ioc |
1060 |
+++ linux-2.6.18-24/net/ipv6/inet6_hashtables.c |
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; |
1061 |
@@ -21,6 +21,9 @@ |
struct sk_buff *skb; |
1062 |
|
int copied, err; |
1063 |
|
+ _Bool update_stat; |
1064 |
|
|
1065 |
|
/* |
1066 |
|
* Check any passed addresses |
1067 |
|
@@ -796,7 +802,12 @@ try_again: |
1068 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1069 |
|
if (!skb) |
1070 |
|
goto out; |
1071 |
|
- |
1072 |
|
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1073 |
|
+ update_stat = 0; |
1074 |
|
+ goto csum_copy_err; |
1075 |
|
+ } |
1076 |
|
+ update_stat = 1; |
1077 |
|
+ |
1078 |
|
copied = skb->len - sizeof(struct udphdr); |
1079 |
|
if (copied > len) { |
1080 |
|
copied = len; |
1081 |
|
@@ -844,7 +855,8 @@ out: |
1082 |
|
return err; |
1083 |
|
|
1084 |
|
csum_copy_err: |
1085 |
|
- UDP_INC_STATS_BH(UDP_MIB_INERRORS); |
1086 |
|
+ if (update_stat) |
1087 |
|
+ UDP_INC_STATS_BH(UDP_MIB_INERRORS); |
1088 |
|
|
1089 |
|
skb_kill_datagram(sk, skb, flags); |
1090 |
|
|
1091 |
|
--- linux-2.6.18-26etch2.orig/net/ipv6/inet6_hashtables.c |
1092 |
|
+++ linux-2.6.18-26etch2/net/ipv6/inet6_hashtables.c |
1093 |
|
@@ -21,6 +21,7 @@ |
1094 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1095 |
#include <net/inet6_hashtables.h> |
#include <net/inet6_hashtables.h> |
1096 |
#include <net/ip.h> |
#include <net/ip.h> |
1097 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1098 |
|
|
1099 |
void __inet6_hash(struct inet_hashinfo *hashinfo, |
void __inet6_hash(struct inet_hashinfo *hashinfo, |
1100 |
struct sock *sk) |
struct sock *sk) |
1101 |
@@ -172,7 +175,7 @@ static int __inet6_check_established(str |
@@ -172,7 +173,7 @@ static int __inet6_check_established(str |
1102 |
const struct in6_addr *saddr = &np->daddr; |
const struct in6_addr *saddr = &np->daddr; |
1103 |
const int dif = sk->sk_bound_dev_if; |
const int dif = sk->sk_bound_dev_if; |
1104 |
const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
1107 |
inet->dport); |
inet->dport); |
1108 |
struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); |
struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); |
1109 |
struct sock *sk2; |
struct sock *sk2; |
1110 |
@@ -266,6 +269,10 @@ int inet6_hash_connect(struct inet_timew |
@@ -266,6 +267,8 @@ int inet6_hash_connect(struct inet_timew |
1111 |
local_bh_disable(); |
local_bh_disable(); |
1112 |
for (i = 1; i <= range; i++) { |
for (i = 1; i <= range; i++) { |
1113 |
port = low + (i + offset) % range; |
port = low + (i + offset) % range; |
1114 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(port)) |
|
+ if (ccs_may_autobind(port)) |
|
1115 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1116 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1117 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1118 |
|
|
1119 |
--- linux-2.6.18-24.orig/net/ipv6/udp.c |
--- linux-2.6.18-26etch2.orig/net/ipv6/raw.c |
1120 |
+++ linux-2.6.18-24/net/ipv6/udp.c |
+++ linux-2.6.18-26etch2/net/ipv6/raw.c |
1121 |
@@ -58,6 +58,9 @@ |
@@ -56,6 +56,7 @@ |
1122 |
|
|
1123 |
#include <linux/proc_fs.h> |
#include <linux/proc_fs.h> |
1124 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
1125 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
1126 |
+#include <linux/sakura.h> |
|
1127 |
+/***** SAKURA Linux end. *****/ |
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1128 |
|
DEFINE_RWLOCK(raw_v6_lock); |
1129 |
|
@@ -384,9 +385,14 @@ static int rawv6_recvmsg(struct kiocb *i |
1130 |
|
if (flags & MSG_ERRQUEUE) |
1131 |
|
return ipv6_recv_error(sk, msg, len); |
1132 |
|
|
1133 |
|
- skb = skb_recv_datagram(sk, flags, noblock, &err); |
1134 |
|
- if (!skb) |
1135 |
|
- goto out; |
1136 |
|
+ for (;;) { |
1137 |
|
+ skb = skb_recv_datagram(sk, flags, noblock, &err); |
1138 |
|
+ if (!skb) |
1139 |
|
+ goto out; |
1140 |
|
+ if (!ccs_socket_post_recvmsg_permission(sk, skb)) |
1141 |
|
+ break; |
1142 |
|
+ skb_kill_datagram(sk, skb, flags); |
1143 |
|
+ } |
1144 |
|
|
1145 |
|
copied = skb->len; |
1146 |
|
if (copied > len) { |
1147 |
|
--- linux-2.6.18-26etch2.orig/net/ipv6/udp.c |
1148 |
|
+++ linux-2.6.18-26etch2/net/ipv6/udp.c |
1149 |
|
@@ -58,6 +58,7 @@ |
1150 |
|
|
1151 |
|
#include <linux/proc_fs.h> |
1152 |
|
#include <linux/seq_file.h> |
1153 |
|
+#include <linux/ccsecurity.h> |
1154 |
|
|
1155 |
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
1156 |
|
|
1157 |
@@ -88,6 +91,10 @@ static int udp_v6_get_port(struct sock * |
@@ -88,6 +89,8 @@ static int udp_v6_get_port(struct sock * |
1158 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1159 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1160 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1161 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1162 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1163 |
goto gotit; |
goto gotit; |
1164 |
} |
} |
1165 |
size = 0; |
size = 0; |
1166 |
@@ -104,6 +111,10 @@ static int udp_v6_get_port(struct sock * |
@@ -104,6 +107,8 @@ static int udp_v6_get_port(struct sock * |
1167 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1168 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1169 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1170 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1171 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1172 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1173 |
break; |
break; |
1174 |
} |
} |
1175 |
--- linux-2.6.18-24.orig/net/socket.c |
@@ -226,6 +231,7 @@ static int udpv6_recvmsg(struct kiocb *i |
1176 |
+++ linux-2.6.18-24/net/socket.c |
struct sk_buff *skb; |
1177 |
@@ -94,6 +94,11 @@ |
size_t copied; |
1178 |
|
int err; |
1179 |
|
+ _Bool update_stat; |
1180 |
|
|
1181 |
|
if (addr_len) |
1182 |
|
*addr_len=sizeof(struct sockaddr_in6); |
1183 |
|
@@ -237,6 +243,11 @@ try_again: |
1184 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1185 |
|
if (!skb) |
1186 |
|
goto out; |
1187 |
|
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1188 |
|
+ update_stat = 0; |
1189 |
|
+ goto csum_copy_err; |
1190 |
|
+ } |
1191 |
|
+ update_stat = 1; |
1192 |
|
|
1193 |
|
copied = skb->len - sizeof(struct udphdr); |
1194 |
|
if (copied > len) { |
1195 |
|
@@ -303,7 +314,8 @@ csum_copy_err: |
1196 |
|
skb_kill_datagram(sk, skb, flags); |
1197 |
|
|
1198 |
|
if (flags & MSG_DONTWAIT) { |
1199 |
|
- UDP6_INC_STATS_USER(UDP_MIB_INERRORS); |
1200 |
|
+ if (update_stat) |
1201 |
|
+ UDP6_INC_STATS_USER(UDP_MIB_INERRORS); |
1202 |
|
return -EAGAIN; |
1203 |
|
} |
1204 |
|
goto try_again; |
1205 |
|
--- linux-2.6.18-26etch2.orig/net/socket.c |
1206 |
|
+++ linux-2.6.18-26etch2/net/socket.c |
1207 |
|
@@ -94,6 +94,8 @@ |
1208 |
#include <net/sock.h> |
#include <net/sock.h> |
1209 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1210 |
|
|
1211 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+#include <linux/tomoyo_socket.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1212 |
+ |
+ |
1213 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1214 |
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
1215 |
size_t size, loff_t pos); |
size_t size, loff_t pos); |
1216 |
@@ -592,7 +597,12 @@ static inline int __sock_sendmsg(struct |
@@ -590,9 +592,10 @@ static inline int __sock_sendmsg(struct |
1217 |
|
si->size = size; |
1218 |
|
|
1219 |
err = security_socket_sendmsg(sock, msg, size); |
err = security_socket_sendmsg(sock, msg, size); |
1220 |
|
+ if (!err) |
1221 |
|
+ err = ccs_socket_sendmsg_permission(sock, msg, size); |
1222 |
if (err) |
if (err) |
1223 |
return err; |
return err; |
1224 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (ccs_socket_sendmsg_permission(sock, |
|
|
+ (struct sockaddr *) msg->msg_name, |
|
|
+ msg->msg_namelen)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1225 |
return sock->ops->sendmsg(iocb, sock, msg, size); |
return sock->ops->sendmsg(iocb, sock, msg, size); |
1226 |
} |
} |
1227 |
|
|
1228 |
@@ -1148,6 +1158,12 @@ static int __sock_create(int family, int |
@@ -1149,6 +1152,8 @@ static int __sock_create(int family, int |
|
family = PF_PACKET; |
|
1229 |
} |
} |
1230 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = ccs_socket_create_permission(family, type, protocol); |
|
|
+ if (err) |
|
|
+ return err; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ |
|
1231 |
err = security_socket_create(family, type, protocol, kern); |
err = security_socket_create(family, type, protocol, kern); |
1232 |
|
+ if (!err) |
1233 |
|
+ err = ccs_socket_create_permission(family, type, protocol); |
1234 |
if (err) |
if (err) |
1235 |
return err; |
return err; |
1236 |
@@ -1342,6 +1358,13 @@ asmlinkage long sys_bind(int fd, struct |
|
1237 |
{ |
@@ -1343,6 +1348,11 @@ asmlinkage long sys_bind(int fd, struct |
1238 |
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) { |
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) { |
1239 |
err = security_socket_bind(sock, (struct sockaddr *)address, addrlen); |
err = security_socket_bind(sock, (struct sockaddr *)address, addrlen); |
1240 |
+ /***** TOMOYO Linux start. *****/ |
if (!err) |
|
+ if (!err) |
|
1241 |
+ err = ccs_socket_bind_permission(sock, |
+ err = ccs_socket_bind_permission(sock, |
1242 |
+ (struct sockaddr *) |
+ (struct sockaddr *) |
1243 |
+ address, |
+ address, |
1244 |
+ addrlen); |
+ addrlen); |
1245 |
+ /***** TOMOYO Linux end. *****/ |
+ if (!err) |
|
if (!err) |
|
1246 |
err = sock->ops->bind(sock, |
err = sock->ops->bind(sock, |
1247 |
(struct sockaddr *)address, addrlen); |
(struct sockaddr *)address, addrlen); |
1248 |
@@ -1370,6 +1393,10 @@ asmlinkage long sys_listen(int fd, int b |
} |
1249 |
backlog = sysctl_somaxconn; |
@@ -1371,6 +1381,8 @@ asmlinkage long sys_listen(int fd, int b |
1250 |
|
|
1251 |
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. *****/ |
|
1252 |
if (!err) |
if (!err) |
1253 |
|
+ err = ccs_socket_listen_permission(sock); |
1254 |
|
+ if (!err) |
1255 |
err = sock->ops->listen(sock, backlog); |
err = sock->ops->listen(sock, backlog); |
1256 |
|
|
1257 |
@@ -1434,6 +1461,13 @@ asmlinkage long sys_accept(int fd, struc |
fput_light(sock->file, fput_needed); |
1258 |
|
@@ -1402,6 +1414,7 @@ asmlinkage long sys_accept(int fd, struc |
1259 |
|
if (!sock) |
1260 |
|
goto out; |
1261 |
|
|
1262 |
|
+retry: |
1263 |
|
err = -ENFILE; |
1264 |
|
if (!(newsock = sock_alloc())) |
1265 |
|
goto out_put; |
1266 |
|
@@ -1434,6 +1447,11 @@ asmlinkage long sys_accept(int fd, struc |
1267 |
if (err < 0) |
if (err < 0) |
1268 |
goto out_fd; |
goto out_fd; |
1269 |
|
|
1270 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_socket_post_accept_permission(sock, newsock)) { |
1271 |
+ if (ccs_socket_accept_permission(newsock, |
+ fput(newfile); |
1272 |
+ (struct sockaddr *) address)) { |
+ put_unused_fd(newfd); |
1273 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
+ goto retry; |
|
+ goto out_fd; |
|
1274 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
1275 |
if (upeer_sockaddr) { |
if (upeer_sockaddr) { |
1276 |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
1277 |
err = -ECONNABORTED; |
err = -ECONNABORTED; |
1278 |
@@ -1490,7 +1524,12 @@ asmlinkage long sys_connect(int fd, stru |
@@ -1488,9 +1506,11 @@ asmlinkage long sys_connect(int fd, stru |
1279 |
|
goto out_put; |
1280 |
|
|
1281 |
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1282 |
|
+ if (!err) |
1283 |
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) |
1284 |
|
+ address, addrlen); |
1285 |
if (err) |
if (err) |
1286 |
goto out_put; |
goto out_put; |
1287 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, |
|
|
+ addrlen); |
|
|
+ if (err) |
|
|
+ goto out_put; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1288 |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
1289 |
sock->file->f_flags); |
sock->file->f_flags); |
1290 |
out_put: |
out_put: |
1291 |
--- linux-2.6.18-24.orig/net/unix/af_unix.c |
--- linux-2.6.18-26etch2.orig/net/unix/af_unix.c |
1292 |
+++ linux-2.6.18-24/net/unix/af_unix.c |
+++ linux-2.6.18-26etch2/net/unix/af_unix.c |
1293 |
@@ -116,6 +116,9 @@ |
@@ -116,6 +116,7 @@ |
1294 |
#include <linux/mount.h> |
#include <linux/mount.h> |
1295 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1296 |
#include <linux/security.h> |
#include <linux/security.h> |
1297 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1298 |
|
|
1299 |
int sysctl_unix_max_dgram_qlen = 10; |
int sysctl_unix_max_dgram_qlen = 10; |
1300 |
|
|
1301 |
@@ -807,6 +810,11 @@ static int unix_bind(struct socket *sock |
@@ -807,6 +808,9 @@ static int unix_bind(struct socket *sock |
1302 |
*/ |
*/ |
1303 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1304 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1305 |
+ /***** TOMOYO Linux start. *****/ |
+ err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt, |
1306 |
+ err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
+ mode, 0); |
|
+ nd.mnt, mode, 0); |
|
1307 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1308 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1309 |
if (err) |
if (err) |
1310 |
goto out_mknod_dput; |
goto out_mknod_dput; |
1311 |
|
@@ -1574,12 +1578,17 @@ static int unix_dgram_recvmsg(struct kio |
1312 |
|
|
1313 |
|
mutex_lock(&u->readlock); |
1314 |
|
|
1315 |
|
+retry: |
1316 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1317 |
|
if (!skb) |
1318 |
|
goto out_unlock; |
1319 |
|
|
1320 |
|
wake_up_interruptible(&u->peer_wait); |
1321 |
|
|
1322 |
|
+ if (ccs_socket_post_recvmsg_permission(sk, skb)) { |
1323 |
|
+ skb_kill_datagram(sk, skb, flags); |
1324 |
|
+ goto retry; |
1325 |
|
+ } |
1326 |
|
if (msg->msg_name) |
1327 |
|
unix_copy_addr(msg, skb->sk); |
1328 |
|
|
1329 |
|
--- linux-2.6.18-26etch2.orig/security/Kconfig |
1330 |
|
+++ linux-2.6.18-26etch2/security/Kconfig |
1331 |
|
@@ -107,5 +107,7 @@ config SECURITY_SECLVL |
1332 |
|
|
1333 |
|
source security/selinux/Kconfig |
1334 |
|
|
1335 |
|
+source security/ccsecurity/Kconfig |
1336 |
|
+ |
1337 |
|
endmenu |
1338 |
|
|
1339 |
|
--- linux-2.6.18-26etch2.orig/security/Makefile |
1340 |
|
+++ linux-2.6.18-26etch2/security/Makefile |
1341 |
|
@@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin |
1342 |
|
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |
1343 |
|
obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o |
1344 |
|
obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o |
1345 |
|
+ |
1346 |
|
+subdir-$(CONFIG_CCSECURITY)+= ccsecurity |
1347 |
|
+obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o |