00001 /*************************************************** */ 00002 /* Rule Set Based Access Control */ 00003 /* Author and (c) 1999-2005: Amon Ott <ao@rsbac.org> */ 00004 /* Generic lists - internal structures */ 00005 /* Last modified: 01/Apr/2005 */ 00006 /*************************************************** */ 00007 00008 #ifndef __RSBAC_GEN_LISTS_H 00009 #define __RSBAC_GEN_LISTS_H 00010 00011 #include <linux/init.h> 00012 #include <rsbac/rkmem.h> 00013 #include <rsbac/lists.h> 00014 #include <rsbac/repl_lists.h> 00015 00016 #define RSBAC_LIST_DISK_VERSION 10003 00017 #define RSBAC_LIST_DISK_OLD_VERSION 10002 00018 #define RSBAC_LIST_NONAME "(no name)" 00019 #define RSBAC_LIST_PROC_NAME "gen_lists" 00020 00021 #define RSBAC_LIST_TA_KEY 0xface99 00022 00023 /* Prototypes */ 00024 00025 /* Init */ 00026 #ifdef CONFIG_RSBAC_INIT_DELAY 00027 int rsbac_list_init(void); 00028 #else 00029 int __init rsbac_list_init(void); 00030 #endif 00031 00032 /* mount / umount */ 00033 int rsbac_list_mount(kdev_t kdev); 00034 int rsbac_list_umount(kdev_t kdev); 00035 00036 /* Status checking */ 00037 int rsbac_check_lists(int correct); 00038 00039 #if defined(CONFIG_RSBAC_AUTO_WRITE) 00040 int rsbac_write_lists(rsbac_boolean_t need_lock); 00041 #endif 00042 00043 /* Data Structures */ 00044 00045 /* All items will be organized in double linked lists 00046 * However, we do not know the descriptor or item sizes, so we will access them 00047 with offsets later and only define the list links here. 00048 */ 00049 00050 struct rsbac_list_item_t 00051 { 00052 struct rsbac_list_item_t * prev; 00053 struct rsbac_list_item_t * next; 00054 rsbac_time_t max_age; 00055 }; 00056 00057 /* lists of lists ds */ 00058 struct rsbac_list_lol_item_t 00059 { 00060 struct rsbac_list_lol_item_t * prev; 00061 struct rsbac_list_lol_item_t * next; 00062 struct rsbac_list_item_t * head; 00063 struct rsbac_list_item_t * tail; 00064 struct rsbac_list_item_t * curr; 00065 u_long count; 00066 rsbac_time_t max_age; 00067 }; 00068 00069 /* Since all registrations will be organized in double linked lists, we must 00070 * have list items and a list head. 00071 * The pointer to this item will also be used as list handle. */ 00072 00073 typedef __u32 rsbac_list_count_t; 00074 00075 struct rsbac_list_reg_item_t 00076 { 00077 struct rsbac_list_info_t info; 00078 u_int flags; 00079 rsbac_list_compare_function_t * compare; 00080 rsbac_list_get_conv_t * get_conv; 00081 void * def_data; 00082 char name[RSBAC_LIST_MAX_FILENAME+1]; 00083 kdev_t device; 00084 struct rsbac_list_item_t * head; 00085 struct rsbac_list_item_t * tail; 00086 struct rsbac_list_item_t * curr; 00087 rwlock_t lock; 00088 rsbac_list_count_t count; 00089 rsbac_boolean_t dirty; 00090 rsbac_boolean_t no_write; 00091 struct rsbac_nanotime_t lastchange; 00092 #ifdef CONFIG_RSBAC_LIST_TRANS 00093 rsbac_ta_number_t ta_copied; 00094 struct rsbac_list_item_t * ta_head; 00095 struct rsbac_list_item_t * ta_tail; 00096 struct rsbac_list_item_t * ta_curr; 00097 rsbac_list_count_t ta_count; 00098 #endif 00099 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS) 00100 struct proc_dir_entry * proc_entry_p; 00101 #endif 00102 struct rsbac_list_reg_item_t * prev; 00103 struct rsbac_list_reg_item_t * next; 00104 struct rsbac_list_reg_item_t * self; 00105 }; 00106 00107 struct rsbac_list_lol_reg_item_t 00108 { 00109 struct rsbac_list_lol_info_t info; 00110 u_int flags; 00111 rsbac_list_compare_function_t * compare; 00112 rsbac_list_compare_function_t * subcompare; 00113 rsbac_list_get_conv_t * get_conv; 00114 rsbac_list_get_conv_t * get_subconv; 00115 void * def_data; 00116 void * def_subdata; 00117 char name[RSBAC_LIST_MAX_FILENAME+1]; 00118 kdev_t device; 00119 struct rsbac_list_lol_item_t * head; 00120 struct rsbac_list_lol_item_t * tail; 00121 struct rsbac_list_lol_item_t * curr; 00122 rwlock_t lock; 00123 rsbac_list_count_t count; 00124 rsbac_boolean_t dirty; 00125 rsbac_boolean_t no_write; 00126 struct rsbac_nanotime_t lastchange; 00127 #ifdef CONFIG_RSBAC_LIST_TRANS 00128 rsbac_ta_number_t ta_copied; 00129 struct rsbac_list_lol_item_t * ta_head; 00130 struct rsbac_list_lol_item_t * ta_tail; 00131 struct rsbac_list_lol_item_t * ta_curr; 00132 rsbac_list_count_t ta_count; 00133 #endif 00134 #if defined(CONFIG_RSBAC_PROC) && defined(CONFIG_PROC_FS) 00135 struct proc_dir_entry * proc_entry_p; 00136 #endif 00137 struct rsbac_list_lol_reg_item_t * prev; 00138 struct rsbac_list_lol_reg_item_t * next; 00139 struct rsbac_list_lol_reg_item_t * self; 00140 }; 00141 00142 /* To provide consistency we use spinlocks for all list accesses. The 00143 'curr' entry is used to avoid repeated lookups for the same item. */ 00144 00145 struct rsbac_list_reg_head_t 00146 { 00147 struct rsbac_list_reg_item_t * head; 00148 struct rsbac_list_reg_item_t * tail; 00149 struct rsbac_list_reg_item_t * curr; 00150 rwlock_t lock; 00151 u_int count; 00152 }; 00153 00154 struct rsbac_list_lol_reg_head_t 00155 { 00156 struct rsbac_list_lol_reg_item_t * head; 00157 struct rsbac_list_lol_reg_item_t * tail; 00158 struct rsbac_list_lol_reg_item_t * curr; 00159 rwlock_t lock; 00160 u_int count; 00161 }; 00162 00163 /* Internal helper list of filled write buffers */ 00164 00165 struct rsbac_list_write_item_t 00166 { 00167 struct rsbac_list_write_item_t * prev; 00168 struct rsbac_list_write_item_t * next; 00169 struct rsbac_list_reg_item_t * list; 00170 u_long buflen; 00171 char * buf; 00172 rsbac_boolean_t vmalloc_used; 00173 char name[RSBAC_LIST_MAX_FILENAME+1]; 00174 kdev_t device; 00175 }; 00176 00177 struct rsbac_list_write_head_t 00178 { 00179 struct rsbac_list_write_item_t * head; 00180 struct rsbac_list_write_item_t * tail; 00181 u_long total; 00182 u_int count; 00183 }; 00184 00185 struct rsbac_list_lol_write_item_t 00186 { 00187 struct rsbac_list_lol_write_item_t * prev; 00188 struct rsbac_list_lol_write_item_t * next; 00189 struct rsbac_list_lol_reg_item_t * list; 00190 u_long buflen; 00191 char * buf; 00192 rsbac_boolean_t vmalloc_used; 00193 char name[RSBAC_LIST_MAX_FILENAME+1]; 00194 kdev_t device; 00195 }; 00196 00197 struct rsbac_list_lol_write_head_t 00198 { 00199 struct rsbac_list_lol_write_item_t * head; 00200 struct rsbac_list_lol_write_item_t * tail; 00201 u_long total; 00202 u_int count; 00203 }; 00204 00205 00206 /* Data structs for file timeout book keeping list filelist */ 00207 struct rsbac_list_filelist_desc_t 00208 { 00209 char filename[RSBAC_LIST_MAX_FILENAME+1]; 00210 }; 00211 00212 struct rsbac_list_filelist_data_t 00213 { 00214 rsbac_time_t timestamp; 00215 rsbac_time_t max_age; 00216 }; 00217 00218 struct rsbac_list_ta_data_t 00219 { 00220 rsbac_time_t start; 00221 rsbac_time_t timeout; 00222 rsbac_uid_t commit_uid; 00223 char password[RSBAC_LIST_TA_MAX_PASSLEN]; 00224 }; 00225 00226 #endif