Dynamic2static.thy
author chunhan
Wed, 04 Sep 2013 15:13:54 +0800
changeset 41 db15ef2ee18c
parent 32 705e1e41faf7
child 43 137358bd4921
permissions -rw-r--r--
fixed bugs in co2sobj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
theory Dynamic2static
32
705e1e41faf7 add event-trace simpset for s2ss
chunhan
parents: 31
diff changeset
     2
imports Main Flask Static Init_prop Valid_prop Tainted_prop Delete_prop Co2sobj_prop
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     3
begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     4
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     5
context tainting_s begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     6
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     7
lemma d2s_main:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
  "valid s \<Longrightarrow> s2ss s \<in> static"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     9
apply (induct s, simp add:s2ss_nil_prop s_init)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
apply (frule vd_cons, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    11
apply (case_tac a, simp_all) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    12
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    13
apply 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    14
induct s, case tac e, every event analysis
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    15
*)
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 21
diff changeset
    16
thm s2ss_def
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 21
diff changeset
    17
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 21
diff changeset
    18
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    19
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    20
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    21
lemma d2s_main':
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    22
  "\<lbrakk>alive s obj; co2sobj s obj= Some sobj\<rbrakk> \<Longrightarrow> sobj \<in> (s2ss s)"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    23
by (simp add:s2ss_def, rule_tac x = obj in exI, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    24
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    25
lemma alive_has_sobj:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    26
  "\<lbrakk>alive s obj; valid s\<rbrakk> \<Longrightarrow> \<exists> sobj. co2sobj s obj = Some sobj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    27
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    28
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    29
lemma t2ts:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    30
  "obj \<in> tainted s \<Longrightarrow> co2sobj s obj = Some sobj \<Longrightarrow> tainted_s (s2ss s) sobj"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    31
apply (frule tainted_in_current, frule tainted_is_valid)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    32
apply (simp add:s2ss_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    33
apply (case_tac sobj, simp_all)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    34
apply (case_tac [!] obj, simp_all split:option.splits if_splits)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    35
apply (rule_tac x = "O_proc nat" in exI, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    36
apply (rule_tac x = "O_file list" in exI, simp)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    37
apply (drule dir_not_tainted, simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    38
apply (drule msgq_not_tainted, simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    39
apply (drule shm_not_tainted, simp)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    40
apply (case_tac prod1, simp, case_tac prod2, clarsimp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    41
apply (rule conjI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    42
apply (rule_tac x = "O_msgq nat1" in exI, simp)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    43
apply (rule conjI) defer
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    44
apply (simp add:cm2smsg_def split:option.splits) 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    45
sorry
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    46
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
lemma delq_imp_delqm:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
  "deleted (O_msgq q) s \<Longrightarrow> deleted (O_msg q m) s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
apply (induct s, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    50
by (case_tac a, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
theorem static_complete: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
  assumes undel: "undeletable obj" and tbl: "taintable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
  shows "taintable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    55
proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
  from tbl obtain s where tainted: "obj \<in> tainted s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
    by (auto simp:taintable_def)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    58
  hence vs: "valid s" by (simp add:tainted_is_valid)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
  hence static: "s2ss s \<in> static" using d2s_main by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
  from tainted have alive: "alive s obj" 
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    61
    using tainted_in_current by auto
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    62
  then obtain sobj where sobj: "co2sobj s obj = Some sobj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    63
    using vs alive_has_sobj by blast
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    64
  from undel vs have "\<not> deleted obj s" and init_alive: "init_alive obj" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    65
    by (auto simp:undeletable_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    66
  with vs sobj have "init_obj_related sobj obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    67
    apply (case_tac obj, case_tac [!] sobj)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    68
    apply (auto split:option.splits if_splits simp:cp2sproc_def ch2sshm_def cq2smsgq_def cm2smsg_def delq_imp_delqm)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    69
    apply (frule not_deleted_init_file, simp+) (*
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    70
apply (drule is_file_has_sfile, erule exE)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    71
    apply (rule_tac x = sf in bexI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    72
    apply (case_tac list, auto split:option.splits simp:is_init_file_props)[1]
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    73
    apply (simp add:same_inode_files_def cfs2sfiles_def) *)  
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    74
    sorry
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    75
  with tainted t2ts init_alive sobj static
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    76
  show ?thesis unfolding taintable_s_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    77
    apply (rule_tac x = "s2ss s" in bexI, simp)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
    apply (rule_tac x = "sobj" in exI, auto)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    79
    done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    80
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    81
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    82
lemma cp2sproc_pi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    83
  "\<lbrakk>cp2sproc s p = Some (Init p', sec, fds, shms); valid s\<rbrakk> \<Longrightarrow> p = p' \<and> \<not> deleted (O_proc p) s \<and> p \<in> init_procs"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    84
by (simp add:cp2sproc_def split:option.splits if_splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    85
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    86
lemma cq2smsgq_qi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    87
  "\<lbrakk>cq2smsgq s q = Some (Init q', sec, sms); valid s\<rbrakk> \<Longrightarrow> q = q' \<and> \<not> deleted (O_msgq q) s \<and> q \<in> init_msgqs"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    88
by (simp add:cq2smsgq_def split:option.splits if_splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    89
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    90
lemma cm2smsg_mi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    91
  "\<lbrakk>cm2smsg s q m = Some (Init m', sec, ttag); q \<in> init_msgqs; valid s\<rbrakk> 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    92
   \<Longrightarrow> m = m' \<and> \<not> deleted (O_msg q m) s \<and> m \<in> set (init_msgs_of_queue q) \<and> q \<in> init_msgqs"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    93
by (clarsimp simp add:cm2smsg_def split:if_splits option.splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    94
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    95
lemma ch2sshm_hi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    96
  "\<lbrakk>ch2sshm s h = Some (Init h', sec); valid s\<rbrakk> \<Longrightarrow> h = h' \<and> \<not> deleted (O_shm h) s \<and> h \<in> init_shms"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    97
by (clarsimp simp:ch2sshm_def split:if_splits option.splits)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    98
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
    99
lemma root_not_deleted:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   100
  "\<lbrakk>deleted (O_dir []) s; valid s\<rbrakk> \<Longrightarrow> False"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   101
apply (induct s, simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   102
apply (frule vd_cons, frule vt_grant_os, case_tac a, auto)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   103
done
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   104
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   105
lemma cf2sfile_fi:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   106
  "\<lbrakk>cf2sfile s f = Some (Init f', sec, psecopt, asecs); valid s\<rbrakk> \<Longrightarrow> f = f' \<and> 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   107
     (if (is_file s f) then \<not> deleted (O_file f) s \<and> is_init_file f 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   108
      else \<not> deleted (O_dir f) s \<and> is_init_dir f)"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   109
apply (case_tac f)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   110
by (auto simp:sroot_def cf2sfile_def root_is_init_dir dest!:root_is_dir' root_not_deleted
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   111
        split:if_splits option.splits) 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   112
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   113
lemma init_deled_imp_deled_s: 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   114
  "\<lbrakk>deleted obj s; init_alive obj; sobj \<in> (s2ss s); valid s\<rbrakk> \<Longrightarrow> \<not> init_obj_related sobj obj"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   115
apply (rule notI)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   116
apply (clarsimp simp:s2ss_def)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   117
apply (case_tac obj, case_tac [!] obja, case_tac sobj)
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   118
apply (auto split:option.splits if_splits dest!:cp2sproc_pi cq2smsgq_qi ch2sshm_hi cm2smsg_mi cf2sfile_fi)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   119
apply (auto simp:cf2sfiles_def same_inode_files_def has_same_inode_prop1' is_file_def is_dir_def
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   120
           split:option.splits t_inode_tag.splits dest!:cf2sfile_fi)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 1
diff changeset
   121
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   122
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   123
lemma deleted_imp_deletable_s:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   124
  "\<lbrakk>deleted obj s; init_alive obj; valid s\<rbrakk> \<Longrightarrow> deletable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   125
apply (simp add:deletable_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   126
apply (rule_tac x = "s2ss s" in bexI)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   127
apply (clarify, simp add:init_deled_imp_deled_s)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   128
apply (erule d2s_main)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   129
done
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   130
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   131
theorem undeletable_s_complete:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   132
  assumes undel_s: "undeletable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   133
  shows "undeletable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   134
proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   135
  from undel_s have init_alive: "init_alive obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   136
    and alive_s: "\<forall> ss \<in> static. \<exists> sobj \<in> ss. init_obj_related sobj obj" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   137
    using undeletable_s_def by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   138
  have "\<not> (\<exists> s. valid s \<and> deleted obj s)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   139
  proof
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   140
    assume "\<exists> s. valid s \<and> deleted obj s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   141
    then obtain s where vs: "valid s" and del: "deleted obj s" by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   142
    from vs have vss: "s2ss s \<in> static" by (rule d2s_main) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   143
    with alive_s obtain sobj where in_ss: "sobj \<in> (s2ss s)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   144
      and related: "init_obj_related sobj obj" by auto
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   145
    from init_alive del vs have "deletable_s obj" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   146
      by (auto elim:deleted_imp_deletable_s)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   147
    with alive_s
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   148
    show False by (auto simp:deletable_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   149
  qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   150
  with init_alive show ?thesis 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   151
    by (simp add:undeletable_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   152
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   153
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   154
theorem final_offer:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   155
  "\<lbrakk>undeletable_s obj; \<not> taintable_s obj; init_alive obj\<rbrakk> \<Longrightarrow> \<not> taintable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   156
apply (erule swap)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   157
by (simp add:static_complete undeletable_s_complete)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   158
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   159
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   160
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   161
(************** static \<rightarrow> dynamic ***************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   162
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   163
lemma created_can_have_many:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   164
  "\<lbrakk>valid s; alive s obj; \<not> init_alive obj\<rbrakk> \<Longrightarrow> \<exists> s'. valid s' \<and> alive s' obj \<and> alive s' obj' \<and> s2ss s = s2ss s'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   165
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   166
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   167
lemma s2d_main:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   168
  "ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   169
apply (erule static.induct)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   170
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   171
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   172
apply (erule exE|erule conjE)+
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   173
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   174
sorry
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   175
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   176
lemma tainted_s_in_ss:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   177
  "tainted_s ss sobj \<Longrightarrow> sobj \<in> ss"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   178
apply (case_tac sobj, simp_all)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   179
apply (case_tac bool, simp+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   180
apply (case_tac bool, simp+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   181
apply (case_tac prod1, case_tac prod2, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   182
thm tainted_s.simps
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   183
oops
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   184
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   185
lemma set_eq_D:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   186
  "\<lbrakk>x \<in> S; {x. P x} = S\<rbrakk> \<Longrightarrow> P x"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   187
by auto
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   188
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   189
lemma cqm2sms_prop1:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   190
  "\<lbrakk>cqm2sms s q queue = Some sms; sm \<in> set sms\<rbrakk> \<Longrightarrow> \<exists> m. cm2smsg s q m = Some sm"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   191
apply (induct queue arbitrary:sms)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   192
apply (auto split:option.splits)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   193
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   194
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   195
lemma sq_sm_prop:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   196
  "\<lbrakk>sm \<in> set sms; cq2smsgq s q = Some (qi, qsec, sms); valid s\<rbrakk>
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   197
   \<Longrightarrow> \<exists> m. cm2smsg s q m = Some sm"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   198
by (auto simp:cq2smsgq_def split: option.splits intro:cqm2sms_prop1)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   199
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   200
lemma tainted_s_imp_tainted:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   201
  "\<lbrakk>tainted_s ss sobj; ss \<in> static\<rbrakk> \<Longrightarrow> \<exists> s obj. valid s \<and> co2sobj s obj = Some sobj \<and> obj \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   202
apply (drule s2d_main)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   203
apply (erule exE, erule conjE, simp add:s2ss_def)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   204
apply (rule_tac x = s in exI, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   205
apply (case_tac sobj, simp_all)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   206
apply (erule conjE, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+) 
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   207
apply (rule_tac x = obj in exI, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   208
apply (case_tac obj, (simp split:option.splits if_splits)+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   209
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   210
apply (erule conjE, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+) 
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   211
apply (rule_tac x = obj in exI, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   212
apply (case_tac obj, (simp split:option.splits if_splits)+)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   213
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   214
apply (case_tac prod1, case_tac prod2, simp)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   215
apply ((erule conjE)+, drule_tac S = ss in set_eq_D, simp, (erule exE|erule conjE)+) 
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   216
apply (case_tac obj, simp_all split:option.splits if_splits)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   217
apply (drule_tac sm = "(aa, ba, True)" in sq_sm_prop, simp+, erule exE)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   218
apply (rule_tac x = "O_msg nat m" in exI)
21
chunhan
parents: 20
diff changeset
   219
apply (simp add:cm2smsg_def split:option.splits)
chunhan
parents: 20
diff changeset
   220
done
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   221
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   222
lemma has_inode_tainted_aux:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   223
  "O_file f \<in> tainted s \<Longrightarrow> \<forall> f'. has_same_inode s f f' \<longrightarrow> O_file f' \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   224
apply (erule tainted.induct)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   225
apply (auto intro:tainted.intros simp:has_same_inode_def)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   226
(*?? need simpset for tainted *)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   227
sorry
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   228
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   229
lemma has_same_inode_tainted:
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   230
  "\<lbrakk>has_same_inode s f f'; O_file f' \<in> tainted s\<rbrakk> \<Longrightarrow> O_file f \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   231
by (drule has_inode_tainted_aux, auto simp:has_same_inode_def)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   232
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   233
theorem static_sound:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   234
  assumes tbl_s: "taintable_s obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   235
  shows "taintable obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   236
proof-
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   237
  from tbl_s obtain ss sobj where static: "ss \<in> static"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   238
    and sobj: "tainted_s ss sobj" and related: "init_obj_related sobj obj"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   239
    and init_alive: "init_alive obj" by (auto simp:taintable_s_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   240
  from static sobj tainted_s_imp_tainted 
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   241
  obtain s obj' where co2sobj: "co2sobj s obj' = Some sobj"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   242
    and tainted': "obj' \<in> tainted s" and vs: "valid s" by blast
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   243
  
20
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   244
  from co2sobj related vs
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   245
  have eq:"obj = obj' \<or> (\<exists> f f'. obj = O_file f \<and> obj' = O_file f' \<and> has_same_inode s f f')"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   246
    apply (case_tac obj', case_tac [!] obj)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   247
    apply (auto split:option.splits if_splits dest!:cp2sproc_pi cq2smsgq_qi ch2sshm_hi cm2smsg_mi cf2sfile_fi)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   248
    apply (auto simp:cf2sfiles_def same_inode_files_def has_same_inode_def is_file_def is_dir_def
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   249
               split:option.splits t_inode_tag.splits dest!:cf2sfile_fi)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   250
    done
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   251
  with tainted' have tainted: "obj \<in> tainted s"
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   252
    by (auto intro:has_same_inode_tainted)
e2c6af3ccb0d fixed bug in tainted_s and update
chunhan
parents: 19
diff changeset
   253
  with vs init_alive
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
  show ?thesis by (auto simp:taintable_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   255
qed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   256
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   257
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   258
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   259
lemma ts2t:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   260
  "obj \<in> tainted_s ss \<Longrightarrow> \<exists> s. obj \<in> tainted s"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   261
  "obj \<in> tainted_s ss \<Longrightarrow> \<exists> so. so True \<in> ss \<Longrightarrow> so True \<in> ss \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss \<Longrightarrow> so True \<in> s2ss s \<Longrightarrow> tainted s obj. "
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   262
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   263
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   264
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   265
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   266
end