1
|
1 |
theory Dynamic2static
|
19
|
2 |
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop
|
1
|
3 |
begin
|
|
4 |
|
|
5 |
context tainting_s begin
|
|
6 |
|
|
7 |
lemma d2s_main:
|
|
8 |
"valid s \<Longrightarrow> s2ss s \<in> static"
|
|
9 |
apply (induct s, simp add:s2ss_nil_prop s_init)
|
|
10 |
apply (frule vd_cons, simp)
|
|
11 |
apply (case_tac a, simp_all)
|
|
12 |
(*
|
|
13 |
apply
|
|
14 |
induct s, case tac e, every event analysis
|
|
15 |
*)
|
|
16 |
sorry
|
|
17 |
|
|
18 |
lemma d2s_main':
|
|
19 |
"\<lbrakk>alive s obj; co2sobj s obj= Some sobj\<rbrakk> \<Longrightarrow> sobj \<in> (s2ss s)"
|
19
|
20 |
by (simp add:s2ss_def, rule_tac x = obj in exI, simp)
|
1
|
21 |
|
|
22 |
lemma alive_has_sobj:
|
|
23 |
"\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> sobj. co2sobj s obj = Some sobj"
|
|
24 |
sorry
|
|
25 |
|
|
26 |
lemma t2ts:
|
|
27 |
"obj \<in> tainted s \<Longrightarrow> co2sobj s obj = Some sobj \<Longrightarrow> tainted_s (s2ss s) sobj"
|
19
|
28 |
apply (frule tainted_in_current, frule tainted_is_valid)
|
1
|
29 |
apply (simp add:s2ss_def)
|
|
30 |
apply (case_tac sobj, simp_all)
|
19
|
31 |
apply (case_tac [!] obj, simp_all split:option.splits if_splits)
|
1
|
32 |
apply (rule_tac x = "O_proc nat" in exI, simp)
|
|
33 |
apply (rule_tac x = "O_file list" in exI, simp)
|
19
|
34 |
apply (drule dir_not_tainted, simp)
|
|
35 |
apply (drule msgq_not_tainted, simp)
|
|
36 |
apply (drule shm_not_tainted, simp)
|
1
|
37 |
apply (case_tac prod1, simp, case_tac prod2, clarsimp)
|
|
38 |
apply (rule conjI)
|
|
39 |
apply (rule_tac x = "O_msgq nat1" in exI, simp)
|
19
|
40 |
apply (rule conjI) defer
|
|
41 |
apply (simp add:cm2smsg_def split:option.splits)
|
|
42 |
sorry
|
1
|
43 |
|
|
44 |
lemma delq_imp_delqm:
|
|
45 |
"deleted (O_msgq q) s \<Longrightarrow> deleted (O_msg q m) s"
|
|
46 |
apply (induct s, simp)
|
|
47 |
by (case_tac a, auto)
|
|
48 |
|
|
49 |
theorem static_complete:
|
|
50 |
assumes undel: "undeletable obj" and tbl: "taintable obj"
|
|
51 |
shows "taintable_s obj"
|
|
52 |
proof-
|
|
53 |
from tbl obtain s where tainted: "obj \<in> tainted s"
|
|
54 |
by (auto simp:taintable_def)
|
19
|
55 |
hence vs: "valid s" by (simp add:tainted_is_valid)
|
1
|
56 |
hence static: "s2ss s \<in> static" using d2s_main by auto
|
|
57 |
from tainted have alive: "alive s obj"
|
19
|
58 |
using tainted_in_current by auto
|
1
|
59 |
then obtain sobj where sobj: "co2sobj s obj = Some sobj"
|
|
60 |
using vs alive_has_sobj by blast
|
|
61 |
from undel vs have "\<not> deleted obj s" and init_alive: "init_alive obj"
|
|
62 |
by (auto simp:undeletable_def)
|
|
63 |
with vs sobj have "init_obj_related sobj obj"
|
|
64 |
apply (case_tac obj, case_tac [!] sobj)
|
19
|
65 |
apply (auto split:option.splits if_splits simp:cp2sproc_def ch2sshm_def cq2smsgq_def cm2smsg_def delq_imp_delqm)
|
|
66 |
apply (frule not_deleted_init_file, simp+) (*
|
|
67 |
apply (drule is_file_has_sfile, erule exE)
|
1
|
68 |
apply (rule_tac x = sf in bexI)
|
|
69 |
apply (case_tac list, auto split:option.splits simp:is_init_file_props)[1]
|
19
|
70 |
apply (simp add:same_inode_files_def cfs2sfiles_def) *)
|
|
71 |
sorry
|
1
|
72 |
with tainted t2ts init_alive sobj static
|
|
73 |
show ?thesis unfolding taintable_s_def
|
|
74 |
apply (rule_tac x = "s2ss s" in bexI, simp)
|
|
75 |
apply (rule_tac x = "sobj" in exI, auto)
|
|
76 |
done
|
|
77 |
qed
|
|
78 |
|
19
|
79 |
lemma cp2sproc_pi:
|
|
80 |
"\<lbrakk>cp2sproc s p = Some (Init p', sec, fds, shms); valid s\<rbrakk> \<Longrightarrow> p = p' \<and> \<not> deleted (O_proc p) s \<and> p \<in> init_procs"
|
|
81 |
by (simp add:cp2sproc_def split:option.splits if_splits)
|
|
82 |
|
|
83 |
lemma cq2smsgq_qi:
|
|
84 |
"\<lbrakk>cq2smsgq s q = Some (Init q', sec, sms); valid s\<rbrakk> \<Longrightarrow> q = q' \<and> \<not> deleted (O_msgq q) s \<and> q \<in> init_msgqs"
|
|
85 |
by (simp add:cq2smsgq_def split:option.splits if_splits)
|
|
86 |
|
|
87 |
lemma cm2smsg_mi:
|
|
88 |
"\<lbrakk>cm2smsg s q m = Some (Init m', sec, ttag); q \<in> init_msgqs; valid s\<rbrakk>
|
|
89 |
\<Longrightarrow> m = m' \<and> \<not> deleted (O_msg q m) s \<and> m \<in> set (init_msgs_of_queue q) \<and> q \<in> init_msgqs"
|
|
90 |
by (clarsimp simp add:cm2smsg_def split:if_splits option.splits)
|
|
91 |
|
|
92 |
lemma ch2sshm_hi:
|
|
93 |
"\<lbrakk>ch2sshm s h = Some (Init h', sec); valid s\<rbrakk> \<Longrightarrow> h = h' \<and> \<not> deleted (O_shm h) s \<and> h \<in> init_shms"
|
|
94 |
by (clarsimp simp:ch2sshm_def split:if_splits option.splits)
|
|
95 |
|
|
96 |
lemma root_not_deleted:
|
|
97 |
"\<lbrakk>deleted (O_dir []) s; valid s\<rbrakk> \<Longrightarrow> False"
|
|
98 |
apply (induct s, simp)
|
|
99 |
apply (frule vd_cons, frule vt_grant_os, case_tac a, auto)
|
|
100 |
done
|
|
101 |
|
|
102 |
lemma cf2sfile_fi:
|
|
103 |
"\<lbrakk>cf2sfile s f = Some (Init f', sec, psecopt, asecs); valid s\<rbrakk> \<Longrightarrow> f = f' \<and>
|
|
104 |
(if (is_file s f) then \<not> deleted (O_file f) s \<and> is_init_file f
|
|
105 |
else \<not> deleted (O_dir f) s \<and> is_init_dir f)"
|
|
106 |
apply (case_tac f)
|
|
107 |
by (auto simp:sroot_def cf2sfile_def root_is_init_dir dest!:root_is_dir' root_not_deleted
|
|
108 |
split:if_splits option.splits)
|
|
109 |
|
1
|
110 |
lemma init_deled_imp_deled_s:
|
|
111 |
"\<lbrakk>deleted obj s; init_alive obj; sobj \<in> (s2ss s); valid s\<rbrakk> \<Longrightarrow> \<not> init_obj_related sobj obj"
|
19
|
112 |
apply (rule notI)
|
|
113 |
apply (clarsimp simp:s2ss_def)
|
|
114 |
apply (case_tac obj, case_tac [!] obja, case_tac sobj)
|
20
|
115 |
apply (auto split:option.splits if_splits dest!:cp2sproc_pi cq2smsgq_qi ch2sshm_hi cm2smsg_mi cf2sfile_fi)
|
|
116 |
apply (auto simp:cf2sfiles_def same_inode_files_def has_same_inode_prop1' is_file_def is_dir_def
|
|
117 |
split:option.splits t_inode_tag.splits dest!:cf2sfile_fi)
|
19
|
118 |
done
|
1
|
119 |
|
|
120 |
lemma deleted_imp_deletable_s:
|
|
121 |
"\<lbrakk>deleted obj s; init_alive obj; valid s\<rbrakk> \<Longrightarrow> deletable_s obj"
|
|
122 |
apply (simp add:deletable_s_def)
|
|
123 |
apply (rule_tac x = "s2ss s" in bexI)
|
|
124 |
apply (clarify, simp add:init_deled_imp_deled_s)
|
|
125 |
apply (erule d2s_main)
|
|
126 |
done
|
|
127 |
|
|
128 |
theorem undeletable_s_complete:
|
|
129 |
assumes undel_s: "undeletable_s obj"
|
|
130 |
shows "undeletable obj"
|
|
131 |
proof-
|
|
132 |
from undel_s have init_alive: "init_alive obj"
|
|
133 |
and alive_s: "\<forall> ss \<in> static. \<exists> sobj \<in> ss. init_obj_related sobj obj"
|
|
134 |
using undeletable_s_def by auto
|
|
135 |
have "\<not> (\<exists> s. valid s \<and> deleted obj s)"
|
|
136 |
proof
|
|
137 |
assume "\<exists> s. valid s \<and> deleted obj s"
|
|
138 |
then obtain s where vs: "valid s" and del: "deleted obj s" by auto
|
|
139 |
from vs have vss: "s2ss s \<in> static" by (rule d2s_main)
|
|
140 |
with alive_s obtain sobj where in_ss: "sobj \<in> (s2ss s)"
|
|
141 |
and related: "init_obj_related sobj obj" by auto
|
|
142 |
from init_alive del vs have "deletable_s obj"
|
|
143 |
by (auto elim:deleted_imp_deletable_s)
|
|
144 |
with alive_s
|
|
145 |
show False by (auto simp:deletable_s_def)
|
|
146 |
qed
|
|
147 |
with init_alive show ?thesis
|
|
148 |
by (simp add:undeletable_def)
|
|
149 |
qed
|
|
150 |
|
|
151 |
theorem final_offer:
|
|
152 |
"\<lbrakk>undeletable_s obj; \<not> taintable_s obj; init_alive obj\<rbrakk> \<Longrightarrow> \<not> taintable obj"
|
|
153 |
apply (erule swap)
|
|
154 |
by (simp add:static_complete undeletable_s_complete)
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
(************** static \<rightarrow> dynamic ***************)
|
|
159 |
|
|
160 |
lemma created_can_have_many:
|
|
161 |
"\<lbrakk>valid s; alive s obj; \<not> init_alive obj\<rbrakk> \<Longrightarrow> \<exists> s'. valid s' \<and> alive s' obj \<and> alive s' obj' \<and> s2ss s = s2ss s'"
|
|
162 |
sorry
|
|
163 |
|
|
164 |
lemma s2d_main:
|
|
165 |
"ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
|
|
166 |
apply (erule static.induct)
|
|
167 |
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
|
|
168 |
|
|
169 |
apply (erule exE|erule conjE)+
|
|
170 |
|
20
|
171 |
sorry
|
|
172 |
|
|
173 |
lemma tainted_s_in_ss:
|
|
174 |
"tainted_s ss sobj \<Longrightarrow> sobj \<in> ss"
|
|
175 |
apply (case_tac sobj, simp_all)
|
|
176 |
apply (case_tac bool, simp+)
|
|
177 |
apply (case_tac bool, simp+)
|
|
178 |
apply (case_tac prod1, case_tac prod2, simp)
|
|
179 |
thm tainted_s.simps
|
|
180 |
oops
|
|
181 |
|
|
182 |
lemma set_eq_D:
|
|
183 |
"\<lbrakk>x \<in> S; {x. P x} = S\<rbrakk> \<Longrightarrow> P x"
|
|
184 |
by auto
|
|
185 |
|
|
186 |
lemma cqm2sms_prop1:
|
|
187 |
"\<lbrakk>cqm2sms s q queue = Some sms; sm \<in> set sms\<rbrakk> \<Longrightarrow> \<exists> m. cm2smsg s q m = Some sm"
|
|
188 |
apply (induct queue arbitrary:sms)
|
|
189 |
apply (auto split:option.splits)
|
|
190 |
done
|
1
|
191 |
|
20
|
192 |
lemma sq_sm_prop:
|
|
193 |
"\<lbrakk>sm \<in> set sms; cq2smsgq s q = Some (qi, qsec, sms); valid s\<rbrakk>
|
|
194 |
\<Longrightarrow> \<exists> m. cm2smsg s q m = Some sm"
|
|
195 |
by (auto simp:cq2smsgq_def split: option.splits intro:cqm2sms_prop1)
|
|
196 |
|
|
197 |
lemma tainted_s_imp_tainted:
|
|
198 |
"\<lbrakk>tainted_s ss sobj; ss \<in> static\<rbrakk> \<Longrightarrow> \<exists> s obj. valid s \<and> co2sobj s obj = Some sobj \<and> obj \<in> tainted s"
|
|
199 |
apply (drule s2d_main)
|
|
200 |
apply (erule exE, erule conjE, simp add:s2ss_def)
|
|
201 |
apply (rule_tac x = s in exI, simp)
|
|
202 |
apply (case_tac sobj, simp_all)
|
|
203 |
apply (erule conjE, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+)
|
|
204 |
apply (rule_tac x = obj in exI, simp)
|
|
205 |
apply (case_tac obj, (simp split:option.splits if_splits)+)
|
|
206 |
|
|
207 |
apply (erule conjE, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+)
|
|
208 |
apply (rule_tac x = obj in exI, simp)
|
|
209 |
apply (case_tac obj, (simp split:option.splits if_splits)+)
|
|
210 |
|
|
211 |
apply (case_tac prod1, case_tac prod2, simp)
|
|
212 |
apply ((erule conjE)+, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+)
|
|
213 |
apply (case_tac obj, simp_all split:option.splits if_splits)
|
|
214 |
apply (drule_tac sm = "(aa, ba, True)" in sq_sm_prop, simp+, erule exE)
|
|
215 |
apply (rule_tac x = "O_msg nat m" in exI)
|
|
216 |
apply (simp)
|
|
217 |
|
|
218 |
apply (case_tac obj, (simp split:option.splits if_splits)+)
|
|
219 |
apply (erule conjE, drule_tac )
|
1
|
220 |
|
|
221 |
|
|
222 |
|
20
|
223 |
lemma has_inode_tainted_aux:
|
|
224 |
"O_file f \<in> tainted s \<Longrightarrow> \<forall> f'. has_same_inode s f f' \<longrightarrow> O_file f' \<in> tainted s"
|
|
225 |
apply (erule tainted.induct)
|
|
226 |
apply (auto intro:tainted.intros simp:has_same_inode_def)
|
|
227 |
(*?? need simpset for tainted *)
|
1
|
228 |
sorry
|
|
229 |
|
20
|
230 |
lemma has_same_inode_tainted:
|
|
231 |
"\<lbrakk>has_same_inode s f f'; O_file f' \<in> tainted s\<rbrakk> \<Longrightarrow> O_file f \<in> tainted s"
|
|
232 |
by (drule has_inode_tainted_aux, auto simp:has_same_inode_def)
|
1
|
233 |
|
|
234 |
theorem static_sound:
|
|
235 |
assumes tbl_s: "taintable_s obj"
|
|
236 |
shows "taintable obj"
|
|
237 |
proof-
|
|
238 |
from tbl_s obtain ss sobj where static: "ss \<in> static"
|
|
239 |
and sobj: "tainted_s ss sobj" and related: "init_obj_related sobj obj"
|
|
240 |
and init_alive: "init_alive obj" by (auto simp:taintable_s_def)
|
|
241 |
from static sobj tainted_s_imp_tainted
|
20
|
242 |
obtain s obj' where co2sobj: "co2sobj s obj' = Some sobj"
|
|
243 |
and tainted': "obj' \<in> tainted s" and vs: "valid s" by blast
|
1
|
244 |
|
20
|
245 |
from co2sobj related vs
|
|
246 |
have eq:"obj = obj' \<or> (\<exists> f f'. obj = O_file f \<and> obj' = O_file f' \<and> has_same_inode s f f')"
|
|
247 |
apply (case_tac obj', case_tac [!] obj)
|
|
248 |
apply (auto split:option.splits if_splits dest!:cp2sproc_pi cq2smsgq_qi ch2sshm_hi cm2smsg_mi cf2sfile_fi)
|
|
249 |
apply (auto simp:cf2sfiles_def same_inode_files_def has_same_inode_def is_file_def is_dir_def
|
|
250 |
split:option.splits t_inode_tag.splits dest!:cf2sfile_fi)
|
|
251 |
done
|
|
252 |
with tainted' have tainted: "obj \<in> tainted s"
|
|
253 |
by (auto intro:has_same_inode_tainted)
|
|
254 |
with vs init_alive
|
1
|
255 |
show ?thesis by (auto simp:taintable_def)
|
|
256 |
qed
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
lemma ts2t:
|
|
261 |
"obj \<in> tainted_s ss \<Longrightarrow> \<exists> s. obj \<in> tainted s"
|
|
262 |
"obj \<in> tainted_s ss \<Longrightarrow> \<exists> so. so True \<in> ss \<Longrightarrow> so True \<in> ss \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss \<Longrightarrow> so True \<in> s2ss s \<Longrightarrow> tainted s obj. "
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
end |