Static_type.thy
author chunhan
Tue, 19 Nov 2013 12:31:56 +0800
changeset 67 811e3028d169
parent 43 137358bd4921
permissions -rwxr-xr-x
update grant_check
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
theory Static_type 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     2
imports Main OS_type_def Flask_type OS_type_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     3
begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     4
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     5
(* option: if some \<rightarrow> initial else none \<rightarrow> new created 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     6
 * the constructor each is one-to-one according to security_class_t
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     7
 * but dynamic-special objects are not included, such as:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
 *  1. file-descriptor: C_fd
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     9
 *  2. network node   : C_node
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
 *  3. 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    11
 *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    12
(* Init \<rightarrow> exists in the initial state; Only: the only static object(cannot be cloned, e.g.)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    13
 * Many \<rightarrow> Many instantiation of this static object in the dynamic world 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    14
 * tainted under:
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    15
 *   Init \<rightarrow> this init obj is tainted
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    16
 *   Only \<rightarrow> this new created is tainted
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    17
 *   Many \<rightarrow> at least one of them is tainted or all of them can be tainted
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    18
 *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    19
datatype 'a Instance =
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    20
  Init 'a 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    21
| Created (* new created *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    22
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    23
| Only  (* for process, cannot clone(that means no childprocesses in ss!); 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    24
           for file, renamed init-file(still keeps Init fname!)) *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    25
| Many
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    26
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    27
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    28
(* (fi, file sectxt, parent file's sectxt, ancestral files' sectxts) *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    29
type_synonym t_sfile = "(t_file Instance) \<times> security_context_t \<times> (security_context_t option) \<times> (security_context_t set)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    30
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    31
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    32
type_synonym t_sfn = "(t_fname Instance) \<times> security_context_t"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    33
type_synonym t_sfile = "t_sfn list" (* apparently, "sfile set" is not a finite set! *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    34
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    35
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    36
(* Sroot si sectxt : root sfile 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    37
 * Sfile si sectxt Sdir : normal sfile *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    38
datatype t_sfile = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    39
  Sroot "t_file Instance" "security_context_t"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    40
| Sfile "t_file Instance" "security_context_t" "t_sfile"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    41
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    42
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    43
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    44
(* This is not finite set! think it as nature numbers 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    45
lemma finite_sfile_set: "finite (UNIV::(t_sfile set))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    46
apply (rule finite.intros)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
unfolding UNIV_def
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
apply (induct x rule:t_sfile.induct)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
apply (simp add:UNIV_def)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    50
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
done *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
(* the flags tells the sfile is a file or dir: NO!
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
 * here sfile means sfd is opened to a sfile that has that "type", it is associated with all dynamic
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    55
 * files that according to this sfile. When we need to give such a file instance, we can give any dynamic
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
 * file in that state which according to this sfd's "creating static_state", so we might record ss in fds??
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
 * that means our static is a "(static-state list) set"?? *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    58
type_synonym t_sfd = "(security_context_t \<times> t_open_flags \<times> t_sfile)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
type_synonym t_sshm = "(t_shm Instance \<times> security_context_t)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    61
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    62
type_synonym t_sproc_sshm = "(t_sshm \<times> t_shm_attach_flag)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    63
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    64
(* (si, sectxt, sectxts of fds, sectxt of attached shms) *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    65
type_synonym t_sproc = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    66
  "t_process Instance \<times> security_context_t \<times> (t_sfd set) \<times> (t_sproc_sshm set)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    67
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    68
(* here is a exception, the tainted-flag is in this type, case, msgq will not be-tainted *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    69
type_synonym t_smsg = "t_msg Instance \<times> security_context_t \<times> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    70
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    71
(* (qmi, sectxt, sectxt of queue) *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    72
type_synonym t_smsgq = "t_msgq Instance \<times> security_context_t \<times> (t_smsg list)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    73
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    74
(* O_fd, O_*_sock, O_shm, O_msgq are all that can not be tainted *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    75
datatype t_sobject =
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    76
  S_proc "t_sproc"     "bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    77
| S_file "t_sfile set" "bool"  (* here sfile set is for "linking", tainted is the inode *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
| S_dir  "t_sfile"     
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    79
| S_msgq "t_smsgq"
43
chunhan
parents: 1
diff changeset
    80
| S_shm  "t_sshm"  (*
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    81
| S_msg  "t_smsgq"    "t_smsg"
43
chunhan
parents: 1
diff changeset
    82
*)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    83
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    84
datatype t_tainted_sobj = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    85
  TS_proc "t_sproc"     "bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    86
| TS_file "t_sfile set" "bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    87
| TS_msg  "t_smsgq"     "t_smsg"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    88
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    89
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    90
(* the static state is the current static objects 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    91
 * But, how to record the static fds ??? fd is a dynamic concept !!! 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    92
 *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    93
type_synonym t_static_state = "t_sobject set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    94
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    95
end