Current_prop.thy
author chunhan
Thu, 11 Jul 2013 07:52:06 +0800
changeset 28 e298d755bc35
parent 27 fc749f19b894
child 29 622516c0fe34
permissions -rw-r--r--
finally finish Info_flow_shm_attach
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
     1
(*<*)
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     2
theory Current_prop
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     3
imports Main Flask_type Flask My_list_prefix Init_prop Valid_prop Delete_prop
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     4
begin
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
     5
(*>*)
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     6
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     7
context flask begin
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     8
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     9
lemma procs_of_shm_prop1: "\<lbrakk> p_flag \<in> procs_of_shm s h; valid s\<rbrakk> \<Longrightarrow> h \<in> current_shms s"
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    10
apply (induct s arbitrary:p_flag)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    11
apply (case_tac p_flag, simp, drule init_procs_has_shm, simp)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    12
apply (frule vd_cons, frule vt_grant_os)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    13
apply (case_tac a, auto split:if_splits option.splits)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    14
done
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    15
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    16
lemma procs_of_shm_prop2: "\<lbrakk>(p, flag) \<in> procs_of_shm s h; valid s\<rbrakk> \<Longrightarrow> p \<in> current_procs s"
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    17
apply (induct s arbitrary:p flag)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    18
apply (simp, drule init_procs_has_shm, simp)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    19
apply (frule vd_cons, frule vt_grant_os)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    20
apply (case_tac a, auto split:if_splits option.splits)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    21
done
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    22
26
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
    23
lemma procs_of_shm_prop2':
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
    24
  "\<lbrakk>p \<notin> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<forall> flag h. (p, flag) \<notin> procs_of_shm s h"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
    25
