S2ss_prop.thy
author chunhan
Tue, 24 Sep 2013 14:02:15 +0800
changeset 47 0960686df575
parent 46 f66d61f5439d
child 48 bf8c09ec1186
permissions -rw-r--r--
bug in s2ss_del_sfile
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32
705e1e41faf7 add event-trace simpset for s2ss
chunhan
parents:
diff changeset
     1
(*<*)
705e1e41faf7 add event-trace simpset for s2ss
chunhan
parents:
diff changeset
     2
theory S2ss_prop
705e1e41faf7 add event-trace simpset for s2ss
chunhan
parents:
diff changeset
     3
imports Main Flask Flask_type Static Static_type Init_prop Tainted_prop Valid_prop Alive_prop Co2sobj_prop
705e1e41faf7 add event-trace simpset for s2ss
chunhan
parents:
diff changeset
     4
begin
705e1e41faf7 add event-trace simpset for s2ss
chunhan
parents:
diff changeset
     5
(*>*)
705e1e41faf7 add event-trace simpset for s2ss
chunhan
parents:
diff changeset
     6
33
6884b3c9284b fix bug of static.thy for the static of recvmsg case
chunhan
parents: 32
diff changeset
     7
context tainting_s begin
6884b3c9284b fix bug of static.thy for the static of recvmsg case
chunhan
parents: 32
diff changeset
     8
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
     9
(* simpset for s2ss*)
39
13bba99ca090 done with co2sobj_simps
chunhan
parents: 38
diff changeset
    10
43
chunhan
parents: 42
diff changeset
    11
lemma co2sobj_some_case:
chunhan
parents: 42
diff changeset
    12
  "\<lbrakk>co2sobj s obj = Some sobj; \<And> p. obj = O_proc p \<Longrightarrow> P (O_proc p);
chunhan
parents: 42
diff changeset
    13
    \<And> f. obj = O_file f \<Longrightarrow> P (O_file f); \<And> h. obj = O_shm h \<Longrightarrow> P (O_shm h);
chunhan
parents: 42
diff changeset
    14
    \<And> f. obj = O_dir f \<Longrightarrow> P (O_dir f); \<And> q. obj = O_msgq q \<Longrightarrow> P (O_msgq q)\<rbrakk>
chunhan
parents: 42
diff changeset
    15
   \<Longrightarrow> P obj"
chunhan
parents: 42
diff changeset
    16
by (case_tac obj, auto)
chunhan
parents: 42
diff changeset
    17
chunhan
parents: 42
diff changeset
    18
lemma co2sobj_execve_alive:
chunhan
parents: 42
diff changeset
    19
  "\<lbrakk>alive s obj; co2sobj s obj = Some x; valid (Execve p f fds # s)\<rbrakk>
chunhan
parents: 42
diff changeset
    20
   \<Longrightarrow> alive (Execve p f fds # s) obj"
chunhan
parents: 42
diff changeset
    21
apply (erule co2sobj_some_case)
chunhan
parents: 42
diff changeset
    22
by (auto simp:alive_simps simp del:alive.simps)
39
13bba99ca090 done with co2sobj_simps
chunhan
parents: 38
diff changeset
    23
33
6884b3c9284b fix bug of static.thy for the static of recvmsg case
chunhan
parents: 32
diff changeset
    24
lemma s2ss_execve:
34
e7f850d1e08e remove O_msg from co2sobj/init_obj2sobj
chunhan
parents: 33
diff changeset
    25
  "valid (Execve p f fds # s) \<Longrightarrow> s2ss (Execve p f fds # s) = (
e7f850d1e08e remove O_msg from co2sobj/init_obj2sobj
chunhan
parents: 33
diff changeset
    26
     if (\<exists> p'. p' \<noteq> p \<and> p' \<in> current_procs s \<and> co2sobj s (O_proc p') = co2sobj s (O_proc p))
