no_shm_selinux/Enrich2.thy
changeset 84 cebdef333899
parent 83 e79e3a8a4ceb
child 85 1d1aa5bdd37d
equal deleted inserted replaced
83:e79e3a8a4ceb 84:cebdef333899
     2 imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
     2 imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
     3  Temp Enrich Proc_fd_of_file_prop
     3  Temp Enrich Proc_fd_of_file_prop
     4 begin
     4 begin
     5 
     5 
     6 context tainting_s begin
     6 context tainting_s begin
       
     7 
       
     8 (* \<And> *)
       
     9 lemma current_proc_fds_in_curp:
       
    10   "\<lbrakk>fd \<in> current_proc_fds s p; valid s\<rbrakk> \<Longrightarrow> p \<in> current_procs s"
       
    11 apply (induct s)
       
    12 apply (simp add:init_fds_of_proc_prop1)
       
    13 apply (frule vt_grant_os, frule vd_cons)
       
    14 apply (case_tac a, auto split:if_splits option.splits)
       
    15 done
     7 
    16 
     8 lemma get_parentfs_ctxts_prop:
    17 lemma get_parentfs_ctxts_prop:
     9   "\<lbrakk>get_parentfs_ctxts s (a # f) = Some ctxts; sectxt_of_obj s (O_dir f) = Some ctxt; valid s\<rbrakk>
    18   "\<lbrakk>get_parentfs_ctxts s (a # f) = Some ctxts; sectxt_of_obj s (O_dir f) = Some ctxt; valid s\<rbrakk>
    10    \<Longrightarrow> ctxt \<in> set (ctxts)"
    19    \<Longrightarrow> ctxt \<in> set (ctxts)"
    11 apply (induct f)
    20 apply (induct f)
    33 apply (erule get_pfs_secs_prop, simp)
    42 apply (erule get_pfs_secs_prop, simp)
    34 apply (erule_tac search_check_allp_intro, simp_all)
    43 apply (erule_tac search_check_allp_intro, simp_all)
    35 apply (simp add:parentf_is_dir_prop2)
    44 apply (simp add:parentf_is_dir_prop2)
    36 done
    45 done
    37 
    46 
       
    47 lemma enrich_proc_dup_ffds':
       
    48   "\<lbrakk>fd \<notin> current_proc_fds (enrich_proc s p p') p'; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
       
    49    \<Longrightarrow> fd \<notin> proc_file_fds s p \<and> file_of_proc_fd s p fd = None"
       
    50 apply (auto simp:enrich_proc_dup_ffds_eq_fds)
       
    51 apply (simp add:proc_file_fds_def)
       
    52 done
       
    53 
       
    54 lemma enrich_proc_cur_inof:
       
    55   "\<lbrakk>valid s; no_del_event s\<rbrakk> \<Longrightarrow> inum_of_file (enrich_proc s p p') f = inum_of_file s f"
       
    56 apply (induct s arbitrary:f)
       
    57 apply simp
       
    58 apply (frule vd_cons, frule vt_grant_os, frule vt_grant)
       
    59 apply (case_tac a, auto)
       
    60 apply (auto split:option.splits simp del:grant.simps)
       
    61 done
       
    62 
       
    63 lemma not_all_procs_sock:
       
    64   "\<lbrakk>p' \<notin> all_procs s; valid s\<rbrakk> \<Longrightarrow> inum_of_socket s (p', fd) = None"
       
    65 apply (frule not_all_procs_prop3)
       
    66 apply (case_tac "inum_of_socket s (p', fd)", simp_all)
       
    67 apply (drule cn_in_curp', simp+)
       
    68 done
       
    69 
       
    70 lemma enrich_proc_cur_inos:
       
    71   "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
       
    72    \<Longrightarrow> inum_of_socket (enrich_proc s p p') (tp, fd) = inum_of_socket s (tp, fd)"
       
    73 apply (induct s arbitrary:tp)
       
    74 apply simp
       
    75 apply (frule vd_cons, frule vt_grant_os)
       
    76 apply (case_tac a, auto split:option.splits simp:not_all_procs_sock)
       
    77 apply (simp add:proc_file_fds_def, erule exE)
       
    78 apply (case_tac "inum_of_socket s (nat1, fd)", simp_all)
       
    79 apply (drule filefd_socket_conflict, simp_all add:current_sockets_def)
       
    80 done
       
    81 
       
    82 lemma enrich_proc_cur_inums:
       
    83   "\<lbrakk>p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
       
    84    \<Longrightarrow> current_inode_nums (enrich_proc s p p') = current_inode_nums s"
       
    85 apply (auto simp:current_inode_nums_def current_file_inums_def 
       
    86   current_sock_inums_def enrich_proc_cur_inof enrich_proc_cur_inos)
       
    87 done
       
    88 
       
    89 lemma enrich_proc_cur_itag:
       
    90   "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
       
    91    \<Longrightarrow> itag_of_inum (enrich_proc s p p') i = itag_of_inum s i"
       
    92 apply (induct s)
       
    93 apply simp
       
    94 apply (frule vd_cons, frule vt_grant_os)
       
    95 apply (case_tac a, auto split:option.splits t_socket_type.splits)
       
    96 done
       
    97 
       
    98 lemma enrich_proc_cur_tcps:
       
    99   "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
       
   100    \<Longrightarrow> is_tcp_sock (enrich_proc s p p') = is_tcp_sock s"
       
   101 apply (rule ext, case_tac x)
       
   102 apply (auto simp add:is_tcp_sock_def enrich_proc_cur_itag enrich_proc_cur_inos
       
   103   split:option.splits t_inode_tag.splits)
       
   104 done
       
   105 
       
   106 lemma enrich_proc_cur_udps:
       
   107   "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
       
   108    \<Longrightarrow> is_udp_sock (enrich_proc s p p') = is_udp_sock s"
       
   109 apply (rule ext, case_tac x)
       
   110 apply (auto simp add:is_udp_sock_def enrich_proc_cur_itag enrich_proc_cur_inos
       
   111   split:option.splits t_inode_tag.splits)
       
   112 done
       
   113 
       
   114 lemma enrich_proc_cur_msgqs:
       
   115   "valid s \<Longrightarrow> current_msgqs (enrich_proc s p p') = current_msgqs s"
       
   116 apply (induct s, simp)
       
   117 apply (frule vt_grant_os, frule vd_cons)
       
   118 apply (case_tac a, auto)
       
   119 done
       
   120 
       
   121 lemma enrich_proc_cur_msgs:
       
   122   "valid s \<Longrightarrow> msgs_of_queue (enrich_proc s p p') q = msgs_of_queue s q "
       
   123 apply (induct s, simp)
       
   124 apply (frule vt_grant_os, frule vd_cons)
       
   125 apply (case_tac a, auto)
       
   126 done
       
   127 
       
   128 lemma enrich_proc_cur_procs:
       
   129   "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s\<rbrakk> 
       
   130    \<Longrightarrow> current_procs (enrich_proc s p p') = current_procs s \<union> {p'}"
       
   131 apply (induct s, simp add:is_created_proc_def)
       
   132 apply (frule vt_grant_os, frule vd_cons)
       
   133 apply (case_tac a, auto simp:is_created_proc_simps)
       
   134 done
       
   135 
       
   136 lemma enrich_proc_cur_files:
       
   137   "\<lbrakk>valid s; no_del_event s\<rbrakk> \<Longrightarrow> current_files (enrich_proc s p p') = current_files s"
       
   138 apply (auto simp:current_files_def)
       
   139 apply (simp add: enrich_proc_cur_inof)+
       
   140 done
       
   141 
       
   142 lemma enrich_proc_cur_fds1:
       
   143   "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s; tp \<in> current_procs s\<rbrakk>
       
   144    \<Longrightarrow> current_proc_fds (enrich_proc s p p') tp = current_proc_fds s tp"
       
   145 apply (induct s, simp add:is_created_proc_def)
       
   146 apply (frule vt_grant_os, frule vd_cons)
       
   147 apply (frule not_all_procs_prop3)
       
   148 apply (case_tac a)
       
   149 apply (auto simp:is_created_proc_simps)
       
   150 done
       
   151 
       
   152 lemma enrich_proc_cur_fds1':
       
   153   "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s; tp \<noteq> p'\<rbrakk>
       
   154    \<Longrightarrow> current_proc_fds (enrich_proc s p p') tp = current_proc_fds s tp"
       
   155 apply (induct s, simp add:is_created_proc_def)
       
   156 apply (frule vt_grant_os, frule vd_cons)
       
   157 apply (frule not_all_procs_prop3)
       
   158 apply (case_tac a)
       
   159 apply (auto simp:is_created_proc_simps)
       
   160 done
       
   161 
       
   162 lemma enrich_proc_cur_fds:
       
   163   "\<lbrakk>p' \<notin> all_procs s; no_del_event s; is_created_proc s p; valid s\<rbrakk>
       
   164    \<Longrightarrow> current_proc_fds (enrich_proc s p p') tp = (if (tp = p') then proc_file_fds s p else current_proc_fds s tp)"
       
   165 apply (simp add:enrich_proc_cur_fds1' enrich_proc_dup_ffds_eq_fds split:if_splits)
       
   166 done
       
   167 
       
   168 lemma enrich_proc_not_alive:
       
   169   "\<lbrakk>enrich_not_alive s (E_proc p') obj; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
       
   170   \<Longrightarrow> enrich_not_alive (enrich_proc s p p') (E_proc p') obj"
       
   171 apply (case_tac obj)
       
   172 apply (simp_all add:enrich_proc_cur_procs enrich_proc_cur_files enrich_proc_cur_inums 
       
   173   enrich_proc_cur_msgqs enrich_proc_cur_msgs enrich_proc_cur_fds)
       
   174 done
       
   175 
       
   176 lemma enrich_proc_filefd:
       
   177   "\<lbrakk>file_of_proc_fd s tp fd = Some f; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
       
   178   \<Longrightarrow> file_of_proc_fd (enrich_proc s p p') tp fd = Some f"
       
   179 apply (induct s arbitrary:tp, simp add:is_created_proc_def)
       
   180 apply (frule vt_grant_os, frule vd_cons)
       
   181 apply (frule not_all_procs_prop3)
       
   182 apply (case_tac a)
       
   183 apply (auto simp:is_created_proc_simps dest:proc_fd_in_procs split:if_splits)
       
   184 done
       
   185 
       
   186 lemma enrich_proc_flagfd:
       
   187   "\<lbrakk>flags_of_proc_fd s tp fd = Some f; is_created_proc s p; p' \<notin> all_procs s; no_del_event s; valid s\<rbrakk>
       
   188   \<Longrightarrow> flags_of_proc_fd (enrich_proc s p p') tp fd = Some f"
       
   189 apply (induct s arbitrary:tp, simp add:is_created_proc_def)
       
   190 apply (frule vt_grant_os, frule vd_cons)
       
   191 apply (frule not_all_procs_prop3)
       
   192 apply (case_tac a)
       
   193 apply (auto simp:is_created_proc_simps dest:proc_fd_in_procs current_fflag_has_ffd split:if_splits option.splits)
       
   194 done
       
   195 
       
   196 lemma enrich_proc_hungs:
       
   197   "\<lbrakk>valid s; no_del_event s\<rbrakk> \<Longrightarrow> files_hung_by_del (enrich_proc s p p') = files_hung_by_del s"
       
   198 apply (induct s, simp)
       
   199 apply (frule vt_grant_os, frule vd_cons)
       
   200 apply (case_tac a, auto simp:files_hung_by_del.simps)
       
   201 done
       
   202 
       
   203 lemma enrich_proc_is_file:
       
   204   "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
       
   205    \<Longrightarrow> is_file (enrich_proc s p p') = is_file s"
       
   206 apply (rule ext, case_tac x)
       
   207 apply (auto simp add:is_file_def enrich_proc_cur_itag enrich_proc_cur_inof
       
   208   split:option.splits t_inode_tag.splits)
       
   209 done
       
   210 
       
   211 lemma enrich_proc_is_dir:
       
   212   "\<lbrakk>valid s; no_del_event s; p' \<notin> all_procs s\<rbrakk> 
       
   213    \<Longrightarrow> is_dir (enrich_proc s p p') = is_dir s"
       
   214 apply (rule ext, case_tac x)
       
   215 apply (auto simp add:is_dir_def enrich_proc_cur_itag enrich_proc_cur_inof
       
   216   split:option.splits t_inode_tag.splits)
       
   217 done
       
   218 
       
   219 lemma enrich_proc_alive:
       
   220   "\<lbrakk>alive s obj; valid s; is_created_proc s p; p' \<notin> all_procs s; no_del_event s\<rbrakk>
       
   221    \<Longrightarrow> alive (enrich_proc s p p') obj"
       
   222 apply (case_tac obj)
       
   223 apply (simp_all add:enrich_proc_is_file enrich_proc_is_dir enrich_proc_cur_msgqs 
       
   224   enrich_proc_cur_msgs enrich_proc_cur_procs enrich_proc_cur_fds
       
   225   enrich_proc_cur_tcps enrich_proc_cur_udps)
       
   226 apply (rule impI, simp)
       
   227 apply (drule current_proc_fds_in_curp, simp, simp add:not_all_procs_prop3)
       
   228 done
       
   229 
    38 lemma enrich_proc_prop:
   230 lemma enrich_proc_prop:
    39   "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk>
   231   "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s; no_del_event s\<rbrakk>
    40    \<Longrightarrow> valid (enrich_proc s p p') \<and> 
   232    \<Longrightarrow> valid (enrich_proc s p p') \<and> 
    41        (\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj) \<and> 
       
    42        (\<forall> obj. enrich_not_alive s obj \<longrightarrow> enrich_not_alive (enrich_proc s p p') obj) \<and>
       
    43        (files_hung_by_del (enrich_proc s p p') = files_hung_by_del s) \<and> 
       
    44        (\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
   233        (\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
    45        (\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and> 
   234        (\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and> 
    46        (\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and> 
   235        (\<forall> q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and> 
    47        (\<forall> tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> file_of_proc_fd (enrich_proc s p p') tp fd = Some f) \<and>
       
    48        (\<forall> tp fd flags. flags_of_proc_fd s tp fd = Some flags \<longrightarrow> 
       
    49                       flags_of_proc_fd (enrich_proc s p p') tp fd = Some flags) \<and>
       
    50        (\<forall> q. msgs_of_queue (enrich_proc s p p') q = msgs_of_queue s q) \<and>
       
    51        (\<forall> tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>
   236        (\<forall> tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>
    52        (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
   237        (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
    53        (\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
   238        (\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
    54 proof (induct s)
   239 proof (induct s)
    55   case Nil
   240   case Nil
    56   thus ?case by (auto simp:is_created_proc_def)
   241   thus ?case by (auto simp:is_created_proc_def)
    57 next
   242 next
    58   case (Cons e s)
   243   case (Cons e s)
    59   hence vd_cons': "valid (e # s)" and created_cons: "is_created_proc (e # s) p"
   244   hence vd_cons': "valid (e # s)" and created_cons: "is_created_proc (e # s) p"
    60     and all_procs_cons: "p' \<notin> all_procs (e # s)" and vd: "valid s" 
   245     and all_procs_cons: "p' \<notin> all_procs (e # s)" and vd: "valid s" 
    61     and os: "os_grant s e" and grant: "grant s e"
   246     and os: "os_grant s e" and grant: "grant s e" 
       
   247     and nodel_cons: "no_del_event (e # s)"
    62     by (auto dest:vd_cons' vt_grant_os vt_grant)
   248     by (auto dest:vd_cons' vt_grant_os vt_grant)
    63   from all_procs_cons have all_procs: "p' \<notin> all_procs s" by (case_tac e, auto)
   249   from all_procs_cons have all_procs: "p' \<notin> all_procs s" by (case_tac e, auto)
       
   250   from nodel_cons have nodel: "no_del_event s" by (case_tac e, auto)
    64   from Cons have pre: "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p') \<and>
   251   from Cons have pre: "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p') \<and>
    65      (\<forall>obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj) \<and>
       
    66      (\<forall>obj. enrich_not_alive s obj \<longrightarrow> enrich_not_alive (enrich_proc s p p') obj) \<and>
       
    67      files_hung_by_del (enrich_proc s p p') = files_hung_by_del s \<and>
       
    68      (\<forall>tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
   252      (\<forall>tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp) \<and>
    69      (\<forall>f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
   253      (\<forall>f. f \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') f = cf2sfile s f) \<and>
    70      (\<forall>q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and>
   254      (\<forall>q. q \<in> current_msgqs s \<longrightarrow> cq2smsgq (enrich_proc s p p') q = cq2smsgq s q) \<and>
    71      (\<forall>tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> file_of_proc_fd (enrich_proc s p p') tp fd = Some f) \<and>
       
    72      (\<forall>tp fd flags.
       
    73          flags_of_proc_fd s tp fd = Some flags \<longrightarrow> flags_of_proc_fd (enrich_proc s p p') tp fd = Some flags) \<and>
       
    74      (\<forall>q. msgs_of_queue (enrich_proc s p p') q = msgs_of_queue s q) \<and>
       
    75      (\<forall>tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>     
   255      (\<forall>tp fd. fd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd) \<and>     
    76      (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
   256      (cp2sproc (enrich_proc s p p') p' = cp2sproc s p) \<and>
    77      (\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
   257      (\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd)"
    78     using vd all_procs by auto
   258     using vd all_procs nodel by auto
    79   have alive_pre: "is_created_proc s p \<Longrightarrow> (\<forall>obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj)"
       
    80     using pre by simp
       
    81   hence curf_pre: "is_created_proc s p \<Longrightarrow> (\<forall>f. f \<in> current_files s \<longrightarrow> f \<in> current_files (enrich_proc s p p'))"
       
    82     using vd apply auto
       
    83     apply (drule is_file_or_dir, simp)
       
    84     apply (erule disjE)
       
    85     apply (erule_tac x = "O_file f" in allE, simp add:is_file_in_current)
       
    86     apply (erule_tac x = "O_dir f" in allE, simp add:is_dir_in_current)
       
    87     done
       
    88   have vd_enrich_cons: "valid (enrich_proc (e # s) p p')"
   259   have vd_enrich_cons: "valid (enrich_proc (e # s) p p')"
    89   proof-
   260   proof-
    90     from pre have pre': "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p')" by simp
   261     from pre have pre': "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p')" by simp
    91     have "is_created_proc s p \<Longrightarrow> valid (e # enrich_proc s p p')" 
   262     have "is_created_proc s p \<Longrightarrow> valid (e # enrich_proc s p p')" 
    92       apply (frule pre')
   263       apply (frule pre')
    93       apply (erule_tac s = s in enrich_valid_intro_cons)
   264       apply (erule_tac s = s and obj' = "E_proc p'" in enrich_valid_intro_cons)
    94       apply (simp_all add:os grant vd pre)
   265       apply (simp_all add: pre nodel_cons all_procs_cons vd_cons')
    95       done  
   266       apply (clarsimp simp:enrich_proc_alive nodel all_procs vd)
       
   267       apply (rule allI, rule impI, erule enrich_proc_not_alive)
       
   268       apply (simp_all add:nodel all_procs vd enrich_proc_hungs enrich_proc_cur_msgs)
       
   269       apply ((rule allI| rule impI)+, erule enrich_proc_filefd)
       
   270       apply (simp_all add:nodel all_procs vd)
       
   271       apply ((rule allI| rule impI)+, erule enrich_proc_flagfd)
       
   272       apply (simp_all add:nodel all_procs vd)
       
   273       done
    96     moreover have "\<And>f fds. \<lbrakk>valid (Execve p f fds # enrich_proc s p p'); is_created_proc s p; 
   274     moreover have "\<And>f fds. \<lbrakk>valid (Execve p f fds # enrich_proc s p p'); is_created_proc s p; 
    97       valid (Execve p f fds # s); p' \<notin> all_procs s\<rbrakk>
   275       valid (Execve p f fds # s); p' \<notin> all_procs s\<rbrakk>
    98       \<Longrightarrow> valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
   276       \<Longrightarrow> valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
    99     proof-
   277     proof-
   100       fix f fds
   278       fix f fds
   101       assume a1: "valid (Execve p f fds # enrich_proc s p p')" and a2: "is_created_proc s p"
   279       assume a1: "valid (Execve p f fds # enrich_proc s p p')" and a2: "is_created_proc s p"
   102         and a3: "valid (Execve p f fds # s)" and a0: "p' \<notin> all_procs s"
   280         and a3: "valid (Execve p f fds # s)" and a0: "p' \<notin> all_procs s"
   103       have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
   281       have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
   104         and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
   282         and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
   105         and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
   283         and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
   106         and ffd_remain: "\<forall>tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> 
       
   107                                    file_of_proc_fd (enrich_proc s p p') tp fd = Some f"
       
   108         and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
   284         and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
   109         and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
   285         and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
   110         using pre a2 by auto
   286         using pre a2
       
   287         by auto
   111       show "valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
   288       show "valid (Execve p' f (fds \<inter> proc_file_fds s p) # Execve p f fds # enrich_proc s p p')"
   112       proof-
   289       proof-
   113         from a0 a3 have a0': "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
   290         from a0 a3 have a0': "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
   114         from a3 have grant: "grant s (Execve p f fds)" and os: "os_grant s (Execve p f fds)"
   291         from a3 have grant: "grant s (Execve p f fds)" and os: "os_grant s (Execve p f fds)"
   115           by (auto dest:vt_grant_os vt_grant simp del:os_grant.simps)
   292           by (auto dest:vt_grant_os vt_grant simp del:os_grant.simps)
   116         have f_in: "is_file (enrich_proc s p p') f" 
   293         have f_in: "is_file (enrich_proc s p p') f"
   117         proof-
   294           using vd nodel os all_procs
   118           from pre a2
   295           by (auto dest:vt_grant_os simp:enrich_proc_is_file)
   119           have a4: "\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj"
       
   120             by (auto)
       
   121           show ?thesis using a3 a4
       
   122             apply (erule_tac x = "O_file f" in allE)
       
   123             by (auto dest:vt_grant_os)
       
   124         qed
       
   125         moreover have a5: "proc_file_fds s p \<subseteq> proc_file_fds (Execve p f fds # enrich_proc s p p') p'" 
   296         moreover have a5: "proc_file_fds s p \<subseteq> proc_file_fds (Execve p f fds # enrich_proc s p p') p'" 
   126           using a3 a0'
   297           using a3 a0'
   127           apply (frule_tac vt_grant_os)
   298           apply (frule_tac vt_grant_os)
   128           apply (auto simp:proc_file_fds_def)
   299           apply (auto simp:proc_file_fds_def)
   129           apply (rule_tac x = fa in exI)
   300           apply (rule_tac x = fa in exI)
   172             using p1 p2 p2' vd cf2sf f_in f_in' grant p3 f_in a1
   343             using p1 p2 p2' vd cf2sf f_in f_in' grant p3 f_in a1
   173             apply (rule_tac s = s in enrich_search_check)
   344             apply (rule_tac s = s in enrich_search_check)
   174             apply (simp_all add:is_file_simps)
   345             apply (simp_all add:is_file_simps)
   175             apply (rule allI, rule impI, erule_tac x = fa in allE, simp)
   346             apply (rule allI, rule impI, erule_tac x = fa in allE, simp)
   176             apply (drule_tac ff = fa in cf2sfile_other')
   347             apply (drule_tac ff = fa in cf2sfile_other')
   177             by (auto simp:a2 curf_pre)
   348             apply (auto simp:a2 enrich_proc_cur_files nodel)
       
   349             done
   178           ultimately show ?thesis 
   350           ultimately show ?thesis 
   179             using p1' p2' p3
   351             using p1' p2' p3
   180             apply (simp split:option.splits)
   352             apply (simp split:option.splits)
   181             using grant p1 p2
   353             using grant p1 p2
   182             apply simp
   354             apply simp
   202       assume a1: "valid (Open p f flags fd opt # enrich_proc s p p')" and a2: "is_created_proc s p"
   374       assume a1: "valid (Open p f flags fd opt # enrich_proc s p p')" and a2: "is_created_proc s p"
   203         and a3: "valid (Open p f flags fd opt # s)" and a4: "p' \<notin> all_procs s"
   375         and a3: "valid (Open p f flags fd opt # s)" and a4: "p' \<notin> all_procs s"
   204       have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
   376       have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
   205         and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
   377         and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
   206         and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
   378         and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
   207         and ffd_remain: "\<forall>tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> 
       
   208                                    file_of_proc_fd (enrich_proc s p p') tp fd = Some f"
       
   209         and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
   379         and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
   210         and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
   380         and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
   211         using pre a2 by auto
   381         using pre a2 by auto
   212       from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3 split:option.splits)
   382       from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3 split:option.splits)
   213       have a5: "p' \<in> current_procs (enrich_proc s p p')" 
   383       have a5: "p' \<in> current_procs (enrich_proc s p p')" 
   216         by (simp_all add:vd a4)
   386         by (simp_all add:vd a4)
   217       have a6: "is_file (Open p f flags fd opt # enrich_proc s p p') f"
   387       have a6: "is_file (Open p f flags fd opt # enrich_proc s p p') f"
   218         using a1 a3
   388         using a1 a3
   219         by (auto simp:is_file_open dest:vt_grant_os)
   389         by (auto simp:is_file_open dest:vt_grant_os)
   220       have a7: "fd \<notin> current_proc_fds (enrich_proc s p p') p'"
   390       have a7: "fd \<notin> current_proc_fds (enrich_proc s p p') p'"
   221         using a2 a4 vd
   391         using a2 a4 vd nodel
   222         apply (simp add:enrich_proc_dup_ffds_eq_fds)
   392         apply (simp add:enrich_proc_dup_ffds_eq_fds)
   223         apply (rule notI)
   393         apply (rule notI)
   224         apply (drule_tac p = p in file_fds_subset_pfds)
   394         apply (drule_tac p = p in file_fds_subset_pfds)
   225         apply (drule set_mp, simp)
   395         apply (drule set_mp, simp)
   226         using a3
   396         using a3
   231       from a3 have grant: "grant s (Open p f flags fd opt)" and os: "os_grant s (Open p f flags fd opt)"
   401       from a3 have grant: "grant s (Open p f flags fd opt)" and os: "os_grant s (Open p f flags fd opt)"
   232         by (auto dest:vt_grant_os vt_grant)
   402         by (auto dest:vt_grant_os vt_grant)
   233       show "valid (Open p' f (remove_create_flag flags) fd None # Open p f flags fd opt # enrich_proc s p p')"
   403       show "valid (Open p' f (remove_create_flag flags) fd None # Open p f flags fd opt # enrich_proc s p p')"
   234       proof (cases opt)
   404       proof (cases opt)
   235         case None
   405         case None
   236         have f_in: "is_file (enrich_proc s p p') f" 
   406         have f_in: "is_file (enrich_proc s p p') f"
   237         proof-
   407           using vd nodel os all_procs None
   238           from pre a2
   408           by (auto dest:vt_grant_os simp:enrich_proc_is_file) 
   239           have a4: "\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj"
       
   240             by (auto)
       
   241           show ?thesis using a3 a4 None
       
   242             apply (erule_tac x = "O_file f" in allE)
       
   243             by (auto dest:vt_grant_os)
       
   244         qed
       
   245         from grant None obtain up rp tp uf rf tf 
   409         from grant None obtain up rp tp uf rf tf 
   246           where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
   410           where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
   247           and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
   411           and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
   248           apply (simp split:option.splits)
   412           apply (simp split:option.splits)
   249           by (case_tac a, case_tac aa, blast)
   413           by (case_tac a, case_tac aa, blast)
   336             apply (case_tac "fa = f")
   500             apply (case_tac "fa = f")
   337             using os Some
   501             using os Some
   338             apply simp
   502             apply simp
   339             apply (drule_tac f' = fa in cf2sfile_open)
   503             apply (drule_tac f' = fa in cf2sfile_open)
   340             apply (simp add:current_files_simps)
   504             apply (simp add:current_files_simps)
   341             using curf_pre a2
   505             using enrich_proc_cur_files a2 nodel
   342             apply simp
   506             apply simp
   343             apply simp
   507             apply simp
   344             using cf2sf
   508             using cf2sf
   345             apply simp
   509             apply simp
   346             done
   510             done
   377       from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
   541       from a4 a3 have a0: "p' \<noteq> p" by (auto dest!:vt_grant_os not_all_procs_prop3)
   378       have "p' \<in> current_procs (enrich_proc s p p')" 
   542       have "p' \<in> current_procs (enrich_proc s p p')" 
   379         using a2 a3 vd
   543         using a2 a3 vd
   380         by (auto intro:enrich_proc_dup_in)
   544         by (auto intro:enrich_proc_dup_in)
   381       moreover have "fd \<in> current_proc_fds (enrich_proc s p p') p'"      
   545       moreover have "fd \<in> current_proc_fds (enrich_proc s p p') p'"      
   382         using a5 a2 a3 vd pre'
   546         using a5 a2 a3 vd pre' nodel
   383         apply (simp)
   547         apply (simp)
   384         apply (drule_tac s = "enrich_proc s p p'" and p = p' in file_fds_subset_pfds)
   548         apply (drule_tac s = "enrich_proc s p p'" and p = p' in file_fds_subset_pfds)
   385         apply (erule set_mp)
   549         apply (erule set_mp)
   386         apply (simp add:enrich_proc_dup_ffds)
   550         apply (simp add:enrich_proc_dup_ffds)
   387         done
   551         done
   400       from a3 have os: "os_grant s (ReadFile p fd)" and grant: "grant s (ReadFile p fd)"
   564       from a3 have os: "os_grant s (ReadFile p fd)" and grant: "grant s (ReadFile p fd)"
   401         by (auto dest:vt_grant_os vt_grant)
   565         by (auto dest:vt_grant_os vt_grant)
   402       have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
   566       have cp2sp: "\<forall> tp. tp \<in> current_procs s \<longrightarrow> cp2sproc (enrich_proc s p p') tp = cp2sproc s tp"
   403         and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
   567         and cf2sf: "\<forall> tf. tf \<in> current_files s \<longrightarrow> cf2sfile (enrich_proc s p p') tf = cf2sfile s tf"
   404         and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
   568         and cfd2sfd: "\<forall> tp tfd. tfd \<in> proc_file_fds s tp \<longrightarrow> cfd2sfd (enrich_proc s p p') tp tfd = cfd2sfd s tp tfd"
   405         and ffd_remain: "\<forall>tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> 
       
   406                                    file_of_proc_fd (enrich_proc s p p') tp fd = Some f"
       
   407         and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
   569         and dup_sp: "cp2sproc (enrich_proc s p p') p' = cp2sproc s p"
   408         and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
   570         and dup_sfd: "\<forall> fd. fd \<in> proc_file_fds s p \<longrightarrow> cfd2sfd (enrich_proc s p p') p' fd = cfd2sfd s p fd"
   409         using pre a2 by auto
   571         using pre a2 by auto
   410       have vd_enrich: "valid (enrich_proc s p p')" using a1 by (auto dest:valid.cases)
   572       have vd_enrich: "valid (enrich_proc s p p')" using a1 by (auto dest:valid.cases)
   411       show "valid (ReadFile p' fd # ReadFile p fd # enrich_proc s p p')"
   573       show "valid (ReadFile p' fd # ReadFile p fd # enrich_proc s p p')"
   412       proof-
   574       proof-
   413         have "os_grant (ReadFile p fd # enrich_proc s p p') (ReadFile p' fd)"
   575         have "os_grant (ReadFile p fd # enrich_proc s p p') (ReadFile p' fd)"
   414           using a1 a2 a4 vd os
   576           using a1 a2 a4 vd os nodel
   415           apply (clarsimp simp:current_files_simps enrich_proc_dup_in enrich_proc_dup_ffds_eq_fds)
   577           apply (clarsimp simp:current_files_simps enrich_proc_dup_in enrich_proc_dup_ffds_eq_fds)
   416           apply (simp add:proc_file_fds_def)
   578           apply (simp add:proc_file_fds_def)
   417           apply (rule conjI)
   579           apply (rule conjI)
   418           apply (rule_tac x = f in exI, simp add:enrich_proc_dup_ffd)
   580           apply (rule_tac x = f in exI, simp add:enrich_proc_dup_ffd)
   419           using curf_pre
   581           using enrich_proc_cur_files
   420           apply (simp)
   582           apply (simp)
   421           apply (drule enrich_proc_dup_fflags)
   583           apply (drule enrich_proc_dup_fflags)
   422           apply simp_all
   584           apply simp_all
   423           apply (erule disjE)
   585           apply (erule disjE)
   424           apply auto
   586           apply auto
   433             by (auto split:option.splits) 
   595             by (auto split:option.splits) 
   434           from os obtain flag where p0: "flags_of_proc_fd s p fd = Some flag"
   596           from os obtain flag where p0: "flags_of_proc_fd s p fd = Some flag"
   435             by auto
   597             by auto
   436           from os have f_in_s: "f \<in> current_files s" using p1 by simp
   598           from os have f_in_s: "f \<in> current_files s" using p1 by simp
   437           from p1 vd have isfile_s: "is_file s f" by (erule_tac file_of_pfd_is_file, simp)
   599           from p1 vd have isfile_s: "is_file s f" by (erule_tac file_of_pfd_is_file, simp)
   438           with alive_pre a2 have isfile_s': "is_file (enrich_proc s p p') f"
   600           hence isfile_s': "is_file (enrich_proc s p p') f"
   439             apply simp
   601             using vd nodel all_procs a2
   440             apply (erule_tac x = "O_file f" in allE, simp)
   602             by (auto simp:enrich_proc_is_file) 
   441             done          
       
   442           from p0 obtain flag' where p0': "flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag'"
   603           from p0 obtain flag' where p0': "flags_of_proc_fd (enrich_proc s p p') p' fd = Some flag'"
   443             and p0'': "(flag' = flag) \<or> (flag' = remove_create_flag flag)"
   604             and p0'': "(flag' = flag) \<or> (flag' = remove_create_flag flag)"
   444             using a2 a4 vd
   605             using a2 a4 vd
   445             apply (drule_tac enrich_proc_dup_fflags)
   606             apply (drule_tac enrich_proc_dup_fflags)
   446             apply auto
   607             apply auto
   485       using created_cons vd_cons' all_procs_cons
   646       using created_cons vd_cons' all_procs_cons
   486       apply (case_tac e)
   647       apply (case_tac e)
   487       apply (auto simp:is_created_proc_simps split:if_splits)
   648       apply (auto simp:is_created_proc_simps split:if_splits)
   488       done
   649       done
   489   qed
   650   qed
   490   moreover have "\<forall>obj. alive (e # s) obj \<longrightarrow> alive (enrich_proc (e # s) p p') obj"
   651   moreover have "\<forall>tp fd. fd \<in> proc_file_fds (e # s) tp \<longrightarrow> 
       
   652     cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
   491   proof clarify
   653   proof clarify
   492     fix obj
   654     fix tp fd 
   493     assume a0: "alive (e # s) obj"
   655     assume a1: "fd \<in> proc_file_fds (e # s) tp"
   494     have a1: "is_created_proc s p \<Longrightarrow> \<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj"
   656     from a1 obtain f where a1': "file_of_proc_fd (e # s) tp fd = Some f" 
   495       using pre by auto
   657       by (auto simp:proc_file_fds_def)
   496     show "alive (enrich_proc (e # s) p p') obj" (*
   658     from pre have pre_sfd: "\<And> tp fd. \<lbrakk>fd \<in> proc_file_fds s tp; is_created_proc s p\<rbrakk> \<Longrightarrow>
   497     proof (cases e)
   659       cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd" by auto
   498       case (Execve tp f fds)
   660     hence pre_sfd': "\<And> tp fd f. \<lbrakk>file_of_proc_fd s tp fd = Some f; is_created_proc s p\<rbrakk> \<Longrightarrow>
   499       with created_cons a1
   661       cfd2sfd (enrich_proc s p p') tp fd = cfd2sfd s tp fd" by (auto simp:proc_file_fds_def)
   500       have b1: "\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p') obj" 
   662     hence pre_sfd'': "\<And> tp fd f proc. \<lbrakk>file_of_proc_fd s tp fd = Some f; is_created_proc s p; p = proc\<rbrakk> \<Longrightarrow>
   501         by (auto simp:is_created_proc_simps)
   663       cfd2sfd (enrich_proc s proc p') tp fd = cfd2sfd s tp fd" by (auto simp:proc_file_fds_def)
       
   664     from a1' all_procs_cons vd_cons' have a2: "tp \<noteq> p'"
       
   665       apply (drule_tac not_all_procs_prop3)
       
   666       apply (drule proc_fd_in_procs, simp)
       
   667       by (rule notI, simp)
       
   668     have a3: "p' \<noteq> p" using all_procs_cons created_cons
       
   669       apply (drule_tac not_all_procs_prop3)
       
   670       apply (rule notI, simp add:is_created_proc_def)
       
   671       done      
       
   672     have a4: "file_of_proc_fd (enrich_proc (e # s) p p') tp fd = Some f" 
       
   673       using a1' nodel_cons all_procs_cons a1' created_cons vd_cons'
       
   674       apply (frule_tac enrich_proc_filefd, simp_all)
       
   675       done
       
   676     show "cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
       
   677     proof-
       
   678       have b1: "\<And> proc f' fds. e = Execve proc f' fds
       
   679         \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
       
   680         using a4 vd_enrich_cons a1' vd_cons' created_cons
       
   681         apply (simp split:if_splits del:file_of_proc_fd.simps add:a2) 
       
   682         apply (simp only:cfd2sfd_execve)
       
   683         apply (drule_tac s = "Execve proc f' fds # enrich_proc s proc p'" in vd_cons)
       
   684         apply (simp split:if_splits add:a2)
       
   685         apply (drule_tac p' = proc and fd' = fd and s = "enrich_proc s proc p'" in cfd2sfd_execve, simp+)
       
   686         apply (erule_tac pre_sfd'', simp add:is_created_proc_simps, simp)
       
   687         apply (drule_tac p' = tp and fd' = fd in cfd2sfd_execve, simp+)
       
   688         apply (erule_tac pre_sfd'', simp add:is_created_proc_simps, simp)
       
   689         apply (simp only:cfd2sfd_execve)
       
   690         apply (rule_tac pre_sfd')
       
   691         apply (auto split:if_splits simp:is_created_proc_simps)
       
   692         done 
       
   693       have b2: "\<And> proc proc' fds. e = Clone proc proc' fds
       
   694        \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
       
   695         using a4 vd_enrich_cons a1' vd_cons' created_cons
       
   696         apply (simp split:if_splits del:file_of_proc_fd.simps) 
       
   697         apply (simp add:cfd2sfd_clone add:a2)
       
   698         apply (simp add:cfd2sfd_clone split:if_splits)
       
   699         apply (erule pre_sfd'', simp add:is_created_proc_simps, simp)
       
   700         apply (erule pre_sfd', simp add:is_created_proc_simps)
       
   701         done 
       
   702       have b3: "\<And> proc f' flags fd' opt. e = Open proc f' flags fd' opt 
       
   703          \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
       
   704         apply (simp split:if_splits)
       
   705         thm cfd2sfd_open
       
   706         sorry
       
   707       have b4: "\<And> proc fd'. e = ReadFile proc fd' 
       
   708          \<Longrightarrow> cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
       
   709         using a4 vd_enrich_cons a1' vd_cons' created_cons
       
   710         apply (simp split:if_splits del:file_of_proc_fd.simps) 
       
   711         apply (frule_tac s = "ReadFile proc fd' # enrich_proc s proc p'" in vd_cons)
       
   712         apply (simp add:cfd2sfd_other)
       
   713         apply (erule pre_sfd'', simp add:is_created_proc_simps, simp)
       
   714         apply (simp add:cfd2sfd_other)
       
   715         apply (erule pre_sfd', simp add:is_created_proc_simps)
       
   716         done 
   502       show ?thesis
   717       show ?thesis
   503         using created_cons all_procs_cons vd_enrich_cons Execve b1 os a0
   718         apply (case_tac e)
   504         apply (simp add:alive_execve split:if_splits)
   719         apply (erule b1, erule b2) 
   505         apply (frule_tac vd_cons) defer
   720         prefer 4 apply (erule b3) prefer 4 apply (erule b4)
   506         apply (frule_tac vd_cons)
   721         using vd created_cons nodel_cons a1' a4 vd_enrich_cons vd_cons'
   507         using vd_cons' Execve vd os
   722         apply (auto intro!:pre_sfd' simp:cfd2sfd_simps is_created_proc_simps 
   508         apply (auto simp:is_file_simps is_dir_simps is_created_proc_simps alive.simps
   723           simp del:file_of_proc_fd.simps split:if_splits dest:vd_cons enrich_proc_filefd)
   509           split:t_object.splits if_splits 
   724         apply (simp_all)
   510           dest:set_mp file_fds_subset_pfds)
   725         done
   511         apply (erule_tac x = "O_proc nat" in allE, simp)
   726     qed
   512         apply (erule_tac x = "O_file list" in allE, simp)
   727   qed
   513         apply (drule set_mp, simp)
       
   514         apply (drule_tac s = s and p = tp in file_fds_subset_pfds)
       
   515         apply (erule_tac x = "O_fd tp nat2" in allE, simp)
       
   516         apply (auto)[1]
       
   517         apply (erule_tac x = "O_fd nat1 nat2" in allE, auto dest:set_mp file_fds_subset_pfds)[1]
       
   518         apply (erule_tac x = "O_dir list" in allE, simp)
       
   519     sorry
       
   520   show ?thesis *) sorry
       
   521   moreover have "\<forall>obj. enrich_not_alive (e # s) obj \<longrightarrow> enrich_not_alive (enrich_proc (e # s) p p') obj"
       
   522     thm enrich_not_alive.simps
       
   523     sorry
       
   524   moreover have "files_hung_by_del (enrich_proc (e # s) p p') = files_hung_by_del (e # s)"
       
   525   proof-
       
   526     have "is_created_proc s p \<Longrightarrow> files_hung_by_del (enrich_proc s p p') = files_hung_by_del s"
       
   527       and ffd_remain: "is_created_proc s p \<Longrightarrow> 
       
   528       \<forall>tp fd f. file_of_proc_fd s tp fd = Some f \<longrightarrow> 
       
   529                                    file_of_proc_fd (enrich_proc s p p') tp fd = Some f"
       
   530       using pre by auto
       
   531     with created_cons all_procs_cons os vd_cons' vd
       
   532     show ?thesis
       
   533       apply (frule_tac not_all_procs_prop3)
       
   534       apply (case_tac e)
       
   535       apply (auto simp:files_hung_by_del.simps is_created_proc_simps)
       
   536       apply (auto simp:enrich_proc_dup_ffd_eq proc_file_fds_def procfd_of_file_eq_fpfd''
       
   537         dest:procfd_of_file_imp_fpfd procfd_of_file_imp_fpfd' procfd_of_file_non_empty
       
   538       )
       
   539       apply (auto simp:enrich_proc_dup_ffd_eq proc_file_fds_def split:if_splits)[1]
       
   540       
       
   541       apply (auto simp:enrich_proc_dup_ffd_eq proc_file_fds_def files_hung_by_del.simps
       
   542         split:option.splits)[1]
       
   543       apply (auto split:option.splits)[1]
       
   544       thm is_created_proc_simps
       
   545     sorry
       
   546   moreover have "\<forall>tp. tp \<in> current_procs (e # s) \<longrightarrow> cp2sproc (enrich_proc (e # s) p p') tp = cp2sproc (e # s) tp"
   728   moreover have "\<forall>tp. tp \<in> current_procs (e # s) \<longrightarrow> cp2sproc (enrich_proc (e # s) p p') tp = cp2sproc (e # s) tp"
   547     sorry
   729     sorry
   548   moreover have "\<forall>f. f \<in> current_files (e # s) \<longrightarrow> cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
   730   moreover have "\<forall>f. f \<in> current_files (e # s) \<longrightarrow> cf2sfile (enrich_proc (e # s) p p') f = cf2sfile (e # s) f"
   549     sorry
   731     sorry
   550   moreover have "\<forall>q. q \<in> current_msgqs (e # s) \<longrightarrow> cq2smsgq (enrich_proc (e # s) p p') q = cq2smsgq (e # s) q"
   732   moreover have "\<forall>q. q \<in> current_msgqs (e # s) \<longrightarrow> cq2smsgq (enrich_proc (e # s) p p') q = cq2smsgq (e # s) q"
   551     sorry
   733     sorry
   552   moreover have "\<forall>tp fd f. file_of_proc_fd (e # s) tp fd = Some f \<longrightarrow> 
       
   553     file_of_proc_fd (enrich_proc (e # s) p p') tp fd = Some f"
       
   554     sorry
       
   555   moreover have "\<forall>tp fd flags. flags_of_proc_fd (e # s) tp fd = Some flags \<longrightarrow>
       
   556         flags_of_proc_fd (enrich_proc (e # s) p p') tp fd = Some flags"
       
   557     sorry
       
   558   moreover have "\<forall>q. msgs_of_queue (enrich_proc (e # s) p p') q = msgs_of_queue (e # s) q"
       
   559     sorry 
       
   560   moreover have "\<forall>tp fd. fd \<in> proc_file_fds (e # s) tp \<longrightarrow> 
       
   561     cfd2sfd (enrich_proc (e # s) p p') tp fd = cfd2sfd (e # s) tp fd"
       
   562     sorry 
       
   563   moreover have "cp2sproc (enrich_proc (e # s) p p') p' = cp2sproc (e # s) p"
   734   moreover have "cp2sproc (enrich_proc (e # s) p p') p' = cp2sproc (e # s) p"
   564   proof-
   735   proof-
   565     from pre have b0: "is_created_proc s p \<Longrightarrow> cp2sproc (enrich_proc s p p') p' = cp2sproc s p" by simp
   736     from pre have b0: "is_created_proc s p \<Longrightarrow> cp2sproc (enrich_proc s p p') p' = cp2sproc s p" by simp
   566     have b1: "\<And> tp f fds. \<lbrakk>valid (enrich_proc (Execve tp f fds # s) p p'); valid (Execve tp f fds # s);
   737     have b1: "\<And> tp f fds. \<lbrakk>valid (enrich_proc (Execve tp f fds # s) p p'); valid (Execve tp f fds # s);
   567       is_created_proc (Execve tp f fds # s) p; p' \<notin> all_procs (Execve tp f fds # s)\<rbrakk>
   738       is_created_proc (Execve tp f fds # s) p; p' \<notin> all_procs (Execve tp f fds # s)\<rbrakk>
   572       and a2: "valid (Execve tp f fds # s)" and a3: "is_created_proc (Execve tp f fds # s) p"
   743       and a2: "valid (Execve tp f fds # s)" and a3: "is_created_proc (Execve tp f fds # s) p"
   573       and a4: "p' \<notin> all_procs (Execve tp f fds # s)"
   744       and a4: "p' \<notin> all_procs (Execve tp f fds # s)"
   574       show "cp2sproc (enrich_proc (Execve tp f fds # s) p p') p' = cp2sproc (Execve tp f fds # s) p"
   745       show "cp2sproc (enrich_proc (Execve tp f fds # s) p p') p' = cp2sproc (Execve tp f fds # s) p"
   575       proof (cases "tp = p")
   746       proof (cases "tp = p")
   576         case True
   747         case True
   577         show ?thesis using True a1 a2 a3 a4 b0
   748         show ?thesis using True a1 a2 a3 a4 b0 vd
   578           thm not_all_procs_prop3
   749           thm not_all_procs_prop3
   579           apply (frule_tac not_all_procs_prop2)
   750           apply (frule_tac not_all_procs_prop2)
   580           apply (frule not_all_procs_prop3)
   751           apply (frule not_all_procs_prop3)
   581           apply (auto simp add:cp2sproc_execve is_created_proc_def split:option.splits dest!:current_has_sec' 
   752           apply (simp add:is_created_proc_simps)
   582             dest:vt_grant_os)
   753           apply (frule vd_cons) (*
       
   754           apply (frule_tac vt_grant_os) 
       
   755           apply (frule_tac \<tau> = "enrich_proc s p p'" in vt_grant_os) *)
       
   756           apply (frule_tac s = "enrich_proc s p p'" in vd_cons)
       
   757           apply (frule_tac \<tau> = s in vt_grant_os)
       
   758           apply (case_tac "p' = p", simp) (*
       
   759           apply (auto simp add:cp2sproc_execve sectxt_of_obj_simps enrich_proc_dup_in
       
   760             split:option.splits dest!:current_has_sec' dest:vt_grant is_file)
       
   761           apply (simp_all add:is_created_proc_def)
       
   762           apply (auto simp:cp2sproc_def)
       
   763           apply (simp_all add:enrich_proc_dup_in)
       
   764 
       
   765           
   583           apply (auto simp:sectxt_of_obj_simps split:option.splits dest:valid.cases)
   766           apply (auto simp:sectxt_of_obj_simps split:option.splits dest:valid.cases)
   584           
   767   *)        
   585           sorry
   768           sorry
   586       next
   769       next
   587         case False
   770         case False
   588         show ?thesis sorry
   771         show ?thesis sorry
   589       qed
   772       qed
   602       sorry
   785       sorry
   603     have b7: "\<And> tp fd. cp2sproc (enrich_proc (CloseFd tp fd # s) p p') p' = cp2sproc (CloseFd tp fd # s) p"
   786     have b7: "\<And> tp fd. cp2sproc (enrich_proc (CloseFd tp fd # s) p p') p' = cp2sproc (CloseFd tp fd # s) p"
   604       sorry
   787       sorry
   605     show ?thesis using vd_enrich_cons
   788     show ?thesis using vd_enrich_cons
   606       apply (case_tac e)
   789       apply (case_tac e)
   607       apply (simp_all only:b1 b2 b3 b4 b5 b6 b7)
   790       using vd_cons' created_cons all_procs_cons
       
   791       apply (auto intro!:b1 b2 b3 b4 b5 b6 b7 simp del:enrich_proc.simps)
   608       using created_cons vd_enrich_cons vd_cons' b0
   792       using created_cons vd_enrich_cons vd_cons' b0
   609       apply (auto simp:cp2sproc_other is_created_proc_def)
   793       apply (auto simp:cp2sproc_other is_created_proc_def)
   610       done
   794       done
   611   qed
   795   qed
   612   moreover have "\<forall> fd. fd \<in> proc_file_fds (e # s) p \<longrightarrow> 
   796   moreover have "\<forall> fd. fd \<in> proc_file_fds (e # s) p \<longrightarrow> 
   613     cfd2sfd (enrich_proc (e # s) p p') p' fd = cfd2sfd (e # s) p fd"
   797     cfd2sfd (enrich_proc (e # s) p p') p' fd = cfd2sfd (e # s) p fd"
   614     sorry
   798     sorry
   615   ultimately show ?case
   799   ultimately show ?case using vd_enrich_cons
   616     by simp
   800     by simp
   617 qed
   801 qed
   618   
   802   
   619 
   803 
   620 lemma enrich_proc_valid:
   804 lemma enrich_proc_valid:
   621   "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> valid (enrich_proc s p p')"
   805   "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> valid (enrich_proc s p p')"
   622 by (auto dest:enrich_proc_prop)
   806 by (auto dest:enrich_proc_prop)
   623 
   807 
   624 lemma enrich_proc_valid:
   808 lemma enrich_proc_valid:
   625   "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> " 
   809   "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk> \<Longrightarrow> " 
   626 
       
   627  
       
   628 
   810 
   629 lemma enrich_proc_tainted: 
   811 lemma enrich_proc_tainted: 
   630   "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
   812   "\<lbrakk>is_created_proc s p; p' \<notin> all_procs s; valid s\<rbrakk>
   631    \<Longrightarrow> tainted (enrich_proc s p p') = (if (O_proc p \<in> tainted s) 
   813    \<Longrightarrow> tainted (enrich_proc s p p') = (if (O_proc p \<in> tainted s) 
   632          then tainted s \<union> {O_proc p'} else tainted s)"
   814          then tainted s \<union> {O_proc p'} else tainted s)"
   667 apply (case_tac a)
   849 apply (case_tac a)
   668 apply (auto simp:is_created_proc_def)[1]
   850 apply (auto simp:is_created_proc_def)[1]
   669 
   851 
   670 
   852 
   671 lemma enrich_proc_tainted:
   853 lemma enrich_proc_tainted:
   672   ""
   854 
   673 
   855 
   674 
   856 
   675 end
   857 end
   676 
   858 
   677 end
   859 end