1
|
1 |
theory Sectxt_prop
|
|
2 |
imports Main Flask Flask_type Current_files_prop Current_sockets_prop Alive_prop
|
|
3 |
begin
|
|
4 |
|
|
5 |
context flask begin
|
|
6 |
|
|
7 |
lemma alive_obj_has_type:
|
|
8 |
assumes alive: "alive s obj" and vs: "valid s"
|
|
9 |
shows "\<exists> t. type_of_obj s obj = Some t"
|
|
10 |
using alive vs
|
|
11 |
proof (induct s arbitrary:obj)
|
|
12 |
case Nil
|
|
13 |
thus ?case
|
|
14 |
by (simp add:init_alive_prop[THEN sym] init_obj_has_type)
|
|
15 |
next
|
|
16 |
case (Cons e s)
|
|
17 |
hence a2: "alive (e # s) obj" and a3: "valid (e # s)" by auto
|
|
18 |
hence a4: "valid s" and a5: "os_grant s e" and a6: "grant s e"
|
|
19 |
by (auto intro:vd_cons vt_grant_os vt_grant)
|
|
20 |
hence a1: "\<And> obj. alive s obj \<Longrightarrow> \<exists>t. type_of_obj s obj = Some t" using Cons by auto
|
|
21 |
have a1': "\<And> obj. type_of_obj s obj = None \<Longrightarrow> \<not> alive s obj" by (rule_tac notI, auto dest:a1)
|
|
22 |
have p1: "\<And> p. p \<in> current_procs s \<Longrightarrow> \<exists> t. type_of_obj s (O_proc p) = Some t" by (auto intro:a1)
|
|
23 |
have p2: "\<And> f. is_file s f \<Longrightarrow> \<exists> t. type_of_obj s (O_file f) = Some t"
|
|
24 |
by (auto intro!:a1 simp:is_file_in_current)
|
|
25 |
have p3: "\<And> f. is_dir s f \<Longrightarrow> \<exists> t. type_of_obj s (O_dir f) = Some t"
|
|
26 |
by (auto intro!:a1 simp:is_dir_in_current)
|
|
27 |
have p4: "\<And> sock. is_tcp_sock s sock \<Longrightarrow> \<exists> t. type_of_obj s (O_tcp_sock sock) = Some t"
|
|
28 |
by (auto intro!:a1 simp:is_tcp_in_current)
|
|
29 |
have p5: "\<And> sock. is_udp_sock s sock \<Longrightarrow> \<exists> t. type_of_obj s (O_udp_sock sock) = Some t"
|
|
30 |
by (auto intro!:a1 simp:is_udp_in_current)
|
|
31 |
have p6: "\<And> p fd. fd \<in> current_proc_fds s p \<Longrightarrow> \<exists> t. type_of_obj s (O_fd p fd) = Some t"
|
|
32 |
by (auto intro:a1)
|
|
33 |
have p7: "\<And> n. n \<in> init_nodes \<Longrightarrow> \<exists> t. type_of_obj s (O_node n) = Some t" by (auto intro:a1)
|
|
34 |
have p8: "\<And> h. h \<in> current_shms s \<Longrightarrow> \<exists> t. type_of_obj s (O_shm h) = Some t" by (auto intro:a1)
|
|
35 |
have p9: "\<And> q. q \<in> current_msgqs s \<Longrightarrow> \<exists> t. type_of_obj s (O_msgq q) = Some t" by (auto intro:a1)
|
|
36 |
have p10: "\<And> q m. \<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s\<rbrakk>
|
|
37 |
\<Longrightarrow> \<exists> t. type_of_obj s (O_msg q m) = Some t" by (auto intro:a1)
|
|
38 |
show ?case using a5 a2 a4 a3
|
|
39 |
apply (case_tac e)
|
|
40 |
apply (auto split:option.splits t_object.splits if_splits t_socket_type.splits
|
|
41 |
dest!:a1' intro:a1 intro:p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 simp:alive_simps)
|
|
42 |
done
|
|
43 |
qed
|
|
44 |
|
|
45 |
lemma alive_obj_has_user:
|
|
46 |
assumes alive: "alive s obj" and vs: "valid s"
|
|
47 |
shows "\<exists> t. user_of_obj s obj = Some t"
|
|
48 |
using alive vs
|
|
49 |
proof (induct s arbitrary:obj)
|
|
50 |
case Nil
|
|
51 |
thus ?case
|
|
52 |
by (simp add:init_alive_prop[THEN sym] init_obj_has_user)
|
|
53 |
next
|
|
54 |
case (Cons e s)
|
|
55 |
hence a2: "alive (e # s) obj" and a3: "valid (e # s)" by auto
|
|
56 |
hence a4: "valid s" and a5: "os_grant s e" and a6: "grant s e"
|
|
57 |
by (auto intro:vd_cons vt_grant_os vt_grant)
|
|
58 |
hence a1: "\<And> obj. alive s obj \<Longrightarrow> \<exists>t. user_of_obj s obj = Some t" using Cons by auto
|
|
59 |
have a1': "\<And> obj. user_of_obj s obj = None \<Longrightarrow> \<not> alive s obj" by (rule_tac notI, auto dest:a1)
|
|
60 |
have p1: "\<And> p. p \<in> current_procs s \<Longrightarrow> \<exists> t. user_of_obj s (O_proc p) = Some t" by (auto intro:a1)
|
|
61 |
have p2: "\<And> f. is_file s f \<Longrightarrow> \<exists> t. user_of_obj s (O_file f) = Some t"
|
|
62 |
by (auto intro!:a1 simp:is_file_in_current)
|
|
63 |
have p3: "\<And> f. is_dir s f \<Longrightarrow> \<exists> t. user_of_obj s (O_dir f) = Some t"
|
|
64 |
by (auto intro!:a1 simp:is_dir_in_current)
|
|
65 |
have p4: "\<And> sock. is_tcp_sock s sock \<Longrightarrow> \<exists> t. user_of_obj s (O_tcp_sock sock) = Some t"
|
|
66 |
by (auto intro!:a1 simp:is_tcp_in_current)
|
|
67 |
have p5: "\<And> sock. is_udp_sock s sock \<Longrightarrow> \<exists> t. user_of_obj s (O_udp_sock sock) = Some t"
|
|
68 |
by (auto intro!:a1 simp:is_udp_in_current)
|
|
69 |
have p6: "\<And> p fd. fd \<in> current_proc_fds s p \<Longrightarrow> \<exists> t. user_of_obj s (O_fd p fd) = Some t"
|
|
70 |
by (auto intro:a1)
|
|
71 |
have p7: "\<And> n. n \<in> init_nodes \<Longrightarrow> \<exists> t. user_of_obj s (O_node n) = Some t" by (auto intro:a1)
|
|
72 |
have p8: "\<And> h. h \<in> current_shms s \<Longrightarrow> \<exists> t. user_of_obj s (O_shm h) = Some t" by (auto intro:a1)
|
|
73 |
have p9: "\<And> q. q \<in> current_msgqs s \<Longrightarrow> \<exists> t. user_of_obj s (O_msgq q) = Some t" by (auto intro:a1)
|
|
74 |
have p10: "\<And> q m. \<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s\<rbrakk>
|
|
75 |
\<Longrightarrow> \<exists> t. user_of_obj s (O_msg q m) = Some t" by (auto intro:a1)
|
|
76 |
show ?case using a5 a2 a4 a3
|
|
77 |
apply (case_tac e)
|
|
78 |
apply (auto split:option.splits t_object.splits if_splits t_socket_type.splits
|
|
79 |
dest!:a1' intro:a1 intro:p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 simp:alive_simps)
|
|
80 |
done
|
|
81 |
qed
|
|
82 |
|
|
83 |
lemma alive_obj_has_type': "\<lbrakk>type_of_obj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj"
|
|
84 |
by (rule_tac notI, auto dest:alive_obj_has_type)
|
|
85 |
|
|
86 |
lemma current_proc_has_type:
|
|
87 |
"\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_proc p) = Some t"
|
|
88 |
by (auto intro:alive_obj_has_type)
|
|
89 |
|
|
90 |
lemma current_proc_has_type':
|
|
91 |
"\<lbrakk>type_of_obj s (O_proc p) = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s"
|
|
92 |
by (rule notI, auto dest:current_proc_has_type)
|
|
93 |
|
|
94 |
lemma is_file_has_type: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_file f) = Some t"
|
|
95 |
by (auto intro:alive_obj_has_type simp:is_file_in_current)
|
|
96 |
|
|
97 |
lemma is_file_has_type': "\<lbrakk>type_of_obj s (O_file f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_file s f"
|
|
98 |
by (auto intro:notI dest:is_file_has_type)
|
|
99 |
|
|
100 |
lemma is_dir_has_type: "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_dir f) = Some t"
|
|
101 |
by (auto intro:alive_obj_has_type simp:is_dir_in_current)
|
|
102 |
|
|
103 |
lemma is_dir_has_type': "\<lbrakk>type_of_obj s (O_dir f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
|
|
104 |
by (auto intro:notI dest:is_dir_has_type)
|
|
105 |
|
|
106 |
lemma is_tcp_has_type: "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_tcp_sock sock) = Some t"
|
|
107 |
by (auto intro:alive_obj_has_type simp:is_tcp_in_current)
|
|
108 |
|
|
109 |
lemma is_tcp_has_type': "\<lbrakk>type_of_obj s (O_tcp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_tcp_sock s sock"
|
|
110 |
by (auto intro:notI dest:is_tcp_has_type)
|
|
111 |
|
|
112 |
lemma is_udp_has_type: "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_udp_sock sock) = Some t"
|
|
113 |
by (auto intro:alive_obj_has_type simp:is_udp_in_current)
|
|
114 |
|
|
115 |
lemma is_udp_has_type': "\<lbrakk>type_of_obj s (O_udp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_udp_sock s sock"
|
|
116 |
by (auto intro:notI dest:is_udp_has_type)
|
|
117 |
|
|
118 |
lemma current_fd_has_type: "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_fd p fd) = Some t"
|
|
119 |
by (auto intro:alive_obj_has_type)
|
|
120 |
|
|
121 |
lemma current_fd_has_type': "\<lbrakk>type_of_obj s (O_fd p fd) = None; valid s\<rbrakk> \<Longrightarrow> fd \<notin> current_proc_fds s p"
|
|
122 |
by (auto intro:notI dest:current_fd_has_type)
|
|
123 |
|
|
124 |
lemma init_node_has_type: "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_node n) = Some t"
|
|
125 |
by (auto intro: alive_obj_has_type)
|
|
126 |
|
|
127 |
lemma init_node_has_type': "\<lbrakk>type_of_obj s (O_node n) = None; valid s\<rbrakk> \<Longrightarrow> n \<notin> init_nodes"
|
|
128 |
by (auto intro:notI dest:init_node_has_type)
|
|
129 |
|
|
130 |
lemma current_shm_has_type: "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_shm h) = Some t"
|
|
131 |
by (auto intro:alive_obj_has_type)
|
|
132 |
|
|
133 |
lemma current_shm_has_type': "\<lbrakk>type_of_obj s (O_shm h) = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s"
|
|
134 |
by (auto intro:notI dest:current_shm_has_type)
|
|
135 |
|
|
136 |
lemma current_msgq_has_type: "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. type_of_obj s (O_msgq q) = Some t"
|
|
137 |
by (auto intro:alive_obj_has_type)
|
|
138 |
|
|
139 |
lemma current_msgq_has_type': "\<lbrakk>type_of_obj s (O_msgq q) = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s"
|
|
140 |
by (auto intro:notI dest:current_msgq_has_type)
|
|
141 |
|
|
142 |
lemma current_msg_has_type: "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
|
|
143 |
\<Longrightarrow> \<exists> t. type_of_obj s (O_msg q m) = Some t"
|
|
144 |
by (auto intro:alive_obj_has_type)
|
|
145 |
|
|
146 |
lemma current_msg_has_type': "\<lbrakk>type_of_obj s (O_msg q m) = None; valid s\<rbrakk>
|
|
147 |
\<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s"
|
|
148 |
by (auto dest!:current_msg_has_type)
|
|
149 |
|
|
150 |
lemmas current_has_type = alive_obj_has_type current_proc_has_type is_file_has_type is_dir_has_type
|
|
151 |
is_tcp_has_type is_udp_has_type current_fd_has_type init_node_has_type current_shm_has_type
|
|
152 |
current_msgq_has_type current_msg_has_type
|
|
153 |
|
|
154 |
lemmas current_has_type' = alive_obj_has_type' current_proc_has_type' is_file_has_type' is_dir_has_type'
|
|
155 |
is_tcp_has_type' is_udp_has_type' current_fd_has_type' init_node_has_type' current_shm_has_type'
|
|
156 |
current_msgq_has_type' current_msg_has_type'
|
|
157 |
|
|
158 |
lemma alive_obj_has_user': "\<lbrakk>user_of_obj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj"
|
|
159 |
by (rule_tac notI, auto dest:alive_obj_has_user)
|
|
160 |
|
|
161 |
lemma current_proc_has_user:
|
|
162 |
"\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_proc p) = Some t"
|
|
163 |
by (auto intro:alive_obj_has_user)
|
|
164 |
|
|
165 |
lemma current_proc_has_user':
|
|
166 |
"\<lbrakk>user_of_obj s (O_proc p) = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s"
|
|
167 |
by (rule notI, auto dest:current_proc_has_user)
|
|
168 |
|
|
169 |
lemma is_file_has_user: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_file f) = Some t"
|
|
170 |
by (auto intro:alive_obj_has_user simp:is_file_in_current)
|
|
171 |
|
|
172 |
lemma is_file_has_user': "\<lbrakk>user_of_obj s (O_file f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_file s f"
|
|
173 |
by (auto intro:notI dest:is_file_has_user)
|
|
174 |
|
|
175 |
lemma is_dir_has_user: "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_dir f) = Some t"
|
|
176 |
by (auto intro:alive_obj_has_user simp:is_dir_in_current)
|
|
177 |
|
|
178 |
lemma is_dir_has_user': "\<lbrakk>user_of_obj s (O_dir f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
|
|
179 |
by (auto intro:notI dest:is_dir_has_user)
|
|
180 |
|
|
181 |
lemma is_tcp_has_user: "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_tcp_sock sock) = Some t"
|
|
182 |
by (auto intro:alive_obj_has_user simp:is_tcp_in_current)
|
|
183 |
|
|
184 |
lemma is_tcp_has_user': "\<lbrakk>user_of_obj s (O_tcp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_tcp_sock s sock"
|
|
185 |
by (auto intro:notI dest:is_tcp_has_user)
|
|
186 |
|
|
187 |
lemma is_udp_has_user: "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_udp_sock sock) = Some t"
|
|
188 |
by (auto intro:alive_obj_has_user simp:is_udp_in_current)
|
|
189 |
|
|
190 |
lemma is_udp_has_user': "\<lbrakk>user_of_obj s (O_udp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_udp_sock s sock"
|
|
191 |
by (auto intro:notI dest:is_udp_has_user)
|
|
192 |
|
|
193 |
lemma current_fd_has_user: "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_fd p fd) = Some t"
|
|
194 |
by (auto intro:alive_obj_has_user)
|
|
195 |
|
|
196 |
lemma current_fd_has_user': "\<lbrakk>user_of_obj s (O_fd p fd) = None; valid s\<rbrakk> \<Longrightarrow> fd \<notin> current_proc_fds s p"
|
|
197 |
by (auto intro:notI dest:current_fd_has_user)
|
|
198 |
|
|
199 |
lemma init_node_has_user: "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_node n) = Some t"
|
|
200 |
by (auto intro: alive_obj_has_user)
|
|
201 |
|
|
202 |
lemma init_node_has_user': "\<lbrakk>user_of_obj s (O_node n) = None; valid s\<rbrakk> \<Longrightarrow> n \<notin> init_nodes"
|
|
203 |
by (auto intro:notI dest:init_node_has_user)
|
|
204 |
|
|
205 |
lemma current_shm_has_user: "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_shm h) = Some t"
|
|
206 |
by (auto intro:alive_obj_has_user)
|
|
207 |
|
|
208 |
lemma current_shm_has_user': "\<lbrakk>user_of_obj s (O_shm h) = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s"
|
|
209 |
by (auto intro:notI dest:current_shm_has_user)
|
|
210 |
|
|
211 |
lemma current_msgq_has_user: "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> t. user_of_obj s (O_msgq q) = Some t"
|
|
212 |
by (auto intro:alive_obj_has_user)
|
|
213 |
|
|
214 |
lemma current_msgq_has_user': "\<lbrakk>user_of_obj s (O_msgq q) = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s"
|
|
215 |
by (auto intro:notI dest:current_msgq_has_user)
|
|
216 |
|
|
217 |
lemma current_msg_has_user: "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
|
|
218 |
\<Longrightarrow> \<exists> t. user_of_obj s (O_msg q m) = Some t"
|
|
219 |
by (auto intro:alive_obj_has_user)
|
|
220 |
|
|
221 |
lemma current_msg_has_user': "\<lbrakk>user_of_obj s (O_msg q m) = None; valid s\<rbrakk>
|
|
222 |
\<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s"
|
|
223 |
by (auto dest!:current_msg_has_user)
|
|
224 |
|
|
225 |
lemmas current_has_user = alive_obj_has_user current_proc_has_user is_file_has_user is_dir_has_user
|
|
226 |
is_tcp_has_user is_udp_has_user current_fd_has_user init_node_has_user current_shm_has_user
|
|
227 |
current_msgq_has_user current_msg_has_user
|
|
228 |
|
|
229 |
lemmas current_has_user' = alive_obj_has_user' current_proc_has_user' is_file_has_user' is_dir_has_user'
|
|
230 |
is_tcp_has_user' is_udp_has_user' current_fd_has_user' init_node_has_user' current_shm_has_user'
|
|
231 |
current_msgq_has_user' current_msg_has_user'
|
|
232 |
|
|
233 |
lemma current_proc_has_role:
|
|
234 |
"\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> r. role_of_proc s p = Some r"
|
|
235 |
apply (induct s arbitrary:p, simp add:init_procrole_prop2)
|
|
236 |
apply (frule vd_cons, frule vt_grant_os, frule vt_grant, case_tac a)
|
|
237 |
apply (auto split:option.splits dest:current_has_type' simp:sectxt_of_obj_def)
|
|
238 |
done
|
|
239 |
|
|
240 |
lemma current_proc_has_role':
|
|
241 |
"\<lbrakk>role_of_proc s p = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s"
|
|
242 |
by (auto dest:current_proc_has_role)
|
|
243 |
|
|
244 |
lemma alive_obj_has_role:
|
|
245 |
"\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> r. role_of_obj s obj = Some r"
|
|
246 |
by (case_tac obj, auto intro:current_proc_has_role)
|
|
247 |
|
|
248 |
lemma alive_obj_has_sec:
|
|
249 |
"\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s obj = Some sec"
|
|
250 |
apply (frule alive_obj_has_type, simp)
|
|
251 |
apply (frule alive_obj_has_role, simp)
|
|
252 |
apply (frule alive_obj_has_user, simp)
|
|
253 |
apply (auto split:option.splits simp:sectxt_of_obj_def)
|
|
254 |
done
|
|
255 |
|
|
256 |
lemma alive_obj_has_sec':
|
|
257 |
"\<lbrakk>sectxt_of_obj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj"
|
|
258 |
by (auto dest:alive_obj_has_sec)
|
|
259 |
|
|
260 |
lemma alive_obj_has_sec'':
|
|
261 |
"\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s obj = Some (u,r,t)"
|
|
262 |
by (auto dest:alive_obj_has_sec)
|
|
263 |
|
|
264 |
lemma current_proc_has_sec:
|
|
265 |
"\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_proc p) = Some sec"
|
|
266 |
by (rule alive_obj_has_sec, simp+)
|
|
267 |
|
|
268 |
lemma current_proc_has_sec':
|
|
269 |
"\<lbrakk>sectxt_of_obj s (O_proc p) = None; valid s\<rbrakk> \<Longrightarrow> p \<notin> current_procs s"
|
|
270 |
by (rule notI, auto dest:current_proc_has_sec)
|
|
271 |
|
|
272 |
lemma current_proc_has_sec'':
|
|
273 |
"\<lbrakk>p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_proc p) = Some (u,r,t)"
|
|
274 |
by (drule current_proc_has_sec, auto)
|
|
275 |
|
|
276 |
lemma is_file_has_sec: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_file f) = Some sec"
|
|
277 |
by (rule alive_obj_has_sec, simp_all add:is_file_in_current)
|
|
278 |
|
|
279 |
lemma is_file_has_sec': "\<lbrakk>sectxt_of_obj s (O_file f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_file s f"
|
|
280 |
by (auto intro:notI dest:is_file_has_sec)
|
|
281 |
|
|
282 |
lemma is_file_has_sec'': "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_file f) = Some (u,r,t)"
|
|
283 |
by (drule is_file_has_sec, auto)
|
|
284 |
|
|
285 |
lemma is_dir_has_sec: "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_dir f) = Some sec"
|
|
286 |
by (rule alive_obj_has_sec, simp_all add:is_dir_in_current)
|
|
287 |
|
|
288 |
lemma is_dir_has_sec': "\<lbrakk>sectxt_of_obj s (O_dir f) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
|
|
289 |
by (auto intro:notI dest:is_dir_has_sec)
|
|
290 |
|
|
291 |
lemma is_dir_has_sec'': "\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_dir f) = Some (u,r,t)"
|
|
292 |
by (drule is_dir_has_sec, auto)
|
|
293 |
|
|
294 |
lemma is_tcp_has_sec: "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_tcp_sock sock) = Some sec"
|
|
295 |
by (rule alive_obj_has_sec, simp_all add:is_tcp_in_current)
|
|
296 |
|
|
297 |
lemma is_tcp_has_sec': "\<lbrakk>sectxt_of_obj s (O_tcp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_tcp_sock s sock"
|
|
298 |
by (auto intro:notI dest:is_tcp_has_sec)
|
|
299 |
|
|
300 |
lemma is_tcp_has_sec'': "\<lbrakk>is_tcp_sock s sock; valid s\<rbrakk>
|
|
301 |
\<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_tcp_sock sock) = Some (u,r,t)"
|
|
302 |
by (drule is_tcp_has_sec, simp_all add:is_tcp_in_current)
|
|
303 |
|
|
304 |
lemma is_udp_has_sec: "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_udp_sock sock) = Some sec"
|
|
305 |
by (rule alive_obj_has_sec, simp_all add:is_udp_in_current)
|
|
306 |
|
|
307 |
lemma is_udp_has_sec': "\<lbrakk>sectxt_of_obj s (O_udp_sock sock) = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_udp_sock s sock"
|
|
308 |
by (auto intro:notI dest:is_udp_has_sec)
|
|
309 |
|
|
310 |
lemma is_udp_has_sec'': "\<lbrakk>is_udp_sock s sock; valid s\<rbrakk>
|
|
311 |
\<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_udp_sock sock) = Some (u,r,t)"
|
|
312 |
by (drule is_udp_has_sec, simp_all add:is_udp_in_current)
|
|
313 |
|
|
314 |
lemma current_fd_has_sec: "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_fd p fd) = Some sec"
|
|
315 |
by (rule alive_obj_has_sec, simp+)
|
|
316 |
|
|
317 |
lemma current_fd_has_sec': "\<lbrakk>sectxt_of_obj s (O_fd p fd) = None; valid s\<rbrakk> \<Longrightarrow> fd \<notin> current_proc_fds s p"
|
|
318 |
by (auto intro:notI dest:current_fd_has_sec)
|
|
319 |
|
|
320 |
lemma current_fd_has_sec'': "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk>
|
|
321 |
\<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_fd p fd) = Some (u, r, t)"
|
|
322 |
by (drule current_fd_has_sec, simp+)
|
|
323 |
|
|
324 |
lemma init_node_has_sec: "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_node n) = Some sec"
|
|
325 |
by (rule alive_obj_has_sec, simp+)
|
|
326 |
|
|
327 |
lemma init_node_has_sec': "\<lbrakk>sectxt_of_obj s (O_node n) = None; valid s\<rbrakk> \<Longrightarrow> n \<notin> init_nodes"
|
|
328 |
by (auto intro:notI dest:init_node_has_sec)
|
|
329 |
|
|
330 |
lemma init_node_has_sec'': "\<lbrakk>n \<in> init_nodes; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_node n) = Some (u,r,t)"
|
|
331 |
by (drule init_node_has_sec, simp+)
|
|
332 |
|
|
333 |
lemma current_shm_has_sec: "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_shm h) = Some sec"
|
|
334 |
by (rule alive_obj_has_sec, simp+)
|
|
335 |
|
|
336 |
lemma current_shm_has_sec': "\<lbrakk>sectxt_of_obj s (O_shm h) = None; valid s\<rbrakk> \<Longrightarrow> h \<notin> current_shms s"
|
|
337 |
by (auto intro:notI dest:current_shm_has_sec)
|
|
338 |
|
|
339 |
lemma current_shm_has_sec'': "\<lbrakk>h \<in> current_shms s; valid s\<rbrakk> \<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_shm h) = Some (u,r,t)"
|
|
340 |
by (drule current_shm_has_sec, simp+)
|
|
341 |
|
|
342 |
lemma current_msgq_has_sec: "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk> \<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_msgq q) = Some sec"
|
|
343 |
by (rule alive_obj_has_sec, simp+)
|
|
344 |
|
|
345 |
lemma current_msgq_has_sec': "\<lbrakk>sectxt_of_obj s (O_msgq q) = None; valid s\<rbrakk> \<Longrightarrow> q \<notin> current_msgqs s"
|
|
346 |
by (auto intro:notI dest:current_msgq_has_sec)
|
|
347 |
|
|
348 |
lemma current_msgq_has_sec'': "\<lbrakk>q \<in> current_msgqs s; valid s\<rbrakk>
|
|
349 |
\<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_msgq q) = Some (u,r,t)"
|
|
350 |
by (drule current_msgq_has_sec, simp+)
|
|
351 |
|
|
352 |
lemma current_msg_has_sec: "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
|
|
353 |
\<Longrightarrow> \<exists> sec. sectxt_of_obj s (O_msg q m) = Some sec"
|
|
354 |
by (rule alive_obj_has_sec, simp+)
|
|
355 |
|
|
356 |
lemma current_msg_has_sec': "\<lbrakk>sectxt_of_obj s (O_msg q m) = None; valid s\<rbrakk>
|
|
357 |
\<Longrightarrow> m \<notin> set (msgs_of_queue s q) \<or> q \<notin> current_msgqs s"
|
|
358 |
by (auto dest!:current_msg_has_sec)
|
|
359 |
|
|
360 |
lemma current_msg_has_sec'': "\<lbrakk>m \<in> set (msgs_of_queue s q); q \<in> current_msgqs s; valid s\<rbrakk>
|
|
361 |
\<Longrightarrow> \<exists> u r t. sectxt_of_obj s (O_msg q m) = Some (u, r, t)"
|
|
362 |
by (drule current_msg_has_sec, simp+)
|
|
363 |
|
|
364 |
lemmas current_has_sec = alive_obj_has_sec current_proc_has_sec is_file_has_sec is_dir_has_sec
|
|
365 |
is_tcp_has_sec is_udp_has_sec current_fd_has_sec init_node_has_sec current_shm_has_sec
|
|
366 |
current_msgq_has_sec current_msg_has_sec
|
|
367 |
|
|
368 |
lemmas current_has_sec' = alive_obj_has_sec' current_proc_has_sec' is_file_has_sec' is_dir_has_sec'
|
|
369 |
is_tcp_has_sec' is_udp_has_sec' current_fd_has_sec' init_node_has_sec' current_shm_has_sec'
|
|
370 |
current_msgq_has_sec' current_msg_has_sec'
|
|
371 |
|
|
372 |
lemmas current_has_sec'' = alive_obj_has_sec'' current_proc_has_sec'' is_file_has_sec'' is_dir_has_sec''
|
|
373 |
is_tcp_has_sec'' is_udp_has_sec'' current_fd_has_sec'' init_node_has_sec'' current_shm_has_sec''
|
|
374 |
current_msgq_has_sec'' current_msg_has_sec''
|
|
375 |
|
7
|
376 |
(************ root sec remains ************)
|
|
377 |
|
|
378 |
lemma root_type_remains:
|
|
379 |
"valid s \<Longrightarrow> type_of_obj s (O_dir []) = init_type_of_obj (O_dir [])"
|
|
380 |
apply (induct s)
|
|
381 |
apply (simp)
|
|
382 |
apply (frule vd_cons, frule vt_grant_os, case_tac a) prefer 6
|
|
383 |
by (case_tac option, auto)
|
|
384 |
|
|
385 |
lemma root_user_remains:
|
|
386 |
"valid s \<Longrightarrow> user_of_obj s (O_dir []) = init_user_of_obj (O_dir [])"
|
|
387 |
apply (induct s)
|
|
388 |
apply (simp)
|
|
389 |
apply (frule vd_cons, frule vt_grant_os, case_tac a) prefer 6
|
|
390 |
by (case_tac option, auto)
|
|
391 |
|
|
392 |
lemma root_has_type':
|
|
393 |
"\<lbrakk>type_of_obj s (O_dir []) = None; valid s\<rbrakk> \<Longrightarrow> False"
|
|
394 |
apply (drule alive_obj_has_type', simp)
|
|
395 |
by (drule root_is_dir, simp)
|
|
396 |
|
|
397 |
lemma root_has_user':
|
|
398 |
"\<lbrakk>user_of_obj s (O_dir []) = None; valid s\<rbrakk> \<Longrightarrow> False"
|
|
399 |
apply (drule alive_obj_has_user', simp)
|
|
400 |
by (drule root_is_dir, simp)
|
|
401 |
|
|
402 |
lemma root_has_init_type':
|
|
403 |
"init_type_of_obj (O_dir []) = None \<Longrightarrow> False"
|
|
404 |
using init_obj_has_type[where obj = "O_dir []"] root_is_init_dir
|
|
405 |
by auto
|
|
406 |
|
|
407 |
lemma root_has_init_user':
|
|
408 |
"init_user_of_obj (O_dir []) = None \<Longrightarrow> False"
|
|
409 |
using init_obj_has_user[where obj = "O_dir []"] root_is_init_dir
|
|
410 |
by auto
|
|
411 |
|
|
412 |
lemma root_sec_remains:
|
|
413 |
"valid s \<Longrightarrow> sectxt_of_obj s (O_dir []) = init_sectxt_of_obj (O_dir [])"
|
|
414 |
by (auto simp:root_user_remains root_type_remains sectxt_of_obj_def init_sectxt_of_obj_def
|
|
415 |
split:option.splits)
|
|
416 |
|
|
417 |
lemma root_sec_set:
|
|
418 |
"\<exists> u t. sec_of_root = (u, R_object, t)"
|
|
419 |
by (auto simp:sec_of_root_def split:option.splits
|
|
420 |
dest!: root_has_init_type' root_has_init_user')
|
|
421 |
|
|
422 |
lemma sec_of_root_set:
|
|
423 |
"init_sectxt_of_obj (O_dir []) = Some sec_of_root"
|
|
424 |
using root_has_init_type' root_has_init_user'
|
|
425 |
apply (auto simp:init_sectxt_of_obj_def sec_of_root_def split:option.splits)
|
|
426 |
done
|
|
427 |
|
1
|
428 |
(*************** sectxt_of_obj simpset ****************)
|
|
429 |
|
|
430 |
lemma sec_execve:
|
|
431 |
"valid (Execve p f fds # s) \<Longrightarrow> sectxt_of_obj (Execve p f fds # s) =
|
|
432 |
(sectxt_of_obj s) (O_proc p := (
|
|
433 |
case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_file f)) of
|
|
434 |
(Some psec, Some fsec) \<Rightarrow> npctxt_execve psec fsec
|
|
435 |
| _ \<Rightarrow> None))"
|
|
436 |
apply (rule ext, frule vd_cons, frule vt_grant_os, frule vt_grant,case_tac x)
|
|
437 |
apply (auto simp:sectxt_of_obj_def split:option.splits
|
|
438 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
439 |
done
|
|
440 |
|
|
441 |
lemma sec_clone:
|
|
442 |
"valid (Clone p p' fds shms # s) \<Longrightarrow> sectxt_of_obj (Clone p p' fds shms # s) = (\<lambda> obj.
|
|
443 |
case obj of
|
|
444 |
O_proc p'' \<Rightarrow> if (p'' = p') then sectxt_of_obj s (O_proc p)
|
|
445 |
else sectxt_of_obj s obj
|
|
446 |
| O_fd p'' fd \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then sectxt_of_obj s (O_fd p fd)
|
|
447 |
else if (p'' = p') then None
|
|
448 |
else sectxt_of_obj s obj
|
|
449 |
| O_tcp_sock (p'', fd) \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then sectxt_of_obj s (O_tcp_sock (p, fd))
|
|
450 |
else if (p'' = p') then None
|
|
451 |
else sectxt_of_obj s obj
|
|
452 |
| O_udp_sock (p'', fd) \<Rightarrow> if (p'' = p' \<and> fd \<in> fds) then sectxt_of_obj s (O_udp_sock (p, fd))
|
|
453 |
else if (p'' = p') then None
|
|
454 |
else sectxt_of_obj s obj
|
|
455 |
| _ \<Rightarrow> sectxt_of_obj s obj )"
|
|
456 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
|
|
457 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
458 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
459 |
done
|
|
460 |
|
|
461 |
lemma sec_open:
|
|
462 |
"valid (Open p f flags fd opt # s) \<Longrightarrow> sectxt_of_obj (Open p f flags fd opt # s) = (\<lambda> obj.
|
|
463 |
case obj of
|
|
464 |
O_file f' \<Rightarrow> if (f' = f \<and> opt \<noteq> None) then
|
|
465 |
(case (parent f) of
|
|
466 |
None \<Rightarrow> None
|
|
467 |
| Some pf \<Rightarrow> (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
|
|
468 |
(Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object,
|
|
469 |
type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_file True)
|
|
470 |
| _ \<Rightarrow> None))
|
|
471 |
else sectxt_of_obj s obj
|
|
472 |
| O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then
|
|
473 |
(case (sectxt_of_obj s (O_proc p)) of
|
|
474 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
475 |
| _ \<Rightarrow> None)
|
|
476 |
else sectxt_of_obj s obj
|
|
477 |
| _ \<Rightarrow> sectxt_of_obj s obj)"
|
|
478 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
|
|
479 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
480 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
481 |
done
|
|
482 |
|
|
483 |
lemma sec_mkdir:
|
|
484 |
"valid (Mkdir p f inum # s) \<Longrightarrow> sectxt_of_obj (Mkdir p f inum # s) =
|
|
485 |
(sectxt_of_obj s) (O_dir f :=
|
|
486 |
(case parent f of
|
|
487 |
None \<Rightarrow> None
|
|
488 |
| Some pf \<Rightarrow> (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
|
|
489 |
(Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object,
|
|
490 |
type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_dir True)
|
|
491 |
| _ \<Rightarrow> None)))"
|
|
492 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
|
|
493 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
494 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
495 |
done
|
|
496 |
|
|
497 |
lemma sec_linkhard:
|
|
498 |
"valid (LinkHard p f f' # s) \<Longrightarrow> sectxt_of_obj (LinkHard p f f' # s) =
|
|
499 |
(sectxt_of_obj s) (O_file f' :=
|
|
500 |
(case parent f' of
|
|
501 |
None \<Rightarrow> None
|
|
502 |
| Some pf \<Rightarrow> (case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
|
|
503 |
(Some psec, Some pfsec) \<Rightarrow> Some (fst psec, R_object,
|
|
504 |
type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_file True)
|
|
505 |
| _ \<Rightarrow> None)))"
|
|
506 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
|
|
507 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
508 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
509 |
done
|
|
510 |
|
|
511 |
lemma sec_createmsgq:
|
|
512 |
"valid (CreateMsgq p q # s) \<Longrightarrow> sectxt_of_obj (CreateMsgq p q # s) = (sectxt_of_obj s) (O_msgq q :=
|
|
513 |
(case (sectxt_of_obj s (O_proc p)) of
|
|
514 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
515 |
| _ \<Rightarrow> None))"
|
|
516 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
|
|
517 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
518 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
519 |
done
|
|
520 |
|
|
521 |
lemma sec_sendmsg:
|
|
522 |
"valid (SendMsg p q m # s) \<Longrightarrow> sectxt_of_obj (SendMsg p q m # s) = (sectxt_of_obj s) (O_msg q m :=
|
|
523 |
(case (sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_msgq q)) of
|
|
524 |
(Some psec, Some qsec) \<Rightarrow> Some (fst psec, R_object,
|
|
525 |
type_transition ((snd o snd) psec) ((snd o snd) qsec) C_msg False)
|
|
526 |
| _ \<Rightarrow> None))"
|
|
527 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
|
|
528 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
529 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
530 |
done
|
|
531 |
|
|
532 |
lemma sec_createshm:
|
|
533 |
"valid (CreateShM p h # s) \<Longrightarrow> sectxt_of_obj (CreateShM p h # s) = (sectxt_of_obj s) (O_shm h :=
|
|
534 |
case (sectxt_of_obj s (O_proc p)) of
|
|
535 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
536 |
| _ \<Rightarrow> None)"
|
|
537 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac x)
|
|
538 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
539 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
540 |
done
|
|
541 |
|
|
542 |
lemma sec_createsock:
|
|
543 |
"valid (CreateSock p af st fd inum # s) \<Longrightarrow> sectxt_of_obj (CreateSock p af st fd inum # s) = (\<lambda> obj.
|
|
544 |
case obj of
|
|
545 |
O_fd p' fd' \<Rightarrow> if (p' = p \<and> fd' = fd) then
|
|
546 |
(case (sectxt_of_obj s (O_proc p)) of
|
|
547 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
548 |
| _ \<Rightarrow> None)
|
|
549 |
else sectxt_of_obj s obj
|
|
550 |
| O_tcp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = STREAM) then
|
|
551 |
(case (sectxt_of_obj s (O_proc p)) of
|
|
552 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
553 |
| _ \<Rightarrow> None)
|
|
554 |
else sectxt_of_obj s obj
|
|
555 |
| O_udp_sock (p', fd') \<Rightarrow> if (p' = p \<and> fd' = fd \<and> st = DGRAM) then
|
|
556 |
(case (sectxt_of_obj s (O_proc p)) of
|
|
557 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
558 |
| _ \<Rightarrow> None)
|
|
559 |
else sectxt_of_obj s obj
|
|
560 |
| _ \<Rightarrow> sectxt_of_obj s obj )"
|
|
561 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
|
|
562 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
563 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
564 |
done
|
|
565 |
|
|
566 |
lemma sec_accept:
|
|
567 |
"valid (Accept p fd addr port fd' inum # s) \<Longrightarrow> sectxt_of_obj (Accept p fd addr port fd' inum # s) = (\<lambda> obj.
|
|
568 |
case obj of
|
|
569 |
O_fd p' fd'' \<Rightarrow> if (p' = p \<and> fd'' = fd') then
|
|
570 |
(case (sectxt_of_obj s (O_proc p)) of
|
|
571 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
572 |
| _ \<Rightarrow> None)
|
|
573 |
else sectxt_of_obj s obj
|
|
574 |
| O_tcp_sock (p', fd'') \<Rightarrow> if (p' = p \<and> fd'' = fd') then
|
|
575 |
(case (sectxt_of_obj s (O_proc p)) of
|
|
576 |
Some psec \<Rightarrow> Some (fst psec, R_object, (snd o snd) psec)
|
|
577 |
| _ \<Rightarrow> None)
|
|
578 |
else sectxt_of_obj s obj
|
|
579 |
| _ \<Rightarrow> sectxt_of_obj s obj )"
|
|
580 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac obj)
|
|
581 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
582 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
583 |
done
|
|
584 |
|
|
585 |
lemma sec_others :
|
|
586 |
"\<lbrakk>valid (e # s);
|
|
587 |
\<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
|
|
588 |
\<forall> p f fds. e \<noteq> Execve p f fds;
|
|
589 |
\<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
|
|
590 |
\<forall> p f inum. e \<noteq> Mkdir p f inum;
|
|
591 |
\<forall> p f f'. e \<noteq> LinkHard p f f';
|
|
592 |
\<forall> p q. e \<noteq> CreateMsgq p q;
|
|
593 |
\<forall> p q m. e \<noteq> SendMsg p q m;
|
|
594 |
\<forall> p h. e \<noteq> CreateShM p h;
|
|
595 |
\<forall> p af st fd inum. e \<noteq> CreateSock p af st fd inum;
|
|
596 |
\<forall> p fd addr port fd' inum. e \<noteq> Accept p fd addr port fd' inum
|
|
597 |
\<rbrakk> \<Longrightarrow> sectxt_of_obj (e # s) = sectxt_of_obj s"
|
|
598 |
apply (rule ext, frule vd_cons, frule vt_grant_os, case_tac e, case_tac[!] x)
|
|
599 |
apply (auto simp:sectxt_of_obj_def split:option.splits if_splits
|
|
600 |
dest!:current_has_type' current_proc_has_role' current_has_user')
|
|
601 |
done
|
|
602 |
|
|
603 |
lemmas sectxt_of_obj_simps = sec_execve sec_open sec_mkdir sec_linkhard sec_createmsgq sec_sendmsg
|
|
604 |
sec_createshm sec_createsock sec_accept sec_clone sec_others (* init_sectxt_prop *)
|
|
605 |
|
|
606 |
(**************** get_parentfs_ctxts simpset **************)
|
|
607 |
|
|
608 |
lemma parentf_is_dir_prop1: "\<lbrakk>is_dir s (x # pf); valid s\<rbrakk> \<Longrightarrow> is_dir s pf"
|
|
609 |
apply (rule_tac f = "x # pf" in parentf_is_dir)
|
|
610 |
by (auto simp:is_dir_def current_files_def split:option.splits t_inode_tag.splits)
|
|
611 |
|
|
612 |
lemma parentf_is_dir_prop2: "\<lbrakk>is_file s (x # pf); valid s\<rbrakk> \<Longrightarrow> is_dir s pf"
|
|
613 |
apply (rule_tac f = "x # pf" in parentf_is_dir)
|
|
614 |
by (auto simp:is_dir_def is_file_def current_files_def split:option.splits t_inode_tag.splits)
|
|
615 |
|
|
616 |
lemma parentf_is_dir_prop3: "\<lbrakk>(x # pf) \<in> current_files s; valid s\<rbrakk> \<Longrightarrow> is_dir s pf"
|
|
617 |
apply (rule_tac f = "x # pf" in parentf_is_dir)
|
|
618 |
by (auto simp:is_dir_def current_files_def split:option.splits t_inode_tag.splits)
|
|
619 |
|
8
|
620 |
lemma get_pfs_secs_prop':
|
1
|
621 |
"\<lbrakk>get_parentfs_ctxts s f = None; valid s\<rbrakk> \<Longrightarrow> \<not> is_dir s f"
|
|
622 |
apply (induct f)
|
|
623 |
by (auto split:option.splits dest:current_has_sec' parentf_is_dir_prop1)
|
|
624 |
|
8
|
625 |
lemma get_pfs_secs_prop:
|
|
626 |
"\<lbrakk>is_dir s f; valid s\<rbrakk> \<Longrightarrow> \<exists> asecs. get_parentfs_ctxts s f = Some asecs"
|
|
627 |
using get_pfs_secs_prop'
|
|
628 |
by (auto)
|
|
629 |
|
1
|
630 |
lemma get_pfs_secs_open:
|
|
631 |
"valid (Open p f flags fd opt # s) \<Longrightarrow> get_parentfs_ctxts (Open p f flags fd opt # s) = get_parentfs_ctxts s"
|
|
632 |
apply (frule noroot_events, frule vd_cons, frule vt_grant_os)
|
|
633 |
apply (rule ext, induct_tac x)
|
|
634 |
by (auto split:option.splits simp:sectxt_of_obj_simps)
|
|
635 |
|
|
636 |
lemma get_pfs_secs_other:
|
|
637 |
"\<lbrakk>valid (e # s); \<forall> p f inum. e \<noteq> Mkdir p f inum\<rbrakk>
|
|
638 |
\<Longrightarrow> get_parentfs_ctxts (e # s) = get_parentfs_ctxts s"
|
|
639 |
apply (frule vd_cons, frule vt_grant_os, rule ext, induct_tac x)
|
|
640 |
apply (case_tac [!] e)
|
|
641 |
apply (auto split:option.splits if_splits simp:sectxt_of_obj_simps)
|
|
642 |
done
|
|
643 |
|
|
644 |
lemma get_pfs_secs_mkdir1:
|
|
645 |
assumes mkdir: "valid (Mkdir p f inum # s)" and noteq: "is_dir s f'"
|
|
646 |
shows "get_parentfs_ctxts (Mkdir p f inum # s) f' = get_parentfs_ctxts s f'"
|
|
647 |
proof-
|
|
648 |
from mkdir have vd: "valid s" and os: "os_grant s (Mkdir p f inum)"
|
|
649 |
by (frule_tac vd_cons, simp, frule_tac vt_grant_os, simp)
|
|
650 |
from mkdir have notroot: "f \<noteq> []" by (auto intro!:noroot_mkdir)
|
|
651 |
show ?thesis using noteq
|
|
652 |
proof (induct f')
|
|
653 |
case Nil
|
|
654 |
show ?case using notroot mkdir by (simp add:sectxt_of_obj_simps)
|
|
655 |
next
|
|
656 |
case (Cons a f')
|
|
657 |
hence p1: "is_dir s f'" using vd by (simp add:parentf_is_dir_prop1)
|
|
658 |
from Cons have p2: "is_dir s (a # f')" by simp
|
|
659 |
from Cons p1 have p3: "get_parentfs_ctxts (Mkdir p f inum # s) f' = get_parentfs_ctxts s f'" by simp
|
|
660 |
from p2 os have p4: "a # f' \<noteq> f" by (auto simp:is_dir_in_current)
|
|
661 |
from p1 os have p5: "f' \<noteq> f" by (auto simp:is_dir_in_current)
|
|
662 |
show ?case using mkdir vd os p4 p5 p1
|
|
663 |
by (auto simp:sectxt_of_obj_simps is_dir_simps p3
|
8
|
664 |
split:option.splits dest:current_has_sec' get_pfs_secs_prop')
|
1
|
665 |
qed
|
|
666 |
qed
|
|
667 |
|
|
668 |
lemma get_pfs_secs_mkdir2:
|
|
669 |
"valid (Mkdir p f inum # s) \<Longrightarrow> get_parentfs_ctxts (Mkdir p f inum # s) f = (
|
|
670 |
case f of
|
|
671 |
[] \<Rightarrow> get_parentfs_ctxts s []
|
|
672 |
| x#pf \<Rightarrow> (case (get_parentfs_ctxts s pf, sectxt_of_obj s (O_proc p), sectxt_of_obj s (O_dir pf)) of
|
|
673 |
(Some pfsecs, Some psec, Some pfsec) \<Rightarrow> Some ((fst psec, R_object, type_transition ((snd o snd) psec) ((snd o snd) pfsec) C_dir True) # pfsecs)
|
|
674 |
| _ \<Rightarrow> None))"
|
|
675 |
apply (frule vd_cons, frule vt_grant_os)
|
|
676 |
apply (frule noroot_events, case_tac f)
|
8
|
677 |
by (auto split:option.splits dest:current_has_sec' get_pfs_secs_prop' get_pfs_secs_mkdir1
|
1
|
678 |
simp:sectxt_of_obj_simps is_dir_simps)
|
|
679 |
|
|
680 |
lemmas get_parentfs_ctxts_simps = get_pfs_secs_other get_pfs_secs_mkdir1 get_pfs_secs_mkdir2
|
|
681 |
|
|
682 |
end
|
|
683 |
|
|
684 |
end |