1 |
This is TOMOYO Linux patch for VineLinux 4.2. |
This is TOMOYO Linux patch for VineLinux 4.2. |
2 |
|
|
3 |
Source code for this patch is http://updates.vinelinux.org/Vine-4.2/updates/SRPMS/kernel-2.6.16-76.40vl4.src.rpm |
Source code for this patch is http://updates.vinelinux.org/Vine-4.2/updates/SRPMS/kernel-2.6.16-76.49vl4.src.rpm |
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 | 5 +++++ |
19 |
fs/exec.c | 21 ++++++- |
fs/namei.c | 34 ++++++++++++++++++++++++++++++++++ |
20 |
fs/fcntl.c | 9 +++ |
fs/namespace.c | 23 ++++++++++++++++++++++- |
21 |
fs/ioctl.c | 11 +++ |
fs/open.c | 31 ++++++++++++++++++++++++++++++- |
22 |
fs/namei.c | 118 ++++++++++++++++++++++++++++++++++++++++ |
fs/proc/proc_misc.c | 1 + |
23 |
fs/namespace.c | 50 ++++++++++++++++ |
include/linux/init_task.h | 9 +++++++++ |
24 |
fs/open.c | 29 +++++++++ |
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 | 111 +++++++++++++++++++++++++++++++++++++ |
net/ipv4/raw.c | 4 ++++ |
38 |
kernel/time.c | 15 +++++ |
net/ipv4/udp.c | 10 +++++++++- |
39 |
net/core/datagram.c | 11 +++ |
net/ipv6/inet6_hashtables.c | 5 ++++- |
40 |
net/ipv4/inet_connection_sock.c | 7 ++ |
net/ipv6/raw.c | 4 ++++ |
41 |
net/ipv4/inet_hashtables.c | 7 ++ |
net/ipv6/udp.c | 8 ++++++++ |
42 |
net/ipv4/udp.c | 11 +++ |
net/socket.c | 25 ++++++++++++++++++++++--- |
43 |
net/ipv6/inet6_hashtables.c | 9 ++- |
net/unix/af_unix.c | 4 ++++ |
44 |
net/ipv6/udp.c | 11 +++ |
security/Kconfig | 2 ++ |
45 |
net/socket.c | 43 +++++++++++++- |
security/Makefile | 3 +++ |
46 |
net/unix/af_unix.c | 15 +++++ |
41 files changed, 290 insertions(+), 11 deletions(-) |
|
42 files changed, 688 insertions(+), 10 deletions(-) |
|
47 |
|
|
48 |
--- linux-2.6.16-76.40vl4.orig/arch/alpha/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/arch/alpha/kernel/ptrace.c |
49 |
+++ linux-2.6.16-76.40vl4/arch/alpha/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/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; |
|
+ /***** TOMOYO Linux start. *****/ |
|
62 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ 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.16-76.40vl4.orig/arch/ia64/ia32/sys_ia32.c |
--- linux-2.6.16-76.51vl4.orig/arch/ia64/ia32/sys_ia32.c |
68 |
+++ linux-2.6.16-76.40vl4/arch/ia64/ia32/sys_ia32.c |
+++ linux-2.6.16-76.51vl4/arch/ia64/ia32/sys_ia32.c |
69 |
@@ -58,6 +58,9 @@ |
@@ -58,6 +58,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 |
@@ -1755,6 +1758,10 @@ sys32_ptrace (int request, pid_t pid, un |
@@ -1755,6 +1756,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; |
|
+ /***** TOMOYO Linux start. *****/ |
|
81 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ 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.16-76.40vl4.orig/arch/ia64/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/arch/ia64/kernel/ptrace.c |
87 |
+++ linux-2.6.16-76.40vl4/arch/ia64/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/arch/ia64/kernel/ptrace.c |
88 |
@@ -29,6 +29,9 @@ |
@@ -29,6 +29,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 |
@@ -1418,6 +1421,10 @@ sys_ptrace (long request, pid_t pid, uns |
@@ -1418,6 +1419,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; |
|
+ /***** TOMOYO Linux start. *****/ |
|
100 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ 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.16-76.40vl4.orig/arch/m32r/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/arch/m32r/kernel/ptrace.c |
106 |
+++ linux-2.6.16-76.40vl4/arch/m32r/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/arch/m32r/kernel/ptrace.c |
107 |
@@ -33,6 +33,9 @@ |
@@ -33,6 +33,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 |
@@ -743,6 +746,10 @@ asmlinkage long sys_ptrace(long request, |
@@ -743,6 +744,8 @@ asmlinkage long sys_ptrace(long request, |
116 |
{ |
{ |
117 |
struct task_struct *child; |
struct task_struct *child; |
118 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
119 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ 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.16-76.40vl4.orig/arch/mips/kernel/ptrace32.c |
--- linux-2.6.16-76.51vl4.orig/arch/mips/kernel/ptrace32.c |
125 |
+++ linux-2.6.16-76.40vl4/arch/mips/kernel/ptrace32.c |
+++ linux-2.6.16-76.51vl4/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; |
|
+ /***** TOMOYO Linux start. *****/ |
|
138 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ 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.16-76.40vl4.orig/arch/powerpc/kernel/ptrace32.c |
--- linux-2.6.16-76.51vl4.orig/arch/powerpc/kernel/ptrace32.c |
144 |
+++ linux-2.6.16-76.40vl4/arch/powerpc/kernel/ptrace32.c |
+++ linux-2.6.16-76.51vl4/arch/powerpc/kernel/ptrace32.c |
145 |
@@ -33,6 +33,9 @@ |
@@ -33,6 +33,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 |
@@ -46,6 +49,10 @@ long compat_sys_ptrace(int request, int |
@@ -46,6 +47,8 @@ long compat_sys_ptrace(int request, int |
154 |
{ |
{ |
155 |
struct task_struct *child; |
struct task_struct *child; |
156 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
157 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ 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.16-76.40vl4.orig/arch/s390/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/arch/s390/kernel/ptrace.c |
163 |
+++ linux-2.6.16-76.40vl4/arch/s390/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/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 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
176 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ 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.16-76.40vl4.orig/arch/sparc/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/arch/sparc/kernel/ptrace.c |
182 |
+++ linux-2.6.16-76.40vl4/arch/sparc/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/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; |
|
+ /***** TOMOYO Linux start. *****/ |
|
195 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
+ 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.16-76.40vl4.orig/arch/sparc64/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/arch/sparc64/kernel/ptrace.c |
203 |
+++ linux-2.6.16-76.40vl4/arch/sparc64/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/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 |
@@ -173,6 +176,12 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -173,6 +174,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; |
|
+ /***** TOMOYO Linux start. *****/ |
|
216 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
+ 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.16-76.40vl4.orig/arch/x86_64/ia32/ptrace32.c |
--- linux-2.6.16-76.51vl4.orig/arch/x86_64/ia32/ptrace32.c |
224 |
+++ linux-2.6.16-76.40vl4/arch/x86_64/ia32/ptrace32.c |
+++ linux-2.6.16-76.51vl4/arch/x86_64/ia32/ptrace32.c |
225 |
@@ -27,6 +27,9 @@ |
@@ -27,6 +27,7 @@ |
226 |
#include <asm/debugreg.h> |
#include <asm/debugreg.h> |
227 |
#include <asm/i387.h> |
#include <asm/i387.h> |
228 |
#include <asm/fpu32.h> |
#include <asm/fpu32.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 |
@@ -206,6 +209,10 @@ asmlinkage long sys32_ptrace(long reques |
@@ -206,6 +207,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; |
|
+ /***** TOMOYO Linux start. *****/ |
|
237 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
238 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
239 |
|
|
240 |
switch (request) { |
switch (request) { |
241 |
default: |
default: |
242 |
--- linux-2.6.16-76.40vl4.orig/fs/Kconfig |
--- linux-2.6.16-76.51vl4.orig/fs/compat.c |
243 |
+++ linux-2.6.16-76.40vl4/fs/Kconfig |
+++ linux-2.6.16-76.51vl4/fs/compat.c |
244 |
@@ -1906,5 +1906,7 @@ endmenu |
@@ -52,6 +52,7 @@ |
|
|
|
|
source "fs/nls/Kconfig" |
|
|
|
|
|
+source "fs/Kconfig.ccs" |
|
|
+ |
|
|
endmenu |
|
|
|
|
|
--- linux-2.6.16-76.40vl4.orig/fs/Makefile |
|
|
+++ linux-2.6.16-76.40vl4/fs/Makefile |
|
|
@@ -106,3 +106,5 @@ obj-$(CONFIG_CONFIGFS_FS) += configfs/ |
|
|
obj-$(CONFIG_OCFS2_FS) += ocfs2/ |
|
|
obj-$(CONFIG_SUPERMOUNT) += supermount/ |
|
|
obj-$(CONFIG_UNION_FS) += unionfs/ |
|
|
+ |
|
|
+include $(srctree)/fs/Makefile-2.6.ccs |
|
|
--- linux-2.6.16-76.40vl4.orig/fs/attr.c |
|
|
+++ linux-2.6.16-76.40vl4/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.16-76.40vl4.orig/fs/compat.c |
|
|
+++ linux-2.6.16-76.40vl4/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 |
@@ -381,6 +384,10 @@ asmlinkage long compat_sys_ioctl(unsigne |
@@ -381,6 +382,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_check_ioctl_permission(filp, cmd, arg); |
|
+ /***** TOMOYO Linux end. *****/ |
|
258 |
if (error) |
if (error) |
259 |
goto out_fput; |
goto out_fput; |
260 |
|
|
261 |
@@ -405,6 +412,12 @@ asmlinkage long compat_sys_ioctl(unsigne |
@@ -405,6 +408,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 |
@@ -1532,7 +1545,7 @@ int compat_do_execve(char * filename, |
@@ -1532,7 +1539,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.16-76.40vl4.orig/fs/exec.c |
--- linux-2.6.16-76.51vl4.orig/fs/exec.c |
282 |
+++ linux-2.6.16-76.40vl4/fs/exec.c |
+++ linux-2.6.16-76.51vl4/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 |
@@ -488,6 +499,13 @@ struct file *open_exec(const char *name) |
@@ -488,6 +494,9 @@ struct file *open_exec(const char *name) |
304 |
int err = vfs_permission(&nd, MAY_EXEC); |
int err = vfs_permission(&nd, MAY_EXEC); |
305 |
if (!err && !(inode->i_mode & 0111)) |
if (!err && !(inode->i_mode & 0111)) |
306 |
err = -EACCES; |
err = -EACCES; |
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 |
@@ -1201,7 +1219,8 @@ int do_execve(char * filename, |
@@ -1201,7 +1210,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.16-76.40vl4.orig/fs/fcntl.c |
--- linux-2.6.16-76.51vl4.orig/fs/fcntl.c |
324 |
+++ linux-2.6.16-76.40vl4/fs/fcntl.c |
+++ linux-2.6.16-76.51vl4/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 |
@@ -215,6 +218,12 @@ static int setfl(int fd, struct file * f |
@@ -215,6 +216,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.16-76.40vl4.orig/fs/ioctl.c |
--- linux-2.6.16-76.51vl4.orig/fs/ioctl.c |
344 |
+++ linux-2.6.16-76.40vl4/fs/ioctl.c |
+++ linux-2.6.16-76.51vl4/fs/ioctl.c |
345 |
@@ -16,6 +16,9 @@ |
@@ -16,6 +16,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 |
@@ -24,6 +27,10 @@ static long do_ioctl(struct file *filp, |
@@ -24,6 +25,8 @@ static long do_ioctl(struct file *filp, |
354 |
|
|
355 |
if (!filp->f_op) |
if (!filp->f_op) |
356 |
goto out; |
goto out; |
|
+ /***** TOMOYO Linux start. *****/ |
|
357 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
+ if (!ccs_capable(CCS_SYS_IOCTL)) |
358 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
359 |
|
|
360 |
if (filp->f_op->unlocked_ioctl) { |
if (filp->f_op->unlocked_ioctl) { |
361 |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
362 |
@@ -168,6 +175,10 @@ asmlinkage long sys_ioctl(unsigned int f |
@@ -168,6 +171,8 @@ asmlinkage long sys_ioctl(unsigned int f |
363 |
goto out; |
goto out; |
364 |
|
|
365 |
error = security_file_ioctl(filp, cmd, arg); |
error = security_file_ioctl(filp, cmd, arg); |
|
+ /***** TOMOYO Linux start. *****/ |
|
366 |
+ if (!error) |
+ if (!error) |
367 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
|
+ /***** TOMOYO Linux end. *****/ |
|
368 |
if (error) |
if (error) |
369 |
goto out_fput; |
goto out_fput; |
370 |
|
|
371 |
--- linux-2.6.16-76.40vl4.orig/fs/namei.c |
--- linux-2.6.16-76.51vl4.orig/fs/namei.c |
372 |
+++ linux-2.6.16-76.40vl4/fs/namei.c |
+++ linux-2.6.16-76.51vl4/fs/namei.c |
373 |
@@ -37,6 +37,10 @@ |
@@ -37,6 +37,8 @@ |
374 |
|
|
375 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
376 |
|
|
377 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
378 |
+ |
+ |
379 |
/* [Feb-1997 T. Schoebel-Theuer] |
/* [Feb-1997 T. Schoebel-Theuer] |
380 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
* Fundamental changes in the pathname lookup mechanisms (namei) |
381 |
* were necessary because of omirr. The reason is that omirr needs |
* were necessary because of omirr. The reason is that omirr needs |
382 |
@@ -1484,6 +1488,13 @@ int vfs_create(struct inode *dir, struct |
@@ -1539,6 +1541,11 @@ int may_open(struct nameidata *nd, int a |
|
error = security_inode_create(dir, dentry, mode); |
|
|
if (error) |
|
|
return error; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (nd) { |
|
|
+ error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, nd->mnt); |
|
|
+ if (error) |
|
|
+ return error; |
|
|
+ } |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
DQUOT_INIT(dir); |
|
|
error = dir->i_op->create(dir, dentry, mode, nd); |
|
|
if (!error) |
|
|
@@ -1539,6 +1550,13 @@ int may_open(struct nameidata *nd, int a |
|
383 |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
384 |
return -EPERM; |
return -EPERM; |
385 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
386 |
+ /* includes O_APPEND and O_TRUNC checks */ |
+ /* includes O_APPEND and O_TRUNC checks */ |
387 |
+ error = ccs_check_open_permission(dentry, nd->mnt, flag); |
+ error = ccs_open_permission(dentry, nd->mnt, flag); |
388 |
+ if (error) |
+ if (error) |
389 |
+ return error; |
+ return error; |
|
+ /***** TOMOYO Linux end. *****/ |
|
390 |
+ |
+ |
391 |
/* |
/* |
392 |
* Ensure there are no outstanding leases on the file. |
* Ensure there are no outstanding leases on the file. |
393 |
*/ |
*/ |
394 |
@@ -1570,6 +1588,9 @@ int may_open(struct nameidata *nd, int a |
@@ -1570,6 +1577,7 @@ int may_open(struct nameidata *nd, int a |
395 |
return 0; |
return 0; |
396 |
} |
} |
397 |
|
|
398 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity_vfs.h> |
|
+#include <linux/tomoyo_vfs.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
399 |
/* |
/* |
400 |
* open_namei() |
* open_namei() |
401 |
* |
* |
402 |
@@ -1834,6 +1855,16 @@ asmlinkage long sys_mknodat(int dfd, con |
@@ -1653,6 +1661,9 @@ do_last: |
403 |
|
if (!path.dentry->d_inode) { |
404 |
if (S_ISDIR(mode)) |
if (!IS_POSIXACL(dir->d_inode)) |
405 |
return -EPERM; |
mode &= ~current->fs->umask; |
406 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_mknod_permission(dir->d_inode, path.dentry, |
407 |
+ if (S_ISCHR(mode) && !ccs_capable(CCS_CREATE_CHAR_DEV)) |
+ nd->mnt, mode, 0); |
408 |
+ return -EPERM; |
+ if (!error) |
409 |
+ if (S_ISBLK(mode) && !ccs_capable(CCS_CREATE_BLOCK_DEV)) |
error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
410 |
+ return -EPERM; |
mutex_unlock(&dir->d_inode->i_mutex); |
411 |
+ if (S_ISFIFO(mode) && !ccs_capable(CCS_CREATE_FIFO)) |
dput(nd->dentry); |
412 |
+ return -EPERM; |
@@ -1847,6 +1858,9 @@ asmlinkage long sys_mknodat(int dfd, con |
413 |
+ if (S_ISSOCK(mode) && !ccs_capable(CCS_CREATE_UNIX_SOCKET)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
414 |
+ return -EPERM; |
mode &= ~current->fs->umask; |
415 |
+ /***** TOMOYO Linux end. *****/ |
if (!IS_ERR(dentry)) { |
416 |
tmp = getname(filename); |
+ error = ccs_mknod_permission(nd.dentry->d_inode, dentry, |
417 |
if (IS_ERR(tmp)) |
+ nd.mnt, mode, dev); |
418 |
return PTR_ERR(tmp); |
+ if (!error) |
419 |
@@ -1852,10 +1883,32 @@ asmlinkage long sys_mknodat(int dfd, con |
switch (mode & S_IFMT) { |
420 |
|
case 0: case S_IFREG: |
421 |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
422 |
break; |
@@ -1920,6 +1934,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
case S_IFCHR: case S_IFBLK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ error = ccs_check_1path_perm(S_ISCHR(mode) ? |
|
|
+ TYPE_MKCHAR_ACL : |
|
|
+ TYPE_MKBLOCK_ACL, |
|
|
+ dentry, nd.mnt); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode, |
|
|
new_decode_dev(dev)); |
|
|
break; |
|
|
case S_IFIFO: case S_IFSOCK: |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ error = ccs_check_1path_perm(S_ISFIFO(mode) ? |
|
|
+ TYPE_MKFIFO_ACL : |
|
|
+ TYPE_MKSOCK_ACL, |
|
|
+ dentry, nd.mnt); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0); |
|
|
break; |
|
|
case S_IFDIR: |
|
|
@@ -1920,6 +1973,13 @@ asmlinkage long sys_mkdirat(int dfd, con |
|
423 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
424 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
425 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
426 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_mkdir_permission(nd.dentry->d_inode, |
427 |
+ error = pre_vfs_mkdir(nd.dentry->d_inode, dentry); |
+ dentry, nd.mnt, mode); |
|
+ if (!error) |
|
|
+ error = ccs_check_1path_perm(TYPE_MKDIR_ACL, |
|
|
+ dentry, nd.mnt); |
|
428 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
429 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
430 |
dput(dentry); |
dput(dentry); |
431 |
} |
} |
432 |
@@ -2028,6 +2088,13 @@ static long do_rmdir(int dfd, const char |
@@ -2028,6 +2045,9 @@ static long do_rmdir(int dfd, const char |
433 |
dentry = lookup_hash(&nd); |
dentry = lookup_hash(&nd); |
434 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
435 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
436 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, |
437 |
+ error = pre_vfs_rmdir(nd.dentry->d_inode, dentry); |
+ nd.mnt); |
|
+ if (!error) |
|
|
+ error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, |
|
|
+ nd.mnt); |
|
438 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
439 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
440 |
dput(dentry); |
dput(dentry); |
441 |
} |
} |
442 |
@@ -2087,6 +2154,10 @@ static long do_unlinkat(int dfd, const c |
@@ -2108,6 +2128,9 @@ static long do_unlinkat(int dfd, const c |
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
struct inode *inode = NULL; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(CCS_SYS_UNLINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
name = getname(pathname); |
|
|
if(IS_ERR(name)) |
|
|
@@ -2108,6 +2179,14 @@ static long do_unlinkat(int dfd, const c |
|
443 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
444 |
if (inode) |
if (inode) |
445 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
446 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_unlink_permission(nd.dentry->d_inode, dentry, |
447 |
+ error = pre_vfs_unlink(nd.dentry->d_inode, dentry); |
+ nd.mnt); |
448 |
+ if (error) |
+ if (!error) |
|
+ goto exit2; |
|
|
+ error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt); |
|
|
+ if (error) |
|
|
+ goto exit2; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
449 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
450 |
exit2: |
exit2: |
451 |
dput(dentry); |
dput(dentry); |
452 |
@@ -2170,6 +2249,10 @@ asmlinkage long sys_symlinkat(const char |
@@ -2186,6 +2209,9 @@ asmlinkage long sys_symlinkat(const char |
|
int error = 0; |
|
|
char * from; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(CCS_SYS_SYMLINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
|
@@ -2186,6 +2269,13 @@ asmlinkage long sys_symlinkat(const char |
|
453 |
dentry = lookup_create(&nd, 0); |
dentry = lookup_create(&nd, 0); |
454 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
455 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
456 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_symlink_permission(nd.dentry->d_inode, |
457 |
+ error = pre_vfs_symlink(nd.dentry->d_inode, dentry); |
+ dentry, nd.mnt, from); |
458 |
+ if (!error) |
+ if (!error) |
|
+ error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, |
|
|
+ dentry, nd.mnt); |
|
|
+ if (!error) |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
459 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
460 |
dput(dentry); |
dput(dentry); |
461 |
} |
} |
462 |
@@ -2258,6 +2348,10 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2278,6 +2304,9 @@ asmlinkage long sys_linkat(int olddfd, c |
|
struct nameidata nd, old_nd; |
|
|
int error; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(CCS_SYS_LINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
if (flags != 0) |
|
|
return -EINVAL; |
|
|
@@ -2278,6 +2372,15 @@ asmlinkage long sys_linkat(int olddfd, c |
|
463 |
new_dentry = lookup_create(&nd, 0); |
new_dentry = lookup_create(&nd, 0); |
464 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
465 |
if (!IS_ERR(new_dentry)) { |
if (!IS_ERR(new_dentry)) { |
466 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode, |
467 |
+ error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, |
+ new_dentry, nd.mnt); |
|
+ new_dentry); |
|
|
+ if (!error) |
|
|
+ error = ccs_check_2path_perm(TYPE_LINK_ACL, |
|
|
+ old_nd.dentry, old_nd.mnt, |
|
|
+ new_dentry, nd.mnt); |
|
468 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
469 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
470 |
dput(new_dentry); |
dput(new_dentry); |
471 |
} |
} |
472 |
@@ -2504,6 +2607,17 @@ static int do_rename(int olddfd, const c |
@@ -2504,6 +2533,11 @@ static int do_rename(int olddfd, const c |
473 |
if (new_dentry == trap) |
if (new_dentry == trap) |
474 |
goto exit5; |
goto exit5; |
475 |
|
|
476 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
477 |
+ error = pre_vfs_rename(old_dir->d_inode, old_dentry, |
+ new_dir->d_inode, new_dentry, newnd.mnt); |
|
+ new_dir->d_inode, new_dentry); |
|
478 |
+ if (error) |
+ if (error) |
479 |
+ goto exit5; |
+ goto exit5; |
|
+ error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, |
|
|
+ new_dentry, newnd.mnt); |
|
|
+ if (error) |
|
|
+ goto exit5; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
480 |
+ |
+ |
481 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
error = vfs_rename(old_dir->d_inode, old_dentry, |
482 |
new_dir->d_inode, new_dentry); |
new_dir->d_inode, new_dentry); |
483 |
exit5: |
exit5: |
484 |
@@ -2526,6 +2640,10 @@ asmlinkage long sys_renameat(int olddfd, |
--- linux-2.6.16-76.51vl4.orig/fs/namespace.c |
485 |
int error; |
+++ linux-2.6.16-76.51vl4/fs/namespace.c |
486 |
char * from; |
@@ -26,6 +26,7 @@ |
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(CCS_SYS_RENAME)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
from = getname(oldname); |
|
|
if(IS_ERR(from)) |
|
|
--- linux-2.6.16-76.40vl4.orig/fs/namespace.c |
|
|
+++ linux-2.6.16-76.40vl4/fs/namespace.c |
|
|
@@ -26,6 +26,12 @@ |
|
487 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
488 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
489 |
#include "pnode.h" |
#include "pnode.h" |
490 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
491 |
|
|
492 |
extern int __init init_rootfs(void); |
extern int __init init_rootfs(void); |
493 |
|
|
494 |
@@ -509,6 +515,11 @@ static int do_umount(struct vfsmount *mn |
@@ -506,6 +507,8 @@ static int do_umount(struct vfsmount *mn |
495 |
|
LIST_HEAD(umount_list); |
496 |
|
|
497 |
|
retval = security_sb_umount(mnt, flags); |
498 |
|
+ if (!retval) |
499 |
|
+ retval = ccs_umount_permission(mnt, flags); |
500 |
if (retval) |
if (retval) |
501 |
return retval; |
return retval; |
502 |
|
|
503 |
+ /***** SAKURA Linux start. *****/ |
@@ -597,6 +600,8 @@ asmlinkage long sys_umount(char __user * |
|
+ if (ccs_may_umount(mnt)) |
|
|
+ return -EPERM; |
|
|
+ /***** SAKURA Linux end. *****/ |
|
|
+ |
|
|
/* |
|
|
* Allow userspace to request a mountpoint be expired rather than |
|
|
* unmounting unconditionally. Unmount only happens if: |
|
|
@@ -597,6 +608,10 @@ asmlinkage long sys_umount(char __user * |
|
504 |
{ |
{ |
505 |
struct nameidata nd; |
struct nameidata nd; |
506 |
int retval; |
int retval; |
|
+ /***** TOMOYO Linux start. *****/ |
|
507 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
508 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
509 |
|
|
510 |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
511 |
if (retval) |
if (retval) |
512 |
@@ -884,6 +899,11 @@ static int do_loopback(struct nameidata |
@@ -884,6 +889,9 @@ static int do_loopback(struct nameidata |
513 |
|
|
514 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
515 |
goto out; |
goto out; |
|
+ /***** SAKURA Linux start. *****/ |
|
516 |
+ err = -EPERM; |
+ err = -EPERM; |
517 |
+ if (ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
518 |
+ goto out; |
+ goto out; |
|
+ /***** SAKURA Linux end. *****/ |
|
519 |
|
|
520 |
err = -ENOMEM; |
err = -ENOMEM; |
521 |
if (recurse) |
if (recurse) |
522 |
@@ -968,7 +988,11 @@ static int do_move_mount(struct nameidat |
@@ -968,7 +976,9 @@ static int do_move_mount(struct nameidat |
523 |
err = -EINVAL; |
err = -EINVAL; |
524 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
525 |
goto out; |
goto out; |
526 |
- |
- |
|
+ /***** SAKURA Linux start. *****/ |
|
527 |
+ err = -EPERM; |
+ err = -EPERM; |
528 |
+ if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
529 |
+ goto out; |
+ goto out; |
|
+ /***** SAKURA Linux end. *****/ |
|
530 |
err = -ENOENT; |
err = -ENOENT; |
531 |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
532 |
if (IS_DEADDIR(nd->dentry->d_inode)) |
if (IS_DEADDIR(nd->dentry->d_inode)) |
533 |
@@ -1070,6 +1094,11 @@ int do_add_mount(struct vfsmount *newmnt |
@@ -1070,6 +1080,9 @@ int do_add_mount(struct vfsmount *newmnt |
534 |
err = -EINVAL; |
err = -EINVAL; |
535 |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
536 |
goto unlock; |
goto unlock; |
|
+ /***** SAKURA Linux start. *****/ |
|
537 |
+ err = -EPERM; |
+ err = -EPERM; |
538 |
+ if (ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
539 |
+ goto unlock; |
+ goto unlock; |
|
+ /***** SAKURA Linux end. *****/ |
|
540 |
|
|
541 |
newmnt->mnt_flags = mnt_flags; |
newmnt->mnt_flags = mnt_flags; |
542 |
if ((err = graft_tree(newmnt, nd))) |
if ((err = graft_tree(newmnt, nd))) |
543 |
@@ -1287,6 +1316,17 @@ long do_mount(char *dev_name, char *dir_ |
@@ -1269,6 +1282,7 @@ int copy_mount_options(const void __user |
544 |
if (data_page) |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
545 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
unsigned long flags, void *data_page) |
546 |
|
{ |
547 |
+ /***** TOMOYO Linux start. *****/ |
+ const unsigned long original_flags = flags; |
548 |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
struct nameidata nd; |
549 |
+ return -EPERM; |
int retval = 0; |
550 |
+ /***** TOMOYO Linux end. *****/ |
int mnt_flags = 0; |
551 |
+ /***** SAKURA Linux start. *****/ |
@@ -1308,6 +1322,9 @@ long do_mount(char *dev_name, char *dir_ |
552 |
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
return retval; |
553 |
+ &flags); |
|
554 |
+ if (retval) |
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
555 |
+ return retval; |
+ if (!retval) |
556 |
+ /***** SAKURA Linux end. *****/ |
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
557 |
+ |
+ original_flags, data_page); |
558 |
/* Separate the per-mountpoint flags */ |
if (retval) |
559 |
if (flags & MS_NOSUID) |
goto dput_out; |
560 |
mnt_flags |= MNT_NOSUID; |
|
561 |
@@ -1585,6 +1625,10 @@ asmlinkage long sys_pivot_root(const cha |
@@ -1585,6 +1602,8 @@ asmlinkage long sys_pivot_root(const cha |
562 |
|
|
563 |
if (!capable(CAP_SYS_ADMIN)) |
if (!capable(CAP_SYS_ADMIN)) |
564 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
565 |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
566 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
567 |
|
|
568 |
lock_kernel(); |
lock_kernel(); |
569 |
|
|
570 |
@@ -1601,6 +1645,10 @@ asmlinkage long sys_pivot_root(const cha |
@@ -1601,6 +1620,8 @@ asmlinkage long sys_pivot_root(const cha |
571 |
goto out1; |
goto out1; |
572 |
|
|
573 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
error = security_sb_pivotroot(&old_nd, &new_nd); |
|
+ /***** SAKURA Linux start. *****/ |
|
574 |
+ if (!error) |
+ if (!error) |
575 |
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
|
+ /***** SAKURA Linux end. *****/ |
|
576 |
if (error) { |
if (error) { |
577 |
path_release(&old_nd); |
path_release(&old_nd); |
578 |
goto out1; |
goto out1; |
579 |
--- linux-2.6.16-76.40vl4.orig/fs/open.c |
--- linux-2.6.16-76.51vl4.orig/fs/open.c |
580 |
+++ linux-2.6.16-76.40vl4/fs/open.c |
+++ linux-2.6.16-76.51vl4/fs/open.c |
581 |
@@ -30,6 +30,13 @@ |
@@ -30,6 +30,8 @@ |
582 |
|
|
583 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
584 |
|
|
585 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
586 |
+ |
+ |
587 |
int vfs_statfs(struct super_block *sb, struct kstatfs *buf) |
int vfs_statfs(struct super_block *sb, struct kstatfs *buf) |
588 |
{ |
{ |
589 |
int retval = -ENODEV; |
int retval = -ENODEV; |
590 |
@@ -269,6 +276,10 @@ static long do_sys_truncate(const char _ |
@@ -269,6 +271,8 @@ static long do_sys_truncate(const char _ |
591 |
if (error) |
if (error) |
592 |
goto dput_and_out; |
goto dput_and_out; |
593 |
|
|
594 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0); |
|
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, nd.dentry, nd.mnt); |
|
595 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
596 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
597 |
if (!error) { |
if (!error) { |
598 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
599 |
@@ -321,7 +332,11 @@ static long do_sys_ftruncate(unsigned in |
@@ -321,7 +325,9 @@ static long do_sys_ftruncate(unsigned in |
600 |
error = -EPERM; |
error = -EPERM; |
601 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
602 |
goto out_putf; |
goto out_putf; |
603 |
- |
- |
604 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0); |
|
+ error = ccs_check_1path_perm(TYPE_TRUNCATE_ACL, dentry, file->f_vfsmnt); |
|
605 |
+ if (error) |
+ if (error) |
606 |
+ goto out_putf; |
+ goto out_putf; |
|
+ /***** TOMOYO Linux end. *****/ |
|
607 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
608 |
if (!error) |
if (!error) |
609 |
error = do_truncate(dentry, length, 0, file); |
error = do_truncate(dentry, length, 0, file); |
610 |
@@ -610,6 +625,14 @@ asmlinkage long sys_chroot(const char __ |
@@ -610,6 +616,10 @@ asmlinkage long sys_chroot(const char __ |
611 |
error = -EPERM; |
error = -EPERM; |
612 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
613 |
goto dput_and_out; |
goto dput_and_out; |
|
+ /***** TOMOYO Linux start. *****/ |
|
614 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
615 |
+ goto dput_and_out; |
+ goto dput_and_out; |
616 |
+ /***** TOMOYO Linux end. *****/ |
+ if (ccs_chroot_permission(&nd)) |
|
+ /***** SAKURA Linux start. *****/ |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
|
617 |
+ goto dput_and_out; |
+ goto dput_and_out; |
|
+ /***** SAKURA Linux end. *****/ |
|
618 |
|
|
619 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
620 |
set_fs_altroot(); |
set_fs_altroot(); |
621 |
@@ -1192,6 +1215,10 @@ EXPORT_SYMBOL(sys_close); |
@@ -641,6 +651,9 @@ asmlinkage long sys_fchmod(unsigned int |
622 |
|
err = -EPERM; |
623 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
624 |
|
goto out_putf; |
625 |
|
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
626 |
|
+ if (err) |
627 |
|
+ goto out_putf; |
628 |
|
mutex_lock(&inode->i_mutex); |
629 |
|
if (mode == (mode_t) -1) |
630 |
|
mode = inode->i_mode; |
631 |
|
@@ -675,6 +688,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
632 |
|
error = -EPERM; |
633 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
634 |
|
goto dput_and_out; |
635 |
|
+ error = ccs_chmod_permission(nd.dentry, nd.mnt, mode); |
636 |
|
+ if (error) |
637 |
|
+ goto dput_and_out; |
638 |
|
|
639 |
|
mutex_lock(&inode->i_mutex); |
640 |
|
if (mode == (mode_t) -1) |
641 |
|
@@ -737,6 +753,8 @@ asmlinkage long sys_chown(const char __u |
642 |
|
|
643 |
|
error = user_path_walk(filename, &nd); |
644 |
|
if (!error) { |
645 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
646 |
|
+ if (!error) |
647 |
|
error = chown_common(nd.dentry, user, group); |
648 |
|
path_release(&nd); |
649 |
|
} |
650 |
|
@@ -756,6 +774,8 @@ asmlinkage long sys_fchownat(int dfd, co |
651 |
|
follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
652 |
|
error = __user_walk_fd(dfd, filename, follow, &nd); |
653 |
|
if (!error) { |
654 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
655 |
|
+ if (!error) |
656 |
|
error = chown_common(nd.dentry, user, group); |
657 |
|
path_release(&nd); |
658 |
|
} |
659 |
|
@@ -770,6 +790,8 @@ asmlinkage long sys_lchown(const char __ |
660 |
|
|
661 |
|
error = user_path_walk_link(filename, &nd); |
662 |
|
if (!error) { |
663 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
664 |
|
+ if (!error) |
665 |
|
error = chown_common(nd.dentry, user, group); |
666 |
|
path_release(&nd); |
667 |
|
} |
668 |
|
@@ -784,6 +806,9 @@ asmlinkage long sys_fchown(unsigned int |
669 |
|
|
670 |
|
file = fget(fd); |
671 |
|
if (file) { |
672 |
|
+ error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt, |
673 |
|
+ user, group); |
674 |
|
+ if (!error) |
675 |
|
error = chown_common(file->f_dentry, user, group); |
676 |
|
fput(file); |
677 |
|
} |
678 |
|
@@ -876,7 +901,9 @@ static struct file *do_filp_open(int dfd |
679 |
|
if ((namei_flags+1) & O_ACCMODE) |
680 |
|
namei_flags++; |
681 |
|
|
682 |
|
+ ccs_save_open_mode(flags); |
683 |
|
error = open_namei(dfd, filename, namei_flags, mode, &nd); |
684 |
|
+ ccs_clear_open_mode(); |
685 |
|
if (!error) |
686 |
|
return nameidata_to_filp(&nd, flags); |
687 |
|
|
688 |
|
@@ -1192,6 +1219,8 @@ EXPORT_SYMBOL(sys_close); |
689 |
*/ |
*/ |
690 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
691 |
{ |
{ |
|
+ /***** TOMOYO Linux start. *****/ |
|
692 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
693 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
694 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
695 |
tty_vhangup(current->signal->tty); |
tty_vhangup(current->signal->tty); |
696 |
return 0; |
return 0; |
697 |
--- linux-2.6.16-76.40vl4.orig/fs/proc/Makefile |
--- linux-2.6.16-76.51vl4.orig/fs/proc/proc_misc.c |
698 |
+++ linux-2.6.16-76.40vl4/fs/proc/Makefile |
+++ linux-2.6.16-76.51vl4/fs/proc/proc_misc.c |
699 |
@@ -13,3 +13,6 @@ proc-y += inode.o root.o base.o ge |
@@ -682,4 +682,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.16-76.40vl4.orig/fs/proc/proc_misc.c |
|
|
+++ linux-2.6.16-76.40vl4/fs/proc/proc_misc.c |
|
|
@@ -682,4 +682,9 @@ void __init proc_misc_init(void) |
|
700 |
if (entry) |
if (entry) |
701 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
entry->proc_fops = &proc_sysrq_trigger_operations; |
702 |
#endif |
#endif |
703 |
+ /***** CCS start. *****/ |
+ printk(KERN_INFO "Hook version: 2.6.16-76.51vl4 2009/09/24\n"); |
|
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
|
|
+ printk(KERN_INFO "Hook version: 2.6.16-76.40vl4 2009/03/18\n"); |
|
|
+#endif |
|
|
+ /***** CCS end. *****/ |
|
704 |
} |
} |
705 |
--- linux-2.6.16-76.40vl4.orig/include/linux/init_task.h |
--- linux-2.6.16-76.51vl4.orig/include/linux/init_task.h |
706 |
+++ linux-2.6.16-76.40vl4/include/linux/init_task.h |
+++ linux-2.6.16-76.51vl4/include/linux/init_task.h |
707 |
@@ -121,6 +121,10 @@ extern struct group_info init_groups; |
@@ -72,6 +72,14 @@ |
708 |
|
|
709 |
|
extern struct group_info init_groups; |
710 |
|
|
711 |
|
+#ifdef CONFIG_CCSECURITY |
712 |
|
+#define INIT_CCSECURITY \ |
713 |
|
+ .ccs_domain_info = NULL, \ |
714 |
|
+ .ccs_flags = 0, |
715 |
|
+#else |
716 |
|
+#define INIT_CCSECURITY |
717 |
|
+#endif |
718 |
|
+ |
719 |
|
/* |
720 |
|
* INIT_TASK is used to set up the first task table, touch at |
721 |
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
722 |
|
@@ -121,6 +129,7 @@ extern struct group_info init_groups; |
723 |
.journal_info = NULL, \ |
.journal_info = NULL, \ |
724 |
.cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
.cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
725 |
.fs_excl = ATOMIC_INIT(0), \ |
.fs_excl = ATOMIC_INIT(0), \ |
726 |
+ /***** TOMOYO Linux start. *****/ \ |
+ INIT_CCSECURITY \ |
|
+ .ccs_domain_info = NULL, \ |
|
|
+ .ccs_flags = 0, \ |
|
|
+ /***** TOMOYO Linux end. *****/ \ |
|
727 |
} |
} |
728 |
|
|
729 |
|
|
730 |
--- linux-2.6.16-76.40vl4.orig/include/linux/sched.h |
--- linux-2.6.16-76.51vl4.orig/include/linux/sched.h |
731 |
+++ linux-2.6.16-76.40vl4/include/linux/sched.h |
+++ linux-2.6.16-76.51vl4/include/linux/sched.h |
732 |
@@ -40,6 +40,10 @@ |
@@ -40,6 +40,8 @@ |
733 |
|
|
734 |
struct exec_domain; |
struct exec_domain; |
735 |
|
|
|
+/***** TOMOYO Linux start. *****/ |
|
736 |
+struct ccs_domain_info; |
+struct ccs_domain_info; |
|
+/***** TOMOYO Linux end. *****/ |
|
737 |
+ |
+ |
738 |
/* |
/* |
739 |
* cloning flags: |
* cloning flags: |
740 |
*/ |
*/ |
741 |
@@ -871,6 +875,10 @@ struct task_struct { |
@@ -873,6 +875,10 @@ struct task_struct { |
|
#endif |
|
|
atomic_t fs_excl; /* holding fs exclusive resources */ |
|
742 |
struct rcu_head rcu; |
struct rcu_head rcu; |
743 |
+ /***** TOMOYO Linux start. *****/ |
|
744 |
|
struct list_head *scm_work_list; |
745 |
|
+#ifdef CONFIG_CCSECURITY |
746 |
+ struct ccs_domain_info *ccs_domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
747 |
+ u32 ccs_flags; |
+ u32 ccs_flags; |
748 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
749 |
}; |
}; |
750 |
|
|
751 |
static inline pid_t process_group(struct task_struct *tsk) |
static inline pid_t process_group(struct task_struct *tsk) |
752 |
--- linux-2.6.16-76.40vl4.orig/kernel/compat.c |
--- linux-2.6.16-76.51vl4.orig/kernel/compat.c |
753 |
+++ linux-2.6.16-76.40vl4/kernel/compat.c |
+++ linux-2.6.16-76.51vl4/kernel/compat.c |
754 |
@@ -23,6 +23,9 @@ |
@@ -23,6 +23,7 @@ |
755 |
#include <linux/security.h> |
#include <linux/security.h> |
756 |
|
|
757 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
758 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
759 |
|
|
760 |
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) |
761 |
{ |
{ |
762 |
@@ -864,6 +867,10 @@ asmlinkage long compat_sys_stime(compat_ |
@@ -864,6 +865,8 @@ asmlinkage long compat_sys_stime(compat_ |
763 |
err = security_settime(&tv, NULL); |
err = security_settime(&tv, NULL); |
764 |
if (err) |
if (err) |
765 |
return err; |
return err; |
|
+ /***** TOMOYO Linux start. *****/ |
|
766 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
767 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
768 |
|
|
769 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
770 |
return 0; |
return 0; |
771 |
--- linux-2.6.16-76.40vl4.orig/kernel/kexec.c |
--- linux-2.6.16-76.51vl4.orig/kernel/kexec.c |
772 |
+++ linux-2.6.16-76.40vl4/kernel/kexec.c |
+++ linux-2.6.16-76.51vl4/kernel/kexec.c |
773 |
@@ -26,6 +26,9 @@ |
@@ -26,6 +26,7 @@ |
774 |
#include <asm/io.h> |
#include <asm/io.h> |
775 |
#include <asm/system.h> |
#include <asm/system.h> |
776 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
777 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
778 |
|
|
779 |
/* Per cpu memory for storing cpu states in case of system crash. */ |
/* Per cpu memory for storing cpu states in case of system crash. */ |
780 |
note_buf_t* crash_notes; |
note_buf_t* crash_notes; |
781 |
@@ -922,6 +925,10 @@ asmlinkage long sys_kexec_load(unsigned |
@@ -922,6 +923,8 @@ asmlinkage long sys_kexec_load(unsigned |
782 |
/* We only trust the superuser with rebooting the system. */ |
/* We only trust the superuser with rebooting the system. */ |
783 |
if (!capable(CAP_SYS_BOOT)) |
if (!capable(CAP_SYS_BOOT)) |
784 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
785 |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
786 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
787 |
|
|
788 |
/* |
/* |
789 |
* Verify we have a legal set of flags |
* Verify we have a legal set of flags |
790 |
--- linux-2.6.16-76.40vl4.orig/kernel/kmod.c |
--- linux-2.6.16-76.51vl4.orig/kernel/kmod.c |
791 |
+++ linux-2.6.16-76.40vl4/kernel/kmod.c |
+++ linux-2.6.16-76.51vl4/kernel/kmod.c |
792 |
@@ -150,6 +150,11 @@ static int ____call_usermodehelper(void |
@@ -150,6 +150,11 @@ static int ____call_usermodehelper(void |
793 |
/* We can run anywhere, unlike our parent keventd(). */ |
/* We can run anywhere, unlike our parent keventd(). */ |
794 |
set_cpus_allowed(current, CPU_MASK_ALL); |
set_cpus_allowed(current, CPU_MASK_ALL); |
795 |
|
|
796 |
+ /***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
797 |
+ current->ccs_domain_info = NULL; |
+ current->ccs_domain_info = NULL; |
798 |
+ current->ccs_flags = 0; |
+ current->ccs_flags = 0; |
799 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
800 |
+ |
+ |
801 |
retval = -EPERM; |
retval = -EPERM; |
802 |
if (current->fs->root) |
if (current->fs->root) |
803 |
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
retval = execve(sub_info->path, sub_info->argv,sub_info->envp); |
804 |
--- linux-2.6.16-76.40vl4.orig/kernel/module.c |
--- linux-2.6.16-76.51vl4.orig/kernel/module.c |
805 |
+++ linux-2.6.16-76.40vl4/kernel/module.c |
+++ linux-2.6.16-76.51vl4/kernel/module.c |
806 |
@@ -42,6 +42,9 @@ |
@@ -42,6 +42,7 @@ |
807 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
808 |
#include <asm/semaphore.h> |
#include <asm/semaphore.h> |
809 |
#include <asm/cacheflush.h> |
#include <asm/cacheflush.h> |
810 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
811 |
|
|
812 |
#if 0 |
#if 0 |
813 |
#define DEBUGP printk |
#define DEBUGP printk |
814 |
@@ -578,7 +581,10 @@ sys_delete_module(const char __user *nam |
@@ -578,7 +579,8 @@ sys_delete_module(const char __user *nam |
815 |
|
|
816 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
817 |
return -EPERM; |
return -EPERM; |
818 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
819 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
820 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
821 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
822 |
return -EFAULT; |
return -EFAULT; |
823 |
name[MODULE_NAME_LEN-1] = '\0'; |
name[MODULE_NAME_LEN-1] = '\0'; |
824 |
@@ -1931,7 +1937,10 @@ sys_init_module(void __user *umod, |
@@ -1931,7 +1933,8 @@ sys_init_module(void __user *umod, |
825 |
/* Must have permission */ |
/* Must have permission */ |
826 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
827 |
return -EPERM; |
return -EPERM; |
828 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
829 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
830 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
831 |
/* Only one module load at a time, please */ |
/* Only one module load at a time, please */ |
832 |
if (down_interruptible(&module_mutex) != 0) |
if (down_interruptible(&module_mutex) != 0) |
833 |
return -EINTR; |
return -EINTR; |
834 |
--- linux-2.6.16-76.40vl4.orig/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/kernel/ptrace.c |
835 |
+++ linux-2.6.16-76.40vl4/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/kernel/ptrace.c |
836 |
@@ -21,6 +21,9 @@ |
@@ -21,6 +21,7 @@ |
837 |
|
|
838 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
839 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
840 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
841 |
|
|
842 |
/* |
/* |
843 |
* ptrace a task: make the debugger its new parent and |
* ptrace a task: make the debugger its new parent and |
844 |
@@ -495,6 +498,10 @@ asmlinkage long sys_ptrace(long request, |
@@ -495,6 +496,8 @@ asmlinkage long sys_ptrace(long request, |
845 |
/* |
/* |
846 |
* This lock_kernel fixes a subtle race with suid exec |
* This lock_kernel fixes a subtle race with suid exec |
847 |
*/ |
*/ |
|
+ /***** TOMOYO Linux start. *****/ |
|
848 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
849 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
850 |
lock_kernel(); |
lock_kernel(); |
851 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
852 |
ret = ptrace_traceme(); |
ret = ptrace_traceme(); |
853 |
--- linux-2.6.16-76.40vl4.orig/kernel/sched.c |
--- linux-2.6.16-76.51vl4.orig/kernel/sched.c |
854 |
+++ linux-2.6.16-76.40vl4/kernel/sched.c |
+++ linux-2.6.16-76.51vl4/kernel/sched.c |
855 |
@@ -52,6 +52,9 @@ |
@@ -52,6 +52,7 @@ |
856 |
#include <asm/tlb.h> |
#include <asm/tlb.h> |
857 |
|
|
858 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
859 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
860 |
|
|
861 |
/* |
/* |
862 |
* Convert user-nice values [ -20 ... 0 ... 19 ] |
* Convert user-nice values [ -20 ... 0 ... 19 ] |
863 |
@@ -3545,6 +3548,10 @@ asmlinkage long sys_nice(int increment) |
@@ -3545,6 +3546,8 @@ asmlinkage long sys_nice(int increment) |
864 |
{ |
{ |
865 |
int retval; |
int retval; |
866 |
long nice; |
long nice; |
|
+ /***** TOMOYO Linux start. *****/ |
|
867 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
+ if (!ccs_capable(CCS_SYS_NICE)) |
868 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
869 |
|
|
870 |
/* |
/* |
871 |
* Setpriority might change our priority at the same moment. |
* Setpriority might change our priority at the same moment. |
872 |
--- linux-2.6.16-76.40vl4.orig/kernel/signal.c |
--- linux-2.6.16-76.51vl4.orig/kernel/signal.c |
873 |
+++ linux-2.6.16-76.40vl4/kernel/signal.c |
+++ linux-2.6.16-76.51vl4/kernel/signal.c |
874 |
@@ -30,6 +30,9 @@ |
@@ -30,6 +30,7 @@ |
875 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
876 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
877 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
878 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
879 |
|
|
880 |
/* |
/* |
881 |
* SLAB caches for signal bits. |
* SLAB caches for signal bits. |
882 |
@@ -2336,6 +2339,12 @@ asmlinkage long |
@@ -2336,6 +2337,8 @@ asmlinkage long |
883 |
sys_kill(int pid, int sig) |
sys_kill(int pid, int sig) |
884 |
{ |
{ |
885 |
struct siginfo info; |
struct siginfo info; |
886 |
+ /***** 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)) |
|
887 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
888 |
|
|
889 |
info.si_signo = sig; |
info.si_signo = sig; |
890 |
info.si_errno = 0; |
info.si_errno = 0; |
891 |
@@ -2394,6 +2403,12 @@ asmlinkage long sys_tgkill(int tgid, int |
@@ -2394,6 +2397,8 @@ asmlinkage long sys_tgkill(int tgid, int |
892 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
893 |
if (pid <= 0 || tgid <= 0) |
if (pid <= 0 || tgid <= 0) |
894 |
return -EINVAL; |
return -EINVAL; |
895 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
|
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
|
896 |
+ return -EPERM; |
+ return -EPERM; |
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
897 |
|
|
898 |
return do_tkill(tgid, pid, sig); |
return do_tkill(tgid, pid, sig); |
899 |
} |
} |
900 |
@@ -2407,6 +2422,12 @@ sys_tkill(int pid, int sig) |
@@ -2407,6 +2412,8 @@ sys_tkill(int pid, int sig) |
901 |
/* This is only valid for single tasks */ |
/* This is only valid for single tasks */ |
902 |
if (pid <= 0) |
if (pid <= 0) |
903 |
return -EINVAL; |
return -EINVAL; |
904 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_tkill_permission(pid, sig)) |
|
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
|
|
+ return -EPERM; |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
|
905 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
906 |
|
|
907 |
return do_tkill(0, pid, sig); |
return do_tkill(0, pid, sig); |
908 |
} |
} |
909 |
--- linux-2.6.16-76.40vl4.orig/kernel/sys.c |
@@ -2424,6 +2431,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
910 |
+++ linux-2.6.16-76.40vl4/kernel/sys.c |
if (info.si_code >= 0) |
911 |
@@ -38,6 +38,9 @@ |
return -EPERM; |
912 |
|
info.si_signo = sig; |
913 |
|
+ if (ccs_sigqueue_permission(pid, sig)) |
914 |
|
+ return -EPERM; |
915 |
|
|
916 |
|
/* POSIX.1b doesn't mention process groups. */ |
917 |
|
return kill_proc_info(sig, &info, pid); |
918 |
|
--- linux-2.6.16-76.51vl4.orig/kernel/sys.c |
919 |
|
+++ linux-2.6.16-76.51vl4/kernel/sys.c |
920 |
|
@@ -38,6 +38,7 @@ |
921 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
922 |
#include <asm/io.h> |
#include <asm/io.h> |
923 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
924 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
925 |
|
|
926 |
#ifndef SET_UNALIGN_CTL |
#ifndef SET_UNALIGN_CTL |
927 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
928 |
@@ -269,6 +272,12 @@ asmlinkage long sys_setpriority(int whic |
@@ -269,6 +270,10 @@ asmlinkage long sys_setpriority(int whic |
929 |
|
|
930 |
if (which > 2 || which < 0) |
if (which > 2 || which < 0) |
931 |
goto out; |
goto out; |
|
+ /***** TOMOYO Linux start. *****/ |
|
932 |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
933 |
+ error = -EPERM; |
+ error = -EPERM; |
934 |
+ goto out; |
+ goto out; |
935 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
936 |
|
|
937 |
/* normalize: avoid signed division (rounding problems) */ |
/* normalize: avoid signed division (rounding problems) */ |
938 |
error = -ESRCH; |
error = -ESRCH; |
939 |
@@ -496,6 +505,10 @@ asmlinkage long sys_reboot(int magic1, i |
@@ -496,6 +501,8 @@ asmlinkage long sys_reboot(int magic1, i |
940 |
magic2 != LINUX_REBOOT_MAGIC2B && |
magic2 != LINUX_REBOOT_MAGIC2B && |
941 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
magic2 != LINUX_REBOOT_MAGIC2C)) |
942 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
943 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
944 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
945 |
|
|
946 |
/* Instead of trying to make the power_off code look like |
/* Instead of trying to make the power_off code look like |
947 |
* 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. |
948 |
@@ -1533,6 +1546,10 @@ asmlinkage long sys_sethostname(char __u |
@@ -1533,6 +1540,8 @@ asmlinkage long sys_sethostname(char __u |
949 |
return -EPERM; |
return -EPERM; |
950 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
951 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
952 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
953 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
954 |
down_write(&uts_sem); |
down_write(&uts_sem); |
955 |
errno = -EFAULT; |
errno = -EFAULT; |
956 |
if (!copy_from_user(tmp, name, len)) { |
if (!copy_from_user(tmp, name, len)) { |
957 |
@@ -1578,6 +1595,10 @@ asmlinkage long sys_setdomainname(char _ |
@@ -1578,6 +1587,8 @@ asmlinkage long sys_setdomainname(char _ |
958 |
return -EPERM; |
return -EPERM; |
959 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
960 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
961 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
962 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
963 |
|
|
964 |
down_write(&uts_sem); |
down_write(&uts_sem); |
965 |
errno = -EFAULT; |
errno = -EFAULT; |
966 |
--- linux-2.6.16-76.40vl4.orig/kernel/sysctl.c |
--- linux-2.6.16-76.51vl4.orig/kernel/sysctl.c |
967 |
+++ linux-2.6.16-76.40vl4/kernel/sysctl.c |
+++ linux-2.6.16-76.51vl4/kernel/sysctl.c |
968 |
@@ -49,6 +49,9 @@ |
@@ -49,6 +49,7 @@ |
969 |
|
|
970 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
971 |
#include <asm/processor.h> |
#include <asm/processor.h> |
972 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
973 |
|
|
974 |
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, |
975 |
void __user *buffer, size_t *lenp, loff_t *ppos); |
void __user *buffer, size_t *lenp, loff_t *ppos); |
976 |
@@ -1108,6 +1111,100 @@ void __init sysctl_init(void) |
@@ -1133,6 +1134,9 @@ int do_sysctl(int __user *name, int nlen |
|
#endif |
|
|
} |
|
|
|
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+static int try_parse_table(int __user *name, int nlen, void __user *oldval, |
|
|
+ void __user *newval, ctl_table *table) |
|
|
+{ |
|
|
+ int n; |
|
|
+ int error = -ENOMEM; |
|
|
+ int op = 0; |
|
|
+ char *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); |
|
|
+ if (oldval) |
|
|
+ op |= 004; |
|
|
+ if (newval) |
|
|
+ op |= 002; |
|
|
+ if (!op) { /* Neither read nor write */ |
|
|
+ error = 0; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (!buffer) |
|
|
+ goto out; |
|
|
+ memset(buffer, 0, PAGE_SIZE); |
|
|
+ snprintf(buffer, PAGE_SIZE - 1, "/proc/sys"); |
|
|
+ repeat: |
|
|
+ if (!nlen) { |
|
|
+ error = -ENOTDIR; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (get_user(n, name)) { |
|
|
+ error = -EFAULT; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ for ( ; table->ctl_name; table++) { |
|
|
+ if (n == table->ctl_name || table->ctl_name == CTL_ANY) { |
|
|
+ int pos = strlen(buffer); |
|
|
+ const char *cp = table->procname; |
|
|
+ error = -ENOMEM; |
|
|
+ if (cp) { |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '/'; |
|
|
+ while (*cp) { |
|
|
+ const unsigned char c |
|
|
+ = *(const unsigned char *) cp; |
|
|
+ if (c == '\\') { |
|
|
+ if (pos + 2 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ } else if (c > ' ' && c < 127) { |
|
|
+ if (pos + 1 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = c; |
|
|
+ } else { |
|
|
+ if (pos + 4 >= PAGE_SIZE - 1) |
|
|
+ goto out; |
|
|
+ buffer[pos++] = '\\'; |
|
|
+ buffer[pos++] = (c >> 6) + '0'; |
|
|
+ buffer[pos++] = ((c >> 3) & 7) |
|
|
+ + '0'; |
|
|
+ buffer[pos++] = (c & 7) + '0'; |
|
|
+ } |
|
|
+ cp++; |
|
|
+ } |
|
|
+ } else { |
|
|
+ /* Assume nobody assigns "=\$=" for procname. */ |
|
|
+ snprintf(buffer + pos, PAGE_SIZE - pos - 1, |
|
|
+ "/=%d=", table->ctl_name); |
|
|
+ if (!memchr(buffer, '\0', PAGE_SIZE - 2)) |
|
|
+ goto out; |
|
|
+ } |
|
|
+ if (table->child) { |
|
|
+ if (table->strategy) { |
|
|
+ /* printk("sysctl='%s'\n", buffer); */ |
|
|
+ if (ccs_check_file_perm(buffer, op, |
|
|
+ "sysctl")) { |
|
|
+ error = -EPERM; |
|
|
+ goto out; |
|
|
+ } |
|
|
+ } |
|
|
+ name++; |
|
|
+ nlen--; |
|
|
+ table = table->child; |
|
|
+ goto repeat; |
|
|
+ } |
|
|
+ /* printk("sysctl='%s'\n", buffer); */ |
|
|
+ error = ccs_check_file_perm(buffer, op, "sysctl"); |
|
|
+ goto out; |
|
|
+ } |
|
|
+ } |
|
|
+ error = -ENOTDIR; |
|
|
+ out: |
|
|
+ kfree(buffer); |
|
|
+ return error; |
|
|
+} |
|
|
+/***** TOMOYO Linux end. *****/ |
|
|
+ |
|
|
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
|
|
void __user *newval, size_t newlen) |
|
|
{ |
|
|
@@ -1133,6 +1230,11 @@ int do_sysctl(int __user *name, int nlen |
|
977 |
|
|
978 |
spin_unlock(&sysctl_lock); |
spin_unlock(&sysctl_lock); |
979 |
|
|
980 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
|
+ error = try_parse_table(name, nlen, oldval, newval, |
|
981 |
+ head->ctl_table); |
+ head->ctl_table); |
982 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
983 |
error = parse_table(name, nlen, oldval, oldlenp, |
error = parse_table(name, nlen, oldval, oldlenp, |
984 |
newval, newlen, head->ctl_table, |
newval, newlen, head->ctl_table, |
985 |
&context); |
&context); |
986 |
@@ -1205,6 +1307,15 @@ repeat: |
@@ -1205,6 +1209,13 @@ repeat: |
987 |
if (ctl_perm(table, 001)) |
if (ctl_perm(table, 001)) |
988 |
return -EPERM; |
return -EPERM; |
989 |
if (table->strategy) { |
if (table->strategy) { |
|
+ /***** TOMOYO Linux start. *****/ |
|
990 |
+ int op = 0; |
+ int op = 0; |
991 |
+ if (oldval) |
+ if (oldval) |
992 |
+ op |= 004; |
+ op |= 004; |
994 |
+ op |= 002; |
+ op |= 002; |
995 |
+ if (ctl_perm(table, op)) |
+ if (ctl_perm(table, op)) |
996 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
997 |
error = table->strategy( |
error = table->strategy( |
998 |
table, name, nlen, |
table, name, nlen, |
999 |
oldval, oldlenp, |
oldval, oldlenp, |
1000 |
--- linux-2.6.16-76.40vl4.orig/kernel/time.c |
--- linux-2.6.16-76.51vl4.orig/kernel/time.c |
1001 |
+++ linux-2.6.16-76.40vl4/kernel/time.c |
+++ linux-2.6.16-76.51vl4/kernel/time.c |
1002 |
@@ -39,6 +39,9 @@ |
@@ -39,6 +39,7 @@ |
1003 |
|
|
1004 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1005 |
#include <asm/unistd.h> |
#include <asm/unistd.h> |
1006 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1007 |
|
|
1008 |
/* |
/* |
1009 |
* 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 |
1010 |
@@ -91,6 +94,10 @@ asmlinkage long sys_stime(time_t __user |
@@ -91,6 +92,8 @@ asmlinkage long sys_stime(time_t __user |
1011 |
err = security_settime(&tv, NULL); |
err = security_settime(&tv, NULL); |
1012 |
if (err) |
if (err) |
1013 |
return err; |
return err; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1014 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1015 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1016 |
|
|
1017 |
do_settimeofday(&tv); |
do_settimeofday(&tv); |
1018 |
return 0; |
return 0; |
1019 |
@@ -161,6 +168,10 @@ int do_sys_settimeofday(struct timespec |
@@ -161,6 +164,8 @@ int do_sys_settimeofday(struct timespec |
1020 |
error = security_settime(tv, tz); |
error = security_settime(tv, tz); |
1021 |
if (error) |
if (error) |
1022 |
return error; |
return error; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1023 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1024 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1025 |
|
|
1026 |
if (tz) { |
if (tz) { |
1027 |
/* SMP safe, global irq locking makes it work. */ |
/* SMP safe, global irq locking makes it work. */ |
1028 |
@@ -239,6 +250,10 @@ int do_adjtimex(struct timex *txc) |
@@ -239,6 +244,8 @@ int do_adjtimex(struct timex *txc) |
1029 |
/* In order to modify anything, you gotta be super-user! */ |
/* In order to modify anything, you gotta be super-user! */ |
1030 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
if (txc->modes && !capable(CAP_SYS_TIME)) |
1031 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1032 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
1033 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1034 |
|
|
1035 |
/* Now we validate the data before disabling interrupts */ |
/* Now we validate the data before disabling interrupts */ |
1036 |
|
|
1037 |
--- linux-2.6.16-76.40vl4.orig/net/core/datagram.c |
--- linux-2.6.16-76.51vl4.orig/net/ipv4/inet_connection_sock.c |
1038 |
+++ linux-2.6.16-76.40vl4/net/core/datagram.c |
+++ linux-2.6.16-76.51vl4/net/ipv4/inet_connection_sock.c |
1039 |
@@ -56,6 +56,11 @@ |
@@ -24,6 +24,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.16-76.40vl4.orig/net/ipv4/inet_connection_sock.c |
|
|
+++ linux-2.6.16-76.40vl4/net/ipv4/inet_connection_sock.c |
|
|
@@ -24,6 +24,9 @@ |
|
1040 |
#include <net/route.h> |
#include <net/route.h> |
1041 |
#include <net/tcp_states.h> |
#include <net/tcp_states.h> |
1042 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1043 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1044 |
|
|
1045 |
#ifdef INET_CSK_DEBUG |
#ifdef INET_CSK_DEBUG |
1046 |
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"; |
1047 |
@@ -88,6 +91,10 @@ int inet_csk_get_port(struct inet_hashin |
@@ -88,6 +89,8 @@ int inet_csk_get_port(struct inet_hashin |
1048 |
do { |
do { |
1049 |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)]; |
1050 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1051 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(rover)) |
|
+ if (ccs_may_autobind(rover)) |
|
1052 |
+ goto next; |
+ goto next; |
|
+ /***** SAKURA Linux end. *****/ |
|
1053 |
inet_bind_bucket_for_each(tb, node, &head->chain) |
inet_bind_bucket_for_each(tb, node, &head->chain) |
1054 |
if (tb->port == rover) |
if (tb->port == rover) |
1055 |
goto next; |
goto next; |
1056 |
--- linux-2.6.16-76.40vl4.orig/net/ipv4/inet_hashtables.c |
--- linux-2.6.16-76.51vl4.orig/net/ipv4/inet_hashtables.c |
1057 |
+++ linux-2.6.16-76.40vl4/net/ipv4/inet_hashtables.c |
+++ linux-2.6.16-76.51vl4/net/ipv4/inet_hashtables.c |
1058 |
@@ -23,6 +23,9 @@ |
@@ -23,6 +23,7 @@ |
1059 |
#include <net/inet_connection_sock.h> |
#include <net/inet_connection_sock.h> |
1060 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1061 |
#include <net/ip.h> |
#include <net/ip.h> |
1062 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1063 |
|
|
1064 |
/* |
/* |
1065 |
* Allocate and initialize a new local port bind bucket. |
* Allocate and initialize a new local port bind bucket. |
1066 |
@@ -268,6 +271,10 @@ int inet_hash_connect(struct inet_timewa |
@@ -268,6 +269,8 @@ int inet_hash_connect(struct inet_timewa |
1067 |
local_bh_disable(); |
local_bh_disable(); |
1068 |
for (i = 1; i <= range; i++) { |
for (i = 1; i <= range; i++) { |
1069 |
port = low + (i + offset) % range; |
port = low + (i + offset) % range; |
1070 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(port)) |
|
+ if (ccs_may_autobind(port)) |
|
1071 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1072 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1073 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1074 |
|
|
1075 |
--- linux-2.6.16-76.40vl4.orig/net/ipv4/udp.c |
--- linux-2.6.16-76.51vl4.orig/net/ipv4/raw.c |
1076 |
+++ linux-2.6.16-76.40vl4/net/ipv4/udp.c |
+++ linux-2.6.16-76.51vl4/net/ipv4/raw.c |
1077 |
@@ -109,6 +109,9 @@ |
@@ -79,6 +79,7 @@ |
1078 |
|
#include <linux/seq_file.h> |
1079 |
|
#include <linux/netfilter.h> |
1080 |
|
#include <linux/netfilter_ipv4.h> |
1081 |
|
+#include <linux/ccsecurity.h> |
1082 |
|
|
1083 |
|
struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; |
1084 |
|
DEFINE_RWLOCK(raw_v4_lock); |
1085 |
|
@@ -592,6 +593,9 @@ static int raw_recvmsg(struct kiocb *ioc |
1086 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1087 |
|
if (!skb) |
1088 |
|
goto out; |
1089 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1090 |
|
+ if (err) |
1091 |
|
+ goto out; |
1092 |
|
|
1093 |
|
copied = skb->len; |
1094 |
|
if (len < copied) { |
1095 |
|
--- linux-2.6.16-76.51vl4.orig/net/ipv4/udp.c |
1096 |
|
+++ linux-2.6.16-76.51vl4/net/ipv4/udp.c |
1097 |
|
@@ -109,6 +109,7 @@ |
1098 |
#include <net/inet_common.h> |
#include <net/inet_common.h> |
1099 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1100 |
#include <net/xfrm.h> |
#include <net/xfrm.h> |
1101 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1102 |
|
|
1103 |
/* |
/* |
1104 |
* Snmp MIB for the UDP layer |
* Snmp MIB for the UDP layer |
1105 |
@@ -147,6 +150,10 @@ static int udp_v4_get_port(struct sock * |
@@ -147,6 +148,8 @@ static int udp_v4_get_port(struct sock * |
1106 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1107 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1108 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1109 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1110 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1111 |
goto gotit; |
goto gotit; |
1112 |
} |
} |
1113 |
size = 0; |
size = 0; |
1114 |
@@ -163,6 +170,10 @@ static int udp_v4_get_port(struct sock * |
@@ -163,6 +166,8 @@ static int udp_v4_get_port(struct sock * |
1115 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1116 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1117 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1118 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1119 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1120 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1121 |
break; |
break; |
1122 |
} |
} |
1123 |
--- linux-2.6.16-76.40vl4.orig/net/ipv6/inet6_hashtables.c |
@@ -797,7 +802,10 @@ try_again: |
1124 |
+++ linux-2.6.16-76.40vl4/net/ipv6/inet6_hashtables.c |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1125 |
@@ -22,6 +22,9 @@ |
if (!skb) |
1126 |
|
goto out; |
1127 |
|
- |
1128 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1129 |
|
+ if (err) |
1130 |
|
+ goto out; |
1131 |
|
+ |
1132 |
|
copied = skb->len - sizeof(struct udphdr); |
1133 |
|
if (copied > len) { |
1134 |
|
copied = len; |
1135 |
|
--- linux-2.6.16-76.51vl4.orig/net/ipv6/inet6_hashtables.c |
1136 |
|
+++ linux-2.6.16-76.51vl4/net/ipv6/inet6_hashtables.c |
1137 |
|
@@ -22,6 +22,7 @@ |
1138 |
#include <net/inet_hashtables.h> |
#include <net/inet_hashtables.h> |
1139 |
#include <net/inet6_hashtables.h> |
#include <net/inet6_hashtables.h> |
1140 |
#include <net/ip.h> |
#include <net/ip.h> |
1141 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1142 |
|
|
1143 |
struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, |
struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, |
1144 |
const struct in6_addr *daddr, |
const struct in6_addr *daddr, |
1145 |
@@ -93,7 +96,7 @@ static int __inet6_check_established(str |
@@ -93,7 +94,7 @@ static int __inet6_check_established(str |
1146 |
const struct in6_addr *saddr = &np->daddr; |
const struct in6_addr *saddr = &np->daddr; |
1147 |
const int dif = sk->sk_bound_dev_if; |
const int dif = sk->sk_bound_dev_if; |
1148 |
const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
1151 |
inet->dport); |
inet->dport); |
1152 |
struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); |
struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); |
1153 |
struct sock *sk2; |
struct sock *sk2; |
1154 |
@@ -187,6 +190,10 @@ int inet6_hash_connect(struct inet_timew |
@@ -187,6 +188,8 @@ int inet6_hash_connect(struct inet_timew |
1155 |
local_bh_disable(); |
local_bh_disable(); |
1156 |
for (i = 1; i <= range; i++) { |
for (i = 1; i <= range; i++) { |
1157 |
port = low + (i + offset) % range; |
port = low + (i + offset) % range; |
1158 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(port)) |
|
+ if (ccs_may_autobind(port)) |
|
1159 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1160 |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
1161 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1162 |
|
|
1163 |
--- linux-2.6.16-76.40vl4.orig/net/ipv6/udp.c |
--- linux-2.6.16-76.51vl4.orig/net/ipv6/raw.c |
1164 |
+++ linux-2.6.16-76.40vl4/net/ipv6/udp.c |
+++ linux-2.6.16-76.51vl4/net/ipv6/raw.c |
1165 |
@@ -59,6 +59,9 @@ |
@@ -56,6 +56,7 @@ |
1166 |
|
|
1167 |
#include <linux/proc_fs.h> |
#include <linux/proc_fs.h> |
1168 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
1169 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
1170 |
+#include <linux/sakura.h> |
|
1171 |
+/***** SAKURA Linux end. *****/ |
struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1172 |
|
DEFINE_RWLOCK(raw_v6_lock); |
1173 |
|
@@ -387,6 +388,9 @@ static int rawv6_recvmsg(struct kiocb *i |
1174 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1175 |
|
if (!skb) |
1176 |
|
goto out; |
1177 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1178 |
|
+ if (err) |
1179 |
|
+ goto out; |
1180 |
|
|
1181 |
|
copied = skb->len; |
1182 |
|
if (copied > len) { |
1183 |
|
--- linux-2.6.16-76.51vl4.orig/net/ipv6/udp.c |
1184 |
|
+++ linux-2.6.16-76.51vl4/net/ipv6/udp.c |
1185 |
|
@@ -59,6 +59,7 @@ |
1186 |
|
|
1187 |
|
#include <linux/proc_fs.h> |
1188 |
|
#include <linux/seq_file.h> |
1189 |
|
+#include <linux/ccsecurity.h> |
1190 |
|
|
1191 |
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; |
1192 |
|
|
1193 |
@@ -89,6 +92,10 @@ static int udp_v6_get_port(struct sock * |
@@ -89,6 +90,8 @@ static int udp_v6_get_port(struct sock * |
1194 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1195 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1196 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1197 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1198 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1199 |
goto gotit; |
goto gotit; |
1200 |
} |
} |
1201 |
size = 0; |
size = 0; |
1202 |
@@ -105,6 +112,10 @@ static int udp_v6_get_port(struct sock * |
@@ -105,6 +108,8 @@ static int udp_v6_get_port(struct sock * |
1203 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1204 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1205 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1206 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1207 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1208 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1209 |
break; |
break; |
1210 |
} |
} |
1211 |
--- linux-2.6.16-76.40vl4.orig/net/socket.c |
@@ -238,6 +243,9 @@ try_again: |
1212 |
+++ linux-2.6.16-76.40vl4/net/socket.c |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1213 |
@@ -97,6 +97,11 @@ |
if (!skb) |
1214 |
|
goto out; |
1215 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1216 |
|
+ if (err) |
1217 |
|
+ goto out; |
1218 |
|
|
1219 |
|
copied = skb->len - sizeof(struct udphdr); |
1220 |
|
if (copied > len) { |
1221 |
|
--- linux-2.6.16-76.51vl4.orig/net/socket.c |
1222 |
|
+++ linux-2.6.16-76.51vl4/net/socket.c |
1223 |
|
@@ -97,6 +97,8 @@ |
1224 |
#include <net/sock.h> |
#include <net/sock.h> |
1225 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1226 |
|
|
1227 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+#include <linux/tomoyo_socket.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1228 |
+ |
+ |
1229 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1230 |
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf, |
1231 |
size_t size, loff_t pos); |
size_t size, loff_t pos); |
1232 |
@@ -546,7 +551,12 @@ static inline int __sock_sendmsg(struct |
@@ -544,9 +546,12 @@ static inline int __sock_sendmsg(struct |
1233 |
|
si->size = size; |
1234 |
|
|
1235 |
err = security_socket_sendmsg(sock, msg, size); |
err = security_socket_sendmsg(sock, msg, size); |
1236 |
|
+ if (!err) |
1237 |
|
+ err = ccs_socket_sendmsg_permission(sock, (struct sockaddr *) |
1238 |
|
+ msg->msg_name, |
1239 |
|
+ msg->msg_namelen); |
1240 |
if (err) |
if (err) |
1241 |
return err; |
return err; |
1242 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (ccs_socket_sendmsg_permission(sock, |
|
|
+ (struct sockaddr *) msg->msg_name, |
|
|
+ msg->msg_namelen)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1243 |
return sock->ops->sendmsg(iocb, sock, msg, size); |
return sock->ops->sendmsg(iocb, sock, msg, size); |
1244 |
} |
} |
1245 |
|
|
1246 |
@@ -1102,6 +1112,12 @@ static int __sock_create(int family, int |
@@ -1103,6 +1108,8 @@ static int __sock_create(int family, int |
|
family = PF_PACKET; |
|
1247 |
} |
} |
1248 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = ccs_socket_create_permission(family, type, protocol); |
|
|
+ if (err) |
|
|
+ return err; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
+ |
|
1249 |
err = security_socket_create(family, type, protocol, kern); |
err = security_socket_create(family, type, protocol, kern); |
1250 |
|
+ if (!err) |
1251 |
|
+ err = ccs_socket_create_permission(family, type, protocol); |
1252 |
if (err) |
if (err) |
1253 |
return err; |
return err; |
1254 |
@@ -1299,6 +1315,12 @@ asmlinkage long sys_bind(int fd, struct |
|
1255 |
|
@@ -1299,6 +1306,10 @@ asmlinkage long sys_bind(int fd, struct |
1256 |
sockfd_put(sock); |
sockfd_put(sock); |
1257 |
return err; |
return err; |
1258 |
} |
} |
|
+ /***** TOMOYO Linux start. *****/ |
|
1259 |
+ err = ccs_socket_bind_permission(sock, |
+ err = ccs_socket_bind_permission(sock, |
1260 |
+ (struct sockaddr *) |
+ (struct sockaddr *) |
1261 |
+ address, addrlen); |
+ address, addrlen); |
1262 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1263 |
err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen); |
err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen); |
1264 |
} |
} |
1265 |
sockfd_put(sock); |
sockfd_put(sock); |
1266 |
@@ -1329,7 +1351,10 @@ asmlinkage long sys_listen(int fd, int b |
@@ -1329,7 +1340,8 @@ asmlinkage long sys_listen(int fd, int b |
1267 |
sockfd_put(sock); |
sockfd_put(sock); |
1268 |
return err; |
return err; |
1269 |
} |
} |
1270 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
1271 |
+ err = ccs_socket_listen_permission(sock); |
+ err = ccs_socket_listen_permission(sock); |
1272 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1273 |
err=sock->ops->listen(sock, backlog); |
err=sock->ops->listen(sock, backlog); |
1274 |
sockfd_put(sock); |
sockfd_put(sock); |
1275 |
} |
} |
1276 |
@@ -1380,6 +1405,13 @@ asmlinkage long sys_accept(int fd, struc |
@@ -1380,6 +1392,11 @@ asmlinkage long sys_accept(int fd, struc |
1277 |
if (err < 0) |
if (err < 0) |
1278 |
goto out_release; |
goto out_release; |
1279 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
1280 |
+ if (ccs_socket_accept_permission(newsock, |
+ if (ccs_socket_accept_permission(newsock, |
1281 |
+ (struct sockaddr *) address)) { |
+ (struct sockaddr *) address)) { |
1282 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1283 |
+ goto out_release; |
+ goto out_release; |
1284 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
1285 |
if (upeer_sockaddr) { |
if (upeer_sockaddr) { |
1286 |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
1287 |
err = -ECONNABORTED; |
err = -ECONNABORTED; |
1288 |
@@ -1435,7 +1467,12 @@ asmlinkage long sys_connect(int fd, stru |
@@ -1433,9 +1450,11 @@ asmlinkage long sys_connect(int fd, stru |
1289 |
|
goto out_put; |
1290 |
|
|
1291 |
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
err = security_socket_connect(sock, (struct sockaddr *)address, addrlen); |
1292 |
|
+ if (!err) |
1293 |
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) |
1294 |
|
+ address, addrlen); |
1295 |
if (err) |
if (err) |
1296 |
goto out_put; |
goto out_put; |
1297 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, |
|
|
+ addrlen); |
|
|
+ if (err) |
|
|
+ goto out_put; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1298 |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
1299 |
sock->file->f_flags); |
sock->file->f_flags); |
1300 |
out_put: |
out_put: |
1301 |
--- linux-2.6.16-76.40vl4.orig/net/unix/af_unix.c |
--- linux-2.6.16-76.51vl4.orig/net/unix/af_unix.c |
1302 |
+++ linux-2.6.16-76.40vl4/net/unix/af_unix.c |
+++ linux-2.6.16-76.51vl4/net/unix/af_unix.c |
1303 |
@@ -117,6 +117,9 @@ |
@@ -117,6 +117,7 @@ |
1304 |
#include <linux/mount.h> |
#include <linux/mount.h> |
1305 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1306 |
#include <linux/security.h> |
#include <linux/security.h> |
1307 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1308 |
|
|
1309 |
int sysctl_unix_max_dgram_qlen = 10; |
int sysctl_unix_max_dgram_qlen = 10; |
1310 |
|
|
1311 |
@@ -738,6 +741,11 @@ static int unix_bind(struct socket *sock |
@@ -782,6 +783,9 @@ static int unix_bind(struct socket *sock |
|
err = unix_autobind(sock); |
|
|
goto out; |
|
|
} |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ err = -EPERM; |
|
|
+ if (sunaddr->sun_path[0] && !ccs_capable(CCS_CREATE_UNIX_SOCKET)) |
|
|
+ goto out; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
err = unix_mkname(sunaddr, addr_len, &hash); |
|
|
if (err < 0) |
|
|
@@ -781,6 +789,13 @@ static int unix_bind(struct socket *sock |
|
1312 |
*/ |
*/ |
1313 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1314 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1315 |
+ /***** TOMOYO Linux start. *****/ |
+ err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt, |
1316 |
+ err = pre_vfs_mknod(nd.dentry->d_inode, dentry, mode); |
+ mode, 0); |
|
+ if (!err) |
|
|
+ err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry, |
|
|
+ nd.mnt); |
|
1317 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1318 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1319 |
if (err) |
if (err) |
1320 |
goto out_mknod_dput; |
goto out_mknod_dput; |
1321 |
|
--- linux-2.6.16-76.51vl4.orig/security/Kconfig |
1322 |
|
+++ linux-2.6.16-76.51vl4/security/Kconfig |
1323 |
|
@@ -101,5 +101,7 @@ config SECURITY_SECLVL |
1324 |
|
|
1325 |
|
source security/selinux/Kconfig |
1326 |
|
|
1327 |
|
+source security/ccsecurity/Kconfig |
1328 |
|
+ |
1329 |
|
endmenu |
1330 |
|
|
1331 |
|
--- linux-2.6.16-76.51vl4.orig/security/Makefile |
1332 |
|
+++ linux-2.6.16-76.51vl4/security/Makefile |
1333 |
|
@@ -17,3 +17,6 @@ obj-$(CONFIG_SECURITY_SELINUX) += selin |
1334 |
|
obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o |
1335 |
|
obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o |
1336 |
|
obj-$(CONFIG_SECURITY_SECLVL) += seclvl.o |
1337 |
|
+ |
1338 |
|
+subdir-$(CONFIG_CCSECURITY)+= ccsecurity |
1339 |
|
+obj-$(CONFIG_CCSECURITY)+= ccsecurity/built-in.o |