author | chunhan |
Tue, 03 Sep 2013 07:25:39 +0800 | |
changeset 37 | 029cccce84b4 |
parent 34 | e7f850d1e08e |
child 39 | 13bba99ca090 |
permissions | -rwxr-xr-x |
1 | 1 |
theory Static |
2 |
imports Static_type OS_type_def Flask_type Flask |
|
3 |
begin |
|
4 |
||
5 |
locale tainting_s = tainting |
|
6 |
||
7 |
begin |
|
8 |
||
9 |
(* |
|
10 |
definition init_sectxt_of_file:: "t_file \<Rightarrow> security_context_t option" |
|
11 |
where |
|
12 |
"init_sectxt_of_file f \<equiv> |
|
13 |
if (is_init_file f) then init_sectxt_of_obj (O_file f) |
|
14 |
else if (is_init_dir f) then init_sectxt_of_obj (O_dir f) |
|
15 |
else None" |
|
16 |
*) |
|
17 |
||
18 |
definition sroot :: "t_sfile" |
|
19 |
where |
|
20 |
"sroot \<equiv> (Init [], sec_of_root, None, {})" |
|
21 |
||
22 |
definition init_cf2sfile :: "t_file \<Rightarrow> t_sfile option" |
|
23 |
where |
|
24 |
"init_cf2sfile f \<equiv> |
|
25 |
case (parent f) of |
|
26 |
None \<Rightarrow> Some sroot |
|
27 |
| Some pf \<Rightarrow> if (is_init_file f) then |
|
28 |
(case (init_sectxt_of_obj (O_file f), init_sectxt_of_obj (O_dir pf), get_parentfs_ctxts [] pf) of |
|
29 |
(Some sec, Some psec, Some aseclist) \<Rightarrow> Some (Init f, sec, Some psec, set aseclist) |
|
30 |
| _ \<Rightarrow> None) else |
|
31 |
(case (init_sectxt_of_obj (O_dir f), init_sectxt_of_obj (O_dir pf), get_parentfs_ctxts [] pf) of |
|
32 |
(Some sec, Some psec, Some aseclist) \<Rightarrow> Some (Init f, sec, Some psec, set aseclist) |
|
33 |
| _ \<Rightarrow> None)" |
|
34 |
||
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
35 |
definition init_cf2sfiles :: "t_file \<Rightarrow> t_sfile set" |
1 | 36 |
where |
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
37 |
"init_cf2sfiles f \<equiv> {sf. \<exists>f' \<in> init_same_inode_files f. init_cf2sfile f' = Some sf}" |
1 | 38 |
|
39 |
definition init_cfd2sfd :: "t_process \<Rightarrow> t_fd \<Rightarrow> (security_context_t \<times> t_open_flags \<times> t_sfile) option" |
|
40 |
where |
|
41 |
"init_cfd2sfd p fd = |
|
42 |
(case (init_file_of_proc_fd p fd, init_oflags_of_proc_fd p fd, init_sectxt_of_obj (O_fd p fd)) of |
|
43 |
(Some f, Some flags, Some sec) \<Rightarrow> (case (init_cf2sfile f) of |
|
44 |
Some sf \<Rightarrow> Some (sec, flags, sf) |
|
45 |
| _ \<Rightarrow> None) |
|
46 |
| _ \<Rightarrow> None)" |
|
47 |
||
48 |
definition init_cfds2sfds :: "t_process \<Rightarrow> (security_context_t \<times> t_open_flags \<times> t_sfile) set" |
|
49 |
where |
|
12 | 50 |
"init_cfds2sfds p \<equiv> { sfd. \<exists> fd \<in> init_proc_file_fds p. init_cfd2sfd p fd = Some sfd}" |
1 | 51 |
|
52 |
definition init_ch2sshm :: "t_shm \<Rightarrow> t_sshm option" |
|
53 |
where |
|
54 |
"init_ch2sshm h \<equiv> (case (init_sectxt_of_obj (O_shm h)) of |
|
55 |
Some sec \<Rightarrow> Some (Init h, sec) |
|
56 |
| _ \<Rightarrow> None)" |
|
57 |
||
58 |
definition init_cph2spshs |
|
59 |
:: "t_process \<Rightarrow> (t_sshm \<times> t_shm_attach_flag) set" |
|
60 |
where |
|
15 | 61 |
"init_cph2spshs p \<equiv> {(sh, flag)| sh flag h. (p, flag) \<in> init_procs_of_shm h \<and> |
1 | 62 |
init_ch2sshm h = Some sh}" |
63 |
||
64 |
definition init_cp2sproc :: "t_process \<Rightarrow> t_sproc option" |
|
65 |
where |
|
66 |
"init_cp2sproc p \<equiv> (case (init_sectxt_of_obj (O_proc p)) of |
|
67 |
Some sec \<Rightarrow> Some (Init p, sec, (init_cfds2sfds p), (init_cph2spshs p)) |
|
68 |
| None \<Rightarrow> None)" |
|
69 |
||
70 |
(* acient files of init-file |
|
71 |
definition init_o2s_afs :: "t_file \<Rightarrow> security_context_t set" |
|
72 |
where |
|
73 |
"init_o2s_afs f \<equiv> {sec. \<exists> f'. f' \<preceq> f \<and> init_sectxt_of_obj (O_dir f') = Some sec}" *) |
|
74 |
||
75 |
definition init_cm2smsg :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option" |
|
76 |
where |
|
77 |
"init_cm2smsg q m \<equiv> (case (init_sectxt_of_obj (O_msg q m)) of |
|
78 |
Some sec \<Rightarrow> Some (Init m, sec, (O_msg q m) \<in> seeds) |
|
79 |
| _ \<Rightarrow> None)" |
|
80 |
||
81 |
fun init_cqm2sms :: "t_msgq \<Rightarrow> t_msg list \<Rightarrow> (t_smsg list) option" |
|
82 |
where |
|
83 |
"init_cqm2sms q [] = Some []" |
|
84 |
| "init_cqm2sms q (m#ms) = |
|
85 |
(case (init_cqm2sms q ms, init_cm2smsg q m) of |
|
86 |
(Some sms, Some sm) \<Rightarrow> Some (sm # sms) |
|
87 |
| _ \<Rightarrow> None)" |
|
88 |
||
89 |
definition init_cq2smsgq :: "t_msgq \<Rightarrow> t_smsgq option" |
|
90 |
where |
|
91 |
"init_cq2smsgq q \<equiv> (case (init_sectxt_of_obj (O_msgq q), init_cqm2sms q (init_msgs_of_queue q)) of |
|
92 |
(Some sec, Some sms) \<Rightarrow> Some (Init q, sec, sms) |
|
93 |
| _ \<Rightarrow> None)" |
|
94 |
||
95 |
fun init_obj2sobj :: "t_object \<Rightarrow> t_sobject option" |
|
96 |
where |
|
97 |
"init_obj2sobj (O_proc p) = |
|
98 |
(case (init_cp2sproc p) of |
|
99 |
Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> seeds)) |
|
100 |
| _ \<Rightarrow> None)" |
|
101 |
| "init_obj2sobj (O_file f) = |
|
37
029cccce84b4
remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents:
34
diff
changeset
|
102 |
Some (S_file (init_cf2sfiles f) |
029cccce84b4
remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents:
34
diff
changeset
|
103 |
(\<exists> f'. f' \<in> (init_same_inode_files f) \<and> O_file f \<in> seeds))" |
029cccce84b4
remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents:
34
diff
changeset
|
104 |
| "init_obj2sobj (O_dir f) = |
029cccce84b4
remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents:
34
diff
changeset
|
105 |
(case (init_cf2sfile f) of |
029cccce84b4
remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents:
34
diff
changeset
|
106 |
Some sf \<Rightarrow> Some (S_dir sf) |
029cccce84b4
remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents:
34
diff
changeset
|
107 |
| _ \<Rightarrow> None)" |
1 | 108 |
| "init_obj2sobj (O_msgq q) = |
109 |
(case (init_cq2smsgq q) of |
|
110 |
Some sq \<Rightarrow> Some (S_msgq sq) |
|
111 |
| _ \<Rightarrow> None)" |
|
112 |
| "init_obj2sobj (O_shm h) = |
|
113 |
(case (init_ch2sshm h) of |
|
114 |
Some sh \<Rightarrow> Some (S_shm sh) |
|
34 | 115 |
| _ \<Rightarrow> None)" (* |
1 | 116 |
| "init_obj2sobj (O_msg q m) = |
117 |
(case (init_cq2smsgq q, init_cm2smsg q m) of |
|
118 |
(Some sq, Some sm) \<Rightarrow> Some (S_msg sq sm) |
|
34 | 119 |
| _ \<Rightarrow> None)" *) |
1 | 120 |
| "init_obj2sobj _ = None" |
121 |
||
122 |
definition |
|
123 |
"init_static_state \<equiv> {sobj. \<exists> obj. init_alive obj \<and> init_obj2sobj obj = Some sobj}" |
|
124 |
||
125 |
fun is_init_sfile :: "t_sfile \<Rightarrow> bool" |
|
126 |
where |
|
127 |
"is_init_sfile (Init _, sec, psec,asec) = True" |
|
128 |
| "is_init_sfile _ = False" |
|
129 |
||
130 |
fun is_many_sfile :: "t_sfile \<Rightarrow> bool" |
|
131 |
where |
|
132 |
"is_many_sfile (Created, sec, psec, asec) = True" |
|
133 |
| "is_many_sfile _ = False" |
|
134 |
||
135 |
fun is_init_sproc :: "t_sproc \<Rightarrow> bool" |
|
136 |
where |
|
137 |
"is_init_sproc (Init p, sec, fds, shms) = True" |
|
138 |
| "is_init_sproc _ = False" |
|
139 |
||
140 |
fun is_many_sproc :: "t_sproc \<Rightarrow> bool" |
|
141 |
where |
|
142 |
"is_many_sproc (Created, sec,fds,shms) = True" |
|
143 |
| "is_many_sproc _ = False" |
|
144 |
||
145 |
fun is_many_smsg :: "t_smsg \<Rightarrow> bool" |
|
146 |
where |
|
147 |
"is_many_smsg (Created,sec,tag) = True" |
|
148 |
| "is_many_smsg _ = False" |
|
149 |
||
150 |
fun is_many_smsgq :: "t_smsgq \<Rightarrow> bool" |
|
151 |
where |
|
152 |
"is_many_smsgq (Created,sec,sms) = (True \<and> (\<forall> sm \<in> (set sms). is_many_smsg sm))" |
|
153 |
| "is_many_smsgq _ = False" |
|
154 |
||
155 |
fun is_many_sshm :: "t_sshm \<Rightarrow> bool" |
|
156 |
where |
|
157 |
"is_many_sshm (Created, sec) = True" |
|
158 |
| "is_many_sshm _ = False" |
|
159 |
||
160 |
(* |
|
161 |
fun is_init_sobj :: "t_sobject \<Rightarrow> bool" |
|
162 |
where |
|
163 |
"is_init_sobj (S_proc (popt, sec, fds, shms) tag) = (popt \<noteq> None)" |
|
164 |
| "is_init_sobj (S_file sf tag) = (is_init_sfile sf)" |
|
165 |
| "is_init_sobj (S_dir sf tag) = (is_init_sfile sf)" |
|
166 |
| "is_init_sobj (S_msg" *) |
|
167 |
||
168 |
fun is_many :: "t_sobject \<Rightarrow> bool" |
|
169 |
where |
|
170 |
"is_many (S_proc (Many, sec, fds, shms) tag) = True" |
|
171 |
| "is_many (S_file sfs tag) = (\<forall> sf \<in> sfs. is_many_sfile sf)" |
|
172 |
| "is_many (S_dir sf ) = is_many_sfile sf" |
|
173 |
| "is_many (S_msgq sq ) = is_many_smsgq sq" |
|
174 |
| "is_many (S_shm sh ) = is_many_sshm sh" |
|
175 |
||
176 |
(* |
|
177 |
fun update_ss_sp:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state" |
|
178 |
where |
|
179 |
"update_ss_sp ss (S_proc sp tag) (S_proc sp' tag') = |
|
180 |
(if (is_many_sproc sp) then ss \<union> {S_proc sp' tag'} |
|
181 |
else (ss - {S_proc sp tag}) \<union> {S_proc sp' tag'})" |
|
182 |
||
183 |
fun update_ss_sd:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state" |
|
184 |
where |
|
185 |
"update_ss_sd ss (S_dir sf tag) (S_dir sf' tag') = |
|
186 |
(if (is_many_sfile sf) then ss \<union> {S_dir sf' tag'} |
|
187 |
else (ss - {S_dir sf tag}) \<union> {S_dir sf' tag'})" |
|
188 |
*) |
|
189 |
||
190 |
definition update_ss :: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state" |
|
191 |
where |
|
192 |
"update_ss ss so so' \<equiv> if (is_many so) then ss \<union> {so'} else (ss - {so}) \<union> {so'}" |
|
193 |
||
194 |
definition add_ss :: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_static_state" |
|
195 |
where |
|
196 |
"add_ss ss so \<equiv> ss \<union> {so}" |
|
197 |
||
198 |
definition del_ss :: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_static_state" |
|
199 |
where |
|
200 |
"del_ss ss so \<equiv> if (is_many so) then ss else ss - {so}" |
|
201 |
||
202 |
(* |
|
203 |
fun sparent :: "t_sfile \<Rightarrow> t_sfile option" |
|
204 |
where |
|
205 |
"sparent (Sroot si sec) = None" |
|
206 |
| "sparent (Sfile si sec spf) = Some spf" |
|
207 |
||
208 |
inductive is_ancesf :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
209 |
where |
|
210 |
"is_ancesf sf sf" |
|
211 |
| "sparent sf = Some spf \<Longrightarrow> is_ancesf spf sf" |
|
212 |
| "\<lbrakk>sparent sf = Some spf; is_ancesf saf spf\<rbrakk> \<Longrightarrow> is_ancesf saf sf" |
|
213 |
||
214 |
definition sfile_reparent :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile" |
|
215 |
where |
|
216 |
"sfile_reparent (Sroot)" |
|
217 |
*) |
|
218 |
||
219 |
(* |
|
220 |
(* sfds rename aux definitions *) |
|
221 |
definition sfds_rename_notrelated |
|
222 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
223 |
where |
|
224 |
"sfds_rename_notrelated sfds from to sfds' \<equiv> |
|
225 |
(\<forall> sec flag sf. (sec,flag,sf) \<in> sfds \<and> (\<not> from \<preceq> sf) \<longrightarrow> (sec,flag,sf) \<in> sfds')" |
|
226 |
||
227 |
definition sfds_rename_renamed |
|
228 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
229 |
where |
|
230 |
"sfds_rename_renamed sfds sf from to sfds' \<equiv> |
|
231 |
(\<forall> sec flag sf'. (sec,flag,sf) \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> |
|
232 |
(sec, flag, file_after_rename sf' from to) \<in> sfds' \<and> (sec,flag,sf) \<notin> sfds')" |
|
233 |
||
234 |
definition sfds_rename_remain |
|
235 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
236 |
where |
|
237 |
"sfds_rename_remain sfds sf from to sfds' \<equiv> |
|
238 |
(\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> |
|
239 |
(sec, flag, sf') \<in> sfds' \<and> (sec,flag, file_after_rename sf' from to) \<notin> sfds')" |
|
240 |
||
241 |
(* for not many, choose on renamed or not *) |
|
242 |
definition sfds_rename_choices |
|
243 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
244 |
where |
|
245 |
"sfds_rename_choices sfds sf from to sfds' \<equiv> |
|
246 |
sfds_rename_remain sfds sf from to sfds' \<or> sfds_rename_renamed sfds sf from to sfds'" |
|
247 |
||
248 |
(* for many, merge renamed with not renamed *) |
|
249 |
definition sfds_rename_both |
|
250 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
251 |
where |
|
252 |
"sfds_rename_both sfds sf from to sfds' \<equiv> |
|
253 |
(\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> |
|
254 |
(sec, flag, sf') \<in> sfds' \<or> (sec,flag, file_after_rename sf' from to) \<in> sfds')" |
|
255 |
||
256 |
(* added to the new sfds, are those only under the new sfile *) |
|
257 |
definition sfds_rename_added |
|
258 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
259 |
where |
|
260 |
"sfds_rename_added sfds from to sfds' \<equiv> |
|
261 |
(\<forall> sec' flag' sf' sec flag. (sec',flag',sf') \<in> sfds' \<and> (sec,flag,sf') \<notin> sfds \<longrightarrow> |
|
262 |
(\<exists> sf. (sec,flag,sf) \<in> sfds \<and> sf' = file_after_rename from to sf))" |
|
263 |
||
264 |
definition sproc_sfds_renamed |
|
265 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
266 |
where |
|
267 |
"sproc_sfds_renamed ss sf from to ss' \<equiv> |
|
268 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
269 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_renamed sfds sf from to sfds'))" |
|
270 |
||
271 |
definition sproc_sfds_remain |
|
272 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
273 |
where |
|
274 |
"sproc_sfds_remain ss sf from to ss' \<equiv> |
|
275 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
276 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_remain sfds sf from to sfds'))" |
|
277 |
||
278 |
(* for not many, choose on renamed or not *) |
|
279 |
definition sproc_sfds_choices |
|
280 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
281 |
where |
|
282 |
"sproc_sfds_choices ss sf from to ss' \<equiv> |
|
283 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
284 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_choices sfds sf from to sfds'))" |
|
285 |
||
286 |
(* for many, merge renamed with not renamed *) |
|
287 |
definition sproc_sfds_both |
|
288 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
289 |
where |
|
290 |
"sproc_sfds_both ss sf from to ss' \<equiv> |
|
291 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
292 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_both sfds sf from to sfds'))" |
|
293 |
||
294 |
(* remove (\<forall> sp tag. S_proc sp tag \<in> ss \<longrightarrow> S_proc sp tag \<in> ss'), |
|
295 |
* cause sfds contains sfs informations *) |
|
296 |
definition ss_rename_notrelated |
|
297 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
298 |
where |
|
299 |
"ss_rename_notrelated ss sf sf' ss' \<equiv> |
|
300 |
(\<forall> sq. S_msgq sq \<in> ss \<longrightarrow> S_msgq sq \<in> ss') \<and> |
|
301 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> (\<exists> sfds'. |
|
302 |
S_proc (pi,sec,sfds',sshms) tagp \<in> ss'\<and> sfds_rename_notrelated sfds sf sf' sfds')) \<and> |
|
303 |
(\<forall> sfs sf'' tag. S_file sfs tag \<in> ss \<and> sf'' \<in> sfs \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> (\<exists> sfs'. |
|
304 |
S_file sfs tag \<in> ss' \<and> sf'' \<in> sfs')) \<and> |
|
305 |
(\<forall> sf'' tag. S_dir sf'' tag \<in> ss \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> S_dir sf'' tag \<in> ss')" |
|
306 |
||
307 |
(* rename from to, from should definited renamed if not many *) |
|
308 |
definition all_descendant_sf_renamed |
|
309 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
310 |
where |
|
311 |
"all_descendant_sf_renamed ss sf from to ss' \<equiv> |
|
312 |
(\<forall> sfs sf' tagf. sf \<preceq> sf' \<and> S_file sfs tagf \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. |
|
313 |
S_file sfs' tagf \<in> ss' \<and> file_after_rename from to sf' \<in> sfs' \<and> sf' \<notin> sfs')) \<and> |
|
314 |
(\<forall> sf' tagf. sf \<preceq> sf' \<and> S_dir sf' tagf \<in> ss \<longrightarrow> S_dir (file_after_rename from to sf') tagf \<in> ss' \<and> S_dir sf' tagf \<notin> ss') \<and> |
|
315 |
sproc_sfds_renamed ss sf from to ss'" |
|
316 |
||
317 |
(* not renamed *) |
|
318 |
definition all_descendant_sf_remain |
|
319 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
320 |
where |
|
321 |
"all_descendant_sf_remain ss sf from to ss' \<equiv> |
|
322 |
(\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. |
|
323 |
S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<notin> sfs' \<and> sf' \<in> sfs')) \<and> |
|
324 |
(\<forall> sf' tag'. sf \<preceq> sf' \<and> S_dir sf' tag' \<in> ss \<longrightarrow> S_dir (file_after_rename from to sf') tag' \<notin> ss' \<and> S_dir sf' tag' \<in> ss') \<and> |
|
325 |
sproc_sfds_remain ss sf from to ss'" |
|
326 |
||
327 |
definition all_descendant_sf_choices |
|
328 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
329 |
where |
|
330 |
"all_descendant_sf_choices ss sf from to ss' \<equiv> |
|
331 |
all_descendant_sf_renamed ss sf from to ss' \<or> all_descendant_sf_remain ss sf from to ss'" |
|
332 |
||
333 |
definition all_descendant_sf_both |
|
334 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
335 |
where |
|
336 |
"all_descendant_sf_both ss sf from to ss' \<equiv> |
|
337 |
(\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. |
|
338 |
S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<in> sfs' \<or> sf' \<in> sfs')) \<and> |
|
339 |
(\<forall> sf' tag'. sf \<preceq> sf' \<and> S_dir sf' tag' \<in> ss \<longrightarrow> |
|
340 |
S_dir (file_after_rename from to sf') tag' \<in> ss' \<or> S_dir sf' tag' \<in> ss') \<and> |
|
341 |
sproc_sfds_both ss sf from to ss'" |
|
342 |
||
343 |
definition ss_renamed_file |
|
344 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
345 |
where |
|
346 |
"ss_renamed_file ss sf sf' ss' \<equiv> |
|
347 |
(if (is_many_sfile sf) |
|
348 |
then all_descendant_sf_choices ss sf sf sf' ss' |
|
349 |
else all_descendant_sf_renamed ss sf sf sf' ss')" |
|
350 |
||
351 |
(* added to the new sfs, are those only under the new sfile *) |
|
352 |
definition sfs_rename_added |
|
353 |
:: "t_sfile set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile set \<Rightarrow> bool" |
|
354 |
where |
|
355 |
"sfs_rename_added sfs from to sfs' \<equiv> |
|
356 |
(\<forall> sf'. sf' \<in> sfs' \<and> sf' \<notin> sfs \<longrightarrow> (\<exists> sf. sf \<in> sfs \<and> sf' = file_after_rename from to sf))" |
|
357 |
||
358 |
(* added to the new sfile, are those only under the new sfile *) |
|
359 |
definition ss_rename_added |
|
360 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
361 |
where |
|
362 |
"ss_rename_added ss from to ss' \<equiv> |
|
363 |
(\<forall> pi sec fds fds' shms tagp. S_proc (pi, sec, fds,shms) tagp \<in> ss \<and> |
|
364 |
S_proc (pi,sec,fds',shms) tagp \<in> ss' \<longrightarrow> sfds_rename_added fds from to fds') \<and> |
|
365 |
(\<forall> sq. S_msgq sq \<in> ss' \<longrightarrow> S_msgq sq \<in> ss) \<and> |
|
366 |
(\<forall> sfs sfs' tagf. S_file sfs' tagf \<in> ss' \<and> S_file sfs tagf \<in> ss \<longrightarrow> |
|
367 |
sfs_rename_added sfs from to sfs') \<and> |
|
368 |
(\<forall> sf' tagf. S_dir sf' tagf \<in> ss' \<and> S_dir sf' tagf \<notin> ss \<longrightarrow> |
|
369 |
(\<exists> sf. S_dir sf tagf \<in> ss \<and> sf' = file_after_rename from to sf))" |
|
370 |
||
371 |
definition sfile_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
372 |
where |
|
373 |
"sfile_alive ss sf \<equiv> (\<exists> sfs tagf. sf \<in> sfs \<and> S_file sfs tagf \<in> ss)" |
|
374 |
||
375 |
definition sf_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
376 |
where |
|
377 |
"sf_alive ss sf \<equiv> (\<exists> tagd. S_dir sf tagd \<in> ss) \<or> sfile_alive ss sf" |
|
378 |
||
379 |
(* constrains that the new static state should satisfy *) |
|
380 |
definition ss_rename:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
381 |
where |
|
382 |
"ss_rename ss sf sf' ss' \<equiv> |
|
383 |
ss_rename_notrelated ss sf sf' ss' \<and> |
|
384 |
ss_renamed_file ss sf sf' ss' \<and> ss_rename_added ss sf sf' ss' \<and> |
|
385 |
(\<forall> sf''. sf_alive ss sf'' \<and> sf \<prec> sf'' \<longrightarrow> |
|
386 |
(if (is_many_sfile sf'') |
|
387 |
then all_descendant_sf_choices ss sf'' sf sf' ss' |
|
388 |
else all_descendant_sf_both ss sf'' sf sf' ss'))" |
|
389 |
||
390 |
(* two sfile, the last fname should not be equal *) |
|
391 |
fun sfile_same_fname:: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
392 |
where |
|
393 |
"sfile_same_fname ((Init n, sec)#spf) ((Init n', sec')#spf') = (n = n')" |
|
394 |
| "sfile_same_fname _ _ = False" |
|
395 |
||
396 |
(* no same init sfile/only sfile in the target-to spf, should be in static_state addmissble check *) |
|
397 |
definition ss_rename_no_same_fname:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
398 |
where |
|
399 |
"ss_rename_no_same_fname ss from spf \<equiv> |
|
400 |
\<not> (\<exists> to. sfile_same_fname from to \<and> parent to = Some spf \<and> sf_alive ss to)" |
|
401 |
||
402 |
(* is not a function, is a relation (one 2 many) |
|
403 |
definition update_ss_rename :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state" |
|
404 |
where |
|
405 |
"update_ss_rename ss sf sf' \<equiv> if (is_many_sfile sf) |
|
406 |
then (ss \<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss} |
|
407 |
\<union> {S_dir (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}) |
|
408 |
else (ss - {S_file sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss} |
|
409 |
- {S_dir sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}) |
|
410 |
\<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss} |
|
411 |
\<union> {S_dir (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}" |
|
412 |
*) |
|
413 |
*) |
|
414 |
||
415 |
fun sectxt_of_sproc :: "t_sproc \<Rightarrow> security_context_t" |
|
416 |
where |
|
417 |
"sectxt_of_sproc (pi,sec,fds,shms) = sec" |
|
418 |
||
419 |
fun sectxt_of_sfile :: "t_sfile \<Rightarrow> security_context_t" |
|
420 |
where |
|
421 |
"sectxt_of_sfile (fi,sec,psec,asecs) = sec" |
|
422 |
||
423 |
fun asecs_of_sfile :: "t_sfile \<Rightarrow> security_context_t set" |
|
424 |
where |
|
425 |
"asecs_of_sfile (fi,sec,psec,asecs) = asecs" |
|
426 |
||
427 |
definition search_check_s :: "security_context_t \<Rightarrow> t_sfile \<Rightarrow> bool \<Rightarrow> bool" |
|
428 |
where |
|
429 |
"search_check_s pctxt sf if_file = |
|
430 |
(if if_file |
|
431 |
then search_check_file pctxt (sectxt_of_sfile sf) \<and> search_check_allp pctxt (asecs_of_sfile sf) |
|
432 |
else search_check_dir pctxt (sectxt_of_sfile sf) \<and> search_check_allp pctxt (asecs_of_sfile sf))" |
|
433 |
||
434 |
definition sectxts_of_sfds :: "t_sfd set \<Rightarrow> security_context_t set" |
|
435 |
where |
|
436 |
"sectxts_of_sfds sfds \<equiv> {ctxt. \<exists> flag sf. (ctxt, flag, sf) \<in> sfds}" |
|
437 |
||
438 |
definition inherit_fds_check_s :: "security_context_t \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
439 |
where |
|
440 |
"inherit_fds_check_s pctxt sfds \<equiv> |
|
441 |
(\<forall> ctxt \<in> sectxts_of_sfds sfds. permission_check pctxt ctxt C_fd P_inherit)" |
|
442 |
||
443 |
definition sectxts_of_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> security_context_t set" |
|
444 |
where |
|
445 |
"sectxts_of_sproc_sshms sshms \<equiv> {ctxt. \<exists> hi flag. ((hi, ctxt),flag) \<in> sshms}" |
|
446 |
||
447 |
definition inherit_shms_check_s :: "security_context_t \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool" |
|
448 |
where |
|
449 |
"inherit_shms_check_s pctxt sshms \<equiv> |
|
450 |
(\<forall> ctxt \<in> sectxts_of_sproc_sshms sshms. permission_check pctxt ctxt C_shm P_inherit)" |
|
451 |
||
452 |
(* |
|
453 |
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool" |
|
454 |
where |
|
455 |
"info_flow_sshm (pi,sec,fds,shms) (pi',sec',fds',shms') = |
|
456 |
(\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" |
|
457 |
*) |
|
458 |
definition info_flow_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool" |
|
459 |
where |
|
460 |
"info_flow_sproc_sshms shms shms' \<equiv> (\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" |
|
461 |
||
25
259a50be4381
wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents:
20
diff
changeset
|
462 |
(* |
1 | 463 |
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool" |
464 |
where |
|
465 |
"info_flow_sshm (pi,sec,fds,shms) (pi',sec',fds',shms') = info_flow_sproc_sshms shms shms'" |
|
25
259a50be4381
wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents:
20
diff
changeset
|
466 |
*) |
259a50be4381
wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents:
20
diff
changeset
|
467 |
inductive info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool" |
259a50be4381
wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents:
20
diff
changeset
|
468 |
where |
259a50be4381
wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents:
20
diff
changeset
|
469 |
"info_flow_sshm sp sp" |
259a50be4381
wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents:
20
diff
changeset
|
470 |
| "\<lbrakk>info_flow_sshm sp (pi,sec,fds,shms); info_flow_sproc_sshms shms shms'\<rbrakk> |
259a50be4381
wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents:
20
diff
changeset
|
471 |
\<Longrightarrow> info_flow_sshm sp (pi',sec',fds',shms')" |
1 | 472 |
|
473 |
definition update_ss_shms :: "t_static_state \<Rightarrow> t_sproc \<Rightarrow> bool \<Rightarrow> t_static_state" |
|
474 |
where |
|
475 |
"update_ss_shms ss spfrom tag \<equiv> {sobj. \<exists> sobj' \<in> ss. |
|
476 |
(case sobj' of |
|
477 |
S_proc sp tagp \<Rightarrow> if (info_flow_sshm spfrom sp) |
|
478 |
then if (is_many_sproc sp) |
|
479 |
then (sobj = S_proc sp tagp \<or> sobj = S_proc sp (tagp \<or> tag)) |
|
480 |
else (sobj = S_proc sp (tagp \<or> tag)) |
|
481 |
else (sobj = S_proc sp tag) |
|
482 |
| _ \<Rightarrow> sobj = sobj')}" |
|
483 |
||
484 |
||
485 |
||
486 |
(* all reachable static states(sobjects set) *) |
|
487 |
inductive_set static :: "t_static_state set" |
|
488 |
where |
|
489 |
s_init: "init_static_state \<in> static" |
|
490 |
| s_execve: "\<lbrakk>ss \<in> static; S_proc (pi, pctxt, fds, shms) tagp \<in> ss; S_file sfs tagf \<in> ss; |
|
491 |
(fi,fsec,pfsec,asecs) \<in> sfs; npctxt_execve pctxt fsec = Some pctxt'; |
|
492 |
grant_execve pctxt fsec pctxt'; search_check_s pctxt (fi,fsec,pfsec,asecs) True; |
|
493 |
inherit_fds_check_s pctxt' fds'; fds' \<subseteq> fds\<rbrakk> |
|
494 |
\<Longrightarrow> (update_ss ss (S_proc (pi, pctxt, fds, shms) tagp) |
|
495 |
(S_proc (pi, pctxt', fds', {}) (tagp \<or> tagf))) \<in> static" |
|
496 |
| s_clone: "\<lbrakk>ss \<in> static; S_proc (pi, pctxt, fds, shms) tagp \<in> ss; |
|
497 |
permission_check pctxt pctxt C_process P_fork; |
|
498 |
inherit_fds_check_s pctxt fds'; fds' \<subseteq> fds; |
|
499 |
inherit_shms_check_s pctxt shms'; shms' \<subseteq> shms\<rbrakk> |
|
500 |
\<Longrightarrow> (add_ss ss (S_proc (Created, pctxt, fds', shms') tagp)) \<in> static" |
|
501 |
| s_kill: "\<lbrakk>ss \<in> static; S_proc (pi, pctxt, fds, shms) tagp \<in> ss; |
|
502 |
S_proc (pi', pctxt', fds', shms') tagp' \<in> ss; |
|
503 |
permission_check pctxt pctxt' C_process P_sigkill\<rbrakk> |
|
504 |
\<Longrightarrow> (del_ss ss (S_proc (pi', pctxt', fds', shms') tagp')) \<in> static" |
|
505 |
| s_ptrace: "\<lbrakk>ss \<in> static; S_proc sp tagp \<in> ss; S_proc sp' tagp' \<in> ss; |
|
506 |
permission_check (sextxt_of_sproc sp) (sectxt_of_sproc sp') C_process P_ptrace\<rbrakk> |
|
507 |
\<Longrightarrow> (update_ss_shms (update_ss_shms ss sp tagp) sp' tagp') \<in> static" |
|
508 |
| s_exit: "\<lbrakk>ss \<in> static; S_proc sp tagp \<in> ss\<rbrakk> \<Longrightarrow> (del_ss ss (S_proc sp tagp)) \<in> static" |
|
509 |
| s_open: "\<lbrakk>ss \<in> static; S_proc (pi, pctxt, fds, shms) tagp \<in> ss; S_file sfs tagf \<in> ss; sf \<in> sfs; |
|
510 |
search_check_s pctxt sf True; \<not> is_creat_excl_flag flags; |
|
511 |
oflags_check flags pctxt (sectxt_of_sfile sf); permission_check pctxt pctxt C_fd P_setattr\<rbrakk> |
|
512 |
\<Longrightarrow> (update_ss ss (S_proc (pi, pctxt, fds, shms) tagp) |
|
513 |
(S_proc (pi, pctxt, fds \<union> {(pctxt,flags,sf)}, shms) tagp)) \<in> static" |
|
514 |
| s_open': "\<lbrakk>ss \<in> static; S_proc (pi, pctxt, fds, shms) tagp \<in> ss; is_creat_excl_flag flags; |
|
515 |
S_dir (pfi,fsec,pfsec,asecs) \<in> ss; search_check_s pctxt (pfi,fsec,pfsec,asecs) False; |
|
516 |
nfsec = nfctxt_create pctxt fsec C_file; oflags_check flags pctxt nfsec; |
|
517 |
permission_check pctxt fsec C_dir P_add_rename; permission_check pctxt pctxt C_fd P_setattr\<rbrakk> |
|
518 |
\<Longrightarrow> (update_ss (add_ss ss (S_file {(Created, nfsec, Some fsec, asecs \<union> {fsec})} tagp)) |
|
519 |
(S_proc (pi, pctxt, fds, shms) tagp) |
|
520 |
(S_proc (pi, pctxt, fds \<union> {(pctxt, flags, (Created, nfsec, Some fsec, asecs \<union> {fsec}))}, shms) tagp) |
|
521 |
) \<in> static" |
|
522 |
| S_readf: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; (fdctxt,flags,sf) \<in> fds; |
|
523 |
permission_check pctxt fdctxt C_fd P_setattr; S_file sfs tagf \<in> ss; sf \<in> sfs; |
|
524 |
permission_check pctxt (sectxt_of_sfile sf) C_file P_read; is_read_flag flags\<rbrakk> |
|
525 |
\<Longrightarrow> (update_ss_shms ss (pi, pctxt,fds,shms) (tagp \<or> tagf)) \<in> static" |
|
526 |
| S_writef: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; (fdctxt,flags,sf) \<in> fds; |
|
527 |
permission_check pctxt fdctxt C_fd P_setattr; sf \<in> sfs; S_file sfs tagf \<in> ss; |
|
528 |
permission_check pctxt (sectxt_of_sfile sf) C_file P_write; is_write_flag flags\<rbrakk> |
|
529 |
\<Longrightarrow> (update_ss ss (S_file sfs tagf) (S_file sfs (tagp \<or> tagf))) \<in> static" |
|
530 |
| S_unlink: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_file sfs tagf \<in> ss; |
|
531 |
(Init f,fsec,Some pfsec,asecs) \<in> sfs; |
|
532 |
search_check_s pctxt (Init f,fsec,Some pfsec,asecs) True; |
|
533 |
permission_check pctxt fsec C_file P_unlink; |
|
534 |
permission_check pctxt pfsec C_dir P_remove_name\<rbrakk> |
|
535 |
\<Longrightarrow> ((ss - {S_file sfs tagf}) \<union> {S_file (sfs - {(Init f,fsec,Some pfsec,asecs)}) tagf}) \<in> static" |
|
536 |
| S_rmdir: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; |
|
537 |
S_dir (fi,fsec,Some pfsec,asecs) \<in> ss; |
|
538 |
search_check_s pctxt (fi,fsec,Some pfsec,asecs) False; |
|
539 |
permission_check pctxt fsec C_dir P_rmdir; |
|
540 |
permission_check pctxt pfsec C_dir P_remove_name\<rbrakk> |
|
541 |
\<Longrightarrow> (del_ss ss (S_dir (fi,fsec,Some pfsec,asecs))) \<in> static" |
|
542 |
| S_mkdir: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_dir (fi,fsec,pfsec,asecs) \<in> ss; |
|
543 |
search_check_s pctxt (fi,fsec,pfsec,asecs) False; |
|
544 |
permission_check pctxt (nfctxt_create pctxt fsec C_dir) C_dir P_create; |
|
545 |
permission_check pctxt fsec C_dir P_add_name\<rbrakk> |
|
546 |
\<Longrightarrow> (add_ss ss (S_dir (Created,nfctxt_create pctxt fsec C_dir,Some fsec,asecs \<union> {fsec}))) \<in> static" |
|
547 |
| s_link: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_dir (pfi,pfsec,ppfsec,asecs) \<in> ss; |
|
548 |
S_file sfs tagf \<in> ss; sf \<in> sfs; nfsec = nfctxt_create pctxt pfsec C_file; |
|
549 |
search_check_s pctxt (pfi,pfsec,ppfsec,asecs) False; search_check_s pctxt sf True; |
|
550 |
permission_check pctxt (sectxt_of_sfile sf) C_file P_link; |
|
551 |
permission_check pctxt pfsec C_dir P_add_name\<rbrakk> |
|
552 |
\<Longrightarrow> (update_ss ss (S_file sfs tagf) |
|
553 |
(S_file (sfs \<union> {(Created,nfsec,Some pfsec, asecs \<union> {pfsec})}) tagf)) \<in> static" |
|
554 |
| s_trunc: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_file sfs tagf \<in> ss; sf \<in> sfs; |
|
555 |
search_check_s pctxt sf True; permission_check pctxt (sectxt_of_sfile sf) C_file P_setattr\<rbrakk> |
|
556 |
\<Longrightarrow> (update_ss ss (S_file sfs tagf) (S_file sfs (tagf \<or> tagp))) \<in> static" |
|
557 |
(* |
|
558 |
| s_rename: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_file sfs tagf \<in> ss; |
|
559 |
(sf#spf') \<in> sfs; S_dir spf tagpf \<in> ss; \<not>((sf#spf') \<preceq> (sf#spf)); |
|
560 |
search_check_s pctxt spf False; search_check_s pctxt (sf#spf') True; |
|
561 |
sectxt_of_sfile (sf#spf') = Some fctxt; sectxt_of_sfile spf = Some pfctxt; |
|
562 |
permission_check pctxt fctxt C_file P_rename; |
|
563 |
permission_check pctxt pfctxt C_dir P_add_name; |
|
564 |
ss_rename ss (sf#spf') (sf#spf) ss'; |
|
565 |
ss_rename_no_same_fname ss (sf#spf') (sf#spf)\<rbrakk> |
|
566 |
\<Longrightarrow> ss' \<in> static" |
|
567 |
| s_rename': "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_dir (sf#spf') tagf \<in> ss; |
|
568 |
S_dir spf tagpf \<in> ss; \<not>((sf#spf') \<preceq> (sf#spf)); |
|
569 |
search_check_s pctxt spf False; search_check_s pctxt (sf#spf') True; |
|
570 |
sectxt_of_sfile (sf#spf') = Some fctxt; sectxt_of_sfile spf = Some pfctxt; |
|
571 |
permission_check pctxt fctxt C_dir P_reparent; |
|
572 |
permission_check pctxt pfctxt C_dir P_add_name; |
|
573 |
ss_rename ss (sf#spf') (sf#spf) ss'; |
|
574 |
ss_rename_no_same_fname ss (sf#spf') (sf#spf)\<rbrakk> |
|
575 |
\<Longrightarrow> ss' \<in> static" |
|
576 |
*) |
|
577 |
| s_createq: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; |
|
578 |
permission_check pctxt pctxt C_msgq P_associate; |
|
579 |
permission_check pctxt pctxt C_msgq P_create\<rbrakk> |
|
580 |
\<Longrightarrow> (add_ss ss (S_msgq (Created,pctxt,[]))) \<in> static" |
|
581 |
| s_sendmsg: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_msgq (qi,qctxt,sms) \<in> ss; |
|
582 |
permission_check pctxt qctxt C_msgq P_enqueue; |
|
583 |
permission_check pctxt qctxt C_msgq P_write; |
|
584 |
permission_check pctxt pctxt C_msg P_create\<rbrakk> |
|
585 |
\<Longrightarrow> (update_ss ss (S_msgq (qi,qctxt,sms)) |
|
586 |
(S_msgq (qi,qctxt,sms @ [(Created, pctxt, tagp)]))) \<in> static" |
|
587 |
| s_recvmsg: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; |
|
588 |
S_msgq (qi,qctxt,(mi,mctxt,tagm)#sms) \<in> ss; |
|
589 |
permission_check pctxt qctxt C_msgq P_read; |
|
590 |
permission_check pctxt mctxt C_msg P_receive\<rbrakk> |
|
33
6884b3c9284b
fix bug of static.thy for the static of recvmsg case
chunhan
parents:
25
diff
changeset
|
591 |
\<Longrightarrow> (update_ss (update_ss_shms ss (pi,pctxt,fds,shms) (tagp \<or> tagm)) |
6884b3c9284b
fix bug of static.thy for the static of recvmsg case
chunhan
parents:
25
diff
changeset
|
592 |
(S_msgq (qi, qctxt, (mi, mctxt, tagm)#sms)) |
6884b3c9284b
fix bug of static.thy for the static of recvmsg case
chunhan
parents:
25
diff
changeset
|
593 |
(S_msgq (qi, qctxt, sms))) \<in> static" |
1 | 594 |
| s_removeq: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_msgq (qi,qctxt,sms) \<in> ss; |
595 |
permission_check pctxt qctxt C_msgq P_destroy\<rbrakk> |
|
596 |
\<Longrightarrow> (del_ss ss (S_msgq (qi,qctxt,sms))) \<in> static" |
|
597 |
| s_createh: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; |
|
598 |
permission_check pctxt pctxt C_shm P_associate; |
|
599 |
permission_check pctxt pctxt C_shm P_create\<rbrakk> |
|
600 |
\<Longrightarrow> (add_ss ss (S_shm (Created, pctxt))) \<in> static" |
|
601 |
| s_attach: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_shm (hi,hctxt) \<in> ss; |
|
602 |
if flag = SHM_RDONLY then permission_check pctxt hctxt C_shm P_read |
|
603 |
else (permission_check pctxt hctxt C_shm P_read \<and> |
|
604 |
permission_check pctxt hctxt C_shm P_write)\<rbrakk> |
|
605 |
\<Longrightarrow> (update_ss ss (S_proc (pi,pctxt,fds,shms) tagp) |
|
606 |
(S_proc (pi,pctxt,fds,shms \<union> {((hi,hctxt),flag)}) tagp)) \<in> static" |
|
607 |
| s_detach: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_shm sh \<in> ss; |
|
608 |
(sh,flag) \<in> shms; \<not> is_many_sshm sh\<rbrakk> |
|
609 |
\<Longrightarrow> (update_ss ss (S_proc (pi,pctxt,fds,shms) tagp) |
|
610 |
(S_proc (pi,pctxt,fds,shms - {(sh,flag)}) tagp)) \<in> static" |
|
611 |
| s_deleteh: "\<lbrakk>ss \<in> static; S_proc (pi,pctxt,fds,shms) tagp \<in> ss; S_shm (hi,hctxt) \<in> ss; |
|
612 |
permission_check pctxt hctxt C_shm P_destroy; \<not> is_many_sshm sh\<rbrakk> |
|
613 |
\<Longrightarrow> (remove_sproc_sshm (del_ss ss (S_shm (hi,hctxt))) (hi,hctxt)) \<in> static" |
|
614 |
||
615 |
(* |
|
616 |
fun smsg_related :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool" |
|
617 |
where |
|
618 |
"smsg_related m [] = False" |
|
619 |
| "smsg_related m ((mi, sec, tag)#sms) = |
|
620 |
(if (mi = Init m) then True else smsg_related m sms)" |
|
621 |
||
622 |
fun smsgq_smsg_related :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool" |
|
623 |
where |
|
624 |
"smsgq_smsg_related q m (qi, sec, smsgslist) = ((qi = Init q) \<and> (smsg_related m smsgslist))" |
|
625 |
||
626 |
fun smsg_relatainted :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool" |
|
627 |
where |
|
628 |
"smsg_relatainted m [] = False" |
|
629 |
| "smsg_relatainted m ((mi, sec, tag)#sms) = |
|
630 |
(if (mi = Init m \<and> tag = True) then True else smsg_relatainted m sms)" |
|
631 |
||
632 |
fun smsgq_smsg_relatainted :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool" |
|
633 |
where |
|
634 |
"smsgq_smsg_relatainted q m (qi, sec, smsgslist) = |
|
635 |
((qi = Init q) \<and> (smsg_relatainted m smsgslist))" |
|
636 |
*) |
|
637 |
||
638 |
fun sfile_related :: "t_sfile \<Rightarrow> t_file \<Rightarrow> bool" |
|
639 |
where |
|
640 |
"sfile_related (fi,sec,psec,asecs) f = (fi = Init f)" |
|
641 |
(* |
|
642 |
fun sproc_related :: "t_process \<Rightarrow> t_sproc \<Rightarrow> bool" |
|
643 |
where |
|
644 |
"sproc_related p (pi, sec, fds, shms) = (pi = Init p)" |
|
645 |
*) |
|
646 |
fun init_obj_related :: "t_sobject \<Rightarrow> t_object \<Rightarrow> bool" |
|
647 |
where |
|
19 | 648 |
"init_obj_related (S_proc (pi, sec, fds, shms) tag) (O_proc p') = (pi = Init p')" |
1 | 649 |
| "init_obj_related (S_file sfs tag) (O_file f) = (\<exists> sf \<in> sfs. sfile_related sf f)" |
650 |
| "init_obj_related (S_dir sf) (O_dir f) = (sfile_related sf f)" |
|
19 | 651 |
| "init_obj_related (S_msgq (qi, sec, sms)) (O_msgq q') = (qi = Init q')" |
652 |
| "init_obj_related (S_shm (hi, sec)) (O_shm h') = (hi = Init h')" |
|
653 |
| "init_obj_related (S_msg (qi, sec, sms) (mi, secm, tagm)) (O_msg q' m') = (qi = Init q' \<and> mi = Init m')" |
|
1 | 654 |
| "init_obj_related _ _ = False" |
655 |
||
656 |
fun tainted_s :: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> bool" |
|
657 |
where |
|
658 |
"tainted_s ss (S_proc sp tag) = (S_proc sp tag \<in> ss \<and> tag = True)" |
|
659 |
| "tainted_s ss (S_file sfs tag) = (S_file sfs tag \<in> ss \<and> tag = True)" |
|
660 |
| "tainted_s ss (S_msg (qi, sec, sms) (mi, secm, tag)) = |
|
20 | 661 |
(S_msgq (qi, sec, sms) \<in> ss \<and> (mi,secm,tag) \<in> set sms \<and> tag = True)" |
1 | 662 |
| "tainted_s ss _ = False" |
663 |
||
664 |
(* |
|
665 |
fun tainted_s :: "t_object \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
666 |
where |
|
667 |
"tainted_s (O_proc p) ss = (\<exists> sp. S_proc sp True \<in> ss \<and> sproc_related p sp)" |
|
668 |
| "tainted_s (O_file f) ss = (\<exists> sfs sf. S_file sfs True \<in> ss \<and> sf \<in> sfs \<and> sfile_related f sf)" |
|
669 |
| "tainted_s (O_msg q m) ss = (\<exists> sq. S_msgq sq \<in> ss \<and> smsgq_smsg_relatainted q m sq)" |
|
670 |
| "tainted_s _ ss = False" |
|
671 |
*) |
|
672 |
||
673 |
definition taintable_s :: "t_object \<Rightarrow> bool" |
|
674 |
where |
|
675 |
"taintable_s obj \<equiv> \<exists> ss \<in> static. \<exists> sobj. tainted_s ss sobj \<and> init_obj_related sobj obj \<and> init_alive obj" |
|
676 |
||
677 |
definition deletable_s :: "t_object \<Rightarrow> bool" |
|
678 |
where |
|
679 |
"deletable_s obj \<equiv> init_alive obj \<and> (\<exists> ss \<in> static. \<forall> sobj \<in> ss. \<not> init_obj_related sobj obj)" |
|
680 |
||
681 |
definition undeletable_s :: "t_object \<Rightarrow> bool" |
|
682 |
where |
|
683 |
"undeletable_s obj \<equiv> init_alive obj \<and> (\<forall> ss \<in> static. \<exists> sobj \<in> ss. init_obj_related sobj obj)" |
|
684 |
||
685 |
||
686 |
(**************** translation from dynamic to static *******************) |
|
687 |
||
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
688 |
definition cf2sfile :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile option" |
1 | 689 |
where |
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
690 |
"cf2sfile s f \<equiv> |
1 | 691 |
case (parent f) of |
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
692 |
None \<Rightarrow> Some sroot |
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
693 |
| Some pf \<Rightarrow> if (is_file s f) |
1 | 694 |
then (case (sectxt_of_obj s (O_file f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of |
695 |
(Some sec, Some psec, Some asecs) \<Rightarrow> |
|
696 |
Some (if (\<not> deleted (O_file f) s \<and> is_init_file f) then Init f else Created, sec, Some psec, set asecs) |
|
697 |
| _ \<Rightarrow> None) |
|
698 |
else (case (sectxt_of_obj s (O_dir f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of |
|
699 |
(Some sec, Some psec, Some asecs) \<Rightarrow> |
|
700 |
Some (if (\<not> deleted (O_dir f) s \<and> is_init_dir f) then Init f else Created, sec, Some psec, set asecs) |
|
701 |
| _ \<Rightarrow> None)" |
|
702 |
||
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
703 |
definition cf2sfiles :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile set" |
1 | 704 |
where |
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
705 |
"cf2sfiles s f \<equiv> {sf. \<exists> f' \<in> (same_inode_files s f). cf2sfile s f' = Some sf}" |
1 | 706 |
|
707 |
(* here cf2sfile is passed with True, because, process' fds are only for files not dirs *) |
|
708 |
definition cfd2sfd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd \<Rightarrow> t_sfd option" |
|
709 |
where |
|
710 |
"cfd2sfd s p fd \<equiv> |
|
711 |
(case (file_of_proc_fd s p fd, flags_of_proc_fd s p fd, sectxt_of_obj s (O_fd p fd)) of |
|
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
712 |
(Some f, Some flags, Some sec) \<Rightarrow> (case (cf2sfile s f) of |
1 | 713 |
Some sf \<Rightarrow> Some (sec, flags, sf) |
714 |
| _ \<Rightarrow> None) |
|
715 |
| _ \<Rightarrow> None)" |
|
716 |
||
717 |
||
718 |
definition cpfd2sfds :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sfd set" |
|
719 |
where |
|
12 | 720 |
"cpfd2sfds s p \<equiv> {sfd. \<exists> fd \<in> proc_file_fds s p. cfd2sfd s p fd = Some sfd}" |
1 | 721 |
|
722 |
definition ch2sshm :: "t_state \<Rightarrow> t_shm \<Rightarrow> t_sshm option" |
|
723 |
where |
|
724 |
"ch2sshm s h \<equiv> (case (sectxt_of_obj s (O_shm h)) of |
|
725 |
Some sec \<Rightarrow> |
|
726 |
Some (if (\<not> deleted (O_shm h) s \<and> h \<in> init_shms) then Init h else Created, sec) |
|
727 |
| _ \<Rightarrow> None)" |
|
728 |
||
729 |
definition cph2spshs :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc_sshm set" |
|
730 |
where |
|
15 | 731 |
"cph2spshs s p \<equiv> {(sh, flag)| sh flag h. (p, flag) \<in> procs_of_shm s h \<and> ch2sshm s h = Some sh}" |
1 | 732 |
|
733 |
definition cp2sproc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc option" |
|
734 |
where |
|
735 |
"cp2sproc s p \<equiv> (case (sectxt_of_obj s (O_proc p)) of |
|
736 |
Some sec \<Rightarrow> |
|
737 |
Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) then Init p else Created, sec, |
|
738 |
cpfd2sfds s p, cph2spshs s p) |
|
739 |
| _ \<Rightarrow> None)" |
|
740 |
||
741 |
definition cm2smsg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option" |
|
742 |
where |
|
743 |
"cm2smsg s q m \<equiv> (case (sectxt_of_obj s (O_msg q m)) of |
|
744 |
Some sec \<Rightarrow> |
|
745 |
Some (if (\<not> deleted (O_msg q m) s \<and> m \<in> set (init_msgs_of_queue q)) then Init m else Created, |
|
746 |
sec, O_msg q m \<in> tainted s) |
|
747 |
| _ \<Rightarrow> None)" |
|
748 |
||
749 |
fun cqm2sms:: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg list \<Rightarrow> (t_smsg list) option" |
|
750 |
where |
|
751 |
"cqm2sms s q [] = Some []" |
|
752 |
| "cqm2sms s q (m#ms) = |
|
753 |
(case (cqm2sms s q ms, cm2smsg s q m) of |
|
754 |
(Some sms, Some sm) \<Rightarrow> Some (sm#sms) |
|
755 |
| _ \<Rightarrow> None)" |
|
756 |
||
757 |
definition cq2smsgq :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_smsgq option" |
|
758 |
where |
|
759 |
"cq2smsgq s q \<equiv> (case (sectxt_of_obj s (O_msgq q), cqm2sms s q (msgs_of_queue s q)) of |
|
760 |
(Some sec, Some sms) \<Rightarrow> |
|
761 |
Some (if (\<not> deleted (O_msgq q) s \<and> q \<in> init_msgqs) then Init q else Created, |
|
762 |
sec, sms) |
|
763 |
| _ \<Rightarrow> None)" |
|
764 |
||
765 |
fun co2sobj :: "t_state \<Rightarrow> t_object \<Rightarrow> t_sobject option" |
|
766 |
where |
|
767 |
"co2sobj s (O_proc p) = |
|
768 |
(case (cp2sproc s p) of |
|
769 |
Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s)) |
|
770 |
| _ \<Rightarrow> None)" |
|
771 |
| "co2sobj s (O_file f) = |
|
37
029cccce84b4
remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents:
34
diff
changeset
|
772 |
Some (S_file (cf2sfiles s f) (O_file f \<in> tainted s))" |
1 | 773 |
| "co2sobj s (O_dir f) = |
6
8779d321cc2e
remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents:
2
diff
changeset
|
774 |
(case (cf2sfile s f) of |
1 | 775 |
Some sf \<Rightarrow> Some (S_dir sf) |
776 |
| _ \<Rightarrow> None)" |
|
777 |
| "co2sobj s (O_msgq q) = |
|
778 |
(case (cq2smsgq s q) of |
|
779 |
Some sq \<Rightarrow> Some (S_msgq sq) |
|
780 |
| _ \<Rightarrow> None)" |
|
781 |
| "co2sobj s (O_shm h) = |
|
782 |
(case (ch2sshm s h) of |
|
783 |
Some sh \<Rightarrow> Some (S_shm sh) |
|
784 |
| _ \<Rightarrow> None)" |
|
33
6884b3c9284b
fix bug of static.thy for the static of recvmsg case
chunhan
parents:
25
diff
changeset
|
785 |
(* |
1 | 786 |
| "co2sobj s (O_msg q m) = |
787 |
(case (cq2smsgq s q, cm2smsg s q m) of |
|
788 |
(Some sq, Some sm) \<Rightarrow> Some (S_msg sq sm) |
|
789 |
| _ \<Rightarrow> None)" |
|
33
6884b3c9284b
fix bug of static.thy for the static of recvmsg case
chunhan
parents:
25
diff
changeset
|
790 |
*) |
1 | 791 |
| "co2sobj s _ = None" |
792 |
||
793 |
||
794 |
(***************** for backward proof when Instancing static objects ******************) |
|
795 |
||
796 |
definition next_nat :: "nat set \<Rightarrow> nat" |
|
797 |
where |
|
798 |
"next_nat nset = (Max nset) + 1" |
|
799 |
||
800 |
definition new_proc :: "t_state \<Rightarrow> t_process" |
|
801 |
where |
|
802 |
"new_proc \<tau> = next_nat (current_procs \<tau>)" |
|
803 |
||
804 |
definition new_inode_num :: "t_state \<Rightarrow> nat" |
|
805 |
where |
|
806 |
"new_inode_num \<tau> = next_nat (current_inode_nums \<tau>)" |
|
807 |
||
808 |
definition new_msgq :: "t_state \<Rightarrow> t_msgq" |
|
809 |
where |
|
810 |
"new_msgq s = next_nat (current_msgqs s)" |
|
811 |
||
812 |
definition new_msg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> nat" |
|
813 |
where |
|
814 |
"new_msg s q = next_nat (set (msgs_of_queue s q))" |
|
815 |
||
816 |
definition new_shm :: "t_state \<Rightarrow> nat" |
|
817 |
where |
|
818 |
"new_shm \<tau> = next_nat (current_shms \<tau>)" |
|
819 |
||
820 |
definition new_proc_fd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd" |
|
821 |
where |
|
822 |
"new_proc_fd \<tau> p = next_nat (current_proc_fds \<tau> p)" |
|
823 |
||
824 |
definition all_fname_under_dir:: "t_file \<Rightarrow> t_state \<Rightarrow> t_fname set" |
|
825 |
where |
|
826 |
"all_fname_under_dir d \<tau> = {fn. \<exists> f. fn # d = f \<and> f \<in> current_files \<tau>}" |
|
827 |
||
828 |
fun fname_all_a:: "nat \<Rightarrow> t_fname" |
|
829 |
where |
|
830 |
"fname_all_a 0 = []" | |
|
831 |
"fname_all_a (Suc n) = ''a''@(fname_all_a n)" |
|
832 |
||
833 |
definition fname_length_set :: "t_fname set \<Rightarrow> nat set" |
|
834 |
where |
|
835 |
"fname_length_set fns = length`fns" |
|
836 |
||
837 |
definition next_fname:: "t_file \<Rightarrow> t_state \<Rightarrow> t_fname" |
|
838 |
where |
|
839 |
"next_fname pf \<tau> = fname_all_a ((Max (fname_length_set (all_fname_under_dir pf \<tau>))) + 1)" |
|
840 |
||
841 |
definition new_childf:: "t_file \<Rightarrow> t_state \<Rightarrow> t_file" |
|
842 |
where |
|
843 |
"new_childf pf \<tau> = next_fname pf \<tau> # pf" |
|
844 |
||
845 |
definition s2ss :: "t_state \<Rightarrow> t_static_state" |
|
846 |
where |
|
847 |
"s2ss s \<equiv> {sobj. \<exists> obj. alive s obj \<and> co2sobj s obj = Some sobj}" |
|
848 |
||
849 |
end |
|
850 |
||
851 |
end |