author | chunhan |
Thu, 16 Jan 2014 11:04:04 +0800 | |
changeset 95 | b7fd75d104bf |
parent 74 | 271e9818b6f6 |
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))" |
39 | 104 |
| "init_obj2sobj (O_dir f) = |
37
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 |
39 | 106 |
Some sf \<Rightarrow> Some (S_dir sf) |
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 |
||
65 | 125 |
(**************** translation from dynamic to static *******************) |
126 |
||
127 |
definition cf2sfile :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile option" |
|
128 |
where |
|
129 |
"cf2sfile s f \<equiv> |
|
130 |
case (parent f) of |
|
131 |
None \<Rightarrow> Some sroot |
|
132 |
| Some pf \<Rightarrow> if (is_file s f) |
|
133 |
then (case (sectxt_of_obj s (O_file f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of |
|
134 |
(Some sec, Some psec, Some asecs) \<Rightarrow> |
|
135 |
Some (if (\<not> deleted (O_file f) s \<and> is_init_file f) then Init f else Created, sec, Some psec, set asecs) |
|
136 |
| _ \<Rightarrow> None) |
|
137 |
else (case (sectxt_of_obj s (O_dir f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of |
|
138 |
(Some sec, Some psec, Some asecs) \<Rightarrow> |
|
139 |
Some (if (\<not> deleted (O_dir f) s \<and> is_init_dir f) then Init f else Created, sec, Some psec, set asecs) |
|
140 |
| _ \<Rightarrow> None)" |
|
141 |
||
142 |
definition cf2sfiles :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile set" |
|
143 |
where |
|
144 |
"cf2sfiles s f \<equiv> {sf. \<exists> f' \<in> (same_inode_files s f). cf2sfile s f' = Some sf}" |
|
145 |
||
146 |
(* here cf2sfile is passed with True, because, process' fds are only for files not dirs *) |
|
147 |
definition cfd2sfd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd \<Rightarrow> t_sfd option" |
|
148 |
where |
|
149 |
"cfd2sfd s p fd \<equiv> |
|
150 |
(case (file_of_proc_fd s p fd, flags_of_proc_fd s p fd, sectxt_of_obj s (O_fd p fd)) of |
|
151 |
(Some f, Some flags, Some sec) \<Rightarrow> (case (cf2sfile s f) of |
|
152 |
Some sf \<Rightarrow> Some (sec, flags, sf) |
|
153 |
| _ \<Rightarrow> None) |
|
154 |
| _ \<Rightarrow> None)" |
|
155 |
||
156 |
||
157 |
definition cpfd2sfds :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sfd set" |
|
158 |
where |
|
159 |
"cpfd2sfds s p \<equiv> {sfd. \<exists> fd \<in> proc_file_fds s p. cfd2sfd s p fd = Some sfd}" |
|
160 |
||
161 |
definition ch2sshm :: "t_state \<Rightarrow> t_shm \<Rightarrow> t_sshm option" |
|
162 |
where |
|
163 |
"ch2sshm s h \<equiv> (case (sectxt_of_obj s (O_shm h)) of |
|
164 |
Some sec \<Rightarrow> |
|
165 |
Some (if (\<not> deleted (O_shm h) s \<and> h \<in> init_shms) then Init h else Created, sec) |
|
166 |
| _ \<Rightarrow> None)" |
|
167 |
||
168 |
definition cph2spshs :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc_sshm set" |
|
169 |
where |
|
170 |
"cph2spshs s p \<equiv> {(sh, flag)| sh flag h. (p, flag) \<in> procs_of_shm s h \<and> ch2sshm s h = Some sh}" |
|
171 |
||
172 |
definition cp2sproc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc option" |
|
173 |
where |
|
174 |
"cp2sproc s p \<equiv> (case (sectxt_of_obj s (O_proc p)) of |
|
175 |
Some sec \<Rightarrow> |
|
176 |
Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) then Init p else Created, sec, |
|
177 |
cpfd2sfds s p, cph2spshs s p) |
|
178 |
| _ \<Rightarrow> None)" |
|
179 |
||
180 |
definition cm2smsg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option" |
|
181 |
where |
|
182 |
"cm2smsg s q m \<equiv> (case (sectxt_of_obj s (O_msg q m)) of |
|
183 |
Some sec \<Rightarrow> |
|
184 |
Some (if (\<not> deleted (O_msg q m) s \<and> m \<in> set (init_msgs_of_queue q)) then Init m else Created, |
|
185 |
sec, O_msg q m \<in> tainted s) |
|
186 |
| _ \<Rightarrow> None)" |
|
187 |
||
188 |
fun cqm2sms:: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg list \<Rightarrow> (t_smsg list) option" |
|
189 |
where |
|
190 |
"cqm2sms s q [] = Some []" |
|
191 |
| "cqm2sms s q (m#ms) = |
|
192 |
(case (cqm2sms s q ms, cm2smsg s q m) of |
|
193 |
(Some sms, Some sm) \<Rightarrow> Some (sm#sms) |
|
194 |
| _ \<Rightarrow> None)" |
|
195 |
||
196 |
definition cq2smsgq :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_smsgq option" |
|
197 |
where |
|
198 |
"cq2smsgq s q \<equiv> (case (sectxt_of_obj s (O_msgq q), cqm2sms s q (msgs_of_queue s q)) of |
|
199 |
(Some sec, Some sms) \<Rightarrow> |
|
200 |
Some (if (\<not> deleted (O_msgq q) s \<and> q \<in> init_msgqs) then Init q else Created, |
|
201 |
sec, sms) |
|
202 |
| _ \<Rightarrow> None)" |
|
203 |
||
204 |
fun co2sobj :: "t_state \<Rightarrow> t_object \<Rightarrow> t_sobject option" |
|
205 |
where |
|
206 |
"co2sobj s (O_proc p) = |
|
207 |
(case (cp2sproc s p) of |
|
208 |
Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s)) |
|
209 |
| _ \<Rightarrow> None)" |
|
210 |
| "co2sobj s (O_file f) = |
|
211 |
Some (S_file (cf2sfiles s f) (O_file f \<in> tainted s))" |
|
212 |
| "co2sobj s (O_dir f) = |
|
213 |
(case (cf2sfile s f) of |
|
214 |
Some sf \<Rightarrow> Some (S_dir sf) |
|
215 |
| _ \<Rightarrow> None)" |
|
216 |
| "co2sobj s (O_msgq q) = |
|
217 |
(case (cq2smsgq s q) of |
|
218 |
Some sq \<Rightarrow> Some (S_msgq sq) |
|
219 |
| _ \<Rightarrow> None)" |
|
220 |
| "co2sobj s (O_shm h) = |
|
221 |
(case (ch2sshm s h) of |
|
222 |
Some sh \<Rightarrow> Some (S_shm sh) |
|
223 |
| _ \<Rightarrow> None)" |
|
224 |
(* |
|
225 |
| "co2sobj s (O_msg q m) = |
|
226 |
(case (cq2smsgq s q, cm2smsg s q m) of |
|
227 |
(Some sq, Some sm) \<Rightarrow> Some (S_msg sq sm) |
|
228 |
| _ \<Rightarrow> None)" |
|
229 |
*) |
|
230 |
| "co2sobj s _ = None" |
|
231 |
||
232 |
||
233 |
definition s2ss :: "t_state \<Rightarrow> t_static_state" |
|
234 |
where |
|
235 |
"s2ss s \<equiv> {sobj. \<exists> obj. alive s obj \<and> co2sobj s obj = Some sobj}" |
|
236 |
||
237 |
||
238 |
(* ******************************************************** *) |
|
239 |
||
240 |
||
1 | 241 |
fun is_init_sfile :: "t_sfile \<Rightarrow> bool" |
242 |
where |
|
243 |
"is_init_sfile (Init _, sec, psec,asec) = True" |
|
244 |
| "is_init_sfile _ = False" |
|
245 |
||
246 |
fun is_many_sfile :: "t_sfile \<Rightarrow> bool" |
|
247 |
where |
|
248 |
"is_many_sfile (Created, sec, psec, asec) = True" |
|
249 |
| "is_many_sfile _ = False" |
|
250 |
||
251 |
fun is_init_sproc :: "t_sproc \<Rightarrow> bool" |
|
252 |
where |
|
253 |
"is_init_sproc (Init p, sec, fds, shms) = True" |
|
254 |
| "is_init_sproc _ = False" |
|
255 |
||
256 |
fun is_many_sproc :: "t_sproc \<Rightarrow> bool" |
|
257 |
where |
|
258 |
"is_many_sproc (Created, sec,fds,shms) = True" |
|
259 |
| "is_many_sproc _ = False" |
|
260 |
||
261 |
fun is_many_smsg :: "t_smsg \<Rightarrow> bool" |
|
262 |
where |
|
263 |
"is_many_smsg (Created,sec,tag) = True" |
|
264 |
| "is_many_smsg _ = False" |
|
265 |
||
61 | 266 |
(* wrong def |
1 | 267 |
fun is_many_smsgq :: "t_smsgq \<Rightarrow> bool" |
268 |
where |
|
269 |
"is_many_smsgq (Created,sec,sms) = (True \<and> (\<forall> sm \<in> (set sms). is_many_smsg sm))" |
|
270 |
| "is_many_smsgq _ = False" |
|
61 | 271 |
*) |
272 |
||
273 |
fun is_many_smsgq :: "t_smsgq \<Rightarrow> bool" |
|
274 |
where |
|
275 |
"is_many_smsgq (Created,sec,sms) = True" |
|
276 |
| "is_many_smsgq _ = False" |
|
1 | 277 |
|
278 |
fun is_many_sshm :: "t_sshm \<Rightarrow> bool" |
|
279 |
where |
|
280 |
"is_many_sshm (Created, sec) = True" |
|
281 |
| "is_many_sshm _ = False" |
|
282 |
||
283 |
fun is_many :: "t_sobject \<Rightarrow> bool" |
|
284 |
where |
|
42 | 285 |
"is_many (S_proc sp tag) = is_many_sproc sp" |
286 |
| "is_many (S_file sfs tag) = (\<forall> sf \<in> sfs. is_many_sfile sf)" |
|
287 |
| "is_many (S_dir sf ) = is_many_sfile sf" |
|
288 |
| "is_many (S_msgq sq ) = is_many_smsgq sq" |
|
289 |
| "is_many (S_shm sh ) = is_many_sshm sh" |
|
1 | 290 |
|
61 | 291 |
fun is_init_smsgq :: "t_smsgq \<Rightarrow> bool" |
292 |
where |
|
293 |
"is_init_smsgq (Init q,sec,sms) = True" |
|
294 |
| "is_init_smsgq _ = False" |
|
295 |
||
296 |
fun is_init_sshm :: "t_sshm \<Rightarrow> bool" |
|
297 |
where |
|
298 |
"is_init_sshm (Init h,sec) = True" |
|
299 |
| "is_init_sshm _ = False" |
|
300 |
||
301 |
fun is_init_sobj :: "t_sobject \<Rightarrow> bool" |
|
302 |
where |
|
303 |
"is_init_sobj (S_proc sp tag ) = is_init_sproc sp" |
|
304 |
| "is_init_sobj (S_file sfs tag) = (\<exists> sf \<in> sfs. is_init_sfile sf)" |
|
305 |
| "is_init_sobj (S_dir sf ) = is_init_sfile sf" |
|
306 |
| "is_init_sobj (S_msgq sq ) = is_init_smsgq sq" |
|
307 |
| "is_init_sobj (S_shm sh ) = is_init_sshm sh" |
|
308 |
||
1 | 309 |
(* |
310 |
fun update_ss_sp:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state" |
|
311 |
where |
|
312 |
"update_ss_sp ss (S_proc sp tag) (S_proc sp' tag') = |
|
313 |
(if (is_many_sproc sp) then ss \<union> {S_proc sp' tag'} |
|
314 |
else (ss - {S_proc sp tag}) \<union> {S_proc sp' tag'})" |
|
315 |
||
316 |
fun update_ss_sd:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state" |
|
317 |
where |
|
318 |
"update_ss_sd ss (S_dir sf tag) (S_dir sf' tag') = |
|
319 |
(if (is_many_sfile sf) then ss \<union> {S_dir sf' tag'} |
|
320 |
else (ss - {S_dir sf tag}) \<union> {S_dir sf' tag'})" |
|
321 |
*) |
|
322 |
||
323 |
(* |
|
324 |
fun sparent :: "t_sfile \<Rightarrow> t_sfile option" |
|
325 |
where |
|
326 |
"sparent (Sroot si sec) = None" |
|
327 |
| "sparent (Sfile si sec spf) = Some spf" |
|
328 |
||
329 |
inductive is_ancesf :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
330 |
where |
|
331 |
"is_ancesf sf sf" |
|
332 |
| "sparent sf = Some spf \<Longrightarrow> is_ancesf spf sf" |
|
333 |
| "\<lbrakk>sparent sf = Some spf; is_ancesf saf spf\<rbrakk> \<Longrightarrow> is_ancesf saf sf" |
|
334 |
||
335 |
definition sfile_reparent :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile" |
|
336 |
where |
|
337 |
"sfile_reparent (Sroot)" |
|
338 |
*) |
|
339 |
||
340 |
(* |
|
341 |
(* sfds rename aux definitions *) |
|
342 |
definition sfds_rename_notrelated |
|
343 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
344 |
where |
|
345 |
"sfds_rename_notrelated sfds from to sfds' \<equiv> |
|
346 |
(\<forall> sec flag sf. (sec,flag,sf) \<in> sfds \<and> (\<not> from \<preceq> sf) \<longrightarrow> (sec,flag,sf) \<in> sfds')" |
|
347 |
||
348 |
definition sfds_rename_renamed |
|
349 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
350 |
where |
|
351 |
"sfds_rename_renamed sfds sf from to sfds' \<equiv> |
|
352 |
(\<forall> sec flag sf'. (sec,flag,sf) \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> |
|
353 |
(sec, flag, file_after_rename sf' from to) \<in> sfds' \<and> (sec,flag,sf) \<notin> sfds')" |
|
354 |
||
355 |
definition sfds_rename_remain |
|
356 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
357 |
where |
|
358 |
"sfds_rename_remain sfds sf from to sfds' \<equiv> |
|
359 |
(\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> |
|
360 |
(sec, flag, sf') \<in> sfds' \<and> (sec,flag, file_after_rename sf' from to) \<notin> sfds')" |
|
361 |
||
74
271e9818b6f6
remove shm and linkhard, make a simplified version of selinux
chunhan
parents:
67
diff
changeset
|
362 |
(* for not many, choose on renamed or not *) |
1 | 363 |
definition sfds_rename_choices |
364 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
365 |
where |
|
366 |
"sfds_rename_choices sfds sf from to sfds' \<equiv> |
|
367 |
sfds_rename_remain sfds sf from to sfds' \<or> sfds_rename_renamed sfds sf from to sfds'" |
|
368 |
||
369 |
(* for many, merge renamed with not renamed *) |
|
370 |
definition sfds_rename_both |
|
371 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
372 |
where |
|
373 |
"sfds_rename_both sfds sf from to sfds' \<equiv> |
|
374 |
(\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> |
|
375 |
(sec, flag, sf') \<in> sfds' \<or> (sec,flag, file_after_rename sf' from to) \<in> sfds')" |
|
376 |
||
377 |
(* added to the new sfds, are those only under the new sfile *) |
|
378 |
definition sfds_rename_added |
|
379 |
:: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
380 |
where |
|
381 |
"sfds_rename_added sfds from to sfds' \<equiv> |
|
382 |
(\<forall> sec' flag' sf' sec flag. (sec',flag',sf') \<in> sfds' \<and> (sec,flag,sf') \<notin> sfds \<longrightarrow> |
|
383 |
(\<exists> sf. (sec,flag,sf) \<in> sfds \<and> sf' = file_after_rename from to sf))" |
|
384 |
||
385 |
definition sproc_sfds_renamed |
|
386 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
387 |
where |
|
388 |
"sproc_sfds_renamed ss sf from to ss' \<equiv> |
|
389 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
390 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_renamed sfds sf from to sfds'))" |
|
391 |
||
392 |
definition sproc_sfds_remain |
|
393 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
394 |
where |
|
395 |
"sproc_sfds_remain ss sf from to ss' \<equiv> |
|
396 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
397 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_remain sfds sf from to sfds'))" |
|
398 |
||
399 |
(* for not many, choose on renamed or not *) |
|
400 |
definition sproc_sfds_choices |
|
401 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
402 |
where |
|
403 |
"sproc_sfds_choices ss sf from to ss' \<equiv> |
|
404 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
405 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_choices sfds sf from to sfds'))" |
|
406 |
||
407 |
(* for many, merge renamed with not renamed *) |
|
408 |
definition sproc_sfds_both |
|
409 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
410 |
where |
|
411 |
"sproc_sfds_both ss sf from to ss' \<equiv> |
|
412 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> |
|
413 |
(\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_both sfds sf from to sfds'))" |
|
414 |
||
415 |
(* remove (\<forall> sp tag. S_proc sp tag \<in> ss \<longrightarrow> S_proc sp tag \<in> ss'), |
|
416 |
* cause sfds contains sfs informations *) |
|
417 |
definition ss_rename_notrelated |
|
418 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
419 |
where |
|
420 |
"ss_rename_notrelated ss sf sf' ss' \<equiv> |
|
421 |
(\<forall> sq. S_msgq sq \<in> ss \<longrightarrow> S_msgq sq \<in> ss') \<and> |
|
422 |
(\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> (\<exists> sfds'. |
|
423 |
S_proc (pi,sec,sfds',sshms) tagp \<in> ss'\<and> sfds_rename_notrelated sfds sf sf' sfds')) \<and> |
|
424 |
(\<forall> sfs sf'' tag. S_file sfs tag \<in> ss \<and> sf'' \<in> sfs \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> (\<exists> sfs'. |
|
425 |
S_file sfs tag \<in> ss' \<and> sf'' \<in> sfs')) \<and> |
|
426 |
(\<forall> sf'' tag. S_dir sf'' tag \<in> ss \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> S_dir sf'' tag \<in> ss')" |
|
427 |
||
428 |
(* rename from to, from should definited renamed if not many *) |
|
429 |
definition all_descendant_sf_renamed |
|
430 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
431 |
where |
|
432 |
"all_descendant_sf_renamed ss sf from to ss' \<equiv> |
|
433 |
(\<forall> sfs sf' tagf. sf \<preceq> sf' \<and> S_file sfs tagf \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. |
|
434 |
S_file sfs' tagf \<in> ss' \<and> file_after_rename from to sf' \<in> sfs' \<and> sf' \<notin> sfs')) \<and> |
|
435 |
(\<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> |
|
436 |
sproc_sfds_renamed ss sf from to ss'" |
|
437 |
||
438 |
(* not renamed *) |
|
439 |
definition all_descendant_sf_remain |
|
440 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
441 |
where |
|
442 |
"all_descendant_sf_remain ss sf from to ss' \<equiv> |
|
443 |
(\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. |
|
444 |
S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<notin> sfs' \<and> sf' \<in> sfs')) \<and> |
|
445 |
(\<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> |
|
446 |
sproc_sfds_remain ss sf from to ss'" |
|
447 |
||
448 |
definition all_descendant_sf_choices |
|
449 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
450 |
where |
|
451 |
"all_descendant_sf_choices ss sf from to ss' \<equiv> |
|
452 |
all_descendant_sf_renamed ss sf from to ss' \<or> all_descendant_sf_remain ss sf from to ss'" |
|
453 |
||
454 |
definition all_descendant_sf_both |
|
455 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
456 |
where |
|
457 |
"all_descendant_sf_both ss sf from to ss' \<equiv> |
|
458 |
(\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. |
|
459 |
S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<in> sfs' \<or> sf' \<in> sfs')) \<and> |
|
460 |
(\<forall> sf' tag'. sf \<preceq> sf' \<and> S_dir sf' tag' \<in> ss \<longrightarrow> |
|
461 |
S_dir (file_after_rename from to sf') tag' \<in> ss' \<or> S_dir sf' tag' \<in> ss') \<and> |
|
462 |
sproc_sfds_both ss sf from to ss'" |
|
463 |
||
464 |
definition ss_renamed_file |
|
465 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
466 |
where |
|
467 |
"ss_renamed_file ss sf sf' ss' \<equiv> |
|
468 |
(if (is_many_sfile sf) |
|
469 |
then all_descendant_sf_choices ss sf sf sf' ss' |
|
470 |
else all_descendant_sf_renamed ss sf sf sf' ss')" |
|
471 |
||
472 |
(* added to the new sfs, are those only under the new sfile *) |
|
473 |
definition sfs_rename_added |
|
474 |
:: "t_sfile set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile set \<Rightarrow> bool" |
|
475 |
where |
|
476 |
"sfs_rename_added sfs from to sfs' \<equiv> |
|
477 |
(\<forall> sf'. sf' \<in> sfs' \<and> sf' \<notin> sfs \<longrightarrow> (\<exists> sf. sf \<in> sfs \<and> sf' = file_after_rename from to sf))" |
|
478 |
||
479 |
(* added to the new sfile, are those only under the new sfile *) |
|
480 |
definition ss_rename_added |
|
481 |
:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
482 |
where |
|
483 |
"ss_rename_added ss from to ss' \<equiv> |
|
484 |
(\<forall> pi sec fds fds' shms tagp. S_proc (pi, sec, fds,shms) tagp \<in> ss \<and> |
|
485 |
S_proc (pi,sec,fds',shms) tagp \<in> ss' \<longrightarrow> sfds_rename_added fds from to fds') \<and> |
|
486 |
(\<forall> sq. S_msgq sq \<in> ss' \<longrightarrow> S_msgq sq \<in> ss) \<and> |
|
487 |
(\<forall> sfs sfs' tagf. S_file sfs' tagf \<in> ss' \<and> S_file sfs tagf \<in> ss \<longrightarrow> |
|
488 |
sfs_rename_added sfs from to sfs') \<and> |
|
489 |
(\<forall> sf' tagf. S_dir sf' tagf \<in> ss' \<and> S_dir sf' tagf \<notin> ss \<longrightarrow> |
|
490 |
(\<exists> sf. S_dir sf tagf \<in> ss \<and> sf' = file_after_rename from to sf))" |
|
491 |
||
492 |
definition sfile_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
493 |
where |
|
494 |
"sfile_alive ss sf \<equiv> (\<exists> sfs tagf. sf \<in> sfs \<and> S_file sfs tagf \<in> ss)" |
|
495 |
||
496 |
definition sf_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
497 |
where |
|
498 |
"sf_alive ss sf \<equiv> (\<exists> tagd. S_dir sf tagd \<in> ss) \<or> sfile_alive ss sf" |
|
499 |
||
500 |
(* constrains that the new static state should satisfy *) |
|
501 |
definition ss_rename:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool" |
|
502 |
where |
|
503 |
"ss_rename ss sf sf' ss' \<equiv> |
|
504 |
ss_rename_notrelated ss sf sf' ss' \<and> |
|
505 |
ss_renamed_file ss sf sf' ss' \<and> ss_rename_added ss sf sf' ss' \<and> |
|
506 |
(\<forall> sf''. sf_alive ss sf'' \<and> sf \<prec> sf'' \<longrightarrow> |
|
507 |
(if (is_many_sfile sf'') |
|
508 |
then all_descendant_sf_choices ss sf'' sf sf' ss' |
|
509 |
else all_descendant_sf_both ss sf'' sf sf' ss'))" |
|
510 |
||
511 |
(* two sfile, the last fname should not be equal *) |
|
512 |
fun sfile_same_fname:: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
513 |
where |
|
514 |
"sfile_same_fname ((Init n, sec)#spf) ((Init n', sec')#spf') = (n = n')" |
|
515 |
| "sfile_same_fname _ _ = False" |
|
516 |
||
517 |
(* no same init sfile/only sfile in the target-to spf, should be in static_state addmissble check *) |
|
518 |
definition ss_rename_no_same_fname:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" |
|
519 |
where |
|
520 |
"ss_rename_no_same_fname ss from spf \<equiv> |
|
521 |
\<not> (\<exists> to. sfile_same_fname from to \<and> parent to = Some spf \<and> sf_alive ss to)" |
|
522 |
||
523 |
(* is not a function, is a relation (one 2 many) |
|
524 |
definition update_ss_rename :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state" |
|
525 |
where |
|
526 |
"update_ss_rename ss sf sf' \<equiv> if (is_many_sfile sf) |
|
527 |
then (ss \<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss} |
|
528 |
\<union> {S_dir (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}) |
|
529 |
else (ss - {S_file sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss} |
|
530 |
- {S_dir sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}) |
|
531 |
\<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss} |
|
532 |
\<union> {S_dir (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}" |
|
533 |
*) |
|
534 |
*) |
|
535 |
||
536 |
fun sectxt_of_sproc :: "t_sproc \<Rightarrow> security_context_t" |
|
537 |
where |
|
538 |
"sectxt_of_sproc (pi,sec,fds,shms) = sec" |
|
539 |
||
540 |
fun sectxt_of_sfile :: "t_sfile \<Rightarrow> security_context_t" |
|
541 |
where |
|
542 |
"sectxt_of_sfile (fi,sec,psec,asecs) = sec" |
|
543 |
||
544 |
fun asecs_of_sfile :: "t_sfile \<Rightarrow> security_context_t set" |
|
545 |
where |
|
546 |
"asecs_of_sfile (fi,sec,psec,asecs) = asecs" |
|
547 |
||
548 |
definition search_check_s :: "security_context_t \<Rightarrow> t_sfile \<Rightarrow> bool \<Rightarrow> bool" |
|
549 |
where |
|
550 |
"search_check_s pctxt sf if_file = |
|
551 |
(if if_file |
|
67 | 552 |
then search_check_ctxt pctxt (sectxt_of_sfile sf) (asecs_of_sfile sf) True |
553 |
else search_check_ctxt pctxt (sectxt_of_sfile sf) (asecs_of_sfile sf) False)" |
|
1 | 554 |
|
555 |
definition sectxts_of_sfds :: "t_sfd set \<Rightarrow> security_context_t set" |
|
556 |
where |
|
557 |
"sectxts_of_sfds sfds \<equiv> {ctxt. \<exists> flag sf. (ctxt, flag, sf) \<in> sfds}" |
|
558 |
||
559 |
definition inherit_fds_check_s :: "security_context_t \<Rightarrow> t_sfd set \<Rightarrow> bool" |
|
560 |
where |
|
67 | 561 |
"inherit_fds_check_s pctxt sfds \<equiv> inherit_fds_check_ctxt pctxt (sectxts_of_sfds sfds)" |
1 | 562 |
|
563 |
definition sectxts_of_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> security_context_t set" |
|
564 |
where |
|
565 |
"sectxts_of_sproc_sshms sshms \<equiv> {ctxt. \<exists> hi flag. ((hi, ctxt),flag) \<in> sshms}" |
|
566 |
||
567 |
definition inherit_shms_check_s :: "security_context_t \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool" |
|
568 |
where |
|
67 | 569 |
"inherit_shms_check_s pctxt sshms \<equiv> inherit_shms_check_ctxt pctxt (sectxts_of_sproc_sshms sshms)" |
1 | 570 |
|
571 |
(* |
|
572 |
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool" |
|
573 |
where |
|
574 |
"info_flow_sshm (pi,sec,fds,shms) (pi',sec',fds',shms') = |
|
575 |
(\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" |
|
576 |
*) |
|
577 |
definition info_flow_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool" |
|
578 |
where |
|
579 |
"info_flow_sproc_sshms shms shms' \<equiv> (\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" |
|
580 |
||
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
|
581 |
(* |
1 | 582 |
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool" |
583 |
where |
|
584 |
"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
|
585 |
*) |
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
|
586 |
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
|
587 |
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
|
588 |
"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
|
589 |
| "\<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
|
590 |
\<Longrightarrow> info_flow_sshm sp (pi',sec',fds',shms')" |
1 | 591 |
|
592 |
||
593 |
(* |
|
594 |
fun smsg_related :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool" |
|
595 |
where |
|
596 |
"smsg_related m [] = False" |
|
597 |
| "smsg_related m ((mi, sec, tag)#sms) = |
|
598 |
(if (mi = Init m) then True else smsg_related m sms)" |
|
599 |
||
600 |
fun smsgq_smsg_related :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool" |
|
601 |
where |
|
602 |
"smsgq_smsg_related q m (qi, sec, smsgslist) = ((qi = Init q) \<and> (smsg_related m smsgslist))" |
|
603 |
||
604 |
fun smsg_relatainted :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool" |
|
605 |
where |
|
606 |
"smsg_relatainted m [] = False" |
|
607 |
| "smsg_relatainted m ((mi, sec, tag)#sms) = |
|
608 |
(if (mi = Init m \<and> tag = True) then True else smsg_relatainted m sms)" |
|
609 |
||
610 |
fun smsgq_smsg_relatainted :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool" |
|
611 |
where |
|
612 |
"smsgq_smsg_relatainted q m (qi, sec, smsgslist) = |
|
613 |
((qi = Init q) \<and> (smsg_relatainted m smsgslist))" |
|
614 |
*) |
|
615 |
||
616 |
fun sfile_related :: "t_sfile \<Rightarrow> t_file \<Rightarrow> bool" |
|
617 |
where |
|
618 |
"sfile_related (fi,sec,psec,asecs) f = (fi = Init f)" |
|
619 |
(* |
|
620 |
fun sproc_related :: "t_process \<Rightarrow> t_sproc \<Rightarrow> bool" |
|
621 |
where |
|
622 |
"sproc_related p (pi, sec, fds, shms) = (pi = Init p)" |
|
623 |
*) |
|
624 |
fun init_obj_related :: "t_sobject \<Rightarrow> t_object \<Rightarrow> bool" |
|
625 |
where |
|
19 | 626 |
"init_obj_related (S_proc (pi, sec, fds, shms) tag) (O_proc p') = (pi = Init p')" |
1 | 627 |
| "init_obj_related (S_file sfs tag) (O_file f) = (\<exists> sf \<in> sfs. sfile_related sf f)" |
628 |
| "init_obj_related (S_dir sf) (O_dir f) = (sfile_related sf f)" |
|
19 | 629 |
| "init_obj_related (S_msgq (qi, sec, sms)) (O_msgq q') = (qi = Init q')" |
630 |
| "init_obj_related (S_shm (hi, sec)) (O_shm h') = (hi = Init h')" |
|
56 | 631 |
(* |
19 | 632 |
| "init_obj_related (S_msg (qi, sec, sms) (mi, secm, tagm)) (O_msg q' m') = (qi = Init q' \<and> mi = Init m')" |
56 | 633 |
*) |
1 | 634 |
| "init_obj_related _ _ = False" |
635 |
||
636 |
||
637 |
||
638 |
(***************** for backward proof when Instancing static objects ******************) |
|
639 |
||
640 |
definition next_nat :: "nat set \<Rightarrow> nat" |
|
641 |
where |
|
642 |
"next_nat nset = (Max nset) + 1" |
|
643 |
||
644 |
definition new_proc :: "t_state \<Rightarrow> t_process" |
|
645 |
where |
|
646 |
"new_proc \<tau> = next_nat (current_procs \<tau>)" |
|
647 |
||
648 |
definition new_inode_num :: "t_state \<Rightarrow> nat" |
|
649 |
where |
|
650 |
"new_inode_num \<tau> = next_nat (current_inode_nums \<tau>)" |
|
651 |
||
652 |
definition new_msgq :: "t_state \<Rightarrow> t_msgq" |
|
653 |
where |
|
654 |
"new_msgq s = next_nat (current_msgqs s)" |
|
655 |
||
656 |
definition new_msg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> nat" |
|
657 |
where |
|
658 |
"new_msg s q = next_nat (set (msgs_of_queue s q))" |
|
659 |
||
660 |
definition new_shm :: "t_state \<Rightarrow> nat" |
|
661 |
where |
|
662 |
"new_shm \<tau> = next_nat (current_shms \<tau>)" |
|
663 |
||
664 |
definition new_proc_fd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd" |
|
665 |
where |
|
666 |
"new_proc_fd \<tau> p = next_nat (current_proc_fds \<tau> p)" |
|
667 |
||
668 |
definition all_fname_under_dir:: "t_file \<Rightarrow> t_state \<Rightarrow> t_fname set" |
|
669 |
where |
|
670 |
"all_fname_under_dir d \<tau> = {fn. \<exists> f. fn # d = f \<and> f \<in> current_files \<tau>}" |
|
671 |
||
672 |
fun fname_all_a:: "nat \<Rightarrow> t_fname" |
|
673 |
where |
|
674 |
"fname_all_a 0 = []" | |
|
675 |
"fname_all_a (Suc n) = ''a''@(fname_all_a n)" |
|
676 |
||
677 |
definition fname_length_set :: "t_fname set \<Rightarrow> nat set" |
|
678 |
where |
|
679 |
"fname_length_set fns = length`fns" |
|
680 |
||
681 |
definition next_fname:: "t_file \<Rightarrow> t_state \<Rightarrow> t_fname" |
|
682 |
where |
|
683 |
"next_fname pf \<tau> = fname_all_a ((Max (fname_length_set (all_fname_under_dir pf \<tau>))) + 1)" |
|
684 |
||
685 |
definition new_childf:: "t_file \<Rightarrow> t_state \<Rightarrow> t_file" |
|
686 |
where |
|
687 |
"new_childf pf \<tau> = next_fname pf \<tau> # pf" |
|
688 |
||
689 |
end |
|
690 |
||
691 |
end |