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 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
definition enrich:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
|
|
13 |
where
|
|
14 |
"enrich s objs s' \<equiv> \<forall> obj \<in> objs. \<exists> obj'. obj' \<notin> objs \<and> alive s' obj \<and> co2sobj s' obj' = co2sobj s' obj"
|
|
15 |
|
|
16 |
definition reserve:: "t_state \<Rightarrow> t_object set \<Rightarrow> t_state \<Rightarrow> bool"
|
|
17 |
where
|
|
18 |
"reserve s objs s' \<equiv> \<forall> obj. alive s obj \<longrightarrow> alive s' obj \<and> co2sobj s' obj = co2sobj s obj"
|
|
19 |
|
|
20 |
definition enrichable :: "t_state \<Rightarrow> t_object set \<Rightarrow> bool"
|
|
21 |
where
|
|
22 |
"enrichable s objs \<equiv> \<exists> s'. valid s' \<and> s2ss s' = s2ss s \<and> enrich s objs s' \<and> reserve s objs s'"
|
|
23 |
|
|
24 |
definition is_created :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
|
|
25 |
where
|
|
26 |
"is_created s obj \<equiv> init_alive obj \<longrightarrow> deleted obj s"
|
|
27 |
|
|
28 |
definition is_inited :: "t_state \<Rightarrow> t_object \<Rightarrow> bool"
|
|
29 |
where
|
|
30 |
"is_inited s obj \<equiv> init_alive obj \<and> \<not> deleted obj s"
|
|
31 |
|
|
32 |
lemma is_inited_eq_not_created:
|
|
33 |
"is_inited s obj = (\<not> is_created s obj)"
|
|
34 |
by (auto simp:is_created_def is_inited_def)
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
lemma d2s_main_execve:
|
|
42 |
"valid (Execve p f fds # s) \<Longrightarrow> s2ss (Execve p f fds # s) \<in> static"
|
|
43 |
apply (frule vd_cons, frule vt_grant_os, clarsimp simp:s2ss_execve)
|
|
44 |
sorry
|
|
45 |
|
|
46 |
lemma d2s_main:
|
|
47 |
"valid s \<Longrightarrow> s2ss s \<propto> static"
|
|
48 |
apply (induct s, simp add:s2ss_nil_prop init_ss_in_def)
|
|
49 |
apply (rule_tac x = "init_static_state" in bexI, simp, simp add:s_init)
|
|
50 |
apply (frule vd_cons, frule vt_grant_os, simp)
|
|
51 |
apply (case_tac a)
|
|
52 |
apply (clarsimp simp add:s2ss_execve)
|
|
53 |
apply (rule conjI, rule impI)
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
sorry
|
|
58 |
|
|
59 |
|
|
60 |
lemma many_sq_imp_sms:
|
|
61 |
"\<lbrakk>S_msgq (Create, sec, sms) \<in> ss; ss \<in> static\<rbrakk> \<Longrightarrow> \<forall> sm \<in> (set sms). is_many_smsg sm"
|
|
62 |
sorry
|
|
63 |
|
|
64 |
|
65
|
65 |
(* recorded in our static world *)
|
|
66 |
fun recorded :: "t_object \<Rightarrow> bool"
|
|
67 |
where
|
|
68 |
"recorded (O_proc p) = True"
|
|
69 |
| "recorded (O_file f) = True"
|
|
70 |
| "recorded (O_dir f) = True"
|
|
71 |
| "recorded (O_node n) = False" (* cause socket is temperary not considered *)
|
|
72 |
| "recorded (O_shm h) = True"
|
|
73 |
| "recorded (O_msgq q) = True"
|
|
74 |
| "recorded _ = False"
|
63
|
75 |
|
|
76 |
lemma enrichability:
|
|
77 |
"\<lbrakk>valid s; \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj\<rbrakk>
|
|
78 |
\<Longrightarrow> enrichable s objs"
|
|
79 |
proof (induct s arbitrary:objs)
|
|
80 |
case Nil
|
|
81 |
hence "objs = {}"
|
|
82 |
apply (auto simp:is_created_def)
|
|
83 |
apply (erule_tac x = x in ballE)
|
|
84 |
apply (auto simp:init_alive_prop)
|
|
85 |
done
|
|
86 |
thus ?case using Nil unfolding enrichable_def enrich_def reserve_def
|
|
87 |
by (rule_tac x = "[]" in exI, auto)
|
|
88 |
next
|
|
89 |
case (Cons e s)
|
|
90 |
hence p1: "\<And> objs. \<forall> obj \<in> objs. alive s obj \<and> is_created s obj \<and> recorded obj \<Longrightarrow> enrichable s objs"
|
|
91 |
and p2: "valid (e # s)" and p3: "\<forall>obj\<in>objs. alive (e # s) obj \<and> is_created (e # s) obj \<and> recorded obj"
|
|
92 |
and os: "os_grant s e" and se: "grant s e" and vd: "valid s"
|
|
93 |
by (auto dest:vt_grant_os vd_cons vt_grant)
|
|
94 |
show ?case sorry (*
|
|
95 |
proof (cases e)
|
|
96 |
case (Execve p f fds)
|
|
97 |
hence p4: "e = Execve p f fds" by simp
|
|
98 |
from p3 have p5: "is_inited s (O_proc p) \<Longrightarrow> (O_proc p) \<notin> objs"
|
|
99 |
by (auto simp:is_created_def is_inited_def p4 elim!:ballE[where x = "O_proc p"])
|
|
100 |
show "enrichable (e # s) objs"
|
|
101 |
proof (case "is_inited s (O_proc p)")
|
|
102 |
apply (simp add:enrichable_def p4)
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
apply auto
|
|
107 |
apply (auto simp:enrichable_def)
|
|
108 |
apply (induct s)
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
done
|
|
113 |
*)
|
|
114 |
qed
|
|
115 |
|
|
116 |
lemma s2d_main:
|
|
117 |
"ss \<in> static \<Longrightarrow> \<exists> s. valid s \<and> s2ss s = ss"
|
|
118 |
apply (erule static.induct)
|
|
119 |
apply (rule_tac x = "[]" in exI, simp add:s2ss_nil_prop valid.intros)
|
|
120 |
|
|
121 |
apply (erule exE|erule conjE)+
|
|
122 |
|
|
123 |
apply (simp add:update_ss_def)
|
|
124 |
|
|
125 |
sorry
|
|
126 |
|
|
127 |
|
|
128 |
end
|
|
129 |
|
|
130 |
end |