by (auto dest:procs_of_shm_prop2)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
    26
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    27
lemma procs_of_shm_prop3: "\<lbrakk>(p, flag) \<in> procs_of_shm s h; (p, flag') \<in> procs_of_shm s h; valid s\<rbrakk>
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    28
  \<Longrightarrow> flag = flag'"
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    29
apply (induct s arbitrary:p flag flag')
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    30
apply (simp, drule_tac flag = flag in init_procs_has_shm, drule_tac flag = flag' in init_procs_has_shm, simp)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    31
apply (frule vd_cons, frule vt_grant_os)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    32
apply (case_tac a, auto split:if_splits option.splits dest:procs_of_shm_prop2)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    33
done
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    34
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    35
lemma procs_of_shm_prop4: "\<lbrakk>(p, flag) \<in> procs_of_shm s h; valid s\<rbrakk> \<Longrightarrow> flag_of_proc_shm s p h = Some flag"
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    36
apply (induct s arbitrary:p flag)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    37
apply (simp, drule init_procs_has_shm, simp)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    38
apply (frule vd_cons, frule vt_grant_os)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    39
apply (case_tac a, auto split:if_splits option.splits dest:procs_of_shm_prop2)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    40
done
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    41
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    42
lemma procs_of_shm_prop4':
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    43
  "\<lbrakk>flag_of_proc_shm s p h = None; valid s\<rbrakk> \<Longrightarrow> \<forall> flag. (p, flag) \<notin> procs_of_shm s h"
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    44
by (auto dest:procs_of_shm_prop4)
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    45
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    46
lemma not_init_intro_proc:
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    47
  "\<lbrakk>p \<notin> current_procs s; valid s\<rbrakk> \<Longrightarrow> deleted (O_proc p) s \<or> p \<notin> init_procs"
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    48
using not_deleted_init_proc by auto
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    49
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    50
lemma not_init_intro_proc':
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    51
  "\<lbrakk>p \<notin> current_procs s; valid s\<rbrakk> \<Longrightarrow> \<not> (\<not> deleted (O_proc p) s \<and> p \<in> init_procs)"
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    52
using not_deleted_init_proc by auto
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
    53
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 19
diff changeset
    54
lemma info_shm_flow_in_procs:
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 19
diff changeset
    55
  "\<lbrakk>info_flow_shm s p p'; valid s\<rbrakk> \<Longrightarrow> p \<in> current_procs s \<and> p' \<in> current_procs s"
26
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
    56
by (auto intro:procs_of_shm_prop2 simp:info_flow_shm_def one_flow_shm_def)
25
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
    57
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    58
lemma flag_of_proc_shm_prop1:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    59
  "\<lbrakk>flag_of_proc_shm s p h = Some flag; valid s\<rbrakk> \<Longrightarrow> (p, flag) \<in> procs_of_shm s h"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    60
apply (induct s arbitrary:p flag)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    61
apply (simp, drule init_shmflag_has_proc, simp)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    62
apply (frule vd_cons, frule vt_grant_os)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    63
apply (case_tac a, auto split:if_splits option.splits dest:procs_of_shm_prop2)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    64
done
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    65
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    66
(*********** simpset for one_flow_shm **************)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    67
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    68
lemma one_flow_not_self:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    69
  "one_flow_shm s h p p \<Longrightarrow> False"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    70
by (simp add:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    71
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    72
lemma one_flow_shm_attach:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    73
  "valid (Attach p h flag # s) \<Longrightarrow> one_flow_shm (Attach p h flag # s) = (\<lambda> h' pa pb. 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    74
     if (h' = h) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    75
     then (pa = p \<and> pb \<noteq> p \<and> flag = SHM_RDWR \<and> (\<exists> flagb. (pb, flagb) \<in> procs_of_shm s h)) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    76
          (pb = p \<and> pa \<noteq> p \<and> (pa, SHM_RDWR) \<in> procs_of_shm s h) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    77
          (one_flow_shm s h pa pb)               
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    78
     else one_flow_shm s h' pa pb        )"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    79
apply (rule ext, rule ext, rule ext, frule vd_cons, frule vt_grant_os)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    80
by (auto simp add: one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    81
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    82
lemma one_flow_shm_detach:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    83
  "valid (Detach p h # s) \<Longrightarrow> one_flow_shm (Detach p h # s) = (\<lambda> h' pa pb.
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    84
     if (h' = h) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    85
     then (pa \<noteq> p \<and> pb \<noteq> p \<and> one_flow_shm s h' pa pb)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    86
     else one_flow_shm s h' pa pb)"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    87
apply (rule ext, rule ext, rule ext, frule vt_grant_os)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    88
by (auto simp:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    89
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    90
lemma one_flow_shm_deleteshm:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    91
  "valid (DeleteShM p h # s) \<Longrightarrow> one_flow_shm (DeleteShM p h # s) = (\<lambda> h' pa pb. 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    92
     if (h' = h) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    93
     then False
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    94
     else one_flow_shm s h' pa pb)"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    95
apply (rule ext, rule ext, rule ext, frule vt_grant_os)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    96
by (auto simp: one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    97
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    98
lemma one_flow_shm_clone:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
    99
  "valid (Clone p p' fds shms # s) \<Longrightarrow> one_flow_shm (Clone p p' fds shms # s) = (\<lambda> h pa pb. 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   100
     if (pa = p' \<and> pb \<noteq> p' \<and> h \<in> shms)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   101
     then (if (pb = p) then (flag_of_proc_shm s p h = Some SHM_RDWR) else one_flow_shm s h p pb)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   102
     else if (pb = p' \<and> pa \<noteq> p' \<and> h \<in> shms)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   103
          then (if (pa = p) then (flag_of_proc_shm s p h = Some SHM_RDWR) else one_flow_shm s h pa p)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   104
          else one_flow_shm s h pa pb)"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   105
apply (rule ext, rule ext, rule ext, frule vt_grant_os, frule vd_cons, clarsimp)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   106
apply (frule_tac p = p' in procs_of_shm_prop2', simp)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   107
apply (auto simp:one_flow_shm_def intro:procs_of_shm_prop4 flag_of_proc_shm_prop1)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   108
done
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   109
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   110
lemma one_flow_shm_execve:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   111
  "valid (Execve p f fds # s) \<Longrightarrow> one_flow_shm (Execve p f fds # s) = (\<lambda> h pa pb. 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   112
     pa \<noteq> p \<and> pb \<noteq> p \<and> one_flow_shm s h pa pb    )"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   113
apply (rule ext, rule ext, rule ext, frule vt_grant_os, frule vd_cons)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   114
by (auto simp:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   115
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   116
lemma one_flow_shm_kill:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   117
  "valid (Kill p p' # s) \<Longrightarrow> one_flow_shm (Kill p p' # s) = (\<lambda> h pa pb. 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   118
     pa \<noteq> p' \<and> pb \<noteq> p' \<and> one_flow_shm s h pa pb                 )"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   119
apply (rule ext, rule ext, rule ext, frule vt_grant_os, frule vd_cons)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   120
by (auto simp:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   121
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   122
lemma one_flow_shm_exit:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   123
  "valid (Exit p # s) \<Longrightarrow> one_flow_shm (Exit p # s) = (\<lambda> h pa pb. 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   124
     pa \<noteq> p \<and> pb \<noteq> p \<and> one_flow_shm s h pa pb                          )"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   125
apply (rule ext, rule ext, rule ext, frule vt_grant_os, frule vd_cons)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   126
by (auto simp:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   127
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   128
lemma one_flow_shm_other:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   129
  "\<lbrakk>valid (e # s); 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   130
    \<forall> p h flag. e \<noteq> Attach p h flag;
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   131
    \<forall> p h. e \<noteq> Detach p h;
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   132
    \<forall> p h. e \<noteq> DeleteShM p h;
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   133
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   134
    \<forall> p f fds. e \<noteq> Execve p f fds;
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   135
    \<forall> p p'. e \<noteq> Kill p p';
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   136
    \<forall> p. e \<noteq> Exit p
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   137
   \<rbrakk> \<Longrightarrow> one_flow_shm (e # s) = one_flow_shm s"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   138
apply (rule ext, rule ext, rule ext, frule vt_grant_os, frule vd_cons)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   139
apply (case_tac e, auto simp:one_flow_shm_def dest:procs_of_shm_prop2)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   140
apply (drule procs_of_shm_prop1, auto)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   141
done
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   142
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   143
lemmas one_flow_shm_simps = one_flow_shm_other one_flow_shm_attach one_flow_shm_detach one_flow_shm_deleteshm
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   144
  one_flow_shm_clone one_flow_shm_execve one_flow_shm_kill one_flow_shm_exit
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   145
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   146
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   147
inductive Info_flow_shm :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process \<Rightarrow> bool"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   148
where
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   149
  ifs_self: "p \<in> current_procs s \<Longrightarrow> Info_flow_shm s p p"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   150
| ifs_flow:"\<lbrakk>Info_flow_shm s p p'; one_flow_shm s h p' p''\<rbrakk> \<Longrightarrow> Info_flow_shm s p p''"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   151
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   152
lemma Info_flow_trans_aux:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   153
  "Info_flow_shm s p' p'' \<Longrightarrow> \<forall>p. Info_flow_shm s p p' \<longrightarrow> Info_flow_shm s p p''"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   154
apply (erule Info_flow_shm.induct)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   155
by (auto intro:Info_flow_shm.intros)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   156
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   157
lemma Info_flow_trans:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   158
  "\<lbrakk>Info_flow_shm s p p'; Info_flow_shm s p' p''\<rbrakk> \<Longrightarrow> Info_flow_shm s p p''"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   159
by (auto dest:Info_flow_trans_aux)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   160
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   161
lemma one_flow_flows:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   162
  "\<lbrakk>one_flow_shm s h p p'; valid s\<rbrakk> \<Longrightarrow> Info_flow_shm s p p'"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   163
apply (rule Info_flow_shm.intros(2), simp_all)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   164
apply (rule Info_flow_shm.intros(1))
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   165
apply (auto intro:procs_of_shm_prop2 simp:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   166
done
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   167
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   168
lemma ifs_flow': "\<lbrakk>one_flow_shm s h p p'; Info_flow_shm s p' p''; valid s\<rbrakk> \<Longrightarrow> Info_flow_shm s p p''"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   169
apply (drule one_flow_flows, simp+)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   170
apply (erule Info_flow_trans, simp+)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   171
done
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   172
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   173
lemma Info_flow_shm_cases1:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   174
  "\<lbrakk>Info_flow_shm s pa pb; 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   175
    \<And>p \<tau>. \<lbrakk>\<tau> = s; pa = p; pb = p; p \<in> current_procs \<tau>\<rbrakk> \<Longrightarrow> P;
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   176
    \<And>\<tau> p p' h p''. \<lbrakk>\<tau> = s; pa = p; pb = p''; Info_flow_shm \<tau> p p'; one_flow_shm \<tau> h p' p''\<rbrakk> \<Longrightarrow> P\<rbrakk>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   177
   \<Longrightarrow> P"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   178
by (erule Info_flow_shm.cases, auto)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   179
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   180
lemma Info_flow_shm_prop1:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   181
  "\<not> Info_flow_shm s p p \<Longrightarrow> p \<notin> current_procs s" 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   182
by (rule notI, drule Info_flow_shm.intros(1), simp)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   183
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   184
lemma Info_flow_shm_intro3:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   185
  "\<lbrakk>Info_flow_shm s p from; (from, SHM_RDWR) \<in> procs_of_shm s h; (to, flag) \<in> procs_of_shm s h\<rbrakk>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   186
   \<Longrightarrow> Info_flow_shm s p to"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   187
apply (case_tac "from = to", simp)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   188
apply (erule_tac h = h in Info_flow_shm.intros(2), simp add:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   189
by (rule_tac x = flag in exI, simp)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   190
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   191
lemma Info_flow_shm_intro4:
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   192
  "\<lbrakk>(p, flagb) \<in> procs_of_shm s h; valid s\<rbrakk> \<Longrightarrow> Info_flow_shm s p p"
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   193
by (drule procs_of_shm_prop2, simp, simp add:Info_flow_shm.intros)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   194
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   195
(********* simpset for inductive Info_flow_shm **********)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   196
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   197
lemma Info_flow_shm_attach1_aux:
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   198
  "Info_flow_shm s' pa pb \<Longrightarrow> valid s' \<and> (s' = Attach p h flag # s) \<longrightarrow> 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   199
     (if Info_flow_shm s pa pb then True else
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   200
     (if (pa = p \<and> flag = SHM_RDWR) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   201
      then (\<exists> p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   202
      else if (pb = p) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   203
           then (\<exists> p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p')
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   204
           else (\<exists> p' flag'. Info_flow_shm s pa p \<and> flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   205
                             Info_flow_shm s p' pb) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   206
                (\<exists> p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pb)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   207
     )  )"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   208
proof (induct rule:Info_flow_shm.induct)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   209
  case (ifs_self proc \<tau>)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   210
  show ?case
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   211
  proof (rule impI)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   212
    assume pre: "valid \<tau> \<and> \<tau> = Attach p h flag # s"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   213
    hence p1: "p \<in> current_procs s" and p2: "valid s" by (auto intro:vd_cons dest:vt_grant_os)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   214
    hence p3: "Info_flow_shm s p p" by (auto intro:Info_flow_shm.intros)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   215
    from ifs_self pre have "proc \<in> current_procs s" by simp 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   216
    hence p4: "Info_flow_shm s proc proc" by (auto intro:Info_flow_shm.intros)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   217
    show "if Info_flow_shm s proc proc then True
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   218
    else if proc = p \<and> flag = SHM_RDWR then \<exists>p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' proc
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   219
         else if proc = p then \<exists>p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s proc p'
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   220
              else (\<exists>p' flag'. Info_flow_shm s proc p \<and>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   221
                       flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> Info_flow_shm s p' proc) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   222
                   (\<exists>p'. Info_flow_shm s proc p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p proc)"      using p4 p3 by auto
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   223
  qed
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   224
next
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   225
  case (ifs_flow \<tau> pa pb h' pc)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   226
  thus ?case
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   227
  proof (rule_tac impI)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   228
    assume p1:"Info_flow_shm \<tau> pa pb" and p2: "valid \<tau> \<and> \<tau> = Attach p h flag # s \<longrightarrow>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   229
     (if Info_flow_shm s pa pb then True
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   230
      else if pa = p \<and> flag = SHM_RDWR then \<exists>p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   231
           else if pb = p then \<exists>p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p'
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   232
                else (\<exists>p' flag'. Info_flow_shm s pa p \<and>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   233
                         flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   234
                     (\<exists>p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pb))"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   235
      and p3: "one_flow_shm \<tau> h' pb pc" and p4: "valid \<tau> \<and> \<tau> = Attach p h flag # s"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   236
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   237
    from p2 and p4 have p2': "(if Info_flow_shm s pa pb then True
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   238
      else if pa = p \<and> flag = SHM_RDWR then \<exists>p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   239
           else if pb = p then \<exists>p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p'
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   240
                else (\<exists>p' flag'. Info_flow_shm s pa p \<and>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   241
                         flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   242
                     (\<exists>p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pb))"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   243
      by (erule_tac impE, simp)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   244
    from p4 have p5: "valid s" and p6: "os_grant s (Attach p h flag)" by (auto intro:vd_cons dest:vt_grant_os)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   245
    from p6 have "p \<in> current_procs s" by simp hence p7:"Info_flow_shm s p p" by (erule_tac Info_flow_shm.intros)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   246
    from p3 p4 have p8: "if (h' = h) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   247
     then (pb = p \<and> pc \<noteq> p \<and> flag = SHM_RDWR \<and> (\<exists> flagb. (pc, flagb) \<in> procs_of_shm s h)) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   248
          (pc = p \<and> pb \<noteq> p \<and> (pb, SHM_RDWR) \<in> procs_of_shm s h) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   249
          (one_flow_shm s h pb pc)               
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   250
     else one_flow_shm s h' pb pc        " by (auto simp add:one_flow_shm_attach) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   251
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   252
    have "\<And> flagb. (pc, flagb) \<in> procs_of_shm s h 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   253
      \<Longrightarrow> \<exists> p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pc"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   254
      apply (rule_tac x= pc in exI, rule_tac x = flagb in exI, frule procs_of_shm_prop2)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   255
      by (simp add:p5, simp add:Info_flow_shm.intros(1))
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   256
    hence p10: "\<not> Info_flow_shm s p pc \<Longrightarrow> (\<exists>p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pc) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   257
      Info_flow_shm s pa pc"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   258
      using p2' p7 p8 p5
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   259
      by (auto split:if_splits dest:Info_flow_shm.intros(2))      
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   260
  (*     apply (rule_tac x = pb in exI, simp add:one_flow_flows, rule_tac x = flagb in exI, simp)+  *)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   261
    moreover have "pc = p \<Longrightarrow> (\<exists> p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p') 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   262
                            \<or> Info_flow_shm s pa pc"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   263
      using p2' p7 p8 p5
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   264
      by (auto split:if_splits intro:Info_flow_shm_intro3 simp:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   265
    moreover have "\<lbrakk>pc \<noteq> p; pa \<noteq> p \<or> flag \<noteq> SHM_RDWR\<rbrakk> \<Longrightarrow> (\<exists>p' flag'. Info_flow_shm s pa p \<and>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   266
                          flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> Info_flow_shm s p' pc) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   267
                      (\<exists>p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pc) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   268
                      Info_flow_shm s pa pc"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   269
      using p2' p7 p8 p5
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   270
      apply (auto split:if_splits intro:Info_flow_shm_intro3 simp:one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   271
      apply (rule_tac x = pc in exI, simp add:Info_flow_shm_intro4)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   272
      apply (rule_tac x = flagb in exI, simp)      
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   273
      done
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   274
    ultimately  show "if Info_flow_shm s pa pc then True
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   275
       else if pa = p \<and> flag = SHM_RDWR then \<exists>p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pc
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   276
            else if pc = p then \<exists>p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p'
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   277
                 else (\<exists>p' flag'. Info_flow_shm s pa p \<and>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   278
                          flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> Info_flow_shm s p' pc) \<or>
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   279
                      (\<exists>p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pc)"
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   280
      using p7 by auto
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   281
  qed
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   282
qed
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   283
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   284
lemma Info_flow_shm_attach1:
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   285
  "\<lbrakk>valid (Attach p h flag # s); Info_flow_shm (Attach p h flag # s) pa pb\<rbrakk>
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   286
   \<Longrightarrow> (if Info_flow_shm s pa pb then True else
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   287
     (if (pa = p \<and> flag = SHM_RDWR) 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   288
      then (\<exists> p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   289
      else if (pb = p) 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   290
           then (\<exists> p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p')
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   291
           else (\<exists> p' flag'. Info_flow_shm s pa p \<and> flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   292
                             Info_flow_shm s p' pb) \<or>
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   293
                (\<exists> p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pb)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   294
     )  )"
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   295
apply (drule_tac p = p and h = h and flag = flag in Info_flow_shm_attach1_aux)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   296
by auto
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   297
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   298
lemma Info_flow_shm_attach_aux[rule_format]:
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   299
  "Info_flow_shm s pa pb \<Longrightarrow> valid (Attach p h flag # s) \<longrightarrow> Info_flow_shm (Attach p h flag # s) pa pb"
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   300
apply (erule Info_flow_shm.induct)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   301
apply (rule impI, rule Info_flow_shm.intros(1), simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   302
apply (rule impI, simp, rule_tac h = ha in Info_flow_shm.intros(2), simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   303
apply (auto simp add:one_flow_shm_simps)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   304
done
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   305
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   306
lemma Info_flow_shm_attach2:
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   307
  "\<lbrakk>valid (Attach p h flag # s); if Info_flow_shm s pa pb then True else
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   308
     (if (pa = p \<and> flag = SHM_RDWR) 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   309
      then (\<exists> p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   310
      else if (pb = p) 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   311
           then (\<exists> p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p')
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   312
           else (\<exists> p' flag'. Info_flow_shm s pa p \<and> flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   313
                             Info_flow_shm s p' pb) \<or>
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   314
                (\<exists> p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pb))\<rbrakk>
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   315
   \<Longrightarrow> Info_flow_shm (Attach p h flag # s) pa pb"
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   316
apply (frule vt_grant_os, frule vd_cons)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   317
apply (auto split:if_splits intro:Info_flow_shm_intro3 simp:one_flow_shm_def intro:Info_flow_shm_attach_aux)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   318
apply (rule_tac p' = p' in Info_flow_trans)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   319
apply (rule_tac p' = p and h = h in Info_flow_shm.intros(2))
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   320
apply (rule Info_flow_shm.intros(1), simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   321
apply (simp add:one_flow_shm_simps, simp add:one_flow_shm_def)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   322
apply (rule conjI, rule notI, simp, rule_tac x = flagb in exI, simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   323
apply (simp add:Info_flow_shm_attach_aux)
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   324
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   325
apply (rule_tac p' = p' in Info_flow_trans)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   326
apply (rule_tac p' = p in Info_flow_trans)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   327
apply (simp add:Info_flow_shm_attach_aux)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   328
apply (rule_tac p' = p and h = h in Info_flow_shm.intros(2))
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   329
apply (rule Info_flow_shm.intros(1), simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   330
apply (simp add:one_flow_shm_simps, simp add:one_flow_shm_def)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   331
apply (rule conjI, rule notI, simp, rule_tac x = flag' in exI, simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   332
apply (simp add:Info_flow_shm_attach_aux)
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   333
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   334
apply (rule_tac p' = p in Info_flow_trans)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   335
apply (rule_tac p' = p' in Info_flow_trans)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   336
apply (simp add:Info_flow_shm_attach_aux)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   337
apply (rule_tac p' = p' and h = h in Info_flow_shm.intros(2))
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   338
apply (rule Info_flow_shm.intros(1), simp add:procs_of_shm_prop2)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   339
apply (simp add:one_flow_shm_simps, simp add:one_flow_shm_def)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   340
apply (rule notI, simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   341
apply (simp add:Info_flow_shm_attach_aux)
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   342
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   343
apply (rule_tac p' = p in Info_flow_trans)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   344
apply (rule_tac p' = p' in Info_flow_trans)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   345
apply (simp add:Info_flow_shm_attach_aux)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   346
apply (rule_tac p' = p' and h = h in Info_flow_shm.intros(2))
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   347
apply (rule Info_flow_shm.intros(1), simp add:procs_of_shm_prop2)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   348
apply (simp add:one_flow_shm_simps, simp add:one_flow_shm_def)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   349
apply (rule notI, simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   350
apply (simp add:Info_flow_shm_attach_aux)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   351
done
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   352
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   353
lemma Info_flow_shm_attach:
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   354
  "valid (Attach p h flag # s) \<Longrightarrow> Info_flow_shm (Attach p h flag # s) = (\<lambda> pa pb. 
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   355
     Info_flow_shm s pa pb \<or>
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   356
     (if (pa = p \<and> flag = SHM_RDWR) 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   357
      then (\<exists> p' flagb. (p', flagb) \<in> procs_of_shm s h \<and> Info_flow_shm s p' pb)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   358
      else if (pb = p) 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   359
           then (\<exists> p'. (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s pa p')
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   360
           else (\<exists> p' flag'. Info_flow_shm s pa p \<and> flag = SHM_RDWR \<and> (p', flag') \<in> procs_of_shm s h \<and> 
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   361
                             Info_flow_shm s p' pb) \<or>
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   362
                (\<exists> p'. Info_flow_shm s pa p' \<and> (p', SHM_RDWR) \<in> procs_of_shm s h \<and> Info_flow_shm s p pb)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   363
     )  )"
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   364
apply (rule ext, rule ext, rule iffI)
28
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   365
apply (drule_tac pa = pa and pb = pb in Info_flow_shm_attach1, simp)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   366
apply (auto split:if_splits)[1]
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   367
apply (drule_tac pa = pa and pb = pb in Info_flow_shm_attach2)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   368
apply (auto split:if_splits)
e298d755bc35 finally finish Info_flow_shm_attach
chunhan
parents: 27
diff changeset
   369
done
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 26
diff changeset
   370
26
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   371
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   372
lemma info_flow_shm_detach:
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   373
  "valid (Detach p h # s) \<Longrightarrow> info_flow_shm (Detach p h # s) = (\<lambda> pa pb. 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   374
     self_shm s pa pb \<or> ((p = pa \<or> p = pb) \<and> (\<exists> h'. h' \<noteq> h \<and> one_flow_shm s h' pa pb)) \<or>
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   375
     (pa \<noteq> p \<and> pb \<noteq> p \<and> info_flow_shm s pa pb) )"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   376
apply (rule ext, rule ext, frule vt_grant_os)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   377
by (auto simp:info_flow_shm_def one_flow_shm_def)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   378
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   379
lemma info_flow_shm_deleteshm:
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   380
  "valid (DeleteShM p h # s) \<Longrightarrow> info_flow_shm (DeleteShM p h # s) = (\<lambda> pa pb. 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   381
     self_shm s pa pb \<or> (\<exists> h'. h' \<noteq> h \<and> one_flow_shm s h' pa pb)     )"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   382
apply (rule ext, rule ext, frule vt_grant_os)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   383
by (auto simp:info_flow_shm_def one_flow_shm_def)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   384
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   385
lemma info_flow_shm_clone:
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   386
  "valid (Clone p p' fds shms # s) \<Longrightarrow> info_flow_shm (Clone p p' fds shms # s) = (\<lambda> pa pb. 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   387
     (pa = p' \<and> pb = p') \<or> (pa = p' \<and> pb \<noteq> p' \<and> (\<exists> h \<in> shms. one_flow_shm s h p pb)) \<or> 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   388
     (pb = p' \<and> pa \<noteq> p' \<and> (\<exists> h \<in> shms. one_flow_shm s h pa p)) \<or> 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   389
     (pa \<noteq> p' \<and> pb \<noteq> p' \<and> info_flow_shm s pa pb))"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   390
apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons, clarsimp)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   391
apply (frule_tac p = p' in procs_of_shm_prop2', simp)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   392
apply (auto simp:info_flow_shm_def one_flow_shm_def)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   393
done
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   394
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   395
lemma info_flow_shm_execve:
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   396
  "valid (Execve p f fds # s) \<Longrightarrow> info_flow_shm (Execve p f fds # s) = (\<lambda> pa pb. 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   397
     (pa = p \<and> pb = p) \<or> (pa \<noteq> p \<and> pb \<noteq> p \<and> info_flow_shm s pa pb)    )"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   398
apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   399
by (auto simp:info_flow_shm_def one_flow_shm_def)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   400
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   401
lemma info_flow_shm_kill:
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   402
  "valid (Kill p p' # s) \<Longrightarrow> info_flow_shm (Kill p p' # s) = (\<lambda> pa pb. 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   403
     pa \<noteq> p' \<and> pb \<noteq> p' \<and> info_flow_shm s pa pb                 )"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   404
apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   405
by (auto simp:info_flow_shm_def one_flow_shm_def)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   406
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   407
lemma info_flow_shm_exit:
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   408
  "valid (Exit p # s) \<Longrightarrow> info_flow_shm (Exit p # s) = (\<lambda> pa pb. 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   409
     pa \<noteq> p \<and> pb \<noteq> p \<and> info_flow_shm s pa pb                          )"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   410
apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   411
by (auto simp:info_flow_shm_def one_flow_shm_def)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   412
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   413
lemma info_flow_shm_other:
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   414
  "\<lbrakk>valid (e # s); 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   415
    \<forall> p h flag. e \<noteq> Attach p h flag;
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   416
    \<forall> p h. e \<noteq> Detach p h;
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   417
    \<forall> p h. e \<noteq> DeleteShM p h;
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   418
    \<forall> p p' fds shms. e \<noteq> Clone p p' fds shms;
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   419
    \<forall> p f fds. e \<noteq> Execve p f fds;
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   420
    \<forall> p p'. e \<noteq> Kill p p';
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   421
    \<forall> p. e \<noteq> Exit p
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   422
   \<rbrakk> \<Longrightarrow> info_flow_shm (e # s) = info_flow_shm s"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   423
apply (rule ext, rule ext, frule vt_grant_os, frule vd_cons)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   424
apply (case_tac e, auto simp:info_flow_shm_def one_flow_shm_def dest:procs_of_shm_prop2)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   425
apply (erule_tac x = h in allE, simp)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   426
apply (drule procs_of_shm_prop1, auto)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   427
done
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   428
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   429
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   430
(*
25
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   431
lemma info_flow_shm_prop1: 
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   432
  "\<lbrakk>info_flow_shm s p p'; p \<noteq> p'; valid s\<rbrakk> 
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   433
   \<Longrightarrow> \<exists> h h' flag. (p, SHM_RDWR) \<in> procs_of_shm s h \<and> (p', flag) \<in> procs_of_shm s h'"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   434
by (induct rule: info_flow_shm.induct, auto)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   435
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   436
lemma info_flow_shm_cases:
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   437
  "\<lbrakk>info_flow_shm \<tau> pa pb; \<And>p s. \<lbrakk>s = \<tau> ; pa = p; pb = p; p \<in> current_procs s\<rbrakk> \<Longrightarrow> P;
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   438
  \<And>s p p' h p'' flag. \<lbrakk>s = \<tau>; pa = p; pb = p''; info_flow_shm s p p'; (p', SHM_RDWR) \<in> procs_of_shm s h;
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   439
                       (p'', flag) \<in> procs_of_shm s h\<rbrakk>\<Longrightarrow> P\<rbrakk>
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   440
  \<Longrightarrow> P"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   441
by (erule info_flow_shm.cases, auto)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   442
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   443
definition one_flow_shm :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process \<Rightarrow> bool"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   444
where
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   445
  "one_flow_shm s p p' \<equiv> p \<noteq> p' \<and> (\<exists> h flag. (p, SHM_RDWR) \<in> procs_of_shm s h \<and> (p', flag) \<in> procs_of_shm s h)"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   446
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   447
inductive flows_shm :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process \<Rightarrow> bool"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   448
where
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   449
  "p \<in> current_procs s \<Longrightarrow> flows_shm s p p"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   450
| "\<lbrakk>flows_shm s p p'; one_flow_shm s p' p''\<rbrakk> \<Longrightarrow> flows_shm s p p''"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   451
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   452
definition attached_procs :: "t_state \<Rightarrow> t_shm \<Rightarrow> t_process set"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   453
where
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   454
  "attached_procs s h \<equiv> {p. \<exists> flag. (p, flag) \<in> procs_of_shm s h}"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   455
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   456
definition flowed_procs:: "t_state \<Rightarrow> t_shm \<Rightarrow> t_process set"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   457
where
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   458
  "flowed_procs s h \<equiv> {p'. \<exists> p \<in> attached_procs s h. flows_shm s p p'}"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   459
26
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   460
inductive flowed_shm:: "t_state \<Rightarrow> t_process \<Rightarrow> t_shm set"
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   461
25
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   462
fun Info_flow_shm :: "t_state \<Rightarrow> t_process \<Rightarrow> t_process set"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   463
where
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   464
  "Info_flow_shm [] = (\<lambda> p. {p'. flows_shm [] p p'})"
26
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   465
| "Info_flow_shm (Attach p h flag # s) = (\<lambda> p'. 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   466
     if (p' = p) then flowed_procs s h 
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   467
     else if ()
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   468
    "
25
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   469
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   470
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   471
lemma info_flow_shm_attach:
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   472
  "valid (Attach p h flag # s) \<Longrightarrow> info_flow_shm (Attach p h flag # s) = (\<lambda> pa pb. (info_flow_shm s pa pb) \<or> 
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   473
     (if (pa = p) 
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   474
      then (if (flag = SHM_RDWR) 
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   475
            then (\<exists> flag. (pb, flag) \<in> procs_of_shm s h)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   476
            else (pb = p)) 
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   477
      else (if (pb = p) 
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   478
            then (pa, SHM_RDWR) \<in> procs_of_shm s h
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   479
            else info_flow_shm s pa pb)) )"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   480
apply (frule vd_cons, frule vt_grant_os, rule ext, rule ext)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   481
apply (case_tac "info_flow_shm s pa pb", simp)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   482
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   483
thm info_flow_shm.cases
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   484
apply (auto split:if_splits intro:info_flow_shm.intros elim:info_flow_shm_cases)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   485
apply (erule info_flow_shm_cases, simp, simp split:if_splits)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   486
apply (rule_tac p = pa and p' = p' in info_flow_shm.intros(2), simp+)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   487
apply (rule notI, erule info_flow_shm.cases, simp+)
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 23
diff changeset
   488
pr 5
26
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   489
*)
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   490
lemmas info_flow_shm_simps = info_flow_shm_other info_flow_shm_attach info_flow_shm_detach info_flow_shm_deleteshm
b6333712cb02 finished info_flow_shm(simple def) simpset
chunhan
parents: 25
diff changeset
   491
  info_flow_shm_clone info_flow_shm_execve info_flow_shm_kill info_flow_shm_exit
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 19
diff changeset
   492
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   493
lemma has_same_inode_in_current:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   494
  "\<lbrakk>has_same_inode s f f'; valid s\<rbrakk> \<Longrightarrow> f \<in> current_files s \<and> f' \<in> current_files s"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   495
by (auto simp add:has_same_inode_def current_files_def)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   496
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   497
lemma has_same_inode_prop1:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   498
  "\<lbrakk>has_same_inode s f f'; is_file s f; valid s\<rbrakk> \<Longrightarrow> is_file s f'"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   499
by (auto simp:has_same_inode_def is_file_def)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   500
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   501
lemma has_same_inode_prop1':
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   502
  "\<lbrakk>has_same_inode s f f'; is_file s f'; valid s\<rbrakk> \<Longrightarrow> is_file s f"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   503
by (auto simp:has_same_inode_def is_file_def)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   504
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   505
lemma has_same_inode_prop2:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   506
  "\<lbrakk>has_same_inode s f f'; file_of_proc_fd s p fd = Some f; valid s\<rbrakk> \<Longrightarrow> is_file s f'"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   507
apply (drule has_same_inode_prop1)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   508
apply (simp add:file_of_pfd_is_file, simp+)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   509
done
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   510
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   511
lemma has_same_inode_prop2':
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   512
  "\<lbrakk>has_same_inode s f f'; file_of_proc_fd s p fd = Some f'; valid s\<rbrakk> \<Longrightarrow> is_file s f"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   513
apply (drule has_same_inode_prop1')
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   514
apply (simp add:file_of_pfd_is_file, simp+)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   515
done
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   516
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   517
lemma tobj_in_init_alive:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   518
  "tobj_in_init obj \<Longrightarrow> init_alive obj"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   519
by (case_tac obj, auto)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   520
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   521
lemma tobj_in_alive:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   522
  "tobj_in_init obj \<Longrightarrow> alive [] obj"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   523
by (case_tac obj, auto simp:is_file_nil)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   524
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   525
end
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   526
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   527
end