1 |
This is TOMOYO Linux patch for kernel 2.4.37. |
This is TOMOYO Linux patch for kernel 2.4.37.6. |
2 |
|
|
3 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.tar.bz2 |
Source code for this patch is http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.37.6.tar.bz2 |
4 |
--- |
--- |
5 |
Documentation/Configure.help | 86 +++++++++++++++++++++++++++++ |
arch/alpha/kernel/ptrace.c | 3 +++ |
6 |
arch/alpha/kernel/ptrace.c | 7 ++ |
arch/arm/kernel/ptrace.c | 3 +++ |
7 |
arch/arm/kernel/ptrace.c | 7 ++ |
arch/cris/kernel/ptrace.c | 3 +++ |
8 |
arch/cris/kernel/ptrace.c | 7 ++ |
arch/i386/kernel/ptrace.c | 3 +++ |
9 |
arch/i386/kernel/ptrace.c | 7 ++ |
arch/ia64/ia32/sys_ia32.c | 3 +++ |
10 |
arch/ia64/ia32/sys_ia32.c | 7 ++ |
arch/ia64/kernel/ptrace.c | 3 +++ |
11 |
arch/ia64/kernel/ptrace.c | 7 ++ |
arch/m68k/kernel/ptrace.c | 3 +++ |
12 |
arch/m68k/kernel/ptrace.c | 7 ++ |
arch/mips/kernel/ptrace.c | 3 +++ |
13 |
arch/mips/kernel/ptrace.c | 7 ++ |
arch/mips64/kernel/ptrace.c | 5 +++++ |
14 |
arch/mips64/kernel/ptrace.c | 11 +++ |
arch/parisc/kernel/ptrace.c | 3 +++ |
15 |
arch/parisc/kernel/ptrace.c | 7 ++ |
arch/ppc/kernel/ptrace.c | 3 +++ |
16 |
arch/ppc/kernel/ptrace.c | 7 ++ |
arch/ppc64/kernel/ptrace.c | 3 +++ |
17 |
arch/ppc64/kernel/ptrace.c | 7 ++ |
arch/ppc64/kernel/ptrace32.c | 3 +++ |
18 |
arch/ppc64/kernel/ptrace32.c | 7 ++ |
arch/s390/kernel/ptrace.c | 3 +++ |
19 |
arch/s390/kernel/ptrace.c | 7 ++ |
arch/s390x/kernel/ptrace.c | 3 +++ |
20 |
arch/s390x/kernel/ptrace.c | 7 ++ |
arch/sh/kernel/ptrace.c | 3 +++ |
21 |
arch/sh/kernel/ptrace.c | 7 ++ |
arch/sh64/kernel/ptrace.c | 3 +++ |
22 |
arch/sh64/kernel/ptrace.c | 7 ++ |
arch/sparc/kernel/ptrace.c | 5 +++++ |
23 |
arch/sparc/kernel/ptrace.c | 9 +++ |
arch/sparc64/kernel/ptrace.c | 5 +++++ |
24 |
arch/sparc64/kernel/ptrace.c | 9 +++ |
arch/x86_64/ia32/ptrace32.c | 3 +++ |
25 |
arch/x86_64/ia32/ptrace32.c | 7 ++ |
arch/x86_64/kernel/ptrace.c | 3 +++ |
26 |
arch/x86_64/kernel/ptrace.c | 7 ++ |
fs/Config.in | 3 +++ |
27 |
fs/Config.in | 3 + |
fs/Makefile | 2 ++ |
28 |
fs/Makefile | 2 |
fs/attr.c | 4 ++++ |
29 |
fs/attr.c | 10 +++ |
fs/exec.c | 12 +++++++++++- |
30 |
fs/exec.c | 21 ++++++- |
fs/fcntl.c | 4 ++++ |
31 |
fs/fcntl.c | 8 ++ |
fs/ioctl.c | 10 ++++++++++ |
32 |
fs/ioctl.c | 16 +++++ |
fs/namei.c | 40 ++++++++++++++++++++++++++++++++++++++++ |
33 |
fs/namei.c | 127 +++++++++++++++++++++++++++++++++++++++++++ |
fs/namespace.c | 34 +++++++++++++++++++++++++++++++++- |
34 |
fs/namespace.c | 58 +++++++++++++++++++ |
fs/open.c | 29 +++++++++++++++++++++++++++++ |
35 |
fs/open.c | 29 +++++++++ |
fs/proc/proc_misc.c | 1 + |
36 |
fs/proc/Makefile | 4 + |
include/linux/sched.h | 14 ++++++++++++++ |
37 |
fs/proc/proc_misc.c | 5 + |
kernel/kmod.c | 5 +++++ |
38 |
include/linux/sched.h | 12 ++++ |
kernel/module.c | 7 +++++++ |
39 |
kernel/kmod.c | 5 + |
kernel/sched.c | 3 +++ |
40 |
kernel/module.c | 15 +++++ |
kernel/signal.c | 7 +++++++ |
41 |
kernel/sched.c | 7 ++ |
kernel/sys.c | 9 +++++++++ |
42 |
kernel/signal.c | 15 +++++ |
kernel/sysctl.c | 13 ++++++++++++- |
43 |
kernel/sys.c | 19 ++++++ |
kernel/time.c | 7 +++++++ |
44 |
kernel/sysctl.c | 113 +++++++++++++++++++++++++++++++++++++- |
net/ipv4/raw.c | 4 ++++ |
45 |
kernel/time.c | 15 +++++ |
net/ipv4/tcp_ipv4.c | 5 +++++ |
46 |
net/core/datagram.c | 10 +++ |
net/ipv4/udp.c | 8 ++++++++ |
47 |
net/ipv4/tcp_ipv4.c | 11 +++ |
net/ipv6/raw.c | 4 ++++ |
48 |
net/ipv4/udp.c | 11 +++ |
net/ipv6/tcp_ipv6.c | 3 +++ |
49 |
net/ipv6/tcp_ipv6.c | 7 ++ |
net/ipv6/udp.c | 8 ++++++++ |
50 |
net/ipv6/udp.c | 11 +++ |
net/socket.c | 25 +++++++++++++++++++++++-- |
51 |
net/socket.c | 40 ++++++++++++- |
net/unix/af_unix.c | 4 ++++ |
52 |
net/unix/af_unix.c | 15 +++++ |
47 files changed, 329 insertions(+), 5 deletions(-) |
|
48 files changed, 824 insertions(+), 6 deletions(-) |
|
53 |
|
|
54 |
--- linux-2.4.37.orig/Documentation/Configure.help |
--- linux-2.4.37.6.orig/arch/alpha/kernel/ptrace.c |
55 |
+++ linux-2.4.37/Documentation/Configure.help |
+++ linux-2.4.37.6/arch/alpha/kernel/ptrace.c |
56 |
@@ -29158,6 +29158,92 @@ CONFIG_SOUND_WM97XX |
@@ -18,6 +18,7 @@ |
|
|
|
|
If unsure, say N. |
|
|
|
|
|
+CONFIG_SAKURA |
|
|
+ Say Y here to support the Domain-Free Mandatory Access Control. |
|
|
+ |
|
|
+ SAKURA stands for |
|
|
+ "Security Advancement Know-how Upon Read-only Approach". |
|
|
+ As the name shows, SAKURA was originally a methodology to make |
|
|
+ root fs read-only to avoid tampering the system files. |
|
|
+ But now, SAKURA is not only a methodology but also a kernel patch |
|
|
+ that improves the system security with less effort. |
|
|
+ |
|
|
+ SAKURA can restrict operations that affect systemwide. |
|
|
+ |
|
|
+CONFIG_TOMOYO |
|
|
+ Say Y here to support the Domain-Based Mandatory Access Control. |
|
|
+ |
|
|
+ TOMOYO stands for "Task Oriented Management Obviates Your Onus". |
|
|
+ TOMOYO is intended to provide the Domain-Based MAC |
|
|
+ utilizing task_struct. |
|
|
+ |
|
|
+ The word "domain" in TOMOYO is a class that a process |
|
|
+ (i.e. task_struct) belong to. |
|
|
+ The domain of a process changes whenever the process |
|
|
+ executes a program. |
|
|
+ This allows you to classify at the finest level. |
|
|
+ The access permission is granted to domains, not to processes. |
|
|
+ Policy is defined as "Which domain can access to which resource.". |
|
|
+ |
|
|
+ The biggest feature of TOMOYO is that TOMOYO has "learning mode". |
|
|
+ The learning mode can automatically generate policy definition, |
|
|
+ and dramatically reduces the policy definition labors. |
|
|
+ |
|
|
+ TOMOYO is applicable to figuring out the system's behavior, for |
|
|
+ TOMOYO uses the canonicalized absolute pathnames and |
|
|
+ TreeView style domain transitions. |
|
|
+ |
|
|
+ You can make custom root fs with minimum files |
|
|
+ to run minimum applications with TOMOYO. |
|
|
+ |
|
|
+CONFIG_TOMOYO_MAX_ACCEPT_ENTRY |
|
|
+ This is the default value for maximal ACL entries |
|
|
+ that are automatically appended into policy at "learning mode". |
|
|
+ Some programs access thousands of objects, so running |
|
|
+ such programs in "learning mode" dulls the system response |
|
|
+ and consumes much memory. |
|
|
+ This is the safeguard for such programs. |
|
|
+ |
|
|
+CONFIG_TOMOYO_MAX_GRANT_LOG |
|
|
+ This is the default value for maximal entries for |
|
|
+ access grant logs that the kernel can hold on memory. |
|
|
+ You can read the log via /proc/ccs/grant_log. |
|
|
+ If you don't need access grant logs, |
|
|
+ you may set this value to 0. |
|
|
+ |
|
|
+CONFIG_TOMOYO_MAX_REJECT_LOG |
|
|
+ This is the default value for maximal entries for |
|
|
+ access reject logs that the kernel can hold on memory. |
|
|
+ You can read the log via /proc/ccs/reject_log. |
|
|
+ If you don't need access reject logs, |
|
|
+ you may set this value to 0. |
|
|
+ |
|
|
+CONFIG_SYAORAN |
|
|
+ Say Y or M here to support the Tamper-Proof Device Filesystem. |
|
|
+ |
|
|
+ SYAORAN stands for |
|
|
+ "Simple Yet All-important Object Realizing Abiding Nexus". |
|
|
+ SYAORAN is a filesystem for /dev with Mandatory Access Control. |
|
|
+ |
|
|
+ SAKURA can make root fs read-only, but the system can't work |
|
|
+ if /dev is read-only. Therefore you need to mount a writable |
|
|
+ filesystem (such as tmpfs) for /dev if root fs is read-only. |
|
|
+ |
|
|
+ But the writable /dev means that files on /dev might be tampered. |
|
|
+ For example, if /dev/null is deleted and re-created as a symbolic |
|
|
+ link to /dev/hda by an attacker, the contents of the IDE HDD |
|
|
+ will be destroyed at a blow. |
|
|
+ |
|
|
+ Also, TOMOYO controls file access by pathnames, |
|
|
+ not by security labels. |
|
|
+ Therefore /dev/null, for example, might be tampered |
|
|
+ if a process have write permission to /dev/null . |
|
|
+ |
|
|
+ SYAORAN can ensure /dev/null is a character device file |
|
|
+ with major=1 minor=3. |
|
|
+ |
|
|
+ You can use SAKURA to make /dev not unmountable. |
|
|
+ |
|
|
# |
|
|
# A couple of things I keep forgetting: |
|
|
# capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet, |
|
|
--- linux-2.4.37.orig/arch/alpha/kernel/ptrace.c |
|
|
+++ linux-2.4.37/arch/alpha/kernel/ptrace.c |
|
|
@@ -18,6 +18,9 @@ |
|
57 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
58 |
#include <asm/system.h> |
#include <asm/system.h> |
59 |
#include <asm/fpu.h> |
#include <asm/fpu.h> |
60 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
61 |
|
|
62 |
#include "proto.h" |
#include "proto.h" |
63 |
|
|
64 |
@@ -251,6 +254,10 @@ sys_ptrace(long request, long pid, long |
@@ -251,6 +252,8 @@ sys_ptrace(long request, long pid, long |
65 |
{ |
{ |
66 |
struct task_struct *child; |
struct task_struct *child; |
67 |
long ret; |
long ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
68 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
69 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
70 |
|
|
71 |
lock_kernel(); |
lock_kernel(); |
72 |
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", |
73 |
--- linux-2.4.37.orig/arch/arm/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/arm/kernel/ptrace.c |
74 |
+++ linux-2.4.37/arch/arm/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/arm/kernel/ptrace.c |
75 |
@@ -22,6 +22,9 @@ |
@@ -22,6 +22,7 @@ |
76 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
77 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
78 |
#include <asm/system.h> |
#include <asm/system.h> |
79 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
80 |
|
|
81 |
#include "ptrace.h" |
#include "ptrace.h" |
82 |
|
|
83 |
@@ -695,6 +698,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -695,6 +696,8 @@ asmlinkage int sys_ptrace(long request, |
84 |
{ |
{ |
85 |
struct task_struct *child; |
struct task_struct *child; |
86 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
87 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
88 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
89 |
|
|
90 |
lock_kernel(); |
lock_kernel(); |
91 |
ret = -EPERM; |
ret = -EPERM; |
92 |
--- linux-2.4.37.orig/arch/cris/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/cris/kernel/ptrace.c |
93 |
+++ linux-2.4.37/arch/cris/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/cris/kernel/ptrace.c |
94 |
@@ -48,6 +48,9 @@ |
@@ -48,6 +48,7 @@ |
95 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
96 |
#include <asm/system.h> |
#include <asm/system.h> |
97 |
#include <asm/processor.h> |
#include <asm/processor.h> |
98 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
99 |
|
|
100 |
/* |
/* |
101 |
* does not yet catch signals sent when the child dies. |
* does not yet catch signals sent when the child dies. |
102 |
@@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -104,6 +105,8 @@ asmlinkage int sys_ptrace(long request, |
103 |
{ |
{ |
104 |
struct task_struct *child; |
struct task_struct *child; |
105 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
106 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
107 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
108 |
|
|
109 |
lock_kernel(); |
lock_kernel(); |
110 |
ret = -EPERM; |
ret = -EPERM; |
111 |
--- linux-2.4.37.orig/arch/i386/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/i386/kernel/ptrace.c |
112 |
+++ linux-2.4.37/arch/i386/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/i386/kernel/ptrace.c |
113 |
@@ -20,6 +20,9 @@ |
@@ -20,6 +20,7 @@ |
114 |
#include <asm/processor.h> |
#include <asm/processor.h> |
115 |
#include <asm/i387.h> |
#include <asm/i387.h> |
116 |
#include <asm/debugreg.h> |
#include <asm/debugreg.h> |
117 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
118 |
|
|
119 |
/* |
/* |
120 |
* does not yet catch signals sent when the child dies. |
* does not yet catch signals sent when the child dies. |
121 |
@@ -152,6 +155,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -152,6 +153,8 @@ asmlinkage int sys_ptrace(long request, |
122 |
struct task_struct *child; |
struct task_struct *child; |
123 |
struct user * dummy = NULL; |
struct user * dummy = NULL; |
124 |
int i, ret; |
int i, ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
125 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
126 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
127 |
|
|
128 |
lock_kernel(); |
lock_kernel(); |
129 |
ret = -EPERM; |
ret = -EPERM; |
130 |
--- linux-2.4.37.orig/arch/ia64/ia32/sys_ia32.c |
--- linux-2.4.37.6.orig/arch/ia64/ia32/sys_ia32.c |
131 |
+++ linux-2.4.37/arch/ia64/ia32/sys_ia32.c |
+++ linux-2.4.37.6/arch/ia64/ia32/sys_ia32.c |
132 |
@@ -57,6 +57,9 @@ |
@@ -57,6 +57,7 @@ |
133 |
#include <net/scm.h> |
#include <net/scm.h> |
134 |
#include <net/sock.h> |
#include <net/sock.h> |
135 |
#include <asm/ia32.h> |
#include <asm/ia32.h> |
136 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
137 |
|
|
138 |
#define DEBUG 0 |
#define DEBUG 0 |
139 |
|
|
140 |
@@ -3131,6 +3134,10 @@ sys32_ptrace (int request, pid_t pid, un |
@@ -3131,6 +3132,8 @@ sys32_ptrace (int request, pid_t pid, un |
141 |
struct task_struct *child; |
struct task_struct *child; |
142 |
unsigned int value, tmp; |
unsigned int value, tmp; |
143 |
long i, ret; |
long i, ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
144 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
145 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
146 |
|
|
147 |
lock_kernel(); |
lock_kernel(); |
148 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
149 |
--- linux-2.4.37.orig/arch/ia64/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/ia64/kernel/ptrace.c |
150 |
+++ linux-2.4.37/arch/ia64/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/ia64/kernel/ptrace.c |
151 |
@@ -27,6 +27,9 @@ |
@@ -27,6 +27,7 @@ |
152 |
#ifdef CONFIG_PERFMON |
#ifdef CONFIG_PERFMON |
153 |
#include <asm/perfmon.h> |
#include <asm/perfmon.h> |
154 |
#endif |
#endif |
155 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
156 |
|
|
157 |
#define offsetof(type,field) ((unsigned long) &((type *) 0)->field) |
#define offsetof(type,field) ((unsigned long) &((type *) 0)->field) |
158 |
|
|
159 |
@@ -1273,6 +1276,10 @@ sys_ptrace (long request, pid_t pid, uns |
@@ -1273,6 +1274,8 @@ sys_ptrace (long request, pid_t pid, uns |
160 |
struct task_struct *child; |
struct task_struct *child; |
161 |
struct switch_stack *sw; |
struct switch_stack *sw; |
162 |
long ret; |
long ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
163 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
164 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
165 |
|
|
166 |
lock_kernel(); |
lock_kernel(); |
167 |
ret = -EPERM; |
ret = -EPERM; |
168 |
--- linux-2.4.37.orig/arch/m68k/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/m68k/kernel/ptrace.c |
169 |
+++ linux-2.4.37/arch/m68k/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/m68k/kernel/ptrace.c |
170 |
@@ -25,6 +25,9 @@ |
@@ -25,6 +25,7 @@ |
171 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
172 |
#include <asm/system.h> |
#include <asm/system.h> |
173 |
#include <asm/processor.h> |
#include <asm/processor.h> |
174 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
175 |
|
|
176 |
/* |
/* |
177 |
* does not yet catch signals sent when the child dies. |
* does not yet catch signals sent when the child dies. |
178 |
@@ -104,6 +107,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -104,6 +105,8 @@ asmlinkage int sys_ptrace(long request, |
179 |
{ |
{ |
180 |
struct task_struct *child; |
struct task_struct *child; |
181 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
182 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
183 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
184 |
|
|
185 |
lock_kernel(); |
lock_kernel(); |
186 |
ret = -EPERM; |
ret = -EPERM; |
187 |
--- linux-2.4.37.orig/arch/mips/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/mips/kernel/ptrace.c |
188 |
+++ linux-2.4.37/arch/mips/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/mips/kernel/ptrace.c |
189 |
@@ -28,6 +28,9 @@ |
@@ -28,6 +28,7 @@ |
190 |
#include <asm/bootinfo.h> |
#include <asm/bootinfo.h> |
191 |
#include <asm/cpu.h> |
#include <asm/cpu.h> |
192 |
#include <asm/fpu.h> |
#include <asm/fpu.h> |
193 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
194 |
|
|
195 |
/* |
/* |
196 |
* Called by kernel/ptrace.c when detaching.. |
* Called by kernel/ptrace.c when detaching.. |
197 |
@@ -43,6 +46,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -43,6 +44,8 @@ asmlinkage int sys_ptrace(long request, |
198 |
{ |
{ |
199 |
struct task_struct *child; |
struct task_struct *child; |
200 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
201 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
202 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
203 |
|
|
204 |
lock_kernel(); |
lock_kernel(); |
205 |
#if 0 |
#if 0 |
206 |
--- linux-2.4.37.orig/arch/mips64/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/mips64/kernel/ptrace.c |
207 |
+++ linux-2.4.37/arch/mips64/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/mips64/kernel/ptrace.c |
208 |
@@ -30,6 +30,9 @@ |
@@ -30,6 +30,7 @@ |
209 |
#include <asm/system.h> |
#include <asm/system.h> |
210 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
211 |
#include <asm/bootinfo.h> |
#include <asm/bootinfo.h> |
212 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
213 |
|
|
214 |
/* |
/* |
215 |
* Called by kernel/ptrace.c when detaching.. |
* Called by kernel/ptrace.c when detaching.. |
216 |
@@ -49,6 +52,10 @@ asmlinkage int sys32_ptrace(int request, |
@@ -49,6 +50,8 @@ asmlinkage int sys32_ptrace(int request, |
217 |
{ |
{ |
218 |
struct task_struct *child; |
struct task_struct *child; |
219 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
220 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
221 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
222 |
|
|
223 |
lock_kernel(); |
lock_kernel(); |
224 |
ret = -EPERM; |
ret = -EPERM; |
225 |
@@ -288,6 +295,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -288,6 +291,8 @@ asmlinkage int sys_ptrace(long request, |
226 |
{ |
{ |
227 |
struct task_struct *child; |
struct task_struct *child; |
228 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
229 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
230 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
231 |
|
|
232 |
lock_kernel(); |
lock_kernel(); |
233 |
#if 0 |
#if 0 |
234 |
--- linux-2.4.37.orig/arch/parisc/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/parisc/kernel/ptrace.c |
235 |
+++ linux-2.4.37/arch/parisc/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/parisc/kernel/ptrace.c |
236 |
@@ -21,6 +21,9 @@ |
@@ -21,6 +21,7 @@ |
237 |
#include <asm/system.h> |
#include <asm/system.h> |
238 |
#include <asm/processor.h> |
#include <asm/processor.h> |
239 |
#include <asm/offset.h> |
#include <asm/offset.h> |
240 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
241 |
|
|
242 |
/* These are used in entry.S, syscall_restore_rfi. We need to record the |
/* These are used in entry.S, syscall_restore_rfi. We need to record the |
243 |
* current stepping mode somewhere other than in PSW, because there is no |
* current stepping mode somewhere other than in PSW, because there is no |
244 |
@@ -94,6 +97,10 @@ long sys_ptrace(long request, pid_t pid, |
@@ -94,6 +95,8 @@ long sys_ptrace(long request, pid_t pid, |
245 |
#ifdef DEBUG_PTRACE |
#ifdef DEBUG_PTRACE |
246 |
long oaddr=addr, odata=data; |
long oaddr=addr, odata=data; |
247 |
#endif |
#endif |
|
+ /***** TOMOYO Linux start. *****/ |
|
248 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
249 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
250 |
|
|
251 |
lock_kernel(); |
lock_kernel(); |
252 |
ret = -EPERM; |
ret = -EPERM; |
253 |
--- linux-2.4.37.orig/arch/ppc/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/ppc/kernel/ptrace.c |
254 |
+++ linux-2.4.37/arch/ppc/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/ppc/kernel/ptrace.c |
255 |
@@ -29,6 +29,9 @@ |
@@ -29,6 +29,7 @@ |
256 |
#include <asm/page.h> |
#include <asm/page.h> |
257 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
258 |
#include <asm/system.h> |
#include <asm/system.h> |
259 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
260 |
|
|
261 |
/* |
/* |
262 |
* Set of msr bits that gdb can change on behalf of a process. |
* Set of msr bits that gdb can change on behalf of a process. |
263 |
@@ -171,6 +174,10 @@ int sys_ptrace(long request, long pid, l |
@@ -171,6 +172,8 @@ int sys_ptrace(long request, long pid, l |
264 |
{ |
{ |
265 |
struct task_struct *child; |
struct task_struct *child; |
266 |
int ret = -EPERM; |
int ret = -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
267 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
268 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
269 |
|
|
270 |
lock_kernel(); |
lock_kernel(); |
271 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
272 |
--- linux-2.4.37.orig/arch/ppc64/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/ppc64/kernel/ptrace.c |
273 |
+++ linux-2.4.37/arch/ppc64/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/ppc64/kernel/ptrace.c |
274 |
@@ -30,6 +30,9 @@ |
@@ -30,6 +30,7 @@ |
275 |
#include <asm/page.h> |
#include <asm/page.h> |
276 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
277 |
#include <asm/system.h> |
#include <asm/system.h> |
278 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
279 |
|
|
280 |
/* |
/* |
281 |
* Set of msr bits that gdb can change on behalf of a process. |
* Set of msr bits that gdb can change on behalf of a process. |
282 |
@@ -120,6 +123,10 @@ int sys_ptrace(long request, long pid, l |
@@ -120,6 +121,8 @@ int sys_ptrace(long request, long pid, l |
283 |
{ |
{ |
284 |
struct task_struct *child; |
struct task_struct *child; |
285 |
int ret = -EPERM; |
int ret = -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
286 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
287 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
288 |
|
|
289 |
lock_kernel(); |
lock_kernel(); |
290 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
291 |
--- linux-2.4.37.orig/arch/ppc64/kernel/ptrace32.c |
--- linux-2.4.37.6.orig/arch/ppc64/kernel/ptrace32.c |
292 |
+++ linux-2.4.37/arch/ppc64/kernel/ptrace32.c |
+++ linux-2.4.37.6/arch/ppc64/kernel/ptrace32.c |
293 |
@@ -30,6 +30,9 @@ |
@@ -30,6 +30,7 @@ |
294 |
#include <asm/page.h> |
#include <asm/page.h> |
295 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
296 |
#include <asm/system.h> |
#include <asm/system.h> |
297 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
298 |
|
|
299 |
#ifdef CONFIG_ALTIVEC |
#ifdef CONFIG_ALTIVEC |
300 |
/* |
/* |
301 |
@@ -121,6 +124,10 @@ int sys32_ptrace(long request, long pid, |
@@ -121,6 +122,8 @@ int sys32_ptrace(long request, long pid, |
302 |
{ |
{ |
303 |
struct task_struct *child; |
struct task_struct *child; |
304 |
int ret = -EPERM; |
int ret = -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
305 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
306 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
307 |
|
|
308 |
lock_kernel(); |
lock_kernel(); |
309 |
if (request == PTRACE_TRACEME) { |
if (request == PTRACE_TRACEME) { |
310 |
--- linux-2.4.37.orig/arch/s390/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/s390/kernel/ptrace.c |
311 |
+++ linux-2.4.37/arch/s390/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/s390/kernel/ptrace.c |
312 |
@@ -37,6 +37,9 @@ |
@@ -37,6 +37,7 @@ |
313 |
#include <asm/pgalloc.h> |
#include <asm/pgalloc.h> |
314 |
#include <asm/system.h> |
#include <asm/system.h> |
315 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
316 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
317 |
|
|
318 |
|
|
319 |
void FixPerRegisters(struct task_struct *task) |
void FixPerRegisters(struct task_struct *task) |
320 |
@@ -221,6 +224,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -221,6 +222,8 @@ asmlinkage int sys_ptrace(long request, |
321 |
unsigned long tmp; |
unsigned long tmp; |
322 |
int copied; |
int copied; |
323 |
ptrace_area parea; |
ptrace_area parea; |
|
+ /***** TOMOYO Linux start. *****/ |
|
324 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
325 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
326 |
|
|
327 |
lock_kernel(); |
lock_kernel(); |
328 |
if (request == PTRACE_TRACEME) |
if (request == PTRACE_TRACEME) |
329 |
--- linux-2.4.37.orig/arch/s390x/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/s390x/kernel/ptrace.c |
330 |
+++ linux-2.4.37/arch/s390x/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/s390x/kernel/ptrace.c |
331 |
@@ -43,6 +43,9 @@ |
@@ -43,6 +43,7 @@ |
332 |
#else |
#else |
333 |
#define parent_31bit 0 |
#define parent_31bit 0 |
334 |
#endif |
#endif |
335 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
336 |
|
|
337 |
|
|
338 |
void FixPerRegisters(struct task_struct *task) |
void FixPerRegisters(struct task_struct *task) |
339 |
@@ -431,6 +434,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -431,6 +432,8 @@ asmlinkage int sys_ptrace(long request, |
340 |
#define sizeof_parent_long 8 |
#define sizeof_parent_long 8 |
341 |
#define dataptr (u8 *)&data |
#define dataptr (u8 *)&data |
342 |
#endif |
#endif |
|
+ /***** TOMOYO Linux start. *****/ |
|
343 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
344 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
345 |
lock_kernel(); |
lock_kernel(); |
346 |
if (request == PTRACE_TRACEME) |
if (request == PTRACE_TRACEME) |
347 |
{ |
{ |
348 |
--- linux-2.4.37.orig/arch/sh/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/sh/kernel/ptrace.c |
349 |
+++ linux-2.4.37/arch/sh/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/sh/kernel/ptrace.c |
350 |
@@ -26,6 +26,9 @@ |
@@ -26,6 +26,7 @@ |
351 |
#include <asm/system.h> |
#include <asm/system.h> |
352 |
#include <asm/processor.h> |
#include <asm/processor.h> |
353 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
354 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
355 |
|
|
356 |
/* |
/* |
357 |
* does not yet catch signals sent when the child dies. |
* does not yet catch signals sent when the child dies. |
358 |
@@ -144,6 +147,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -144,6 +145,8 @@ asmlinkage int sys_ptrace(long request, |
359 |
struct task_struct *child, *tsk = current; |
struct task_struct *child, *tsk = current; |
360 |
struct user * dummy = NULL; |
struct user * dummy = NULL; |
361 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
362 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
363 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
364 |
|
|
365 |
lock_kernel(); |
lock_kernel(); |
366 |
ret = -EPERM; |
ret = -EPERM; |
367 |
--- linux-2.4.37.orig/arch/sh64/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/sh64/kernel/ptrace.c |
368 |
+++ linux-2.4.37/arch/sh64/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/sh64/kernel/ptrace.c |
369 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
370 |
#include <asm/system.h> |
#include <asm/system.h> |
371 |
#include <asm/processor.h> |
#include <asm/processor.h> |
372 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
373 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
374 |
|
|
375 |
/* This mask defines the bits of the SR which the user is not allowed to |
/* This mask defines the bits of the SR which the user is not allowed to |
376 |
change, which are everything except S, Q, M, PR, SZ, FR. */ |
change, which are everything except S, Q, M, PR, SZ, FR. */ |
377 |
@@ -122,6 +125,10 @@ asmlinkage int sys_ptrace(long request, |
@@ -122,6 +123,8 @@ asmlinkage int sys_ptrace(long request, |
378 |
{ |
{ |
379 |
struct task_struct *child, *tsk = current; |
struct task_struct *child, *tsk = current; |
380 |
int ret; |
int ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
381 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
382 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
383 |
|
|
384 |
lock_kernel(); |
lock_kernel(); |
385 |
ret = -EPERM; |
ret = -EPERM; |
386 |
--- linux-2.4.37.orig/arch/sparc/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/sparc/kernel/ptrace.c |
387 |
+++ linux-2.4.37/arch/sparc/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/sparc/kernel/ptrace.c |
388 |
@@ -21,6 +21,9 @@ |
@@ -21,6 +21,7 @@ |
389 |
#include <asm/pgtable.h> |
#include <asm/pgtable.h> |
390 |
#include <asm/system.h> |
#include <asm/system.h> |
391 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
392 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
393 |
|
|
394 |
#define MAGIC_CONSTANT 0x80000000 |
#define MAGIC_CONSTANT 0x80000000 |
395 |
|
|
396 |
@@ -262,6 +265,12 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -262,6 +263,10 @@ asmlinkage void do_ptrace(struct pt_regs |
397 |
unsigned long data = regs->u_regs[UREG_I3]; |
unsigned long data = regs->u_regs[UREG_I3]; |
398 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
399 |
struct task_struct *child; |
struct task_struct *child; |
|
+ /***** TOMOYO Linux start. *****/ |
|
400 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
401 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
402 |
+ return; |
+ return; |
403 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
404 |
|
|
405 |
lock_kernel(); |
lock_kernel(); |
406 |
#ifdef DEBUG_PTRACE |
#ifdef DEBUG_PTRACE |
407 |
--- linux-2.4.37.orig/arch/sparc64/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/sparc64/kernel/ptrace.c |
408 |
+++ linux-2.4.37/arch/sparc64/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/sparc64/kernel/ptrace.c |
409 |
@@ -26,6 +26,9 @@ |
@@ -26,6 +26,7 @@ |
410 |
#include <asm/psrcompat.h> |
#include <asm/psrcompat.h> |
411 |
#include <asm/visasm.h> |
#include <asm/visasm.h> |
412 |
#include <asm/spitfire.h> |
#include <asm/spitfire.h> |
413 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
414 |
|
|
415 |
#define MAGIC_CONSTANT 0x80000000 |
#define MAGIC_CONSTANT 0x80000000 |
416 |
|
|
417 |
@@ -108,6 +111,12 @@ asmlinkage void do_ptrace(struct pt_regs |
@@ -108,6 +109,10 @@ asmlinkage void do_ptrace(struct pt_regs |
418 |
unsigned long data = regs->u_regs[UREG_I3]; |
unsigned long data = regs->u_regs[UREG_I3]; |
419 |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
unsigned long addr2 = regs->u_regs[UREG_I4]; |
420 |
struct task_struct *child; |
struct task_struct *child; |
|
+ /***** TOMOYO Linux start. *****/ |
|
421 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
+ if (!ccs_capable(CCS_SYS_PTRACE)) { |
422 |
+ pt_error_return(regs, EPERM); |
+ pt_error_return(regs, EPERM); |
423 |
+ return; |
+ return; |
424 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
425 |
|
|
426 |
if (current->thread.flags & SPARC_FLAG_32BIT) { |
if (current->thread.flags & SPARC_FLAG_32BIT) { |
427 |
addr &= 0xffffffffUL; |
addr &= 0xffffffffUL; |
428 |
--- linux-2.4.37.orig/arch/x86_64/ia32/ptrace32.c |
--- linux-2.4.37.6.orig/arch/x86_64/ia32/ptrace32.c |
429 |
+++ linux-2.4.37/arch/x86_64/ia32/ptrace32.c |
+++ linux-2.4.37.6/arch/x86_64/ia32/ptrace32.c |
430 |
@@ -24,6 +24,9 @@ |
@@ -24,6 +24,7 @@ |
431 |
#include <asm/i387.h> |
#include <asm/i387.h> |
432 |
#include <asm/fpu32.h> |
#include <asm/fpu32.h> |
433 |
#include <linux/mm.h> |
#include <linux/mm.h> |
434 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
435 |
|
|
436 |
/* determines which flags the user has access to. */ |
/* determines which flags the user has access to. */ |
437 |
/* 1 = access 0 = no access */ |
/* 1 = access 0 = no access */ |
438 |
@@ -203,6 +206,10 @@ asmlinkage long sys32_ptrace(long reques |
@@ -203,6 +204,8 @@ asmlinkage long sys32_ptrace(long reques |
439 |
struct pt_regs *childregs; |
struct pt_regs *childregs; |
440 |
int ret; |
int ret; |
441 |
__u32 val; |
__u32 val; |
|
+ /***** TOMOYO Linux start. *****/ |
|
442 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
443 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
444 |
|
|
445 |
switch (request) { |
switch (request) { |
446 |
case PTRACE_TRACEME: |
case PTRACE_TRACEME: |
447 |
--- linux-2.4.37.orig/arch/x86_64/kernel/ptrace.c |
--- linux-2.4.37.6.orig/arch/x86_64/kernel/ptrace.c |
448 |
+++ linux-2.4.37/arch/x86_64/kernel/ptrace.c |
+++ linux-2.4.37.6/arch/x86_64/kernel/ptrace.c |
449 |
@@ -22,6 +22,9 @@ |
@@ -22,6 +22,7 @@ |
450 |
#include <asm/processor.h> |
#include <asm/processor.h> |
451 |
#include <asm/i387.h> |
#include <asm/i387.h> |
452 |
#include <asm/debugreg.h> |
#include <asm/debugreg.h> |
453 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
454 |
|
|
455 |
/* |
/* |
456 |
* does not yet catch signals sent when the child dies. |
* does not yet catch signals sent when the child dies. |
457 |
@@ -180,6 +183,10 @@ asmlinkage long sys_ptrace(long request, |
@@ -180,6 +181,8 @@ asmlinkage long sys_ptrace(long request, |
458 |
struct task_struct *child; |
struct task_struct *child; |
459 |
struct user * dummy = NULL; |
struct user * dummy = NULL; |
460 |
long i, ret; |
long i, ret; |
|
+ /***** TOMOYO Linux start. *****/ |
|
461 |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
+ if (!ccs_capable(CCS_SYS_PTRACE)) |
462 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
463 |
|
|
464 |
/* This lock_kernel fixes a subtle race with suid exec */ |
/* This lock_kernel fixes a subtle race with suid exec */ |
465 |
lock_kernel(); |
lock_kernel(); |
466 |
--- linux-2.4.37.orig/fs/Config.in |
--- linux-2.4.37.6.orig/fs/Config.in |
467 |
+++ linux-2.4.37/fs/Config.in |
+++ linux-2.4.37.6/fs/Config.in |
468 |
@@ -176,4 +176,7 @@ comment 'Partition Types' |
@@ -176,4 +176,7 @@ comment 'Partition Types' |
469 |
source fs/partitions/Config.in |
source fs/partitions/Config.in |
470 |
endmenu |
endmenu |
471 |
source fs/nls/Config.in |
source fs/nls/Config.in |
472 |
+ |
+ |
|
+source fs/Config.ccs.in |
|
|
+ |
|
473 |
endmenu |
endmenu |
474 |
--- linux-2.4.37.orig/fs/Makefile |
+ |
475 |
+++ linux-2.4.37/fs/Makefile |
+source security/ccsecurity/Config.in |
476 |
@@ -80,5 +80,5 @@ obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o |
--- linux-2.4.37.6.orig/fs/Makefile |
477 |
|
+++ linux-2.4.37.6/fs/Makefile |
478 |
|
@@ -80,5 +80,7 @@ obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o |
479 |
# persistent filesystems |
# persistent filesystems |
480 |
obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o)) |
obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o)) |
481 |
|
|
482 |
- |
+subdir-$(CONFIG_CCSECURITY) += ../security/ccsecurity |
483 |
+include Makefile-2.4.ccs |
+obj-$(CONFIG_CCSECURITY) += ../security/ccsecurity/ccsecurity.o |
484 |
|
|
485 |
include $(TOPDIR)/Rules.make |
include $(TOPDIR)/Rules.make |
486 |
--- linux-2.4.37.orig/fs/attr.c |
--- linux-2.4.37.6.orig/fs/attr.c |
487 |
+++ linux-2.4.37/fs/attr.c |
+++ linux-2.4.37.6/fs/attr.c |
488 |
@@ -12,6 +12,9 @@ |
@@ -12,6 +12,7 @@ |
489 |
#include <linux/dnotify.h> |
#include <linux/dnotify.h> |
490 |
#include <linux/fcntl.h> |
#include <linux/fcntl.h> |
491 |
#include <linux/quotaops.h> |
#include <linux/quotaops.h> |
492 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
493 |
|
|
494 |
/* Taken over from the old code... */ |
/* Taken over from the old code... */ |
495 |
|
|
496 |
@@ -127,6 +130,13 @@ int notify_change(struct dentry * dentry |
@@ -127,6 +128,9 @@ int notify_change(struct dentry * dentry |
497 |
attr->ia_atime = now; |
attr->ia_atime = now; |
498 |
if (!(ia_valid & ATTR_MTIME_SET)) |
if (!(ia_valid & ATTR_MTIME_SET)) |
499 |
attr->ia_mtime = now; |
attr->ia_mtime = now; |
500 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_setattr_permission(dentry, attr); |
501 |
+ if ((ia_valid & ATTR_MODE) && !ccs_capable(CCS_SYS_CHMOD)) |
+ if (error) |
502 |
+ return -EPERM; |
+ return error; |
|
+ if ((ia_valid & (ATTR_UID | ATTR_GID)) && |
|
|
+ !ccs_capable(CCS_SYS_CHOWN)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
503 |
|
|
504 |
lock_kernel(); |
lock_kernel(); |
505 |
if (inode->i_op && inode->i_op->setattr) |
if (inode->i_op && inode->i_op->setattr) |
506 |
--- linux-2.4.37.orig/fs/exec.c |
--- linux-2.4.37.6.orig/fs/exec.c |
507 |
+++ linux-2.4.37/fs/exec.c |
+++ linux-2.4.37.6/fs/exec.c |
508 |
@@ -48,6 +48,10 @@ |
@@ -48,6 +48,8 @@ |
509 |
#include <linux/kmod.h> |
#include <linux/kmod.h> |
510 |
#endif |
#endif |
511 |
|
|
512 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
513 |
+ |
+ |
514 |
int core_uses_pid; |
int core_uses_pid; |
515 |
char core_pattern[65] = "core"; |
char core_pattern[65] = "core"; |
516 |
int core_setuid_ok = 0; |
int core_setuid_ok = 0; |
517 |
@@ -125,6 +129,13 @@ asmlinkage long sys_uselib(const char * |
@@ -125,6 +127,10 @@ asmlinkage long sys_uselib(const char * |
518 |
if (error) |
if (error) |
519 |
goto exit; |
goto exit; |
520 |
|
|
521 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_uselib_permission(nd.dentry, nd.mnt); |
|
+ /* 01 means "read". */ |
|
|
+ error = ccs_check_open_permission(nd.dentry, nd.mnt, 01); |
|
522 |
+ if (error) |
+ if (error) |
523 |
+ goto exit; |
+ goto exit; |
|
+ /***** TOMOYO Linux end. *****/ |
|
524 |
+ |
+ |
525 |
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); |
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); |
526 |
error = PTR_ERR(file); |
error = PTR_ERR(file); |
527 |
if (IS_ERR(file)) |
if (IS_ERR(file)) |
528 |
@@ -389,6 +400,13 @@ struct file *open_exec(const char *name) |
@@ -389,6 +395,9 @@ struct file *open_exec(const char *name) |
529 |
int err = permission(inode, MAY_EXEC); |
int err = permission(inode, MAY_EXEC); |
530 |
if (!err && !(inode->i_mode & 0111)) |
if (!err && !(inode->i_mode & 0111)) |
531 |
err = -EACCES; |
err = -EACCES; |
532 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!err) |
533 |
+ if (!err && (current->ccs_flags & |
+ err = ccs_open_exec_permission(nd.dentry, |
534 |
+ CCS_CHECK_READ_FOR_OPEN_EXEC)) |
+ nd.mnt); |
|
+ /* 01 means "read". */ |
|
|
+ err = ccs_check_open_permission(nd.dentry, |
|
|
+ nd.mnt, 01); |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
535 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
536 |
if (!err) { |
if (!err) { |
537 |
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); |
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); |
538 |
@@ -986,7 +1004,8 @@ int do_execve(char * filename, char ** a |
@@ -989,7 +998,8 @@ int do_execve(char * filename, char ** a |
539 |
if (retval < 0) |
if (retval < 0) |
540 |
goto out; |
goto out; |
541 |
|
|
542 |
- retval = search_binary_handler(&bprm,regs); |
- retval = search_binary_handler(&bprm,regs); |
543 |
+ retval = search_binary_handler_with_transition(&bprm, regs); |
+ retval = ccs_search_binary_handler(&bprm, regs); |
544 |
+ |
+ |
545 |
if (retval >= 0) |
if (retval >= 0) |
546 |
/* execve success */ |
/* execve success */ |
547 |
return retval; |
return retval; |
548 |
--- linux-2.4.37.orig/fs/fcntl.c |
--- linux-2.4.37.6.orig/fs/fcntl.c |
549 |
+++ linux-2.4.37/fs/fcntl.c |
+++ linux-2.4.37.6/fs/fcntl.c |
550 |
@@ -16,6 +16,9 @@ |
@@ -16,6 +16,7 @@ |
551 |
#include <asm/poll.h> |
#include <asm/poll.h> |
552 |
#include <asm/siginfo.h> |
#include <asm/siginfo.h> |
553 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
554 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
555 |
|
|
556 |
extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg); |
extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg); |
557 |
extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); |
extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); |
558 |
@@ -214,6 +217,11 @@ static int setfl(int fd, struct file * f |
@@ -214,6 +215,9 @@ static int setfl(int fd, struct file * f |
559 |
if (!(arg & O_APPEND) && IS_APPEND(inode)) |
if (!(arg & O_APPEND) && IS_APPEND(inode)) |
560 |
return -EPERM; |
return -EPERM; |
561 |
|
|
562 |
+ /***** TOMOYO Linux start. *****/ |
+ if (!(arg & O_APPEND) && ccs_rewrite_permission(filp)) |
|
+ if (!(arg & O_APPEND) && ccs_check_rewrite_permission(filp)) |
|
563 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
564 |
+ |
+ |
565 |
/* Did FASYNC state change? */ |
/* Did FASYNC state change? */ |
566 |
if ((arg ^ filp->f_flags) & FASYNC) { |
if ((arg ^ filp->f_flags) & FASYNC) { |
567 |
if (filp->f_op && filp->f_op->fasync) { |
if (filp->f_op && filp->f_op->fasync) { |
568 |
--- linux-2.4.37.orig/fs/ioctl.c |
--- linux-2.4.37.6.orig/fs/ioctl.c |
569 |
+++ linux-2.4.37/fs/ioctl.c |
+++ linux-2.4.37.6/fs/ioctl.c |
570 |
@@ -10,6 +10,9 @@ |
@@ -10,6 +10,7 @@ |
571 |
|
|
572 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
573 |
#include <asm/ioctls.h> |
#include <asm/ioctls.h> |
574 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
575 |
|
|
576 |
static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg) |
static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg) |
577 |
{ |
{ |
578 |
@@ -55,6 +58,13 @@ asmlinkage long sys_ioctl(unsigned int f |
@@ -55,6 +56,11 @@ asmlinkage long sys_ioctl(unsigned int f |
579 |
filp = fget(fd); |
filp = fget(fd); |
580 |
if (!filp) |
if (!filp) |
581 |
goto out; |
goto out; |
582 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
|
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
|
583 |
+ if (error) { |
+ if (error) { |
584 |
+ fput(filp); |
+ fput(filp); |
585 |
+ goto out; |
+ goto out; |
586 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
587 |
error = 0; |
error = 0; |
588 |
lock_kernel(); |
lock_kernel(); |
589 |
switch (cmd) { |
switch (cmd) { |
590 |
@@ -112,6 +122,12 @@ asmlinkage long sys_ioctl(unsigned int f |
@@ -112,6 +118,10 @@ asmlinkage long sys_ioctl(unsigned int f |
591 |
error = -ENOTTY; |
error = -ENOTTY; |
592 |
break; |
break; |
593 |
default: |
default: |
|
+ /***** TOMOYO Linux start. *****/ |
|
594 |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
+ if (!ccs_capable(CCS_SYS_IOCTL)) { |
595 |
+ error = -EPERM; |
+ error = -EPERM; |
596 |
+ break; |
+ break; |
597 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
598 |
error = -ENOTTY; |
error = -ENOTTY; |
599 |
if (S_ISREG(filp->f_dentry->d_inode->i_mode)) |
if (S_ISREG(filp->f_dentry->d_inode->i_mode)) |
600 |
error = file_ioctl(filp, cmd, arg); |
error = file_ioctl(filp, cmd, arg); |
601 |
--- linux-2.4.37.orig/fs/namei.c |
--- linux-2.4.37.6.orig/fs/namei.c |
602 |
+++ linux-2.4.37/fs/namei.c |
+++ linux-2.4.37.6/fs/namei.c |
603 |
@@ -28,6 +28,11 @@ |
@@ -28,6 +28,9 @@ |
604 |
|
|
605 |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
606 |
|
|
607 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
608 |
+#include <linux/module.h> |
+#include <linux/module.h> |
|
+/***** TOMOYO Linux end. *****/ |
|
609 |
+ |
+ |
610 |
/* [Feb-1997 T. Schoebel-Theuer] |
/* [Feb-1997 T. Schoebel-Theuer] |
611 |
* Fundamental changes in the pathname lookup mechanisms (namei) |
* Fundamental changes in the pathname lookup mechanisms (namei) |
612 |
* were necessary because of omirr. The reason is that omirr needs |
* were necessary because of omirr. The reason is that omirr needs |
613 |
@@ -1003,6 +1008,9 @@ exit_lock: |
@@ -1003,6 +1006,7 @@ exit_lock: |
614 |
return error; |
return error; |
615 |
} |
} |
616 |
|
|
617 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity_vfs.h> |
|
+#include <linux/tomoyo_vfs.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
618 |
/* |
/* |
619 |
* open_namei() |
* open_namei() |
620 |
* |
* |
621 |
@@ -1068,6 +1076,13 @@ do_last: |
@@ -1068,6 +1072,9 @@ do_last: |
622 |
|
|
623 |
/* Negative dentry, just create the file */ |
/* Negative dentry, just create the file */ |
624 |
if (!dentry->d_inode) { |
if (!dentry->d_inode) { |
625 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_mknod_permission(dir->d_inode, dentry, nd->mnt, |
626 |
+ error = pre_vfs_create(dir->d_inode, dentry); |
+ mode & ~current->fs->umask, 0); |
|
+ if (!error) |
|
|
+ error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, |
|
|
+ nd->mnt); |
|
627 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
628 |
error = vfs_create(dir->d_inode, dentry, |
error = vfs_create(dir->d_inode, dentry, |
629 |
mode & ~current->fs->umask); |
mode & ~current->fs->umask); |
630 |
up(&dir->d_inode->i_sem); |
up(&dir->d_inode->i_sem); |
631 |
@@ -1154,6 +1169,13 @@ ok: |
@@ -1154,6 +1161,11 @@ ok: |
632 |
goto exit; |
goto exit; |
633 |
} |
} |
634 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
635 |
+ /* includes O_APPEND and O_TRUNC checks */ |
+ /* includes O_APPEND and O_TRUNC checks */ |
636 |
+ error = ccs_check_open_permission(dentry, nd->mnt, flag); |
+ error = ccs_open_permission(dentry, nd->mnt, flag); |
637 |
+ if (error) |
+ if (error) |
638 |
+ goto exit; |
+ goto exit; |
|
+ /***** TOMOYO Linux end. *****/ |
|
639 |
+ |
+ |
640 |
/* |
/* |
641 |
* Ensure there are no outstanding leases on the file. |
* Ensure there are no outstanding leases on the file. |
642 |
*/ |
*/ |
643 |
@@ -1292,6 +1314,17 @@ asmlinkage long sys_mknod(const char * f |
@@ -1292,6 +1304,7 @@ asmlinkage long sys_mknod(const char * f |
644 |
|
|
645 |
if (S_ISDIR(mode)) |
if (S_ISDIR(mode)) |
646 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (S_ISCHR(mode) && !ccs_capable(CCS_CREATE_CHAR_DEV)) |
|
|
+ return -EPERM; |
|
|
+ if (S_ISBLK(mode) && !ccs_capable(CCS_CREATE_BLOCK_DEV)) |
|
|
+ return -EPERM; |
|
|
+ if (S_ISFIFO(mode) && !ccs_capable(CCS_CREATE_FIFO)) |
|
|
+ return -EPERM; |
|
|
+ if (S_ISSOCK(mode) && !ccs_capable(CCS_CREATE_UNIX_SOCKET)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
647 |
+ |
+ |
648 |
tmp = getname(filename); |
tmp = getname(filename); |
649 |
if (IS_ERR(tmp)) |
if (IS_ERR(tmp)) |
650 |
return PTR_ERR(tmp); |
return PTR_ERR(tmp); |
651 |
@@ -1306,9 +1339,33 @@ asmlinkage long sys_mknod(const char * f |
@@ -1304,6 +1317,10 @@ asmlinkage long sys_mknod(const char * f |
652 |
|
|
653 |
|
mode &= ~current->fs->umask; |
654 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
655 |
|
+ error = ccs_mknod_permission(nd.dentry->d_inode, dentry, |
656 |
|
+ nd.mnt, mode, dev); |
657 |
|
+ if (error) |
658 |
|
+ goto out_dput; |
659 |
switch (mode & S_IFMT) { |
switch (mode & S_IFMT) { |
660 |
case 0: case S_IFREG: |
case 0: case S_IFREG: |
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ error = pre_vfs_create(nd.dentry->d_inode, dentry); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ error = ccs_check_1path_perm(TYPE_CREATE_ACL, dentry, |
|
|
+ nd.mnt); |
|
|
+ if (error) |
|
|
+ break; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
661 |
error = vfs_create(nd.dentry->d_inode,dentry,mode); |
error = vfs_create(nd.dentry->d_inode,dentry,mode); |
662 |
break; |
@@ -1317,6 +1334,7 @@ asmlinkage long sys_mknod(const char * f |
663 |
case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: |
default: |
664 |
+ /***** TOMOYO Linux start. *****/ |
error = -EINVAL; |
665 |
+ error = pre_vfs_mknod(nd.dentry->d_inode, dentry); |
} |
666 |
+ if (error) |
+out_dput: |
667 |
+ break; |
dput(dentry); |
668 |
+ error = ccs_check_1path_perm(S_ISCHR(mode) ? |
} |
669 |
+ TYPE_MKCHAR_ACL : |
up(&nd.dentry->d_inode->i_sem); |
670 |
+ S_ISBLK(mode) ? |
@@ -1370,6 +1388,9 @@ asmlinkage long sys_mkdir(const char * p |
|
+ TYPE_MKBLOCK_ACL : |
|
|
+ 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,dev); |
|
|
break; |
|
|
case S_IFDIR: |
|
|
@@ -1370,6 +1427,13 @@ asmlinkage long sys_mkdir(const char * p |
|
671 |
dentry = lookup_create(&nd, 1); |
dentry = lookup_create(&nd, 1); |
672 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
673 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
674 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_mkdir_permission(nd.dentry->d_inode, |
675 |
+ 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); |
|
676 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
677 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, |
error = vfs_mkdir(nd.dentry->d_inode, dentry, |
678 |
mode & ~current->fs->umask); |
mode & ~current->fs->umask); |
679 |
dput(dentry); |
dput(dentry); |
680 |
@@ -1479,6 +1543,13 @@ asmlinkage long sys_rmdir(const char * p |
@@ -1479,6 +1500,9 @@ asmlinkage long sys_rmdir(const char * p |
681 |
dentry = lookup_hash(&nd.last, nd.dentry); |
dentry = lookup_hash(&nd.last, nd.dentry); |
682 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
683 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
684 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, |
685 |
+ error = pre_vfs_rmdir(nd.dentry->d_inode, dentry); |
+ nd.mnt); |
|
+ if (!error) |
|
|
+ error = ccs_check_1path_perm(TYPE_RMDIR_ACL, dentry, |
|
|
+ nd.mnt); |
|
686 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
687 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
688 |
dput(dentry); |
dput(dentry); |
689 |
} |
} |
690 |
@@ -1530,6 +1601,10 @@ asmlinkage long sys_unlink(const char * |
@@ -1548,6 +1572,10 @@ asmlinkage long sys_unlink(const char * |
|
char * name; |
|
|
struct dentry *dentry; |
|
|
struct nameidata nd; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(CCS_SYS_UNLINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
name = getname(pathname); |
|
|
if(IS_ERR(name)) |
|
|
@@ -1548,6 +1623,14 @@ asmlinkage long sys_unlink(const char * |
|
691 |
/* Why not before? Because we want correct error value */ |
/* Why not before? Because we want correct error value */ |
692 |
if (nd.last.name[nd.last.len]) |
if (nd.last.name[nd.last.len]) |
693 |
goto slashes; |
goto slashes; |
694 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_unlink_permission(nd.dentry->d_inode, dentry, |
695 |
+ error = pre_vfs_unlink(nd.dentry->d_inode, dentry); |
+ nd.mnt); |
|
+ if (error) |
|
|
+ goto exit2; |
|
|
+ error = ccs_check_1path_perm(TYPE_UNLINK_ACL, dentry, nd.mnt); |
|
696 |
+ if (error) |
+ if (error) |
697 |
+ goto exit2; |
+ goto exit2; |
|
+ /***** TOMOYO Linux end. *****/ |
|
698 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
699 |
exit2: |
exit2: |
700 |
dput(dentry); |
dput(dentry); |
701 |
@@ -1596,6 +1679,10 @@ asmlinkage long sys_symlink(const char * |
@@ -1612,6 +1640,9 @@ asmlinkage long sys_symlink(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)) |
|
|
@@ -1612,6 +1699,13 @@ asmlinkage long sys_symlink(const char * |
|
702 |
dentry = lookup_create(&nd, 0); |
dentry = lookup_create(&nd, 0); |
703 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
704 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
705 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_symlink_permission(nd.dentry->d_inode, |
706 |
+ error = pre_vfs_symlink(nd.dentry->d_inode, dentry); |
+ dentry, nd.mnt, from); |
707 |
+ if (!error) |
+ if (!error) |
|
+ error = ccs_check_1path_perm(TYPE_SYMLINK_ACL, |
|
|
+ dentry, nd.mnt); |
|
|
+ if (!error) |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
708 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from); |
error = vfs_symlink(nd.dentry->d_inode, dentry, from); |
709 |
dput(dentry); |
dput(dentry); |
710 |
} |
} |
711 |
@@ -1679,6 +1773,10 @@ asmlinkage long sys_link(const char * ol |
@@ -1698,6 +1729,10 @@ asmlinkage long sys_link(const char * ol |
|
{ |
|
|
int error; |
|
|
char * to; |
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (!ccs_capable(CCS_SYS_LINK)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
|
|
|
|
to = getname(newname); |
|
|
error = PTR_ERR(to); |
|
|
@@ -1698,6 +1796,17 @@ asmlinkage long sys_link(const char * ol |
|
712 |
new_dentry = lookup_create(&nd, 0); |
new_dentry = lookup_create(&nd, 0); |
713 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
714 |
if (!IS_ERR(new_dentry)) { |
if (!IS_ERR(new_dentry)) { |
715 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_link_permission(old_nd.dentry, |
716 |
+ error = pre_vfs_link(old_nd.dentry, nd.dentry->d_inode, |
+ nd.dentry->d_inode, |
717 |
+ new_dentry); |
+ new_dentry, nd.mnt); |
718 |
+ if (!error) |
+ if (!error) |
|
+ error = ccs_check_2path_perm(TYPE_LINK_ACL, |
|
|
+ old_nd.dentry, |
|
|
+ old_nd.mnt, |
|
|
+ new_dentry, |
|
|
+ nd.mnt); |
|
|
+ if (!error) |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
719 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
720 |
dput(new_dentry); |
dput(new_dentry); |
721 |
} |
} |
722 |
@@ -1928,6 +2037,20 @@ static inline int do_rename(const char * |
@@ -1928,12 +1963,17 @@ static inline int do_rename(const char * |
723 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
724 |
if (IS_ERR(new_dentry)) |
if (IS_ERR(new_dentry)) |
725 |
goto exit4; |
goto exit4; |
726 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
727 |
+ error = pre_vfs_rename(old_dir->d_inode, old_dentry, |
+ new_dir->d_inode, new_dentry, newnd.mnt); |
728 |
+ new_dir->d_inode, new_dentry); |
+ if (error) |
729 |
+ if (error) { |
+ goto exit5; |
|
+ dput(new_dentry); |
|
|
+ goto exit4; |
|
|
+ } |
|
|
+ error = ccs_check_2path_perm(TYPE_RENAME_ACL, old_dentry, oldnd.mnt, |
|
|
+ new_dentry, newnd.mnt); |
|
|
+ if (error) { |
|
|
+ dput(new_dentry); |
|
|
+ goto exit4; |
|
|
+ } |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
730 |
|
|
731 |
lock_kernel(); |
lock_kernel(); |
732 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
error = vfs_rename(old_dir->d_inode, old_dentry, |
733 |
@@ -1952,6 +2075,10 @@ asmlinkage long sys_rename(const char * |
new_dir->d_inode, new_dentry); |
734 |
int error; |
unlock_kernel(); |
735 |
char * from; |
|
736 |
char * to; |
+exit5: |
737 |
+ /***** TOMOYO Linux start. *****/ |
dput(new_dentry); |
738 |
+ if (!ccs_capable(CCS_SYS_RENAME)) |
exit4: |
739 |
+ return -EPERM; |
dput(old_dentry); |
740 |
+ /***** TOMOYO Linux end. *****/ |
--- linux-2.4.37.6.orig/fs/namespace.c |
741 |
|
+++ linux-2.4.37.6/fs/namespace.c |
742 |
from = getname(oldname); |
@@ -21,6 +21,8 @@ |
|
if(IS_ERR(from)) |
|
|
--- linux-2.4.37.orig/fs/namespace.c |
|
|
+++ linux-2.4.37/fs/namespace.c |
|
|
@@ -21,6 +21,13 @@ |
|
743 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
744 |
#include <linux/namespace.h> |
#include <linux/namespace.h> |
745 |
|
|
746 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
747 |
+ |
+ |
748 |
struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data); |
struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data); |
749 |
int do_remount_sb(struct super_block *sb, int flags, void * data); |
int do_remount_sb(struct super_block *sb, int flags, void * data); |
750 |
void kill_super(struct super_block *sb); |
void kill_super(struct super_block *sb); |
751 |
@@ -290,6 +297,10 @@ static int do_umount(struct vfsmount *mn |
@@ -290,6 +292,9 @@ static int do_umount(struct vfsmount *mn |
752 |
{ |
{ |
753 |
struct super_block * sb = mnt->mnt_sb; |
struct super_block * sb = mnt->mnt_sb; |
754 |
int retval = 0; |
int retval = 0; |
755 |
+ /***** SAKURA Linux start. *****/ |
+ retval = ccs_umount_permission(mnt, flags); |
756 |
+ if (ccs_may_umount(mnt)) |
+ if (retval) |
757 |
+ return -EPERM; |
+ return retval; |
|
+ /***** SAKURA Linux end. *****/ |
|
758 |
|
|
759 |
/* |
/* |
760 |
* If we may have to abort operations to get out of this |
* If we may have to abort operations to get out of this |
761 |
@@ -365,6 +376,10 @@ asmlinkage long sys_umount(char * name, |
@@ -365,6 +370,8 @@ asmlinkage long sys_umount(char * name, |
762 |
{ |
{ |
763 |
struct nameidata nd; |
struct nameidata nd; |
764 |
int retval; |
int retval; |
|
+ /***** TOMOYO Linux start. *****/ |
|
765 |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
+ if (!ccs_capable(CCS_SYS_UMOUNT)) |
766 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
767 |
|
|
768 |
retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd); |
retval = __user_walk(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd); |
769 |
if (retval) |
if (retval) |
770 |
@@ -500,6 +515,11 @@ static int do_loopback(struct nameidata |
@@ -500,6 +507,9 @@ static int do_loopback(struct nameidata |
771 |
down_write(¤t->namespace->sem); |
down_write(¤t->namespace->sem); |
772 |
err = -EINVAL; |
err = -EINVAL; |
773 |
if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) { |
if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) { |
|
+ /***** SAKURA Linux start. *****/ |
|
774 |
+ err = -EPERM; |
+ err = -EPERM; |
775 |
+ if (ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
776 |
+ goto out; |
+ goto out; |
|
+ /***** SAKURA Linux end. *****/ |
|
777 |
err = -ENOMEM; |
err = -ENOMEM; |
778 |
if (recurse) |
if (recurse) |
779 |
mnt = copy_tree(old_nd.mnt, old_nd.dentry); |
mnt = copy_tree(old_nd.mnt, old_nd.dentry); |
780 |
@@ -516,7 +536,9 @@ static int do_loopback(struct nameidata |
@@ -516,7 +526,7 @@ static int do_loopback(struct nameidata |
781 |
} else |
} else |
782 |
mntput(mnt); |
mntput(mnt); |
783 |
} |
} |
784 |
- |
- |
|
+ /***** SAKURA Linux start. *****/ |
|
785 |
+ out: |
+ out: |
|
+ /***** SAKURA Linux end. *****/ |
|
786 |
up_write(¤t->namespace->sem); |
up_write(¤t->namespace->sem); |
787 |
path_release(&old_nd); |
path_release(&old_nd); |
788 |
return err; |
return err; |
789 |
@@ -570,6 +592,12 @@ static int do_move_mount(struct nameidat |
@@ -570,6 +580,10 @@ static int do_move_mount(struct nameidat |
790 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
791 |
goto out; |
goto out; |
792 |
|
|
|
+ /***** SAKURA Linux start. *****/ |
|
793 |
+ err = -EPERM; |
+ err = -EPERM; |
794 |
+ if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
795 |
+ goto out; |
+ goto out; |
|
+ /***** SAKURA Linux end. *****/ |
|
796 |
+ |
+ |
797 |
err = -ENOENT; |
err = -ENOENT; |
798 |
down(&nd->dentry->d_inode->i_zombie); |
down(&nd->dentry->d_inode->i_zombie); |
799 |
if (IS_DEADDIR(nd->dentry->d_inode)) |
if (IS_DEADDIR(nd->dentry->d_inode)) |
800 |
@@ -641,6 +669,12 @@ static int do_add_mount(struct nameidata |
@@ -641,6 +655,10 @@ static int do_add_mount(struct nameidata |
801 |
if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry) |
if (nd->mnt->mnt_sb == mnt->mnt_sb && nd->mnt->mnt_root == nd->dentry) |
802 |
goto unlock; |
goto unlock; |
803 |
|
|
|
+ /***** SAKURA Linux start. *****/ |
|
804 |
+ err = -EPERM; |
+ err = -EPERM; |
805 |
+ if (ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
806 |
+ goto unlock; |
+ goto unlock; |
|
+ /***** SAKURA Linux end. *****/ |
|
807 |
+ |
+ |
808 |
mnt->mnt_flags = mnt_flags; |
mnt->mnt_flags = mnt_flags; |
809 |
err = graft_tree(mnt, nd); |
err = graft_tree(mnt, nd); |
810 |
unlock: |
unlock: |
811 |
@@ -718,6 +752,17 @@ long do_mount(char * dev_name, char * di |
@@ -700,6 +718,7 @@ static int copy_mount_options (const voi |
812 |
if (data_page) |
long do_mount(char * dev_name, char * dir_name, char *type_page, |
813 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
unsigned long flags, void *data_page) |
814 |
|
{ |
815 |
+ /***** TOMOYO Linux start. *****/ |
+ const unsigned long original_flags = flags; |
816 |
+ if (!ccs_capable(CCS_SYS_MOUNT)) |
struct nameidata nd; |
817 |
+ return -EPERM; |
int retval = 0; |
818 |
+ /***** TOMOYO Linux end. *****/ |
int mnt_flags = 0; |
819 |
+ /***** SAKURA Linux start. *****/ |
@@ -732,6 +751,11 @@ long do_mount(char * dev_name, char * di |
820 |
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
if (retval) |
821 |
+ &flags); |
return retval; |
822 |
|
|
823 |
|
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
824 |
|
+ original_flags, data_page); |
825 |
+ if (retval) |
+ if (retval) |
826 |
+ return retval; |
+ goto out; |
|
+ /***** SAKURA Linux end. *****/ |
|
827 |
+ |
+ |
828 |
/* Separate the per-mountpoint flags */ |
if (flags & MS_REMOUNT) |
829 |
if (flags & MS_NOSUID) |
retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags, |
830 |
mnt_flags |= MNT_NOSUID; |
data_page); |
831 |
@@ -911,6 +956,10 @@ asmlinkage long sys_pivot_root(const cha |
@@ -742,6 +766,7 @@ long do_mount(char * dev_name, char * di |
832 |
|
else |
833 |
|
retval = do_add_mount(&nd, type_page, flags, mnt_flags, |
834 |
|
dev_name, data_page); |
835 |
|
+ out: |
836 |
|
path_release(&nd); |
837 |
|
return retval; |
838 |
|
} |
839 |
|
@@ -911,6 +936,8 @@ asmlinkage long sys_pivot_root(const cha |
840 |
|
|
841 |
if (!capable(CAP_SYS_ADMIN)) |
if (!capable(CAP_SYS_ADMIN)) |
842 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
843 |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
+ if (!ccs_capable(CCS_SYS_PIVOT_ROOT)) |
844 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
845 |
|
|
846 |
lock_kernel(); |
lock_kernel(); |
847 |
|
|
848 |
@@ -925,6 +974,13 @@ asmlinkage long sys_pivot_root(const cha |
@@ -925,6 +952,11 @@ asmlinkage long sys_pivot_root(const cha |
849 |
if (error) |
if (error) |
850 |
goto out1; |
goto out1; |
851 |
|
|
852 |
+ /***** SAKURA Linux start. *****/ |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
|
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
|
853 |
+ if (error) { |
+ if (error) { |
854 |
+ path_release(&old_nd); |
+ path_release(&old_nd); |
855 |
+ goto out1; |
+ goto out1; |
856 |
+ } |
+ } |
|
+ /***** SAKURA Linux end. *****/ |
|
857 |
read_lock(¤t->fs->lock); |
read_lock(¤t->fs->lock); |
858 |
user_nd.mnt = mntget(current->fs->rootmnt); |
user_nd.mnt = mntget(current->fs->rootmnt); |
859 |
user_nd.dentry = dget(current->fs->root); |
user_nd.dentry = dget(current->fs->root); |
860 |
--- linux-2.4.37.orig/fs/open.c |
--- linux-2.4.37.6.orig/fs/open.c |
861 |
+++ linux-2.4.37/fs/open.c |
+++ linux-2.4.37.6/fs/open.c |
862 |
@@ -20,6 +20,13 @@ |
@@ -20,6 +20,8 @@ |
863 |
|
|
864 |
#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) |
#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) |
865 |
|
|
866 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
|
+/***** TOMOYO Linux start. *****/ |
|
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
867 |
+ |
+ |
868 |
int vfs_statfs(struct super_block *sb, struct statfs *buf) |
int vfs_statfs(struct super_block *sb, struct statfs *buf) |
869 |
{ |
{ |
870 |
int retval = -ENODEV; |
int retval = -ENODEV; |
871 |
@@ -164,6 +171,11 @@ static inline long do_sys_truncate(const |
@@ -164,6 +166,9 @@ static inline long do_sys_truncate(const |
872 |
if (error) |
if (error) |
873 |
goto dput_and_out; |
goto dput_and_out; |
874 |
|
|
875 |
+ /***** 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); |
|
876 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
877 |
+ |
+ |
878 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
879 |
if (!error) { |
if (!error) { |
880 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
881 |
@@ -217,6 +229,11 @@ static inline long do_sys_ftruncate(unsi |
@@ -217,6 +222,9 @@ static inline long do_sys_ftruncate(unsi |
882 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
883 |
goto out_putf; |
goto out_putf; |
884 |
|
|
885 |
+ /***** 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); |
|
886 |
+ if (error) |
+ if (error) |
887 |
+ goto out_putf; |
+ goto out_putf; |
|
+ /***** TOMOYO Linux end. *****/ |
|
888 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
889 |
if (!error) |
if (!error) |
890 |
error = do_truncate(dentry, length); |
error = do_truncate(dentry, length); |
891 |
@@ -466,6 +483,14 @@ asmlinkage long sys_chroot(const char * |
@@ -466,6 +474,10 @@ asmlinkage long sys_chroot(const char * |
892 |
error = -EPERM; |
error = -EPERM; |
893 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
894 |
goto dput_and_out; |
goto dput_and_out; |
|
+ /***** TOMOYO Linux start. *****/ |
|
895 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
896 |
+ goto dput_and_out; |
+ goto dput_and_out; |
897 |
+ /***** TOMOYO Linux end. *****/ |
+ if (ccs_chroot_permission(&nd)) |
|
+ /***** SAKURA Linux start. *****/ |
|
|
+ if (ccs_check_chroot_permission(&nd)) |
|
898 |
+ goto dput_and_out; |
+ goto dput_and_out; |
|
+ /***** SAKURA Linux end. *****/ |
|
899 |
|
|
900 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
901 |
set_fs_altroot(); |
set_fs_altroot(); |
902 |
@@ -897,6 +922,10 @@ out_unlock: |
@@ -497,6 +509,9 @@ asmlinkage long sys_fchmod(unsigned int |
903 |
|
err = -EPERM; |
904 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
905 |
|
goto out_putf; |
906 |
|
+ err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode); |
907 |
|
+ if (err) |
908 |
|
+ goto out_putf; |
909 |
|
if (mode == (mode_t) -1) |
910 |
|
mode = inode->i_mode; |
911 |
|
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); |
912 |
|
@@ -528,6 +543,9 @@ asmlinkage long sys_chmod(const char * f |
913 |
|
error = -EPERM; |
914 |
|
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
915 |
|
goto dput_and_out; |
916 |
|
+ error = ccs_chmod_permission(nd.dentry, nd.mnt, mode); |
917 |
|
+ if (error) |
918 |
|
+ goto dput_and_out; |
919 |
|
|
920 |
|
if (mode == (mode_t) -1) |
921 |
|
mode = inode->i_mode; |
922 |
|
@@ -608,6 +626,8 @@ asmlinkage long sys_chown(const char * f |
923 |
|
|
924 |
|
error = user_path_walk(filename, &nd); |
925 |
|
if (!error) { |
926 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
927 |
|
+ if (!error) |
928 |
|
error = chown_common(nd.dentry, user, group); |
929 |
|
path_release(&nd); |
930 |
|
} |
931 |
|
@@ -621,6 +641,8 @@ asmlinkage long sys_lchown(const char * |
932 |
|
|
933 |
|
error = user_path_walk_link(filename, &nd); |
934 |
|
if (!error) { |
935 |
|
+ error = ccs_chown_permission(nd.dentry, nd.mnt, user, group); |
936 |
|
+ if (!error) |
937 |
|
error = chown_common(nd.dentry, user, group); |
938 |
|
path_release(&nd); |
939 |
|
} |
940 |
|
@@ -635,6 +657,9 @@ asmlinkage long sys_fchown(unsigned int |
941 |
|
|
942 |
|
file = fget(fd); |
943 |
|
if (file) { |
944 |
|
+ error = ccs_chown_permission(file->f_dentry, file->f_vfsmnt, |
945 |
|
+ user, group); |
946 |
|
+ if (!error) |
947 |
|
error = chown_common(file->f_dentry, user, group); |
948 |
|
fput(file); |
949 |
|
} |
950 |
|
@@ -666,7 +691,9 @@ struct file *filp_open(const char * file |
951 |
|
if (namei_flags & O_TRUNC) |
952 |
|
namei_flags |= 2; |
953 |
|
|
954 |
|
+ ccs_save_open_mode(flags); |
955 |
|
error = open_namei(filename, namei_flags, mode, &nd); |
956 |
|
+ ccs_clear_open_mode(); |
957 |
|
if (!error) |
958 |
|
return dentry_open(nd.dentry, nd.mnt, flags); |
959 |
|
|
960 |
|
@@ -897,6 +924,8 @@ out_unlock: |
961 |
*/ |
*/ |
962 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
963 |
{ |
{ |
|
+ /***** TOMOYO Linux start. *****/ |
|
964 |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
+ if (!ccs_capable(CCS_SYS_VHANGUP)) |
965 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
966 |
if (capable(CAP_SYS_TTY_CONFIG)) { |
if (capable(CAP_SYS_TTY_CONFIG)) { |
967 |
tty_vhangup(current->tty); |
tty_vhangup(current->tty); |
968 |
return 0; |
return 0; |
969 |
--- linux-2.4.37.orig/fs/proc/Makefile |
--- linux-2.4.37.6.orig/fs/proc/proc_misc.c |
970 |
+++ linux-2.4.37/fs/proc/Makefile |
+++ linux-2.4.37.6/fs/proc/proc_misc.c |
971 |
@@ -18,4 +18,8 @@ ifeq ($(CONFIG_PROC_DEVICETREE),y) |
@@ -670,4 +670,5 @@ void __init proc_misc_init(void) |
|
obj-y += proc_devtree.o |
|
|
endif |
|
|
|
|
|
+export-objs += ccs_proc.o |
|
|
+obj-$(CONFIG_SAKURA) += ccs_proc.o |
|
|
+obj-$(CONFIG_TOMOYO) += ccs_proc.o |
|
|
+ |
|
|
include $(TOPDIR)/Rules.make |
|
|
--- linux-2.4.37.orig/fs/proc/proc_misc.c |
|
|
+++ linux-2.4.37/fs/proc/proc_misc.c |
|
|
@@ -670,4 +670,9 @@ void __init proc_misc_init(void) |
|
972 |
entry->proc_fops = &ppc_htab_operations; |
entry->proc_fops = &ppc_htab_operations; |
973 |
} |
} |
974 |
#endif |
#endif |
975 |
+ /***** CCS start. *****/ |
+ printk(KERN_INFO "Hook version: 2.4.37.6 2009/09/17\n); |
|
+#if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO) |
|
|
+ printk(KERN_INFO "Hook version: 2.4.37 2009/03/18\n"); |
|
|
+#endif |
|
|
+ /***** CCS end. *****/ |
|
976 |
} |
} |
977 |
--- linux-2.4.37.orig/include/linux/sched.h |
--- linux-2.4.37.6.orig/include/linux/sched.h |
978 |
+++ linux-2.4.37/include/linux/sched.h |
+++ linux-2.4.37.6/include/linux/sched.h |
979 |
@@ -29,6 +29,10 @@ extern unsigned long event; |
@@ -29,6 +29,15 @@ extern unsigned long event; |
980 |
|
|
981 |
struct exec_domain; |
struct exec_domain; |
982 |
|
|
983 |
+/***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
984 |
+struct ccs_domain_info; |
+struct ccs_domain_info; |
985 |
+/***** TOMOYO Linux end. *****/ |
+#define INIT_CCSECURITY \ |
986 |
|
+ .ccs_domain_info = NULL, \ |
987 |
|
+ .ccs_flags = 0, |
988 |
|
+#else |
989 |
|
+#define INIT_CCSECURITY |
990 |
|
+#endif |
991 |
+ |
+ |
992 |
/* |
/* |
993 |
* cloning flags: |
* cloning flags: |
994 |
*/ |
*/ |
995 |
@@ -417,6 +421,10 @@ struct task_struct { |
@@ -417,6 +426,10 @@ struct task_struct { |
996 |
void *journal_info; |
void *journal_info; |
997 |
|
|
998 |
struct list_head *scm_work_list; |
struct list_head *scm_work_list; |
999 |
+ /***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
1000 |
+ struct ccs_domain_info *ccs_domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
1001 |
+ u32 ccs_flags; |
+ u32 ccs_flags; |
1002 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
1003 |
}; |
}; |
1004 |
|
|
1005 |
/* |
/* |
1006 |
@@ -512,6 +520,10 @@ extern struct exec_domain default_exec_d |
@@ -512,6 +525,7 @@ extern struct exec_domain default_exec_d |
1007 |
blocked: {{0}}, \ |
blocked: {{0}}, \ |
1008 |
alloc_lock: SPIN_LOCK_UNLOCKED, \ |
alloc_lock: SPIN_LOCK_UNLOCKED, \ |
1009 |
journal_info: NULL, \ |
journal_info: NULL, \ |
1010 |
+ /***** TOMOYO Linux start. *****/ \ |
+ INIT_CCSECURITY \ |
|
+ ccs_domain_info: NULL, \ |
|
|
+ ccs_flags: 0 \ |
|
|
+ /***** TOMOYO Linux end. *****/ \ |
|
1011 |
} |
} |
1012 |
|
|
1013 |
|
|
1014 |
--- linux-2.4.37.orig/kernel/kmod.c |
--- linux-2.4.37.6.orig/kernel/kmod.c |
1015 |
+++ linux-2.4.37/kernel/kmod.c |
+++ linux-2.4.37.6/kernel/kmod.c |
1016 |
@@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa |
@@ -134,6 +134,11 @@ int exec_usermodehelper(char *program_pa |
1017 |
/* Allow execve args to be in kernel space. */ |
/* Allow execve args to be in kernel space. */ |
1018 |
set_fs(KERNEL_DS); |
set_fs(KERNEL_DS); |
1019 |
|
|
1020 |
+ /***** TOMOYO Linux start. *****/ |
+#ifdef CONFIG_CCSECURITY |
1021 |
+ current->ccs_domain_info = NULL; |
+ current->ccs_domain_info = NULL; |
1022 |
+ current->ccs_flags = 0; |
+ current->ccs_flags = 0; |
1023 |
+ /***** TOMOYO Linux end. *****/ |
+#endif |
1024 |
+ |
+ |
1025 |
/* Go, go, go... */ |
/* Go, go, go... */ |
1026 |
if (execve(program_path, argv, envp) < 0) |
if (execve(program_path, argv, envp) < 0) |
1027 |
return -errno; |
return -errno; |
1028 |
--- linux-2.4.37.orig/kernel/module.c |
--- linux-2.4.37.6.orig/kernel/module.c |
1029 |
+++ linux-2.4.37/kernel/module.c |
+++ linux-2.4.37.6/kernel/module.c |
1030 |
@@ -10,6 +10,9 @@ |
@@ -10,6 +10,7 @@ |
1031 |
#include <linux/slab.h> |
#include <linux/slab.h> |
1032 |
#include <linux/kmod.h> |
#include <linux/kmod.h> |
1033 |
#include <linux/seq_file.h> |
#include <linux/seq_file.h> |
1034 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1035 |
|
|
1036 |
/* |
/* |
1037 |
* Originally by Anonymous (as far as I know...) |
* Originally by Anonymous (as far as I know...) |
1038 |
@@ -298,6 +301,10 @@ sys_create_module(const char *name_user, |
@@ -298,6 +299,8 @@ sys_create_module(const char *name_user, |
1039 |
|
|
1040 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
1041 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1042 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
1043 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1044 |
lock_kernel(); |
lock_kernel(); |
1045 |
if ((namelen = get_mod_name(name_user, &name)) < 0) { |
if ((namelen = get_mod_name(name_user, &name)) < 0) { |
1046 |
error = namelen; |
error = namelen; |
1047 |
@@ -353,6 +360,10 @@ sys_init_module(const char *name_user, s |
@@ -353,6 +356,8 @@ sys_init_module(const char *name_user, s |
1048 |
|
|
1049 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
1050 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1051 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
1052 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1053 |
lock_kernel(); |
lock_kernel(); |
1054 |
if ((namelen = get_mod_name(name_user, &name)) < 0) { |
if ((namelen = get_mod_name(name_user, &name)) < 0) { |
1055 |
error = namelen; |
error = namelen; |
1056 |
@@ -614,6 +625,10 @@ sys_delete_module(const char *name_user) |
@@ -614,6 +619,8 @@ sys_delete_module(const char *name_user) |
1057 |
|
|
1058 |
if (!capable(CAP_SYS_MODULE)) |
if (!capable(CAP_SYS_MODULE)) |
1059 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1060 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
1061 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1062 |
|
|
1063 |
lock_kernel(); |
lock_kernel(); |
1064 |
if (name_user) { |
if (name_user) { |
1065 |
--- linux-2.4.37.orig/kernel/sched.c |
--- linux-2.4.37.6.orig/kernel/sched.c |
1066 |
+++ linux-2.4.37/kernel/sched.c |
+++ linux-2.4.37.6/kernel/sched.c |
1067 |
@@ -32,6 +32,9 @@ |
@@ -32,6 +32,7 @@ |
1068 |
|
|
1069 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1070 |
#include <asm/mmu_context.h> |
#include <asm/mmu_context.h> |
1071 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1072 |
|
|
1073 |
extern void timer_bh(void); |
extern void timer_bh(void); |
1074 |
extern void tqueue_bh(void); |
extern void tqueue_bh(void); |
1075 |
@@ -899,6 +902,10 @@ void set_cpus_allowed(struct task_struct |
@@ -899,6 +900,8 @@ void set_cpus_allowed(struct task_struct |
1076 |
asmlinkage long sys_nice(int increment) |
asmlinkage long sys_nice(int increment) |
1077 |
{ |
{ |
1078 |
long newprio; |
long newprio; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1079 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
+ if (!ccs_capable(CCS_SYS_NICE)) |
1080 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1081 |
|
|
1082 |
/* |
/* |
1083 |
* Setpriority might change our priority at the same moment. |
* Setpriority might change our priority at the same moment. |
1084 |
--- linux-2.4.37.orig/kernel/signal.c |
--- linux-2.4.37.6.orig/kernel/signal.c |
1085 |
+++ linux-2.4.37/kernel/signal.c |
+++ linux-2.4.37.6/kernel/signal.c |
1086 |
@@ -15,6 +15,9 @@ |
@@ -15,6 +15,7 @@ |
1087 |
#include <linux/sched.h> |
#include <linux/sched.h> |
1088 |
|
|
1089 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1090 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1091 |
|
|
1092 |
/* |
/* |
1093 |
* SLAB caches for signal bits. |
* SLAB caches for signal bits. |
1094 |
@@ -1025,6 +1028,12 @@ asmlinkage long |
@@ -1025,6 +1026,8 @@ asmlinkage long |
1095 |
sys_kill(int pid, int sig) |
sys_kill(int pid, int sig) |
1096 |
{ |
{ |
1097 |
struct siginfo info; |
struct siginfo info; |
1098 |
+ /***** TOMOYO Linux start. *****/ |
+ if (ccs_kill_permission(pid, sig)) |
|
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
|
1099 |
+ return -EPERM; |
+ return -EPERM; |
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1100 |
|
|
1101 |
info.si_signo = sig; |
info.si_signo = sig; |
1102 |
info.si_errno = 0; |
info.si_errno = 0; |
1103 |
@@ -1049,6 +1058,12 @@ sys_tkill(int pid, int sig) |
@@ -1048,6 +1051,8 @@ sys_tkill(int pid, int sig) |
1104 |
|
/* This is only valid for single tasks */ |
1105 |
if (pid <= 0) |
if (pid <= 0) |
1106 |
return -EINVAL; |
return -EINVAL; |
1107 |
|
+ if (ccs_tkill_permission(pid, sig)) |
1108 |
|
+ return -EPERM; |
1109 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
|
+ if (sig && !ccs_capable(CCS_SYS_KILL)) |
|
|
+ return -EPERM; |
|
|
+ if (sig && ccs_check_signal_acl(sig, pid)) |
|
|
+ return -EPERM; |
|
|
+ /***** TOMOYO Linux end. *****/ |
|
1110 |
info.si_signo = sig; |
info.si_signo = sig; |
1111 |
info.si_errno = 0; |
info.si_errno = 0; |
1112 |
info.si_code = SI_TKILL; |
@@ -1078,6 +1083,8 @@ sys_rt_sigqueueinfo(int pid, int sig, si |
1113 |
--- linux-2.4.37.orig/kernel/sys.c |
if (info.si_code >= 0) |
1114 |
+++ linux-2.4.37/kernel/sys.c |
return -EPERM; |
1115 |
@@ -17,6 +17,9 @@ |
info.si_signo = sig; |
1116 |
|
+ if (ccs_sigqueue_permission(pid, sig)) |
1117 |
|
+ return -EPERM; |
1118 |
|
|
1119 |
|
/* POSIX.1b doesn't mention process groups. */ |
1120 |
|
return kill_proc_info(sig, &info, pid); |
1121 |
|
--- linux-2.4.37.6.orig/kernel/sys.c |
1122 |
|
+++ linux-2.4.37.6/kernel/sys.c |
1123 |
|
@@ -17,6 +17,7 @@ |
1124 |
|
|
1125 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1126 |
#include <asm/io.h> |
#include <asm/io.h> |
1127 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1128 |
|
|
1129 |
#ifndef SET_UNALIGN_CTL |
#ifndef SET_UNALIGN_CTL |
1130 |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
# define SET_UNALIGN_CTL(a,b) (-EINVAL) |
1131 |
@@ -220,6 +223,10 @@ asmlinkage long sys_setpriority(int whic |
@@ -220,6 +221,8 @@ asmlinkage long sys_setpriority(int whic |
1132 |
|
|
1133 |
if (which > 2 || which < 0) |
if (which > 2 || which < 0) |
1134 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1135 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
+ if (!ccs_capable(CCS_SYS_NICE)) |
1136 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1137 |
|
|
1138 |
/* normalize: avoid signed division (rounding problems) */ |
/* normalize: avoid signed division (rounding problems) */ |
1139 |
error = -ESRCH; |
error = -ESRCH; |
1140 |
@@ -299,6 +306,10 @@ asmlinkage long sys_reboot(int magic1, i |
@@ -299,6 +302,8 @@ asmlinkage long sys_reboot(int magic1, i |
1141 |
(magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && |
(magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && |
1142 |
magic2 != LINUX_REBOOT_MAGIC2B)) |
magic2 != LINUX_REBOOT_MAGIC2B)) |
1143 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1144 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
1145 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1146 |
|
|
1147 |
lock_kernel(); |
lock_kernel(); |
1148 |
switch (cmd) { |
switch (cmd) { |
1149 |
@@ -1042,6 +1053,10 @@ asmlinkage long sys_sethostname(char *na |
@@ -1042,6 +1047,8 @@ asmlinkage long sys_sethostname(char *na |
1150 |
return -EPERM; |
return -EPERM; |
1151 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
1152 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1153 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
1154 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1155 |
down_write(&uts_sem); |
down_write(&uts_sem); |
1156 |
errno = -EFAULT; |
errno = -EFAULT; |
1157 |
if (!copy_from_user(tmp, name, len)) { |
if (!copy_from_user(tmp, name, len)) { |
1158 |
@@ -1083,6 +1098,10 @@ asmlinkage long sys_setdomainname(char * |
@@ -1083,6 +1090,8 @@ asmlinkage long sys_setdomainname(char * |
1159 |
return -EPERM; |
return -EPERM; |
1160 |
if (len < 0 || len > __NEW_UTS_LEN) |
if (len < 0 || len > __NEW_UTS_LEN) |
1161 |
return -EINVAL; |
return -EINVAL; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1162 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
1163 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1164 |
|
|
1165 |
down_write(&uts_sem); |
down_write(&uts_sem); |
1166 |
errno = -EFAULT; |
errno = -EFAULT; |
1167 |
--- linux-2.4.37.orig/kernel/sysctl.c |
--- linux-2.4.37.6.orig/kernel/sysctl.c |
1168 |
+++ linux-2.4.37/kernel/sysctl.c |
+++ linux-2.4.37.6/kernel/sysctl.c |
1169 |
@@ -33,6 +33,9 @@ |
@@ -33,6 +33,7 @@ |
1170 |
#include <linux/swap.h> |
#include <linux/swap.h> |
1171 |
|
|
1172 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1173 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1174 |
|
|
1175 |
#ifdef CONFIG_ROOT_NFS |
#ifdef CONFIG_ROOT_NFS |
1176 |
#include <linux/nfs_fs.h> |
#include <linux/nfs_fs.h> |
1177 |
@@ -411,6 +414,100 @@ void __init sysctl_init(void) |
@@ -439,6 +440,9 @@ int do_sysctl(int *name, int nlen, void |
|
#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 *name, int nlen, void *oldval, size_t *oldlenp, |
|
|
void *newval, size_t newlen) |
|
|
{ |
|
|
@@ -439,6 +536,11 @@ int do_sysctl(int *name, int nlen, void |
|
1178 |
|
|
1179 |
spin_unlock(&sysctl_lock); |
spin_unlock(&sysctl_lock); |
1180 |
|
|
1181 |
+ /***** TOMOYO Linux start. *****/ |
+ error = ccs_parse_table(name, nlen, oldval, newval, |
|
+ error = try_parse_table(name, nlen, oldval, newval, |
|
1182 |
+ head->ctl_table); |
+ head->ctl_table); |
1183 |
+ if (!error) |
+ if (!error) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1184 |
error = parse_table(name, nlen, oldval, oldlenp, |
error = parse_table(name, nlen, oldval, oldlenp, |
1185 |
newval, newlen, head->ctl_table, |
newval, newlen, head->ctl_table, |
1186 |
&context); |
&context); |
1187 |
@@ -508,6 +610,15 @@ repeat: |
@@ -508,6 +512,13 @@ repeat: |
1188 |
if (ctl_perm(table, 001)) |
if (ctl_perm(table, 001)) |
1189 |
return -EPERM; |
return -EPERM; |
1190 |
if (table->strategy) { |
if (table->strategy) { |
|
+ /***** TOMOYO Linux start. *****/ |
|
1191 |
+ int op = 0; |
+ int op = 0; |
1192 |
+ if (oldval) |
+ if (oldval) |
1193 |
+ op |= 004; |
+ op |= 004; |
1195 |
+ op |= 002; |
+ op |= 002; |
1196 |
+ if (ctl_perm(table, op)) |
+ if (ctl_perm(table, op)) |
1197 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1198 |
error = table->strategy( |
error = table->strategy( |
1199 |
table, name, nlen, |
table, name, nlen, |
1200 |
oldval, oldlenp, |
oldval, oldlenp, |
1201 |
@@ -1456,7 +1567,7 @@ int sysctl_string(ctl_table *table, int |
@@ -1456,7 +1467,7 @@ int sysctl_string(ctl_table *table, int |
1202 |
len--; |
len--; |
1203 |
((char *) table->data)[len] = 0; |
((char *) table->data)[len] = 0; |
1204 |
} |
} |
1207 |
} |
} |
1208 |
|
|
1209 |
/* |
/* |
1210 |
--- linux-2.4.37.orig/kernel/time.c |
--- linux-2.4.37.6.orig/kernel/time.c |
1211 |
+++ linux-2.4.37/kernel/time.c |
+++ linux-2.4.37.6/kernel/time.c |
1212 |
@@ -29,6 +29,9 @@ |
@@ -29,6 +29,7 @@ |
1213 |
#include <linux/smp_lock.h> |
#include <linux/smp_lock.h> |
1214 |
|
|
1215 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1216 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1217 |
|
|
1218 |
/* |
/* |
1219 |
* 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 |
1220 |
@@ -77,6 +80,10 @@ asmlinkage long sys_stime(int * tptr) |
@@ -77,6 +78,8 @@ asmlinkage long sys_stime(int * tptr) |
1221 |
|
|
1222 |
if (!capable(CAP_SYS_TIME)) |
if (!capable(CAP_SYS_TIME)) |
1223 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1224 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1225 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1226 |
if (get_user(value, tptr)) |
if (get_user(value, tptr)) |
1227 |
return -EFAULT; |
return -EFAULT; |
1228 |
write_lock_irq(&xtime_lock); |
write_lock_irq(&xtime_lock); |
1229 |
@@ -151,6 +158,10 @@ int do_sys_settimeofday(struct timeval * |
@@ -151,6 +154,8 @@ int do_sys_settimeofday(struct timeval * |
1230 |
|
|
1231 |
if (!capable(CAP_SYS_TIME)) |
if (!capable(CAP_SYS_TIME)) |
1232 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1233 |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
+ if (!ccs_capable(CCS_SYS_SETTIME)) |
1234 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1235 |
|
|
1236 |
if (tz) { |
if (tz) { |
1237 |
/* SMP safe, global irq locking makes it work. */ |
/* SMP safe, global irq locking makes it work. */ |
1238 |
@@ -217,6 +228,10 @@ int do_adjtimex(struct timex *txc) |
@@ -217,6 +222,8 @@ int do_adjtimex(struct timex *txc) |
1239 |
/* In order to modify anything, you gotta be super-user! */ |
/* In order to modify anything, you gotta be super-user! */ |
1240 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
if (txc->modes && !capable(CAP_SYS_TIME)) |
1241 |
return -EPERM; |
return -EPERM; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1242 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
1243 |
+ return -EPERM; |
+ return -EPERM; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1244 |
|
|
1245 |
/* Now we validate the data before disabling interrupts */ |
/* Now we validate the data before disabling interrupts */ |
1246 |
|
|
1247 |
--- linux-2.4.37.orig/net/core/datagram.c |
--- linux-2.4.37.6.orig/net/ipv4/raw.c |
1248 |
+++ linux-2.4.37/net/core/datagram.c |
+++ linux-2.4.37.6/net/ipv4/raw.c |
1249 |
@@ -43,6 +43,10 @@ |
@@ -64,6 +64,7 @@ |
1250 |
#include <net/sock.h> |
#include <net/raw.h> |
1251 |
|
#include <net/inet_common.h> |
1252 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1253 |
|
+#include <linux/ccsecurity.h> |
1254 |
|
|
1255 |
+/***** TOMOYO Linux start. *****/ |
struct sock *raw_v4_htable[RAWV4_HTABLE_SIZE]; |
1256 |
+#include <linux/tomoyo.h> |
rwlock_t raw_v4_lock = RW_LOCK_UNLOCKED; |
1257 |
+#include <linux/tomoyo_socket.h> |
@@ -503,6 +504,9 @@ int raw_recvmsg(struct sock *sk, struct |
1258 |
+/***** TOMOYO Linux end. *****/ |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1259 |
|
if (!skb) |
1260 |
/* |
goto out; |
1261 |
* Is a socket 'connection oriented' ? |
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1262 |
@@ -164,6 +168,12 @@ struct sk_buff *skb_recv_datagram(struct |
+ if (err) |
1263 |
} else |
+ goto out; |
|
skb = skb_dequeue(&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; |
|
1264 |
|
|
1265 |
--- linux-2.4.37.orig/net/ipv4/tcp_ipv4.c |
copied = skb->len; |
1266 |
+++ linux-2.4.37/net/ipv4/tcp_ipv4.c |
if (len < copied) { |
1267 |
@@ -67,6 +67,9 @@ |
--- linux-2.4.37.6.orig/net/ipv4/tcp_ipv4.c |
1268 |
|
+++ linux-2.4.37.6/net/ipv4/tcp_ipv4.c |
1269 |
|
@@ -67,6 +67,7 @@ |
1270 |
#include <linux/inet.h> |
#include <linux/inet.h> |
1271 |
#include <linux/stddef.h> |
#include <linux/stddef.h> |
1272 |
#include <linux/ipsec.h> |
#include <linux/ipsec.h> |
1273 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1274 |
|
|
1275 |
extern int sysctl_ip_dynaddr; |
extern int sysctl_ip_dynaddr; |
1276 |
extern int sysctl_ip_default_ttl; |
extern int sysctl_ip_default_ttl; |
1277 |
@@ -228,6 +231,10 @@ static int tcp_v4_get_port(struct sock * |
@@ -228,6 +229,8 @@ static int tcp_v4_get_port(struct sock * |
1278 |
rover = low; |
rover = low; |
1279 |
head = &tcp_bhash[tcp_bhashfn(rover)]; |
head = &tcp_bhash[tcp_bhashfn(rover)]; |
1280 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1281 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(rover)) |
|
+ if (ccs_may_autobind(rover)) |
|
1282 |
+ goto next; |
+ goto next; |
|
+ /***** SAKURA Linux end. *****/ |
|
1283 |
for (tb = head->chain; tb; tb = tb->next) |
for (tb = head->chain; tb; tb = tb->next) |
1284 |
if (tb->port == rover) |
if (tb->port == rover) |
1285 |
goto next; |
goto next; |
1286 |
@@ -688,6 +695,10 @@ static int tcp_v4_hash_connect(struct so |
@@ -688,6 +691,8 @@ static int tcp_v4_hash_connect(struct so |
1287 |
rover = low; |
rover = low; |
1288 |
head = &tcp_bhash[tcp_bhashfn(rover)]; |
head = &tcp_bhash[tcp_bhashfn(rover)]; |
1289 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1290 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(rover)) |
|
+ if (ccs_may_autobind(rover)) |
|
1291 |
+ goto next_port; |
+ goto next_port; |
|
+ /***** SAKURA Linux end. *****/ |
|
1292 |
|
|
1293 |
/* Does not bother with rcv_saddr checks, |
/* Does not bother with rcv_saddr checks, |
1294 |
* because the established check is already |
* because the established check is already |
1295 |
--- linux-2.4.37.orig/net/ipv4/udp.c |
--- linux-2.4.37.6.orig/net/ipv4/udp.c |
1296 |
+++ linux-2.4.37/net/ipv4/udp.c |
+++ linux-2.4.37.6/net/ipv4/udp.c |
1297 |
@@ -97,6 +97,9 @@ |
@@ -97,6 +97,7 @@ |
1298 |
#include <net/route.h> |
#include <net/route.h> |
1299 |
#include <net/inet_common.h> |
#include <net/inet_common.h> |
1300 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1301 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1302 |
|
|
1303 |
/* |
/* |
1304 |
* Snmp MIB for the UDP layer |
* Snmp MIB for the UDP layer |
1305 |
@@ -131,6 +134,10 @@ static int udp_v4_get_port(struct sock * |
@@ -131,6 +132,8 @@ static int udp_v4_get_port(struct sock * |
1306 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1307 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1308 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1309 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1310 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1311 |
goto gotit; |
goto gotit; |
1312 |
} |
} |
1313 |
size = 0; |
size = 0; |
1314 |
@@ -148,6 +155,10 @@ static int udp_v4_get_port(struct sock * |
@@ -148,6 +151,8 @@ static int udp_v4_get_port(struct sock * |
1315 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1316 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1317 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1318 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1319 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1320 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1321 |
break; |
break; |
1322 |
} |
} |
1323 |
--- linux-2.4.37.orig/net/ipv6/tcp_ipv6.c |
@@ -711,6 +716,9 @@ try_again: |
1324 |
+++ linux-2.4.37/net/ipv6/tcp_ipv6.c |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1325 |
@@ -52,6 +52,9 @@ |
if (!skb) |
1326 |
|
goto out; |
1327 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1328 |
|
+ if (err) |
1329 |
|
+ goto out; |
1330 |
|
|
1331 |
|
copied = skb->len - sizeof(struct udphdr); |
1332 |
|
if (copied > len) { |
1333 |
|
--- linux-2.4.37.6.orig/net/ipv6/raw.c |
1334 |
|
+++ linux-2.4.37.6/net/ipv6/raw.c |
1335 |
|
@@ -45,6 +45,7 @@ |
1336 |
|
#include <net/inet_common.h> |
1337 |
|
|
1338 |
|
#include <net/rawv6.h> |
1339 |
|
+#include <linux/ccsecurity.h> |
1340 |
|
|
1341 |
|
struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE]; |
1342 |
|
rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED; |
1343 |
|
@@ -369,6 +370,9 @@ int rawv6_recvmsg(struct sock *sk, struc |
1344 |
|
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1345 |
|
if (!skb) |
1346 |
|
goto out; |
1347 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1348 |
|
+ if (err) |
1349 |
|
+ goto out; |
1350 |
|
|
1351 |
|
copied = skb->len; |
1352 |
|
if (copied > len) { |
1353 |
|
--- linux-2.4.37.6.orig/net/ipv6/tcp_ipv6.c |
1354 |
|
+++ linux-2.4.37.6/net/ipv6/tcp_ipv6.c |
1355 |
|
@@ -52,6 +52,7 @@ |
1356 |
#include <net/inet_ecn.h> |
#include <net/inet_ecn.h> |
1357 |
|
|
1358 |
#include <asm/uaccess.h> |
#include <asm/uaccess.h> |
1359 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1360 |
|
|
1361 |
static void tcp_v6_send_reset(struct sk_buff *skb); |
static void tcp_v6_send_reset(struct sk_buff *skb); |
1362 |
static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req); |
static void tcp_v6_or_send_ack(struct sk_buff *skb, struct open_request *req); |
1363 |
@@ -110,6 +113,10 @@ static int tcp_v6_get_port(struct sock * |
@@ -110,6 +111,8 @@ static int tcp_v6_get_port(struct sock * |
1364 |
rover = low; |
rover = low; |
1365 |
head = &tcp_bhash[tcp_bhashfn(rover)]; |
head = &tcp_bhash[tcp_bhashfn(rover)]; |
1366 |
spin_lock(&head->lock); |
spin_lock(&head->lock); |
1367 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(rover)) |
|
+ if (ccs_may_autobind(rover)) |
|
1368 |
+ goto next; |
+ goto next; |
|
+ /***** SAKURA Linux end. *****/ |
|
1369 |
for (tb = head->chain; tb; tb = tb->next) |
for (tb = head->chain; tb; tb = tb->next) |
1370 |
if (tb->port == rover) |
if (tb->port == rover) |
1371 |
goto next; |
goto next; |
1372 |
--- linux-2.4.37.orig/net/ipv6/udp.c |
--- linux-2.4.37.6.orig/net/ipv6/udp.c |
1373 |
+++ linux-2.4.37/net/ipv6/udp.c |
+++ linux-2.4.37.6/net/ipv6/udp.c |
1374 |
@@ -50,6 +50,9 @@ |
@@ -50,6 +50,7 @@ |
1375 |
#include <net/inet_common.h> |
#include <net/inet_common.h> |
1376 |
|
|
1377 |
#include <net/checksum.h> |
#include <net/checksum.h> |
1378 |
+/***** SAKURA Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/sakura.h> |
|
|
+/***** SAKURA Linux end. *****/ |
|
1379 |
|
|
1380 |
struct udp_mib udp_stats_in6[NR_CPUS*2]; |
struct udp_mib udp_stats_in6[NR_CPUS*2]; |
1381 |
|
|
1382 |
@@ -77,6 +80,10 @@ static int udp_v6_get_port(struct sock * |
@@ -77,6 +78,8 @@ static int udp_v6_get_port(struct sock * |
1383 |
result = sysctl_local_port_range[0] + |
result = sysctl_local_port_range[0] + |
1384 |
((result - sysctl_local_port_range[0]) & |
((result - sysctl_local_port_range[0]) & |
1385 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1386 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1387 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1388 |
goto gotit; |
goto gotit; |
1389 |
} |
} |
1390 |
size = 0; |
size = 0; |
1391 |
@@ -94,6 +101,10 @@ static int udp_v6_get_port(struct sock * |
@@ -94,6 +97,8 @@ static int udp_v6_get_port(struct sock * |
1392 |
result = sysctl_local_port_range[0] |
result = sysctl_local_port_range[0] |
1393 |
+ ((result - sysctl_local_port_range[0]) & |
+ ((result - sysctl_local_port_range[0]) & |
1394 |
(UDP_HTABLE_SIZE - 1)); |
(UDP_HTABLE_SIZE - 1)); |
1395 |
+ /***** SAKURA Linux start. *****/ |
+ if (ccs_lport_reserved(result)) |
|
+ if (ccs_may_autobind(result)) |
|
1396 |
+ continue; |
+ continue; |
|
+ /***** SAKURA Linux end. *****/ |
|
1397 |
if (!udp_lport_inuse(result)) |
if (!udp_lport_inuse(result)) |
1398 |
break; |
break; |
1399 |
} |
} |
1400 |
--- linux-2.4.37.orig/net/socket.c |
@@ -406,6 +411,9 @@ try_again: |
1401 |
+++ linux-2.4.37/net/socket.c |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
1402 |
@@ -84,6 +84,10 @@ |
if (!skb) |
1403 |
|
goto out; |
1404 |
|
+ err = ccs_socket_recvmsg_permission(sk, skb, flags); |
1405 |
|
+ if (err) |
1406 |
|
+ goto out; |
1407 |
|
|
1408 |
|
copied = skb->len - sizeof(struct udphdr); |
1409 |
|
if (copied > len) { |
1410 |
|
--- linux-2.4.37.6.orig/net/socket.c |
1411 |
|
+++ linux-2.4.37.6/net/socket.c |
1412 |
|
@@ -84,6 +84,7 @@ |
1413 |
#include <net/sock.h> |
#include <net/sock.h> |
1414 |
#include <net/scm.h> |
#include <net/scm.h> |
1415 |
#include <linux/netfilter.h> |
#include <linux/netfilter.h> |
1416 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+#include <linux/tomoyo_socket.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1417 |
|
|
1418 |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |
1419 |
static ssize_t sock_read(struct file *file, char *buf, |
static ssize_t sock_read(struct file *file, char *buf, |
1420 |
@@ -501,7 +505,12 @@ int sock_sendmsg(struct socket *sock, st |
@@ -501,7 +502,10 @@ int sock_sendmsg(struct socket *sock, st |
1421 |
{ |
{ |
1422 |
int err; |
int err; |
1423 |
struct scm_cookie scm; |
struct scm_cookie scm; |
1424 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
1425 |
+ err = ccs_socket_sendmsg_permission(sock, |
+ err = ccs_socket_sendmsg_permission(sock, |
1426 |
+ (struct sockaddr *) msg->msg_name, |
+ (struct sockaddr *) msg->msg_name, |
1427 |
+ msg->msg_namelen); |
+ msg->msg_namelen); |
1428 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1429 |
err = scm_send(sock, msg, &scm); |
err = scm_send(sock, msg, &scm); |
1430 |
if (err >= 0) { |
if (err >= 0) { |
1431 |
err = sock->ops->sendmsg(sock, msg, size, &scm); |
err = sock->ops->sendmsg(sock, msg, size, &scm); |
1432 |
@@ -847,7 +856,11 @@ int sock_create(int family, int type, in |
@@ -850,7 +854,9 @@ int sock_create(int family, int type, in |
1433 |
} |
} |
1434 |
family = PF_PACKET; |
family = PF_PACKET; |
1435 |
} |
} |
1436 |
- |
- |
|
+ /***** TOMOYO Linux start. *****/ |
|
1437 |
+ i = ccs_socket_create_permission(family, type, protocol); |
+ i = ccs_socket_create_permission(family, type, protocol); |
1438 |
+ if (i) |
+ if (i) |
1439 |
+ return i; |
+ return i; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1440 |
#if defined(CONFIG_KMOD) && defined(CONFIG_NET) |
#if defined(CONFIG_KMOD) && defined(CONFIG_NET) |
1441 |
/* Attempt to load a protocol module if the find failed. |
/* Attempt to load a protocol module if the find failed. |
1442 |
* |
* |
1443 |
@@ -1003,6 +1016,12 @@ asmlinkage long sys_bind(int fd, struct |
@@ -1006,6 +1012,10 @@ asmlinkage long sys_bind(int fd, struct |
1444 |
if((sock = sockfd_lookup(fd,&err))!=NULL) |
if((sock = sockfd_lookup(fd,&err))!=NULL) |
1445 |
{ |
{ |
1446 |
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) |
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) |
|
+ /***** TOMOYO Linux start. *****/ |
|
1447 |
+ err = ccs_socket_bind_permission(sock, |
+ err = ccs_socket_bind_permission(sock, |
1448 |
+ (struct sockaddr *) |
+ (struct sockaddr *) |
1449 |
+ address, addrlen); |
+ address, addrlen); |
1450 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1451 |
err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen); |
err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen); |
1452 |
sockfd_put(sock); |
sockfd_put(sock); |
1453 |
} |
} |
1454 |
@@ -1026,6 +1045,10 @@ asmlinkage long sys_listen(int fd, int b |
@@ -1029,6 +1039,8 @@ asmlinkage long sys_listen(int fd, int b |
1455 |
if ((sock = sockfd_lookup(fd, &err)) != NULL) { |
if ((sock = sockfd_lookup(fd, &err)) != NULL) { |
1456 |
if ((unsigned) backlog > sysctl_somaxconn) |
if ((unsigned) backlog > sysctl_somaxconn) |
1457 |
backlog = sysctl_somaxconn; |
backlog = sysctl_somaxconn; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1458 |
+ err = ccs_socket_listen_permission(sock); |
+ err = ccs_socket_listen_permission(sock); |
1459 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1460 |
err=sock->ops->listen(sock, backlog); |
err=sock->ops->listen(sock, backlog); |
1461 |
sockfd_put(sock); |
sockfd_put(sock); |
1462 |
} |
} |
1463 |
@@ -1066,6 +1089,13 @@ asmlinkage long sys_accept(int fd, struc |
@@ -1069,6 +1081,11 @@ asmlinkage long sys_accept(int fd, struc |
1464 |
if (err < 0) |
if (err < 0) |
1465 |
goto out_release; |
goto out_release; |
1466 |
|
|
|
+ /***** TOMOYO Linux start. *****/ |
|
1467 |
+ if (ccs_socket_accept_permission(newsock, |
+ if (ccs_socket_accept_permission(newsock, |
1468 |
+ (struct sockaddr *) address)) { |
+ (struct sockaddr *) address)) { |
1469 |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
+ err = -ECONNABORTED; /* Hope less harmful than -EPERM. */ |
1470 |
+ goto out_release; |
+ goto out_release; |
1471 |
+ } |
+ } |
|
+ /***** TOMOYO Linux end. *****/ |
|
1472 |
if (upeer_sockaddr) { |
if (upeer_sockaddr) { |
1473 |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) { |
1474 |
err = -ECONNABORTED; |
err = -ECONNABORTED; |
1475 |
@@ -1116,6 +1146,12 @@ asmlinkage long sys_connect(int fd, stru |
@@ -1119,6 +1136,10 @@ asmlinkage long sys_connect(int fd, stru |
1476 |
err = move_addr_to_kernel(uservaddr, addrlen, address); |
err = move_addr_to_kernel(uservaddr, addrlen, address); |
1477 |
if (err < 0) |
if (err < 0) |
1478 |
goto out_put; |
goto out_put; |
|
+ /***** TOMOYO Linux start. *****/ |
|
1479 |
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, |
+ err = ccs_socket_connect_permission(sock, (struct sockaddr *) address, |
1480 |
+ addrlen); |
+ addrlen); |
1481 |
+ if (err) |
+ if (err) |
1482 |
+ goto out_put; |
+ goto out_put; |
|
+ /***** TOMOYO Linux end. *****/ |
|
1483 |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
err = sock->ops->connect(sock, (struct sockaddr *) address, addrlen, |
1484 |
sock->file->f_flags); |
sock->file->f_flags); |
1485 |
out_put: |
out_put: |
1486 |
--- linux-2.4.37.orig/net/unix/af_unix.c |
--- linux-2.4.37.6.orig/net/unix/af_unix.c |
1487 |
+++ linux-2.4.37/net/unix/af_unix.c |
+++ linux-2.4.37.6/net/unix/af_unix.c |
1488 |
@@ -111,6 +111,9 @@ |
@@ -111,6 +111,7 @@ |
1489 |
#include <linux/rtnetlink.h> |
#include <linux/rtnetlink.h> |
1490 |
|
|
1491 |
#include <asm/checksum.h> |
#include <asm/checksum.h> |
1492 |
+/***** TOMOYO Linux start. *****/ |
+#include <linux/ccsecurity.h> |
|
+#include <linux/tomoyo.h> |
|
|
+/***** TOMOYO Linux end. *****/ |
|
1493 |
|
|
1494 |
int sysctl_unix_max_dgram_qlen = 10; |
int sysctl_unix_max_dgram_qlen = 10; |
1495 |
|
|
1496 |
@@ -645,6 +648,11 @@ static int unix_bind(struct socket *sock |
@@ -710,6 +711,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) |
|
|
@@ -709,6 +717,13 @@ static int unix_bind(struct socket *sock |
|
1497 |
* All right, let's create it. |
* All right, let's create it. |
1498 |
*/ |
*/ |
1499 |
mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask); |
mode = S_IFSOCK | (sock->inode->i_mode & ~current->fs->umask); |
1500 |
+ /***** TOMOYO Linux start. *****/ |
+ err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt, |
1501 |
+ err = pre_vfs_mknod(nd.dentry->d_inode, dentry); |
+ mode, 0); |
|
+ if (!err) |
|
|
+ err = ccs_check_1path_perm(TYPE_MKSOCK_ACL, dentry, |
|
|
+ nd.mnt); |
|
1502 |
+ if (!err) |
+ if (!err) |
|
+ /***** TOMOYO Linux end. *****/ |
|
1503 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1504 |
if (err) |
if (err) |
1505 |
goto out_mknod_dput; |
goto out_mknod_dput; |