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