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