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