133 (* |
133 (* |
134 and init_file_at_writing_by:: "t_file \<Rightarrow> (t_process \<times> t_fd) set" |
134 and init_file_at_writing_by:: "t_file \<Rightarrow> (t_process \<times> t_fd) set" |
135 *) |
135 *) |
136 and init_socket_state :: "t_socket \<rightharpoonup> t_sock_state" |
136 and init_socket_state :: "t_socket \<rightharpoonup> t_sock_state" |
137 |
137 |
|
138 (* |
138 and init_msgqs :: "t_msgq set" |
139 and init_msgqs :: "t_msgq set" |
139 and init_msgs_of_queue:: "t_msgq \<Rightarrow> t_msg list" |
140 and init_msgs_of_queue:: "t_msgq \<Rightarrow> t_msg list" |
|
141 *) |
|
142 and max_queue :: "nat" |
140 (* |
143 (* |
141 and init_shms :: "t_shm set" |
144 and init_shms :: "t_shm set" |
142 and init_procs_of_shm :: "t_shm \<Rightarrow> (t_process \<times> t_shm_attach_flag) set" |
145 and init_procs_of_shm :: "t_shm \<Rightarrow> (t_process \<times> t_shm_attach_flag) set" |
143 and init_flag_of_proc_shm :: "t_process \<Rightarrow> t_shm \<rightharpoonup> t_shm_attach_flag" |
146 and init_flag_of_proc_shm :: "t_process \<Rightarrow> t_shm \<rightharpoonup> t_shm_attach_flag" |
144 *) |
147 *) |
160 |
163 |
161 (* |
164 (* |
162 and init_procs_has_shm: "\<And> p h flag. (p,flag) \<in> init_procs_of_shm h \<Longrightarrow> p \<in> init_procs \<and> h \<in> init_shms \<and> init_flag_of_proc_shm p h = Some flag" |
165 and init_procs_has_shm: "\<And> p h flag. (p,flag) \<in> init_procs_of_shm h \<Longrightarrow> p \<in> init_procs \<and> h \<in> init_shms \<and> init_flag_of_proc_shm p h = Some flag" |
163 and init_shmflag_has_proc: "\<And> p h flag. init_flag_of_proc_shm p h = Some flag \<Longrightarrow> (p, flag) \<in> init_procs_of_shm h" |
166 and init_shmflag_has_proc: "\<And> p h flag. init_flag_of_proc_shm p h = Some flag \<Longrightarrow> (p, flag) \<in> init_procs_of_shm h" |
164 *) |
167 *) |
|
168 |
|
169 (* |
165 and init_msgs_distinct: "\<And> q. distinct (init_msgs_of_queue q)" |
170 and init_msgs_distinct: "\<And> q. distinct (init_msgs_of_queue q)" |
166 and init_msgs_valid: "\<And> m q. m \<in> set (init_msgs_of_queue q) \<Longrightarrow> q \<in> init_msgqs" |
171 and init_msgs_valid: "\<And> m q. m \<in> set (init_msgs_of_queue q) \<Longrightarrow> q \<in> init_msgqs" |
|
172 and init_msgq_valid: "\<And> q. length (init_msgs_of_queue q) \<le> max_queue" |
|
173 *) |
167 |
174 |
168 and init_socket_has_inode: "\<And> p fd. (p, fd) \<in> init_sockets \<Longrightarrow> \<exists> im. init_inum_of_socket (p, fd) = Some im \<and> p \<in> init_procs \<and> fd \<in> init_fds_of_proc p \<and> init_file_of_proc_fd p fd = None" |
175 and init_socket_has_inode: "\<And> p fd. (p, fd) \<in> init_sockets \<Longrightarrow> \<exists> im. init_inum_of_socket (p, fd) = Some im \<and> p \<in> init_procs \<and> fd \<in> init_fds_of_proc p \<and> init_file_of_proc_fd p fd = None" |
169 and inos_has_sock_tag: "\<And> s im. init_inum_of_socket s = Some im \<Longrightarrow> s \<in> init_sockets \<and> (\<exists> tag. init_itag_of_inum im = Some tag \<and> is_sock_itag tag)" |
176 and inos_has_sock_tag: "\<And> s im. init_inum_of_socket s = Some im \<Longrightarrow> s \<in> init_sockets \<and> (\<exists> tag. init_itag_of_inum im = Some tag \<and> is_sock_itag tag)" |
170 (* |
177 (* |
171 and init_netobj_has_state: "bidirect_in_init init_netobjs init_netobj_state" |
178 and init_netobj_has_state: "bidirect_in_init init_netobjs init_netobj_state" |
172 and init_netobj_has_socktype:"bidirect_in_init init_netobjs init_netobj_socktype" |
179 and init_netobj_has_socktype:"bidirect_in_init init_netobjs init_netobj_socktype" |
173 and init_netobj_has_laddr: "\<And> s. after_bind (init_netobj_state s) \<Longrightarrow> init_netobj_localaddr s \<noteq> None" |
180 and init_netobj_has_laddr: "\<And> s. after_bind (init_netobj_state s) \<Longrightarrow> init_netobj_localaddr s \<noteq> None" |
174 and init_netobj_has_raddr: "\<And> s. after_conacc (init_netobj_state s) \<Longrightarrow> init_netobj_remoteaddr s \<noteq> None" |
181 and init_netobj_has_raddr: "\<And> s. after_conacc (init_netobj_state s) \<Longrightarrow> init_netobj_remoteaddr s \<noteq> None" |
175 *) |
182 *) |
176 |
183 |
177 and init_finite_sets: "finite init_files \<and> finite init_procs \<and> (\<forall> p. finite (init_fds_of_proc p)) \<and> finite init_shms \<and> finite init_msgqs \<and> finite init_users" |
184 and init_finite_sets: "finite init_files \<and> finite init_procs \<and> (\<forall> p. finite (init_fds_of_proc p)) \<and> finite init_shms \<and> finite init_users" (* finite init_msgqs *) |
178 |
185 |
179 begin |
186 begin |
180 |
187 |
181 definition is_init_file:: "t_file \<Rightarrow> bool" |
188 definition is_init_file:: "t_file \<Rightarrow> bool" |
182 where |
189 where |
224 | "init_alive (O_tcp_sock k) = (is_init_tcp_sock k)" |
231 | "init_alive (O_tcp_sock k) = (is_init_tcp_sock k)" |
225 | "init_alive (O_udp_sock k) = (is_init_udp_sock k)" |
232 | "init_alive (O_udp_sock k) = (is_init_udp_sock k)" |
226 (* |
233 (* |
227 | "init_alive (O_shm h) = (h \<in> init_shms)" |
234 | "init_alive (O_shm h) = (h \<in> init_shms)" |
228 *) |
235 *) |
229 | "init_alive (O_msgq q) = (q \<in> init_msgqs)" |
236 | "init_alive (O_msgq q) = False" (* (q \<in> init_msgqs) *) |
230 | "init_alive (O_msg q m) = (m \<in> set (init_msgs_of_queue q) \<and> q \<in> init_msgqs)" |
237 | "init_alive (O_msg q m) = False" (* (m \<in> set (init_msgs_of_queue q) \<and> q \<in> init_msgqs)" *) |
231 |
238 |
232 |
239 |
233 (************ system listeners, event-related ***********) |
240 (************ system listeners, event-related ***********) |
234 |
241 |
235 fun file_of_proc_fd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd \<Rightarrow> t_file option" |
242 fun file_of_proc_fd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd \<Rightarrow> t_file option" |
510 "info_flow_shm s from to \<equiv> (self_shm s from to) \<or> (\<exists> h. one_flow_shm s h from to)" |
517 "info_flow_shm s from to \<equiv> (self_shm s from to) \<or> (\<exists> h. one_flow_shm s h from to)" |
511 *) |
518 *) |
512 |
519 |
513 fun current_msgqs :: "t_state \<Rightarrow> t_msgq set" |
520 fun current_msgqs :: "t_state \<Rightarrow> t_msgq set" |
514 where |
521 where |
515 "current_msgqs [] = init_msgqs" |
522 "current_msgqs [] = {}" (* init_msgqs *) |
516 | "current_msgqs (CreateMsgq p q # \<tau>) = insert q (current_msgqs \<tau>)" |
523 | "current_msgqs (CreateMsgq p q # \<tau>) = insert q (current_msgqs \<tau>)" |
517 | "current_msgqs (RemoveMsgq p q # \<tau>) = (current_msgqs \<tau>) - {q}" |
524 | "current_msgqs (RemoveMsgq p q # \<tau>) = (current_msgqs \<tau>) - {q}" |
518 | "current_msgqs (_ # \<tau>) = current_msgqs \<tau>" |
525 | "current_msgqs (_ # \<tau>) = current_msgqs \<tau>" |
519 |
526 |
520 fun msgs_of_queue :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg list" |
527 fun msgs_of_queue :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg list" |
521 where |
528 where |
522 "msgs_of_queue [] = init_msgs_of_queue" |
529 "msgs_of_queue [] = (\<lambda> x. [])" (* init_msgs_of_queue*) |
523 | "msgs_of_queue (CreateMsgq p q # \<tau>) = (msgs_of_queue \<tau>)(q := [])" |
530 | "msgs_of_queue (CreateMsgq p q # \<tau>) = (msgs_of_queue \<tau>)(q := [])" |
524 | "msgs_of_queue (SendMsg p q m # \<tau>) = (msgs_of_queue \<tau>)(q := msgs_of_queue \<tau> q @ [m])" |
531 | "msgs_of_queue (SendMsg p q m # \<tau>) = (msgs_of_queue \<tau>)(q := msgs_of_queue \<tau> q @ [m])" |
525 | "msgs_of_queue (RecvMsg p q m # \<tau>) = (msgs_of_queue \<tau>)(q := tl (msgs_of_queue \<tau> q))" |
532 | "msgs_of_queue (RecvMsg p q m # \<tau>) = (msgs_of_queue \<tau>)(q := tl (msgs_of_queue \<tau> q))" |
526 | "msgs_of_queue (RemoveMsgq p q # \<tau>) = (msgs_of_queue \<tau>)(q := [])" |
533 | "msgs_of_queue (RemoveMsgq p q # \<tau>) = (msgs_of_queue \<tau>)(q := [])" |
527 | "msgs_of_queue (_ # \<tau>) = msgs_of_queue \<tau>" |
534 | "msgs_of_queue (_ # \<tau>) = msgs_of_queue \<tau>" |
718 pf\<^isub>3 \<notin> files_hung_by_del \<tau>) )" |
725 pf\<^isub>3 \<notin> files_hung_by_del \<tau>) )" |
719 *) |
726 *) |
720 | "os_grant \<tau> (CreateMsgq p q) = |
727 | "os_grant \<tau> (CreateMsgq p q) = |
721 (p \<in> current_procs \<tau> \<and> q \<notin> (current_msgqs \<tau>))" |
728 (p \<in> current_procs \<tau> \<and> q \<notin> (current_msgqs \<tau>))" |
722 | "os_grant \<tau> (SendMsg p q m) = |
729 | "os_grant \<tau> (SendMsg p q m) = |
723 (p \<in> current_procs \<tau> \<and> q \<in> current_msgqs \<tau> \<and> m \<notin> (set (msgs_of_queue \<tau> q)))" |
730 (p \<in> current_procs \<tau> \<and> q \<in> current_msgqs \<tau> \<and> m \<notin> (set (msgs_of_queue \<tau> q)) \<and> |
|
731 length (msgs_of_queue \<tau> q) < max_queue)" |
724 | "os_grant \<tau> (RecvMsg p q m) = |
732 | "os_grant \<tau> (RecvMsg p q m) = |
725 (p \<in> current_procs \<tau> \<and> q \<in> current_msgqs \<tau> \<and> m = hd (msgs_of_queue \<tau> q) \<and> msgs_of_queue \<tau> q \<noteq> [])" |
733 (p \<in> current_procs \<tau> \<and> q \<in> current_msgqs \<tau> \<and> m = hd (msgs_of_queue \<tau> q) \<and> msgs_of_queue \<tau> q \<noteq> [])" |
726 | "os_grant \<tau> (RemoveMsgq p q) = |
734 | "os_grant \<tau> (RemoveMsgq p q) = |
727 (p \<in> current_procs \<tau> \<and> q \<in> current_msgqs \<tau>)" |
735 (p \<in> current_procs \<tau> \<and> q \<in> current_msgqs \<tau>)" |
728 (* |
736 (* |
1475 inductive valid :: "t_state \<Rightarrow> bool" |
1483 inductive valid :: "t_state \<Rightarrow> bool" |
1476 where |
1484 where |
1477 "valid []" |
1485 "valid []" |
1478 | "\<lbrakk>valid s; os_grant s e; grant s e\<rbrakk> \<Longrightarrow> valid (e # s)" |
1486 | "\<lbrakk>valid s; os_grant s e; grant s e\<rbrakk> \<Longrightarrow> valid (e # s)" |
1479 |
1487 |
1480 (* tobj: object that can be tainted *) |
1488 |
|
1489 (* tobj: object that can be tainted |
1481 fun tobj_in_init :: "t_object \<Rightarrow> bool" |
1490 fun tobj_in_init :: "t_object \<Rightarrow> bool" |
1482 where |
1491 where |
1483 "tobj_in_init (O_proc p) = (p \<in> init_procs)" |
1492 "tobj_in_init (O_proc p) = (p \<in> init_procs)" |
1484 | "tobj_in_init (O_file f) = (is_init_file f)" |
1493 | "tobj_in_init (O_file f) = (is_init_file f)" |
1485 (* directory is not taintable |
1494 (* directory is not taintable |
1487 |
1496 |
1488 | "tobj_in_init (O_node n) = (n \<in> init_nodes)" |
1497 | "tobj_in_init (O_node n) = (n \<in> init_nodes)" |
1489 | "tobj_in_init (O_msg q m) = (m \<in> set (init_msgs_of_queue q) \<and> q \<in> init_msgqs)" |
1498 | "tobj_in_init (O_msg q m) = (m \<in> set (init_msgs_of_queue q) \<and> q \<in> init_msgqs)" |
1490 *) |
1499 *) |
1491 | "tobj_in_init _ = False" (* other kind of obj cannot be tainted *) |
1500 | "tobj_in_init _ = False" (* other kind of obj cannot be tainted *) |
|
1501 *) |
|
1502 |
1492 |
1503 |
1493 (* no use |
1504 (* no use |
1494 fun no_del_event:: "t_event list \<Rightarrow> bool" |
1505 fun no_del_event:: "t_event list \<Rightarrow> bool" |
1495 where |
1506 where |
1496 "no_del_event [] = True" |
1507 "no_del_event [] = True" |