diff -r f27882976251 -r 289a30c4cfb7 Co2sobj_prop.thy --- a/Co2sobj_prop.thy Wed May 15 15:42:46 2013 +0800 +++ b/Co2sobj_prop.thy Thu May 16 15:18:44 2013 +0800 @@ -6,7 +6,7 @@ context tainting_s begin -(************ simpset for cf2sfile ***************) +(****************** cf2sfile path simpset ***************) lemma sroot_only: "cf2sfile s [] = Some sroot" @@ -34,7 +34,7 @@ apply (frule parentf_is_dir'', simp) apply (frule is_file_or_dir, simp) apply (auto dest!:current_has_sec' - simp:cf2sfile_def split:option.splits if_splits dest!:get_pfs_secs_prop) + simp:cf2sfile_def split:option.splits if_splits dest!:get_pfs_secs_prop') done definition sectxt_of_pf :: "t_state \ t_file \ security_context_t option" @@ -132,50 +132,42 @@ apply (auto split:option.splits) done - +lemma cf2sfile_path_file_prop1: + "\is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\ + \ \ fsec. cf2sfile s (f # pf) = + Some (if (\ deleted (O_file (f # pf)) s \ is_init_file (f # pf)) then Init (f # pf) + else Created, fsec, Some pfsec, asecs \ {pfsec}) \ + sectxt_of_obj s (O_file (f # pf)) = Some fsec" +apply (frule is_file_has_sfile, simp) +by (auto simp:cf2sfile_path_file) -apply simp +lemma cf2sfile_path_file_prop2: + "\is_file s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); + sectxt_of_obj s (O_file (f # pf)) = Some fsec; valid s\ \ cf2sfile s (f # pf) = + Some (if (\ deleted (O_file (f # pf)) s \ is_init_file (f # pf)) then Init (f # pf) + else Created, fsec, Some pfsec, asecs \ {pfsec})" +by (drule cf2sfile_path_file_prop1, auto) -thm cf2sfile_def -apply (simp (no_asm_simp)) -apply simp -apply (frule cf2sfile_path_file, simp) -apply (simp add: cf2sfile_path_file) -apply auto -apply (simp only:cf2sfile_path_file) -by (simp add:cf2sfile_path_file cf2sfile_path_dir) -apply (frule parentf_is_dir'', simp) -apply (frule is_file_or_dir, simp) -apply (frule sroot_set, erule disjE) -apply (frule is_dir_has_sfile, simp, frule is_file_has_sfile, simp) -apply (case_tac pf, clarsimp) -apply (auto dest!:is_file_has_sec' is_dir_has_sec' get_pfs_secs_prop simp:cf2sfile_def get_parentfs_ctxts.simps - simp:get_parentfs_ctxts'_def sectxt_of_pf_def split:option.splits if_splits)[1] -apply (auto dest!:is_file_has_sec' is_dir_has_sec' get_pfs_secs_prop - simp:get_parentfs_ctxts'_def sectxt_of_pf_def split:option.splits if_splits)[1] -apply (case_tac "is_file s (f # pf)") -apply (frule is_file_has_sec, simp) -apply (frule is_dir_has_sec, simp) -apply (frule is_dir_not_file) -apply (erule exE)+ -apply (auto split:option.splits)[1] -apply simp +lemma cf2sfile_path_dir_prop1: + "\is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); valid s\ + \ \ fsec. cf2sfile s (f # pf) = + Some (if (\ deleted (O_dir (f # pf)) s \ is_init_dir (f # pf)) then Init (f # pf) + else Created, fsec, Some pfsec, asecs \ {pfsec}) \ + sectxt_of_obj s (O_dir (f # pf)) = Some fsec" +apply (frule is_dir_has_sfile, simp) +by (auto simp:cf2sfile_path_dir) -apply (rule ext) -apply (subst (1) cf2sfile_def) -apply (auto simp del:deleted.simps get_parentfs_ctxts.simps split:option.splits if_splits) +lemma cf2sfile_path_dir_prop2: + "\is_dir s (f # pf); cf2sfile s pf = Some (pfi, pfsec, psec, asecs); + sectxt_of_obj s (O_dir (f # pf)) = Some fsec; valid s\ \ cf2sfile s (f # pf) = + Some (if (\ deleted (O_dir (f # pf)) s \ is_init_dir (f # pf)) then Init (f # pf) + else Created, fsec, Some pfsec, asecs \ {pfsec})" +by (drule cf2sfile_path_dir_prop1, auto) -lemma cf2sfile_open_none1: - "valid (Open p f flag fd None # s) \ cf2sfile (Open p f flag fd None # s) f b = cf2sfile s f b" -apply (frule vd_cons, frule vt_grant_os) -apply (frule noroot_events, case_tac f, simp) -apply (auto split:if_splits option.splits dest!:current_has_sec' dest:parentf_in_current' - simp:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps - get_parentfs_ctxts_simps) -done +(**************** cf2sfile event list simpset ****************) -lemma cf2sfile_open_none2: - "valid (Open p f flag fd None # s) \ cf2sfile (Open p f flag fd None # s) f' b = cf2sfile s f' b" +lemma cf2sfile_open_none': + "valid (Open p f flag fd None # s) \ cf2sfile (Open p f flag fd None # s) f'= cf2sfile s f'" apply (frule vd_cons, frule vt_grant_os) apply (induct f', simp add:cf2sfile_def) apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps @@ -184,14 +176,13 @@ lemma cf2sfile_open_none: "valid (Open p f flag fd None # s) \ cf2sfile (Open p f flag fd None # s) = cf2sfile s" -apply (rule ext, rule ext) -apply (simp add:cf2sfile_open_none1 cf2sfile_open_none2) -done +apply (rule ext) +by (simp add:cf2sfile_open_none') lemma cf2sfile_open_some1: "\valid (Open p f flag fd (Some inum) # s); f' \ current_files s\ \ cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'" -apply (frule vd_cons, frule vt_grant_os, frule noroot_events, rule ext) +apply (frule vd_cons, frule vt_grant_os, frule noroot_events) apply (case_tac "f = f'", simp) apply (induct f', simp add:sroot_only, simp) apply (frule parentf_in_current', simp+) @@ -201,18 +192,18 @@ lemma cf2sfile_open_some2: "\valid (Open p f flag fd (Some inum) # s); is_file s f'\ - \ cf2sfile (Open p f flag fd (Some inum) # s) f' True = cf2sfile s f' True" + \ cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'" apply (frule vd_cons, drule is_file_in_current) by (simp add:cf2sfile_open_some1) lemma cf2sfile_open_some3: "\valid (Open p f flag fd (Some inum) # s); is_dir s f'\ - \ cf2sfile (Open p f flag fd (Some inum) # s) f' False = cf2sfile s f' False" + \ cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'" apply (frule vd_cons, drule is_dir_in_current) by (simp add:cf2sfile_open_some1) lemma cf2sfile_open_some4: - "valid (Open p f flag fd (Some inum) # s) \ cf2sfile (Open p f flag fd (Some inum) # s) f True = ( + "valid (Open p f flag fd (Some inum) # s) \ cf2sfile (Open p f flag fd (Some inum) # s) f = ( case (parent f) of Some pf \ (case (sectxt_of_obj (Open p f flag fd (Some inum) # s) (O_file f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of @@ -228,80 +219,169 @@ apply (simp add:is_file_in_current) done -lemma cf2sfile_open_some5: - "valid (Open p f flag fd (Some inum) # s) \ - cf2sfile (Open p f flag fd (Some inum) # s) f False = cf2sfile s f False" -apply (frule vd_cons, frule vt_grant_os, frule noroot_events) -apply (case_tac f, simp) -apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps - get_parentfs_ctxts_simps split:option.splits) -done - lemma cf2sfile_open: "\valid (Open p f flag fd opt # s); f' \ current_files (Open p f flag fd opt # s)\ - \ cf2sfile (Open p f flag fd opt # s) f' b = ( - if (opt = None) then cf2sfile s f' b - else if (f' = f \ b) + \ cf2sfile (Open p f flag fd opt # s) f' = ( + if (opt = None) then cf2sfile s f' + else if (f' = f) then (case (parent f) of Some pf \ (case (sectxt_of_obj (Open p f flag fd opt # s) (O_file f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of (Some sec, Some psec, Some asecs) \ Some (Created, sec, Some psec, set asecs) | _ \ None) | None \ None) - else cf2sfile s f' b)" + else cf2sfile s f')" apply (case_tac opt) apply (simp add:cf2sfile_open_none) apply (case_tac "f = f'") -apply (auto simp:cf2sfile_open_some1 cf2sfile_open_some4 cf2sfile_open_some5 current_files_simps) +apply (simp add:cf2sfile_open_some4 split:option.splits) +apply (simp add:cf2sfile_open_some1 current_files_simps) done lemma cf2sfile_mkdir1: "\valid (Mkdir p f i # s); f' \ current_files s\ \ cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'" -apply (frule vd_cons, frule vt_grant_os, frule noroot_events, rule ext) +apply (frule vd_cons, frule vt_grant_os, frule noroot_events) apply (case_tac "f = f'", simp) apply (induct f', simp add:sroot_only, simp) apply (frule parentf_in_current', simp+) -apply clarsimp -apply (case_tac "f = f'", simp+) -apply (simp (no_asm_simp) add:cf2sfile_def) -apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps +apply (case_tac "f = f'", simp) +apply (simp add:cf2sfile_path is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps get_parentfs_ctxts_simps split:if_splits option.splits) done lemma cf2sfile_mkdir2: - "\valid (Open p f flag fd (Some inum) # s); is_file s f'\ - \ cf2sfile (Open p f flag fd (Some inum) # s) f' True = cf2sfile s f' True" + "\valid (Mkdir p f i # s); is_file s f'\ + \ cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'" apply (frule vd_cons, drule is_file_in_current) -by (simp add:cf2sfile_open_some1) +by (simp add:cf2sfile_mkdir1) lemma cf2sfile_mkdir3: - "\valid (Open p f flag fd (Some inum) # s); is_dir s f'\ - \ cf2sfile (Open p f flag fd (Some inum) # s) f' False = cf2sfile s f' False" + "\valid (Mkdir p f i # s); is_dir s f'\ + \ cf2sfile (Mkdir p f i # s) f' = cf2sfile s f'" apply (frule vd_cons, drule is_dir_in_current) -by (simp add:cf2sfile_open_some1) +by (simp add:cf2sfile_mkdir1) +lemma cf2sfile_mkdir4: + "valid (Mkdir p f i # s) + \ cf2sfile (Mkdir p f i # s) f = (case (parent f) of + Some pf \ (case (sectxt_of_obj (Mkdir p f i # s) (O_dir f), sectxt_of_obj s (O_dir pf), + get_parentfs_ctxts s pf) of + (Some sec, Some psec, Some asecs) \ Some (Created, sec, Some psec, set asecs) + | _ \ None) + | None \ None)" +apply (frule vd_cons, frule vt_grant_os, frule noroot_events) +apply (case_tac f, simp) +apply (clarsimp simp:os_grant.simps) +apply (simp add:sectxt_of_obj_simps) +apply (frule current_proc_has_sec, simp) +apply (frule is_dir_has_sec, simp) +apply (frule get_pfs_secs_prop, simp) +apply (frule is_dir_not_file) +apply (auto simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps + get_parentfs_ctxts_simps split:option.splits if_splits + dest:not_deleted_init_dir is_dir_in_current not_deleted_init_file is_file_in_current) +done lemma cf2sfile_mkdir: - "valid (Mkdir p f i # s) - \ cf2sfile (Mkdir p f i # s) = (\ f' b. - if (f' = f \ \ b) + "\valid (Mkdir p f i # s); f' \ current_files (Mkdir p f i # s)\ + \ cf2sfile (Mkdir p f i # s) f' = ( + if (f' = f) then (case (parent f) of Some pf \ (case (sectxt_of_obj (Mkdir p f i # s) (O_dir f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of (Some sec, Some psec, Some asecs) \ Some (Created, sec, Some psec, set asecs) | _ \ None) | None \ None) - else cf2sfile s f' b)" + else cf2sfile s f')" +apply (case_tac "f = f'") +apply (simp add:cf2sfile_mkdir4 split:option.splits) +apply (simp add:cf2sfile_mkdir1 current_files_simps) +done + +lemma cf2sfile_linkhard1: + "\valid (LinkHard p oldf f # s); f' \ current_files s\ + \ cf2sfile (LinkHard p oldf f# s) f' = cf2sfile s f'" +apply (frule vd_cons, frule vt_grant_os, frule noroot_events) +apply (case_tac "f = f'", simp) +apply (induct f', simp add:sroot_only, simp) +apply (frule parentf_in_current', simp+) +apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps + get_parentfs_ctxts_simps split:if_splits option.splits) +done + +lemma cf2sfile_linkhard2: + "\valid (LinkHard p oldf f # s); is_file s f'\ + \ cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'" +apply (frule vd_cons, drule is_file_in_current) +by (simp add:cf2sfile_linkhard1) + +lemma cf2sfile_linkhard3: + "\valid (LinkHard p oldf f # s); is_dir s f'\ + \ cf2sfile (LinkHard p oldf f # s) f' = cf2sfile s f'" +apply (frule vd_cons, drule is_dir_in_current) +by (simp add:cf2sfile_linkhard1) + +lemma cf2sfile_linkhard4: + "valid (LinkHard p oldf f # s) + \ cf2sfile (LinkHard p oldf f # s) f = (case (parent f) of + Some pf \ (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), + get_parentfs_ctxts s pf) of + (Some sec, Some psec, Some asecs) \ Some (Created, sec, Some psec, set asecs) + | _ \ None) + | None \ None)" +apply (frule vd_cons, frule vt_grant_os, frule noroot_events) +apply (case_tac f, simp) +apply (simp add:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps + get_parentfs_ctxts_simps) +apply (rule impI, (erule conjE)+) +apply (drule not_deleted_init_file, simp+) +apply (simp add:is_file_in_current) +done + +lemma cf2sfile_linkhard: + "\valid (LinkHard p oldf f # s); f' \ current_files (LinkHard p oldf f # s)\ + \ cf2sfile (LinkHard p oldf f # s) f' = ( + if (f' = f) + then (case (parent f) of + Some pf \ (case (sectxt_of_obj (LinkHard p oldf f # s) (O_file f), sectxt_of_obj s (O_dir pf), + get_parentfs_ctxts s pf) of + (Some sec, Some psec, Some asecs) \ Some (Created, sec, Some psec, set asecs) + | _ \ None) + | None \ None) + else cf2sfile s f')" +apply (case_tac "f = f'") +apply (simp add:cf2sfile_linkhard4 split:option.splits) +apply (simp add:cf2sfile_linkhard1 current_files_simps) +done + +lemma cf2sfile_other: + "\ff \ current_files s; + \ p f flag fd opt. e \ Open p f flag fd opt; + \ p fd. e \ CloseFd p fd; + \ p f. e \ UnLink p f; + \ p f. e \ Rmdir p f; + \ p f i. e \ Mkdir p f i; + \ p f f'. e \ LinkHard p f f'; + valid (e # s)\ \ cf2sfile (e # s) ff = cf2sfile s ff" apply (frule vd_cons, frule vt_grant_os) -apply (rule ext, rule ext) +apply (induct ff, simp add:sroot_only) +apply (frule parentf_in_current', simp+, case_tac e) +apply (auto simp:current_files_simps is_file_simps is_dir_simps sectxt_of_obj_simps cf2sfile_path + split:if_splits option.splits) +done -apply (auto simp:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps - get_parentfs_ctxts_simps split:if_splits option.splits) +lemma cf2sfile_unlink: + "\valid (UnLink p f # s); f' \ current_files (UnLink p f # s)\ + \ cf2sfile (UnLink p f # s) f' = cf2sfile s f'" +apply (frule vd_cons, frule vt_grant_os) +apply (simp add:current_files_simps split:if_splits) +apply (auto simp:cf2sfile_def sectxt_of_obj_simps get_parentfs_ctxts_simps is_file_simps is_dir_simps + split:if_splits option.splits) - - +lemmas cf2sfile_simps = cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_other +