# HG changeset patch # User chunhan # Date 1372058557 -28800 # Node ID b6333712cb024e0c3ef2336cf27b50e9cd67de12 # Parent 259a50be438128fa2cb28f22c0ee16903a88c588 finished info_flow_shm(simple def) simpset diff -r 259a50be4381 -r b6333712cb02 Current_prop.thy --- a/Current_prop.thy Mon Jun 24 09:01:42 2013 +0800 +++ b/Current_prop.thy Mon Jun 24 15:22:37 2013 +0800 @@ -20,6 +20,10 @@ apply (case_tac a, auto split:if_splits option.splits) done +lemma procs_of_shm_prop2': + "\p \ current_procs s; valid s\ \ \ flag h. (p, flag) \ procs_of_shm s h" +by (auto dest:procs_of_shm_prop2) + lemma procs_of_shm_prop3: "\(p, flag) \ procs_of_shm s h; (p, flag') \ procs_of_shm s h; valid s\ \ flag = flag'" apply (induct s arbitrary:p flag flag') @@ -49,11 +53,77 @@ lemma info_shm_flow_in_procs: "\info_flow_shm s p p'; valid s\ \ p \ current_procs s \ p' \ current_procs s" -apply (induct rule:info_flow_shm.induct ) -by (auto intro:procs_of_shm_prop2) +by (auto intro:procs_of_shm_prop2 simp:info_flow_shm_def one_flow_shm_def) (*********** simpset for info_flow_shm **************) +lemma info_flow_shm_attach: + "valid (Attach p h flag # s) \ info_flow_shm (Attach p h flag # s) = (\ pa pb. + (pa = p \ flag = SHM_RDWR \ (\ flagb. (pb, flagb) \ procs_of_shm s h)) \ + (pb = p \ (pa, SHM_RDWR) \ procs_of_shm s h) \ + (info_flow_shm s pa pb) )" +apply (rule ext, rule ext, frule vt_grant_os) +by (auto simp add:info_flow_shm_def one_flow_shm_def) + +lemma info_flow_shm_detach: + "valid (Detach p h # s) \ info_flow_shm (Detach p h # s) = (\ pa pb. + self_shm s pa pb \ ((p = pa \ p = pb) \ (\ h'. h' \ h \ one_flow_shm s h' pa pb)) \ + (pa \ p \ pb \ p \ info_flow_shm s pa pb) )" +apply (rule ext, rule ext, frule vt_grant_os) +by (auto simp:info_flow_shm_def one_flow_shm_def) + +lemma info_flow_shm_deleteshm: + "valid (DeleteShM p h # s) \ info_flow_shm (DeleteShM p h # s) = (\ pa pb. + self_shm s pa pb \ (\ h'. h' \ h \ one_flow_shm s h' pa pb) )" +apply (rule ext, rule ext, frule vt_grant_os) +by (auto simp:info_flow_shm_def one_flow_shm_def) + +lemma info_flow_shm_clone: + "valid (Clone p p' fds shms # s) \ info_flow_shm (Clone p p' fds shms # s) = (\ pa pb. + (pa = p' \ pb = p') \ (pa = p' \ pb \ p' \ (\ h \ shms. one_flow_shm s h p pb)) \ + (pb = p' \ pa \ p' \ (\ h \ shms. one_flow_shm s h pa p)) \ + (pa \ p' \ pb \ p' \ info_flow_shm s pa pb))" +apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons, clarsimp) +apply (frule_tac p = p' in procs_of_shm_prop2', simp) +apply (auto simp:info_flow_shm_def one_flow_shm_def) +done + +lemma info_flow_shm_execve: + "valid (Execve p f fds # s) \ info_flow_shm (Execve p f fds # s) = (\ pa pb. + (pa = p \ pb = p) \ (pa \ p \ pb \ p \ info_flow_shm s pa pb) )" +apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons) +by (auto simp:info_flow_shm_def one_flow_shm_def) + +lemma info_flow_shm_kill: + "valid (Kill p p' # s) \ info_flow_shm (Kill p p' # s) = (\ pa pb. + pa \ p' \ pb \ p' \ info_flow_shm s pa pb )" +apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons) +by (auto simp:info_flow_shm_def one_flow_shm_def) + +lemma info_flow_shm_exit: + "valid (Exit p # s) \ info_flow_shm (Exit p # s) = (\ pa pb. + pa \ p \ pb \ p \ info_flow_shm s pa pb )" +apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons) +by (auto simp:info_flow_shm_def one_flow_shm_def) + +lemma info_flow_shm_other: + "\valid (e # s); + \ p h flag. e \ Attach p h flag; + \ p h. e \ Detach p h; + \ p h. e \ DeleteShM p h; + \ p p' fds shms. e \ Clone p p' fds shms; + \ p f fds. e \ Execve p f fds; + \ p p'. e \ Kill p p'; + \ p. e \ Exit p + \ \ info_flow_shm (e # s) = info_flow_shm s" +apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons) +apply (case_tac e, auto simp:info_flow_shm_def one_flow_shm_def dest:procs_of_shm_prop2) +apply (erule_tac x = h in allE, simp) +apply (drule procs_of_shm_prop1, auto) +done + + +(* lemma info_flow_shm_prop1: "\info_flow_shm s p p'; p \ p'; valid s\ \ \ h h' flag. (p, SHM_RDWR) \ procs_of_shm s h \ (p', flag) \ procs_of_shm s h'" @@ -83,10 +153,15 @@ where "flowed_procs s h \ {p'. \ p \ attached_procs s h. flows_shm s p p'}" +inductive flowed_shm:: "t_state \ t_process \ t_shm set" + fun Info_flow_shm :: "t_state \ t_process \ t_process set" where "Info_flow_shm [] = (\ p. {p'. flows_shm [] p p'})" -| "Info_flow_shm (Attach p h flag # s) = (\ p'. if (p' = p) then {p''. \ }" +| "Info_flow_shm (Attach p h flag # s) = (\ p'. + if (p' = p) then flowed_procs s h + else if () + " lemma info_flow_shm_attach: @@ -107,8 +182,9 @@ apply (rule_tac p = pa and p' = p' in info_flow_shm.intros(2), simp+) apply (rule notI, erule info_flow_shm.cases, simp+) pr 5 - -lemmas info_flow_shm_simps = info_flow_shm_other +*) +lemmas info_flow_shm_simps = info_flow_shm_other info_flow_shm_attach info_flow_shm_detach info_flow_shm_deleteshm + info_flow_shm_clone info_flow_shm_execve info_flow_shm_kill info_flow_shm_exit lemma has_same_inode_in_current: "\has_same_inode s f f'; valid s\ \ f \ current_files s \ f' \ current_files s" diff -r 259a50be4381 -r b6333712cb02 Flask.thy --- a/Flask.thy Mon Jun 24 09:01:42 2013 +0800 +++ b/Flask.thy Mon Jun 24 15:22:37 2013 +0800 @@ -473,17 +473,25 @@ (\ h. (procs_of_shm s h) - {(p, flag) | flag. (p, flag) \ procs_of_shm s h})" | "procs_of_shm (e # \) = procs_of_shm \" +(* inductive info_flow_shm :: "t_state \ t_process \ t_process \ bool" where "p \ current_procs s \ info_flow_shm s p p" | "\info_flow_shm s p p'; (p', SHM_RDWR) \ procs_of_shm s h; (p'', flag) \ procs_of_shm s h; p' \ p''\ \ info_flow_shm s p p''" -(* +*) +definition one_flow_shm :: "t_state \ t_shm \ t_process \ t_process \ bool" +where + "one_flow_shm s h from to \ (from, SHM_RDWR) \ procs_of_shm s h \ (\ flag. (to, flag) \ procs_of_shm s h)" + +fun self_shm :: "t_state \ t_process \ t_process \ bool" +where + "self_shm s p p' = (p = p' \ p' \ current_procs s)" + definition info_flow_shm :: "t_state \ t_process \ t_process \ bool" where - "info_flow_shm \ from to \ (from = to \ from \ current_procs \) \ (\ h toflag. - (((from, SHM_RDWR) \ procs_of_shm \ h) \ ((to, toflag) \ procs_of_shm \ h)))" -*) + "info_flow_shm s from to \ (self_shm s from to) \ (\ h. one_flow_shm s h from to)" + fun current_msgqs :: "t_state \ t_msg set" where