Tainted_prop.thy
author chunhan
Tue, 27 Aug 2013 08:50:53 +0800
changeset 31 aa1375b6c0eb
parent 29 622516c0fe34
child 34 e7f850d1e08e
permissions -rw-r--r--
find bugs in os_grant, case RecvMsg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     1
theory Tainted_prop 
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
     2
imports Main Flask Flask_type Init_prop Current_files_prop Current_sockets_prop Delete_prop Proc_fd_of_file_prop Current_prop Alive_prop
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     3
begin
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     4
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     5
context tainting begin
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
     6
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
     7
fun Tainted :: "t_state \<Rightarrow> t_object set"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
     8
where
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
     9
  "Tainted [] = seeds"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    10
| "Tainted (Clone p p' fds shms # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    11
     (if (O_proc p) \<in> Tainted s then Tainted s \<union> {O_proc p'} else Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    12
| "Tainted (Execve p f fds # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    13
     (if (O_file f) \<in> Tainted s then Tainted s \<union> {O_proc p} else Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    14
| "Tainted (Kill p p' # s) = Tainted s - {O_proc p'}"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    15
| "Tainted (Ptrace p p' # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    16
     (if (O_proc p) \<in> Tainted s 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    17
      then Tainted s \<union> {O_proc p'' | p''. info_flow_shm s p' p''}
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    18
      else if (O_proc p') \<in> Tainted s 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    19
           then Tainted s \<union> {O_proc p'' | p''. info_flow_shm s p p''}
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    20
                else Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    21
| "Tainted (Exit p # s) = Tainted s - {O_proc p}"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    22
| "Tainted (Open p f flags fd opt # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    23
     (case opt of
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    24
        Some inum \<Rightarrow> (if (O_proc p) \<in> Tainted s
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    25
                      then Tainted s \<union> {O_file f}
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    26
                      else Tainted s)
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    27
      | _         \<Rightarrow> Tainted s)" 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    28
| "Tainted (ReadFile p fd # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    29
     (case (file_of_proc_fd s p fd) of
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    30
        Some f \<Rightarrow> if (O_file f) \<in> Tainted s
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    31
                  then Tainted s \<union> {O_proc p' | p'. info_flow_shm s p p'}
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    32
                  else Tainted s
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    33
      | None   \<Rightarrow> Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    34
| "Tainted (WriteFile p fd # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    35
     (case (file_of_proc_fd s p fd) of 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    36
        Some f \<Rightarrow> if (O_proc p) \<in> Tainted s
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    37
                  then Tainted s \<union> {O_file f' | f'. has_same_inode s f f'}
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    38
                  else Tainted s
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    39
      | None   \<Rightarrow> Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    40
| "Tainted (CloseFd p fd # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    41
     (case (file_of_proc_fd s p fd) of
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    42
        Some f \<Rightarrow> ( if ((proc_fd_of_file s f = {(p,fd)}) \<and> (f \<in> files_hung_by_del s))
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    43
                    then Tainted s - {O_file f} else Tainted s )
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    44
      | _      \<Rightarrow> Tainted s)"
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    45
| "Tainted (UnLink p f # s) = 
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    46
     (if (proc_fd_of_file s f = {}) then Tainted s - {O_file f} else Tainted s)"
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    47
| "Tainted (LinkHard p f f' # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    48
     (if (O_file f \<in> Tainted s) then Tainted s \<union> {O_file f'} else Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    49
| "Tainted (Truncate p f len # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    50
     (if (len > 0 \<and> O_proc p \<in> Tainted s)
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    51
      then Tainted s \<union> {O_file f' | f'. has_same_inode s f f'}
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    52
      else Tainted s)"
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    53
| "Tainted (Attach p h flag # s) = 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    54
     (if (O_proc p \<in> Tainted s \<and> flag = SHM_RDWR) 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    55
      then Tainted s \<union> {O_proc p' | p' flag'. (p', flag') \<in> procs_of_shm s h}
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    56
      else if (\<exists> p'. O_proc p' \<in> Tainted s \<and> (p', SHM_RDWR) \<in> procs_of_shm s h)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    57
           then Tainted s \<union> {O_proc p}
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    58
           else Tainted s)"
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    59
| "Tainted (SendMsg p q m # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    60
     (if (O_proc p \<in> Tainted s) then Tainted s \<union> {O_msg q m} else Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    61
| "Tainted (RecvMsg p q m # s) = 
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    62
     (if (O_msg q m \<in> Tainted s) 
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    63
      then (Tainted s \<union> {O_proc p' | p'. info_flow_shm s p p'}) - {O_msg q m}
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    64
      else Tainted s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    65
| "Tainted (RemoveMsgq p q # s) = Tainted s - {O_msg q m| m. O_msg q m \<in> Tainted s}"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    66
| "Tainted (e # s) = Tainted s"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    67
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    68
lemma valid_Tainted_obj:
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    69
  "\<lbrakk>obj \<in> Tainted s; valid s\<rbrakk> \<Longrightarrow> (\<forall> f. obj \<noteq> O_dir f) \<and> (\<forall> q. obj \<noteq> O_msgq q) \<and> (\<forall> h. obj \<noteq> O_shm h) \<and> (\<forall> p fd. obj \<noteq> O_fd p fd) \<and> (\<forall> s. obj \<noteq> O_tcp_sock s) \<and> (\<forall> s. obj \<noteq> O_udp_sock s)"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    70
apply (induct s, simp, drule seeds_in_init, case_tac obj, simp+)
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    71
apply (frule vd_cons, frule vt_grant_os, case_tac a)
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    72
apply (auto split:if_splits option.splits)
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    73
done
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    74
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    75
lemma Tainted_in_current:
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    76
  "\<lbrakk>obj \<in> Tainted s; valid s\<rbrakk> \<Longrightarrow> alive s obj"
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    77
apply (induct s, simp)
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    78
apply (drule seeds_in_init, case_tac obj, simp_all add:is_file_nil)
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
    79
apply (frule vd_cons, frule valid_Tainted_obj, simp, frule vt_grant_os, case_tac a)
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    80
apply (auto simp:alive_simps split:if_splits option.splits t_object.splits
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    81
           intro:has_same_inode_prop2 has_same_inode_prop1 procs_of_shm_prop2 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
    82
            dest:info_shm_flow_in_procs)
29
622516c0fe34 path_by_shm reconstrain path without duplicated process AND shm
chunhan
parents: 27
diff changeset
    83
done 
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    84
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    85
lemma Tainted_proc_in_current:
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    86
  "\<lbrakk>O_proc p \<in> Tainted s; valid s\<rbrakk> \<Longrightarrow> p \<in> current_procs s"
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    87
by (drule Tainted_in_current, simp+)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    88
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: 24
diff changeset
    89
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    90
lemma info_flow_shm_Tainted:
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    91
  "\<lbrakk>O_proc p \<in> Tainted s; info_flow_shm s p p'; valid s\<rbrakk> \<Longrightarrow> O_proc p' \<in> Tainted s"
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    92
proof (induct s arbitrary:p p')
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
    93
  case Nil
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    94
  thus ?case by (simp add:flow_shm_in_seeds)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    95
next
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    96
  case (Cons e s)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    97
  hence p1: "O_proc p \<in> Tainted (e # s)" and p2: "info_flow_shm (e # s) p p'" and p3: "valid (e # s)"  
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    98
    and p4: "\<And> p p'. \<lbrakk>O_proc p \<in> Tainted s; info_flow_shm s p p'\<rbrakk> \<Longrightarrow> O_proc p' \<in> Tainted s" 
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
    99
    and p5: "valid s" and p6: "os_grant s e"
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   100
    by (auto dest:vd_cons intro:vd_cons vt_grant_os)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   101
  have p4': 
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   102
    "\<And> p p' h flag. \<lbrakk>O_proc p \<in> Tainted s; (p, SHM_RDWR) \<in> procs_of_shm s h; (p', flag) \<in> procs_of_shm s h\<rbrakk> 
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   103
                \<Longrightarrow> O_proc p' \<in> Tainted s"
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   104
    by (rule p4, auto simp:info_flow_shm_def one_flow_shm_def procs_of_shm_prop2 p5)    
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   105
  from p2 p3 have p7: "p \<in> current_procs (e # s)" and p8: "p' \<in> current_procs (e # s)" 
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   106
    by (auto dest:info_shm_flow_in_procs) 
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   107
  show ?case
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   108
  proof (cases "self_shm s p p'")
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   109
    case True with p1 show ?thesis by simp
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   110
  next
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   111
    case False
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   112
    with p1 p2 p5 p6 p7 p8 p3 show ?thesis
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   113
    apply (case_tac e)(*
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   114
    prefer 7
27
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   115
    apply (simp add:info_flow_shm_simps split:if_splits option.splits)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   116
    apply (rule allI|rule impI|rule conjI)+
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   117
    apply simp
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   118
    apply (case_tac "O_proc p \<in> Tainted s", drule_tac p'=p' in p4, simp+)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   119
    apply simp
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   120
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   121
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   122
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   123
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   124
    apply (auto simp:info_flow_shm_simps one_flow_shm_def dest:Tainted_in_current 
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   125
  intro:p4 p4' split:if_splits option.splits)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   126
    apply (auto simp:info_flow_shm_def one_flow_shm_def)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   127
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   128
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   129
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   130
    apply (auto simp:one_flow_shm_def intro:p4 p4' split:if_splits option.splits)
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   131
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   132
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   133
fc749f19b894 Info_flow_shm_attach_prop
chunhan
parents: 25
diff changeset
   134
    prefer 7
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: 24
diff changeset
   135
    apply (simp split:if_splits option.splits)
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   136
    apply (rule allI|rule impI|rule conjI)+
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: 24
diff changeset
   137
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: 24
diff changeset
   138
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: 24
diff changeset
   139
    apply (auto dest:p4'   procs_of_shm_prop2 Tainted_in_current split:if_splits option.splits)[1]
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: 24
diff changeset
   140
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   141
    apply (erule disjE, drule_tac p = p and p' = p' in p4', simp+)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   142
    apply (erule disjE, rule disjI2, rule disjI2, rule_tac x = h in exI, simp, rule_tac x= toflag in exI, simp)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   143
    apply ((erule exE|erule conjE)+)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   144
    
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   145
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   146
    apply (auto simp:info_flow_shm_def dest:p4'
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   147
           procs_of_shm_prop2 Tainted_in_current split:if_splits option.splits)[1]
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   148
    apply (drule_tac p = p and p' = p' in p4')
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   149
    apply (erule_tac x = ha in allE, simp)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   150
    apply (drule_tac p = "nat1" and p' = p' in p4')
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   151
    apply (auto dest:p4'[where p = nat1 and p' = p'])
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   152
    
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   153
apply (induct s) 
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   154
apply simp defer
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   155
apply (frule vd_cons, frule vt_grant_os, case_tac a)
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   156
apply (auto simp:info_flow_shm_def elim!:disjE)
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   157
sorry *)
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   158
  sorry
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   159
qed
24
566b0d1c3669 info_flow_shm is wrongly defined: p -flow-> p'; p' -flow-> p'' ==> p -flow-> p'', this property cannot be infered by current definition. we should use inductive
chunhan
parents: 23
diff changeset
   160
qed
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   161
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   162
lemma tainted_imp_Tainted:
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   163
  "obj \<in> tainted s \<Longrightarrow> obj \<in> Tainted s"
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   164
apply (induct rule:tainted.induct)  (*
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   165
apply (simp_all add:vd_cons) 
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   166
apply (rule impI)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   167
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   168
apply (rule disjI2, rule_tac x = flag' in exI, simp)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   169
apply ((rule impI)+, erule_tac x = p' in allE, simp)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   170
*)
23
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   171
apply (auto intro:info_flow_shm_Tainted dest:vd_cons)
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   172
apply (case_tac e, auto split:option.splits if_splits simp:alive_simps)
25e55731ed01 locale of tainting for seeds when same shm/inode bugs
chunhan
parents: 22
diff changeset
   173
done
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   174
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   175
lemma Tainted_imp_tainted_aux_remain:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   176
  "\<lbrakk>obj \<in> Tainted s; valid (e # s); alive (e # s) obj; \<And> obj. obj \<in> Tainted s \<Longrightarrow> obj \<in> tainted s\<rbrakk>
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   177
   \<Longrightarrow> obj \<in> tainted (e # s)"
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   178
by (rule t_remain, auto)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   179
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   180
lemma Tainted_imp_tainted:
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   181
  "\<lbrakk>obj \<in> Tainted s; valid s\<rbrakk> \<Longrightarrow> obj \<in> tainted s"
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   182
apply (induct s arbitrary:obj, simp add:t_init)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   183
apply (frule Tainted_in_current, simp+)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   184
apply (frule vt_grant_os, frule vd_cons, case_tac a)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   185
apply (auto split:if_splits option.splits elim:Tainted_imp_tainted_aux_remain intro:tainted.intros)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   186
done
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   187
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   188
lemma tainted_eq_Tainted:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   189
  "valid s \<Longrightarrow> (obj \<in> tainted s) = (obj \<in> Tainted s)"
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   190
by (rule iffI, auto intro:Tainted_imp_tainted tainted_imp_Tainted)
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   191
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   192
lemma info_flow_shm_tainted:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   193
  "\<lbrakk>O_proc p \<in> tainted s; info_flow_shm s p p'; valid s\<rbrakk> \<Longrightarrow> O_proc p' \<in> tainted s"
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   194
by (simp only:tainted_eq_Tainted info_flow_shm_Tainted)
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   195
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   196
lemma has_same_inode_Tainted:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   197
  "\<lbrakk>O_file f \<in> Tainted s; has_same_inode s f f'; valid s\<rbrakk> \<Longrightarrow> O_file f' \<in> Tainted s"
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   198
apply (induct s arbitrary:f f', simp add:same_inode_in_seeds)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   199
apply (frule vt_grant_os, frule vd_cons, case_tac a)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   200
apply (auto split:if_splits option.splits simp:has_same_inode_def dest:iof's_im_in_cim)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   201
apply (drule_tac obj = "O_file list2" in Tainted_in_current, simp, simp add:is_file_in_current) 
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   202
done
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   203
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   204
lemma has_same_inode_tainted:
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   205
  "\<lbrakk>O_file f \<in> tainted s; has_same_inode s f f'; valid s\<rbrakk> \<Longrightarrow> O_file f' \<in> tainted s"
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   206
by (simp add:has_same_inode_Tainted tainted_eq_Tainted)
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   207
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   208
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   209
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   210
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   211
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   212
lemma tainted_in_current:
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   213
  "obj \<in> tainted s \<Longrightarrow> alive s obj"
31
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   214
apply (erule tainted.induct)
aa1375b6c0eb find bugs in os_grant, case RecvMsg
chunhan
parents: 29
diff changeset
   215
apply (auto dest:vt_grant_os vd_cons info_shm_flow_in_procs procs_of_shm_prop2 simp:is_file_simps)
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   216
apply (drule seeds_in_init, simp add:tobj_in_alive)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   217
apply (erule has_same_inode_prop2, simp, simp add:vd_cons)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   218
apply (frule vt_grant_os, simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   219
apply (erule has_same_inode_prop1, simp, simp add:vd_cons)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   220
done
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   221
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   222
lemma tainted_is_valid:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   223
  "obj \<in> tainted s \<Longrightarrow> valid s"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   224
by (erule tainted.induct, auto intro:valid.intros)
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   225
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   226
lemma t_remain_app:
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   227
  "\<lbrakk>obj \<in> tainted s; \<not> deleted obj (s' @ s); valid (s' @ s)\<rbrakk> 
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   228
  \<Longrightarrow> obj \<in> tainted (s' @ s)"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   229
apply (induct s', simp)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   230
apply (simp (no_asm) only:cons_app_simp_aux, rule t_remain)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   231
apply (simp_all add:not_deleted_cons_D vd_cons)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   232
apply (drule tainted_in_current, simp add:not_deleted_imp_alive_cons)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   233
done
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   234
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   235
lemma valid_tainted_obj:
22
f20a798cdf7d info_flow_shm bug & update
chunhan
parents: 19
diff changeset
   236
  "obj \<in> tainted s \<Longrightarrow> (\<forall> f. obj \<noteq> O_dir f) \<and> (\<forall> q. obj \<noteq> O_msgq q) \<and> (\<forall> h. obj \<noteq> O_shm h) \<and> (\<forall> p fd. obj \<noteq> O_fd p fd) \<and> (\<forall> s. obj \<noteq> O_tcp_sock s) \<and> (\<forall> s. obj \<noteq> O_udp_sock s)"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   237
apply (erule tainted.induct)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   238
apply (drule seeds_in_init)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   239
by auto
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   240
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   241
lemma dir_not_tainted: "O_dir f \<in> tainted s \<Longrightarrow> False"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   242
by (auto dest:valid_tainted_obj)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   243
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   244
lemma msgq_not_tainted: "O_msgq q \<in> tainted s \<Longrightarrow> False"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   245
by (auto dest:valid_tainted_obj)
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   246
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   247
lemma shm_not_tainted: "O_shm h \<in> tainted s \<Longrightarrow> False"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   248
by (auto dest:valid_tainted_obj)
18
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   249
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   250
end
9b42765ce554 info_flow did NOT guarantee in current_procs
chunhan
parents:
diff changeset
   251
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 18
diff changeset
   252
end