77
|
1 |
theory Enrich
|
|
2 |
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
|
|
3 |
Temp
|
|
4 |
begin
|
|
5 |
|
78
|
6 |
datatype t_enrich_obj =
|
|
7 |
E_proc "t_process"
|
|
8 |
| E_file "t_file"
|
|
9 |
| E_fd "t_process" "t_fd"
|
|
10 |
| E_inum "nat"
|
|
11 |
| E_msgq "t_msgq"
|
|
12 |
| E_msg "t_msgq" "t_msg"
|
|
13 |
|
77
|
14 |
context tainting_s begin
|
|
15 |
|
|
16 |
(* enrich s target_proc duplicated_pro *)
|
|
17 |
fun enrich_proc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process \<Rightarrow> t_state"
|
|
18 |
where
|
|
19 |
"enrich_proc [] tp dp = []"
|
|
20 |
| "enrich_proc (Execve p f fds # s) tp dp = (
|
|
21 |
if (tp = p)
|
|
22 |
then Execve dp f (fds \<inter> proc_file_fds s p) # Execve p f fds # (enrich_proc s tp dp)
|
|
23 |
else Execve p f fds # (enrich_proc s tp dp))"
|
|
24 |
| "enrich_proc (Clone p p' fds # s) tp dp = (
|
|
25 |
if (tp = p')
|
|
26 |
then Clone p dp (fds \<inter> proc_file_fds s p) # Clone p p' fds # s
|
|
27 |
else Clone p p' fds # (enrich_proc s tp dp))"
|
|
28 |
| "enrich_proc (Open p f flags fd opt # s) tp dp = (
|
|
29 |
if (tp = p)
|
|
30 |
then Open dp f (remove_create_flag flags) fd opt # Open p f flags fd opt # (enrich_proc s tp dp)
|
|
31 |
else Open p f flags fd opt # (enrich_proc s tp dp))"
|
|
32 |
| "enrich_proc (CloseFd p fd # s) tp dp = (
|
80
|
33 |
if (tp = p \<and> fd \<in> proc_file_fds s p)
|
77
|
34 |
then CloseFd dp fd # CloseFd p fd # (enrich_proc s tp dp)
|
|
35 |
else CloseFd p fd # (enrich_proc s tp dp))"
|
|
36 |
(*
|
|
37 |
| "enrich_proc (Attach p h flag # s) tp dp = (
|
|
38 |
if (tp = p)
|
|
39 |
then Attach dp h flag # Attach p h flag # (enrich_proc s tp dp)
|
|
40 |
else Attach p h flag # (enrich_proc s tp dp))"
|
|
41 |
| "enrich_proc (Detach p h # s) tp dp = (
|
|
42 |
if (tp = p)
|
|
43 |
then Detach dp h # Detach p h # (enrich_proc s tp dp)
|
|
44 |
else Detach p h # (enrich_proc s tp dp))"
|
|
45 |
*)
|
|
46 |
| "enrich_proc (Kill p p' # s) tp dp = (
|
79
|
47 |
if (tp = p') then Kill p p' # s
|
77
|
48 |
else Kill p p' # (enrich_proc s tp dp))"
|
|
49 |
| "enrich_proc (Exit p # s) tp dp = (
|
|
50 |
if (tp = p) then Exit p # s
|
|
51 |
else Exit p # (enrich_proc s tp dp))"
|
|
52 |
| "enrich_proc (e # s) tp dp = e # (enrich_proc s tp dp)"
|
|
53 |
|
|
54 |
lemma enrich_search_check:
|
|
55 |
assumes grant: "search_check s (up, rp, tp) f"
|
|
56 |
and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f"
|
|
57 |
and vd: "valid s" and f_in: "is_file s f" and f_in': "is_file s' f"
|
|
58 |
and sec: "sectxt_of_obj s' (O_file f) = sectxt_of_obj s (O_file f)"
|
|
59 |
shows "search_check s' (up, rp, tp) f"
|
|
60 |
proof (cases f)
|
|
61 |
case Nil
|
|
62 |
with f_in vd have "False"
|
|
63 |
by (auto dest:root_is_dir')
|
|
64 |
thus ?thesis by simp
|
|
65 |
next
|
|
66 |
case (Cons n pf)
|
|
67 |
from vd f_in obtain sf where sf: "cf2sfile s f = Some sf"
|
|
68 |
apply (drule_tac is_file_in_current, drule_tac current_file_has_sfile, simp)
|
|
69 |
apply (erule exE, simp)
|
|
70 |
done
|
|
71 |
then obtain psfs where psfs: "get_parentfs_ctxts s pf = Some psfs" using Cons
|
|
72 |
by (auto simp:cf2sfile_def split:option.splits if_splits)
|
|
73 |
from sf cf2sf f_in have sf': "cf2sfile s' f = Some sf" by (auto dest:is_file_in_current)
|
|
74 |
then obtain psfs' where psfs': "get_parentfs_ctxts s' pf = Some psfs'"using Cons
|
|
75 |
by (auto simp:cf2sfile_def split:option.splits if_splits)
|
|
76 |
with sf sf' psfs have psfs_eq: "set psfs' = set psfs" using Cons f_in f_in'
|
|
77 |
apply (simp add:cf2sfile_def split:option.splits)
|
|
78 |
apply (case_tac sf, simp)
|
|
79 |
done
|
|
80 |
show ?thesis using grant f_in f_in' psfs psfs' psfs_eq sec
|
|
81 |
apply (simp add:Cons split:option.splits)
|
|
82 |
by (case_tac a, simp)
|
|
83 |
qed
|
|
84 |
|
78
|
85 |
lemma enrich_search_check':
|
|
86 |
assumes grant: "search_check s (up, rp, tp) f"
|
|
87 |
and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f"
|
|
88 |
and vd: "valid s" and vd': "valid s'" and f_in: "is_dir s f" and f_in': "is_dir s' f"
|
|
89 |
and sec: "sectxt_of_obj s' (O_dir f) = sectxt_of_obj s (O_dir f)"
|
|
90 |
shows "search_check s' (up, rp, tp) f"
|
|
91 |
proof (cases f)
|
|
92 |
case Nil
|
|
93 |
have "sectxt_of_obj s' (O_dir []) = sectxt_of_obj s (O_dir [])"
|
|
94 |
using cf2sf
|
|
95 |
apply (erule_tac x = "[]" in allE)
|
|
96 |
by (auto simp:cf2sfile_def root_sec_remains vd vd')
|
|
97 |
thus ?thesis using grant Nil
|
|
98 |
by auto
|
|
99 |
next
|
|
100 |
case (Cons n pf)
|
|
101 |
from vd f_in obtain sf where sf: "cf2sfile s f = Some sf"
|
|
102 |
apply (drule_tac is_dir_in_current, drule_tac current_file_has_sfile, simp)
|
|
103 |
apply (erule exE, simp)
|
|
104 |
done
|
|
105 |
then obtain psfs where psfs: "get_parentfs_ctxts s pf = Some psfs" using Cons
|
|
106 |
by (auto simp:cf2sfile_def split:option.splits if_splits)
|
|
107 |
from sf cf2sf f_in have sf': "cf2sfile s' f = Some sf" by (auto dest:is_dir_in_current)
|
|
108 |
then obtain psfs' where psfs': "get_parentfs_ctxts s' pf = Some psfs'"using Cons
|
|
109 |
by (auto simp:cf2sfile_def split:option.splits if_splits)
|
|
110 |
with sf sf' psfs have psfs_eq: "set psfs' = set psfs" using Cons f_in f_in'
|
|
111 |
apply (drule_tac is_dir_not_file)
|
|
112 |
apply (drule is_dir_not_file)
|
|
113 |
apply (simp add:cf2sfile_def split:option.splits)
|
|
114 |
apply (case_tac sf, simp)
|
|
115 |
done
|
|
116 |
show ?thesis using grant f_in f_in' psfs psfs' psfs_eq sec
|
|
117 |
apply (drule_tac is_dir_not_file)
|
|
118 |
apply (drule_tac is_dir_not_file)
|
|
119 |
apply (simp add:Cons split:option.splits)
|
|
120 |
by (case_tac a, simp)
|
|
121 |
qed
|
|
122 |
|
77
|
123 |
lemma proc_filefd_has_sfd: "\<lbrakk>fd \<in> proc_file_fds s p; valid s\<rbrakk> \<Longrightarrow> \<exists> sfd. cfd2sfd s p fd = Some sfd"
|
|
124 |
apply (simp add:proc_file_fds_def)
|
|
125 |
apply (auto dest: current_filefd_has_sfd)
|
|
126 |
done
|
|
127 |
|
|
128 |
lemma enrich_inherit_fds_check:
|
|
129 |
assumes grant: "inherit_fds_check s (up, nr, nt) p fds" and vd: "valid s"
|
|
130 |
and cfd2sfd: "\<forall> p fd. fd \<in> proc_file_fds s p\<longrightarrow> cfd2sfd s' p fd = cfd2sfd s p fd"
|
|
131 |
and fd_in: "fds \<subseteq> proc_file_fds s p" and fd_in': "fds \<subseteq> proc_file_fds s' p"
|
|
132 |
shows "inherit_fds_check s' (up, nr, nt) p fds"
|
|
133 |
proof-
|
|
134 |
have "\<And> fd. fd \<in> fds \<Longrightarrow> sectxt_of_obj s' (O_fd p fd) = sectxt_of_obj s (O_fd p fd)"
|
|
135 |
proof-
|
|
136 |
fix fd
|
|
137 |
assume fd_in_fds: "fd \<in> fds"
|
|
138 |
hence fd_in_cfds: "fd \<in> proc_file_fds s p"
|
|
139 |
and fd_in_cfds': "fd \<in> proc_file_fds s' p"
|
|
140 |
using fd_in fd_in' by auto
|
|
141 |
with cfd2sfd
|
|
142 |
have cfd_eq: "cfd2sfd s' p fd = cfd2sfd s p fd" by auto
|
|
143 |
from fd_in_cfds obtain f where ffd: "file_of_proc_fd s p fd = Some f"
|
|
144 |
by (auto simp:proc_file_fds_def)
|
|
145 |
moreover have "flags_of_proc_fd s p fd \<noteq> None"
|
|
146 |
using ffd vd by (auto dest:current_filefd_has_flags)
|
|
147 |
moreover have "sectxt_of_obj s (O_fd p fd) \<noteq> None"
|
|
148 |
using fd_in_cfds vd
|
|
149 |
apply (rule_tac notI)
|
|
150 |
by (auto dest!:current_has_sec' file_fds_subset_pfds[where p = p] intro:vd)
|
|
151 |
moreover have "cf2sfile s f \<noteq> None"
|
|
152 |
apply (rule notI)
|
|
153 |
apply (drule current_file_has_sfile')
|
|
154 |
using ffd
|
|
155 |
by (auto simp:vd is_file_in_current dest:file_of_pfd_is_file)
|
|
156 |
ultimately show "sectxt_of_obj s' (O_fd p fd) = sectxt_of_obj s (O_fd p fd)"
|
|
157 |
using cfd_eq
|
|
158 |
by (auto simp:cfd2sfd_def split:option.splits)
|
|
159 |
qed
|
|
160 |
hence "sectxts_of_fds s' p fds = sectxts_of_fds s p fds"
|
|
161 |
by (simp add:sectxts_of_fds_def)
|
|
162 |
thus ?thesis using grant
|
|
163 |
by (simp add:inherit_fds_check_def)
|
|
164 |
qed
|
|
165 |
|
80
|
166 |
|
|
167 |
lemma enrich_inherit_fds_check_dup:
|
|
168 |
assumes grant: "inherit_fds_check s (up, nr, nt) p fds" and vd: "valid s"
|
|
169 |
and cfd2sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd s' p' fd = cfd2sfd s p fd"
|
|
170 |
and fd_in: "fds' \<subseteq> fds \<inter> proc_file_fds s p"
|
|
171 |
shows "inherit_fds_check s' (up, nr, nt) p' fds'"
|
|
172 |
proof-
|
|
173 |
have "sectxts_of_fds s' p' fds' \<subseteq> sectxts_of_fds s p fds"
|
|
174 |
proof-
|
|
175 |
have "\<And> fd sfd. \<lbrakk>fd \<in> fds'; sectxt_of_obj s' (O_fd p' fd) = Some sfd\<rbrakk>
|
|
176 |
\<Longrightarrow> \<exists> fd \<in> fds. sectxt_of_obj s (O_fd p fd) = Some sfd"
|
|
177 |
proof-
|
|
178 |
fix fd sfd
|
|
179 |
assume fd_in_fds': "fd \<in> fds'"
|
|
180 |
and sec: "sectxt_of_obj s' (O_fd p' fd) = Some sfd"
|
|
181 |
from fd_in_fds' fd_in
|
|
182 |
have fd_in_fds: "fd \<in> fds" and fd_in_cfds: "fd \<in> proc_file_fds s p"
|
|
183 |
by auto
|
|
184 |
from fd_in_cfds obtain f where ffd: "file_of_proc_fd s p fd = Some f"
|
|
185 |
by (auto simp:proc_file_fds_def)
|
|
186 |
moreover have "flags_of_proc_fd s p fd \<noteq> None"
|
|
187 |
using ffd vd by (auto dest:current_filefd_has_flags)
|
|
188 |
moreover have "cf2sfile s f \<noteq> None"
|
|
189 |
apply (rule notI)
|
|
190 |
apply (drule current_file_has_sfile')
|
|
191 |
using ffd
|
|
192 |
by (auto simp:vd is_file_in_current dest:file_of_pfd_is_file)
|
|
193 |
moreover have "sectxt_of_obj s (O_fd p fd) \<noteq> None"
|
|
194 |
using fd_in_cfds vd
|
|
195 |
apply (rule_tac notI)
|
|
196 |
by (auto dest!:current_has_sec' file_fds_subset_pfds[where p = p] intro:vd)
|
|
197 |
ultimately
|
|
198 |
have "sectxt_of_obj s (O_fd p fd) = Some sfd"
|
|
199 |
using fd_in_cfds cfd2sfd sec
|
|
200 |
apply (erule_tac x = fd in allE)
|
|
201 |
apply (auto simp:cfd2sfd_def split:option.splits)
|
|
202 |
done
|
|
203 |
thus "\<exists> fd \<in> fds. sectxt_of_obj s (O_fd p fd) = Some sfd"
|
|
204 |
using fd_in_fds
|
|
205 |
by (rule_tac x = fd in bexI, auto)
|
|
206 |
qed
|
|
207 |
thus ?thesis by (auto simp:sectxts_of_fds_def)
|
|
208 |
qed
|
|
209 |
thus ?thesis using grant
|
|
210 |
by (auto simp:inherit_fds_check_def inherit_fds_check_ctxt_def)
|
|
211 |
qed
|
|
212 |
|
77
|
213 |
lemma not_all_procs_cons:
|
|
214 |
"p \<notin> all_procs (e # s) \<Longrightarrow> p \<notin> all_procs s"
|
|
215 |
by (case_tac e, auto)
|
|
216 |
|
|
217 |
lemma not_all_procs_prop:
|
|
218 |
"\<lbrakk>p' \<notin> all_procs s; p \<in> current_procs s; valid s\<rbrakk> \<Longrightarrow> p' \<noteq> p"
|
|
219 |
apply (induct s, rule notI, simp)
|
|
220 |
apply (frule vt_grant_os, frule vd_cons, frule not_all_procs_cons, simp, rule notI)
|
|
221 |
apply (case_tac a, auto)
|
|
222 |
done
|
|
223 |
|
78
|
224 |
fun enrich_not_alive :: "t_state \<Rightarrow> t_enrich_obj \<Rightarrow> bool"
|
77
|
225 |
where
|
78
|
226 |
"enrich_not_alive s (E_file f) = (f \<notin> current_files s)"
|
|
227 |
| "enrich_not_alive s (E_proc p) = (p \<notin> current_procs s)"
|
|
228 |
| "enrich_not_alive s (E_fd p fd) = (p \<in> current_procs s \<longrightarrow> fd \<notin> current_proc_fds s p)"
|
|
229 |
| "enrich_not_alive s (E_msgq q) = (q \<notin> current_msgqs s)"
|
|
230 |
| "enrich_not_alive s (E_inum i) = (i \<notin> current_inode_nums s)"
|
|
231 |
| "enrich_not_alive s (E_msg q m) = (q \<in> current_msgqs s \<longrightarrow> m \<notin> set (msgs_of_queue s q))"
|
|
232 |
|
|
233 |
lemma file_has_parent: "\<lbrakk>is_file s f; valid s\<rbrakk> \<Longrightarrow> \<exists> pf. is_dir s pf \<and> parent f = Some pf"
|
|
234 |
apply (case_tac f)
|
|
235 |
apply (simp, drule root_is_dir', simp+)
|
|
236 |
apply (simp add:parentf_is_dir_prop2)
|
|
237 |
done
|
77
|
238 |
|
|
239 |
lemma enrich_valid_intro_cons:
|
|
240 |
assumes vs': "valid s'"
|
|
241 |
and os: "os_grant s e" and grant: "grant s e" and vd: "valid s"
|
|
242 |
and alive: "\<forall> obj. alive s obj \<longrightarrow> alive s' obj"
|
|
243 |
and alive': "\<forall> obj. enrich_not_alive s obj \<longrightarrow> enrich_not_alive s' obj"
|
78
|
244 |
and hungs: "files_hung_by_del s' = files_hung_by_del s"
|
77
|
245 |
and cp2sp: "\<forall> p. p \<in> current_procs s \<longrightarrow> cp2sproc s' p = cp2sproc s p"
|
|
246 |
and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f"
|
78
|
247 |
and cq2sq: "\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq s' q = cq2smsgq s q"
|
77
|
248 |
and ffd_remain: "\<forall> p fd f. file_of_proc_fd s p fd = Some f \<longrightarrow> file_of_proc_fd s' p fd = Some f"
|
78
|
249 |
and fflags_remain: "\<forall> p fd flags. flags_of_proc_fd s p fd = Some flags \<longrightarrow> flags_of_proc_fd s' p fd = Some flags"
|
|
250 |
and sms_remain: "\<forall> q. msgs_of_queue s' q = msgs_of_queue s q"
|
|
251 |
(* and empty_remain: "\<forall> f. dir_is_empty s f \<longrightarrow> dir_is_empty s' f" *)
|
77
|
252 |
and cfd2sfd: "\<forall> p fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd s' p fd = cfd2sfd s p fd"
|
|
253 |
shows "valid (e # s')"
|
|
254 |
proof (cases e)
|
|
255 |
case (Execve p f fds)
|
|
256 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
257 |
apply (erule_tac x = "O_proc p" in allE)
|
|
258 |
by (auto simp:Execve)
|
|
259 |
have f_in: "is_file s' f" using os alive
|
|
260 |
apply (erule_tac x = "O_file f" in allE)
|
|
261 |
by (auto simp:Execve)
|
|
262 |
have fd_in: "fds \<subseteq> proc_file_fds s' p" using os alive ffd_remain
|
|
263 |
by (auto simp:Execve proc_file_fds_def)
|
|
264 |
have "os_grant s' e" using p_in f_in fd_in by (simp add:Execve)
|
|
265 |
moreover have "grant s' e"
|
|
266 |
proof-
|
|
267 |
from grant obtain up rp tp uf rf tf
|
|
268 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
269 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
270 |
by (simp add:Execve split:option.splits, blast)
|
|
271 |
with grant obtain pu nr nt where p3: "npctxt_execve (up, rp, tp) (uf, rf, tf) = Some (pu, nr, nt)"
|
|
272 |
by (simp add:Execve split:option.splits del:npctxt_execve.simps, blast)
|
|
273 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
274 |
using os cp2sp
|
|
275 |
apply (erule_tac x = p in allE)
|
|
276 |
by (auto simp:Execve co2sobj.simps cp2sproc_def split:option.splits)
|
|
277 |
from os have f_in': "is_file s f" by (simp add:Execve)
|
|
278 |
from vd os have "\<exists> sf. cf2sfile s f = Some sf"
|
|
279 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:Execve)
|
|
280 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf
|
|
281 |
apply (erule_tac x = f in allE)
|
|
282 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
|
|
283 |
apply (case_tac f, simp)
|
|
284 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
|
|
285 |
done
|
|
286 |
have "inherit_fds_check s' (pu, nr, nt) p fds"
|
|
287 |
proof-
|
|
288 |
have "fds \<subseteq> proc_file_fds s' p" using os ffd_remain Execve
|
|
289 |
by (auto simp:proc_file_fds_def)
|
|
290 |
thus ?thesis using Execve grant vd cfd2sfd p1 p2 p3 os
|
|
291 |
apply (rule_tac s = s in enrich_inherit_fds_check)
|
|
292 |
by (simp_all split:option.splits)
|
|
293 |
qed
|
|
294 |
moreover have "search_check s' (pu, rp, tp) f"
|
|
295 |
using p1 p2 p2' vd cf2sf f_in' grant Execve p3 f_in
|
|
296 |
apply (rule_tac s = s in enrich_search_check)
|
|
297 |
by (simp_all split:option.splits)
|
|
298 |
ultimately show ?thesis using p1' p2' p3
|
|
299 |
apply (simp add:Execve split:option.splits)
|
|
300 |
using grant Execve p1 p2
|
|
301 |
by (simp add:Execve grant p1 p2)
|
|
302 |
qed
|
|
303 |
ultimately show ?thesis using vs'
|
|
304 |
by (erule_tac valid.intros(2), simp+)
|
|
305 |
next
|
|
306 |
case (Clone p p' fds)
|
|
307 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
308 |
apply (erule_tac x = "O_proc p" in allE)
|
|
309 |
by (auto simp:Clone)
|
|
310 |
have p'_not_in: "p' \<notin> current_procs s'" using os alive'
|
78
|
311 |
apply (erule_tac x = "E_proc p'" in allE)
|
77
|
312 |
by (auto simp:Clone)
|
|
313 |
have fd_in: "fds \<subseteq> proc_file_fds s' p" using os alive ffd_remain
|
|
314 |
by (auto simp:Clone proc_file_fds_def)
|
|
315 |
have "os_grant s' e" using p_in p'_not_in fd_in by (simp add:Clone)
|
|
316 |
moreover have "grant s' e"
|
|
317 |
proof-
|
|
318 |
from grant obtain up rp tp
|
|
319 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
320 |
apply (simp add:Clone split:option.splits)
|
|
321 |
by (case_tac a, auto)
|
|
322 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
323 |
using os cp2sp
|
|
324 |
apply (erule_tac x = p in allE)
|
|
325 |
by (auto simp:Clone co2sobj.simps cp2sproc_def split:option.splits)
|
|
326 |
have p2: "inherit_fds_check s' (up, rp, tp) p fds"
|
|
327 |
proof-
|
|
328 |
have "fds \<subseteq> proc_file_fds s' p" using os ffd_remain Clone
|
|
329 |
by (auto simp:proc_file_fds_def)
|
|
330 |
thus ?thesis using Clone grant vd cfd2sfd p1 os
|
|
331 |
apply (rule_tac s = s in enrich_inherit_fds_check)
|
|
332 |
by (simp_all split:option.splits)
|
|
333 |
qed
|
|
334 |
show ?thesis using p1 p2 p1' grant
|
|
335 |
by (simp add:Clone)
|
|
336 |
qed
|
|
337 |
ultimately show ?thesis using vs'
|
|
338 |
by (erule_tac valid.intros(2), simp+)
|
|
339 |
next
|
78
|
340 |
case (Kill p p')
|
|
341 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
342 |
apply (erule_tac x = "O_proc p" in allE)
|
|
343 |
by (auto simp:Kill)
|
|
344 |
have p'_in: "p' \<in> current_procs s'" using os alive
|
|
345 |
apply (erule_tac x = "O_proc p'" in allE)
|
|
346 |
by (auto simp:Kill)
|
|
347 |
have "os_grant s' e" using p_in p'_in by (simp add:Kill)
|
|
348 |
moreover have "grant s' e"
|
|
349 |
proof-
|
|
350 |
from grant obtain up rp tp up' rp' tp'
|
|
351 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
352 |
and p'1: "sectxt_of_obj s (O_proc p') = Some (up', rp', tp')"
|
|
353 |
apply (simp add:Kill split:option.splits)
|
|
354 |
by (case_tac a, case_tac aa, blast)
|
|
355 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
356 |
using os cp2sp
|
|
357 |
apply (erule_tac x = p in allE)
|
|
358 |
by (auto simp:Kill co2sobj.simps cp2sproc_def split:option.splits)
|
|
359 |
from p'1 have p'1': "sectxt_of_obj s' (O_proc p') = Some (up', rp', tp')"
|
|
360 |
using os cp2sp
|
|
361 |
apply (erule_tac x = p' in allE)
|
|
362 |
by (auto simp:Kill co2sobj.simps cp2sproc_def split:option.splits)
|
|
363 |
show ?thesis using p1 p'1 p1' p'1' grant
|
|
364 |
by (simp add:Kill)
|
|
365 |
qed
|
|
366 |
ultimately show ?thesis using vs'
|
|
367 |
by (erule_tac valid.intros(2), simp+)
|
|
368 |
next
|
|
369 |
case (Ptrace p p')
|
|
370 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
371 |
apply (erule_tac x = "O_proc p" in allE)
|
|
372 |
by (auto simp:Ptrace)
|
|
373 |
have p'_in: "p' \<in> current_procs s'" using os alive
|
|
374 |
apply (erule_tac x = "O_proc p'" in allE)
|
|
375 |
by (auto simp:Ptrace)
|
|
376 |
have "os_grant s' e" using p_in p'_in by (simp add:Ptrace)
|
|
377 |
moreover have "grant s' e"
|
|
378 |
proof-
|
|
379 |
from grant obtain up rp tp up' rp' tp'
|
|
380 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
381 |
and p'1: "sectxt_of_obj s (O_proc p') = Some (up', rp', tp')"
|
|
382 |
apply (simp add:Ptrace split:option.splits)
|
|
383 |
by (case_tac a, case_tac aa, blast)
|
|
384 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
385 |
using os cp2sp
|
|
386 |
apply (erule_tac x = p in allE)
|
|
387 |
by (auto simp:Ptrace co2sobj.simps cp2sproc_def split:option.splits)
|
|
388 |
from p'1 have p'1': "sectxt_of_obj s' (O_proc p') = Some (up', rp', tp')"
|
|
389 |
using os cp2sp
|
|
390 |
apply (erule_tac x = p' in allE)
|
|
391 |
by (auto simp:Ptrace co2sobj.simps cp2sproc_def split:option.splits)
|
|
392 |
show ?thesis using p1 p'1 p1' p'1' grant
|
|
393 |
by (simp add:Ptrace)
|
|
394 |
qed
|
|
395 |
ultimately show ?thesis using vs'
|
|
396 |
by (erule_tac valid.intros(2), simp+)
|
|
397 |
next
|
|
398 |
case (Exit p)
|
|
399 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
400 |
apply (erule_tac x = "O_proc p" in allE)
|
|
401 |
by (auto simp:Exit)
|
|
402 |
have "os_grant s' e" using p_in by (simp add:Exit)
|
|
403 |
moreover have "grant s' e"
|
|
404 |
by (simp add:Exit)
|
|
405 |
ultimately show ?thesis using vs'
|
|
406 |
by (erule_tac valid.intros(2), simp+)
|
|
407 |
next
|
|
408 |
case (Open p f flags fd opt)
|
|
409 |
show ?thesis
|
|
410 |
proof (cases opt)
|
|
411 |
case None
|
|
412 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
413 |
apply (erule_tac x = "O_proc p" in allE)
|
|
414 |
by (auto simp:Open None)
|
|
415 |
have f_in: "is_file s' f" using os alive
|
|
416 |
apply (erule_tac x = "O_file f" in allE)
|
|
417 |
by (auto simp:Open None)
|
|
418 |
have fd_not_in: "fd \<notin> current_proc_fds s' p"
|
|
419 |
using os alive' p_in
|
|
420 |
apply (erule_tac x = "E_fd p fd" in allE)
|
|
421 |
by (simp add:Open None)
|
|
422 |
have "os_grant s' e" using p_in f_in fd_not_in os
|
|
423 |
by (simp add:Open None)
|
|
424 |
moreover have "grant s' e"
|
|
425 |
proof-
|
|
426 |
from grant obtain up rp tp uf rf tf
|
|
427 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
428 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
429 |
apply (simp add:Open None split:option.splits)
|
|
430 |
by (case_tac a, case_tac aa, blast)
|
|
431 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
432 |
using os cp2sp
|
|
433 |
apply (erule_tac x = p in allE)
|
|
434 |
by (auto simp:Open None co2sobj.simps cp2sproc_def split:option.splits)
|
|
435 |
from os have f_in': "is_file s f" by (simp add:Open None)
|
|
436 |
from vd os have "\<exists> sf. cf2sfile s f = Some sf"
|
|
437 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:Open None)
|
|
438 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf
|
|
439 |
apply (erule_tac x = f in allE)
|
|
440 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
|
|
441 |
apply (case_tac f, simp)
|
|
442 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
|
|
443 |
done
|
|
444 |
have "search_check s' (up, rp, tp) f"
|
|
445 |
using p1 p2 p2' vd cf2sf f_in' grant Open None f_in
|
|
446 |
apply (rule_tac s = s in enrich_search_check)
|
|
447 |
by (simp_all split:option.splits)
|
|
448 |
thus ?thesis using p1' p2'
|
|
449 |
apply (simp add:Open None split:option.splits)
|
|
450 |
using grant Open None p1 p2
|
|
451 |
by simp
|
|
452 |
qed
|
|
453 |
ultimately show ?thesis using vs'
|
|
454 |
by (erule_tac valid.intros(2), simp+)
|
|
455 |
next
|
|
456 |
case (Some inum)
|
|
457 |
from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f = Some pf"
|
|
458 |
by (auto simp:Open Some)
|
|
459 |
have pf_in: "is_dir s' pf" using pf_in_s alive
|
|
460 |
apply (erule_tac x = "O_dir pf" in allE)
|
|
461 |
by simp
|
|
462 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
463 |
apply (erule_tac x = "O_proc p" in allE)
|
|
464 |
by (auto simp:Open Some)
|
|
465 |
have f_not_in: "f \<notin> current_files s'" using os alive'
|
|
466 |
apply (erule_tac x = "E_file f" in allE)
|
|
467 |
by (auto simp:Open Some)
|
|
468 |
have fd_not_in: "fd \<notin> current_proc_fds s' p"
|
|
469 |
using os alive' p_in
|
|
470 |
apply (erule_tac x = "E_fd p fd" in allE)
|
|
471 |
by (simp add:Open Some)
|
|
472 |
have inum_not_in: "inum \<notin> current_inode_nums s'"
|
|
473 |
using os alive'
|
|
474 |
apply (erule_tac x = "E_inum inum" in allE)
|
|
475 |
by (simp add:Open Some)
|
|
476 |
have "os_grant s' e" using p_in pf_in parent f_not_in fd_not_in inum_not_in os
|
|
477 |
by (simp add:Open Some hungs)
|
|
478 |
moreover have "grant s' e"
|
|
479 |
proof-
|
|
480 |
from grant parent obtain up rp tp uf rf tf
|
|
481 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
482 |
and p2: "sectxt_of_obj s (O_dir pf) = Some (uf, rf, tf)"
|
|
483 |
apply (simp add:Open Some split:option.splits)
|
|
484 |
by (case_tac a, case_tac aa, blast)
|
|
485 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
486 |
using os cp2sp
|
|
487 |
apply (erule_tac x = p in allE)
|
|
488 |
by (auto simp:Open Some co2sobj.simps cp2sproc_def split:option.splits)
|
|
489 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
|
|
490 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:Open Some)
|
|
491 |
hence p2': "sectxt_of_obj s' (O_dir pf) = Some (uf, rf, tf)" using p2 cf2sf pf_in pf_in_s
|
|
492 |
apply (erule_tac x = pf in allE)
|
|
493 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
|
|
494 |
apply (drule is_dir_not_file, drule is_dir_not_file)
|
|
495 |
apply (auto simp:cf2sfile_def split:option.splits)
|
|
496 |
apply (case_tac pf, simp_all)
|
|
497 |
by (simp add:sroot_def root_sec_remains vd vs')
|
|
498 |
have "search_check s' (up, rp, tp) pf"
|
|
499 |
using p1 p2 p2' vd cf2sf pf_in grant Open Some pf_in_s parent vs'
|
|
500 |
apply (rule_tac s = s in enrich_search_check')
|
|
501 |
by (simp_all split:option.splits)
|
|
502 |
thus ?thesis using p1' p2' parent
|
|
503 |
apply (simp add:Open Some split:option.splits)
|
|
504 |
using grant Open Some p1 p2
|
|
505 |
by simp
|
|
506 |
qed
|
|
507 |
ultimately show ?thesis using vs'
|
|
508 |
by (erule_tac valid.intros(2), simp+)
|
|
509 |
qed
|
|
510 |
next
|
|
511 |
case (ReadFile p fd)
|
|
512 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
513 |
apply (erule_tac x = "O_proc p" in allE)
|
|
514 |
by (auto simp:ReadFile)
|
|
515 |
have fd_in: "fd \<in> current_proc_fds s' p" using os alive
|
|
516 |
apply (erule_tac x = "O_fd p fd" in allE)
|
|
517 |
by (auto simp:ReadFile)
|
|
518 |
obtain f where ffd: "file_of_proc_fd s p fd = Some f"
|
|
519 |
using os ReadFile by auto
|
|
520 |
hence f_in_s: "is_file s f" using vd
|
|
521 |
by (auto intro:file_of_pfd_is_file)
|
|
522 |
obtain flags where fflag: "flags_of_proc_fd s p fd = Some flags"
|
|
523 |
using os ReadFile by auto
|
|
524 |
have ffd_in: "file_of_proc_fd s' p fd = Some f"
|
|
525 |
using ffd_remain ffd by auto
|
|
526 |
hence f_in: "is_file s' f" using vs'
|
|
527 |
by (auto intro:file_of_pfd_is_file)
|
|
528 |
have flags_in: "flags_of_proc_fd s' p fd = Some flags"
|
|
529 |
using fflags_remain fflag by auto
|
|
530 |
have "os_grant s' e" using p_in fd_in ffd_in flags_in fflag os f_in
|
|
531 |
by (auto simp add:ReadFile is_file_in_current)
|
|
532 |
moreover have "grant s' e"
|
|
533 |
proof-
|
|
534 |
from grant ffd obtain up rp tp uf rf tf ufd rfd tfd
|
|
535 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
536 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
537 |
and p3: "sectxt_of_obj s (O_fd p fd) = Some (ufd, rfd, tfd)"
|
|
538 |
apply (simp add:ReadFile split:option.splits)
|
|
539 |
by (case_tac a, case_tac aa, case_tac ab, blast)
|
|
540 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
541 |
using os cp2sp
|
|
542 |
apply (erule_tac x = p in allE)
|
|
543 |
by (auto simp:ReadFile co2sobj.simps cp2sproc_def split:option.splits)
|
|
544 |
from vd f_in_s have "\<exists> sf. cf2sfile s f = Some sf"
|
|
545 |
by (auto dest!:is_file_in_current current_file_has_sfile)
|
|
546 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in_s p2 cf2sf
|
|
547 |
apply (erule_tac x = f in allE)
|
|
548 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
|
|
549 |
apply (case_tac f, simp)
|
|
550 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
|
|
551 |
done
|
|
552 |
have p3': "sectxt_of_obj s' (O_fd p fd) = Some (ufd, rfd, tfd)"
|
|
553 |
using cfd2sfd ffd_in ffd p3 f_in f_in_s vd
|
|
554 |
apply (erule_tac x = p in allE)
|
|
555 |
apply (erule_tac x = fd in allE)
|
|
556 |
apply (simp add:proc_file_fds_def)
|
|
557 |
apply (auto simp:cfd2sfd_def fflag flags_in p3 split:option.splits
|
|
558 |
dest!:current_file_has_sfile' simp:is_file_in_current)
|
|
559 |
done
|
|
560 |
show ?thesis using p1' p2' p3' ffd_in ffd
|
|
561 |
apply (simp add:ReadFile split:option.splits)
|
|
562 |
using grant p1 p2 p3 ReadFile
|
|
563 |
by simp
|
|
564 |
qed
|
|
565 |
ultimately show ?thesis using vs'
|
|
566 |
by (erule_tac valid.intros(2), simp+)
|
|
567 |
next
|
|
568 |
case (WriteFile p fd)
|
|
569 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
570 |
apply (erule_tac x = "O_proc p" in allE)
|
|
571 |
by (auto simp:WriteFile)
|
|
572 |
have fd_in: "fd \<in> current_proc_fds s' p" using os alive
|
|
573 |
apply (erule_tac x = "O_fd p fd" in allE)
|
|
574 |
by (auto simp:WriteFile)
|
|
575 |
obtain f where ffd: "file_of_proc_fd s p fd = Some f"
|
|
576 |
using os WriteFile by auto
|
|
577 |
hence f_in_s: "is_file s f" using vd
|
|
578 |
by (auto intro:file_of_pfd_is_file)
|
|
579 |
obtain flags where fflag: "flags_of_proc_fd s p fd = Some flags"
|
|
580 |
using os WriteFile by auto
|
|
581 |
have ffd_in: "file_of_proc_fd s' p fd = Some f"
|
|
582 |
using ffd_remain ffd by auto
|
|
583 |
hence f_in: "is_file s' f" using vs'
|
|
584 |
by (auto intro:file_of_pfd_is_file)
|
|
585 |
have flags_in: "flags_of_proc_fd s' p fd = Some flags"
|
|
586 |
using fflags_remain fflag by auto
|
|
587 |
have "os_grant s' e" using p_in fd_in ffd_in flags_in fflag os f_in
|
|
588 |
by (auto simp add:WriteFile is_file_in_current)
|
|
589 |
moreover have "grant s' e"
|
|
590 |
proof-
|
|
591 |
from grant ffd obtain up rp tp uf rf tf ufd rfd tfd
|
|
592 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
593 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
594 |
and p3: "sectxt_of_obj s (O_fd p fd) = Some (ufd, rfd, tfd)"
|
|
595 |
apply (simp add:WriteFile split:option.splits)
|
|
596 |
by (case_tac a, case_tac aa, case_tac ab, blast)
|
|
597 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
598 |
using os cp2sp
|
|
599 |
apply (erule_tac x = p in allE)
|
|
600 |
by (auto simp:WriteFile co2sobj.simps cp2sproc_def split:option.splits)
|
|
601 |
from vd f_in_s have "\<exists> sf. cf2sfile s f = Some sf"
|
|
602 |
by (auto dest!:is_file_in_current current_file_has_sfile)
|
|
603 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in_s p2 cf2sf
|
|
604 |
apply (erule_tac x = f in allE)
|
|
605 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
|
|
606 |
apply (case_tac f, simp)
|
|
607 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
|
|
608 |
done
|
|
609 |
have p3': "sectxt_of_obj s' (O_fd p fd) = Some (ufd, rfd, tfd)"
|
|
610 |
using cfd2sfd ffd_in ffd p3 f_in f_in_s vd
|
|
611 |
apply (erule_tac x = p in allE)
|
|
612 |
apply (erule_tac x = fd in allE)
|
|
613 |
apply (simp add:proc_file_fds_def)
|
|
614 |
apply (auto simp:cfd2sfd_def fflag flags_in p3 split:option.splits
|
|
615 |
dest!:current_file_has_sfile' simp:is_file_in_current)
|
|
616 |
done
|
|
617 |
show ?thesis using p1' p2' p3' ffd_in ffd
|
|
618 |
apply (simp add:WriteFile split:option.splits)
|
|
619 |
using grant p1 p2 p3 WriteFile
|
|
620 |
by simp
|
|
621 |
qed
|
|
622 |
ultimately show ?thesis using vs'
|
|
623 |
by (erule_tac valid.intros(2), simp+)
|
|
624 |
next
|
|
625 |
case (CloseFd p fd)
|
|
626 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
627 |
apply (erule_tac x = "O_proc p" in allE)
|
|
628 |
by (auto simp:CloseFd)
|
|
629 |
have fd_in: "fd \<in> current_proc_fds s' p" using os alive
|
|
630 |
apply (erule_tac x = "O_fd p fd" in allE)
|
|
631 |
by (auto simp:CloseFd)
|
|
632 |
have "os_grant s' e" using p_in fd_in
|
|
633 |
by (auto simp add:CloseFd)
|
|
634 |
moreover have "grant s' e"
|
|
635 |
by(simp add:CloseFd)
|
|
636 |
ultimately show ?thesis using vs'
|
|
637 |
by (erule_tac valid.intros(2), simp+)
|
|
638 |
next
|
|
639 |
case (UnLink p f)
|
|
640 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
641 |
apply (erule_tac x = "O_proc p" in allE)
|
|
642 |
by (auto simp:UnLink)
|
|
643 |
have f_in: "is_file s' f" using os alive
|
|
644 |
apply (erule_tac x = "O_file f" in allE)
|
|
645 |
by (auto simp:UnLink)
|
|
646 |
from os vd obtain pf where pf_in_s: "is_dir s pf"
|
|
647 |
and parent: "parent f = Some pf"
|
|
648 |
by (auto simp:UnLink dest!:file_has_parent)
|
|
649 |
from pf_in_s alive have pf_in: "is_dir s' pf"
|
|
650 |
apply (erule_tac x = "O_dir pf" in allE)
|
|
651 |
by (auto simp:UnLink)
|
|
652 |
have "os_grant s' e" using p_in f_in os
|
|
653 |
by (simp add:UnLink hungs)
|
|
654 |
moreover have "grant s' e"
|
|
655 |
proof-
|
|
656 |
from grant parent obtain up rp tp uf rf tf upf rpf tpf
|
|
657 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
658 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
659 |
and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)"
|
|
660 |
apply (simp add:UnLink split:option.splits)
|
|
661 |
by (case_tac a, case_tac aa, case_tac ab, blast)
|
|
662 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
663 |
using os cp2sp
|
|
664 |
apply (erule_tac x = p in allE)
|
|
665 |
by (auto simp:UnLink co2sobj.simps cp2sproc_def split:option.splits)
|
|
666 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf"
|
|
667 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:UnLink)
|
|
668 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)"
|
|
669 |
using p2 cf2sf f_in os parent
|
|
670 |
apply (erule_tac x = f in allE)
|
|
671 |
apply (erule exE, clarsimp simp:UnLink)
|
|
672 |
apply (frule_tac s = s in is_file_in_current, simp)
|
|
673 |
by (auto simp:cf2sfile_def split:option.splits)
|
|
674 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
|
|
675 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:UnLink)
|
|
676 |
hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s
|
|
677 |
apply (erule_tac x = pf in allE)
|
|
678 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
|
|
679 |
apply (drule is_dir_not_file, drule is_dir_not_file)
|
|
680 |
apply (auto simp:cf2sfile_def split:option.splits)
|
|
681 |
apply (case_tac pf, simp_all)
|
|
682 |
by (simp add:sroot_def root_sec_remains vd vs')
|
|
683 |
have "search_check s' (up, rp, tp) f"
|
|
684 |
using p1 p2 p2' vd cf2sf f_in grant UnLink os parent vs'
|
|
685 |
apply (rule_tac s = s in enrich_search_check)
|
|
686 |
by (simp_all split:option.splits)
|
|
687 |
thus ?thesis using p1' p2' p3' parent
|
|
688 |
apply (simp add:UnLink split:option.splits)
|
|
689 |
using grant UnLink p1 p2 p3
|
|
690 |
by simp
|
|
691 |
qed
|
|
692 |
ultimately show ?thesis using vs'
|
|
693 |
by (erule_tac valid.intros(2), simp+)
|
|
694 |
next
|
|
695 |
case (Rmdir p f)
|
|
696 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
697 |
apply (erule_tac x = "O_proc p" in allE)
|
|
698 |
by (auto simp:Rmdir)
|
|
699 |
have f_in: "is_dir s' f" using os alive
|
|
700 |
apply (erule_tac x = "O_dir f" in allE)
|
|
701 |
by (auto simp:Rmdir dir_is_empty_def)
|
|
702 |
have not_root: "f \<noteq> []" using os
|
|
703 |
by (auto simp:Rmdir)
|
|
704 |
from os vd obtain pf where pf_in_s: "is_dir s pf"
|
|
705 |
and parent: "parent f = Some pf"
|
|
706 |
apply (auto simp:Rmdir dir_is_empty_def)
|
|
707 |
apply (case_tac f, simp+)
|
|
708 |
apply (drule parentf_is_dir_prop1, auto)
|
|
709 |
done
|
|
710 |
from pf_in_s alive have pf_in: "is_dir s' pf"
|
|
711 |
apply (erule_tac x = "O_dir pf" in allE)
|
|
712 |
by (auto simp:Rmdir)
|
|
713 |
have empty_in: "dir_is_empty s' f" using os
|
|
714 |
apply (simp add:dir_is_empty_def f_in)
|
|
715 |
apply auto using alive'
|
|
716 |
apply (erule_tac x = "E_file f'" in allE)
|
|
717 |
by (simp add:Rmdir dir_is_empty_def)
|
|
718 |
have "os_grant s' e" using p_in f_in os empty_in
|
|
719 |
by (simp add:Rmdir hungs)
|
|
720 |
moreover have "grant s' e"
|
|
721 |
proof-
|
|
722 |
from grant parent obtain up rp tp uf rf tf upf rpf tpf
|
|
723 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
724 |
and p2: "sectxt_of_obj s (O_dir f) = Some (uf, rf, tf)"
|
|
725 |
and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)"
|
|
726 |
apply (simp add:Rmdir split:option.splits)
|
|
727 |
by (case_tac a, case_tac aa, case_tac ab, blast)
|
|
728 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
729 |
using os cp2sp
|
|
730 |
apply (erule_tac x = p in allE)
|
|
731 |
by (auto simp:Rmdir co2sobj.simps cp2sproc_def split:option.splits)
|
|
732 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf"
|
|
733 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:dir_is_empty_def Rmdir)
|
|
734 |
hence p2': "sectxt_of_obj s' (O_dir f) = Some (uf, rf, tf)"
|
|
735 |
using p2 cf2sf f_in os parent
|
|
736 |
apply (erule_tac x = f in allE)
|
|
737 |
apply (erule exE, clarsimp simp:Rmdir dir_is_empty_def)
|
|
738 |
apply (frule_tac s = s in is_dir_in_current, simp)
|
|
739 |
apply (drule is_dir_not_file, drule is_dir_not_file)
|
|
740 |
by (auto simp:cf2sfile_def split:option.splits)
|
|
741 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
|
|
742 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:Rmdir)
|
|
743 |
hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s
|
|
744 |
apply (erule_tac x = pf in allE)
|
|
745 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
|
|
746 |
apply (drule is_dir_not_file, drule is_dir_not_file)
|
|
747 |
apply (auto simp:cf2sfile_def split:option.splits)
|
|
748 |
apply (case_tac pf, simp_all)
|
|
749 |
by (simp add:sroot_def root_sec_remains vd vs')
|
|
750 |
have "search_check s' (up, rp, tp) f"
|
|
751 |
using p1 p2 p2' vd cf2sf f_in grant Rmdir os parent vs'
|
|
752 |
apply (rule_tac s = s in enrich_search_check')
|
|
753 |
by (simp_all add:dir_is_empty_def split:option.splits)
|
|
754 |
thus ?thesis using p1' p2' p3' parent
|
|
755 |
apply (simp add:Rmdir split:option.splits)
|
|
756 |
using grant Rmdir p1 p2 p3
|
|
757 |
by simp
|
|
758 |
qed
|
|
759 |
ultimately show ?thesis using vs'
|
|
760 |
by (erule_tac valid.intros(2), simp+)
|
|
761 |
next
|
|
762 |
case (Mkdir p f inum)
|
|
763 |
from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f = Some pf"
|
|
764 |
by (auto simp:Mkdir)
|
|
765 |
have pf_in: "is_dir s' pf" using pf_in_s alive
|
|
766 |
apply (erule_tac x = "O_dir pf" in allE)
|
|
767 |
by simp
|
|
768 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
769 |
apply (erule_tac x = "O_proc p" in allE)
|
|
770 |
by (auto simp:Mkdir)
|
|
771 |
have f_not_in: "f \<notin> current_files s'" using os alive'
|
|
772 |
apply (erule_tac x = "E_file f" in allE)
|
|
773 |
by (auto simp:Mkdir)
|
|
774 |
have inum_not_in: "inum \<notin> current_inode_nums s'"
|
|
775 |
using os alive'
|
|
776 |
apply (erule_tac x = "E_inum inum" in allE)
|
|
777 |
by (simp add:Mkdir)
|
|
778 |
have "os_grant s' e" using p_in pf_in parent f_not_in os inum_not_in
|
|
779 |
by (simp add:Mkdir hungs)
|
|
780 |
moreover have "grant s' e"
|
|
781 |
proof-
|
|
782 |
from grant parent obtain up rp tp uf rf tf
|
|
783 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
784 |
and p2: "sectxt_of_obj s (O_dir pf) = Some (uf, rf, tf)"
|
|
785 |
apply (simp add:Mkdir split:option.splits)
|
|
786 |
by (case_tac a, case_tac aa, blast)
|
|
787 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
788 |
using os cp2sp
|
|
789 |
apply (erule_tac x = p in allE)
|
|
790 |
by (auto simp:Mkdir co2sobj.simps cp2sproc_def split:option.splits)
|
|
791 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
|
|
792 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:Mkdir)
|
|
793 |
hence p2': "sectxt_of_obj s' (O_dir pf) = Some (uf, rf, tf)" using p2 cf2sf pf_in pf_in_s
|
|
794 |
apply (erule_tac x = pf in allE)
|
|
795 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
|
|
796 |
apply (drule is_dir_not_file, drule is_dir_not_file)
|
|
797 |
apply (auto simp:cf2sfile_def split:option.splits)
|
|
798 |
apply (case_tac pf, simp_all)
|
|
799 |
by (simp add:sroot_def root_sec_remains vd vs')
|
|
800 |
have "search_check s' (up, rp, tp) pf"
|
|
801 |
using p1 p2 p2' vd cf2sf pf_in grant Mkdir pf_in_s parent vs'
|
|
802 |
apply (rule_tac s = s in enrich_search_check')
|
|
803 |
apply (simp_all split:option.splits)
|
|
804 |
done
|
|
805 |
thus ?thesis using p1' p2' parent
|
|
806 |
apply (simp add:Mkdir split:option.splits)
|
|
807 |
using grant Mkdir p1 p2
|
|
808 |
apply simp
|
|
809 |
done
|
|
810 |
qed
|
|
811 |
ultimately show ?thesis using vs'
|
|
812 |
by (erule_tac valid.intros(2), simp+)
|
|
813 |
next
|
|
814 |
case (LinkHard p f f')
|
|
815 |
from os obtain pf where pf_in_s: "is_dir s pf" and parent: "parent f' = Some pf"
|
|
816 |
by (auto simp:LinkHard)
|
|
817 |
have pf_in: "is_dir s' pf" using pf_in_s alive
|
|
818 |
apply (erule_tac x = "O_dir pf" in allE)
|
|
819 |
by simp
|
|
820 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
821 |
apply (erule_tac x = "O_proc p" in allE)
|
|
822 |
by (auto simp:LinkHard)
|
|
823 |
have f'_not_in: "f' \<notin> current_files s'" using os alive'
|
|
824 |
apply (erule_tac x = "E_file f'" in allE)
|
|
825 |
by (auto simp:LinkHard)
|
|
826 |
have f_in: "is_file s' f" using os alive
|
|
827 |
apply (erule_tac x = "O_file f" in allE)
|
|
828 |
by (auto simp:LinkHard)
|
|
829 |
have "os_grant s' e" using p_in pf_in parent os f_in f'_not_in
|
|
830 |
by (simp add:LinkHard hungs)
|
|
831 |
moreover have "grant s' e"
|
|
832 |
proof-
|
|
833 |
from grant parent obtain up rp tp uf rf tf upf rpf tpf
|
|
834 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
835 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
836 |
and p3: "sectxt_of_obj s (O_dir pf) = Some (upf, rpf, tpf)"
|
|
837 |
apply (simp add:LinkHard split:option.splits)
|
|
838 |
by (case_tac a, case_tac aa, case_tac ab, blast)
|
|
839 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
840 |
using os cp2sp
|
|
841 |
apply (erule_tac x = p in allE)
|
|
842 |
by (auto simp:LinkHard co2sobj.simps cp2sproc_def split:option.splits)
|
|
843 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s f = Some sf"
|
|
844 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:LinkHard)
|
|
845 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)"
|
|
846 |
using p2 cf2sf f_in os parent
|
|
847 |
apply (erule_tac x = f in allE)
|
|
848 |
apply (erule exE, clarsimp simp:LinkHard)
|
|
849 |
apply (frule_tac s = s in is_file_in_current, simp)
|
|
850 |
apply (auto simp:cf2sfile_def split:option.splits)
|
|
851 |
apply (case_tac f, simp)
|
|
852 |
by (drule_tac s = s in root_is_dir', simp add:vd, simp+)
|
|
853 |
from vd os pf_in_s have "\<exists> sf. cf2sfile s pf = Some sf"
|
|
854 |
by (auto dest!:is_dir_in_current current_file_has_sfile simp:LinkHard)
|
|
855 |
hence p3': "sectxt_of_obj s' (O_dir pf) = Some (upf, rpf, tpf)" using p3 cf2sf pf_in pf_in_s
|
|
856 |
apply (erule_tac x = pf in allE)
|
|
857 |
apply (erule exE, frule_tac s = s in is_dir_in_current, simp)
|
|
858 |
apply (drule is_dir_not_file, drule is_dir_not_file)
|
|
859 |
apply (auto simp:cf2sfile_def split:option.splits)
|
|
860 |
apply (case_tac pf, simp_all)
|
|
861 |
by (simp add:sroot_def root_sec_remains vd vs')
|
|
862 |
have "search_check s' (up, rp, tp) f"
|
|
863 |
using p1 p2 p2' vd cf2sf f_in grant LinkHard os parent vs'
|
|
864 |
apply (rule_tac s = s in enrich_search_check)
|
|
865 |
by (simp_all split:option.splits)
|
|
866 |
moreover have "search_check s' (up, rp, tp) pf"
|
|
867 |
using p1 p3 p3' vd cf2sf pf_in grant LinkHard os parent vs'
|
|
868 |
apply (rule_tac s = s in enrich_search_check')
|
|
869 |
apply (simp_all split:option.splits)
|
|
870 |
done
|
|
871 |
ultimately show ?thesis using p1' p2' p3' parent
|
|
872 |
apply (simp add:LinkHard split:option.splits)
|
|
873 |
using grant LinkHard p1 p2 p3
|
|
874 |
apply simp
|
|
875 |
done
|
|
876 |
qed
|
|
877 |
ultimately show ?thesis using vs'
|
|
878 |
by (erule_tac valid.intros(2), simp+)
|
|
879 |
next
|
|
880 |
case (Truncate p f len)
|
|
881 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
882 |
apply (erule_tac x = "O_proc p" in allE)
|
|
883 |
by (auto simp:Truncate)
|
|
884 |
have f_in: "is_file s' f" using os alive
|
|
885 |
apply (erule_tac x = "O_file f" in allE)
|
|
886 |
by (auto simp:Truncate)
|
|
887 |
have "os_grant s' e" using p_in f_in by (simp add:Truncate)
|
|
888 |
moreover have "grant s' e"
|
|
889 |
proof-
|
|
890 |
from grant obtain up rp tp uf rf tf
|
|
891 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
892 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
893 |
apply (simp add:Truncate split:option.splits)
|
|
894 |
by (case_tac a, case_tac aa, blast)
|
|
895 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
896 |
using os cp2sp
|
|
897 |
apply (erule_tac x = p in allE)
|
|
898 |
by (auto simp:Truncate co2sobj.simps cp2sproc_def split:option.splits)
|
|
899 |
from os have f_in': "is_file s f" by (simp add:Truncate)
|
|
900 |
from vd os have "\<exists> sf. cf2sfile s f = Some sf"
|
|
901 |
by (auto dest!:is_file_in_current current_file_has_sfile simp:Truncate)
|
|
902 |
hence p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" using f_in f_in' p2 cf2sf
|
|
903 |
apply (erule_tac x = f in allE)
|
|
904 |
apply (auto dest:is_file_in_current simp:cf2sfile_def split:option.splits)
|
|
905 |
apply (case_tac f, simp)
|
|
906 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
|
|
907 |
done
|
|
908 |
have "search_check s' (up, rp, tp) f"
|
|
909 |
using p1 p2 p2' vd cf2sf f_in' grant Truncate f_in
|
|
910 |
apply (rule_tac s = s in enrich_search_check)
|
|
911 |
by (simp_all split:option.splits)
|
|
912 |
thus ?thesis using p1' p2'
|
|
913 |
apply (simp add:Truncate split:option.splits)
|
|
914 |
using grant Truncate p1 p2
|
|
915 |
by (simp add:Truncate grant p1 p2)
|
|
916 |
qed
|
|
917 |
ultimately show ?thesis using vs'
|
|
918 |
by (erule_tac valid.intros(2), simp+)
|
|
919 |
next
|
|
920 |
case (CreateMsgq p q)
|
|
921 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
922 |
apply (erule_tac x = "O_proc p" in allE)
|
|
923 |
by (auto simp:CreateMsgq)
|
|
924 |
have q_not_in: "q \<notin> current_msgqs s'" using os alive'
|
|
925 |
apply (erule_tac x = "E_msgq q" in allE)
|
|
926 |
by (simp add:CreateMsgq)
|
|
927 |
have "os_grant s' e" using p_in q_not_in by (simp add:CreateMsgq)
|
|
928 |
moreover have "grant s' e"
|
|
929 |
proof-
|
|
930 |
from grant obtain up rp tp
|
|
931 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
932 |
apply (simp add:CreateMsgq split:option.splits)
|
|
933 |
by (case_tac a, blast)
|
|
934 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
935 |
using os cp2sp
|
|
936 |
apply (erule_tac x = p in allE)
|
|
937 |
by (auto simp:CreateMsgq co2sobj.simps cp2sproc_def split:option.splits)
|
|
938 |
show ?thesis using p1'
|
|
939 |
apply (simp add:CreateMsgq split:option.splits)
|
|
940 |
using grant CreateMsgq p1
|
|
941 |
by simp
|
|
942 |
qed
|
|
943 |
ultimately show ?thesis using vs'
|
|
944 |
by (erule_tac valid.intros(2), simp+)
|
|
945 |
next
|
|
946 |
case (RemoveMsgq p q)
|
|
947 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
948 |
apply (erule_tac x = "O_proc p" in allE)
|
|
949 |
by (auto simp:RemoveMsgq)
|
|
950 |
have q_in: "q \<in> current_msgqs s'" using os alive
|
|
951 |
apply (erule_tac x = "O_msgq q" in allE)
|
|
952 |
by (simp add:RemoveMsgq)
|
|
953 |
have "os_grant s' e" using p_in q_in by (simp add:RemoveMsgq)
|
|
954 |
moreover have "grant s' e"
|
|
955 |
proof-
|
|
956 |
from grant obtain up rp tp uq rq tq
|
|
957 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
958 |
and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)"
|
|
959 |
apply (simp add:RemoveMsgq split:option.splits)
|
|
960 |
by (case_tac a, case_tac aa, blast)
|
|
961 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
962 |
using os cp2sp
|
|
963 |
apply (erule_tac x = p in allE)
|
|
964 |
by (auto simp:RemoveMsgq co2sobj.simps cp2sproc_def split:option.splits)
|
|
965 |
from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)"
|
|
966 |
using os cq2sq vd
|
|
967 |
apply (erule_tac x = q in allE)
|
|
968 |
by (auto simp:RemoveMsgq co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits)
|
|
969 |
show ?thesis using p1' p2' grant p1 p2
|
|
970 |
by (simp add:RemoveMsgq)
|
|
971 |
qed
|
|
972 |
ultimately show ?thesis using vs'
|
|
973 |
by (erule_tac valid.intros(2), simp+)
|
|
974 |
next
|
|
975 |
case (SendMsg p q m)
|
|
976 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
977 |
apply (erule_tac x = "O_proc p" in allE)
|
|
978 |
by (auto simp:SendMsg)
|
|
979 |
have q_in: "q \<in> current_msgqs s'" using os alive
|
|
980 |
apply (erule_tac x = "O_msgq q" in allE)
|
|
981 |
by (simp add:SendMsg)
|
|
982 |
have m_not_in: "m \<notin> set (msgs_of_queue s' q)" using os alive'
|
|
983 |
apply (erule_tac x = "E_msg q m" in allE)
|
|
984 |
by (simp add:SendMsg q_in)
|
|
985 |
have "os_grant s' e" using p_in q_in m_not_in
|
|
986 |
by (simp add:SendMsg)
|
|
987 |
moreover have "grant s' e"
|
|
988 |
proof-
|
|
989 |
from grant obtain up rp tp uq rq tq
|
|
990 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
991 |
and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)"
|
|
992 |
apply (simp add:SendMsg split:option.splits)
|
|
993 |
by (case_tac a, case_tac aa, blast)
|
|
994 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
995 |
using os cp2sp
|
|
996 |
apply (erule_tac x = p in allE)
|
|
997 |
by (auto simp:SendMsg co2sobj.simps cp2sproc_def split:option.splits)
|
|
998 |
from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)"
|
|
999 |
using os cq2sq vd
|
|
1000 |
apply (erule_tac x = q in allE)
|
|
1001 |
by (auto simp:SendMsg co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits)
|
|
1002 |
show ?thesis using p1' p2' grant p1 p2
|
|
1003 |
by (simp add:SendMsg)
|
|
1004 |
qed
|
|
1005 |
ultimately show ?thesis using vs'
|
|
1006 |
by (erule_tac valid.intros(2), simp+)
|
|
1007 |
next
|
|
1008 |
case (RecvMsg p q m)
|
|
1009 |
have p_in: "p \<in> current_procs s'" using os alive
|
|
1010 |
apply (erule_tac x = "O_proc p" in allE)
|
|
1011 |
by (auto simp:RecvMsg)
|
|
1012 |
have q_in: "q \<in> current_msgqs s'" using os alive
|
|
1013 |
apply (erule_tac x = "O_msgq q" in allE)
|
|
1014 |
by (simp add:RecvMsg)
|
|
1015 |
have m_in: "m = hd (msgs_of_queue s' q)"
|
|
1016 |
and sms_not_empty: "msgs_of_queue s' q \<noteq> []"
|
|
1017 |
using os sms_remain
|
|
1018 |
by (auto simp:RecvMsg)
|
|
1019 |
have "os_grant s' e" using p_in q_in m_in sms_not_empty os
|
|
1020 |
by (simp add:RecvMsg)
|
|
1021 |
moreover have "grant s' e"
|
|
1022 |
proof-
|
|
1023 |
from grant obtain up rp tp uq rq tq um rm tm
|
|
1024 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
1025 |
and p2: "sectxt_of_obj s (O_msgq q) = Some (uq, rq, tq)"
|
|
1026 |
and p3: "sectxt_of_obj s (O_msg q m) = Some (um, rm, tm)"
|
|
1027 |
apply (simp add:RecvMsg split:option.splits)
|
|
1028 |
by (case_tac a, case_tac aa, case_tac ab, blast)
|
|
1029 |
from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
|
|
1030 |
using os cp2sp
|
|
1031 |
apply (erule_tac x = p in allE)
|
|
1032 |
by (auto simp:RecvMsg co2sobj.simps cp2sproc_def split:option.splits)
|
|
1033 |
from p2 have p2': "sectxt_of_obj s' (O_msgq q) = Some (uq, rq, tq)"
|
|
1034 |
using os cq2sq vd
|
|
1035 |
apply (erule_tac x = q in allE)
|
|
1036 |
by (auto simp:RecvMsg co2sobj.simps cq2smsgq_def dest!:current_has_sms' split:option.splits)
|
|
1037 |
from p3 have p3': "sectxt_of_obj s' (O_msg q m) = Some (um, rm, tm)"
|
|
1038 |
using sms_remain cq2sq vd os p2 p2' p3
|
|
1039 |
apply (erule_tac x = q in allE)
|
|
1040 |
apply (erule_tac x = q in allE)
|
|
1041 |
apply (clarsimp simp:RecvMsg)
|
|
1042 |
apply (simp add:cq2smsgq_def split:option.splits if_splits)
|
|
1043 |
apply (drule current_has_sms', simp, simp)
|
|
1044 |
apply (case_tac "msgs_of_queue s q", simp)
|
|
1045 |
apply (simp add:cqm2sms.simps split:option.splits)
|
|
1046 |
apply (auto simp add:cm2smsg_def split:option.splits if_splits)[1]
|
|
1047 |
apply (case_tac "msgs_of_queue s q", simp)
|
|
1048 |
apply (simp add:cqm2sms.simps split:option.splits)
|
|
1049 |
apply (auto simp add:cm2smsg_def split:option.splits if_splits)[1]
|
|
1050 |
done
|
|
1051 |
show ?thesis using p1' p2' p3' grant p1 p2 p3
|
|
1052 |
by (simp add:RecvMsg)
|
|
1053 |
qed
|
|
1054 |
ultimately show ?thesis using vs'
|
|
1055 |
by (erule_tac valid.intros(2), simp+)
|
|
1056 |
next
|
|
1057 |
case (CreateSock p af st fd inum)
|
|
1058 |
show ?thesis using grant
|
|
1059 |
by (simp add:CreateSock)
|
|
1060 |
next
|
|
1061 |
case (Bind p fd addr)
|
|
1062 |
show ?thesis using grant
|
|
1063 |
by (simp add:Bind)
|
|
1064 |
next
|
|
1065 |
case (Connect p fd addr)
|
|
1066 |
show ?thesis using grant
|
|
1067 |
by (simp add:Connect)
|
|
1068 |
next
|
|
1069 |
case (Listen p fd)
|
|
1070 |
show ?thesis using grant
|
|
1071 |
by (simp add:Listen)
|
|
1072 |
next
|
|
1073 |
case (Accept p fd addr port fd' inum)
|
|
1074 |
show ?thesis using grant
|
|
1075 |
by (simp add:Accept)
|
|
1076 |
next
|
|
1077 |
case (SendSock p fd)
|
|
1078 |
show ?thesis using grant
|
|
1079 |
by (simp add:SendSock)
|
|
1080 |
next
|
|
1081 |
case (RecvSock p fd)
|
|
1082 |
show ?thesis using grant
|
|
1083 |
by (simp add:RecvSock)
|
|
1084 |
next
|
|
1085 |
case (Shutdown p fd how)
|
|
1086 |
show ?thesis using grant
|
|
1087 |
by (simp add:Shutdown)
|
|
1088 |
qed
|
77
|
1089 |
|
79
|
1090 |
lemma not_all_procs_prop2:
|
|
1091 |
"p' \<notin> all_procs s \<Longrightarrow> p' \<notin> init_procs"
|
|
1092 |
apply (induct s, simp)
|
|
1093 |
by (case_tac a, auto)
|
|
1094 |
|
|
1095 |
lemma not_all_procs_prop3:
|
|
1096 |
"p' \<notin> all_procs s \<Longrightarrow> p' \<notin> current_procs s"
|
|
1097 |
apply (induct s, simp)
|
|
1098 |
by (case_tac a, auto)
|
|
1099 |
|
|
1100 |
definition is_created_proc:: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
|
|
1101 |
where
|
|
1102 |
"is_created_proc s p \<equiv> p \<in> current_procs s \<and> (p \<in> init_procs \<longrightarrow> died (O_proc p) s)"
|
|
1103 |
|
|
1104 |
lemma created_proc_clone:
|
|
1105 |
"valid (Clone p p' fds # s) \<Longrightarrow>
|
|
1106 |
is_created_proc (Clone p p' fds # s) tp = (if (tp = p') then True else is_created_proc s tp)"
|
|
1107 |
apply (drule vt_grant_os)
|
|
1108 |
apply (auto simp:is_created_proc_def dest:not_all_procs_prop2)
|
|
1109 |
using not_died_init_proc
|
|
1110 |
by auto
|
|
1111 |
|
|
1112 |
lemma created_proc_exit:
|
|
1113 |
"is_created_proc (Exit p # s) tp = (if (tp = p) then False else is_created_proc s tp)"
|
|
1114 |
by (simp add:is_created_proc_def)
|
|
1115 |
|
|
1116 |
lemma created_proc_kill:
|
|
1117 |
"is_created_proc (Kill p p' # s) tp = (if (tp = p') then False else is_created_proc s tp)"
|
|
1118 |
by (simp add:is_created_proc_def)
|
|
1119 |
|
|
1120 |
lemma created_proc_other:
|
|
1121 |
"\<lbrakk>\<And> p p' fds. e \<noteq> Clone p p' fds;
|
|
1122 |
\<And> p. e \<noteq> Exit p;
|
|
1123 |
\<And> p p'. e \<noteq> Kill p p'\<rbrakk> \<Longrightarrow> is_created_proc (e # s) tp = is_created_proc s tp"
|
|
1124 |
by (case_tac e, auto simp:is_created_proc_def)
|
|
1125 |
|
|
1126 |
lemmas is_created_proc_simps = created_proc_clone created_proc_exit created_proc_kill created_proc_other
|
|
1127 |
(*
|
77
|
1128 |
|
|
1129 |
|
|
1130 |
|
|
1131 |
|
79
|
1132 |
(p \<in> current_procs s \<longrightarrow> co2sobj (enrich_proc s p p') (O_proc p') = co2sobj (enrich_proc s p p') (O_proc p)) \<and>
|
|
1133 |
(\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj) \<and>
|
|
1134 |
(\<forall> p'. p' \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
|
|
1135 |
(\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
|
|
1136 |
(Tainted (enrich_proc s p p') = (Tainted s \<union> (if (O_proc p \<in> Tainted s) then {O_proc p'} else {})))"*)
|
|
1137 |
|
|
1138 |
lemma enrich_proc_dup_in:
|
|
1139 |
"\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
|
|
1140 |
\<Longrightarrow> p' \<in> current_procs (enrich_proc s p p')"
|
|
1141 |
apply (induct s, simp add:is_created_proc_def)
|
|
1142 |
apply (frule vt_grant_os, frule vd_cons)
|
|
1143 |
apply (case_tac a, auto simp:is_created_proc_def dest:not_all_procs_prop3)
|
|
1144 |
done
|
|
1145 |
|
|
1146 |
lemma enrich_proc_dup_ffd:
|
|
1147 |
"\<lbrakk>file_of_proc_fd s p fd = Some f; is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
|
|
1148 |
\<Longrightarrow> file_of_proc_fd (enrich_proc s p p') p' fd = Some f"
|
|
1149 |
apply (induct s, simp add:is_created_proc_def)
|
|
1150 |
apply (frule vt_grant_os, frule vd_cons)
|
|
1151 |
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def
|
|
1152 |
dest:not_all_procs_prop3 split:if_splits option.splits)
|
|
1153 |
done
|
|
1154 |
|
80
|
1155 |
lemma enrich_proc_dup_ffd':
|
|
1156 |
"\<lbrakk>file_of_proc_fd (enrich_proc s p p') p' fd = Some f; is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
|
|
1157 |
\<Longrightarrow> file_of_proc_fd s p fd = Some f"
|
|
1158 |
apply (induct s, simp add:is_created_proc_def)
|
|
1159 |
apply (frule vt_grant_os, frule vd_cons)
|
|
1160 |
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def
|
|
1161 |
dest:not_all_procs_prop3 split:if_splits option.splits)
|
|
1162 |
done
|
|
1163 |
|
79
|
1164 |
lemma current_fflag_in_fds:
|
|
1165 |
"\<lbrakk>flags_of_proc_fd s p fd = Some flag; valid s\<rbrakk> \<Longrightarrow> fd \<in> current_proc_fds s p"
|
|
1166 |
apply (induct s arbitrary:p)
|
|
1167 |
apply (simp add:flags_of_proc_fd.simps file_of_proc_fd.simps init_oflags_prop2)
|
|
1168 |
apply (frule vd_cons, frule vt_grant_os, case_tac a)
|
|
1169 |
apply (auto split:if_splits option.splits dest:proc_fd_in_fds)
|
80
|
1170 |
done
|
79
|
1171 |
|
|
1172 |
lemma current_fflag_has_ffd:
|
|
1173 |
"\<lbrakk>flags_of_proc_fd s p fd = Some flag; valid s\<rbrakk> \<Longrightarrow> \<exists> f. file_of_proc_fd s p fd = Some f"
|
|
1174 |
apply (induct s arbitrary:p)
|
|
1175 |
apply (simp add: file_of_proc_fd.simps init_fileflag_valid)
|
|
1176 |
apply (frule vd_cons, frule vt_grant_os, case_tac a)
|
|
1177 |
apply (auto split:if_splits option.splits dest:proc_fd_in_fds)
|
80
|
1178 |
done
|
79
|
1179 |
|
|
1180 |
lemma enrich_proc_dup_fflags:
|
80
|
1181 |
"\<lbrakk>flags_of_proc_fd s p fd = Some flag; is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
|
|
1182 |
\<Longrightarrow> flags_of_proc_fd (enrich_proc s p p') p' fd = Some (remove_create_flag flag) \<or>
|
|
1183 |
flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag"
|
|
1184 |
apply (induct s arbitrary:p, simp add:is_created_proc_def)
|
79
|
1185 |
apply (frule vt_grant_os, frule vd_cons)
|
80
|
1186 |
apply (case_tac a, auto simp:is_created_proc_def proc_file_fds_def is_creat_flag_def
|
79
|
1187 |
dest:not_all_procs_prop3 split:if_splits option.splits)
|
80
|
1188 |
done
|
|
1189 |
|
|
1190 |
lemma enrich_proc_dup_ffds:
|
|
1191 |
"\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
|
|
1192 |
\<Longrightarrow> proc_file_fds (enrich_proc s p p') p' = proc_file_fds s p"
|
|
1193 |
apply (auto simp:proc_file_fds_def)
|
|
1194 |
apply (rule_tac x = f in exI)
|
|
1195 |
apply (erule enrich_proc_dup_ffd', simp+)
|
|
1196 |
apply (rule_tac x = f in exI)
|
|
1197 |
apply (erule enrich_proc_dup_ffd, simp+)
|
|
1198 |
done
|
77
|
1199 |
|
|
1200 |
lemma enrich_proc_prop:
|
|
1201 |
"\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk>
|
|
1202 |
\<Longrightarrow> valid (enrich_proc s p p') \<and>
|
79
|
1203 |
(\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj) \<and>
|
|
1204 |
(\<forall> obj. enrich_not_alive s obj \<longrightarrow> enrich_not_alive (enrich_proc s p p') obj) \<and>
|
|
1205 |
(files_hung_by_del (enrich_proc s p p') = files_hung_by_del s) \<and>
|
|
1206 |
(\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
|
|
1207 |
(\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
|
|
1208 |
(\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and>
|
|
1209 |
(\<forall> tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> file_of_proc_fd (enrich_proc s p p') tp fd = Some f) \<and>
|
|
1210 |
(\<forall> tp fd flags. flags_of_proc_fd s tp fd = Some flags \<longrightarrow>
|
|
1211 |
flags_of_proc_fd (enrich_proc s p p') tp fd = Some flags) \<and>
|
|
1212 |
(\<forall> q. msgs_of_queue (enrich_proc s p p') q = msgs_of_queue s q) \<and>
|
|
1213 |
(\<forall> tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>
|
|
1214 |
(cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
|
|
1215 |
(\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
|
77
|
1216 |
proof (induct s)
|
|
1217 |
case Nil
|
|
1218 |
thus ?case by (auto simp:is_created_proc_def)
|
|
1219 |
next
|
|
1220 |
case (Cons e s)
|
79
|
1221 |
hence vd_cons: "valid (e # s)" and created_cons: "is_created_proc (e # s) p"
|
|
1222 |
and all_procs_cons: "p' \<notin> all_procs (e # s)" and vd: "valid s"
|
|
1223 |
and os: "os_grant s e" and grant: "grant s e"
|
|
1224 |
by (auto dest:vd_cons vt_grant_os vt_grant)
|
|
1225 |
from all_procs_cons have all_procs: "p' \<notin> all_procs s" by (case_tac e, auto)
|
|
1226 |
from Cons have pre: "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p') \<and>
|
|
1227 |
(\<forall>obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj) \<and>
|
|
1228 |
(\<forall>obj. enrich_not_alive s obj \<longrightarrow> enrich_not_alive (enrich_proc s p p') obj) \<and>
|
|
1229 |
files_hung_by_del (enrich_proc s p p') = files_hung_by_del s \<and>
|
|
1230 |
(\<forall>tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
|
|
1231 |
(\<forall>f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
|
|
1232 |
(\<forall>q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and>
|
|
1233 |
(\<forall>tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> file_of_proc_fd (enrich_proc s p p') tp fd = Some f) \<and>
|
|
1234 |
(\<forall>tp fd flags.
|
|
1235 |
flags_of_proc_fd s tp fd = Some flags \<longrightarrow> flags_of_proc_fd (enrich_proc s p p') tp fd = Some flags) \<and>
|
|
1236 |
(\<forall>q. msgs_of_queue (enrich_proc s p p') q = msgs_of_queue s q) \<and>
|
80
|
1237 |
(\<forall>tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>
|
|
1238 |
(cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
|
|
1239 |
(\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
|
79
|
1240 |
using vd all_procs by auto
|
80
|
1241 |
have alive_pre: "is_created_proc s p \<Longrightarrow> (\<forall>obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj)"
|
|
1242 |
using pre by simp
|
|
1243 |
hence curf_pre: "is_created_proc s p \<Longrightarrow> (\<forall>f. f \<in> current_files s \<longrightarrow> f \<in> current_files (enrich_proc s p p'))"
|
|
1244 |
using vd apply auto
|
|
1245 |
apply (drule is_file_or_dir, simp)
|
|
1246 |
apply (erule disjE)
|
|
1247 |
apply (erule_tac x = "O_file f" in allE, simp add:is_file_in_current)
|
|
1248 |
apply (erule_tac x = "O_dir f" in allE, simp add:is_dir_in_current)
|
|
1249 |
done
|
79
|
1250 |
have "valid (enrich_proc (e # s) p p')"
|
|
1251 |
proof-
|
|
1252 |
from pre have pre': "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p')" by simp
|
|
1253 |
have "is_created_proc s p \<Longrightarrow> valid (e # enrich_proc s p p')"
|
|
1254 |
apply (frule pre')
|
|
1255 |
apply (erule_tac s = s in enrich_valid_intro_cons)
|
|
1256 |
apply (simp_all add:os grant vd pre)
|
|
1257 |
done
|
80
|
1258 |
moreover have "\<And>f fds. \<lbrakk>valid (Execve p f fds # enrich_proc s p p'); is_created_proc s p;
|
|
1259 |
valid (Execve p f fds # s); p' \<notin> all_procs s\<rbrakk>
|
79
|
1260 |
\<Longrightarrow> valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
|
80
|
1261 |
proof-
|
|
1262 |
fix f fds
|
|
1263 |
assume a1: "valid (Execve p f fds # enrich_proc s p p')" and a2: "is_created_proc s p"
|
|
1264 |
and a3: "valid (Execve p f fds # s)" and a0: "p' \<notin> all_procs s"
|
|
1265 |
have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
|
|
1266 |
and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
|
|
1267 |
and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
|
|
1268 |
and ffd_remain: "\<forall>tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow>
|
|
1269 |
file_of_proc_fd (enrich_proc s p p') tp fd = Some f"
|
|
1270 |
and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
|
|
1271 |
and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
|
|
1272 |
using pre a2 by auto
|
|
1273 |
show "valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
|
|
1274 |
proof-
|
|
1275 |
from a0 a3 have a0': "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
|
|
1276 |
from a3 have grant: "grant s (Execve p f fds)" and os: "os_grant s (Execve p f fds)"
|
|
1277 |
by (auto dest:vt_grant_os vt_grant simp del:os_grant.simps)
|
|
1278 |
have f_in: "is_file (enrich_proc s p p') f"
|
|
1279 |
proof-
|
|
1280 |
from pre a2
|
|
1281 |
have a4: "\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj"
|
|
1282 |
by (auto)
|
|
1283 |
show ?thesis using a3 a4
|
|
1284 |
apply (erule_tac x = "O_file f" in allE)
|
|
1285 |
by (auto dest:vt_grant_os)
|
|
1286 |
qed
|
|
1287 |
moreover have a5: "proc_file_fds s p \<subseteq> proc_file_fds (Execve p f fds # enrich_proc s p p') p'"
|
|
1288 |
using a3 a0'
|
|
1289 |
apply (frule_tac vt_grant_os)
|
|
1290 |
apply (auto simp:proc_file_fds_def)
|
|
1291 |
apply (rule_tac x = fa in exI)
|
|
1292 |
apply (erule enrich_proc_dup_ffd)
|
|
1293 |
apply (simp_all add:vd all_procs a2)
|
|
1294 |
done
|
|
1295 |
ultimately have "os_grant (Execve p f fds # enrich_proc s p p') (Execve p' f (fds \<inter> proc_file_fds s p))"
|
|
1296 |
apply (auto simp:is_file_simps enrich_proc_dup_in a2 vd all_procs a1 enrich_proc_dup_ffds)
|
|
1297 |
done
|
|
1298 |
moreover have "grant (Execve p f fds # enrich_proc s p p') (Execve p' f (fds \<inter> proc_file_fds s p))"
|
|
1299 |
proof-
|
|
1300 |
from grant obtain up rp tp uf rf tf
|
|
1301 |
where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
|
|
1302 |
and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)"
|
|
1303 |
by (simp split:option.splits, blast)
|
|
1304 |
with grant obtain pu nr nt where p3: "npctxt_execve (up, rp, tp) (uf, rf, tf) = Some (pu, nr, nt)"
|
|
1305 |
by (simp split:option.splits del:npctxt_execve.simps, blast)
|
|
1306 |
have p1': "sectxt_of_obj (Execve p f fds # enrich_proc s p p') (O_proc p') = Some (up, rp, tp)"
|
|
1307 |
using p1 dup_sp a1 a0'
|
|
1308 |
apply (simp add:sectxt_of_obj_simps)
|
|
1309 |
by (simp add:cp2sproc_def split:option.splits)
|
|
1310 |
from os have f_in': "is_file s f" by simp
|
|
1311 |
from vd os have "\<exists> sf. cf2sfile s f = Some sf"
|
|
1312 |
by (auto dest!:is_file_in_current current_file_has_sfile)
|
|
1313 |
hence p2': "sectxt_of_obj (Execve p f fds # enrich_proc s p p') (O_file f) = Some (uf, rf, tf)"
|
|
1314 |
using f_in p2 cf2sf os a1
|
|
1315 |
apply (erule_tac x = f in allE)
|
|
1316 |
apply (auto dest:is_file_in_current simp:cf2sfile_def sectxt_of_obj_simps split:option.splits)
|
|
1317 |
apply (case_tac f, simp)
|
|
1318 |
apply (drule_tac s = s in root_is_dir', simp add:vd, simp+)
|
|
1319 |
done
|
|
1320 |
from dup_sfd a5 have "\<forall>fd. fd \<in> proc_file_fds s p \<longrightarrow>
|
|
1321 |
cfd2sfd (Execve p f fds # enrich_proc s p p') p' fd = cfd2sfd s p fd"
|
|
1322 |
apply (rule_tac allI)
|
|
1323 |
apply (erule_tac x = fd in allE, clarsimp)
|
|
1324 |
apply (drule set_mp, simp)
|
|
1325 |
apply (auto simp:cfd2sfd_execve proc_file_fds_def a1)
|
|
1326 |
done
|
|
1327 |
hence "inherit_fds_check (Execve p f fds # enrich_proc s p p') (up, nr, nt) p' (fds \<inter> proc_file_fds s p)"
|
|
1328 |
using grant os p1 p2 p3 vd
|
|
1329 |
apply (clarsimp)
|
|
1330 |
apply (rule_tac s = s and p = p and fds = fds in enrich_inherit_fds_check_dup)
|
|
1331 |
apply simp_all
|
|
1332 |
done
|
|
1333 |
moreover have "search_check (Execve p f fds # enrich_proc s p p') (up, rp, tp) f"
|
|
1334 |
using p1 p2 p2' vd cf2sf f_in f_in' grant p3 f_in a1
|
|
1335 |
apply (rule_tac s = s in enrich_search_check)
|
|
1336 |
apply (simp_all add:is_file_simps)
|
|
1337 |
apply (rule allI, rule impI, erule_tac x = fa in allE, simp)
|
|
1338 |
apply (drule_tac ff = fa in cf2sfile_other')
|
|
1339 |
by (auto simp:a2 curf_pre)
|
|
1340 |
ultimately show ?thesis
|
|
1341 |
using p1' p2' p3
|
|
1342 |
apply (simp split:option.splits)
|
|
1343 |
using grant p1 p2
|
|
1344 |
apply simp
|
|
1345 |
done
|
|
1346 |
qed
|
|
1347 |
ultimately show ?thesis using a1
|
|
1348 |
by (erule_tac valid.intros(2), auto)
|
|
1349 |
qed
|
|
1350 |
qed
|
79
|
1351 |
moreover have "\<And>tp fds. \<lbrakk>valid (Clone tp p fds # s); p' \<noteq> p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow>
|
|
1352 |
valid (Clone tp p' (fds \<inter> proc_file_fds s tp) # Clone tp p fds # s)"
|
|
1353 |
apply (frule vt_grant_os, frule vt_grant, drule not_all_procs_prop3)
|
|
1354 |
apply (rule valid.intros(2))
|
|
1355 |
apply (simp_all split:option.splits add:sectxt_of_obj_simps)
|
|
1356 |
apply (auto simp add:proc_file_fds_def)[1]
|
|
1357 |
apply (auto simp:inherit_fds_check_def sectxt_of_obj_simps sectxts_of_fds_def inherit_fds_check_ctxt_def)
|
|
1358 |
done
|
|
1359 |
moreover have "\<And>f flags fd inum.
|
|
1360 |
\<lbrakk>valid (Open p f flags fd inum # enrich_proc s p p'); is_created_proc s p\<rbrakk>
|
|
1361 |
\<Longrightarrow> valid (Open p' f (remove_create_flag flags) fd inum # Open p f flags fd inum # enrich_proc s p p')"
|
|
1362 |
sorry
|
80
|
1363 |
moreover have "\<And>fd. \<lbrakk>valid (CloseFd p fd # enrich_proc s p p'); is_created_proc s p;
|
|
1364 |
valid (CloseFd p fd # s); p' \<notin> all_procs s\<rbrakk>
|
79
|
1365 |
\<Longrightarrow> valid (CloseFd p' fd # CloseFd p fd # enrich_proc s p p')"
|
80
|
1366 |
proof-
|
|
1367 |
fix fd
|
|
1368 |
assume a1: "valid (CloseFd p fd # enrich_proc s p p')" and a2: "is_created_proc s p"
|
|
1369 |
and a3: "p' \<notin> all_procs s" and a4: "valid (CloseFd p fd # s)"
|
|
1370 |
from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
|
|
1371 |
have "p' \<in> current_procs (enrich_proc s p p')"
|
|
1372 |
using a2 a3 vd
|
|
1373 |
by (auto intro:enrich_proc_dup_in)
|
|
1374 |
moreover have "fd \<in> current_proc_fds (enrich_proc s p p') p'"
|
|
1375 |
ultimately show "valid (CloseFd p' fd # CloseFd p fd # enrich_proc s p p')"
|
|
1376 |
apply (rule valid.intros(2))
|
|
1377 |
apply (simp_all add:a1 a0 a2 pre')
|
|
1378 |
|
|
1379 |
|
|
1380 |
|
79
|
1381 |
sorry
|
80
|
1382 |
(*
|
|
1383 |
thus ?thesis using created_cons vd_cons all_procs_cons
|
79
|
1384 |
apply (case_tac e)
|
|
1385 |
apply (auto simp:is_created_proc_simps split:if_splits)
|
80
|
1386 |
*)
|
79
|
1387 |
ultimately show ?thesis using created_cons vd_cons all_procs_cons
|
|
1388 |
apply (case_tac e)
|
|
1389 |
apply (auto simp:is_created_proc_simps split:if_splits)
|
|
1390 |
done
|
|
1391 |
qed
|
|
1392 |
moreover have "\<forall>obj. alive (e # s) obj \<longrightarrow> alive (enrich_proc (e # s) p p') obj"
|
|
1393 |
sorry
|
|
1394 |
moreover have "\<forall>obj. enrich_not_alive (e # s) obj \<longrightarrow> enrich_not_alive (enrich_proc (e # s) p p') obj"
|
|
1395 |
sorry
|
|
1396 |
moreover have "files_hung_by_del (enrich_proc (e # s) p p') = files_hung_by_del (e # s)"
|
|
1397 |
sorry
|
|
1398 |
moreover have "\<forall>p. p \<in> current_procs (e # s) \<longrightarrow> cp2sproc (enrich_proc (e # s) p p') p = cp2sproc (e # s) p"
|
|
1399 |
sorry
|
|
1400 |
moreover have "\<forall>f. f \<in> current_files (e # s) \<longrightarrow> cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
|
|
1401 |
sorry
|
|
1402 |
moreover have "\<forall>q. q \<in> current_msgqs (e # s) \<longrightarrow> cq2smsgq (enrich_proc (e # s) p p') q = cq2smsgq (e # s) q"
|
|
1403 |
sorry
|
|
1404 |
moreover have "\<forall>p fd f. file_of_proc_fd (e # s) p fd = Some f \<longrightarrow>
|
|
1405 |
file_of_proc_fd (enrich_proc (e # s) p p') p fd = Some f"
|
|
1406 |
sorry
|
|
1407 |
moreover have "\<forall>p fd flags. flags_of_proc_fd (e # s) p fd = Some flags \<longrightarrow>
|
|
1408 |
flags_of_proc_fd (enrich_proc (e # s) p p') p fd = Some flags"
|
|
1409 |
sorry
|
|
1410 |
moreover have "\<forall>q. msgs_of_queue (enrich_proc (e # s) p p') q = msgs_of_queue (e # s) q"
|
|
1411 |
sorry
|
|
1412 |
moreover have "\<forall>p fd. fd \<in> proc_file_fds (e # s) p \<longrightarrow>
|
|
1413 |
cfd2sfd (enrich_proc (e # s) p p') p fd = cfd2sfd (e # s) p fd"
|
|
1414 |
sorry
|
|
1415 |
ultimately show ?case
|
77
|
1416 |
by auto
|
|
1417 |
qed
|
79
|
1418 |
|
77
|
1419 |
|
79
|
1420 |
lemma enrich_proc_valid:
|
|
1421 |
"\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> valid (enrich_proc s p p')"
|
|
1422 |
by (auto dest:enrich_proc_prop)
|
|
1423 |
|
|
1424 |
lemma enrich_proc_valid:
|
|
1425 |
"\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> "
|
|
1426 |
|
|
1427 |
|
|
1428 |
|