77
|
1 |
theory Dynamic_static
|
|
2 |
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
|
|
3 |
Temp Enrich
|
|
4 |
begin
|
|
5 |
|
|
6 |
context tainting_s begin
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
lemma "alive s obj \<Longrightarrow> alive (enrich_proc s p p') obj"
|
|
11 |
apply (induct s, simp)
|
|
12 |
apply (case_tac a, case_tac[!] obj) sorry (*
|
|
13 |
apply (auto simp:is_file_def is_dir_def split:option.splits t_inode_tag.splits)
|
|
14 |
thm is_file_other
|
|
15 |
*)
|
|
16 |
lemma enrich_proc_valid:
|
|
17 |
"\<lbrakk>p \<in> current_procs s; valid s; p \<in> init_procs \<longrightarrow> deleted (O_proc p) s; p' \<notin> current_procs s\<rbrakk> \<Longrightarrow> valid (enrich_proc s p p')" (*
|
|
18 |
apply (induct s, simp)
|
|
19 |
apply (frule vd_cons, frule vt_grant, frule vt_grant_os, case_tac a)
|
|
20 |
apply (auto intro!:valid.intros(2))
|
|
21 |
prefer 28
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
end
|
|
26 |
*)
|
|
27 |
sorry
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
(* for any created obj, we can enrich trace with events that create new objs with the same static-properties *)
|
|
34 |
definition enriched:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
|
|
35 |
where
|
|
36 |
"enriched s objs s' \<equiv> \<forall> obj \<in> objs. \<exists> obj'. \<not> alive s obj' \<and> obj' \<notin> objs \<and>
|
|
37 |
alive s' obj' \<and> co2sobj s' obj' = co2sobj s' obj"
|
|
38 |
|
|
39 |
definition reserved:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
|
|
40 |
where
|
|
41 |
"reserved s objs s' \<equiv> \<forall> obj. alive s obj \<longrightarrow> alive s' obj \<and> co2sobj s' obj = co2sobj s obj"
|
|
42 |
|
|
43 |
definition enrichable :: "t_state \<Rightarrow> t_object set \<Rightarrow> bool"
|
|
44 |
where
|
|
45 |
"enrichable s objs \<equiv> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enriched s objs s' \<and> reserved s objs s'"
|
|
46 |
|
|
47 |
fun is_created :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
|
|
48 |
where
|
|
49 |
"is_created s (O_file f) = (\<forall> f' \<in> same_inode_files s f. init_alive (O_file f') \<longrightarrow> deleted (O_file f') s)"
|
|
50 |
| "is_created s obj = (init_alive obj \<longrightarrow> deleted obj s)"
|
|
51 |
|
|
52 |
definition is_inited :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
|
|
53 |
where
|
|
54 |
"is_inited s obj \<equiv> init_alive obj \<and> \<not> deleted obj s"
|
|
55 |
|
|
56 |
(*
|
|
57 |
lemma is_inited_eq_not_created:
|
|
58 |
"is_inited s obj = (\<not> is_created s obj)"
|
|
59 |
by (auto simp:is_created_def is_inited_def)
|
|
60 |
*)
|
|
61 |
|
|
62 |
lemma many_sq_imp_sms:
|
|
63 |
"\<lbrakk>S_msgq (Create, sec, sms) \<in> ss; ss \<in> static\<rbrakk> \<Longrightarrow> \<forall> sm \<in> (set sms). is_many_smsg sm"
|
|
64 |
sorry
|
|
65 |
|
|
66 |
(* recorded in our static world *)
|
|
67 |
fun recorded :: "t_object \<Rightarrow> bool"
|
|
68 |
where
|
|
69 |
"recorded (O_proc p) = True"
|
|
70 |
| "recorded (O_file f) = True"
|
|
71 |
| "recorded (O_dir f) = True"
|
|
72 |
| "recorded (O_node n) = False" (* cause socket is temperary not considered *)
|
|
73 |
| "recorded (O_shm h) = True"
|
|
74 |
| "recorded (O_msgq q) = True"
|
|
75 |
| "recorded _ = False"
|
|
76 |
|
|
77 |
lemma cf2sfile_fi_init_file:
|
|
78 |
"\<lbrakk>cf2sfile s f = Some (Init f', sec, psec, asecs); is_file s f; valid s\<rbrakk>
|
|
79 |
\<Longrightarrow> is_init_file f \<and> \<not> deleted (O_file f) s"
|
|
80 |
apply (simp add:cf2sfile_def sroot_def split:option.splits if_splits)
|
|
81 |
apply (case_tac f, simp, drule root_is_dir', simp+)
|
|
82 |
done
|
|
83 |
|
|
84 |
lemma root_not_deleted:
|
|
85 |
"valid s \<Longrightarrow> \<not> deleted (O_dir []) s"
|
|
86 |
apply (induct s, simp)
|
|
87 |
apply (frule vd_cons, frule vt_grant_os, case_tac a)
|
|
88 |
by auto
|
|
89 |
|
|
90 |
lemma cf2sfile_fi_init_dir:
|
|
91 |
"\<lbrakk>cf2sfile s f = Some (Init f', sec, psec, asecs); is_dir s f; valid s\<rbrakk>
|
|
92 |
\<Longrightarrow> is_init_dir f \<and> \<not> deleted (O_dir f) s"
|
|
93 |
apply (simp add:cf2sfile_def sroot_def split:option.splits if_splits)
|
|
94 |
apply (case_tac f, simp add:root_is_init_dir root_not_deleted, simp)
|
|
95 |
apply (drule file_dir_conflict, simp+)
|
|
96 |
done
|
|
97 |
|
|
98 |
lemma is_created_imp_many:
|
|
99 |
"\<lbrakk>is_created s obj; co2sobj s obj = Some sobj; alive s obj; valid s\<rbrakk> \<Longrightarrow> is_many sobj"
|
|
100 |
apply (case_tac obj, auto simp:co2sobj.simps split:option.splits)
|
|
101 |
apply (case_tac [!] a)
|
|
102 |
apply (auto simp:cp2sproc_def ch2sshm_def cq2smsgq_def cf2sfiles_def same_inode_files_def
|
|
103 |
split:option.splits if_splits)
|
|
104 |
apply (frule cf2sfile_fi_init_file, simp add:is_file_def, simp)
|
|
105 |
apply (erule_tac x = f' in allE, simp)
|
|
106 |
apply (frule cf2sfile_fi_init_dir, simp+)+
|
|
107 |
done
|
|
108 |
|
|
109 |
lemma anotherp_imp_manysp:
|
|
110 |
"\<lbrakk>cp2sproc s p = Some sp; co2sobj s (O_proc p') = co2sobj s (O_proc p); p' \<noteq> p;
|
|
111 |
p' \<in> current_procs s; p \<in> current_procs s\<rbrakk>
|
|
112 |
\<Longrightarrow> is_many_sproc sp"
|
|
113 |
by (case_tac sp, auto simp:cp2sproc_def co2sobj.simps split:option.splits if_splits)
|
|
114 |
|
|
115 |
lemma is_file_has_sfs:
|
|
116 |
"\<lbrakk>is_file s f; valid s; cf2sfile s f = Some sf\<rbrakk>
|
|
117 |
\<Longrightarrow> \<exists> sfs. co2sobj s (O_file f) = Some (S_file sfs (O_file f \<in> Tainted s)) \<and> sf \<in> sfs"
|
|
118 |
apply (rule_tac x = "{sf' | f' sf'. cf2sfile s f' = Some sf' \<and> f' \<in> same_inode_files s f}" in exI)
|
|
119 |
apply (auto simp:co2sobj.simps cf2sfiles_def tainted_eq_Tainted)
|
|
120 |
apply (rule_tac x = f in exI, simp add:same_inode_files_prop9)
|
|
121 |
done
|
|
122 |
|
|
123 |
declare Product_Type.split_paired_Ex Product_Type.split_paired_All [simp del]
|
|
124 |
|
|
125 |
lemma current_proc_in_s2ss:
|
|
126 |
"\<lbrakk>cp2sproc s p = Some sp; p \<in> current_procs s; valid s\<rbrakk>
|
|
127 |
\<Longrightarrow> S_proc sp (O_proc p \<in> Tainted s) \<in> s2ss s"
|
|
128 |
apply (simp add:s2ss_def, rule_tac x = "O_proc p" in exI)
|
|
129 |
apply (auto simp:co2sobj.simps tainted_eq_Tainted)
|
|
130 |
done
|
|
131 |
|
|
132 |
lemma current_file_in_s2ss:
|
|
133 |
"\<lbrakk>co2sobj s (O_file f) = Some (S_file sfs tagf); is_file s f; valid s\<rbrakk>
|
|
134 |
\<Longrightarrow> S_file sfs tagf \<in> s2ss s"
|
|
135 |
by (simp add:s2ss_def, rule_tac x = "O_file f" in exI, simp)
|
|
136 |
|
|
137 |
declare npctxt_execve.simps grant_execve.simps search_check.simps [simp del]
|
|
138 |
|
|
139 |
|
|
140 |
lemma npctxt_execve_eq_sec:
|
|
141 |
"\<lbrakk>sectxt_of_obj (Execve p f fds # s) (O_proc p) = Some sec'; sectxt_of_obj s (O_proc p) = Some sec;
|
|
142 |
sectxt_of_obj s (O_file f) = Some fsec; valid (Execve p f fds # s)\<rbrakk>
|
|
143 |
\<Longrightarrow> npctxt_execve sec fsec = Some sec'"
|
|
144 |
by (case_tac sec, case_tac fsec, auto simp:npctxt_execve.simps sectxt_of_obj_simps split:option.splits)
|
|
145 |
|
|
146 |
lemma npctxt_execve_eq_cp2sproc:
|
|
147 |
"\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
|
|
148 |
cp2sproc s p = Some (pi, sec, sfds, shms); cf2sfile s f = Some (fi, fsec, psec, asecs)\<rbrakk>
|
|
149 |
\<Longrightarrow> npctxt_execve sec fsec = Some sec'"
|
|
150 |
apply (frule vt_grant_os, frule vd_cons)
|
|
151 |
apply (rule npctxt_execve_eq_sec, auto simp:cp2sproc_def cf2sfile_def split:option.splits)
|
|
152 |
apply (case_tac f, auto dest:root_is_dir')
|
|
153 |
done
|
|
154 |
|
|
155 |
lemma seach_check_eq_static:
|
|
156 |
"\<lbrakk>cf2sfile s f = Some sf; valid s; is_dir s f \<or> is_file s f\<rbrakk>
|
|
157 |
\<Longrightarrow> search_check_s sec sf (is_file s f) = search_check s sec f"
|
|
158 |
apply (case_tac sf)
|
|
159 |
apply (induct f)
|
|
160 |
apply (auto simp:search_check_s_def search_check.simps cf2sfile_def sroot_def
|
|
161 |
root_sec_remains init_sectxt_prop sec_of_root_valid
|
|
162 |
dest!:root_is_dir' current_has_sec' split:option.splits)
|
|
163 |
done
|
|
164 |
|
|
165 |
lemma grant_execve_intro_execve:
|
|
166 |
"\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
|
|
167 |
cp2sproc s p = Some (pi, sec, sfds, shms); cf2sfile s f = Some (fi, fsec, psec, asecs)\<rbrakk>
|
|
168 |
\<Longrightarrow> grant_execve sec fsec sec'"
|
|
169 |
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
|
|
170 |
apply (auto split:option.splits dest!:current_has_sec' simp del:grant_execve.simps simp add:cp2sproc_execve)
|
|
171 |
apply (erule_tac x = aba in allE, erule_tac x = aca in allE, erule_tac x = bb in allE)
|
|
172 |
apply (auto simp del:grant_execve.simps simp add:cp2sproc_def cf2sfile_def split:option.splits)
|
|
173 |
apply (case_tac f, simp, drule root_is_dir', simp, simp, simp)
|
|
174 |
apply (simp add:sectxt_of_obj_simps)
|
|
175 |
done
|
|
176 |
|
|
177 |
lemma search_check_intro_execve:
|
|
178 |
"\<lbrakk>cp2sproc s p = Some (pi, sec, sfds, shms); valid (Execve p f fds # s)\<rbrakk>
|
|
179 |
\<Longrightarrow> search_check s sec f"
|
|
180 |
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
|
|
181 |
apply (auto split:option.splits dest!:current_has_sec' simp del:grant_execve.simps simp add:cp2sproc_execve)
|
|
182 |
apply (erule_tac x = aaa in allE, erule_tac x = ab in allE, erule_tac x = ba in allE)
|
|
183 |
apply (auto simp add:cp2sproc_def cf2sfile_def split:option.splits)
|
|
184 |
done
|
|
185 |
|
|
186 |
lemma inherit_fds_check_intro_execve:
|
|
187 |
"\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s)\<rbrakk>
|
|
188 |
\<Longrightarrow> inherit_fds_check s sec' p fds"
|
|
189 |
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
|
|
190 |
apply (auto split:option.splits dest!:current_has_sec' simp add:cp2sproc_execve)
|
|
191 |
apply (erule_tac x = aba in allE, erule_tac x = aca in allE, erule_tac x = bb in allE)
|
|
192 |
apply (auto simp add:cp2sproc_def cf2sfile_def split:option.splits)
|
|
193 |
apply (simp add:sectxt_of_obj_simps)
|
|
194 |
done
|
|
195 |
|
|
196 |
lemma execve_sfds_subset:
|
|
197 |
"\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
|
|
198 |
cp2sproc s p = Some (pi, sec, sfds, shms)\<rbrakk>
|
|
199 |
\<Longrightarrow> sfds' \<subseteq> sfds"
|
|
200 |
apply (frule vt_grant_os)
|
|
201 |
apply (auto simp:cp2sproc_def cpfd2sfds_execve split:option.splits dest!:current_has_sec')
|
|
202 |
apply (simp add:cpfd2sfds_def)
|
|
203 |
apply (rule_tac x = fd in bexI, auto simp:proc_file_fds_def)
|
|
204 |
done
|
|
205 |
|
|
206 |
lemma inherit_fds_check_imp_static:
|
|
207 |
"\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms');
|
|
208 |
inherit_fds_check s sec' p fds; valid (Execve p f fds # s)\<rbrakk>
|
|
209 |
\<Longrightarrow> inherit_fds_check_s sec' sfds'"
|
|
210 |
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
|
|
211 |
apply (auto simp:cp2sproc_def cpfd2sfds_execve inherit_fds_check_def inherit_fds_check_s_def split:option.splits)
|
|
212 |
sorry (*
|
|
213 |
apply (erule_tac x = "(ad, ae, bc)" in ballE, auto simp:sectxts_of_sfds_def sectxts_of_fds_def)
|
|
214 |
apply (erule_tac x = fd in ballE, auto simp:cfd2sfd_def split:option.splits)
|
|
215 |
done *)
|
|
216 |
|
|
217 |
lemma d2s_main_execve_grant_aux:
|
|
218 |
"\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
|
|
219 |
cp2sproc s p = Some (pi, sec, sfds, shms); cf2sfile s f = Some (fi, fsec, psec, asecs)\<rbrakk>
|
|
220 |
\<Longrightarrow> (npctxt_execve sec fsec = Some sec') \<and> grant_execve sec fsec sec' \<and>
|
|
221 |
search_check_s sec (fi, fsec, psec, asecs) (is_file s f) \<and>
|
|
222 |
inherit_fds_check_s sec' sfds' \<and> sfds' \<subseteq> sfds"
|
|
223 |
apply (rule conjI, erule_tac pi = pi and sec = sec and sfds = sfds and
|
|
224 |
shms = shms and fi = fi and fsec = fsec and psec = psec and
|
|
225 |
asecs = asecs in npctxt_execve_eq_cp2sproc, simp, simp, simp)
|
|
226 |
apply (rule conjI, erule_tac pi = pi and sec = sec and sfds = sfds and
|
|
227 |
shms = shms and fi = fi and fsec = fsec and psec = psec and
|
|
228 |
asecs = asecs in grant_execve_intro_execve, simp, simp, simp)
|
|
229 |
apply (rule conjI, drule_tac sec = sec in search_check_intro_execve, simp)
|
|
230 |
apply (frule vd_cons, frule vt_grant_os)
|
|
231 |
apply (drule_tac sec = sec in seach_check_eq_static, simp, simp, simp)
|
|
232 |
apply (rule conjI, rule inherit_fds_check_imp_static, simp)
|
|
233 |
apply (erule inherit_fds_check_intro_execve, simp, simp)
|
|
234 |
apply (erule_tac pi = pi and sfds = sfds and shms = shms in execve_sfds_subset, simp+)
|
|
235 |
done
|
|
236 |
|
|
237 |
lemma d2s_main_execve:
|
|
238 |
"\<lbrakk>valid (Execve p f fds # s); s2ss s \<propto> static\<rbrakk> \<Longrightarrow> s2ss (Execve p f fds # s) \<propto> static"
|
|
239 |
apply (frule vd_cons, frule vt_grant_os, clarsimp)
|
|
240 |
apply (frule is_file_has_sfile', simp, erule exE, frule is_file_has_sfs, simp+, erule exE, erule conjE)
|
|
241 |
apply (auto simp:s2ss_execve split:if_splits option.splits dest:current_proc_has_sp')
|
|
242 |
apply (clarsimp simp add:init_ss_in_def init_ss_eq_def)
|
|
243 |
apply (rule_tac x = "update_ss ss' (S_proc (ah, (ai, aj, bd), ak, be) (O_proc p \<in> Tainted s))
|
|
244 |
(S_proc (ad, (ae, af, bb), ag, bc) (O_proc p \<in> Tainted s \<or> O_file f \<in> Tainted s))" in bexI)
|
|
245 |
apply (auto simp:update_ss_def elim:Set.subset_insertI2 simp:anotherp_imp_manysp)[1]
|
|
246 |
apply (case_tac "ah = ad", case_tac "bc = {}", simp)
|
|
247 |
apply (erule_tac sfs = sfs and fi = a and fsec = "(aa, ab,b)" and pfsec = ac and asecs = ba in s_execve,
|
|
248 |
auto intro:current_proc_in_s2ss current_file_in_s2ss split:option.splits dest:d2s_main_execve_grant_aux)[1]
|
|
249 |
apply (simp add:cp2sproc_execve split:option.splits)
|
|
250 |
apply (simp add:cp2sproc_def split:option.splits if_splits)
|
|
251 |
|
|
252 |
apply (clarsimp simp add:init_ss_in_def init_ss_eq_def)
|
|
253 |
apply (rule_tac x = "update_ss ss' (S_proc (ah, (ai, aj, bd), ak, be) (O_proc p \<in> Tainted s))
|
|
254 |
(S_proc (ad, (ae, af, bb), ag, bc) (O_proc p \<in> Tainted s \<or> O_file f \<in> Tainted s))" in bexI)
|
|
255 |
apply (rule conjI, simp add:update_ss_def)
|
|
256 |
apply (rule conjI, simp add:update_ss_def)
|
|
257 |
apply (auto)[1]
|
|
258 |
apply (simp add:update_ss_def)
|
|
259 |
apply (rule conjI, rule impI)
|
|
260 |
apply (rule subsetI, clarsimp)
|
|
261 |
apply (erule impE)
|
|
262 |
apply (erule set_mp, simp)
|
|
263 |
apply (case_tac ah, simp+)
|
|
264 |
apply (rule impI, rule subsetI, clarsimp)
|
|
265 |
apply (erule set_mp, simp)
|
|
266 |
|
|
267 |
apply (case_tac "ah = ad", case_tac "bc = {}", simp)
|
|
268 |
apply (erule_tac sfs = sfs and fi = a and fsec = "(aa, ab,b)" and pfsec = ac and asecs = ba in s_execve,
|
|
269 |
auto intro:current_proc_in_s2ss current_file_in_s2ss split:option.splits dest:d2s_main_execve_grant_aux)[1]
|
|
270 |
apply (simp add:cp2sproc_execve split:option.splits)
|
|
271 |
apply (simp add:cp2sproc_def split:option.splits if_splits)
|
|
272 |
done
|
|
273 |
|
|
274 |
lemma co2sobj_eq_alive_proc_imp:
|
|
275 |
"\<lbrakk>co2sobj s obj = co2sobj s (O_proc p); alive s (O_proc p); valid s\<rbrakk>
|
|
276 |
\<Longrightarrow> \<exists> p'. obj = O_proc p'"
|
|
277 |
by (auto simp add:co2sobj.simps split:option.splits dest:current_proc_has_sp' intro:co2sobj_sproc_imp)
|
|
278 |
|
|
279 |
|
|
280 |
lemma enrichable_execve:
|
|
281 |
assumes p1: "\<And> objs. \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj
|
|
282 |
\<Longrightarrow> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enriched s objs s' \<and> reserved s objs s'"
|
|
283 |
and p2: "valid (e # s)" and p3: "\<forall>obj\<in>objs. alive (e # s) obj \<and> is_created (e # s) obj \<and> recorded obj"
|
|
284 |
and p4: "e = Execve p f fds"
|
|
285 |
shows "enrichable (e # s) objs"
|
|
286 |
proof-
|
|
287 |
from p2 have os: "os_grant s e" and se: "grant s e" and vd: "valid s"
|
|
288 |
by (auto dest:vt_grant_os vd_cons vt_grant)
|
|
289 |
from p3 have recorded: "\<forall> obj \<in> objs. recorded obj" by auto
|
|
290 |
from p3 p4 p2 have p1': "\<forall> obj \<in> objs. alive s obj \<and> is_created s obj"
|
|
291 |
apply clarify
|
|
292 |
apply (erule_tac x = obj in ballE, simp add:alive_simps)
|
|
293 |
apply (case_tac obj, auto simp:same_inode_files_simps)
|
|
294 |
done
|
|
295 |
then obtain s' where a1: "valid s'" and a2: "s2ss s' = s2ss s" and a3: "enriched s objs s'"
|
|
296 |
and a4: "reserved s objs s'"
|
|
297 |
using p1 recorded by metis
|
|
298 |
show ?thesis
|
|
299 |
proof (cases "O_proc p \<in> objs")
|
|
300 |
case True
|
|
301 |
hence p_in: "p \<in> current_procs s'" using a4 os p4
|
|
302 |
by (auto simp:reserved_def elim:allE[where x = "O_proc p"])
|
|
303 |
with a1 a3 True obtain p' where b1: "\<not> alive s (O_proc p')" and b2: "O_proc p' \<notin> objs"
|
|
304 |
and b3: "alive s' (O_proc p')" and b4: "co2sobj s' (O_proc p') = co2sobj s' (O_proc p)"
|
|
305 |
apply (simp only:enriched_def)
|
|
306 |
apply (erule_tac x = "O_proc p" in ballE)
|
|
307 |
apply (erule exE|erule conjE)+
|
|
308 |
apply (frule co2sobj_eq_alive_proc_imp, auto)
|
|
309 |
done
|
|
310 |
have "valid (Execve p' f fds # e # s')"
|
|
311 |
sorry
|
|
312 |
moreover have "s2ss (Execve p' f fds # e # s') = s2ss (e # s)"
|
|
313 |
sorry
|
|
314 |
moreover have "enriched (e # s) objs (Execve p' f fds # e # s')"
|
|
315 |
sorry
|
|
316 |
moreover have "reserved (e # s) objs (Execve p' f fds # e # s')"
|
|
317 |
sorry
|
|
318 |
ultimately show ?thesis
|
|
319 |
apply (simp add:enrichable_def)
|
|
320 |
apply (rule_tac x = "Execve p' f fds # e # s'" in exI)
|
|
321 |
by auto
|
|
322 |
next
|
|
323 |
case False
|
|
324 |
from a4 os p4 have "p \<in> current_procs s'"
|
|
325 |
apply (simp add:reserved_def)
|
|
326 |
by (erule_tac x = "O_proc p" in allE, auto)
|
|
327 |
moreover from a4 os p4 have "is_file s' f"
|
|
328 |
apply (simp add:reserved_def)
|
|
329 |
by (erule_tac x = "O_file f" in allE, auto)
|
|
330 |
moreover from a4 os p4 vd have "fds \<subseteq> proc_file_fds s' p"
|
|
331 |
apply (rule_tac subsetI, clarsimp simp:reserved_def current_proc_fds.simps)
|
|
332 |
apply (erule_tac x = "O_fd p x" in allE, erule impE)
|
|
333 |
sorry
|
|
334 |
ultimately have "os_grant s' e"
|
|
335 |
by (simp add:p4)
|
|
336 |
moreover have "grant s' e"
|
|
337 |
sorry
|
|
338 |
ultimately have "valid (e # s')"
|
|
339 |
using a1 by (erule_tac valid.intros(2), simp+)
|
|
340 |
thus ?thesis
|
|
341 |
apply (simp add:enrichable_def)
|
|
342 |
apply (rule_tac x = "e # s'" in exI)
|
|
343 |
apply (simp)
|
|
344 |
sorry
|
|
345 |
qed
|
|
346 |
qed
|
|
347 |
|
|
348 |
lemma s2d_main_execve:
|
|
349 |
"\<lbrakk>grant_execve pctxt fsec pctxt'; ss \<in> static; S_proc (pi, pctxt, fds, shms) tagp \<in> ss; S_file sfs tagf \<in> ss;
|
|
350 |
(fi, fsec, pfsec, asecs) \<in> sfs; npctxt_execve pctxt fsec = Some pctxt';
|
|
351 |
search_check_s pctxt (fi, fsec, pfsec, asecs) True; inherit_fds_check_s pctxt' fds'; fds' \<subseteq> fds; valid s;
|
|
352 |
s2ss s = ss\<rbrakk> \<Longrightarrow> \<exists>s. valid s \<and>
|
|
353 |
s2ss s = update_ss ss (S_proc (pi, pctxt, fds, shms) tagp) (S_proc (pi, pctxt', fds', {}) (tagp \<or> tagf))"
|
|
354 |
apply (simp add:update_ss_def)
|
|
355 |
thm update_ss_def
|
|
356 |
sorry
|
|
357 |
|
|
358 |
(*
|
|
359 |
lemma s2d_main_execve:
|
|
360 |
"ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
|
|
361 |
apply (erule static.induct)
|
|
362 |
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
|
|
363 |
apply (erule exE|erule conjE)+
|
|
364 |
apply (rule s2d_main_execve, simp+)
|
|
365 |
|
|
366 |
apply (erule exE|erule conjE)+
|
|
367 |
|
|
368 |
|
|
369 |
sorry
|
|
370 |
*)
|
|
371 |
|
|
372 |
|
|
373 |
(*********************** uppest-level 3 theorems ***********************)
|
|
374 |
|
|
375 |
lemma enrichability:
|
|
376 |
"\<lbrakk>valid s; \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj\<rbrakk>
|
|
377 |
\<Longrightarrow> enrichable s objs" sorry (*
|
|
378 |
proof (induct s arbitrary:objs)
|
|
379 |
case Nil
|
|
380 |
hence "objs = {}"
|
|
381 |
apply (auto)
|
|
382 |
apply (erule_tac x = x in ballE)
|
|
383 |
apply (case_tac x)
|
|
384 |
apply (auto simp:init_alive_prop)
|
|
385 |
sorry (* done *)
|
|
386 |
thus ?case using Nil unfolding enrichable_def enriched_def reserved_def
|
|
387 |
by (rule_tac x = "[]" in exI, auto)
|
|
388 |
next
|
|
389 |
case (Cons e s)
|
|
390 |
hence p1: "\<And> objs. \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj
|
|
391 |
\<Longrightarrow> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enriched s objs s' \<and> reserved s objs s'"
|
|
392 |
and p2: "valid (e # s)" and p3: "\<forall>obj\<in>objs. alive (e # s) obj \<and> is_created (e # s) obj \<and> recorded obj"
|
|
393 |
and os: "os_grant s e" and se: "grant s e" and vd: "valid s"
|
|
394 |
by (auto dest:vt_grant_os vd_cons vt_grant simp:enrichable_def)
|
|
395 |
show ?case
|
|
396 |
proof (cases e)
|
|
397 |
case (Execve p f fds)
|
|
398 |
hence p4: "e = Execve p f fds" by simp
|
|
399 |
from p3 have p5: "is_inited s (O_proc p) \<Longrightarrow> (O_proc p) \<notin> objs"
|
|
400 |
by (auto simp:is_created_def is_inited_def p4 elim!:ballE[where x = "O_proc p"])
|
|
401 |
show "enrichable (e # s) objs"
|
|
402 |
proof (cases "is_inited s (O_proc p)")
|
|
403 |
case True
|
|
404 |
with p5 have a1: "(O_proc p) \<notin> objs" by simp
|
|
405 |
with p3 p4 p2 have a2: "\<forall> obj \<in> objs. alive s obj \<and> is_created s obj" and a2': "\<forall> obj \<in> objs. recorded obj"
|
|
406 |
apply (auto simp:is_created_def alive_simps is_inited_def)
|
|
407 |
apply (erule_tac x = obj in ballE, auto simp:alive_simps split:t_object.splits)
|
|
408 |
done
|
|
409 |
then obtain s' where a3: "valid s'" and a4: "s2ss s' = s2ss s"
|
|
410 |
and a5: "enriched s objs s'" and a6: "reserved s objs s'"
|
|
411 |
using p1 apply (simp add:enrichable_def) sorry
|
|
412 |
from a5 p4 p2 a2' have a7: "enriched s objs (e # s')"
|
|
413 |
apply (clarsimp simp add:enriched_def co2sobj_execve)
|
|
414 |
apply (erule_tac x = obj in ballE, clarsimp)
|
|
415 |
apply (rule_tac x = obj' in exI, auto simp:co2sobj_execve alive_simps)
|
|
416 |
thm enriched_def
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
obtain s' where p6:"enriched s objs s'"
|
|
421 |
apply (simp add: alive_simps enrichable_def)
|
|
422 |
apply auto apply (rule ballI, rule_tac x = obj in exI)
|
|
423 |
|
|
424 |
have p6:"enriched (e # s) objs (e # s)"
|
|
425 |
apply (simp add:enriched_def alive_simps)
|
|
426 |
apply auto apply (rule ballI, rule_tac x = obj in exI)
|
|
427 |
|
|
428 |
have "enrich (e # s) objs (e # s)"
|
|
429 |
apply (simp add:enrich_def p4)
|
|
430 |
sorry
|
|
431 |
moreover have "reserve (e # s) objs (e # s)"
|
|
432 |
sorry
|
|
433 |
ultimately show ?thesis using p2
|
|
434 |
apply (simp add:enrichable_def)
|
|
435 |
by (rule_tac x = "e # s" in exI, simp)
|
|
436 |
next
|
|
437 |
|
|
438 |
|
|
439 |
thm enrichable_def
|
|
440 |
apply (simp add:enrichable_def p4)
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
apply auto
|
|
445 |
apply (auto simp:enrichable_def)
|
|
446 |
apply (induct s)
|
|
447 |
|
|
448 |
|
|
449 |
|
|
450 |
done
|
|
451 |
|
|
452 |
qed
|
|
453 |
*)
|
|
454 |
|
|
455 |
lemma d2s_main:
|
|
456 |
"valid s \<Longrightarrow> s2ss s \<propto> static"
|
|
457 |
apply (induct s, simp add:s2ss_nil_prop init_ss_in_def)
|
|
458 |
apply (rule_tac x = "init_static_state" in bexI, simp, simp add:s_init)
|
|
459 |
apply (frule vd_cons, frule vt_grant_os, simp)
|
|
460 |
apply (case_tac a)
|
|
461 |
apply (clarsimp simp add:s2ss_execve)
|
|
462 |
apply (rule conjI, rule impI)
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
sorry
|
|
467 |
|
|
468 |
lemma s2d_main:
|
|
469 |
"ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
|
|
470 |
apply (erule static.induct)
|
|
471 |
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
|
|
472 |
|
|
473 |
apply (erule exE|erule conjE)+
|
|
474 |
|
|
475 |
apply (simp add:update_ss_def)
|
|
476 |
|
|
477 |
sorry
|
|
478 |
|
|
479 |
lemma deleted_imp_deleted_s:
|
|
480 |
"\<lbrakk>deleted obj s; valid s\<rbrakk> \<Longrightarrow> \<exists> ss \<in> static. deleted_s ss obj "
|
|
481 |
sorry
|
|
482 |
|
|
483 |
lemma deleted_s_imp_deleted:
|
|
484 |
"\<lbrakk>deleted_s ss obj; ss \<in> static\<rbrakk> \<Longrightarrow> \<exists> s. valid s \<and> deleted obj s"
|
|
485 |
sorry
|
|
486 |
|
|
487 |
lemma updeletable_s_sound_comp:
|
|
488 |
"undeletable_s obj = undeletable obj"
|
|
489 |
apply (simp add:undeletable_def undeletable_s_def)
|
|
490 |
apply (auto dest:deleted_imp_deleted_s deleted_s_imp_deleted)
|
|
491 |
done
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
end
|
|
496 |
|
|
497 |
end
|
|
498 |
|
|
499 |
(*
|
|
500 |
lemma s2d_main':
|
|
501 |
"ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s \<doteq> ss"
|
|
502 |
apply (erule static.induct)
|
|
503 |
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
|
|
504 |
|
|
505 |
apply (erule exE|erule conjE)+
|
|
506 |
|
|
507 |
apply (simp add:update_ss_def)
|
|
508 |
|
|
509 |
sorry
|
|
510 |
|
|
511 |
*) |