35
f2e620d799cf in the middle of building simpset for co2sobj, therefore we can deal with s2ss
chunhan
parents: 34
diff changeset
    27
     then (case (cp2sproc (Execve p f fds # s) p) of
f2e620d799cf in the middle of building simpset for co2sobj, therefore we can deal with s2ss
chunhan
parents: 34
diff changeset
    28
             Some sp \<Rightarrow> s2ss s \<union> {S_proc sp (O_proc p \<in> Tainted s \<or> O_file f \<in> Tainted s)}
43
chunhan
parents: 42
diff changeset
    29
           | _ \<Rightarrow> {} )
chunhan
parents: 42
diff changeset
    30
     else (case (cp2sproc (Execve p f fds # s) p, cp2sproc s p) of
chunhan
parents: 42
diff changeset
    31
             (Some sp, Some sp') \<Rightarrow> s2ss s - {S_proc sp' (O_proc p \<in> Tainted s)}
chunhan
parents: 42
diff changeset
    32
                                    \<union> {S_proc sp (O_proc p \<in> Tainted s \<or> O_file f \<in> Tainted s)}
chunhan
parents: 42
diff changeset
    33
           | _ \<Rightarrow> {} ) )"
35
f2e620d799cf in the middle of building simpset for co2sobj, therefore we can deal with s2ss
chunhan
parents: 34
diff changeset
    34
apply (frule vd_cons, frule vt_grant_os, simp split:if_splits)
42
chunhan
parents: 41
diff changeset
    35
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    36
apply (rule conjI, rule impI, (erule exE|erule conjE)+)
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    37
apply (frule_tac p = p in current_proc_has_sp, simp, erule exE)
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    38
apply (frule_tac p = p' in current_proc_has_sp, simp, erule exE, simp)
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    39
apply (subgoal_tac "p \<in> current_procs (Execve p f fds # s)")
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    40
apply (drule_tac p = p and s = "Execve p f fds # s" in current_proc_has_sp, simp)
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    41
apply (erule exE, simp)
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    42
apply (simp add:s2ss_def, rule set_eqI, rule iffI)
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    43
apply (drule CollectD, (erule exE|erule conjE)+)
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    44
apply (case_tac "obj = O_proc p")
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    45
apply (simp add:co2sobj_execve tainted_eq_Tainted split:if_splits)
42
chunhan
parents: 41
diff changeset
    46
apply (simp add:co2sobj_execve, rule disjI2)
chunhan
parents: 41
diff changeset
    47
apply (rule_tac x = obj in exI, case_tac obj, (simp add:alive_simps)+)[1]
chunhan
parents: 41
diff changeset
    48
apply (simp, erule disjE)
chunhan
parents: 41
diff changeset
    49
apply (rule_tac x = "O_proc p" in exI, simp add:tainted_eq_Tainted)
chunhan
parents: 41
diff changeset
    50
apply (erule exE| erule conjE)+
chunhan
parents: 41
diff changeset
    51
apply (case_tac "x = S_proc sp (O_proc p \<in> tainted s)")
chunhan
parents: 41
diff changeset
    52
apply (rule_tac x = "O_proc p'" in exI)
chunhan
parents: 41
diff changeset
    53
apply (simp add:alive_execve co2sobj_execve tainted_eq_Tainted cp2sproc_execve)
43
chunhan
parents: 42
diff changeset
    54
apply (case_tac "obj = O_proc p", simp)
chunhan
parents: 42
diff changeset
    55
apply (frule co2sobj_execve_alive, simp, simp)
chunhan
parents: 42
diff changeset
    56
apply (frule_tac obj = obj in co2sobj_execve, simp)
chunhan
parents: 42
diff changeset
    57
apply (rule_tac x = obj in exI, simp, simp)
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    58
43
chunhan
parents: 42
diff changeset
    59
apply (erule conjE, frule current_proc_has_sp, simp, erule exE, rule impI, simp)
chunhan
parents: 42
diff changeset
    60
apply (subgoal_tac "p \<in> current_procs (Execve p f fds # s)") 
chunhan
parents: 42
diff changeset
    61
apply (drule_tac p = p and s = "Execve p f fds # s" in current_proc_has_sp, simp)
chunhan
parents: 42
diff changeset
    62
apply (erule exE, erule conjE, simp)
chunhan
parents: 42
diff changeset
    63
apply (simp add:s2ss_def, rule set_eqI, rule iffI)
chunhan
parents: 42
diff changeset
    64
apply (drule CollectD, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
    65
apply (case_tac "obj = O_proc p", simp add:tainted_eq_Tainted)
chunhan
parents: 42
diff changeset
    66
apply (rule disjI1, simp split:if_splits)
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
    67
apply (simp add:co2sobj_execve, rule disjI2)
43
chunhan
parents: 42
diff changeset
    68
apply (rule conjI,rule_tac x = obj in exI, simp add:alive_simps split:t_object.splits)
chunhan
parents: 42
diff changeset
    69
apply (rule notI, simp, case_tac obj)
chunhan
parents: 42
diff changeset
    70
apply (erule_tac x = nat in allE, simp add:tainted_eq_Tainted, (simp split:option.splits)+)
chunhan
parents: 42
diff changeset
    71
apply (erule disjE, simp)
chunhan
parents: 42
diff changeset
    72
apply (rule_tac x = "O_proc p" in exI, simp add:tainted_eq_Tainted)
chunhan
parents: 42
diff changeset
    73
apply (erule exE|erule conjE)+
chunhan
parents: 42
diff changeset
    74
apply (rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
    75
apply (drule_tac obj = obj in co2sobj_execve_alive, simp+)
chunhan
parents: 42
diff changeset
    76
apply (frule_tac obj = obj in co2sobj_execve, simp, simp)
chunhan
parents: 42
diff changeset
    77
apply (rule impI, simp add:tainted_eq_Tainted, simp)
chunhan
parents: 42
diff changeset
    78
done
chunhan
parents: 42
diff changeset
    79
chunhan
parents: 42
diff changeset
    80
lemma s2ss_clone_alive:
chunhan
parents: 42
diff changeset
    81
  "\<lbrakk>co2sobj s obj = Some x; alive s obj; obj \<noteq> O_proc p'; valid (Clone p p' fds shms # s)\<rbrakk>
chunhan
parents: 42
diff changeset
    82
   \<Longrightarrow> alive (Clone p p' fds shms # s) obj"
chunhan
parents: 42
diff changeset
    83
by (erule co2sobj_some_case, auto simp:alive_clone)
chunhan
parents: 42
diff changeset
    84
chunhan
parents: 42
diff changeset
    85
lemma s2ss_clone:
chunhan
parents: 42
diff changeset
    86
  "valid (Clone p p' fds shms # s) \<Longrightarrow> s2ss (Clone p p' fds shms # s) = (
chunhan
parents: 42
diff changeset
    87
     case (cp2sproc (Clone p p' fds shms # s) p') of
chunhan
parents: 42
diff changeset
    88
       Some sp \<Rightarrow> s2ss s \<union> {S_proc sp (O_proc p \<in> Tainted s)}
chunhan
parents: 42
diff changeset
    89
     | _       \<Rightarrow> {})"
chunhan
parents: 42
diff changeset
    90
apply (frule vd_cons, frule vt_grant_os, split option.splits)
chunhan
parents: 42
diff changeset
    91
apply (rule conjI, rule impI, drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
    92
apply (rule allI, rule impI, simp add:s2ss_def)
chunhan
parents: 42
diff changeset
    93
apply (rule set_eqI, rule iffI, drule CollectD, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
    94
apply (case_tac "obj = O_proc p'", simp add:tainted_eq_Tainted)
chunhan
parents: 42
diff changeset
    95
apply (case_tac "O_proc p' \<in> Tainted s", drule Tainted_in_current, simp+)
chunhan
parents: 42
diff changeset
    96
apply (rule disjI1, simp split:if_splits)
chunhan
parents: 42
diff changeset
    97
apply (simp add:tainted_eq_Tainted, rule disjI2)
chunhan
parents: 42
diff changeset
    98
apply (frule co2sobj_clone, simp)
chunhan
parents: 42
diff changeset
    99
apply (rule_tac x = obj in exI, simp add:alive_simps split:t_object.splits)
chunhan
parents: 42
diff changeset
   100
chunhan
parents: 42
diff changeset
   101
apply (simp, erule disjE, simp)
chunhan
parents: 42
diff changeset
   102
apply (rule_tac x = "O_proc p'" in exI, simp add:tainted_eq_Tainted)
chunhan
parents: 42
diff changeset
   103
apply (rule impI, rule notI, drule Tainted_in_current, simp+)
chunhan
parents: 42
diff changeset
   104
apply (erule exE| erule conjE)+
chunhan
parents: 42
diff changeset
   105
apply (case_tac "obj = O_proc p'", simp)
chunhan
parents: 42
diff changeset
   106
apply (rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   107
apply (frule s2ss_clone_alive, simp+)
chunhan
parents: 42
diff changeset
   108
apply (auto simp:co2sobj_clone alive_simps)
chunhan
parents: 42
diff changeset
   109
done
chunhan
parents: 42
diff changeset
   110
chunhan
parents: 42
diff changeset
   111
definition update_s2ss_shm:: "t_state \<Rightarrow> t_process \<Rightarrow> t_static_state" 
chunhan
parents: 42
diff changeset
   112
where
chunhan
parents: 42
diff changeset
   113
  "update_s2ss_shm s pfrom \<equiv> s2ss s 
chunhan
parents: 42
diff changeset
   114
     \<union> {S_proc sp True| sp p. info_flow_shm s pfrom p \<and> cp2sproc s p = Some sp}
chunhan
parents: 42
diff changeset
   115
     - {S_proc sp False | sp p. info_flow_shm s pfrom p \<and> cp2sproc s p = Some sp \<and> 
chunhan
parents: 42
diff changeset
   116
           (\<not> (\<exists> p'. \<not> info_flow_shm s pfrom p' \<and> p' \<in> current_procs s \<and> 
chunhan
parents: 42
diff changeset
   117
                cp2sproc s p' = Some sp \<and> O_proc p' \<notin> Tainted s))}"
chunhan
parents: 42
diff changeset
   118
chunhan
parents: 42
diff changeset
   119
lemma Tainted_ptrace':
chunhan
parents: 42
diff changeset
   120
  "valid s \<Longrightarrow> Tainted (Ptrace p p' # s) = 
chunhan
parents: 42
diff changeset
   121
     (if (O_proc p \<in> Tainted s \<and> O_proc p' \<notin> Tainted s)
chunhan
parents: 42
diff changeset
   122
      then Tainted s \<union> {O_proc p'' | p''. info_flow_shm s p' p''}
chunhan
parents: 42
diff changeset
   123
      else if (O_proc p' \<in> Tainted s \<and> O_proc p \<notin> Tainted s)
chunhan
parents: 42
diff changeset
   124
           then Tainted s \<union> {O_proc p'' | p''. info_flow_shm s p p''}
chunhan
parents: 42
diff changeset
   125
                else Tainted s)"
chunhan
parents: 42
diff changeset
   126
using info_flow_shm_Tainted by auto
chunhan
parents: 42
diff changeset
   127
chunhan
parents: 42
diff changeset
   128
lemma co2sobj_some_caseD:
chunhan
parents: 42
diff changeset
   129
  "\<lbrakk>co2sobj s obj = Some sobj; \<And> p. \<lbrakk>co2sobj s obj = Some sobj; obj = O_proc p\<rbrakk> \<Longrightarrow> P (O_proc p);
chunhan
parents: 42
diff changeset
   130
    \<And> f. \<lbrakk>co2sobj s obj = Some sobj; obj = O_file f\<rbrakk> \<Longrightarrow> P (O_file f); 
chunhan
parents: 42
diff changeset
   131
    \<And> h. \<lbrakk>co2sobj s obj = Some sobj; obj = O_shm h\<rbrakk> \<Longrightarrow> P (O_shm h);
chunhan
parents: 42
diff changeset
   132
    \<And> f. \<lbrakk>co2sobj s obj = Some sobj; obj = O_dir f\<rbrakk> \<Longrightarrow> P (O_dir f); 
chunhan
parents: 42
diff changeset
   133
    \<And> q. \<lbrakk>co2sobj s obj = Some sobj; obj = O_msgq q\<rbrakk> \<Longrightarrow> P (O_msgq q)\<rbrakk>
chunhan
parents: 42
diff changeset
   134
   \<Longrightarrow> P obj"
chunhan
parents: 42
diff changeset
   135
by (case_tac obj, auto)
chunhan
parents: 42
diff changeset
   136
chunhan
parents: 42
diff changeset
   137
lemma s2ss_ptrace1_aux: "x \<notin> {x. P x} \<Longrightarrow> \<not> P x" by simp
chunhan
parents: 42
diff changeset
   138
chunhan
parents: 42
diff changeset
   139
lemma s2ss_ptrace1:
chunhan
parents: 42
diff changeset
   140
  "\<lbrakk>valid (Ptrace p p' # s); O_proc p \<in> Tainted s; O_proc p' \<notin> Tainted s\<rbrakk>
chunhan
parents: 42
diff changeset
   141
   \<Longrightarrow> s2ss (Ptrace p p' # s) = update_s2ss_shm s p'"
chunhan
parents: 42
diff changeset
   142
unfolding update_s2ss_shm_def s2ss_def
chunhan
parents: 42
diff changeset
   143
apply (frule vd_cons, rule set_eqI, rule iffI)
chunhan
parents: 42
diff changeset
   144
apply (drule CollectD, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
   145
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   146
apply (rule DiffI)
chunhan
parents: 42
diff changeset
   147
apply (case_tac "O_proc pa \<in> Tainted s")
chunhan
parents: 42
diff changeset
   148
apply (rule UnI1, simp, rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   149
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   150
apply (case_tac "info_flow_shm s p' pa")
chunhan
parents: 42
diff changeset
   151
apply (rule UnI2, rule CollectI, simp only:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   152
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   153
apply (rule_tac x = a in exI, rule_tac x = pa in exI)
chunhan
parents: 42
diff changeset
   154
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   155
apply (rule UnI1, simp)
chunhan
parents: 42
diff changeset
   156
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   157
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   158
apply (rule notI, clarsimp simp:cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   159
apply (erule_tac x = pa in allE, simp)
chunhan
parents: 42
diff changeset
   160
chunhan
parents: 42
diff changeset
   161
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   162
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   163
apply (simp)
chunhan
parents: 42
diff changeset
   164
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   165
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   166
apply (simp split:option.splits)
chunhan
parents: 42
diff changeset
   167
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   168
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   169
apply (simp split:option.splits)
chunhan
parents: 42
diff changeset
   170
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   171
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   172
apply (simp split:option.splits)
chunhan
parents: 42
diff changeset
   173
chunhan
parents: 42
diff changeset
   174
apply (erule DiffE, drule s2ss_ptrace1_aux, erule UnE)
chunhan
parents: 42
diff changeset
   175
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   176
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   177
apply (case_tac "O_proc pa \<in> Tainted s")
chunhan
parents: 42
diff changeset
   178
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   179
apply (clarsimp simp add:tainted_eq_Tainted cp2sproc_other split:option.splits)
chunhan
parents: 42
diff changeset
   180
apply (case_tac "info_flow_shm s p' pa", simp only:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   181
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   182
apply (drule Meson.not_exD, erule_tac x = a in allE, drule Meson.not_exD, erule_tac x = pa in allE)
chunhan
parents: 42
diff changeset
   183
apply (simp add:tainted_eq_Tainted, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
   184
apply (rule_tac x = "O_proc p'a" in exI)
chunhan
parents: 42
diff changeset
   185
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   186
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   187
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   188
chunhan
parents: 42
diff changeset
   189
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   190
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   191
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   192
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   193
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   194
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   195
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   196
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   197
chunhan
parents: 42
diff changeset
   198
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   199
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   200
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted info_shm_flow_in_procs)
chunhan
parents: 42
diff changeset
   201
done
chunhan
parents: 42
diff changeset
   202
chunhan
parents: 42
diff changeset
   203
lemma s2ss_ptrace2:
chunhan
parents: 42
diff changeset
   204
  "\<lbrakk>valid (Ptrace p p' # s); O_proc p' \<in> Tainted s; O_proc p \<notin> Tainted s\<rbrakk>
chunhan
parents: 42
diff changeset
   205
   \<Longrightarrow> s2ss (Ptrace p p' # s) = update_s2ss_shm s p"
chunhan
parents: 42
diff changeset
   206
unfolding update_s2ss_shm_def s2ss_def
chunhan
parents: 42
diff changeset
   207
apply (frule vd_cons, rule set_eqI, rule iffI)
chunhan
parents: 42
diff changeset
   208
apply (drule CollectD, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
   209
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   210
apply (rule DiffI)
chunhan
parents: 42
diff changeset
   211
apply (case_tac "O_proc pa \<in> Tainted s")
chunhan
parents: 42
diff changeset
   212
apply (rule UnI1, simp, rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   213
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   214
apply (case_tac "info_flow_shm s p pa")
chunhan
parents: 42
diff changeset
   215
apply (rule UnI2, rule CollectI, simp only:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   216
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   217
apply (rule_tac x = a in exI, rule_tac x = pa in exI)
chunhan
parents: 42
diff changeset
   218
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   219
apply (rule UnI1, simp)
chunhan
parents: 42
diff changeset
   220
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   221
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   222
apply (rule notI, clarsimp simp:cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   223
apply (erule_tac x = pa in allE, simp)
chunhan
parents: 42
diff changeset
   224
chunhan
parents: 42
diff changeset
   225
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   226
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   227
apply (simp)
chunhan
parents: 42
diff changeset
   228
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   229
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   230
apply (simp split:option.splits)
chunhan
parents: 42
diff changeset
   231
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   232
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   233
apply (simp split:option.splits)
chunhan
parents: 42
diff changeset
   234
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   235
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   236
apply (simp split:option.splits)
chunhan
parents: 42
diff changeset
   237
chunhan
parents: 42
diff changeset
   238
apply (erule DiffE, drule s2ss_ptrace1_aux, erule UnE)
chunhan
parents: 42
diff changeset
   239
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   240
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   241
apply (case_tac "O_proc pa \<in> Tainted s")
chunhan
parents: 42
diff changeset
   242
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   243
apply (clarsimp simp add:tainted_eq_Tainted cp2sproc_other split:option.splits)
chunhan
parents: 42
diff changeset
   244
apply (case_tac "info_flow_shm s p pa", simp only:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   245
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   246
apply (drule Meson.not_exD, erule_tac x = a in allE, drule Meson.not_exD, erule_tac x = pa in allE)
chunhan
parents: 42
diff changeset
   247
apply (simp add:tainted_eq_Tainted, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
   248
apply (rule_tac x = "O_proc p'a" in exI)
chunhan
parents: 42
diff changeset
   249
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   250
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   251
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   252
chunhan
parents: 42
diff changeset
   253
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   254
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   255
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   256
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   257
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   258
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   259
apply (rule_tac x = obj in exI,
chunhan
parents: 42
diff changeset
   260
       auto split:option.splits simp:co2sobj_ptrace alive_simps simp del:co2sobj.simps)[1]
chunhan
parents: 42
diff changeset
   261
chunhan
parents: 42
diff changeset
   262
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   263
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   264
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted info_shm_flow_in_procs)
chunhan
parents: 42
diff changeset
   265
done
chunhan
parents: 42
diff changeset
   266
chunhan
parents: 42
diff changeset
   267
lemma s2ss_ptrace3:
chunhan
parents: 42
diff changeset
   268
  "\<lbrakk>valid (Ptrace p p' # s); (O_proc p' \<in> Tainted s) = (O_proc p \<in> Tainted s)\<rbrakk>
chunhan
parents: 42
diff changeset
   269
   \<Longrightarrow> s2ss (Ptrace p p' # s) = s2ss s"
chunhan
parents: 42
diff changeset
   270
unfolding s2ss_def
chunhan
parents: 42
diff changeset
   271
apply (frule vd_cons, rule set_eqI, rule iffI)
chunhan
parents: 42
diff changeset
   272
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   273
apply (rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   274
apply (frule alive_other, simp+)
chunhan
parents: 42
diff changeset
   275
apply (frule_tac obj = obj in co2sobj_ptrace, simp)
chunhan
parents: 42
diff changeset
   276
apply (auto simp add:tainted_eq_Tainted split:t_object.splits option.splits if_splits
chunhan
parents: 42
diff changeset
   277
  intro:info_flow_shm_Tainted)[1]
chunhan
parents: 42
diff changeset
   278
chunhan
parents: 42
diff changeset
   279
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   280
apply (rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   281
apply (frule alive_other, simp+)
chunhan
parents: 42
diff changeset
   282
apply (frule_tac obj = obj in co2sobj_ptrace, simp)
chunhan
parents: 42
diff changeset
   283
apply (auto simp add:tainted_eq_Tainted split:t_object.splits option.splits if_splits 
chunhan
parents: 42
diff changeset
   284
  intro:info_flow_shm_Tainted)
chunhan
parents: 42
diff changeset
   285
done
chunhan
parents: 42
diff changeset
   286
chunhan
parents: 42
diff changeset
   287
lemma s2ss_ptrace:
chunhan
parents: 42
diff changeset
   288
  "valid (Ptrace p p' # s) \<Longrightarrow> s2ss (Ptrace p p' # s) = (
chunhan
parents: 42
diff changeset
   289
     if (O_proc p \<in> Tainted s \<and> O_proc p' \<notin> Tainted s) 
chunhan
parents: 42
diff changeset
   290
     then update_s2ss_shm s p'
chunhan
parents: 42
diff changeset
   291
     else if (O_proc p' \<in> Tainted s \<and> O_proc p \<notin> Tainted s)
chunhan
parents: 42
diff changeset
   292
          then update_s2ss_shm s p
chunhan
parents: 42
diff changeset
   293
          else s2ss s                                   )"
chunhan
parents: 42
diff changeset
   294
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 42
diff changeset
   295
apply (simp add:s2ss_ptrace2 s2ss_ptrace1 split:if_splits)
chunhan
parents: 42
diff changeset
   296
by (auto dest:s2ss_ptrace3)
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
   297
43
chunhan
parents: 42
diff changeset
   298
lemma s2ss_kill:
chunhan
parents: 42
diff changeset
   299
  "valid (Kill p p' # s) \<Longrightarrow> s2ss (Kill p p' # s) = (
chunhan
parents: 42
diff changeset
   300
     if (\<exists> p''. p'' \<in> current_procs s \<and> p'' \<noteq> p' \<and> co2sobj s (O_proc p'') = co2sobj s (O_proc p'))
chunhan
parents: 42
diff changeset
   301
     then s2ss s 
chunhan
parents: 42
diff changeset
   302
     else (case (co2sobj s (O_proc p')) of
chunhan
parents: 42
diff changeset
   303
             Some sp \<Rightarrow> s2ss s - {sp}
chunhan
parents: 42
diff changeset
   304
           | _       \<Rightarrow> {}))"
chunhan
parents: 42
diff changeset
   305
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 42
diff changeset
   306
unfolding s2ss_def
chunhan
parents: 42
diff changeset
   307
apply (simp split:if_splits, rule conjI)
chunhan
parents: 42
diff changeset
   308
apply (rule impI, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
   309
apply (split option.splits)
chunhan
parents: 42
diff changeset
   310
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   311
apply (simp split: option.splits, (erule conjE)+)
chunhan
parents: 42
diff changeset
   312
apply (rule set_eqI, rule iffI, erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   313
apply (rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   314
apply (simp add:co2sobj_kill tainted_eq_Tainted alive_kill split:t_object.splits if_splits)
chunhan
parents: 42
diff changeset
   315
apply (erule CollectE, erule exE, erule conjE, rule CollectI)
chunhan
parents: 42
diff changeset
   316
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   317
apply (case_tac "pa = p'")
chunhan
parents: 42
diff changeset
   318
apply (rule_tac x = "O_proc p''" in exI)
chunhan
parents: 42
diff changeset
   319
apply (simp add:cp2sproc_kill tainted_eq_Tainted alive_kill
chunhan
parents: 42
diff changeset
   320
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   321
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   322
apply (clarsimp simp add:cp2sproc_kill tainted_eq_Tainted alive_kill
chunhan
parents: 42
diff changeset
   323
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   324
apply (rule_tac x = obj in exI, frule alive_kill, simp add:co2sobj_kill del:co2sobj.simps)+
chunhan
parents: 42
diff changeset
   325
chunhan
parents: 42
diff changeset
   326
apply (rule impI, erule conjE, frule current_proc_has_sp, simp, erule exE, simp)
chunhan
parents: 42
diff changeset
   327
apply (rule set_eqI, rule iffI)
chunhan
parents: 42
diff changeset
   328
apply (erule CollectE, erule exE, erule conjE, rule DiffI)
chunhan
parents: 42
diff changeset
   329
apply (rule CollectI, rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   330
apply (simp add:co2sobj_kill tainted_eq_Tainted alive_kill split:t_object.splits if_splits)
chunhan
parents: 42
diff changeset
   331
apply (rule notI, simp, case_tac obj)
chunhan
parents: 42
diff changeset
   332
apply (erule_tac x = nat in allE)
chunhan
parents: 42
diff changeset
   333
apply (simp add:co2sobj_kill cp2sproc_kill tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   334
apply (simp split:option.splits)+
chunhan
parents: 42
diff changeset
   335
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   336
apply (case_tac "pa = p'")
chunhan
parents: 42
diff changeset
   337
apply (rule_tac x = "O_proc p''" in exI)
chunhan
parents: 42
diff changeset
   338
apply (simp add:cp2sproc_kill tainted_eq_Tainted alive_kill
chunhan
parents: 42
diff changeset
   339
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   340
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   341
apply (clarsimp simp add:cp2sproc_kill tainted_eq_Tainted alive_kill
chunhan
parents: 42
diff changeset
   342
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   343
apply (rule_tac x = obj in exI, frule alive_kill, simp add:co2sobj_kill del:co2sobj.simps)+
chunhan
parents: 42
diff changeset
   344
done
chunhan
parents: 42
diff changeset
   345
chunhan
parents: 42
diff changeset
   346
lemma s2ss_exit:
chunhan
parents: 42
diff changeset
   347
  "valid (Exit p # s) \<Longrightarrow> s2ss (Exit p # s) = (
chunhan
parents: 42
diff changeset
   348
     if (\<exists> p'. p' \<in> current_procs s \<and> p' \<noteq> p \<and> co2sobj s (O_proc p') = co2sobj s (O_proc p))
chunhan
parents: 42
diff changeset
   349
     then s2ss s 
chunhan
parents: 42
diff changeset
   350
     else (case (co2sobj s (O_proc p)) of
chunhan
parents: 42
diff changeset
   351
             Some sp \<Rightarrow> s2ss s - {sp}
chunhan
parents: 42
diff changeset
   352
           | _       \<Rightarrow> {}))"
chunhan
parents: 42
diff changeset
   353
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 42
diff changeset
   354
unfolding s2ss_def
chunhan
parents: 42
diff changeset
   355
apply (simp split:if_splits, rule conjI)
chunhan
parents: 42
diff changeset
   356
apply (rule impI, (erule exE|erule conjE)+)
chunhan
parents: 42
diff changeset
   357
apply (split option.splits)
chunhan
parents: 42
diff changeset
   358
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   359
apply (simp split: option.splits, (erule conjE)+)
chunhan
parents: 42
diff changeset
   360
apply (rule set_eqI, rule iffI, erule CollectE, (erule exE|erule conjE)+, rule CollectI)
chunhan
parents: 42
diff changeset
   361
apply (rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   362
apply (simp add:co2sobj_exit tainted_eq_Tainted alive_exit split:t_object.splits if_splits)
chunhan
parents: 42
diff changeset
   363
apply (erule CollectE, erule exE, erule conjE, rule CollectI)
chunhan
parents: 42
diff changeset
   364
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   365
apply (case_tac "pa = p")
chunhan
parents: 42
diff changeset
   366
apply (rule_tac x = "O_proc p'" in exI)
chunhan
parents: 42
diff changeset
   367
apply (simp add:cp2sproc_exit tainted_eq_Tainted alive_exit
chunhan
parents: 42
diff changeset
   368
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   369
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   370
apply (clarsimp simp add:cp2sproc_exit tainted_eq_Tainted alive_exit
chunhan
parents: 42
diff changeset
   371
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   372
apply (rule_tac x = obj in exI, frule alive_exit, simp add:co2sobj_exit del:co2sobj.simps)+
chunhan
parents: 42
diff changeset
   373
chunhan
parents: 42
diff changeset
   374
apply (rule impI, frule current_proc_has_sp, simp, erule exE, simp)
chunhan
parents: 42
diff changeset
   375
apply (rule set_eqI, rule iffI)
chunhan
parents: 42
diff changeset
   376
apply (erule CollectE, erule exE, erule conjE, rule DiffI)
chunhan
parents: 42
diff changeset
   377
apply (rule CollectI, rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   378
apply (simp add:co2sobj_exit tainted_eq_Tainted alive_exit split:t_object.splits if_splits)
chunhan
parents: 42
diff changeset
   379
apply (rule notI, simp, case_tac obj)
chunhan
parents: 42
diff changeset
   380
apply (erule_tac x = nat in allE)
chunhan
parents: 42
diff changeset
   381
apply (simp add:co2sobj_exit cp2sproc_exit tainted_eq_Tainted split:option.splits)
chunhan
parents: 42
diff changeset
   382
apply (simp split:option.splits)+
chunhan
parents: 42
diff changeset
   383
apply (erule co2sobj_some_caseD)
chunhan
parents: 42
diff changeset
   384
apply (case_tac "pa = p")
chunhan
parents: 42
diff changeset
   385
apply (rule_tac x = "O_proc p'" in exI)
chunhan
parents: 42
diff changeset
   386
apply (simp add:cp2sproc_exit tainted_eq_Tainted alive_exit
chunhan
parents: 42
diff changeset
   387
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   388
apply (rule_tac x = "O_proc pa" in exI)
chunhan
parents: 42
diff changeset
   389
apply (clarsimp simp add:cp2sproc_exit tainted_eq_Tainted alive_exit
chunhan
parents: 42
diff changeset
   390
  split:t_object.splits if_splits option.splits)
chunhan
parents: 42
diff changeset
   391
apply (rule_tac x = obj in exI, frule alive_exit, simp add:co2sobj_exit del:co2sobj.simps)+
chunhan
parents: 42
diff changeset
   392
done
chunhan
parents: 42
diff changeset
   393
chunhan
parents: 42
diff changeset
   394
lemma alive_has_sobj':
chunhan
parents: 42
diff changeset
   395
  "\<lbrakk>co2sobj s obj = None; valid s\<rbrakk> \<Longrightarrow> \<not> alive s obj"
chunhan
parents: 42
diff changeset
   396
apply (case_tac obj)
chunhan
parents: 42
diff changeset
   397
apply (auto split:option.splits)
chunhan
parents: 42
diff changeset
   398
oops
chunhan
parents: 42
diff changeset
   399
chunhan
parents: 42
diff changeset
   400
declare co2sobj.simps [simp del]
chunhan
parents: 42
diff changeset
   401
chunhan
parents: 42
diff changeset
   402
lemma co2sobj_open_none:
chunhan
parents: 42
diff changeset
   403
  "\<lbrakk>valid (Open p f flag fd None # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (Open p f flag fd None # s) obj = (
chunhan
parents: 42
diff changeset
   404
      if (obj = O_proc p) 
chunhan
parents: 42
diff changeset
   405
      then (case (cp2sproc (Open p f flag fd None # s) p) of
chunhan
parents: 42
diff changeset
   406
              Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> Tainted s))
chunhan
parents: 42
diff changeset
   407
           | _       \<Rightarrow> None)
chunhan
parents: 42
diff changeset
   408
      else co2sobj s obj)"
chunhan
parents: 42
diff changeset
   409
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 42
diff changeset
   410
apply (frule_tac obj = obj in co2sobj_open, simp add:alive_open)
chunhan
parents: 42
diff changeset
   411
apply (auto split:t_object.splits option.splits dest!:current_proc_has_sp')
chunhan
parents: 42
diff changeset
   412
done
chunhan
parents: 42
diff changeset
   413
chunhan
parents: 42
diff changeset
   414
lemma co2sobj_open_some:
chunhan
parents: 42
diff changeset
   415
  "\<lbrakk>valid (Open p f flag fd (Some i) # s); alive s obj\<rbrakk> \<Longrightarrow> co2sobj (Open p f flag fd (Some i) # s) obj = (
chunhan
parents: 42
diff changeset
   416
      if (obj = O_proc p) 
chunhan
parents: 42
diff changeset
   417
      then (case (cp2sproc (Open p f flag fd (Some i) # s) p) of
chunhan
parents: 42
diff changeset
   418
              Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> Tainted s))
chunhan
parents: 42
diff changeset
   419
           | _       \<Rightarrow> None)
chunhan
parents: 42
diff changeset
   420
      else if (obj = O_file f) 
chunhan
parents: 42
diff changeset
   421
           then (case (cf2sfile (Open p f flag fd (Some i) # s) f) of
chunhan
parents: 42
diff changeset
   422
                   Some sf \<Rightarrow> Some (S_file {sf} (O_proc p \<in> Tainted s))
chunhan
parents: 42
diff changeset
   423
                 | _       \<Rightarrow> None)
chunhan
parents: 42
diff changeset
   424
           else co2sobj s obj)"
chunhan
parents: 42
diff changeset
   425
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 42
diff changeset
   426
apply (frule_tac obj = obj in co2sobj_open, simp add:alive_open)
chunhan
parents: 42
diff changeset
   427
apply (auto split:t_object.splits option.splits dest!:current_proc_has_sp')
chunhan
parents: 42
diff changeset
   428
done
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
   429
43
chunhan
parents: 42
diff changeset
   430
lemma alive_co2sobj_some_open_none:
chunhan
parents: 42
diff changeset
   431
  "\<lbrakk>co2sobj s obj = Some sobj; alive s obj; valid (Open p f flag fd None # s)\<rbrakk>
chunhan
parents: 42
diff changeset
   432
   \<Longrightarrow> alive (Open p f flag fd None # s) obj"
chunhan
parents: 42
diff changeset
   433
by (erule co2sobj_some_caseD, auto simp:alive_simps is_file_simps is_dir_simps)
chunhan
parents: 42
diff changeset
   434
chunhan
parents: 42
diff changeset
   435
lemma alive_co2sobj_some_open_none':
chunhan
parents: 42
diff changeset
   436
  "\<lbrakk>co2sobj (Open p f flag fd None # s) obj = Some sobj; alive (Open p f flag fd None # s) obj; 
chunhan
parents: 42
diff changeset
   437
    valid (Open p f flag fd None # s)\<rbrakk> \<Longrightarrow> alive s obj"
chunhan
parents: 42
diff changeset
   438
by (erule co2sobj_some_caseD, auto simp:alive_simps is_file_simps is_dir_simps)
chunhan
parents: 42
diff changeset
   439
chunhan
parents: 42
diff changeset
   440
lemma co2sobj_proc_obj:
chunhan
parents: 42
diff changeset
   441
  "\<lbrakk>co2sobj s obj = Some x; co2sobj s (O_proc p) = Some x\<rbrakk>
chunhan
parents: 42
diff changeset
   442
   \<Longrightarrow> \<exists> p'. obj = O_proc p'"
chunhan
parents: 42
diff changeset
   443
by (case_tac obj, auto simp:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   444
chunhan
parents: 42
diff changeset
   445
lemma s2ss_open_none:
chunhan
parents: 42
diff changeset
   446
  "valid (Open p f flag fd None # s) \<Longrightarrow> s2ss (Open p f flag fd None # s) = (
chunhan
parents: 42
diff changeset
   447
      case (co2sobj s (O_proc p), co2sobj (Open p f flag fd None # s) (O_proc p)) of
chunhan
parents: 42
diff changeset
   448
        (Some sp, Some sp') \<Rightarrow> 
chunhan
parents: 42
diff changeset
   449
           if (\<exists> p'. p' \<in> current_procs s \<and> p' \<noteq> p \<and> co2sobj s (O_proc p') = Some sp)
chunhan
parents: 42
diff changeset
   450
           then s2ss s \<union> {sp'}
chunhan
parents: 42
diff changeset
   451
           else s2ss s - {sp} \<union> {sp'} 
chunhan
parents: 42
diff changeset
   452
      | _                   \<Rightarrow> {} )"
chunhan
parents: 42
diff changeset
   453
unfolding s2ss_def
chunhan
parents: 42
diff changeset
   454
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 42
diff changeset
   455
apply (case_tac "co2sobj s (O_proc p)", simp add:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   456
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   457
apply (case_tac "co2sobj (Open p f flag fd None # s) (O_proc p)")
chunhan
parents: 42
diff changeset
   458
apply (simp add:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   459
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   460
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE, simp)
chunhan
parents: 42
diff changeset
   461
apply (frule_tac obj = obj in alive_co2sobj_some_open_none', simp, simp)
chunhan
parents: 42
diff changeset
   462
apply (rule conjI, rule impI, erule exE, (erule conjE)+)
chunhan
parents: 42
diff changeset
   463
apply (rule Meson.disj_comm, rule disjCI, case_tac "obj = O_proc p", simp)
chunhan
parents: 42
diff changeset
   464
apply (rule_tac x = obj in exI, simp add:co2sobj_open_none)
chunhan
parents: 42
diff changeset
   465
apply (rule impI)
chunhan
parents: 42
diff changeset
   466
apply (case_tac "obj = O_proc p", simp)
chunhan
parents: 42
diff changeset
   467
apply (rule Meson.disj_comm, rule disjCI, rule conjI)
chunhan
parents: 42
diff changeset
   468
apply (rule_tac x = obj in exI, simp add:co2sobj_open_none)
chunhan
parents: 42
diff changeset
   469
apply (simp add:co2sobj_open_none split:option.splits)
chunhan
parents: 42
diff changeset
   470
apply (rule notI)
chunhan
parents: 42
diff changeset
   471
apply (frule co2sobj_proc_obj, simp, erule exE)
chunhan
parents: 42
diff changeset
   472
apply (erule_tac x = p' in allE, simp)
chunhan
parents: 42
diff changeset
   473
chunhan
parents: 42
diff changeset
   474
apply (simp split:if_splits)
chunhan
parents: 42
diff changeset
   475
apply (erule disjE, rule_tac x = "O_proc p" in exI, simp)
chunhan
parents: 42
diff changeset
   476
apply (erule exE, erule conjE, case_tac "obj = O_proc p")
chunhan
parents: 42
diff changeset
   477
apply (rule_tac x = "O_proc p'" in exI, simp add:co2sobj_open_none)
chunhan
parents: 42
diff changeset
   478
apply (rule_tac x = obj in exI, simp add:co2sobj_open_none alive_co2sobj_some_open_none)
chunhan
parents: 42
diff changeset
   479
apply (erule disjE, rule_tac x = "O_proc p" in exI, simp)
chunhan
parents: 42
diff changeset
   480
apply (erule conjE, erule exE, erule conjE, case_tac "obj = O_proc p")
chunhan
parents: 42
diff changeset
   481
apply (rule_tac x = "O_proc p'" in exI, simp add:co2sobj_open_none)
chunhan
parents: 42
diff changeset
   482
apply (rule_tac x = obj in exI, simp add:co2sobj_open_none alive_co2sobj_some_open_none)
chunhan
parents: 42
diff changeset
   483
done
chunhan
parents: 42
diff changeset
   484
chunhan
parents: 42
diff changeset
   485
lemma alive_co2sobj_some_open_some:
chunhan
parents: 42
diff changeset
   486
  "\<lbrakk>alive s obj; valid (Open p f flag fd (Some i) # s)\<rbrakk>
chunhan
parents: 42
diff changeset
   487
   \<Longrightarrow> alive (Open p f flag fd (Some i) # s) obj"
chunhan
parents: 42
diff changeset
   488
by (case_tac obj, auto simp:alive_simps is_file_simps is_dir_simps)
chunhan
parents: 42
diff changeset
   489
chunhan
parents: 42
diff changeset
   490
lemma alive_co2sobj_some_open_some':
chunhan
parents: 42
diff changeset
   491
  "\<lbrakk>co2sobj (Open p f flag fd (Some i) # s) obj = Some sobj; alive (Open p f flag fd (Some i) # s) obj; 
chunhan
parents: 42
diff changeset
   492
    valid (Open p f flag fd (Some i) # s); obj \<noteq> O_file f\<rbrakk> \<Longrightarrow> alive s obj"
chunhan
parents: 42
diff changeset
   493
by (erule co2sobj_some_caseD, auto simp:alive_simps is_file_simps is_dir_simps)
chunhan
parents: 42
diff changeset
   494
chunhan
parents: 42
diff changeset
   495
lemma s2ss_open_some:
chunhan
parents: 42
diff changeset
   496
  "valid (Open p f flag fd (Some i) # s) \<Longrightarrow> s2ss (Open p f flag fd (Some i) # s) = (
chunhan
parents: 42
diff changeset
   497
      case (co2sobj s (O_proc p), co2sobj (Open p f flag fd (Some i) # s) (O_proc p),
chunhan
parents: 42
diff changeset
   498
            co2sobj (Open p f flag fd (Some i) # s) (O_file f)) of
chunhan
parents: 42
diff changeset
   499
        (Some sp, Some sp', Some sf) \<Rightarrow> 
chunhan
parents: 42
diff changeset
   500
           if (\<exists> p'. p' \<in> current_procs s \<and> p' \<noteq> p \<and> co2sobj s (O_proc p') = Some sp)
chunhan
parents: 42
diff changeset
   501
           then s2ss s \<union> {sp', sf} 
chunhan
parents: 42
diff changeset
   502
           else s2ss s - {sp} \<union> {sp', sf} 
chunhan
parents: 42
diff changeset
   503
      | _                   \<Rightarrow> {} )"
chunhan
parents: 42
diff changeset
   504
unfolding s2ss_def
chunhan
parents: 42
diff changeset
   505
apply (frule vt_grant_os, frule vd_cons)
chunhan
parents: 42
diff changeset
   506
apply (case_tac "co2sobj s (O_proc p)", simp add:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   507
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   508
apply (case_tac "co2sobj (Open p f flag fd (Some i) # s) (O_proc p)")
chunhan
parents: 42
diff changeset
   509
apply (simp add:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   510
apply (drule current_proc_has_sp', simp, simp)
chunhan
parents: 42
diff changeset
   511
apply (case_tac "co2sobj (Open p f flag fd (Some i) # s) (O_file f)")
chunhan
parents: 42
diff changeset
   512
apply (simp add:co2sobj.simps split:option.splits)
chunhan
parents: 42
diff changeset
   513
apply (clarsimp split del:if_splits)
chunhan
parents: 42
diff changeset
   514
chunhan
parents: 42
diff changeset
   515
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE)
chunhan
parents: 42
diff changeset
   516
apply (split if_splits, rule conjI, rule impI, erule exE, erule conjE, erule conjE)
chunhan
parents: 42
diff changeset
   517
apply (case_tac "obj = O_proc p", simp, case_tac "obj = O_file f", simp)
chunhan
parents: 42
diff changeset
   518
apply (rule UnI1, rule CollectI, rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   519
apply (frule_tac obj = obj in alive_co2sobj_some_open_some', simp+)
chunhan
parents: 42
diff changeset
   520
apply (simp add:co2sobj_open split:t_object.splits)
chunhan
parents: 42
diff changeset
   521
apply (rule impI, case_tac "obj = O_proc p", simp, case_tac "obj = O_file f", simp)
chunhan
parents: 42
diff changeset
   522
apply (rule UnI1, rule DiffI, rule CollectI, rule_tac x = obj in exI)
chunhan
parents: 42
diff changeset
   523
apply (frule_tac obj = obj in alive_co2sobj_some_open_some', simp+)
chunhan
parents: 42
diff changeset
   524
apply (simp add:co2sobj_open split:t_object.splits)
chunhan
parents: 42
diff changeset
   525
apply (frule_tac obj = obj in co2sobj_open_some, simp+)
chunhan
parents: 42
diff changeset
   526
apply (simp add:alive_co2sobj_some_open_some', simp)
chunhan
parents: 42
diff changeset
   527
apply (rule notI)
chunhan
parents: 42
diff changeset
   528
apply (frule_tac obj = obj and p = p in co2sobj_proc_obj, simp+, erule exE)
chunhan
parents: 42
diff changeset
   529
apply (erule_tac x = p' in allE, simp)
chunhan
parents: 42
diff changeset
   530
chunhan
parents: 42
diff changeset
   531
apply (simp split:if_splits, erule disjE)
chunhan
parents: 42
diff changeset
   532
apply (rule_tac x = "O_proc p" in exI, simp)
chunhan
parents: 42
diff changeset
   533
apply (erule disjE, rule_tac x = "O_file f" in exI, simp add:is_file_simps)
chunhan
parents: 42
diff changeset
   534
apply (erule exE, erule conjE)
chunhan
parents: 42
diff changeset
   535
apply (case_tac "obj = O_proc p", simp)
chunhan
parents: 42
diff changeset
   536
apply (rule_tac x = "O_proc p'" in exI, simp add:co2sobj_open_some)
chunhan
parents: 42
diff changeset
   537
apply (case_tac "obj = O_file f", simp add:is_file_in_current)
chunhan
parents: 42
diff changeset
   538
apply (rule_tac x = obj in exI, simp add:co2sobj_open_some alive_co2sobj_some_open_some)
chunhan
parents: 42
diff changeset
   539
apply (erule disjE, rule_tac x = "O_proc p" in exI, simp)
chunhan
parents: 42
diff changeset
   540
apply (erule disjE, rule_tac x = "O_file f" in exI, simp add:is_file_simps)
chunhan
parents: 42
diff changeset
   541
apply (erule conjE, erule exE, erule conjE)
chunhan
parents: 42
diff changeset
   542
apply (case_tac "obj = O_proc p", simp)
chunhan
parents: 42
diff changeset
   543
apply (case_tac "obj = O_file f", simp add:is_file_in_current)
chunhan
parents: 42
diff changeset
   544
apply (rule_tac x = obj in exI, simp add:co2sobj_open_some alive_co2sobj_some_open_some)
chunhan
parents: 42
diff changeset
   545
done
chunhan
parents: 42
diff changeset
   546
chunhan
parents: 42
diff changeset
   547
lemma s2ss_open:
chunhan
parents: 42
diff changeset
   548
  "valid (Open p f flag fd opt # s) \<Longrightarrow> s2ss (Open p f flag fd opt # s) = (
chunhan
parents: 42
diff changeset
   549
     if opt = None
chunhan
parents: 42
diff changeset
   550
     then (case (co2sobj s (O_proc p), co2sobj (Open p f flag fd opt # s) (O_proc p)) of
chunhan
parents: 42
diff changeset
   551
        (Some sp, Some sp') \<Rightarrow> 
chunhan
parents: 42
diff changeset
   552
           if (\<exists> p'. p' \<in> current_procs s \<and> p' \<noteq> p \<and> co2sobj s (O_proc p') = Some sp)
chunhan
parents: 42
diff changeset
   553
           then s2ss s \<union> {sp'}
chunhan
parents: 42
diff changeset
   554
           else s2ss s - {sp} \<union> {sp'} 
chunhan
parents: 42
diff changeset
   555
      | _                   \<Rightarrow> {} )
chunhan
parents: 42
diff changeset
   556
     else (case (co2sobj s (O_proc p), co2sobj (Open p f flag fd opt # s) (O_proc p),
chunhan
parents: 42
diff changeset
   557
            co2sobj (Open p f flag fd opt # s) (O_file f)) of
chunhan
parents: 42
diff changeset
   558
        (Some sp, Some sp', Some sf) \<Rightarrow> 
chunhan
parents: 42
diff changeset
   559
           if (\<exists> p'. p' \<in> current_procs s \<and> p' \<noteq> p \<and> co2sobj s (O_proc p') = Some sp)
chunhan
parents: 42
diff changeset
   560
           then s2ss s \<union> {sp', sf} 
chunhan
parents: 42
diff changeset
   561
           else s2ss s - {sp} \<union> {sp', sf} 
chunhan
parents: 42
diff changeset
   562
      | _                   \<Rightarrow> {} ) )"
chunhan
parents: 42
diff changeset
   563
apply (case_tac opt)
chunhan
parents: 42
diff changeset
   564
apply (simp add:s2ss_open_some s2ss_open_none)+
chunhan
parents: 42
diff changeset
   565
done
chunhan
parents: 42
diff changeset
   566
44
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   567
lemma s2ss_readfile:
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   568
  "valid (ReadFile p fd # s) \<Longrightarrow> s2ss (ReadFile p fd # s) = (
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   569
     case (file_of_proc_fd s p fd) of 
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   570
       Some f \<Rightarrow> if (O_file f \<in> Tainted s)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   571
                 then update_s2ss_shm s p
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   572
                 else s2ss s
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   573
     | _      \<Rightarrow> {})"
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   574
apply (frule vt_grant_os, frule vd_cons, clarsimp split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   575
apply (rule conjI, rule impI, rule impI, simp)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   576
unfolding update_s2ss_shm_def s2ss_def
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   577
apply (rule set_eqI, rule iffI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   578
apply (drule CollectD, (erule exE|erule conjE)+)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   579
apply (erule co2sobj_some_caseD)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   580
apply (rule DiffI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   581
apply (case_tac "O_proc pa \<in> Tainted s")
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   582
apply (rule UnI1, simp, rule_tac x = "O_proc pa" in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   583
apply (clarsimp simp:cp2sproc_other tainted_eq_Tainted co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   584
apply (case_tac "info_flow_shm s p pa")
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   585
apply (rule UnI2, rule CollectI, simp only:co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   586
apply (drule current_proc_has_sp', simp, simp)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   587
apply (rule_tac x = ab in exI, rule_tac x = pa in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   588
apply (clarsimp simp:cp2sproc_other tainted_eq_Tainted split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   589
apply (rule UnI1, simp)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   590
apply (rule_tac x = "O_proc pa" in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   591
apply (clarsimp simp:cp2sproc_other tainted_eq_Tainted co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   592
apply (rule notI, clarsimp simp:cp2sproc_other tainted_eq_Tainted co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   593
apply (erule_tac x = pa in allE, simp)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   594
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   595
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   596
apply (simp add:alive_simps co2sobj_readfile, rule notI, clarsimp simp:co2sobj.simps)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   597
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   598
apply (simp add:alive_simps co2sobj_readfile, rule notI, clarsimp simp:co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   599
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   600
apply (simp add:alive_simps co2sobj_readfile, rule notI, clarsimp simp:co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   601
apply (rule DiffI, rule UnI1, rule CollectI, rule_tac x = obj in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   602
apply (simp add:alive_simps co2sobj_readfile, rule notI, clarsimp simp:co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   603
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   604
apply (erule DiffE, drule s2ss_ptrace1_aux, erule UnE)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   605
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   606
apply (erule co2sobj_some_caseD)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   607
apply (case_tac "O_proc pa \<in> Tainted s")
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   608
apply (rule_tac x = "O_proc pa" in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   609
apply (clarsimp simp:tainted_eq_Tainted cp2sproc_other co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   610
apply (case_tac "info_flow_shm s p pa", simp only:co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   611
apply (drule current_proc_has_sp', simp, simp)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   612
apply (drule Meson.not_exD, erule_tac x = ab in allE, drule Meson.not_exD, erule_tac x = pa in allE)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   613
apply (simp add:tainted_eq_Tainted, (erule exE|erule conjE)+)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   614
apply (rule_tac x = "O_proc p'" in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   615
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   616
apply (rule_tac x = "O_proc pa" in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   617
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted co2sobj.simps split:option.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   618
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   619
apply (rule_tac x = obj in exI,
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   620
       auto split:option.splits simp:co2sobj_readfile alive_simps simp del:co2sobj.simps)[1]
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   621
apply (rule_tac x = obj in exI,
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   622
       auto split:option.splits simp:co2sobj_readfile alive_simps simp del:co2sobj.simps)[1]
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   623
apply (rule_tac x = obj in exI,
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   624
       auto split:option.splits simp:co2sobj_readfile alive_simps simp del:co2sobj.simps)[1]
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   625
apply (rule_tac x = obj in exI,
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   626
       auto split:option.splits simp:co2sobj_readfile alive_simps simp del:co2sobj.simps)[1]
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   627
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   628
apply (erule CollectE, (erule exE|erule conjE)+, rule CollectI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   629
apply (rule_tac x = "O_proc pa" in exI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   630
apply (clarsimp simp:Tainted_ptrace' cp2sproc_other tainted_eq_Tainted info_shm_flow_in_procs co2sobj.simps)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   631
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   632
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   633
apply (rule impI, rule impI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   634
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE, rule CollectI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   635
apply (rule_tac x = obj in exI, simp add:alive_simps co2sobj_readfile split:t_object.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   636
apply (erule CollectE, erule exE, erule conjE, rule CollectI)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   637
apply (rule_tac x = obj in exI, simp add:alive_simps)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   638
apply (drule_tac obj = obj in co2sobj_readfile, simp)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   639
apply (simp split:t_object.splits)
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   640
apply (simp add:co2sobj.simps)+
563194dcdbc6 s2ss_readfile
chunhan
parents: 43
diff changeset
   641
done
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
   642
45
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   643
lemma same_inode_files_prop9:
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   644
  "is_file s f \<Longrightarrow> f \<in> same_inode_files s f"
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   645
by (simp add:same_inode_files_def)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   646
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   647
lemma cf2sfiles_prop:
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   648
  "\<lbrakk>f \<in> same_inode_files s f'; valid s\<rbrakk> \<Longrightarrow> cf2sfiles s f = cf2sfiles s f'"
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   649
apply (auto simp:cf2sfiles_def)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   650
apply (rule_tac x = f'a in bexI, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   651
apply (erule same_inode_files_prop4, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   652
apply (rule_tac x = f'a in bexI, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   653
apply (drule same_inode_files_prop5)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   654
apply (erule same_inode_files_prop4, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   655
done
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   656
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   657
lemma co2sobj_writefile_unchange:
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   658
  "\<lbrakk>valid (WriteFile p fd # s); alive s obj; file_of_proc_fd s p fd = Some f;
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   659
    O_proc p \<in> Tainted s \<longrightarrow> O_file f \<in> Tainted s\<rbrakk> 
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   660
   \<Longrightarrow> co2sobj (WriteFile p fd # s) obj = co2sobj s obj"
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   661
apply (frule vd_cons, frule co2sobj_writefile, simp, simp split:t_object.splits if_splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   662
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   663
apply (case_tac "O_proc p \<in> Tainted s")
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   664
apply (simp add:tainted_eq_Tainted same_inodes_Tainted)+
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   665
done
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   666
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   667
lemma s2ss_writefile:
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   668
  "valid (WriteFile p fd # s) \<Longrightarrow> s2ss (WriteFile p fd # s) = (
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   669
     case (file_of_proc_fd s p fd) of
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   670
       Some f \<Rightarrow> if (O_proc p \<in> Tainted s \<and> O_file f \<notin> Tainted s)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   671
                 then (if (\<exists> f'. f' \<notin> same_inode_files s f \<and> is_file s f' \<and>
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   672
                                 co2sobj s (O_file f') = co2sobj s (O_file f))
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   673
                       then s2ss s \<union> {S_file (cf2sfiles s f) True}
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   674
                       else s2ss s - {S_file (cf2sfiles s f) False} 
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   675
                                   \<union> {S_file (cf2sfiles s f) True})
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   676
                 else s2ss s
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   677
     | _      \<Rightarrow> {})"
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   678
apply (frule vd_cons, frule vt_grant_os)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   679
apply (clarsimp split:option.splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   680
unfolding s2ss_def
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   681
apply (rule conjI|rule impI|erule exE|erule conjE)+
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   682
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   683
apply (frule_tac obj =  obj in co2sobj_writefile, simp add:alive_other)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   684
apply (simp split:t_object.splits if_splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   685
apply (rule disjI2, rule_tac x= "O_proc nat" in exI, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   686
apply (rule disjI1, simp add:cf2sfiles_prop)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   687
apply (rule disjI2, rule_tac x = obj in exI, simp add:is_file_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   688
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   689
apply (rule disjI2, rule_tac x = obj in exI, simp add:is_dir_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   690
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   691
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   692
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   693
apply (rule disjI2, rule_tac x = obj in exI, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   694
apply (rule disjI2, rule_tac x = obj in exI, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   695
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   696
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   697
apply (simp, erule disjE)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   698
apply (rule_tac x = "O_file aa" in exI, simp add:is_file_simps file_of_pfd_is_file)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   699
apply (frule_tac obj = "O_file aa" in co2sobj_writefile, simp add:file_of_pfd_is_file)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   700
apply (simp split:if_splits add:same_inode_files_def file_of_pfd_is_file)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   701
apply (erule exE, erule conjE)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   702
apply (erule_tac obj = obj in co2sobj_some_caseD)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   703
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   704
apply (case_tac "fa \<in> same_inode_files s aa")
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   705
apply (frule_tac f = fa and f' = aa in cf2sfiles_prop, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   706
apply (rule_tac x = "O_file f'" in exI, simp add:co2sobj_writefile is_file_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   707
apply (rule conjI, rule impI, simp add:same_inode_files_prop5)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   708
apply (rule impI, simp add:co2sobj.simps tainted_eq_Tainted same_inodes_Tainted)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   709
apply (rule_tac x = "O_file fa" in exI, simp add:co2sobj_writefile is_file_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   710
apply (rule impI, simp add:same_inode_files_prop5)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   711
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   712
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile is_dir_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   713
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   714
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   715
apply (rule impI, rule impI, simp, rule set_eqI, rule iffI, erule CollectE, (erule conjE|erule exE)+)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   716
apply (rule CollectI, rule_tac x = obj in exI, simp add:alive_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   717
apply (simp add:co2sobj_writefile split:t_object.splits if_splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   718
apply (simp add:co2sobj.simps tainted_eq_Tainted same_inodes_Tainted)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   719
apply (case_tac "O_proc p \<in> Tainted s", simp, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   720
apply (erule CollectE, (erule conjE|erule exE)+, rule CollectI)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   721
apply (rule_tac x = obj in exI)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   722
apply (simp add:co2sobj_writefile_unchange alive_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   723
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   724
apply (rule impI| rule conjI|erule conjE)+
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   725
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   726
apply (simp add:alive_simps co2sobj_writefile split:t_object.splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   727
apply (rule disjI2, rule conjI, rule_tac x = obj in exI, simp,
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   728
  rule notI, simp add:co2sobj.simps split:option.splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   729
apply (simp split:if_splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   730
apply (rule disjI1, simp add:cf2sfiles_prop)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   731
apply (rule disjI2, rule conjI, rule_tac x = obj in exI, simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   732
apply (rule notI, simp add:co2sobj.simps split:option.splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   733
apply (erule_tac x = list in allE, simp add:tainted_eq_Tainted same_inode_files_prop5)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   734
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   735
apply (rule disjI2, rule conjI, rule_tac x = obj in exI, simp,
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   736
  rule notI, simp add:co2sobj.simps split:option.splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   737
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   738
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   739
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   740
apply (rule disjI2, rule conjI, rule_tac x = obj in exI, simp,
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   741
  rule notI, simp add:co2sobj.simps split:option.splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   742
apply (rule disjI2, rule conjI, rule_tac x = obj in exI, simp,
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   743
  rule notI, simp add:co2sobj.simps split:option.splits)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   744
apply (simp add:co2sobj.simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   745
apply (simp)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   746
apply (erule disjE)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   747
apply (rule_tac x= "O_file aa" in exI, simp add:co2sobj_writefile alive_simps file_of_pfd_is_file)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   748
apply (rule impI, simp add:same_inode_files_def file_of_pfd_is_file)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   749
apply (erule exE|erule conjE)+
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   750
apply (erule co2sobj_some_caseD)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   751
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   752
apply (case_tac "fa \<in> same_inode_files s aa")
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   753
apply (frule cf2sfiles_prop, simp, simp add:co2sobj.simps tainted_eq_Tainted same_inodes_Tainted)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   754
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile is_file_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   755
apply (rule impI, simp add:same_inode_files_prop5)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   756
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   757
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile is_dir_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   758
apply (rule_tac x = obj in exI, simp add:co2sobj_writefile)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   759
apply (rule impI, rule impI)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   760
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   761
apply (rule set_eqI, rule iffI, erule CollectE,erule exE,erule conjE,rule CollectI)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   762
apply (rule_tac x = obj in exI)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   763
apply (simp add:co2sobj_writefile_unchange alive_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   764
apply (erule CollectE, erule exE, erule conjE)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   765
apply (rule CollectI, rule_tac x = obj in exI)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   766
apply (simp add:co2sobj_writefile_unchange alive_simps)
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   767
done
d7fab2e2a0b8 s2ss_writefile
chunhan
parents: 44
diff changeset
   768
47
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   769
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   770
definition update_s2ss_obj :: "t_state \<Rightarrow> t_static_state \<Rightarrow> t_object \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   771
where
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   772
  "update_s2ss_obj s ss obj sobj sobj' = 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   773
     (if (\<exists> obj'. alive s obj' \<and> obj' \<noteq> obj \<and> co2sobj s obj' = Some sobj)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   774
      then ss \<union> {sobj'}
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   775
      else ss - {sobj} \<union> {sobj'})"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   776
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   777
definition update_s2ss_sfile :: "t_state \<Rightarrow> t_static_state \<Rightarrow> t_file \<Rightarrow> t_sfile \<Rightarrow> t_static_state"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   778
where 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   779
  "update_s2ss_sfile s ss f sf \<equiv> 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   780
     if (same_inode_files s f = {f})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   781
     then ss
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   782
     else ss \<union> {S_file (cf2sfiles s f - {sf}) (O_file f \<in> Tainted s)}"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   783
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   784
definition del_s2ss_file:: "t_state \<Rightarrow> t_static_state \<Rightarrow> t_file \<Rightarrow> t_sfile \<Rightarrow> t_static_state"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   785
where
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   786
  "del_s2ss_file s ss f sf = 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   787
     (if (\<exists> f' \<in> same_inode_files s f. f' \<noteq> f \<and> cf2sfile s f' = Some sf)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   788
      then ss
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   789
      else if (\<exists> f'. is_file s f' \<and> f' \<notin> same_inode_files s f \<and> co2sobj s (O_file f') = co2sobj s (O_file f))
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   790
           then update_s2ss_sfile s ss f sf
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   791
           else update_s2ss_sfile s (ss - {S_file (cf2sfiles s f) (O_file f \<in> Tainted s)}) f sf"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   792
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   793
lemma alive_co2sobj_closefd1:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   794
  "\<lbrakk>alive s obj; valid (CloseFd p fd # s); co2sobj s obj = Some sobj; 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   795
    file_of_proc_fd s p fd = Some f; \<not> (f \<in> files_hung_by_del s \<and> proc_fd_of_file s f = {(p, fd)})\<rbrakk>
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   796
   \<Longrightarrow> alive (CloseFd p fd # s) obj"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   797
apply (erule co2sobj_some_caseD)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   798
by (auto simp:alive_simps is_file_simps is_dir_simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   799
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   800
lemma alive_co2sobj_closefd3:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   801
  "\<lbrakk>alive s obj; valid (CloseFd p fd # s); co2sobj s obj = Some sobj; obj \<noteq> O_file f;
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   802
    file_of_proc_fd s p fd = Some f; f \<in> files_hung_by_del s; proc_fd_of_file s f = {(p, fd)}\<rbrakk>
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   803
   \<Longrightarrow> alive (CloseFd p fd # s) obj"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   804
apply (erule co2sobj_some_caseD)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   805
by (auto simp:alive_simps is_file_simps is_dir_simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   806
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   807
lemma alive_co2sobj_closefd2:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   808
  "\<lbrakk>alive s obj; valid (CloseFd p fd # s); co2sobj s obj = Some sobj; file_of_proc_fd s p fd = None\<rbrakk>
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   809
   \<Longrightarrow> alive (CloseFd p fd # s) obj"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   810
apply (erule co2sobj_some_caseD)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   811
by (auto simp:alive_simps is_file_simps is_dir_simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   812
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   813
lemma alive_co2sobj_closefd':
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   814
  "\<lbrakk>co2sobj (CloseFd p fd # s) obj = Some sobj; alive (CloseFd p fd # s) obj; 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   815
    valid (CloseFd p fd # s)\<rbrakk> \<Longrightarrow> alive s obj"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   816
apply (erule co2sobj_some_caseD)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   817
by (auto simp:alive_simps is_file_simps is_dir_simps split:option.splits if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   818
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   819
ML {*asm_full_simp_tac*}
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   820
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   821
ML {*
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   822
fun my_setiff_tac i = 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   823
     (etac @{thm CollectE} i 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   824
      ORELSE (     asm_full_simp_tac (HOL_ss addsimps @{thms Set.insert_iff}) i
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   825
              THEN etac @{thm disjE} i)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   826
      ORELSE (     asm_full_simp_tac (HOL_ss addsimps @{thms Set.Diff_iff}) i
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   827
              THEN etac @{thm conjE} i 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   828
              THEN (REPEAT (etac @{thm CollectE} i))))
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   829
THEN (REPEAT ((        etac @{thm exE} 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   830
               ORELSE' etac @{thm conjE}
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   831
               ORELSE' etac @{thm bexE}) i))
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   832
THEN (rtac @{thm CollectI} i
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   833
      ORELSE (     asm_full_simp_tac (HOL_ss addsimps @{thms Set.insert_iff}) i))
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   834
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   835
*}
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   836
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   837
ML {*
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   838
fun my_seteq_tac i = 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   839
     (simp_tac (HOL_ss addsimps @{thms s2ss_def}) 1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   840
THEN (rtac @{thm set_eqI} i)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   841
THEN (rtac @{thm iffI} i)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   842
THEN my_setiff_tac i
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   843
*}
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   844
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   845
lemma co2sobj_sproc_imp:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   846
  "co2sobj s obj = Some (S_proc sp tag) \<Longrightarrow> \<exists> p. obj = O_proc p"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   847
by (case_tac obj, auto simp:co2sobj.simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   848
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   849
lemma co2sobj_sfile_imp:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   850
  "co2sobj s obj = Some (S_file sfs tag) \<Longrightarrow> \<exists> f. obj = O_file f"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   851
by (case_tac obj, auto simp:co2sobj.simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   852
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   853
lemma co2sobj_sdir_imp:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   854
  "co2sobj s obj = Some (S_dir sf) \<Longrightarrow> \<exists> f. obj = O_dir f"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   855
by (case_tac obj, auto simp:co2sobj.simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   856
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   857
lemma co2sobj_sshm_imp:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   858
  "co2sobj s obj = Some (S_shm sh) \<Longrightarrow> \<exists> h. obj = O_shm h"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   859
by (case_tac obj, auto simp:co2sobj.simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   860
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   861
lemma co2sobj_smsgq_imp:
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   862
  "co2sobj s obj = Some (S_msgq sq) \<Longrightarrow> \<exists> q. obj = O_msgq q"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   863
by (case_tac obj, auto simp:co2sobj.simps split:option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   864
46
f66d61f5439d need a more general update_s2ss_sobj concept
chunhan
parents: 45
diff changeset
   865
lemma s2ss_closefd:
f66d61f5439d need a more general update_s2ss_sobj concept
chunhan
parents: 45
diff changeset
   866
  "valid (CloseFd p fd # s) \<Longrightarrow> s2ss (CloseFd p fd # s) = (
f66d61f5439d need a more general update_s2ss_sobj concept
chunhan
parents: 45
diff changeset
   867
     case (file_of_proc_fd s p fd) of
47
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   868
       Some f \<Rightarrow> if (f \<in> files_hung_by_del s \<and> proc_fd_of_file s f = {(p, fd)})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   869
                 then (case (cf2sfile s f, cp2sproc s p, cp2sproc (CloseFd p fd # s) p) of
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   870
                         (Some sf, Some sp, Some sp') \<Rightarrow> 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   871
                            (del_s2ss_file s (
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   872
                               update_s2ss_obj s (s2ss s) (O_proc p) 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   873
                                 (S_proc sp (O_proc p \<in> Tainted s))
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   874
                                 (S_proc sp' (O_proc p \<in> Tainted s))) f sf)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   875
                      | _ \<Rightarrow> {})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   876
                 else (case (cp2sproc s p, cp2sproc (CloseFd p fd # s) p) of 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   877
                         (Some sp, Some sp') \<Rightarrow> 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   878
                            (update_s2ss_obj s (s2ss s) (O_proc p)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   879
                               (S_proc sp (O_proc p \<in> Tainted s))
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   880
                               (S_proc sp' (O_proc p \<in> Tainted s)))
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   881
                      | _ \<Rightarrow> {})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   882
      | _     \<Rightarrow> s2ss s)"
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   883
apply (frule vd_cons, frule vt_grant_os)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   884
apply (clarsimp simp only:os_grant.simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   885
apply (frule current_proc_has_sp, simp, erule exE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   886
apply (case_tac "file_of_proc_fd s p fd")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   887
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   888
apply (simp add:s2ss_def)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   889
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE, rule CollectI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   890
apply (rule_tac x = obj in exI, simp add:alive_co2sobj_closefd')
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   891
apply (frule co2sobj_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   892
apply (frule cp2sproc_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   893
apply (simp add:proc_file_fds_def split:t_object.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   894
apply (simp split:if_splits add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   895
apply (erule CollectE, erule exE, erule conjE, rule CollectI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   896
apply (rule_tac x = obj in exI, simp add:alive_co2sobj_closefd2)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   897
apply (frule_tac obj = obj in co2sobj_closefd, simp add:alive_co2sobj_closefd2)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   898
apply (frule cp2sproc_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   899
apply (auto simp add:proc_file_fds_def co2sobj.simps tainted_eq_Tainted 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   900
            split:t_object.splits option.splits if_splits)[1]
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   901
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   902
apply (case_tac "cp2sproc (CloseFd p fd # s) p")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   903
apply (drule current_proc_has_sp', simp, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   904
apply (case_tac "cf2sfile s a")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   905
apply (drule current_file_has_sfile', simp, simp add:file_of_pfd_in_current)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   906
apply (simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   907
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   908
apply (rule conjI, rule impI, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   909
apply (simp add:del_s2ss_file_def)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   910
apply (rule conjI|rule impI|erule exE|erule conjE|erule bexE)+
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   911
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   912
apply (simp add:update_s2ss_obj_def)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   913
apply (rule conjI|rule impI|erule exE|erule conjE|erule bexE)+
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   914
apply (tactic {*my_seteq_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   915
apply simp
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   916
apply (case_tac "obj = O_proc p")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   917
apply (simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   918
apply (rule disjI2, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   919
apply (frule_tac obj = obj in co2sobj_closefd, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   920
apply (simp add:alive_simps co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   921
apply (tactic {*my_setiff_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   922
apply (rule_tac x = "O_proc p" in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   923
apply (simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   924
apply (tactic {*my_setiff_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   925
apply (case_tac "obj = O_proc p")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   926
apply (rule_tac x = obj' in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   927
apply (frule co2sobj_sproc_imp, erule exE, simp add:co2sobj_closefd)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   928
apply (simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   929
apply (case_tac "obj = O_file a")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   930
apply (rule_tac x = "O_file f'" in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   931
apply (case_tac "f' = a", simp add:same_inode_files_prop9 file_of_pfd_is_file)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   932
apply (frule_tac obj = "O_file f'" in co2sobj_closefd, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   933
apply (simp add:alive_simps co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   934
apply (rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   935
apply (frule_tac obj = obj in alive_co2sobj_closefd3, simp+)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   936
apply (frule_tac obj = obj in co2sobj_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   937
apply (auto simp add:alive_simps co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)[1]
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   938
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   939
apply (rule impI)+
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   940
apply (tactic {*my_seteq_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   941
apply (case_tac "obj = O_proc p", rule disjI1, simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   942
apply (rule disjI2)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   943
apply (case_tac "obj = O_file a", simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   944
apply (rule DiffI, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   945
apply (rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   946
apply (frule_tac obj = obj in alive_co2sobj_closefd', simp+)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   947
apply (frule_tac obj = obj in co2sobj_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   948
apply (simp add:alive_simps co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   949
apply (simp, rule notI, simp, frule co2sobj_sproc_imp, erule exE, simp add:co2sobj_closefd)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   950
apply (erule_tac x = "O_proc pa" in allE, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   951
apply (tactic {*my_setiff_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   952
apply (rule_tac x = "O_proc p" in exI, simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   953
apply (tactic {*my_setiff_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   954
apply (case_tac "obj = O_proc p", simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   955
apply (case_tac "obj = O_file a", rule_tac x = "O_file f'" in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   956
apply (case_tac "f' = a", simp add:same_inode_files_prop9 file_of_pfd_is_file)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   957
apply (frule_tac obj = "O_file f'" in co2sobj_closefd, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   958
apply (simp add:alive_simps co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   959
apply (rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   960
apply (frule_tac obj = obj in alive_co2sobj_closefd3, simp+)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   961
apply (frule_tac obj = obj in co2sobj_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   962
apply (auto simp add:co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)[1]
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   963
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   964
apply (rule impI, tactic {*my_seteq_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   965
apply (simp add:update_s2ss_obj_def)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   966
apply (rule conjI, rule impI, (erule exE|erule conjE)+)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   967
apply (erule_tac obj = obj in co2sobj_some_caseD)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   968
apply (case_tac "pa = p", simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   969
apply (rule disjI2, rule disjI2, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   970
apply (frule_tac obj = obj in co2sobj_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   971
apply (auto simp add:co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)[1]
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   972
apply (case_tac "f = a", simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   973
apply (case_tac "f \<in> same_inode_files s a", rule disjI1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   974
apply (simp add:co2sobj_simps split:if_splits option.splits t_sobject.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   975
apply (simp add:co2sobj.simps tainted_eq_Tainted same_inodes_Tainted cf2sfiles_prop)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   976
apply (erule bexE, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   977
apply (erule_tac x = f'' in ballE, simp, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   978
apply (rule disjI2, rule disjI2, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   979
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   980
apply (rule disjI2, rule disjI2, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   981
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   982
apply (rule disjI2, rule disjI2, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   983
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   984
apply (rule disjI2, rule disjI2, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   985
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   986
apply (rule impI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   987
apply (erule_tac obj = obj in co2sobj_some_caseD)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   988
apply (case_tac "pa = p", simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   989
apply (rule disjI2, rule disjI2, rule conjI, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   990
apply (frule_tac obj = obj in co2sobj_closefd, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   991
apply (auto simp add:co2sobj.simps tainted_eq_Tainted split:t_object.splits if_splits)[1]
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   992
apply (rule notI, simp add:co2sobj_closefd)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   993
apply (erule_tac x = obj in allE, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   994
apply (case_tac "f = a", simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   995
apply (case_tac "f \<in> same_inode_files s a", rule disjI1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   996
apply (simp add:co2sobj_simps split:if_splits option.splits t_sobject.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   997
apply (simp add:co2sobj.simps tainted_eq_Tainted same_inodes_Tainted cf2sfiles_prop)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   998
apply (erule bexE, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
   999
apply (erule_tac x = f'' in ballE, simp, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1000
apply (rule disjI2, rule disjI2, rule conjI, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1001
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1002
apply (rule notI, simp add:co2sobj_closefd, erule_tac x = obj in allE, simp add:is_file_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1003
apply (rule disjI2, rule disjI2, rule conjI, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1004
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1005
apply (rule notI, simp add:co2sobj_closefd, erule_tac x = obj in allE, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1006
apply (rule disjI2, rule disjI2, rule conjI, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1007
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1008
apply (rule notI, simp add:co2sobj_closefd, erule_tac x = obj in allE, simp add:is_dir_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1009
apply (rule disjI2, rule disjI2, rule conjI, rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1010
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp add:alive_simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1011
apply (rule notI, simp add:co2sobj_closefd, erule_tac x = obj in allE, simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1012
apply (tactic {*my_setiff_tac 1*})
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1013
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1014
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1015
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1016
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1017
defer
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1018
apply (rule impI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1019
apply (simp add:update_s2ss_obj_def)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1020
apply (rule conjI, rule impI, erule exE, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1021
apply (simp add:s2ss_def)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1022
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1023
apply (simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1024
apply (case_tac "obj = O_proc p")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1025
apply (simp add:co2sobj.simps tainted_eq_Tainted split:if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1026
apply (rule disjI2, rule_tac x = obj in exI, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1027
apply (simp add:alive_co2sobj_closefd')
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1028
apply (frule_tac obj = obj in co2sobj_closefd, simp, simp split:t_object.splits if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1029
apply (simp, erule disjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1030
apply (rule_tac x = "O_proc p" in exI, simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1031
apply (erule exE, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1032
apply (case_tac "obj = O_proc p")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1033
apply (rule_tac x = obj' in exI, simp add:alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1034
apply (frule_tac obj = obj' in co2sobj_closefd, simp add:alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1035
apply (clarsimp split:t_object.splits if_splits option.splits simp:tainted_eq_Tainted co2sobj.simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1036
apply (rule_tac x = obj in exI, simp add:alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1037
apply (frule_tac obj = obj in co2sobj_closefd, simp add:alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1038
apply (clarsimp split:t_object.splits if_splits option.splits simp:tainted_eq_Tainted co2sobj.simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1039
apply (rule impI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1040
apply (simp add:s2ss_def)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1041
apply (rule set_eqI, rule iffI, erule CollectE, erule exE, erule conjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1042
apply (simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1043
apply (case_tac "obj = O_proc p")
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1044
apply (rule disjI1, simp add:co2sobj.simps tainted_eq_Tainted split:if_splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1045
apply (rule disjI2, rule conjI, rule_tac x = obj in exI, simp add:alive_co2sobj_closefd')
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1046
apply (frule_tac obj = obj in co2sobj_closefd, simp add:alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1047
apply (clarsimp split:t_object.splits if_splits option.splits simp:tainted_eq_Tainted co2sobj.simps)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1048
apply (rule notI, erule_tac x = obj in allE, simp add:alive_co2sobj_closefd')
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1049
apply (frule_tac obj = obj in co2sobj_closefd, simp add:alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1050
apply (clarsimp split:t_object.splits if_splits option.splits)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1051
apply (simp)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1052
apply (erule disjE)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1053
apply (rule_tac x = "O_proc p" in exI, simp add:co2sobj.simps tainted_eq_Tainted)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1054
apply (erule exE|erule conjE)+
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1055
apply (rule_tac x = obj in exI)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1056
apply (frule_tac obj = obj in co2sobj_closefd, simp add:alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1057
apply (clarsimp split:t_object.splits if_splits option.splits 
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1058
                simp:tainted_eq_Tainted co2sobj.simps alive_co2sobj_closefd1)
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1059
done
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1060
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1061
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1062
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1063
41
db15ef2ee18c fixed bugs in co2sobj
chunhan
parents: 39
diff changeset
  1064
43
chunhan
parents: 42
diff changeset
  1065
lemmas s2ss_simps = s2ss_execve s2ss_clone s2ss_ptrace s2ss_kill s2ss_exit s2ss_open
47
0960686df575 bug in s2ss_del_sfile
chunhan
parents: 46
diff changeset
  1066
  s2ss_readfile s2ss_writefile s2ss_closefd
35
f2e620d799cf in the middle of building simpset for co2sobj, therefore we can deal with s2ss
chunhan
parents: 34
diff changeset
  1067