Dynamic_static.thy
author chunhan
Tue, 19 Nov 2013 12:31:56 +0800
changeset 67 811e3028d169
parent 66 5f86fb3ddd44
child 68 742bed613245
permissions -rw-r--r--
update grant_check
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
     1
theory Dynamic_static
051b0ee98852 restructured
chunhan
parents:
diff changeset
     2
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop S2ss_prop S2ss_prop2
65
chunhan
parents: 63
diff changeset
     3
 Temp
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
     4
begin
051b0ee98852 restructured
chunhan
parents:
diff changeset
     5
051b0ee98852 restructured
chunhan
parents:
diff changeset
     6
context tainting_s begin
051b0ee98852 restructured
chunhan
parents:
diff changeset
     7
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
     8
fun remove_create_flag :: "t_open_flags \<Rightarrow> t_open_flags"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
     9
where
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    10
  "remove_create_flag (mflag, oflags) = (mflag, oflags - {OF_CREAT})"
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
    11
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    12
fun all_procs :: "t_state \<Rightarrow> t_process set"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    13
where
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    14
  "all_procs [] = init_procs"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    15
| "all_procs (Clone p p' fds shms # s) = insert p' (all_procs s)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    16
| "all_procs (e # s) = all_procs s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    17
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    18
definition brandnew_proc :: "t_state \<Rightarrow> t_process"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    19
where
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    20
  "brandnew_proc s \<equiv> next_nat (all_procs s)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    21
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    22
(*
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    23
definition brandnew_proc :: "t_state \<Rightarrow> t_process"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    24
where
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    25
  "brandnew_proc s \<equiv> next_nat ({p | p s'. p \<in> current_procs s' \<and> s' \<preceq> s})"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    26
 another approach:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    27
  brandnew_proc = next_nat (all_procs s),
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    28
    where all_procs is a event-trace listener *)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    29
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    30
(*
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    31
lemma brandnew_proc_prop1:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    32
  "\<lbrakk>s' \<preceq> s; valid s\<rbrakk> \<Longrightarrow> brandnew_proc s \<notin> current_procs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    33
apply (frule vd_preceq, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    34
apply (simp add:brandnew_proc_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    35
apply (auto)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    36
sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    37
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    38
lemma brandnew_proc_prop2:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    39
  "\<lbrakk>p \<in> current_procs s'; s' \<preceq> s; valid s\<rbrakk> \<Longrightarrow> brandnew_proc s \<noteq> p"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    40
by (auto dest:brandnew_proc_prop1)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    41
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    42
lemma brandnew_proc_prop3:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    43
  "\<lbrakk>p \<in> current_procs s; valid (e # s)\<rbrakk> \<Longrightarrow> brandnew_proc (e # s) \<noteq> p"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    44
apply (rule brandnew_proc_prop2, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    45
apply (rule no_juniorI, simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    46
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    47
*)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    48
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    49
(* enrich s target_proc duplicated_pro *)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    50
fun enrich_proc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process \<Rightarrow> t_state"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    51
where 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    52
  "enrich_proc [] tp dp = []"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    53
| "enrich_proc (Execve p f fds # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    54
     if (tp = p) 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    55
     then Execve dp f fds # Execve p f fds # (enrich_proc s tp dp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    56
     else Execve p f fds # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    57
| "enrich_proc (Clone p p' fds shms # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    58
     if (tp = p') 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    59
     then Clone p dp fds shms # Clone p p' fds shms # s
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    60
     else Clone p dp fds shms # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    61
| "enrich_proc (Open p f flags fd opt # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    62
     if (tp = p)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    63
     then Open dp f (remove_create_flag flags) fd opt # Open p f flags fd opt # (enrich_proc s tp dp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    64
     else Open p f flags fd opt # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    65
| "enrich_proc (CloseFd p fd # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    66
     if (tp = p)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    67
     then CloseFd dp fd # CloseFd p fd # (enrich_proc s tp dp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    68
     else CloseFd p fd # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    69
| "enrich_proc (Attach p h flag # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    70
     if (tp = p)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    71
     then Attach dp h flag # Attach p h flag # (enrich_proc s tp dp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    72
     else Attach p h flag # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    73
| "enrich_proc (Detach p h # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    74
     if (tp = p) 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    75
     then Detach dp h # Detach p h # (enrich_proc s tp dp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    76
     else Detach p h # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    77
| "enrich_proc (Kill p p' # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    78
     if (tp = p) then Kill p p' # s
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    79
     else Kill p p' # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    80
| "enrich_proc (Exit p # s) tp dp = (
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    81
     if (tp = p) then Exit p # s
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    82
     else Exit p # (enrich_proc s tp dp))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    83
| "enrich_proc (e # s) tp dp = e # (enrich_proc s tp dp)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    84
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    85
definition is_created_proc:: "t_state \<Rightarrow> t_process \<Rightarrow> bool"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    86
where
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    87
  "is_created_proc s p \<equiv> p \<in> init_procs \<longrightarrow> deleted (O_proc p) s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
    88
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    89
lemma enrich_proc_aux1:
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    90
  assumes vs': "valid s'"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    91
    and os: "os_grant s e" and grant: "grant s e"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    92
    and alive: "\<forall> obj. alive s obj \<longrightarrow> alive s' obj"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    93
    and cp2sp: "\<forall> p. p \<in> current_procs s \<longrightarrow> cp2sproc s' p = cp2sproc s p"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    94
    and cf2sf: "\<forall> f. f \<in> current_files s \<longrightarrow> cf2sfile s' f = cf2sfile s f"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    95
  shows "valid (e # s')"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    96
proof (cases e)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    97
  case (Execve p f fds)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    98
  have p_in: "p \<in> current_procs s'" using os alive
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
    99
    apply (erule_tac x = "O_proc p" in allE)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   100
    by (auto simp:Execve)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   101
  have f_in: "is_file s' f" using os alive
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   102
    apply (erule_tac x = "O_file f" in allE)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   103
    by (auto simp:Execve)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   104
  have fd_in: "fds \<subseteq> current_proc_fds s' p" using os alive
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   105
    apply (auto simp:Execve)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   106
    by (erule_tac x = "O_fd p x" in allE, auto)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   107
  have "os_grant s' e" using p_in f_in fd_in by (simp add:Execve)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   108
  moreover have "grant s' e"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   109
  proof-
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   110
    from grant obtain up rp tp uf rf tf 
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   111
      where p1: "sectxt_of_obj s (O_proc p) = Some (up, rp, tp)"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   112
      and p2: "sectxt_of_obj s (O_file f) = Some (uf, rf, tf)" 
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   113
      by (simp add:Execve split:option.splits, blast)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   114
    with grant obtain pu nr nt where p3: "npctxt_execve (up, rp, tp) (uf, rf, tf) = Some (pu, nr, nt)"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   115
      by (simp add:Execve split:option.splits del:npctxt_execve.simps, blast)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   116
    from p1 have p1': "sectxt_of_obj s' (O_proc p) = Some (up, rp, tp)"
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   117
      using os cp2sp
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   118
      apply (erule_tac x = p in allE)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   119
      by (auto simp:Execve co2sobj.simps cp2sproc_def split:option.splits)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   120
    from p2 have p2': "sectxt_of_obj s' (O_file f) = Some (uf, rf, tf)" 
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   121
      using os cf2sf
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   122
      apply (erule_tac x = "f" in allE)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   123
      apply (auto simp:Execve dest:is_file_in_current)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   124
      thm cf2sfile_def
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   125
      apply (auto simp:cf2sfile_def split:option.splits)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   126
      apply (auto simp:Execve co2sobj.simps cf2sfile_simps split:option.splits)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   127
      apply (simp add:cf2sfiles_def)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   128
      apply (auto)[1]
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   129
      using os pre
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   130
  show ?thesis
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   131
  proof-
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   132
    have
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   133
    
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   134
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   135
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   136
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   137
lemma enrich_proc_prop:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   138
  "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   139
   \<Longrightarrow> valid (enrich_proc s p p') \<and> 
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   140
       (p \<in> current_procs s \<longrightarrow> co2sobj (enrich_proc s p p') (O_proc p') = co2sobj (enrich_proc s p p') (O_proc p)) \<and>
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   141
       (\<forall> obj. alive s obj \<longrightarrow> alive (enrich_proc s p p')  obj \<and> co2sobj (enrich_proc s p p') obj = co2sobj s obj)"
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   142
proof (induct s)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   143
  case Nil
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   144
  thus ?case by (auto simp:is_created_proc_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   145
next
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   146
  case (Cons e s)
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   147
  hence p1: "\<lbrakk>valid s; is_created_proc s p; p' \<notin> all_procs s\<rbrakk>
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   148
  \<Longrightarrow> valid (enrich_proc s p p') \<and>
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   149
     (p \<in> current_procs s \<longrightarrow> co2sobj (enrich_proc s p p') (O_proc p') = co2sobj (enrich_proc s p p') (O_proc p)) \<and>
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   150
     (alive s obj \<longrightarrow> alive (enrich_proc s p p') obj \<and> co2sobj (enrich_proc s p p') obj = co2sobj s obj)"
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   151
    and p2: "valid (e # s)" and p3: "is_created_proc (e # s) p" and p4: "p' \<notin> all_procs (e # s)"
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   152
    by auto
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   153
  from p2 have vd: "valid s" and os: "os_grant s e" and grant: "grant s e"
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   154
    by (auto dest:vd_cons vt_grant vt_grant_os)
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   155
  from p4 have p4': "p' \<notin> all_procs s" by (case_tac e, auto)
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   156
  from p1 p4' have a1: "is_created_proc s p \<Longrightarrow> valid (enrich_proc s p p')" by (auto simp:vd)
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   157
  have c1: "valid (enrich_proc (e # s) p p')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   158
    apply (case_tac e)
67
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   159
    using a1 os p3
811e3028d169 update grant_check
chunhan
parents: 66
diff changeset
   160
    apply (auto simp:is_created_proc_def)
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   161
    sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   162
  moreover have c2: "p' \<in> current_procs (enrich_proc (e # s) p p')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   163
    sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   164
  moreover have c3: "co2sobj (enrich_proc (e # s) p p') (O_proc p') = co2sobj (enrich_proc (e # s) p p') (O_proc p)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   165
    sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   166
  moreover have c4: "alive (e # s) obj \<longrightarrow>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   167
     alive (enrich_proc (e # s) p p') obj \<and> co2sobj (enrich_proc (e # s) p p') obj = co2sobj (e # s) obj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   168
    sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   169
  ultimately show ?case by auto
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   170
qed
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   171
051b0ee98852 restructured
chunhan
parents:
diff changeset
   172
051b0ee98852 restructured
chunhan
parents:
diff changeset
   173
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   174
lemma "alive s obj \<Longrightarrow> alive (enrich_proc s p p') obj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   175
apply (induct s, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   176
apply (case_tac a, case_tac[!] obj)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   177
apply (auto simp:is_file_def is_dir_def split:option.splits t_inode_tag.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   178
thm is_file_other
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   179
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   180
lemma enrich_proc_valid:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   181
  "\<lbrakk>p \<in> current_procs s; valid s; p \<in> init_procs \<longrightarrow> deleted (O_proc p) s; p' \<notin> current_procs s\<rbrakk> \<Longrightarrow> valid (enrich_proc s p p')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   182
apply (induct s, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   183
apply (frule vd_cons, frule vt_grant, frule vt_grant_os, case_tac a)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   184
apply (auto intro!:valid.intros(2))
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   185
prefer 28
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   186
       
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   187
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   188
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   189
end
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   190
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   191
(* for any created obj, we can enrich trace with events that create new objs with the same static-properties *)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   192
definition enriched:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   193
where
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   194
  "enriched s objs s' \<equiv> \<forall> obj \<in> objs. \<exists> obj'. \<not> alive s obj' \<and> obj' \<notin> objs \<and>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   195
                                                alive s' obj' \<and> co2sobj s' obj' = co2sobj s' obj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   196
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   197
definition reserved:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   198
where
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   199
  "reserved s objs s' \<equiv> \<forall> obj. alive s obj \<longrightarrow> alive s' obj \<and> co2sobj s' obj = co2sobj s obj"
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   200
051b0ee98852 restructured
chunhan
parents:
diff changeset
   201
definition enrichable :: "t_state \<Rightarrow> t_object set \<Rightarrow> bool"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   202
where
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   203
  "enrichable s objs \<equiv> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enriched s objs s' \<and> reserved s objs s'"
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   204
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   205
fun is_created :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   206
where
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   207
  "is_created s (O_file f) = (\<forall> f' \<in> same_inode_files s f. init_alive (O_file f') \<longrightarrow> deleted (O_file f') s)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   208
| "is_created s obj        = (init_alive obj \<longrightarrow> deleted obj s)"
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   209
051b0ee98852 restructured
chunhan
parents:
diff changeset
   210
definition is_inited :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   211
where
051b0ee98852 restructured
chunhan
parents:
diff changeset
   212
  "is_inited s obj \<equiv> init_alive obj \<and> \<not> deleted obj s"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   213
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   214
(*
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   215
lemma is_inited_eq_not_created:
051b0ee98852 restructured
chunhan
parents:
diff changeset
   216
  "is_inited s obj = (\<not> is_created s obj)"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   217
by (auto simp:is_created_def is_inited_def)
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   218
*)
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   219
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   220
lemma many_sq_imp_sms:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   221
  "\<lbrakk>S_msgq (Create, sec, sms) \<in> ss; ss \<in> static\<rbrakk> \<Longrightarrow> \<forall> sm \<in> (set sms). is_many_smsg sm"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   222
sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   223
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   224
(* recorded in our static world *)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   225
fun recorded :: "t_object \<Rightarrow> bool"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   226
where
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   227
  "recorded (O_proc p)     = True"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   228
| "recorded (O_file f)     = True"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   229
| "recorded (O_dir  f)     = True"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   230
| "recorded (O_node n)     = False" (* cause socket is temperary not considered *)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   231
| "recorded (O_shm  h)     = True"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   232
| "recorded (O_msgq q)     = True"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   233
| "recorded _              = False"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   234
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   235
lemma cf2sfile_fi_init_file:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   236
  "\<lbrakk>cf2sfile s f = Some (Init f', sec, psec, asecs); is_file s f; valid s\<rbrakk> 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   237
   \<Longrightarrow> is_init_file f \<and> \<not> deleted (O_file f) s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   238
apply (simp add:cf2sfile_def sroot_def split:option.splits if_splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   239
apply (case_tac f, simp, drule root_is_dir', simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   240
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   241
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   242
lemma root_not_deleted:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   243
  "valid s \<Longrightarrow> \<not> deleted (O_dir []) s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   244
apply (induct s, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   245
apply (frule vd_cons, frule vt_grant_os, case_tac a)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   246
by auto
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   247
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   248
lemma cf2sfile_fi_init_dir:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   249
  "\<lbrakk>cf2sfile s f = Some (Init f', sec, psec, asecs); is_dir s f; valid s\<rbrakk> 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   250
   \<Longrightarrow> is_init_dir f \<and> \<not> deleted (O_dir f) s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   251
apply (simp add:cf2sfile_def sroot_def split:option.splits if_splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   252
apply (case_tac f, simp add:root_is_init_dir root_not_deleted, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   253
apply (drule file_dir_conflict, simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   254
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   255
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   256
lemma is_created_imp_many: 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   257
  "\<lbrakk>is_created s obj; co2sobj s obj = Some sobj; alive s obj; valid s\<rbrakk> \<Longrightarrow> is_many sobj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   258
apply (case_tac obj, auto simp:co2sobj.simps split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   259
apply (case_tac [!] a)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   260
apply (auto simp:cp2sproc_def ch2sshm_def cq2smsgq_def cf2sfiles_def same_inode_files_def
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   261
  split:option.splits if_splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   262
apply (frule cf2sfile_fi_init_file, simp add:is_file_def, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   263
apply (erule_tac x = f' in allE, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   264
apply (frule cf2sfile_fi_init_dir, simp+)+
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   265
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   266
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   267
lemma anotherp_imp_manysp: 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   268
  "\<lbrakk>cp2sproc s p = Some sp; co2sobj s (O_proc p') = co2sobj s (O_proc p); p' \<noteq> p;
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   269
    p' \<in> current_procs s; p \<in> current_procs s\<rbrakk> 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   270
   \<Longrightarrow> is_many_sproc sp"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   271
by (case_tac sp, auto simp:cp2sproc_def co2sobj.simps split:option.splits if_splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   272
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   273
lemma is_file_has_sfs:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   274
  "\<lbrakk>is_file s f; valid s; cf2sfile s f = Some sf\<rbrakk> 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   275
   \<Longrightarrow> \<exists> sfs. co2sobj s (O_file f) = Some (S_file sfs (O_file f \<in> Tainted s)) \<and> sf \<in> sfs"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   276
apply (rule_tac x = "{sf' | f' sf'. cf2sfile s f' = Some sf' \<and> f' \<in> same_inode_files s f}" in exI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   277
apply (auto simp:co2sobj.simps cf2sfiles_def tainted_eq_Tainted)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   278
apply (rule_tac x = f in exI, simp add:same_inode_files_prop9)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   279
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   280
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   281
declare Product_Type.split_paired_Ex Product_Type.split_paired_All [simp del]
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   282
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   283
lemma current_proc_in_s2ss:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   284
  "\<lbrakk>cp2sproc s p = Some sp; p \<in> current_procs s; valid s\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   285
   \<Longrightarrow> S_proc sp (O_proc p \<in> Tainted s) \<in> s2ss s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   286
apply (simp add:s2ss_def, rule_tac x = "O_proc p" in exI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   287
apply (auto simp:co2sobj.simps tainted_eq_Tainted)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   288
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   289
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   290
lemma current_file_in_s2ss:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   291
  "\<lbrakk>co2sobj s (O_file f) = Some (S_file sfs tagf); is_file s f; valid s\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   292
   \<Longrightarrow> S_file sfs tagf \<in> s2ss s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   293
by (simp add:s2ss_def, rule_tac x = "O_file f" in exI, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   294
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   295
declare npctxt_execve.simps grant_execve.simps search_check.simps [simp del]
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   296
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   297
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   298
lemma npctxt_execve_eq_sec:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   299
  "\<lbrakk>sectxt_of_obj (Execve p f fds # s) (O_proc p) = Some sec'; sectxt_of_obj s (O_proc p) = Some sec;
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   300
    sectxt_of_obj s (O_file f) = Some fsec; valid (Execve p f fds # s)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   301
   \<Longrightarrow> npctxt_execve sec fsec = Some sec'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   302
by (case_tac sec, case_tac fsec, auto simp:npctxt_execve.simps sectxt_of_obj_simps split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   303
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   304
lemma npctxt_execve_eq_cp2sproc:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   305
  "\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   306
    cp2sproc s p = Some (pi, sec, sfds, shms); cf2sfile s f = Some (fi, fsec, psec, asecs)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   307
   \<Longrightarrow> npctxt_execve sec fsec = Some sec'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   308
apply (frule vt_grant_os, frule vd_cons)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   309
apply (rule npctxt_execve_eq_sec, auto simp:cp2sproc_def cf2sfile_def split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   310
apply (case_tac f, auto dest:root_is_dir')
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   311
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   312
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   313
lemma seach_check_eq_static:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   314
  "\<lbrakk>cf2sfile s f = Some sf; valid s; is_dir s f \<or> is_file s f\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   315
   \<Longrightarrow> search_check_s sec sf (is_file s f) = search_check s sec f"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   316
apply (case_tac sf)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   317
apply (induct f)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   318
apply (auto simp:search_check_s_def search_check.simps cf2sfile_def sroot_def 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   319
                 root_sec_remains init_sectxt_prop sec_of_root_valid
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   320
           dest!:root_is_dir' current_has_sec' split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   321
apply (simp add:search_check_allp_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   322
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   323
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   324
lemma grant_execve_intro_execve:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   325
  "\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   326
     cp2sproc s p = Some (pi, sec, sfds, shms); cf2sfile s f = Some (fi, fsec, psec, asecs)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   327
    \<Longrightarrow> grant_execve sec fsec sec'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   328
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   329
apply (auto split:option.splits dest!:current_has_sec' simp del:grant_execve.simps simp add:cp2sproc_execve)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   330
apply (erule_tac x = aba in allE, erule_tac x = aca in allE, erule_tac x = bb in allE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   331
apply (auto simp del:grant_execve.simps simp add:cp2sproc_def cf2sfile_def split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   332
apply (case_tac f, simp, drule root_is_dir', simp, simp, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   333
apply (simp add:sectxt_of_obj_simps)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   334
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   335
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   336
lemma search_check_intro_execve:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   337
  "\<lbrakk>cp2sproc s p = Some (pi, sec, sfds, shms); valid (Execve p f fds # s)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   338
   \<Longrightarrow> search_check s sec f"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   339
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   340
apply (auto split:option.splits dest!:current_has_sec' simp del:grant_execve.simps simp add:cp2sproc_execve)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   341
apply (erule_tac x = aaa in allE, erule_tac x = ab in allE, erule_tac x = ba in allE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   342
apply (auto simp add:cp2sproc_def cf2sfile_def split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   343
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   344
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   345
lemma inherit_fds_check_intro_execve:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   346
  "\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   347
    \<Longrightarrow> inherit_fds_check s sec' p fds"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   348
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   349
apply (auto split:option.splits dest!:current_has_sec' simp add:cp2sproc_execve)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   350
apply (erule_tac x = aba in allE, erule_tac x = aca in allE, erule_tac x = bb in allE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   351
apply (auto simp add:cp2sproc_def cf2sfile_def split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   352
apply (simp add:sectxt_of_obj_simps)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   353
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   354
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   355
lemma execve_sfds_subset: 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   356
  "\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   357
    cp2sproc s p = Some (pi, sec, sfds, shms)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   358
   \<Longrightarrow> sfds' \<subseteq> sfds"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   359
apply (frule vt_grant_os)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   360
apply (auto simp:cp2sproc_def cpfd2sfds_execve split:option.splits dest!:current_has_sec')
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   361
apply (simp add:cpfd2sfds_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   362
apply (rule_tac x = fd in bexI, auto simp:proc_file_fds_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   363
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   364
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   365
lemma inherit_fds_check_imp_static:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   366
  "\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms');
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   367
    inherit_fds_check s sec' p fds; valid (Execve p f fds # s)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   368
   \<Longrightarrow> inherit_fds_check_s sec' sfds'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   369
apply (frule vt_grant_os, frule vd_cons, frule vt_grant)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   370
apply (auto simp:cp2sproc_def cpfd2sfds_execve inherit_fds_check_def inherit_fds_check_s_def split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   371
apply (erule_tac x = "(ad, ae, bc)" in ballE, auto simp:sectxts_of_sfds_def sectxts_of_fds_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   372
apply (erule_tac x = fd in ballE, auto simp:cfd2sfd_def split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   373
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   374
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   375
lemma d2s_main_execve_grant_aux:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   376
  "\<lbrakk>cp2sproc (Execve p f fds # s) p = Some (pi', sec', sfds', shms'); valid (Execve p f fds # s);
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   377
    cp2sproc s p = Some (pi, sec, sfds, shms); cf2sfile s f = Some (fi, fsec, psec, asecs)\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   378
   \<Longrightarrow> (npctxt_execve sec fsec = Some sec') \<and> grant_execve sec fsec sec' \<and> 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   379
       search_check_s sec (fi, fsec, psec, asecs) (is_file s f) \<and> 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   380
       inherit_fds_check_s sec' sfds' \<and> sfds' \<subseteq> sfds"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   381
apply (rule conjI, erule_tac pi = pi and sec = sec and sfds = sfds and 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   382
   shms = shms and fi = fi and fsec = fsec and psec = psec and 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   383
   asecs = asecs in npctxt_execve_eq_cp2sproc, simp, simp, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   384
apply (rule conjI, erule_tac pi = pi and sec = sec and sfds = sfds and 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   385
   shms = shms and fi = fi and fsec = fsec and psec = psec and 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   386
   asecs = asecs in grant_execve_intro_execve, simp, simp, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   387
apply (rule conjI, drule_tac sec = sec in search_check_intro_execve, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   388
apply (frule vd_cons, frule vt_grant_os)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   389
apply (drule_tac sec = sec in seach_check_eq_static, simp, simp, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   390
apply (rule conjI, rule inherit_fds_check_imp_static, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   391
apply (erule inherit_fds_check_intro_execve, simp, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   392
apply (erule_tac pi = pi and sfds = sfds and shms = shms in execve_sfds_subset, simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   393
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   394
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   395
lemma d2s_main_execve:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   396
  "\<lbrakk>valid (Execve p f fds # s); s2ss s \<propto> static\<rbrakk> \<Longrightarrow> s2ss (Execve p f fds # s) \<propto> static"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   397
apply (frule vd_cons, frule vt_grant_os, clarsimp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   398
apply (frule is_file_has_sfile', simp, erule exE, frule is_file_has_sfs, simp+, erule exE, erule conjE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   399
apply (auto simp:s2ss_execve split:if_splits option.splits dest:current_proc_has_sp')
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   400
apply (clarsimp simp add:init_ss_in_def init_ss_eq_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   401
apply (rule_tac x = "update_ss ss' (S_proc (ah, (ai, aj, bd), ak, be) (O_proc p \<in> Tainted s))
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   402
  (S_proc (ad, (ae, af, bb), ag, bc) (O_proc p \<in> Tainted s \<or> O_file f \<in> Tainted s))" in bexI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   403
apply (auto simp:update_ss_def elim:Set.subset_insertI2 simp:anotherp_imp_manysp)[1]
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   404
apply (case_tac "ah = ad", case_tac "bc = {}", simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   405
apply (erule_tac sfs = sfs and fi = a and fsec = "(aa, ab,b)" and pfsec = ac and asecs = ba in s_execve,
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   406
  auto intro:current_proc_in_s2ss current_file_in_s2ss split:option.splits dest:d2s_main_execve_grant_aux)[1]
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   407
apply (simp add:cp2sproc_execve split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   408
apply (simp add:cp2sproc_def split:option.splits if_splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   409
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   410
apply (clarsimp simp add:init_ss_in_def init_ss_eq_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   411
apply (rule_tac x = "update_ss ss' (S_proc (ah, (ai, aj, bd), ak, be) (O_proc p \<in> Tainted s))
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   412
  (S_proc (ad, (ae, af, bb), ag, bc) (O_proc p \<in> Tainted s \<or> O_file f \<in> Tainted s))" in bexI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   413
apply (rule conjI, simp add:update_ss_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   414
apply (rule conjI, simp add:update_ss_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   415
apply (auto)[1]
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   416
apply (simp add:update_ss_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   417
apply (rule conjI, rule impI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   418
apply (rule subsetI, clarsimp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   419
apply (erule impE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   420
apply (erule set_mp, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   421
apply (case_tac ah, simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   422
apply (rule impI, rule subsetI, clarsimp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   423
apply (erule set_mp, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   424
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   425
apply (case_tac "ah = ad", case_tac "bc = {}", simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   426
apply (erule_tac sfs = sfs and fi = a and fsec = "(aa, ab,b)" and pfsec = ac and asecs = ba in s_execve,
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   427
  auto intro:current_proc_in_s2ss current_file_in_s2ss split:option.splits dest:d2s_main_execve_grant_aux)[1]
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   428
apply (simp add:cp2sproc_execve split:option.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   429
apply (simp add:cp2sproc_def split:option.splits if_splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   430
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   431
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   432
lemma co2sobj_eq_alive_proc_imp:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   433
  "\<lbrakk>co2sobj s obj = co2sobj s (O_proc p); alive s (O_proc p); valid s\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   434
   \<Longrightarrow> \<exists> p'. obj = O_proc p'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   435
by (auto simp add:co2sobj.simps split:option.splits dest:current_proc_has_sp' intro:co2sobj_sproc_imp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   436
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   437
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   438
lemma enrichable_execve:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   439
 assumes p1: "\<And> objs. \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   440
              \<Longrightarrow> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enriched s objs s' \<and> reserved s objs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   441
  and p2: "valid (e # s)" and p3: "\<forall>obj\<in>objs. alive (e # s) obj \<and> is_created (e # s) obj \<and> recorded obj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   442
  and p4: "e = Execve p f fds" 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   443
  shows "enrichable (e # s) objs"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   444
proof-
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   445
  from p2 have os: "os_grant s e" and se: "grant s e" and vd: "valid s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   446
    by (auto dest:vt_grant_os vd_cons vt_grant)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   447
  from p3 have recorded: "\<forall> obj \<in> objs. recorded obj" by auto
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   448
  from p3 p4 p2 have p1': "\<forall> obj \<in> objs. alive s obj \<and> is_created s obj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   449
    apply clarify
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   450
    apply (erule_tac x = obj in ballE, simp add:alive_simps)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   451
    apply (case_tac obj, auto simp:same_inode_files_simps)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   452
    done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   453
  then obtain s' where a1: "valid s'" and a2: "s2ss s' = s2ss s" and a3: "enriched s objs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   454
    and a4: "reserved s objs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   455
    using p1 recorded by metis 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   456
  show ?thesis
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   457
  proof (cases "O_proc p \<in> objs")
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   458
    case True
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   459
    hence p_in: "p \<in> current_procs s'" using a4 os p4
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   460
      by (auto simp:reserved_def elim:allE[where x = "O_proc p"])
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   461
    with a1 a3 True obtain p' where b1: "\<not> alive s (O_proc p')" and b2: "O_proc p' \<notin> objs" 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   462
      and b3: "alive s' (O_proc p')" and b4: "co2sobj s' (O_proc p') = co2sobj s' (O_proc p)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   463
      apply (simp only:enriched_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   464
      apply (erule_tac x = "O_proc p" in ballE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   465
      apply (erule exE|erule conjE)+
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   466
      apply (frule co2sobj_eq_alive_proc_imp, auto)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   467
      done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   468
    have "valid (Execve p' f fds # e # s')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   469
      sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   470
    moreover have "s2ss (Execve p' f fds # e # s') = s2ss (e # s)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   471
      sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   472
    moreover have "enriched (e # s) objs (Execve p' f fds # e # s')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   473
      sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   474
    moreover have "reserved (e # s) objs (Execve p' f fds # e # s')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   475
      sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   476
    ultimately show ?thesis
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   477
      apply (simp add:enrichable_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   478
      apply (rule_tac x = "Execve p' f fds # e # s'" in exI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   479
      by auto
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   480
  next
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   481
    case False
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   482
    from a4 os p4 have "p \<in> current_procs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   483
      apply (simp add:reserved_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   484
      by (erule_tac x = "O_proc p" in allE, auto)      
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   485
    moreover from a4 os p4 have "is_file s' f"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   486
      apply (simp add:reserved_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   487
      by (erule_tac x = "O_file f" in allE, auto)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   488
    moreover from a4 os p4 have "fds \<subseteq> current_proc_fds s' p"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   489
      apply (rule_tac subsetI, clarsimp simp:reserved_def current_proc_fds.simps)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   490
      apply (erule_tac x = "O_fd p x" in allE, erule impE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   491
      apply (simp, erule set_mp, simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   492
      done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   493
    ultimately have "os_grant s' e" 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   494
      by (simp add:p4)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   495
    moreover have "grant s' e"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   496
      sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   497
    ultimately have "valid (e # s')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   498
      using a1 by (erule_tac valid.intros(2), simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   499
    thus ?thesis
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   500
      apply (simp add:enrichable_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   501
      apply (rule_tac x = "e # s'" in exI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   502
      apply (simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   503
    sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   504
qed
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   505
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   506
lemma s2d_main_execve:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   507
  "\<lbrakk>grant_execve pctxt fsec pctxt'; ss \<in> static; S_proc (pi, pctxt, fds, shms) tagp \<in> ss; S_file sfs tagf \<in> ss;
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   508
     (fi, fsec, pfsec, asecs) \<in> sfs; npctxt_execve pctxt fsec = Some pctxt'; 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   509
    search_check_s pctxt (fi, fsec, pfsec, asecs) True; inherit_fds_check_s pctxt' fds'; fds' \<subseteq> fds; valid s;
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   510
    s2ss s = ss\<rbrakk> \<Longrightarrow> \<exists>s. valid s \<and> 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   511
    s2ss s = update_ss ss (S_proc (pi, pctxt, fds, shms) tagp) (S_proc (pi, pctxt', fds', {}) (tagp \<or> tagf))"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   512
apply (simp add:update_ss_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   513
thm update_ss_def
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   514
sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   515
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   516
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   517
lemma s2d_main_execve:
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   518
  "ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   519
apply (erule static.induct)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   520
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   521
apply (erule exE|erule conjE)+
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   522
apply (rule s2d_main_execve, simp+)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   523
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   524
apply (erule exE|erule conjE)+
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   525
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   526
apply (simp add:update_ss_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   527
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   528
sorry
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   529
051b0ee98852 restructured
chunhan
parents:
diff changeset
   530
051b0ee98852 restructured
chunhan
parents:
diff changeset
   531
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   532
(*********************** uppest-level 3 theorems ***********************)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   533
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   534
lemma enrichability: 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   535
  "\<lbrakk>valid s; \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj\<rbrakk>
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   536
   \<Longrightarrow> enrichable s objs"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   537
proof (induct s arbitrary:objs)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   538
  case Nil
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   539
  hence "objs = {}" 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   540
    apply (auto simp:is_created_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   541
    apply (erule_tac x = x in ballE)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   542
    apply (auto simp:init_alive_prop)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   543
    done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   544
  thus ?case using Nil unfolding enrichable_def enriched_def reserved_def
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   545
    by (rule_tac x = "[]" in exI, auto)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   546
next
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   547
  case (Cons e s)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   548
  hence p1: "\<And> objs. \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   549
             \<Longrightarrow> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enriched s objs s' \<and> reserved s objs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   550
    and p2: "valid (e # s)" and p3: "\<forall>obj\<in>objs. alive (e # s) obj \<and> is_created (e # s) obj \<and> recorded obj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   551
    and os: "os_grant s e" and se: "grant s e" and vd: "valid s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   552
    by (auto dest:vt_grant_os vd_cons vt_grant simp:enrichable_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   553
  show ?case 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   554
  proof (cases e)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   555
    case (Execve p f fds) 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   556
    hence p4: "e = Execve p f fds" by simp
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   557
    from p3 have p5: "is_inited s (O_proc p) \<Longrightarrow> (O_proc p) \<notin> objs" 
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   558
      by (auto simp:is_created_def is_inited_def p4 elim!:ballE[where x = "O_proc p"])
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   559
    show "enrichable (e # s) objs"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   560
    proof (cases "is_inited s (O_proc p)")
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   561
      case True
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   562
      with p5 have a1: "(O_proc p) \<notin> objs" by simp
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   563
      with p3 p4 p2 have a2: "\<forall> obj \<in> objs. alive s obj \<and> is_created s obj" and a2': "\<forall> obj \<in> objs. recorded obj"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   564
        apply (auto simp:is_created_def alive_simps is_inited_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   565
        apply (erule_tac x = obj in ballE, auto simp:alive_simps split:t_object.splits)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   566
        done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   567
      then obtain s' where a3: "valid s'" and a4: "s2ss s' = s2ss s"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   568
        and a5: "enriched s objs s'" and a6: "reserved s objs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   569
        using p1 apply (simp add:enrichable_def) sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   570
      from a5 p4 p2 a2' have a7: "enriched s objs (e # s')"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   571
        apply (clarsimp simp add:enriched_def co2sobj_execve)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   572
        apply (erule_tac x = obj in ballE, clarsimp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   573
        apply (rule_tac x = obj' in exI, auto simp:co2sobj_execve alive_simps)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   574
        thm enriched_def
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   575
051b0ee98852 restructured
chunhan
parents:
diff changeset
   576
66
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   577
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   578
obtain s' where p6:"enriched s objs s'"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   579
        apply (simp add: alive_simps enrichable_def)       
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   580
        apply auto apply (rule ballI, rule_tac x = obj in exI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   581
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   582
        have p6:"enriched (e # s) objs (e # s)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   583
        apply (simp add:enriched_def alive_simps)       
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   584
        apply auto apply (rule ballI, rule_tac x = obj in exI)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   585
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   586
      have "enrich (e # s) objs (e # s)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   587
        apply (simp add:enrich_def p4)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   588
        sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   589
      moreover have "reserve (e # s) objs (e # s)"
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   590
        sorry
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   591
      ultimately show ?thesis using p2
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   592
        apply (simp add:enrichable_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   593
        by (rule_tac x = "e # s" in exI, simp)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   594
    next
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   595
        
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   596
      
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   597
thm enrichable_def
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   598
      apply (simp add:enrichable_def p4)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   599
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   600
      
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   601
  
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   602
    apply auto
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   603
    apply (auto simp:enrichable_def)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   604
apply (induct s)
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   605
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   606
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   607
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   608
done
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   609
5f86fb3ddd44 enrich_proc
chunhan
parents: 65
diff changeset
   610
qed
63
051b0ee98852 restructured
chunhan
parents:
diff changeset
   611
051b0ee98852 restructured
chunhan
parents:
diff changeset
   612
lemma d2s_main:
051b0ee98852 restructured
chunhan
parents:
diff changeset
   613
  "valid s \<Longrightarrow> s2ss s \<propto> static"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   614
apply (induct s, simp add:s2ss_nil_prop init_ss_in_def)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   615
apply (rule_tac x = "init_static_state" in bexI, simp, simp add:s_init)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   616
apply (frule vd_cons, frule vt_grant_os, simp)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   617
apply (case_tac a) 
051b0ee98852 restructured
chunhan
parents:
diff changeset
   618
apply (clarsimp simp add:s2ss_execve)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   619
apply (rule conjI, rule impI)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   620
051b0ee98852 restructured
chunhan
parents:
diff changeset
   621
051b0ee98852 restructured
chunhan
parents:
diff changeset
   622
051b0ee98852 restructured
chunhan
parents:
diff changeset
   623
sorry
051b0ee98852 restructured
chunhan
parents:
diff changeset
   624
051b0ee98852 restructured
chunhan
parents:
diff changeset
   625
lemma s2d_main:
051b0ee98852 restructured
chunhan
parents:
diff changeset
   626
  "ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
051b0ee98852 restructured
chunhan
parents:
diff changeset
   627
apply (erule static.induct)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   628
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   629
051b0ee98852 restructured
chunhan
parents:
diff changeset
   630
apply (erule exE|erule conjE)+
051b0ee98852 restructured
chunhan
parents:
diff changeset
   631
051b0ee98852 restructured
chunhan
parents:
diff changeset
   632
apply (simp add:update_ss_def)
051b0ee98852 restructured
chunhan
parents:
diff changeset
   633
051b0ee98852 restructured
chunhan
parents:
diff changeset
   634
sorry
051b0ee98852 restructured
chunhan
parents:
diff changeset
   635
051b0ee98852 restructured
chunhan
parents:
diff changeset
   636
051b0ee98852 restructured
chunhan
parents:
diff changeset
   637
end
051b0ee98852 restructured
chunhan
parents:
diff changeset
   638
051b0ee98852 restructured
chunhan
parents:
diff changeset
   639
end