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)
+ − 115
apply (auto split:option.splits if_splits dest!:cp2sproc_pi cq2smsgq_qi ch2sshm_hi cm2smsg_mi)
+ − 116
+ − 117
done
1
+ − 118
+ − 119
lemma deleted_imp_deletable_s:
+ − 120
"\<lbrakk>deleted obj s; init_alive obj; valid s\<rbrakk> \<Longrightarrow> deletable_s obj"
+ − 121
apply (simp add:deletable_s_def)
+ − 122
apply (rule_tac x = "s2ss s" in bexI)
+ − 123
apply (clarify, simp add:init_deled_imp_deled_s)
+ − 124
apply (erule d2s_main)
+ − 125
done
+ − 126
+ − 127
theorem undeletable_s_complete:
+ − 128
assumes undel_s: "undeletable_s obj"
+ − 129
shows "undeletable obj"
+ − 130
proof-
+ − 131
from undel_s have init_alive: "init_alive obj"
+ − 132
and alive_s: "\<forall> ss \<in> static. \<exists> sobj \<in> ss. init_obj_related sobj obj"
+ − 133
using undeletable_s_def by auto
+ − 134
have "\<not> (\<exists> s. valid s \<and> deleted obj s)"
+ − 135
proof
+ − 136
assume "\<exists> s. valid s \<and> deleted obj s"
+ − 137
then obtain s where vs: "valid s" and del: "deleted obj s" by auto
+ − 138
from vs have vss: "s2ss s \<in> static" by (rule d2s_main)
+ − 139
with alive_s obtain sobj where in_ss: "sobj \<in> (s2ss s)"
+ − 140
and related: "init_obj_related sobj obj" by auto
+ − 141
from init_alive del vs have "deletable_s obj"
+ − 142
by (auto elim:deleted_imp_deletable_s)
+ − 143
with alive_s
+ − 144
show False by (auto simp:deletable_s_def)
+ − 145
qed
+ − 146
with init_alive show ?thesis
+ − 147
by (simp add:undeletable_def)
+ − 148
qed
+ − 149
+ − 150
theorem final_offer:
+ − 151
"\<lbrakk>undeletable_s obj; \<not> taintable_s obj; init_alive obj\<rbrakk> \<Longrightarrow> \<not> taintable obj"
+ − 152
apply (erule swap)
+ − 153
by (simp add:static_complete undeletable_s_complete)
+ − 154
+ − 155
+ − 156
+ − 157
(************** static \<rightarrow> dynamic ***************)
+ − 158
+ − 159
lemma created_can_have_many:
+ − 160
"\<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'"
+ − 161
sorry
+ − 162
+ − 163
lemma s2d_main:
+ − 164
"ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
+ − 165
apply (erule static.induct)
+ − 166
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
+ − 167
+ − 168
apply (erule exE|erule conjE)+
+ − 169
+ − 170
apply (erule exE, erule conjE)+
+ − 171
+ − 172
sorry
+ − 173
+ − 174
+ − 175
+ − 176
lemma tainted_s_imp_tainted:
+ − 177
"\<lbrakk>tainted_s ss sobj; ss \<in> static\<rbrakk> \<Longrightarrow> \<exists> obj s. s2ss s = ss \<and> valid s \<and> co2sobj s obj = Some sobj \<and> obj \<in> tainted s"
+ − 178
sorry
+ − 179
+ − 180
+ − 181
theorem static_sound:
+ − 182
assumes tbl_s: "taintable_s obj"
+ − 183
shows "taintable obj"
+ − 184
proof-
+ − 185
from tbl_s obtain ss sobj where static: "ss \<in> static"
+ − 186
and sobj: "tainted_s ss sobj" and related: "init_obj_related sobj obj"
+ − 187
and init_alive: "init_alive obj" by (auto simp:taintable_s_def)
+ − 188
from static sobj tainted_s_imp_tainted
+ − 189
obtain s obj' where s2ss: "s2ss s = ss" and co2sobj: "co2sobj s obj' = Some sobj"
+ − 190
and tainted: "obj' \<in> tainted s" and vs: "valid s" by blast
+ − 191
+ − 192
from co2sobj related
+ − 193
have eq:"obj = obj'"
+ − 194
apply (case_tac obj', case_tac [!] obj, case_tac [!] sobj)
+ − 195
apply auto
+ − 196
apply (auto split:option.splits if_splits)
+ − 197
apply (case_tac a, simp+)
+ − 198
apply (simp add:cp2sproc_def split:option.splits if_splits)
+ − 199
apply simp
+ − 200
sorry
+ − 201
with tainted vs init_alive
+ − 202
show ?thesis by (auto simp:taintable_def)
+ − 203
qed
+ − 204
+ − 205
+ − 206
+ − 207
lemma ts2t:
+ − 208
"obj \<in> tainted_s ss \<Longrightarrow> \<exists> s. obj \<in> tainted s"
+ − 209
"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. "
+ − 210
+ − 211
+ − 212
+ − 213
+ − 214
end