Static.thy
author chunhan
Mon, 23 Dec 2013 19:47:17 +0800
changeset 82 0a68c605ae79
parent 74 271e9818b6f6
permissions -rwxr-xr-x
update
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     1
theory Static
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     2
imports Static_type OS_type_def Flask_type Flask
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
locale tainting_s = tainting 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     6
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     7
begin
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     8
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
     9
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    10
definition init_sectxt_of_file:: "t_file \<Rightarrow> security_context_t option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    11
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    12
  "init_sectxt_of_file f \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    13
     if (is_init_file f) then init_sectxt_of_obj (O_file f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    14
     else if (is_init_dir f) then init_sectxt_of_obj (O_dir f)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    15
     else None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    16
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    17
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    18
definition sroot :: "t_sfile"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    19
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    20
  "sroot \<equiv> (Init [], sec_of_root, None, {})"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    21
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    22
definition init_cf2sfile :: "t_file \<Rightarrow> t_sfile option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    23
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    24
  "init_cf2sfile f \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    25
     case (parent f) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    26
       None \<Rightarrow> Some sroot
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    27
     | Some pf \<Rightarrow> if (is_init_file f) then 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    28
 (case (init_sectxt_of_obj (O_file f), init_sectxt_of_obj (O_dir pf), get_parentfs_ctxts [] pf) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    29
    (Some sec, Some psec, Some aseclist) \<Rightarrow> Some (Init f, sec, Some psec, set aseclist)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    30
  | _ \<Rightarrow> None)    else 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    31
 (case (init_sectxt_of_obj (O_dir f), init_sectxt_of_obj (O_dir pf), get_parentfs_ctxts [] pf) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    32
    (Some sec, Some psec, Some aseclist) \<Rightarrow> Some (Init f, sec, Some psec, set aseclist)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    33
  | _ \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    34
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 2
diff changeset
    35
definition init_cf2sfiles :: "t_file \<Rightarrow> t_sfile set"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    36
where
6
8779d321cc2e remove duplicated pre-condition of current_files in OS_grant, since it is property if is_file/is_dir.
chunhan
parents: 2
diff changeset
    37
  "init_cf2sfiles f \<equiv> {sf. \<exists>f' \<in> init_same_inode_files f. init_cf2sfile f' = Some sf}"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    38
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    39
definition init_cfd2sfd :: "t_process \<Rightarrow> t_fd \<Rightarrow> (security_context_t \<times> t_open_flags \<times> t_sfile) option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    40
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    41
  "init_cfd2sfd p fd = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    42
     (case (init_file_of_proc_fd p fd, init_oflags_of_proc_fd p fd, init_sectxt_of_obj (O_fd p fd)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    43
        (Some f, Some flags, Some sec) \<Rightarrow> (case (init_cf2sfile f) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    44
                                             Some sf \<Rightarrow> Some (sec, flags, sf)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    45
                                           | _ \<Rightarrow> None)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    46
      | _ \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    47
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    48
definition init_cfds2sfds :: "t_process \<Rightarrow> (security_context_t \<times> t_open_flags \<times> t_sfile) set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    49
where
12
47a4b2ae0556 Modify definitions of cpfd2sfds
chunhan
parents: 11
diff changeset
    50
  "init_cfds2sfds p \<equiv> { sfd. \<exists> fd \<in> init_proc_file_fds p. init_cfd2sfd p fd = Some sfd}"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    51
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    52
definition init_ch2sshm :: "t_shm \<Rightarrow> t_sshm option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    53
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    54
  "init_ch2sshm h \<equiv> (case (init_sectxt_of_obj (O_shm h)) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    55
                       Some sec \<Rightarrow> Some (Init h, sec)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    56
                     | _        \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    57
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    58
definition init_cph2spshs 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    59
  :: "t_process \<Rightarrow> (t_sshm \<times> t_shm_attach_flag) set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    60
where
15
4ca824cd0c59 finally get cph2spshs_attach done
chunhan
parents: 12
diff changeset
    61
  "init_cph2spshs p \<equiv> {(sh, flag)| sh flag h. (p, flag) \<in> init_procs_of_shm h \<and> 
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    62
                                             init_ch2sshm h = Some sh}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    63
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    64
definition init_cp2sproc :: "t_process \<Rightarrow> t_sproc option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    65
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    66
  "init_cp2sproc p \<equiv> (case (init_sectxt_of_obj (O_proc p)) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    67
       Some sec \<Rightarrow> Some (Init p, sec, (init_cfds2sfds p), (init_cph2spshs p))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    68
     | None     \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    69
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    70
(* acient files of init-file 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    71
definition init_o2s_afs :: "t_file \<Rightarrow> security_context_t set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    72
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    73
  "init_o2s_afs f \<equiv> {sec. \<exists> f'. f' \<preceq> f \<and> init_sectxt_of_obj (O_dir f') = Some sec}" *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    74
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    75
definition init_cm2smsg :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    76
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    77
  "init_cm2smsg q m \<equiv> (case (init_sectxt_of_obj (O_msg q m)) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    78
                         Some sec \<Rightarrow> Some (Init m, sec, (O_msg q m) \<in> seeds)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    79
                       | _ \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    80
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    81
fun init_cqm2sms :: "t_msgq \<Rightarrow> t_msg list \<Rightarrow> (t_smsg list) option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    82
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    83
  "init_cqm2sms q []     = Some []"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    84
| "init_cqm2sms q (m#ms) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    85
     (case (init_cqm2sms q ms, init_cm2smsg q m) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    86
        (Some sms, Some sm) \<Rightarrow> Some (sm # sms)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    87
      | _        \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    88
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    89
definition init_cq2smsgq :: "t_msgq \<Rightarrow> t_smsgq option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    90
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    91
  "init_cq2smsgq q \<equiv> (case (init_sectxt_of_obj (O_msgq q), init_cqm2sms q (init_msgs_of_queue q)) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    92
       (Some sec, Some sms) \<Rightarrow> Some (Init q, sec, sms)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    93
     | _ \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    94
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    95
fun init_obj2sobj :: "t_object \<Rightarrow> t_sobject option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    96
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    97
  "init_obj2sobj (O_proc p) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    98
     (case (init_cp2sproc p) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
    99
       Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> seeds))
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   100
     | _ \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   101
| "init_obj2sobj (O_file f) = 
37
029cccce84b4 remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents: 34
diff changeset
   102
     Some (S_file (init_cf2sfiles f) 
029cccce84b4 remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents: 34
diff changeset
   103
                  (\<exists> f'. f' \<in> (init_same_inode_files f) \<and> O_file f \<in> seeds))"
39
13bba99ca090 done with co2sobj_simps
chunhan
parents: 37
diff changeset
   104
| "init_obj2sobj (O_dir f) = 
37
029cccce84b4 remove in-current constrains from co2sobj, alive already does this job in co2sobj's properties
chunhan
parents: 34
diff changeset
   105
     (case (init_cf2sfile f) of
39
13bba99ca090 done with co2sobj_simps
chunhan
parents: 37
diff changeset
   106
           Some sf \<Rightarrow> Some (S_dir sf) 
13bba99ca090 done with co2sobj_simps
chunhan
parents: 37
diff changeset
   107
         | _ \<Rightarrow> None)"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   108
| "init_obj2sobj (O_msgq q) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   109
     (case (init_cq2smsgq q) of
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   110
       Some sq \<Rightarrow> Some (S_msgq sq)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   111
     | _ \<Rightarrow> None)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   112
| "init_obj2sobj (O_shm h) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   113
     (case (init_ch2sshm h) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   114
       Some sh \<Rightarrow> Some (S_shm sh)
34
e7f850d1e08e remove O_msg from co2sobj/init_obj2sobj
chunhan
parents: 33
diff changeset
   115
     | _       \<Rightarrow> None)"  (*
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   116
| "init_obj2sobj (O_msg q m) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   117
     (case (init_cq2smsgq q, init_cm2smsg q m) of 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   118
        (Some sq, Some sm) \<Rightarrow> Some (S_msg sq sm)
34
e7f850d1e08e remove O_msg from co2sobj/init_obj2sobj
chunhan
parents: 33
diff changeset
   119
      | _                  \<Rightarrow> None)" *)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   120
| "init_obj2sobj _ = None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   121
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   122
definition  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   123
  "init_static_state \<equiv> {sobj. \<exists> obj. init_alive obj \<and> init_obj2sobj obj = Some sobj}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   124
65
chunhan
parents: 61
diff changeset
   125
(**************** translation from dynamic to static *******************)
chunhan
parents: 61
diff changeset
   126
chunhan
parents: 61
diff changeset
   127
definition cf2sfile :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile option"
chunhan
parents: 61
diff changeset
   128
where
chunhan
parents: 61
diff changeset
   129
  "cf2sfile s f \<equiv>
chunhan
parents: 61
diff changeset
   130
     case (parent f) of 
chunhan
parents: 61
diff changeset
   131
       None \<Rightarrow> Some sroot
chunhan
parents: 61
diff changeset
   132
     | Some pf \<Rightarrow> if (is_file s f) 
chunhan
parents: 61
diff changeset
   133
     then (case (sectxt_of_obj s (O_file f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of
chunhan
parents: 61
diff changeset
   134
            (Some sec, Some psec, Some asecs) \<Rightarrow>
chunhan
parents: 61
diff changeset
   135
 Some (if (\<not> deleted (O_file f) s \<and> is_init_file f) then Init f else Created, sec, Some psec, set asecs)
chunhan
parents: 61
diff changeset
   136
          | _ \<Rightarrow> None) 
chunhan
parents: 61
diff changeset
   137
     else (case (sectxt_of_obj s (O_dir f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of
chunhan
parents: 61
diff changeset
   138
            (Some sec, Some psec, Some asecs) \<Rightarrow>
chunhan
parents: 61
diff changeset
   139
 Some (if (\<not> deleted (O_dir f) s \<and> is_init_dir f) then Init f else Created, sec, Some psec, set asecs)
chunhan
parents: 61
diff changeset
   140
          | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   141
chunhan
parents: 61
diff changeset
   142
definition cf2sfiles :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile set"
chunhan
parents: 61
diff changeset
   143
where
chunhan
parents: 61
diff changeset
   144
  "cf2sfiles s f \<equiv> {sf. \<exists> f' \<in> (same_inode_files s f). cf2sfile s f' = Some sf}"
chunhan
parents: 61
diff changeset
   145
chunhan
parents: 61
diff changeset
   146
(* here cf2sfile is passed with True, because, process' fds are only for files not dirs *)
chunhan
parents: 61
diff changeset
   147
definition cfd2sfd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd \<Rightarrow> t_sfd option" 
chunhan
parents: 61
diff changeset
   148
where
chunhan
parents: 61
diff changeset
   149
  "cfd2sfd s p fd \<equiv> 
chunhan
parents: 61
diff changeset
   150
    (case (file_of_proc_fd s p fd, flags_of_proc_fd s p fd, sectxt_of_obj s (O_fd p fd)) of
chunhan
parents: 61
diff changeset
   151
      (Some f, Some flags, Some sec) \<Rightarrow> (case (cf2sfile s f) of 
chunhan
parents: 61
diff changeset
   152
                                          Some sf \<Rightarrow> Some (sec, flags, sf)
chunhan
parents: 61
diff changeset
   153
                                        | _       \<Rightarrow> None)
chunhan
parents: 61
diff changeset
   154
    | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   155
chunhan
parents: 61
diff changeset
   156
chunhan
parents: 61
diff changeset
   157
definition cpfd2sfds :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sfd set"
chunhan
parents: 61
diff changeset
   158
where
chunhan
parents: 61
diff changeset
   159
  "cpfd2sfds s p \<equiv> {sfd. \<exists> fd \<in> proc_file_fds s p. cfd2sfd s p fd = Some sfd}"
chunhan
parents: 61
diff changeset
   160
chunhan
parents: 61
diff changeset
   161
definition ch2sshm :: "t_state \<Rightarrow> t_shm \<Rightarrow> t_sshm option"
chunhan
parents: 61
diff changeset
   162
where
chunhan
parents: 61
diff changeset
   163
  "ch2sshm s h \<equiv> (case (sectxt_of_obj s (O_shm h)) of
chunhan
parents: 61
diff changeset
   164
                    Some sec \<Rightarrow> 
chunhan
parents: 61
diff changeset
   165
 Some (if (\<not> deleted (O_shm h) s \<and> h \<in> init_shms) then Init h else Created, sec)
chunhan
parents: 61
diff changeset
   166
                  | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   167
chunhan
parents: 61
diff changeset
   168
definition cph2spshs :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc_sshm set"
chunhan
parents: 61
diff changeset
   169
where
chunhan
parents: 61
diff changeset
   170
  "cph2spshs s p \<equiv> {(sh, flag)| sh flag h. (p, flag) \<in> procs_of_shm s h \<and> ch2sshm s h = Some sh}"
chunhan
parents: 61
diff changeset
   171
chunhan
parents: 61
diff changeset
   172
definition cp2sproc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc option"
chunhan
parents: 61
diff changeset
   173
where
chunhan
parents: 61
diff changeset
   174
  "cp2sproc s p \<equiv> (case (sectxt_of_obj s (O_proc p)) of 
chunhan
parents: 61
diff changeset
   175
                     Some sec \<Rightarrow> 
chunhan
parents: 61
diff changeset
   176
 Some (if (\<not> deleted (O_proc p) s \<and> p \<in> init_procs) then Init p else Created, sec, 
chunhan
parents: 61
diff changeset
   177
       cpfd2sfds s p, cph2spshs s p)
chunhan
parents: 61
diff changeset
   178
                   | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   179
chunhan
parents: 61
diff changeset
   180
definition cm2smsg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option"
chunhan
parents: 61
diff changeset
   181
where
chunhan
parents: 61
diff changeset
   182
  "cm2smsg s q m \<equiv> (case (sectxt_of_obj s (O_msg q m)) of 
chunhan
parents: 61
diff changeset
   183
                      Some sec \<Rightarrow>
chunhan
parents: 61
diff changeset
   184
 Some (if (\<not> deleted (O_msg q m) s \<and> m \<in> set (init_msgs_of_queue q)) then Init m else Created,
chunhan
parents: 61
diff changeset
   185
       sec, O_msg q m \<in> tainted s)
chunhan
parents: 61
diff changeset
   186
                    | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   187
chunhan
parents: 61
diff changeset
   188
fun cqm2sms:: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg list \<Rightarrow> (t_smsg list) option"
chunhan
parents: 61
diff changeset
   189
where 
chunhan
parents: 61
diff changeset
   190
  "cqm2sms s q [] = Some []"
chunhan
parents: 61
diff changeset
   191
| "cqm2sms s q (m#ms) = 
chunhan
parents: 61
diff changeset
   192
     (case (cqm2sms s q ms, cm2smsg s q m) of 
chunhan
parents: 61
diff changeset
   193
       (Some sms, Some sm) \<Rightarrow> Some (sm#sms) 
chunhan
parents: 61
diff changeset
   194
     | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   195
chunhan
parents: 61
diff changeset
   196
definition cq2smsgq :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_smsgq option"
chunhan
parents: 61
diff changeset
   197
where
chunhan
parents: 61
diff changeset
   198
  "cq2smsgq s q \<equiv> (case (sectxt_of_obj s (O_msgq q), cqm2sms s q (msgs_of_queue s q)) of 
chunhan
parents: 61
diff changeset
   199
                     (Some sec, Some sms) \<Rightarrow> 
chunhan
parents: 61
diff changeset
   200
 Some (if (\<not> deleted (O_msgq q) s \<and> q \<in> init_msgqs) then Init q else Created,
chunhan
parents: 61
diff changeset
   201
       sec, sms)
chunhan
parents: 61
diff changeset
   202
                   | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   203
chunhan
parents: 61
diff changeset
   204
fun co2sobj :: "t_state \<Rightarrow> t_object \<Rightarrow> t_sobject option"
chunhan
parents: 61
diff changeset
   205
where
chunhan
parents: 61
diff changeset
   206
  "co2sobj s (O_proc p) = 
chunhan
parents: 61
diff changeset
   207
     (case (cp2sproc s p) of 
chunhan
parents: 61
diff changeset
   208
        Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s))
chunhan
parents: 61
diff changeset
   209
      | _       \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   210
| "co2sobj s (O_file f) = 
chunhan
parents: 61
diff changeset
   211
     Some (S_file (cf2sfiles s f) (O_file f \<in> tainted s))"
chunhan
parents: 61
diff changeset
   212
| "co2sobj s (O_dir f) = 
chunhan
parents: 61
diff changeset
   213
     (case (cf2sfile s f) of
chunhan
parents: 61
diff changeset
   214
        Some sf  \<Rightarrow> Some (S_dir sf)
chunhan
parents: 61
diff changeset
   215
      | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   216
| "co2sobj s (O_msgq q) = 
chunhan
parents: 61
diff changeset
   217
     (case (cq2smsgq s q) of
chunhan
parents: 61
diff changeset
   218
        Some sq \<Rightarrow> Some (S_msgq sq)
chunhan
parents: 61
diff changeset
   219
      | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   220
| "co2sobj s (O_shm h) = 
chunhan
parents: 61
diff changeset
   221
     (case (ch2sshm s h) of 
chunhan
parents: 61
diff changeset
   222
        Some sh \<Rightarrow> Some (S_shm sh)
chunhan
parents: 61
diff changeset
   223
      | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   224
(*
chunhan
parents: 61
diff changeset
   225
| "co2sobj s (O_msg q m) = 
chunhan
parents: 61
diff changeset
   226
     (case (cq2smsgq s q, cm2smsg s q m) of 
chunhan
parents: 61
diff changeset
   227
       (Some sq, Some sm) \<Rightarrow> Some (S_msg sq sm)
chunhan
parents: 61
diff changeset
   228
     | _ \<Rightarrow> None)"
chunhan
parents: 61
diff changeset
   229
*)
chunhan
parents: 61
diff changeset
   230
| "co2sobj s _ = None"
chunhan
parents: 61
diff changeset
   231
chunhan
parents: 61
diff changeset
   232
chunhan
parents: 61
diff changeset
   233
definition s2ss :: "t_state \<Rightarrow> t_static_state"
chunhan
parents: 61
diff changeset
   234
where
chunhan
parents: 61
diff changeset
   235
  "s2ss s \<equiv> {sobj. \<exists> obj. alive s obj \<and> co2sobj s obj = Some sobj}"
chunhan
parents: 61
diff changeset
   236
chunhan
parents: 61
diff changeset
   237
chunhan
parents: 61
diff changeset
   238
(* ******************************************************** *)
chunhan
parents: 61
diff changeset
   239
chunhan
parents: 61
diff changeset
   240
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   241
fun is_init_sfile :: "t_sfile \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   242
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   243
  "is_init_sfile (Init _, sec, psec,asec) = True"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   244
| "is_init_sfile _ = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   245
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   246
fun is_many_sfile :: "t_sfile \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   247
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   248
  "is_many_sfile (Created, sec, psec, asec) = True"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   249
| "is_many_sfile _ = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   250
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   251
fun is_init_sproc :: "t_sproc \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   252
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   253
  "is_init_sproc (Init p, sec, fds, shms) = True"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   254
| "is_init_sproc _                        = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   255
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   256
fun is_many_sproc :: "t_sproc \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   257
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   258
  "is_many_sproc (Created, sec,fds,shms) = True"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   259
| "is_many_sproc _                       = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   260
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   261
fun is_many_smsg :: "t_smsg \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   262
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   263
  "is_many_smsg (Created,sec,tag) = True"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   264
| "is_many_smsg _                 = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   265
61
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   266
(* wrong def 
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   267
fun is_many_smsgq :: "t_smsgq \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   268
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   269
  "is_many_smsgq (Created,sec,sms) = (True \<and> (\<forall> sm \<in> (set sms). is_many_smsg sm))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   270
| "is_many_smsgq _                 = False"
61
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   271
*)
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   272
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   273
fun is_many_smsgq :: "t_smsgq \<Rightarrow> bool"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   274
where
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   275
  "is_many_smsgq (Created,sec,sms) = True"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   276
| "is_many_smsgq _                 = False"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   277
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   278
fun is_many_sshm :: "t_sshm \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   279
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   280
  "is_many_sshm (Created, sec) = True"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   281
| "is_many_sshm _              = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   282
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   283
fun is_many :: "t_sobject \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   284
where
42
chunhan
parents: 39
diff changeset
   285
  "is_many (S_proc sp   tag) = is_many_sproc sp"
chunhan
parents: 39
diff changeset
   286
| "is_many (S_file sfs  tag) = (\<forall> sf \<in> sfs. is_many_sfile sf)"
chunhan
parents: 39
diff changeset
   287
| "is_many (S_dir  sf      ) = is_many_sfile sf"
chunhan
parents: 39
diff changeset
   288
| "is_many (S_msgq sq      ) = is_many_smsgq sq"
chunhan
parents: 39
diff changeset
   289
| "is_many (S_shm  sh      ) = is_many_sshm  sh"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   290
61
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   291
fun is_init_smsgq :: "t_smsgq \<Rightarrow> bool"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   292
where
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   293
  "is_init_smsgq (Init q,sec,sms) = True"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   294
| "is_init_smsgq _                = False"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   295
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   296
fun is_init_sshm :: "t_sshm \<Rightarrow> bool"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   297
where
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   298
  "is_init_sshm (Init h,sec) = True"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   299
| "is_init_sshm _            = False"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   300
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   301
fun is_init_sobj :: "t_sobject \<Rightarrow> bool"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   302
where
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   303
  "is_init_sobj (S_proc sp tag ) = is_init_sproc sp"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   304
| "is_init_sobj (S_file sfs tag) = (\<exists> sf \<in> sfs. is_init_sfile sf)"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   305
| "is_init_sobj (S_dir  sf     ) = is_init_sfile sf"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   306
| "is_init_sobj (S_msgq sq     ) = is_init_smsgq sq"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   307
| "is_init_sobj (S_shm  sh     ) = is_init_sshm sh"
0d219ddd6354 appropriate object for taintable
chunhan
parents: 56
diff changeset
   308
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   309
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   310
fun update_ss_sp:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   311
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   312
  "update_ss_sp ss (S_proc sp tag) (S_proc sp' tag') = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   313
     (if (is_many_sproc sp) then ss \<union> {S_proc sp' tag'} 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   314
      else (ss - {S_proc sp tag}) \<union> {S_proc sp' tag'})"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   315
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   316
fun update_ss_sd:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   317
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   318
  "update_ss_sd ss (S_dir sf tag) (S_dir sf' tag') = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   319
     (if (is_many_sfile sf) then ss \<union> {S_dir sf' tag'} 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   320
      else (ss - {S_dir sf tag}) \<union> {S_dir sf' tag'})"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   321
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   322
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   323
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   324
fun sparent :: "t_sfile \<Rightarrow> t_sfile option"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   325
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   326
  "sparent (Sroot si sec) = None"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   327
| "sparent (Sfile si sec spf) = Some spf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   328
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   329
inductive is_ancesf :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   330
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   331
  "is_ancesf sf sf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   332
| "sparent sf = Some spf \<Longrightarrow> is_ancesf spf sf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   333
| "\<lbrakk>sparent sf = Some spf; is_ancesf saf spf\<rbrakk> \<Longrightarrow> is_ancesf saf sf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   334
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   335
definition sfile_reparent :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   336
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   337
  "sfile_reparent (Sroot)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   338
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   339
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   340
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   341
(* sfds rename aux definitions *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   342
definition sfds_rename_notrelated 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   343
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   344
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   345
  "sfds_rename_notrelated sfds from to sfds' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   346
     (\<forall> sec flag sf. (sec,flag,sf) \<in> sfds \<and> (\<not> from \<preceq> sf) \<longrightarrow> (sec,flag,sf) \<in> sfds')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   347
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   348
definition sfds_rename_renamed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   349
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   350
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   351
  "sfds_rename_renamed sfds sf from to sfds' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   352
     (\<forall> sec flag sf'. (sec,flag,sf) \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   353
         (sec, flag, file_after_rename sf' from to) \<in> sfds' \<and> (sec,flag,sf) \<notin> sfds')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   354
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   355
definition sfds_rename_remain
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   356
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   357
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   358
  "sfds_rename_remain sfds sf from to sfds' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   359
     (\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   360
         (sec, flag, sf') \<in> sfds' \<and> (sec,flag, file_after_rename sf' from to) \<notin> sfds')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   361
74
271e9818b6f6 remove shm and linkhard, make a simplified version of selinux
chunhan
parents: 67
diff changeset
   362
  (* for not many, choose on renamed or not *)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   363
definition sfds_rename_choices
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   364
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   365
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   366
  "sfds_rename_choices sfds sf from to sfds' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   367
     sfds_rename_remain sfds sf from to sfds' \<or> sfds_rename_renamed sfds sf from to sfds'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   368
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   369
(* for many, merge renamed with not renamed *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   370
definition sfds_rename_both
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   371
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   372
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   373
  "sfds_rename_both sfds sf from to sfds' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   374
     (\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   375
         (sec, flag, sf') \<in> sfds' \<or> (sec,flag, file_after_rename sf' from to) \<in> sfds')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   376
  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   377
(* added to the new sfds, are those only under the new sfile *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   378
definition sfds_rename_added
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   379
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   380
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   381
  "sfds_rename_added sfds from to sfds' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   382
     (\<forall> sec' flag' sf' sec flag. (sec',flag',sf') \<in> sfds' \<and> (sec,flag,sf') \<notin> sfds \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   383
        (\<exists> sf. (sec,flag,sf) \<in> sfds \<and> sf' = file_after_rename from to sf))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   384
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   385
definition sproc_sfds_renamed
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   386
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   387
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   388
  "sproc_sfds_renamed ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   389
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   390
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_renamed sfds sf from to sfds'))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   391
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   392
definition sproc_sfds_remain
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   393
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   394
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   395
  "sproc_sfds_remain ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   396
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   397
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_remain sfds sf from to sfds'))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   398
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   399
(* for not many, choose on renamed or not *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   400
definition sproc_sfds_choices
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   401
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   402
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   403
  "sproc_sfds_choices ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   404
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   405
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_choices sfds sf from to sfds'))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   406
  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   407
(* for many, merge renamed with not renamed *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   408
definition sproc_sfds_both
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   409
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   410
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   411
  "sproc_sfds_both ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   412
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   413
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_both sfds sf from to sfds'))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   414
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   415
(* remove (\<forall> sp tag. S_proc sp tag \<in> ss \<longrightarrow> S_proc sp tag \<in> ss'),
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   416
 * cause sfds contains sfs informations *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   417
definition ss_rename_notrelated 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   418
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   419
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   420
  "ss_rename_notrelated ss sf sf' ss' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   421
     (\<forall> sq. S_msgq sq \<in> ss \<longrightarrow> S_msgq sq \<in> ss') \<and> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   422
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> (\<exists> sfds'.  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   423
         S_proc (pi,sec,sfds',sshms) tagp \<in> ss'\<and> sfds_rename_notrelated sfds sf sf' sfds'))  \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   424
     (\<forall> sfs sf'' tag. S_file sfs tag \<in> ss \<and> sf'' \<in> sfs \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> (\<exists> sfs'. 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   425
         S_file sfs tag \<in> ss' \<and> sf'' \<in> sfs')) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   426
     (\<forall> sf'' tag. S_dir sf'' tag \<in> ss \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> S_dir sf'' tag \<in> ss')" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   427
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   428
(* rename from to, from should definited renamed if not many *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   429
definition all_descendant_sf_renamed 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   430
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   431
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   432
  "all_descendant_sf_renamed ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   433
     (\<forall> sfs sf' tagf. sf \<preceq> sf' \<and> S_file sfs tagf \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   434
       S_file sfs' tagf \<in> ss' \<and> file_after_rename from to sf' \<in> sfs' \<and> sf' \<notin> sfs')) \<and> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   435
     (\<forall> sf' tagf. sf \<preceq> sf' \<and> S_dir sf' tagf \<in> ss \<longrightarrow> S_dir (file_after_rename from to sf') tagf \<in> ss' \<and> S_dir sf' tagf \<notin> ss') \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   436
     sproc_sfds_renamed ss sf from to ss'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   437
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   438
(* not renamed *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   439
definition all_descendant_sf_remain
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   440
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   441
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   442
  "all_descendant_sf_remain ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   443
     (\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   444
       S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<notin> sfs' \<and> sf' \<in> sfs')) \<and> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   445
     (\<forall> sf' tag'. sf \<preceq> sf' \<and> S_dir sf' tag' \<in> ss \<longrightarrow> S_dir (file_after_rename from to sf') tag' \<notin> ss' \<and> S_dir sf' tag' \<in> ss') \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   446
     sproc_sfds_remain ss sf from to ss'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   447
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   448
definition all_descendant_sf_choices
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   449
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   450
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   451
  "all_descendant_sf_choices ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   452
     all_descendant_sf_renamed ss sf from to ss' \<or> all_descendant_sf_remain ss sf from to ss'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   453
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   454
definition all_descendant_sf_both
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   455
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   456
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   457
  "all_descendant_sf_both ss sf from to ss' \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   458
     (\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   459
        S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<in> sfs' \<or> sf' \<in> sfs')) \<and> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   460
     (\<forall> sf' tag'. sf \<preceq> sf' \<and> S_dir sf' tag' \<in> ss \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   461
        S_dir (file_after_rename from to sf') tag' \<in> ss' \<or> S_dir sf' tag' \<in> ss') \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   462
     sproc_sfds_both ss sf from to ss'"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   463
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   464
definition ss_renamed_file 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   465
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   466
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   467
  "ss_renamed_file ss sf sf' ss' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   468
     (if (is_many_sfile sf) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   469
        then all_descendant_sf_choices ss sf sf sf' ss'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   470
        else all_descendant_sf_renamed ss sf sf sf' ss')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   471
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   472
(* added to the new sfs, are those only under the new sfile *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   473
definition sfs_rename_added
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   474
  :: "t_sfile set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   475
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   476
  "sfs_rename_added sfs from to sfs' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   477
     (\<forall> sf'. sf' \<in> sfs' \<and> sf' \<notin> sfs \<longrightarrow> (\<exists> sf. sf \<in> sfs \<and> sf' = file_after_rename from to sf))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   478
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   479
(* added to the new sfile, are those only under the new sfile *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   480
definition ss_rename_added
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   481
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   482
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   483
  "ss_rename_added ss from to ss' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   484
     (\<forall> pi sec fds fds' shms tagp. S_proc (pi, sec, fds,shms) tagp \<in> ss \<and> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   485
        S_proc (pi,sec,fds',shms) tagp \<in> ss' \<longrightarrow> sfds_rename_added fds from to fds') \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   486
     (\<forall> sq. S_msgq sq \<in> ss' \<longrightarrow> S_msgq sq \<in> ss) \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   487
     (\<forall> sfs sfs' tagf. S_file sfs' tagf \<in> ss' \<and> S_file sfs tagf \<in> ss \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   488
        sfs_rename_added sfs from to sfs') \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   489
     (\<forall> sf' tagf. S_dir sf' tagf \<in> ss' \<and> S_dir sf' tagf \<notin> ss \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   490
        (\<exists> sf. S_dir sf tagf \<in> ss \<and> sf' = file_after_rename from to sf))" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   491
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   492
definition sfile_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   493
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   494
  "sfile_alive ss sf \<equiv> (\<exists> sfs tagf. sf \<in> sfs \<and> S_file sfs tagf \<in> ss)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   495
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   496
definition sf_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   497
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   498
  "sf_alive ss sf \<equiv> (\<exists> tagd. S_dir sf tagd \<in> ss) \<or> sfile_alive ss sf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   499
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   500
(* constrains that the new static state should satisfy *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   501
definition ss_rename:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   502
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   503
  "ss_rename ss sf sf' ss' \<equiv> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   504
     ss_rename_notrelated ss sf sf' ss' \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   505
     ss_renamed_file ss sf sf' ss' \<and> ss_rename_added ss sf sf' ss' \<and>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   506
     (\<forall> sf''. sf_alive ss sf'' \<and> sf \<prec> sf'' \<longrightarrow> 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   507
       (if (is_many_sfile sf'') 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   508
        then all_descendant_sf_choices ss sf'' sf sf' ss'
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   509
        else all_descendant_sf_both ss sf'' sf sf' ss'))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   510
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   511
(* two sfile, the last fname should not be equal *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   512
fun sfile_same_fname:: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   513
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   514
  "sfile_same_fname ((Init n, sec)#spf) ((Init n', sec')#spf') = (n = n')"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   515
| "sfile_same_fname _                   _                      = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   516
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   517
(* no same init sfile/only sfile in the target-to spf, should be in static_state addmissble check *)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   518
definition ss_rename_no_same_fname:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   519
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   520
  "ss_rename_no_same_fname ss from spf \<equiv>
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   521
    \<not> (\<exists> to. sfile_same_fname from to \<and> parent to = Some spf \<and> sf_alive ss to)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   522
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   523
(* is not a function, is a relation (one 2 many)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   524
definition update_ss_rename :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   525
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   526
  "update_ss_rename ss sf sf' \<equiv> if (is_many_sfile sf) 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   527
     then (ss \<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss}
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   528
              \<union> {S_dir  (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss})
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   529
     else (ss - {S_file sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss}
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   530
              - {S_dir  sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss})
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   531
              \<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss}
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   532
              \<union> {S_dir  (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   533
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   534
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   535
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   536
fun sectxt_of_sproc :: "t_sproc \<Rightarrow> security_context_t"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   537
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   538
  "sectxt_of_sproc (pi,sec,fds,shms) = sec"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   539
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   540
fun sectxt_of_sfile :: "t_sfile \<Rightarrow> security_context_t"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   541
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   542
  "sectxt_of_sfile (fi,sec,psec,asecs) = sec"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   543
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   544
fun asecs_of_sfile :: "t_sfile \<Rightarrow> security_context_t set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   545
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   546
  "asecs_of_sfile (fi,sec,psec,asecs) = asecs"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   547
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   548
definition search_check_s :: "security_context_t \<Rightarrow> t_sfile \<Rightarrow> bool \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   549
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   550
  "search_check_s pctxt sf if_file = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   551
    (if if_file 
67
811e3028d169 update grant_check
chunhan
parents: 65
diff changeset
   552
      then search_check_ctxt pctxt (sectxt_of_sfile sf) (asecs_of_sfile sf) True
811e3028d169 update grant_check
chunhan
parents: 65
diff changeset
   553
      else search_check_ctxt pctxt (sectxt_of_sfile sf) (asecs_of_sfile sf) False)"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   554
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   555
definition sectxts_of_sfds :: "t_sfd set \<Rightarrow> security_context_t set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   556
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   557
  "sectxts_of_sfds sfds \<equiv> {ctxt. \<exists> flag sf. (ctxt, flag, sf) \<in> sfds}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   558
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   559
definition inherit_fds_check_s :: "security_context_t \<Rightarrow> t_sfd set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   560
where
67
811e3028d169 update grant_check
chunhan
parents: 65
diff changeset
   561
  "inherit_fds_check_s pctxt sfds \<equiv> inherit_fds_check_ctxt pctxt (sectxts_of_sfds sfds)"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   562
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   563
definition sectxts_of_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> security_context_t set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   564
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   565
  "sectxts_of_sproc_sshms sshms \<equiv> {ctxt. \<exists> hi flag. ((hi, ctxt),flag) \<in> sshms}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   566
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   567
definition inherit_shms_check_s :: "security_context_t \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   568
where
67
811e3028d169 update grant_check
chunhan
parents: 65
diff changeset
   569
  "inherit_shms_check_s pctxt sshms \<equiv> inherit_shms_check_ctxt pctxt (sectxts_of_sproc_sshms sshms)"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   570
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   571
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   572
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   573
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   574
  "info_flow_sshm (pi,sec,fds,shms) (pi',sec',fds',shms') = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   575
     (\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   576
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   577
definition info_flow_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   578
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   579
  "info_flow_sproc_sshms shms shms' \<equiv> (\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   580
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: 20
diff changeset
   581
(*
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   582
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   583
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   584
  "info_flow_sshm (pi,sec,fds,shms) (pi',sec',fds',shms') = info_flow_sproc_sshms shms shms'"
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: 20
diff changeset
   585
*)
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: 20
diff changeset
   586
inductive info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool"
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 20
diff changeset
   587
where
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 20
diff changeset
   588
  "info_flow_sshm sp sp"
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: 20
diff changeset
   589
| "\<lbrakk>info_flow_sshm sp (pi,sec,fds,shms); info_flow_sproc_sshms shms shms'\<rbrakk>
259a50be4381 wrong of info-flow-shm, it is a inductive(transitive) notion, not a simple relation just between 2 nodes, more information, see 5.7 of ideas_of_selinux.txt
chunhan
parents: 20
diff changeset
   590
   \<Longrightarrow> info_flow_sshm sp (pi',sec',fds',shms')"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   591
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   592
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   593
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   594
fun smsg_related :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   595
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   596
  "smsg_related m []                   = False" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   597
| "smsg_related m ((mi, sec, tag)#sms) =  
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   598
    (if (mi = Init m) then True else smsg_related m sms)" 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   599
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   600
fun smsgq_smsg_related :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   601
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   602
  "smsgq_smsg_related q m (qi, sec, smsgslist) = ((qi = Init q) \<and> (smsg_related m smsgslist))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   603
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   604
fun smsg_relatainted :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   605
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   606
  "smsg_relatainted m []                     = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   607
| "smsg_relatainted m ((mi, sec, tag)#sms) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   608
    (if (mi = Init m \<and> tag = True) then True else smsg_relatainted m sms)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   609
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   610
fun smsgq_smsg_relatainted :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   611
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   612
  "smsgq_smsg_relatainted q m (qi, sec, smsgslist) = 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   613
     ((qi = Init q) \<and> (smsg_relatainted m smsgslist))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   614
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   615
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   616
fun sfile_related :: "t_sfile \<Rightarrow> t_file \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   617
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   618
  "sfile_related (fi,sec,psec,asecs) f = (fi = Init f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   619
(*
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   620
fun sproc_related :: "t_process \<Rightarrow> t_sproc \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   621
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   622
  "sproc_related p (pi, sec, fds, shms) = (pi = Init p)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   623
*)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   624
fun init_obj_related :: "t_sobject \<Rightarrow> t_object \<Rightarrow> bool"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   625
where
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 15
diff changeset
   626
  "init_obj_related (S_proc (pi, sec, fds, shms) tag) (O_proc p') = (pi = Init p')"
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   627
| "init_obj_related (S_file sfs tag) (O_file f) = (\<exists> sf \<in> sfs. sfile_related sf f)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   628
| "init_obj_related (S_dir sf) (O_dir f) = (sfile_related sf f)"
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 15
diff changeset
   629
| "init_obj_related (S_msgq (qi, sec, sms)) (O_msgq q') = (qi = Init q')"
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 15
diff changeset
   630
| "init_obj_related (S_shm (hi, sec)) (O_shm h') = (hi = Init h')"
56
chunhan
parents: 47
diff changeset
   631
(*
19
ced0fcfbcf8e reprove the top-level dynamic2static
chunhan
parents: 15
diff changeset
   632
| "init_obj_related (S_msg (qi, sec, sms) (mi, secm, tagm)) (O_msg q' m') = (qi = Init q' \<and> mi = Init m')"
56
chunhan
parents: 47
diff changeset
   633
*)
1
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   634
| "init_obj_related _ _ = False"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   635
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   636
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   637
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   638
(***************** for backward proof when Instancing static objects ******************)
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   639
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   640
definition next_nat :: "nat set \<Rightarrow> nat"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   641
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   642
  "next_nat nset = (Max nset) + 1"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   643
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   644
definition new_proc :: "t_state \<Rightarrow> t_process"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   645
where 
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   646
  "new_proc \<tau> = next_nat (current_procs \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   647
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   648
definition new_inode_num :: "t_state \<Rightarrow> nat"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   649
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   650
  "new_inode_num \<tau> = next_nat (current_inode_nums \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   651
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   652
definition new_msgq :: "t_state \<Rightarrow> t_msgq"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   653
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   654
  "new_msgq s = next_nat (current_msgqs s)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   655
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   656
definition new_msg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> nat"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   657
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   658
  "new_msg s q = next_nat (set (msgs_of_queue s q))"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   659
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   660
definition new_shm :: "t_state \<Rightarrow> nat"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   661
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   662
  "new_shm \<tau> = next_nat (current_shms \<tau>)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   663
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   664
definition new_proc_fd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   665
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   666
  "new_proc_fd \<tau> p = next_nat (current_proc_fds \<tau> p)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   667
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   668
definition all_fname_under_dir:: "t_file \<Rightarrow> t_state \<Rightarrow> t_fname set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   669
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   670
  "all_fname_under_dir d \<tau> = {fn. \<exists> f. fn # d = f \<and> f \<in> current_files \<tau>}"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   671
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   672
fun fname_all_a:: "nat \<Rightarrow> t_fname"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   673
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   674
  "fname_all_a 0 = []" |
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   675
  "fname_all_a (Suc n) = ''a''@(fname_all_a n)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   676
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   677
definition fname_length_set :: "t_fname set \<Rightarrow> nat set"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   678
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   679
  "fname_length_set fns = length`fns"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   680
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   681
definition next_fname:: "t_file \<Rightarrow> t_state \<Rightarrow> t_fname"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   682
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   683
  "next_fname pf \<tau> = fname_all_a ((Max (fname_length_set (all_fname_under_dir pf \<tau>))) + 1)"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   684
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   685
definition new_childf:: "t_file \<Rightarrow> t_state \<Rightarrow> t_file"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   686
where
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   687
  "new_childf pf \<tau> = next_fname pf \<tau> # pf"
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   688
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   689
end
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   690
7d9c0ed02b56 thy files
chunhan
parents:
diff changeset
   691
end